linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dt: bindings: Add a generic ethernet device binding
@ 2016-07-13 10:20 Hans de Goede
  2016-07-14 23:17 ` David Miller
  2016-07-15 20:42 ` Arnd Bergmann
  0 siblings, 2 replies; 10+ messages in thread
From: Hans de Goede @ 2016-07-13 10:20 UTC (permalink / raw)
  To: linux-arm-kernel

On some boards (android tablets) different batches use different sdio
wifi modules. This is not a problem since sdio is a discoverable bus,
so we only need to describe and activate the mmc controller in dt and
then the kernel will automatically load the right driver.

But sometimes it is useful to specify certain ethernet properties for
these "unknown" sdio devices, specifically we want the boot-loader
to be able to set "local-mac-address" as some of these sdio wifi
modules come without an eeprom / without a factory programmed mac
address.

Since the exact device is unknown (differs per batch) we cannot use
a wifi-chip specific compatible. This commit adds a new
"generic,ethernet" binding for use in dt-nodes describing such an
unknown ethernet device.

Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 Documentation/devicetree/bindings/net/generic.txt | 30 +++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/generic.txt

diff --git a/Documentation/devicetree/bindings/net/generic.txt b/Documentation/devicetree/bindings/net/generic.txt
new file mode 100644
index 0000000..2325709
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/generic.txt
@@ -0,0 +1,30 @@
+* Generic ethernet controller
+
+This binding is for ethernet devices which need a dt node so that certain
+standard properties, e.g. a mac-address can be specified via dt, but
+otherwise can be detected automatically as they are on a discoverable bus.
+
+Required properties:
+- compatible: should be "generic,ethernet"
+
+Optional properties:
+- See bindings/ethernet.txt
+
+Example:
+
+/ {
+	aliases {
+		/* Make u-boot set mac-address for the sdio-wifi (no eeprom) */
+		ethernet0 = &sdio_wifi;
+	};
+};
+
+&mmc1 {
+	non-removable;
+	status = "okay";
+
+	sdio_wifi: sdio_wifi at 1 {
+		compatible = "generic,ethernet"
+		reg = <1>;
+	};
+};
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-13 10:20 [PATCH] dt: bindings: Add a generic ethernet device binding Hans de Goede
@ 2016-07-14 23:17 ` David Miller
  2016-07-15  6:40   ` Hans de Goede
  2016-07-15 20:42 ` Arnd Bergmann
  1 sibling, 1 reply; 10+ messages in thread
From: David Miller @ 2016-07-14 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

From: Hans de Goede <hdegoede@redhat.com>
Date: Wed, 13 Jul 2016 12:20:04 +0200

> On some boards (android tablets) different batches use different sdio
> wifi modules. This is not a problem since sdio is a discoverable bus,
> so we only need to describe and activate the mmc controller in dt and
> then the kernel will automatically load the right driver.
> 
> But sometimes it is useful to specify certain ethernet properties for
> these "unknown" sdio devices, specifically we want the boot-loader
> to be able to set "local-mac-address" as some of these sdio wifi
> modules come without an eeprom / without a factory programmed mac
> address.
> 
> Since the exact device is unknown (differs per batch) we cannot use
> a wifi-chip specific compatible. This commit adds a new
> "generic,ethernet" binding for use in dt-nodes describing such an
> unknown ethernet device.
> 
> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Precedence exists for a "system ethernet address" as far back as the
original sparc device tree implementation, so please just specify it
that way rather than trying to force having to make an alias or
reference to it from a specific device.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-14 23:17 ` David Miller
@ 2016-07-15  6:40   ` Hans de Goede
  2016-07-15  6:44     ` Hans de Goede
  2016-07-15 17:51     ` David Miller
  0 siblings, 2 replies; 10+ messages in thread
From: Hans de Goede @ 2016-07-15  6:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 15-07-16 01:17, David Miller wrote:
> From: Hans de Goede <hdegoede@redhat.com>
> Date: Wed, 13 Jul 2016 12:20:04 +0200
>
>> On some boards (android tablets) different batches use different sdio
>> wifi modules. This is not a problem since sdio is a discoverable bus,
>> so we only need to describe and activate the mmc controller in dt and
>> then the kernel will automatically load the right driver.
>>
>> But sometimes it is useful to specify certain ethernet properties for
>> these "unknown" sdio devices, specifically we want the boot-loader
>> to be able to set "local-mac-address" as some of these sdio wifi
>> modules come without an eeprom / without a factory programmed mac
>> address.
>>
>> Since the exact device is unknown (differs per batch) we cannot use
>> a wifi-chip specific compatible. This commit adds a new
>> "generic,ethernet" binding for use in dt-nodes describing such an
>> unknown ethernet device.
>>
>> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>
> Precedence exists for a "system ethernet address" as far back as the
> original sparc device tree implementation, so please just specify it
> that way rather than trying to force having to make an alias or
> reference to it from a specific device.

Some boards where this is applicable have both a wired and a wireless
ethernet, so one global setting will not work.

Regards,

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-15  6:40   ` Hans de Goede
@ 2016-07-15  6:44     ` Hans de Goede
  2016-07-15 17:51     ` David Miller
  1 sibling, 0 replies; 10+ messages in thread
