[U-Boot] [PATCH] sunxi: Add support for eth1addr
Hans de Goede
hdegoede at redhat.com
Thu Jun 30 13:15:58 CEST 2016
Hi,
On 30-06-16 12:50, Ian Campbell wrote:
> On Sun, 2016-06-26 at 13:54 +0200, Hans de Goede wrote:
>> Currently we will already fill ethaddr with a fixed unique address
>> based on the SoCs serial (from the sid) to make sure that boards which
>> use the integrated emac / gmac get a fixed mac rather then a random one.
>>
>> On some boards (observed on 2 tablets using sdio rtl8703as wifi chips)
>> the wifi does not come with a fixed mac either, so also set eth1addr,
>> so that dts files can set an ethernet1 alias to get mac-address and
>> local-mac-address filled for dt nodes describing the wifi controller.
>
> This does it unconditionally, won't having eth1addr show up for boards
> which only have one network device (WIFI or otherwise) be potentially
> confusing for users? i.e. lacking it would be a sign that the online
> guide you are following might not exactly be relevant to your board, or
> people seeing it and then wasting time trying to figure out how to use
> the second device. Of secondary concern (since I think it is far less
> liklely) would be confusing some software somewhere.
>
> Also what is the impact on boards which have a second network device
> which does have a proper MAC address, either one which is part of the
> board or e.g. on a USB dongle? I think we don't want to override any
> burnt in MAC addresses.
This just sets eth1addr in the u-boot env, it will only actually
do something to the devicetree if there is an ethernet1 alias in
there (which there should not be for e.g an usb dongle).
So this can only cause any issues if people add a ethernet1 alias
when they should not.
As for overriding a burnt-in mac-address, if the ethernet1
alias is present then u-boot will only modify a pre-existing
"mac-address" dt property, if none is present it will not
touch it. It will unconditional modify / add a "local-mac-address"
property. Drivers should only honor "local-mac-address" if
there is no burnt-in mac-address, see e.g. :
https://github.com/jwrdegoede/rtl8723bs/commit/be5e87ea71677120ede457213208902ed9942653
Now if users have a driver which honors mac-address to
override the burnt-in mac, and the add an alias ethernet1
and they add an "mac-address" property to the dt node
the ethernet1 alias points to, then they get exactly
what they ask for.
Regards,
Hans
>
> Ian.
>
>>
>> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
>> ---
>> board/sunxi/board.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
>> index b5a50f4..41d796c 100644
>> --- a/board/sunxi/board.c
>> +++ b/board/sunxi/board.c
>> @@ -641,6 +641,18 @@ int misc_init_r(void)
>> eth_setenv_enetaddr("ethaddr", mac_addr);
>> }
>>
>> + if (!getenv("eth1addr")) {
>> + /* Non OUI / registered MAC address */
>> + mac_addr[0] = 0x12;
>> + mac_addr[1] = (sid[0] >> 0) & 0xff;
>> + mac_addr[2] = (sid[3] >> 24) & 0xff;
>> + mac_addr[3] = (sid[3] >> 16) & 0xff;
>> + mac_addr[4] = (sid[3] >> 8) & 0xff;
>> + mac_addr[5] = (sid[3] >> 0) & 0xff;
>> +
>> + eth_setenv_enetaddr("eth1addr", mac_addr);
>> + }
>> +
>> if (!getenv("serial#")) {
>> snprintf(serial_string,
>> sizeof(serial_string),
>> "%08x%08x", sid[0], sid[3]);
More information about the U-Boot
mailing list