diff mbox

dt: bindings: Add a generic ethernet device binding

Message ID 1468405204-5845-1-git-send-email-hdegoede@redhat.com
State Changes Requested, archived
Headers show

Commit Message

Hans de Goede July 13, 2016, 10:20 a.m. UTC
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

Comments

David Miller July 14, 2016, 11:17 p.m. UTC | #1
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.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hans de Goede July 15, 2016, 6:40 a.m. UTC | #2
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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hans de Goede July 15, 2016, 6:44 a.m. UTC | #3
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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller July 15, 2016, 5:51 p.m. UTC | #4
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"
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann July 15, 2016, 8:42 p.m. UTC | #5
On Wednesday, July 13, 2016 12:20:04 PM CEST Hans de Goede wrote:
> +&mmc1 {
> +       non-removable;
> +       status = "okay";
> +
> +       sdio_wifi: sdio_wifi@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

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hans de Goede July 16, 2016, 10:12 a.m. UTC | #6
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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Hans de Goede July 16, 2016, 10:18 a.m. UTC | #7
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@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


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann July 16, 2016, 7:19 p.m. UTC | #8
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@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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller July 17, 2016, 1:02 a.m. UTC | #9
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.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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@1 {
+		compatible = "generic,ethernet"
+		reg = <1>;
+	};
+};