From: Hans de Goede @ 2016-07-15  6:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 15-07-16 08:40, Hans de Goede wrote:
> Hi,
>
> On 15-07-16 01:17, David Miller wrote:
>> From: Hans de Goede <hdegoede@redhat.com>
>> Date: Wed, 13 Jul 2016 12:20:04 +0200
>>
>>> On some boards (android tablets) different batches use different sdio
>>> wifi modules. This is not a problem since sdio is a discoverable bus,
>>> so we only need to describe and activate the mmc controller in dt and
>>> then the kernel will automatically load the right driver.
>>>
>>> But sometimes it is useful to specify certain ethernet properties for
>>> these "unknown" sdio devices, specifically we want the boot-loader
>>> to be able to set "local-mac-address" as some of these sdio wifi
>>> modules come without an eeprom / without a factory programmed mac
>>> address.
>>>
>>> Since the exact device is unknown (differs per batch) we cannot use
>>> a wifi-chip specific compatible. This commit adds a new
>>> "generic,ethernet" binding for use in dt-nodes describing such an
>>> unknown ethernet device.
>>>
>>> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>
>> Precedence exists for a "system ethernet address" as far back as the
>> original sparc device tree implementation, so please just specify it
>> that way rather than trying to force having to make an alias or
>> reference to it from a specific device.
>
> Some boards where this is applicable have both a wired and a wireless
> ethernet, so one global setting will not work.

And besides that, everything used in this binding already exists, it
just adds a new "generic,ethernet" compatible, because e.g. the mmc
bindings specify that the node describing a sdio function _must_
have a compatible, and as explained in some cases we cannot use
a compatible for a specific wifi chip since different batches use
different wifi modules.

About the use of "generic,ethernet" looking at the simple-framebuffer
binding I guess it should be just "ethernet".

Regards,

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-15  6:40   ` Hans de Goede
  2016-07-15  6:44     ` Hans de Goede
@ 2016-07-15 17:51     ` David Miller
  2016-07-16 10:12       ` Hans de Goede
  1 sibling, 1 reply; 10+ messages in thread
From: David Miller @ 2016-07-15 17:51 UTC (permalink / raw)
  To: linux-arm-kernel

From: Hans de Goede <hdegoede@redhat.com>
Date: Fri, 15 Jul 2016 08:40:00 +0200

> Hi,
> 
> On 15-07-16 01:17, David Miller wrote:
>> From: Hans de Goede <hdegoede@redhat.com>
>> Date: Wed, 13 Jul 2016 12:20:04 +0200
>>
>>> On some boards (android tablets) different batches use different sdio
>>> wifi modules. This is not a problem since sdio is a discoverable bus,
>>> so we only need to describe and activate the mmc controller in dt and
>>> then the kernel will automatically load the right driver.
>>>
>>> But sometimes it is useful to specify certain ethernet properties for
>>> these "unknown" sdio devices, specifically we want the boot-loader
>>> to be able to set "local-mac-address" as some of these sdio wifi
>>> modules come without an eeprom / without a factory programmed mac
>>> address.
>>>
>>> Since the exact device is unknown (differs per batch) we cannot use
>>> a wifi-chip specific compatible. This commit adds a new
>>> "generic,ethernet" binding for use in dt-nodes describing such an
>>> unknown ethernet device.
>>>
>>> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>
>> Precedence exists for a "system ethernet address" as far back as the
>> original sparc device tree implementation, so please just specify it
>> that way rather than trying to force having to make an alias or
>> reference to it from a specific device.
> 
> Some boards where this is applicable have both a wired and a wireless
> ethernet, so one global setting will not work.

Then call it "eth:local-mac-address" and "wifi:local-mac-address"

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-13 10:20 [PATCH] dt: bindings: Add a generic ethernet device binding Hans de Goede
  2016-07-14 23:17 ` David Miller
@ 2016-07-15 20:42 ` Arnd Bergmann
  2016-07-16 10:18   ` Hans de Goede
  1 sibling, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2016-07-15 20:42 UTC (permalink / raw)
  To: linux-arm-kernel

On Wednesday, July 13, 2016 12:20:04 PM CEST Hans de Goede wrote:
> +&mmc1 {
> +       non-removable;
> +       status = "okay";
> +
> +       sdio_wifi: sdio_wifi at 1 {
> +               compatible = "generic,ethernet"
> +               reg = <1>;
> +       };
> +};

For discoverable buses, we normally use a compatible property that
reflects the device ID on that bus, e.g. on PCI we have "pci1A2B:3C4D",
and I think that makes more sense than having to come up with strings
for sdio devices.

In fact, Linux completely ignores the compatible strings on those
buses (pci, usb, sdio, ...), so I think we can just do the same thing
using no compatible string at all.

	Arnd

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-15 17:51     ` David Miller
@ 2016-07-16 10:12       ` Hans de Goede
  2016-07-17  1:02         ` David Miller
  0 siblings, 1 reply; 10+ messages in thread
From: Hans de Goede @ 2016-07-16 10:12 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 15-07-16 19:51, David Miller wrote:
> From: Hans de Goede <hdegoede@redhat.com>
> Date: Fri, 15 Jul 2016 08:40:00 +0200
>
>> Hi,
>>
>> On 15-07-16 01:17, David Miller wrote:
>>> From: Hans de Goede <hdegoede@redhat.com>
>>> Date: Wed, 13 Jul 2016 12:20:04 +0200
>>>
>>>> On some boards (android tablets) different batches use different sdio
>>>> wifi modules. This is not a problem since sdio is a discoverable bus,
>>>> so we only need to describe and activate the mmc controller in dt and
>>>> then the kernel will automatically load the right driver.
>>>>
>>>> But sometimes it is useful to specify certain ethernet properties for
>>>> these "unknown" sdio devices, specifically we want the boot-loader
>>>> to be able to set "local-mac-address" as some of these sdio wifi
>>>> modules come without an eeprom / without a factory programmed mac
>>>> address.
>>>>
>>>> Since the exact device is unknown (differs per batch) we cannot use
>>>> a wifi-chip specific compatible. This commit adds a new
>>>> "generic,ethernet" binding for use in dt-nodes describing such an
>>>> unknown ethernet device.
>>>>
>>>> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>
>>> Precedence exists for a "system ethernet address" as far back as the
>>> original sparc device tree implementation, so please just specify it
>>> that way rather than trying to force having to make an alias or
>>> reference to it from a specific device.
>>
>> Some boards where this is applicable have both a wired and a wireless
>> ethernet, so one global setting will not work.
>
> Then call it "eth:local-mac-address" and "wifi:local-mac-address"

Until we get a board with 2 ethernet interfaces, really the alias thing
is working fine here, that is not the problem.

Regards,

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-15 20:42 ` Arnd Bergmann
@ 2016-07-16 10:18   ` Hans de Goede
  2016-07-16 19:19     ` Arnd Bergmann
  0 siblings, 1 reply; 10+ messages in thread
From: Hans de Goede @ 2016-07-16 10:18 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

On 15-07-16 22:42, Arnd Bergmann wrote:
> On Wednesday, July 13, 2016 12:20:04 PM CEST Hans de Goede wrote:
>> +&mmc1 {
>> +       non-removable;
>> +       status = "okay";
>> +
>> +       sdio_wifi: sdio_wifi at 1 {
>> +               compatible = "generic,ethernet"
>> +               reg = <1>;
>> +       };
>> +};
>
> For discoverable buses, we normally use a compatible property that
> reflects the device ID on that bus, e.g. on PCI we have "pci1A2B:3C4D"
> and I think that makes more sense than having to come up with strings
> for sdio devices.

2 things:

1) The problem here is that different batches of the same board
(cheap chinese tablet) have different sdio wifi modules, so we
actually cannot specify a vendor / product id as in your example.

2) In some cases we do want an actual compatible because some devices
have some oob (out-of-band) going with e.g. gpio-s which cannot be
handled by mmc-pwrseq.

> In fact, Linux completely ignores the compatible strings on those
> buses (pci, usb, sdio, ...),

You're mostly right, but at least the brcmfmac driver looks for a
compatible in the mmc-host child node describing its sdio function
to see if it should check for oob irq information there.

> so I think we can just do the same thing
> using no compatible string at all.

I'm all for not using any compatible string at all, actually I submitted
a patch for a sunxi dt file which did that and Maxime pointed out that
the compatible is listed as Required in:
Documentation/devicetree/bindings/mmc/mmc-card.txt

If we can agree to make it optional, then I'll happily submit a patch
with that change and Maxime can take my sunxi dts patch as is :)

Regards,

Hans

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-16 10:18   ` Hans de Goede
@ 2016-07-16 19:19     ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2016-07-16 19:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Saturday, July 16, 2016 12:18:40 PM CEST Hans de Goede wrote:
> Hi,
> 
> On 15-07-16 22:42, Arnd Bergmann wrote:
> > On Wednesday, July 13, 2016 12:20:04 PM CEST Hans de Goede wrote:
> >> +&mmc1 {
> >> +       non-removable;
> >> +       status = "okay";
> >> +
> >> +       sdio_wifi: sdio_wifi at 1 {
> >> +               compatible = "generic,ethernet"
> >> +               reg = <1>;
> >> +       };
> >> +};
> >
> > For discoverable buses, we normally use a compatible property that
> > reflects the device ID on that bus, e.g. on PCI we have "pci1A2B:3C4D"
> > and I think that makes more sense than having to come up with strings
> > for sdio devices.
> 
> 2 things:
> 
> 1) The problem here is that different batches of the same board
> (cheap chinese tablet) have different sdio wifi modules, so we
> actually cannot specify a vendor / product id as in your example.

Right, this is where we have a mismatch between original OF
that did all the device probing and provided the compatible
strings for the OS to use, and the FDT method where the bootloader
does no probing at all but relies on a complete hardware
description to be there already. I have no good solution
for that.

> 2) In some cases we do want an actual compatible because some devices
> have some oob (out-of-band) going with e.g. gpio-s which cannot be
> handled by mmc-pwrseq.

But those are the cases in which we do know the compatible
string (whether we use one from custom binding or from the
generic ID method doesnt' matter).

> > In fact, Linux completely ignores the compatible strings on those
> > buses (pci, usb, sdio, ...),
> 
> You're mostly right, but at least the brcmfmac driver looks for a
> compatible in the mmc-host child node describing its sdio function
> to see if it should check for oob irq information there.

I'm aware of that one, and not really happy with the way it turned
out, because the compatible string in that case identifies the
oldest supported chip for that driver. We normally do that when
the devices are 100% compatible, but that is not the case here
at all, so that binding violates both the conventions for
discoverable buses and those that we use for non-discoverable
buses.

> > so I think we can just do the same thing
> > using no compatible string at all.
> 
> I'm all for not using any compatible string at all, actually I submitted
> a patch for a sunxi dt file which did that and Maxime pointed out that
> the compatible is listed as Required in:
> Documentation/devicetree/bindings/mmc/mmc-card.txt
> 
> If we can agree to make it optional, then I'll happily submit a patch
> with that change and Maxime can take my sunxi dts patch as is :)

Right, I think that would be best, we should at least come up with a
general policy for that case.

	Arnd

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] dt: bindings: Add a generic ethernet device binding
  2016-07-16 10:12       ` Hans de Goede
@ 2016-07-17  1:02         ` David Miller
  0 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2016-07-17  1:02 UTC (permalink / raw)
  To: linux-arm-kernel

From: Hans de Goede <hdegoede@redhat.com>
Date: Sat, 16 Jul 2016 12:12:37 +0200

> Hi,
> 
> On 15-07-16 19:51, David Miller wrote:
>> From: Hans de Goede <hdegoede@redhat.com>
>> Date: Fri, 15 Jul 2016 08:40:00 +0200
>>
>>> Hi,
>>>
>>> On 15-07-16 01:17, David Miller wrote:
>>>> From: Hans de Goede <hdegoede@redhat.com>
>>>> Date: Wed, 13 Jul 2016 12:20:04 +0200
>>>>
>>>>> On some boards (android tablets) different batches use different sdio
>>>>> wifi modules. This is not a problem since sdio is a discoverable bus,
>>>>> so we only need to describe and activate the mmc controller in dt and
>>>>> then the kernel will automatically load the right driver.
>>>>>
>>>>> But sometimes it is useful to specify certain ethernet properties for
>>>>> these "unknown" sdio devices, specifically we want the boot-loader
>>>>> to be able to set "local-mac-address" as some of these sdio wifi
>>>>> modules come without an eeprom / without a factory programmed mac
>>>>> address.
>>>>>
>>>>> Since the exact device is unknown (differs per batch) we cannot use
>>>>> a wifi-chip specific compatible. This commit adds a new
>>>>> "generic,ethernet" binding for use in dt-nodes describing such an
>>>>> unknown ethernet device.
>>>>>
>>>>> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>>
>>>> Precedence exists for a "system ethernet address" as far back as the
>>>> original sparc device tree implementation, so please just specify it
>>>> that way rather than trying to force having to make an alias or
>>>> reference to it from a specific device.
>>>
>>> Some boards where this is applicable have both a wired and a wireless
>>> ethernet, so one global setting will not work.
>>
>> Then call it "eth:local-mac-address" and "wifi:local-mac-address"
> 
> Until we get a board with 2 ethernet interfaces, really the alias
> thing
> is working fine here, that is not the problem.

Fair enough.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-07-17  1:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-13 10:20 [PATCH] dt: bindings: Add a generic ethernet device binding Hans de Goede
2016-07-14 23:17 ` David Miller
2016-07-15  6:40   ` Hans de Goede
2016-07-15  6:44     ` Hans de Goede
2016-07-15 17:51     ` David Miller
2016-07-16 10:12       ` Hans de Goede
2016-07-17  1:02         ` David Miller
2016-07-15 20:42 ` Arnd Bergmann
2016-07-16 10:18   ` Hans de Goede
2016-07-16 19:19     ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).