[U-Boot] [PATCHv5 00/21] Retrieve MAC address from EEPROM

First off: P.S. Joe, for some reason my previous patches where added with me as: "oliver@schinagl.nl oliver@schinagl.nl" I see that it comes from patchwork as such. Is there some way to fix this to "Olliver Schinagl oliver@schinagl.nl"?
Below the updated summary:
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. The series does a few small cleanups at the start, as either I ran into them while doing this series and fixed them along the way or actually depended on them.
A manufacturer wants to produce boards and may even have MAC addresses for boards. Maintaining unique environments on a per-board basis however is horrible. Also this data should be very persistent, and not easily deletable by simply wiping the environment or device tree. Finally there are chips available on the market with a pre-programmed MAC address chips (proms) that a board manufacturer wants to use. Because of this, the MAC needs to be stored be able to read from such an 'external' source.
The current idea of the eeprom layout, is to skip the first 8 bytes, so that other information can be stored there if needed, for example a header with some magic to identify the EEPROM. Or equivalent purposes.
After those 8 bytes the MAC address follows the first macaddress. The macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes. Following the first macaddress one can store a second, or a third etc etc macaddress.
The CRC8 is optional (via a define) but is strongly recommended to have. It helps preventing user error and more importantly, checks if the bytes read are actually a user inserted address. E.g. only writing 1 macaddress into the eeprom but trying to consume 2.
These patches where tested on Olimex OLinuXino Lime1 (A10/A20), Lime2 (NAND and eMMC) and A20-OLinuXino-MICRO-4G variants and have been in use internally on our production systems since v2 of this patch set.
TODO in a follow up series: * Replace the I2C specific read function to a generic function using Maxime Ripard's EEPROM uclass once merged. * Upgrade to use the EERPOM layout functionality.
======= Changes since v4: * Some patches have been merged, so those are no longer included in the set. * Reworked review comments * Added the source of a MAC address * Made sunxi-gmac a subclassed driver * Switch sunxi-[eg]mac to Kconfig * Drop the FDT injection code for now, this needs more thought/discussion
Changes since v3: * Split off board specific stuff and only modify the generic functions * Make reading of an eeprom available to every board. By default this is unconfigure and thus should just fall through * Clean some minor bits up (ARP_HLEN) and use it more generically * Update the gen_ethaddr_crc as suggested by simon * Let the fixup_ethernet from fdt_common insert mac addresses to the environment for unconfigured devices. There is a small caveat here however as described in the TODO above. * Print the mac address that u-boot assigned to each device.
Changes since v2: * Drop the id byte altogether and just mark it as reserved. The 'index' can be used to indicate the interface instead * Addopt the read_rom_hwaddr hooks * Renamed crc8 tool to gen_ethaddr_crc * Improved the layout EEPROM example * Made a function out of the hwaddress writing function in sunxi_emac so it can be re-used as the write_hwaddr net_ops hook. * No longer handle fdt parameters in board.c
Changes since v1: * Do not CRC the id byte, move it just after the crc byte. One of the reasons I decided to move it after the crc8 was mostly due to mass generation of MAC + CRC combo's where the ID is still unknown. Also not crc-ing the ID means that it is much easier for a user to change it (via the u-boot i2c cmd line or from within linux) without having to worry about the crc. * Add a generator to convert a MAC address from the input to a MAC + CRC8 on the output.
Olliver Schinagl (21): net: cosmetic: Do not use magic values for ARP_HLEN net: core: Sanitize get/set operations for enetaddr net: core: Inform the user of the device MAC address net: core: Add function to check/set MAC locality net: Add ability to set MAC address via EEPROM net: core: print the source of the MAC address net: cosmetic: A MAC address is not limited to SROM fdt: fixup_eth: Remove code duplication with a function fdt: fixup_eth: improve error catching/reduce identation net: sunxi: Enable I2C bus set via NET_ETHADDR_EEPROM_I2C_BUS net: sunxi_[eg]mac: Convert to Kconfig arm: sunxi: Expose function to generate sunxi-specific a MAC address net: sunxi_emac: Write HW address via net_ops hook net: sunxi: Have sunxi common functions together net: sunxi_emac: Add read_rom_hwaddr hook net: sunxi_gmac: Make the sunxi variant of dw driver a subclass net: dw: Expose designware_eth_start net: sunxi_gmac: Add read_rom_hwaddr hook net: sun8i_gmac: Add read_rom_hwaddr hook net: sun8i: fix whitespace net: core: Check return value of read_rom_hwaddr
arch/arm/include/asm/arch-sunxi/sys_proto.h | 7 +- arch/arm/mach-sunxi/board.c | 1 - board/sunxi/Kconfig | 4 + board/sunxi/Makefile | 1 - board/sunxi/board.c | 145 ++++++++++++++++--------- common/fdt_support.c | 33 +++--- configs/A10-OLinuXino-Lime_defconfig | 4 +- configs/A10s-OLinuXino-M_defconfig | 2 +- configs/A20-OLinuXino-Lime2_defconfig | 5 +- configs/A20-OLinuXino-Lime_defconfig | 5 +- configs/A20-OLinuXino_MICRO_defconfig | 5 +- configs/A20-Olimex-SOM-EVB_defconfig | 4 +- configs/Bananapi_defconfig | 4 +- configs/Bananapro_defconfig | 4 +- configs/CSQ_CS908_defconfig | 3 +- configs/Colombus_defconfig | 4 +- configs/Cubieboard2_defconfig | 4 +- configs/Cubieboard_defconfig | 3 +- configs/Cubietruck_defconfig | 4 +- configs/Hummingbird_A31_defconfig | 4 +- configs/Itead_Ibox_A20_defconfig | 4 +- configs/Lamobo_R1_defconfig | 4 +- configs/Linksprite_pcDuino3_Nano_defconfig | 4 +- configs/Linksprite_pcDuino3_defconfig | 4 +- configs/Linksprite_pcDuino_defconfig | 2 +- configs/Marsboard_A10_defconfig | 2 +- configs/Mele_A1000G_quad_defconfig | 3 +- configs/Mele_A1000_defconfig | 3 +- configs/Mele_I7_defconfig | 3 +- configs/Mele_M3_defconfig | 3 +- configs/Mele_M5_defconfig | 3 +- configs/Mele_M9_defconfig | 3 +- configs/Orangepi_defconfig | 4 +- configs/Orangepi_mini_defconfig | 4 +- configs/Sinlinx_SinA31s_defconfig | 3 +- configs/Sinovoip_BPI_M2_defconfig | 4 +- configs/Wits_Pro_A20_DKT_defconfig | 4 +- configs/ba10_tv_box_defconfig | 2 +- configs/i12-tvbox_defconfig | 4 +- configs/icnova-a20-swac_defconfig | 4 +- configs/jesurun_q5_defconfig | 3 +- configs/mixtile_loftq_defconfig | 4 +- doc/README.enetaddr | 99 +++++++++++++++++ drivers/net/Kconfig | 33 +++++- drivers/net/Makefile | 5 +- drivers/net/designware.c | 3 +- drivers/net/designware.h | 1 + drivers/net/sun8i_emac.c | 15 ++- drivers/net/sunxi_common.c | 33 ++++++ drivers/net/sunxi_common.h | 13 +++ drivers/net/sunxi_emac.c | 15 +++ board/sunxi/gmac.c => drivers/net/sunxi_gmac.c | 54 ++++++++- include/configs/sunxi-common.h | 5 - include/net.h | 53 ++++++++- net/Kconfig | 59 ++++++++++ net/eth-uclass.c | 65 ++++++----- net/eth_common.c | 53 ++++++++- net/eth_legacy.c | 7 +- 58 files changed, 626 insertions(+), 207 deletions(-) create mode 100644 drivers/net/sunxi_common.c create mode 100644 drivers/net/sunxi_common.h rename board/sunxi/gmac.c => drivers/net/sunxi_gmac.c (67%)

Previously overlooked magic value in commit a40db6d51171 ("net: cosmetic: Do not use magic values for ARP_HLEN")
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- net/eth_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/eth_common.c b/net/eth_common.c index 58fa295771..049c1ee6f9 100644 --- a/net/eth_common.c +++ b/net/eth_common.c @@ -17,7 +17,7 @@ void eth_parse_enetaddr(const char *addr, uchar *enetaddr) char *end; int i;
- for (i = 0; i < 6; ++i) { + for (i = 0; i < ARP_HLEN; ++i) { enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0; if (addr) addr = (*end) ? end + 1 : end;

On 10 April 2017 at 09:33, Olliver Schinagl oliver@schinagl.nl wrote:
Previously overlooked magic value in commit a40db6d51171 ("net: cosmetic: Do not use magic values for ARP_HLEN")
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
net/eth_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Apr 10, 2017 at 10:33 AM, Olliver Schinagl oliver@schinagl.nl wrote:
Previously overlooked magic value in commit a40db6d51171 ("net: cosmetic: Do not use magic values for ARP_HLEN")
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
Acked-by: Joe Hershberger joe.hershberger@ni.com

In the current net stack, we have a few functions to get and set the "ethaddr" and "ethNaddr" environment variables, which use magic values to get and set these environment variables. Remove the magicness of the buffer by defining it proper and also check the input for its length.
Additionally use the define in fdt parser where the ethaddr variables are also used.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- common/fdt_support.c | 2 +- include/net.h | 1 + net/eth_common.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c index c6a76b7ad2..d462bf0642 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -471,7 +471,7 @@ void fdt_fixup_ethernet(void *fdt) { int i, j, prop; char *tmp, *end; - char mac[16]; + char mac[ETH_ENETADDR_ENV_NAME_LEN]; const char *path; unsigned char mac_addr[ARP_HLEN]; int offset; diff --git a/include/net.h b/include/net.h index ed5259a807..b4af8eaae4 100644 --- a/include/net.h +++ b/include/net.h @@ -243,6 +243,7 @@ void eth_set_current(void); /* set nterface to ethcur var */
int eth_get_dev_index(void); /* get the device index */ void eth_parse_enetaddr(const char *addr, uchar *enetaddr); +#define ETH_ENETADDR_ENV_NAME_LEN 32 int eth_getenv_enetaddr(const char *name, uchar *enetaddr); int eth_setenv_enetaddr(const char *name, const uchar *enetaddr);
diff --git a/net/eth_common.c b/net/eth_common.c index 049c1ee6f9..0fe4d260d8 100644 --- a/net/eth_common.c +++ b/net/eth_common.c @@ -45,16 +45,20 @@ int eth_setenv_enetaddr(const char *name, const uchar *enetaddr) int eth_getenv_enetaddr_by_index(const char *base_name, int index, uchar *enetaddr) { - char enetvar[32]; - sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); + char enetvar[ETH_ENETADDR_ENV_NAME_LEN]; + + snprintf(enetvar, ETH_ENETADDR_ENV_NAME_LEN, + index ? "%s%daddr" : "%saddr", base_name, index); return eth_getenv_enetaddr(enetvar, enetaddr); }
int eth_setenv_enetaddr_by_index(const char *base_name, int index, uchar *enetaddr) { - char enetvar[32]; - sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index); + char enetvar[ETH_ENETADDR_ENV_NAME_LEN]; + + snprintf(enetvar, ETH_ENETADDR_ENV_NAME_LEN, + index ? "%s%daddr" : "%saddr", base_name, index); return eth_setenv_enetaddr(enetvar, enetaddr); }
@@ -72,7 +76,7 @@ void eth_common_init(void)
int eth_mac_skip(int index) { - char enetvar[15]; + char enetvar[ETH_ENETADDR_ENV_NAME_LEN]; char *skip_state;
sprintf(enetvar, index ? "eth%dmacskip" : "ethmacskip", index);

On 10 April 2017 at 09:33, Olliver Schinagl oliver@schinagl.nl wrote:
In the current net stack, we have a few functions to get and set the "ethaddr" and "ethNaddr" environment variables, which use magic values to get and set these environment variables. Remove the magicness of the buffer by defining it proper and also check the input for its length.
Additionally use the define in fdt parser where the ethaddr variables are also used.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
common/fdt_support.c | 2 +- include/net.h | 1 + net/eth_common.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 6 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

In certain conditions we currently print the MAC address. For example a warning when a random mac address is in use or a missmatch between HW and ENV.
If all things went well however (but even if there is a miss-match) we do not inform the user what the final MAC address of the device is.
Lets print the final MAC address of the device with which it has been setup.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- net/eth-uclass.c | 9 ++++++--- net/eth_legacy.c | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index c3cc3152a2..781376955a 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -413,11 +413,12 @@ int eth_initialize(void) }
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT); + putc('\n'); do { - if (num_devices) - printf(", "); + struct eth_pdata *pdata = dev->platdata;
- printf("eth%d: %s", dev->seq, dev->name); + printf("eth%d: %s [%pM]\n", dev->seq, dev->name, + pdata->enetaddr);
if (ethprime && dev == prime_dev) printf(" [PRIME]"); @@ -525,6 +526,8 @@ static int eth_post_probe(struct udevice *dev) #endif }
+ printf("%s ", dev->name); + return 0; }
diff --git a/net/eth_legacy.c b/net/eth_legacy.c index e4bd0f4c1a..687763682a 100644 --- a/net/eth_legacy.c +++ b/net/eth_legacy.c @@ -179,6 +179,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, dev->name); }
+ printf("%s (eth%d) has MAC address: %pM\n", + dev->name, eth_number, dev->enetaddr); + return ret; }

Hi Oliver,
On 10 April 2017 at 09:33, Olliver Schinagl oliver@schinagl.nl wrote:
In certain conditions we currently print the MAC address. For example a warning when a random mac address is in use or a missmatch between HW and ENV.
If all things went well however (but even if there is a miss-match) we do not inform the user what the final MAC address of the device is.
Lets print the final MAC address of the device with which it has been setup.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
net/eth-uclass.c | 9 ++++++--- net/eth_legacy.c | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index c3cc3152a2..781376955a 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -413,11 +413,12 @@ int eth_initialize(void) }
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
putc('\n'); do {
if (num_devices)
printf(", ");
struct eth_pdata *pdata = dev->platdata;
printf("eth%d: %s", dev->seq, dev->name);
printf("eth%d: %s [%pM]\n", dev->seq, dev->name,
pdata->enetaddr); if (ethprime && dev == prime_dev) printf(" [PRIME]");
@@ -525,6 +526,8 @@ static int eth_post_probe(struct udevice *dev) #endif }
printf("%s ", dev->name);
return 0;
}
diff --git a/net/eth_legacy.c b/net/eth_legacy.c index e4bd0f4c1a..687763682a 100644 --- a/net/eth_legacy.c +++ b/net/eth_legacy.c @@ -179,6 +179,9 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, dev->name); }
printf("%s (eth%d) has MAC address: %pM\n",
dev->name, eth_number, dev->enetaddr);
As a general rule I don't think we should be adding new features to legacy code. If people want the new features they can switch over to driver model.
Regards, Simon

Universally administered and locally administered addresses are distinguished by setting the second-least-significant bit of the first octet of the address. Having a function to check and set this U/L bit from a function makes it nice for boards that want to generate their own mac address to ensure they are locally administered.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- include/net.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/include/net.h b/include/net.h index b4af8eaae4..b1d6f05a76 100644 --- a/include/net.h +++ b/include/net.h @@ -779,6 +779,28 @@ static inline int is_multicast_ethaddr(const u8 *addr) return 0x01 & addr[0]; }
+/** + * is_local_ethaddr - Determine if the Ethernet address is a locally + * administered MAC address. + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Return true if the address is a locally administered address. + */ +static inline int is_local_ethaddr(const u8 *addr) +{ + return 0x02 & addr[0]; +} + +/** + * set_local_ethaddr - Make the supplied Ethernet address a locally + * administered one. + * @addr: Pointer to a six-byte array containing the Ethernet address + */ +static inline void set_local_ethaddr(u8 *addr) +{ + addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ +} + /* * is_broadcast_ethaddr - Determine if the Ethernet address is broadcast * @addr: Pointer to a six-byte array containing the Ethernet address @@ -823,7 +845,7 @@ static inline void net_random_ethaddr(uchar *addr) addr[i] = rand_r(&seed);
addr[0] &= 0xfe; /* clear multicast bit */ - addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ + set_local_ethaddr(addr); }
/* Convert an IP address to a string */

A first comment I have myself, which will go in a v3 (or as a separate patch after this has been merged):
On 10-04-17 17:33, Olliver Schinagl wrote:
Universally administered and locally administered addresses are distinguished by setting the second-least-significant bit of the first octet of the address. Having a function to check and set this U/L bit from a function makes it nice for boards that want to generate their own mac address to ensure they are locally administered.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl
include/net.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/include/net.h b/include/net.h index b4af8eaae4..b1d6f05a76 100644 --- a/include/net.h +++ b/include/net.h @@ -779,6 +779,28 @@ static inline int is_multicast_ethaddr(const u8 *addr) return 0x01 & addr[0]; }
0x01 can be a defien,
+/**
- is_local_ethaddr - Determine if the Ethernet address is a locally
administered MAC address.
- @addr: Pointer to a six-byte array containing the Ethernet address
- Return true if the address is a locally administered address.
- */
+static inline int is_local_ethaddr(const u8 *addr) +{
- return 0x02 & addr[0];
0x02 can be a define as well
+}
+/**
- set_local_ethaddr - Make the supplied Ethernet address a locally
administered one.
- @addr: Pointer to a six-byte array containing the Ethernet address
- */
+static inline void set_local_ethaddr(u8 *addr) +{
- addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
+}
/*
- is_broadcast_ethaddr - Determine if the Ethernet address is broadcast
- @addr: Pointer to a six-byte array containing the Ethernet address
@@ -823,7 +845,7 @@ static inline void net_random_ethaddr(uchar *addr) addr[i] = rand_r(&seed);
addr[0] &= 0xfe; /* clear multicast bit */
- addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
- set_local_ethaddr(addr);
}
/* Convert an IP address to a string */

This patch allows Kconfig to enable and set parameters to make it possible to read the MAC address from an EEPROM. The net core layer then uses this information to read MAC addresses from this EEPROM.
Besides the various tuneables as to how to access the eeprom (bus, address, addressing mode/length, 2 configurable that are EEPROM generic (e.g. SPI or some other form of access) which are:
NET_ETHADDR_EEPROM_OFFSET, indicating where in the EEPROM the start of the MAC address is. The default is 8 allowing for 8 bytes before the MAC for other purposes (header MAGIC for example).
NET_ETHADDR_EEPROM_CRC8, indicating the MAC is appended with a CRC8-CCIT checksum that should be verified.
Currently only I2C eeproms have been tested and thus only those options are available, but shouldn't be a limit. NET_ETHADDR_EEPROM_SPI can be just as created and added.
The code currently first checks if there is a non-zero MAC address in the eeprom. If that fails to be the case, the read_rom_hwaddr can be used by a board to supply the MAC in other ways.
If both these fails, the other code is still in place to query the environent, which then can be used to override the hardware supplied data.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- doc/README.enetaddr | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++ include/net.h | 14 ++++++++ net/Kconfig | 59 +++++++++++++++++++++++++++++++ net/eth-uclass.c | 42 +++++++++++------------ net/eth_common.c | 37 ++++++++++++++++++++ net/eth_legacy.c | 2 ++ 6 files changed, 231 insertions(+), 22 deletions(-)
diff --git a/doc/README.enetaddr b/doc/README.enetaddr index 50e4899787..89c1f7d6b4 100644 --- a/doc/README.enetaddr +++ b/doc/README.enetaddr @@ -47,6 +47,105 @@ Correct flow of setting up the MAC address (summarized): Previous behavior had the MAC address always being programmed into hardware in the device's init() function.
+-------- + EEPROM +-------- + +Boards may come with an EEPROM specifically to store configuration bits, such +as a MAC address. Using CONFIG_NET_ETHADDR_EEPROM enables this feature. +Depending on the board, the EEPROM may be connected on various methods, but +currently, only the I2C bus can be used via CONFIG_NET_ETHADDR_EEPROM_I2C. + +The following config options are available, +CONFIG_NET_ETHADDR_EEPROM_I2C_BUS is the I2C bus on which the eeprom is present. +CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR sets the address of the EEPROM, which +defaults to the very common 0x50. Small size EEPROM's generally use single byte +addressing but larger EEPROM's may use double byte addressing, which can be +configured using CONFIG_NET_ETHADDR_EEPROM_ADDRLEN. + +Within the EEPROM, the MAC address can be stored on any arbitrary offset, +CONFIG_NET_ETHADDR_EEPROM_OFFSET sets this to 8 as a default however, allowing +the first 8 bytes to be used for an optional data, for example a configuration +struct where the mac address is part of. + +Appending the 6 (ARP_HLEN) bytes is a CRC8 byte over the previous ARP_HLEN +bytes. Whether to check this CRC8 or not is dependent on +CONFIG_NET_ETHADDR_EEPROM_CRC8. + +To keep things nicely aligned, a final 'reserved' byte is added to the mac +address + crc8 combo. + +A board may want to store more information in its eeprom, using the following +example layout, this can be achieved. + +struct mac_addr { + uint8_t mac[ARP_HLEN]; + uint8_t crc8; + uint8_t reserved; +}; + +struct config_eeprom { + uint32_t magic; + uint8_t version; + uint8_t reserved[2]; + uint8_t mac_cnt; + struct mac_addr[mac_cnt]; +}; + +Filling this in: +struct config_eeprom eeprom = { + .magic = { 'M', 'g', 'i', 'c' }, + .reserved = { 0x00, 0x00 }, + .mac_cnt = 2, + .mac_addr = { + { + .mac = { + 0x01, 0x23, 0x45, + 0x67, 0x89, 0xab, + }, + .crc8 = 0xbe, + .reserved = 0x00, + }, { + .mac = { + 0xba, 0x98, 0x76, + 0x54, 0x32, 0x10, + }, + .crc8 = 0x82, + .reserved = 0x00, + }, + }, +}; + +The eeprom content would look like this. + +00000000 4d 67 69 63 01 00 00 02 01 23 45 67 89 ab be 00 |Mgic.....#Eg....| +00000010 ba 98 76 54 32 10 82 00 |..vT2...| + +This can be done from linux using the i2c-tools: + +i2cset I2CBUS 0x50 0x08 0x01 +i2cset I2CBUS 0x50 0x09 0x23 +i2cset I2CBUS 0x50 0x0a 0x45 +i2cset I2CBUS 0x50 0x0b 0x67 +i2cset I2CBUS 0x50 0x0c 0x89 +i2cset I2CBUS 0x50 0x0d 0xab +i2cset I2CBUS 0x50 0x0e 0xbe + +Alternativly this can be done from the u-boot console as: + +u-boot> mm.b 0 +00000000: 00 ? 01 +00000001: 23 ? 23 +00000002: 45 ? 45 +00000003: 67 ? 67 +00000004: 89 ? 89 +00000005: ab ? ab +00000006: be ? be +00000007: 00 ? q +i2c dev I2CBUS +i2c write 0 50 8 7 +i2c md 50 8 + ------- Usage ------- diff --git a/include/net.h b/include/net.h index b1d6f05a76..7c66f3f06d 100644 --- a/include/net.h +++ b/include/net.h @@ -248,6 +248,20 @@ int eth_getenv_enetaddr(const char *name, uchar *enetaddr); int eth_setenv_enetaddr(const char *name, const uchar *enetaddr);
/** + * eeprom_read_enetaddr() - Read the hardware address from an eeprom + * + * This function tries to read the MAC address from an eeprom as can be read + * in docs/README.enetaddr. + * + * @index: index of the interface to get the hwaddr for + * @enetaddr: pointer for the found hwaddr. Needs to be atleast ARP_HLEN + * @return: 0 on success, non-zero is error status. Additionally hwaddr + * is set to 00:00:00:00:00. This is also the case if + * CONFIG_NET_ETHADDR_EEPROM is not set. + */ +int eeprom_read_enetaddr(const int index, unsigned char *enetaddr); + +/** * eth_setenv_enetaddr_by_index() - set the MAC address environment variable * * This sets up an environment variable with the given MAC address (@enetaddr). diff --git a/net/Kconfig b/net/Kconfig index 414c5497c7..ed7706c428 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -7,6 +7,65 @@ menuconfig NET
if NET
+config NET_ETHADDR_EEPROM + bool "Get ethaddr from eeprom" + help + Selecting this will try to get the Ethernet address from an onboard + EEPROM and set into the environment if and only if the environment + does currently not already hold a MAC address. For more information + see doc/README.enetaddr. + +config NET_ETHADDR_EEPROM_I2C + depends on NET_ETHADDR_EEPROM + bool "EEPROM on I2C bus" + help + This switch enables checks for an EEPROM on the I2C bus. Naturally + this will only work if there is an actual EEPROM connected on the + I2C bus and the bus and device are properly configured via the + options below. + +config NET_ETHADDR_EEPROM_I2C_BUS + depends on NET_ETHADDR_EEPROM_I2C + int "I2C bus" + default 0 + help + Select the bus on which the EEPROM is present, defaults to bus 0. + Remember to also make the selected bus available via I2Cn_ENABLE. + +config NET_ETHADDR_EEPROM_I2C_ADDR + depends on NET_ETHADDR_EEPROM_I2C + hex "EEPROM address" + default 0x50 + help + Select the address of the EEPROM, defaults to address 0x50. + +config NET_ETHADDR_EEPROM_I2C_ADDRLEN + depends on NET_ETHADDR_EEPROM_I2C + int "EEPROM address length" + default 1 + help + Number of bytes to be used for the I2C address length. Typically 1, + 2 for large memories, 0 for register type devices with only one + register. + +config NET_ETHADDR_EEPROM_OFFSET + depends on NET_ETHADDR_EEPROM + hex "EEPROM offset" + default 8 + help + Select the byte offset of the MAC address within the page, + defaults to byte 8. + +config NET_ETHADDR_EEPROM_CRC8 + depends on NET_ETHADDR_EEPROM + bool "Check CRC8 of MAC" + default y + help + Optionally, it is possible to run a CRC-8-CCITT check on the MAC + address. To do so, the MAC address is stored with a CRC8 byte append. + This option enables the CRC check of the MAC address against the CRC + byte. + config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" select LIB_RAND diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 781376955a..02ee926f74 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -459,7 +459,8 @@ static int eth_post_probe(struct udevice *dev) { struct eth_device_priv *priv = dev->uclass_priv; struct eth_pdata *pdata = dev->platdata; - unsigned char env_enetaddr[ARP_HLEN]; + unsigned char env_enetaddr[ARP_HLEN] = { 0x00 }; + int ret;
#if defined(CONFIG_NEEDS_MANUAL_RELOC) struct eth_ops *ops = eth_get_ops(dev); @@ -490,38 +491,35 @@ static int eth_post_probe(struct udevice *dev) #endif
priv->state = ETH_STATE_INIT; + pdata->enetaddr_src = ENETADDR_SRC_UNKNOWN; + + /* Check if the device has a MAC address in EEPROM */ + ret = eeprom_read_enetaddr(dev->seq, pdata->enetaddr); + if (!ret && !is_zero_ethaddr(pdata->enetaddr)) + pdata->enetaddr_src = ENETADDR_SRC_EEPROM; + else + /* Check if the device driver has a MAC address */ + if (eth_get_ops(dev)->read_rom_hwaddr) { + eth_get_ops(dev)->read_rom_hwaddr(dev); + pdata->enetaddr_src = ENETADDR_SRC_DRIVER; + }
- /* Check if the device has a MAC address in ROM */ - if (eth_get_ops(dev)->read_rom_hwaddr) - eth_get_ops(dev)->read_rom_hwaddr(dev); - + /* Check the environment for a MAC address */ eth_getenv_enetaddr_by_index("eth", dev->seq, env_enetaddr); if (!is_zero_ethaddr(env_enetaddr)) { - if (!is_zero_ethaddr(pdata->enetaddr) && - memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) { - printf("\nWarning: %s MAC addresses don't match:\n", - dev->name); - printf("Address in ROM is %pM\n", - pdata->enetaddr); - printf("Address in environment is %pM\n", - env_enetaddr); - } - - /* Override the ROM MAC address */ + /* Override the (EEP)ROM MAC address */ memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN); + pdata->enetaddr_src = ENETADDR_SRC_ENV; } else if (is_valid_ethaddr(pdata->enetaddr)) { eth_setenv_enetaddr_by_index("eth", dev->seq, pdata->enetaddr); - printf("\nWarning: %s using MAC address from ROM\n", - dev->name); } else if (is_zero_ethaddr(pdata->enetaddr) || !is_valid_ethaddr(pdata->enetaddr)) { + /* No valid MAC addresses found, fall back */ #ifdef CONFIG_NET_RANDOM_ETHADDR net_random_ethaddr(pdata->enetaddr); - printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", - dev->name, dev->seq, pdata->enetaddr); + pdata->enetaddr_src = ENETADDR_SRC_RANDOM; #else - printf("\nError: %s address not set.\n", - dev->name); + pdata->enetaddr_src = ENETADDR_SRC_NONE; return -EINVAL; #endif } diff --git a/net/eth_common.c b/net/eth_common.c index 0fe4d260d8..24488746c9 100644 --- a/net/eth_common.c +++ b/net/eth_common.c @@ -8,10 +8,47 @@
#include <common.h> #include <dm.h> +#include <i2c.h> #include <miiphy.h> #include <net.h> #include "eth_internal.h"
+int eeprom_read_enetaddr(const int index, unsigned char *enetaddr) +{ + uint8_t eeprom[ARP_HLEN + 1] = { 0x00 }; +#if defined(CONFIG_NET_ETHADDR_EEPROM) && defined(CONFIG_NET_ETHADDR_EEPROM_I2C) + int old_i2c_bus; + + if ((index < 0) && !enetaddr) + return -ENOSYS; + + old_i2c_bus = i2c_get_bus_num(); + if (old_i2c_bus != CONFIG_NET_ETHADDR_EEPROM_I2C_BUS) + i2c_set_bus_num(CONFIG_NET_ETHADDR_EEPROM_I2C_BUS); + /* Skip in blocks of 8 (ARP + CRC8 + pad), but read 7 from the eeprom */ + if (i2c_read(CONFIG_NET_ETHADDR_EEPROM_I2C_ADDR, + CONFIG_NET_ETHADDR_EEPROM_OFFSET + (index * (ARP_HLEN + 2)), + CONFIG_NET_ETHADDR_EEPROM_I2C_ADDRLEN, + eeprom, ARP_HLEN + 1)) { + i2c_set_bus_num(old_i2c_bus); + puts("Could not read I2C EEPROM or EEPROM missing on device: "); + return -ENOSYS; + } + i2c_set_bus_num(old_i2c_bus); + +#ifdef CONFIG_NET_ETHADDR_EEPROM_CRC8 + if (crc8(0, eeprom, ARP_HLEN) != eeprom[ARP_HLEN]) { + puts("CRC error on MAC address from I2C EEPROM on device: "); + return -EINVAL; + } +#endif +#endif + + memcpy(enetaddr, eeprom, ARP_HLEN); + + return 0; +} + void eth_parse_enetaddr(const char *addr, uchar *enetaddr) { char *end; diff --git a/net/eth_legacy.c b/net/eth_legacy.c index 687763682a..ca63e43c1d 100644 --- a/net/eth_legacy.c +++ b/net/eth_legacy.c @@ -137,6 +137,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, unsigned char env_enetaddr[ARP_HLEN]; int ret = 0;
+ eeprom_read_enetaddr(eth_number, dev->enetaddr); + eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);
if (!is_zero_ethaddr(env_enetaddr)) {

With many potential places where a MAC address can be read from, the user may not know where the MAC address originated from. Print the MAC source after initializing the Ethernet device.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- include/net.h | 14 ++++++++++++++ net/eth-uclass.c | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/include/net.h b/include/net.h index 7c66f3f06d..3eb5f81ea5 100644 --- a/include/net.h +++ b/include/net.h @@ -87,18 +87,32 @@ enum eth_state_t { ETH_STATE_ACTIVE };
+enum enetaddr_source { + ENETADDR_SRC_UNKNOWN = 0, + ENETADDR_SRC_ROM, + ENETADDR_SRC_EEPROM, + ENETADDR_SRC_DRIVER, + ENETADDR_SRC_BOARD, + ENETADDR_SRC_ENV, + ENETADDR_SRC_FDT, + ENETADDR_SRC_RANDOM, + ENETADDR_SRC_NONE, +}; + #ifdef CONFIG_DM_ETH /** * struct eth_pdata - Platform data for Ethernet MAC controllers * * @iobase: The base address of the hardware registers * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env + * @enetaddr_source: Indicator where the Ethernet MAC adress came from * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... * @max_speed: Maximum speed of Ethernet connection supported by MAC */ struct eth_pdata { phys_addr_t iobase; unsigned char enetaddr[ARP_HLEN]; + enum enetaddr_source enetaddr_src; int phy_interface; int max_speed; }; diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 02ee926f74..c88b032868 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -416,9 +416,21 @@ int eth_initialize(void) putc('\n'); do { struct eth_pdata *pdata = dev->platdata; - - printf("eth%d: %s [%pM]\n", dev->seq, dev->name, - pdata->enetaddr); + const char *enetaddr_src[] = { + "unknown", + "ROM", + "EEPROM", + "driver", + "board", + "environment", + "flattened device tree", + "randomly generated", + "not set", + }; + + printf("eth%d: %s [%pM] (%s)\n", dev->seq, dev->name, + pdata->enetaddr, + enetaddr_src[pdata->enetaddr_src]);
if (ethprime && dev == prime_dev) printf(" [PRIME]");

Currently, we print that the MAC from the SROM does not match. It can be many forms of ROM, so lets drop the S.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- net/eth_legacy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/eth_legacy.c b/net/eth_legacy.c index ca63e43c1d..8c3a1750ea 100644 --- a/net/eth_legacy.c +++ b/net/eth_legacy.c @@ -146,7 +146,7 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, memcmp(dev->enetaddr, env_enetaddr, ARP_HLEN)) { printf("\nWarning: %s MAC addresses don't match:\n", dev->name); - printf("Address in SROM is %pM\n", + printf("Address in ROM is %pM\n", dev->enetaddr); printf("Address in environment is %pM\n", env_enetaddr);

In fdt_support.c we use a loop to parse the mac address string from the fdt blob, net.h has a function for this however, so lets use it.
Also, rename the variable from tmp to something more descriptive.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- common/fdt_support.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c index d462bf0642..4d05465232 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -469,8 +469,8 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
void fdt_fixup_ethernet(void *fdt) { - int i, j, prop; - char *tmp, *end; + int i, prop; + char *fdt_eth_addr; char mac[ETH_ENETADDR_ENV_NAME_LEN]; const char *path; unsigned char mac_addr[ARP_HLEN]; @@ -509,16 +509,11 @@ void fdt_fixup_ethernet(void *fdt) } else { continue; } - tmp = getenv(mac); - if (!tmp) + fdt_eth_addr = getenv(mac); + if (!fdt_eth_addr) continue;
- for (j = 0; j < 6; j++) { - mac_addr[j] = tmp ? - simple_strtoul(tmp, &end, 16) : 0; - if (tmp) - tmp = (*end) ? end + 1 : end; - } + eth_parse_enetaddr(fdt_eth_addr, mac_addr);
do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);

Currently when checking for an error in ethernet aliases in the fdt, we only check for the error case -1. It is safer to ignore anything < 0.
By rearranging logic a bit we can now also reduce identation.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- common/fdt_support.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c index 4d05465232..71cbee43e0 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -501,20 +501,20 @@ void fdt_fixup_ethernet(void *fdt) else i = trailing_strtol(name);
- if (i != -1) { - if (i == 0) - strcpy(mac, "ethaddr"); - else - sprintf(mac, "eth%daddr", i); - } else { + if (i < 0) continue; - } + + if (i == 0) + strcpy(mac, "ethaddr"); + else + sprintf(mac, "eth%daddr", i); + fdt_eth_addr = getenv(mac); - if (!fdt_eth_addr) + if (fdt_eth_addr) + eth_parse_enetaddr(fdt_eth_addr, mac_addr); + else continue;
- eth_parse_enetaddr(fdt_eth_addr, mac_addr); - do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0); do_fixup_by_path(fdt, path, "local-mac-address",

A user may select the connected eeprom address via NET_ETHADDR_EEPROM_I2C_BUS, but not enable it (I2Cn_ENABLE). To prevent this mistake, enable the I2C controller selected via NET_ETHADDR_EEPROM_I2C_BUS.
This in turn simplifies the defconfig.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- board/sunxi/Kconfig | 4 ++++ configs/A10-OLinuXino-Lime_defconfig | 1 - configs/A20-OLinuXino-Lime2_defconfig | 1 - configs/A20-OLinuXino-Lime_defconfig | 1 - configs/A20-OLinuXino_MICRO_defconfig | 1 - 5 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 962da09136..e515175117 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -441,6 +441,7 @@ config I2C0_ENABLE
config I2C1_ENABLE bool "Enable I2C/TWI controller 1" + default y if (NET_ETHADDR_EEPROM_I2C_BUS = 1) default n select CMD_I2C ---help--- @@ -448,6 +449,7 @@ config I2C1_ENABLE
config I2C2_ENABLE bool "Enable I2C/TWI controller 2" + default y if (NET_ETHADDR_EEPROM_I2C_BUS = 2) default n select CMD_I2C ---help--- @@ -455,6 +457,7 @@ config I2C2_ENABLE
if MACH_SUN6I || MACH_SUN7I config I2C3_ENABLE + default y if (NET_ETHADDR_EEPROM_I2C_BUS = 3) bool "Enable I2C/TWI controller 3" default n select CMD_I2C @@ -475,6 +478,7 @@ endif if MACH_SUN7I config I2C4_ENABLE bool "Enable I2C/TWI controller 4" + default y if (NET_ETHADDR_EEPROM_I2C_BUS = 4) default n select CMD_I2C ---help--- diff --git a/configs/A10-OLinuXino-Lime_defconfig b/configs/A10-OLinuXino-Lime_defconfig index 6634139ab8..7a8756620a 100644 --- a/configs/A10-OLinuXino-Lime_defconfig +++ b/configs/A10-OLinuXino-Lime_defconfig @@ -17,7 +17,6 @@ CONFIG_SPL_I2C_SUPPORT=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 -CONFIG_I2C1_ENABLE=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig index 4c720b3109..0d7d5f042f 100644 --- a/configs/A20-OLinuXino-Lime2_defconfig +++ b/configs/A20-OLinuXino-Lime2_defconfig @@ -24,7 +24,6 @@ CONFIG_ETH_DESIGNWARE=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 -CONFIG_I2C1_ENABLE=y CONFIG_AXP_ALDO3_VOLT=2800 CONFIG_AXP_ALDO4_VOLT=2800 CONFIG_USB_EHCI_HCD=y diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig index 564ae256a3..a90d681064 100644 --- a/configs/A20-OLinuXino-Lime_defconfig +++ b/configs/A20-OLinuXino-Lime_defconfig @@ -19,7 +19,6 @@ CONFIG_ETH_DESIGNWARE=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 -CONFIG_I2C1_ENABLE=y CONFIG_AXP_ALDO3_VOLT=2800 CONFIG_AXP_ALDO4_VOLT=2800 CONFIG_USB_EHCI_HCD=y diff --git a/configs/A20-OLinuXino_MICRO_defconfig b/configs/A20-OLinuXino_MICRO_defconfig index 93be13b407..d0bfa9c3c0 100644 --- a/configs/A20-OLinuXino_MICRO_defconfig +++ b/configs/A20-OLinuXino_MICRO_defconfig @@ -22,7 +22,6 @@ CONFIG_ETH_DESIGNWARE=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 -CONFIG_I2C1_ENABLE=y CONFIG_AXP_ALDO3_VOLT=2800 CONFIG_AXP_ALDO4_VOLT=2800 CONFIG_USB_EHCI_HCD=y

Convert both the sunxi_emac and sunxi_gmac drivers to use KConfig.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- configs/A10-OLinuXino-Lime_defconfig | 3 ++- configs/A10s-OLinuXino-M_defconfig | 2 +- configs/A20-OLinuXino-Lime2_defconfig | 4 ++-- configs/A20-OLinuXino-Lime_defconfig | 4 ++-- configs/A20-OLinuXino_MICRO_defconfig | 4 ++-- configs/A20-Olimex-SOM-EVB_defconfig | 4 ++-- configs/Bananapi_defconfig | 4 ++-- configs/Bananapro_defconfig | 4 ++-- configs/CSQ_CS908_defconfig | 3 +-- configs/Colombus_defconfig | 4 ++-- configs/Cubieboard2_defconfig | 4 ++-- configs/Cubieboard_defconfig | 3 ++- configs/Cubietruck_defconfig | 4 ++-- configs/Hummingbird_A31_defconfig | 4 ++-- configs/Itead_Ibox_A20_defconfig | 4 ++-- configs/Lamobo_R1_defconfig | 4 ++-- configs/Linksprite_pcDuino3_Nano_defconfig | 4 ++-- configs/Linksprite_pcDuino3_defconfig | 4 ++-- configs/Linksprite_pcDuino_defconfig | 2 +- configs/Marsboard_A10_defconfig | 2 +- configs/Mele_A1000G_quad_defconfig | 3 +-- configs/Mele_A1000_defconfig | 3 ++- configs/Mele_I7_defconfig | 3 +-- configs/Mele_M3_defconfig | 3 +-- configs/Mele_M5_defconfig | 3 +-- configs/Mele_M9_defconfig | 3 +-- configs/Orangepi_defconfig | 4 ++-- configs/Orangepi_mini_defconfig | 4 ++-- configs/Sinlinx_SinA31s_defconfig | 3 +-- configs/Sinovoip_BPI_M2_defconfig | 4 ++-- configs/Wits_Pro_A20_DKT_defconfig | 4 ++-- configs/ba10_tv_box_defconfig | 2 +- configs/i12-tvbox_defconfig | 4 ++-- configs/icnova-a20-swac_defconfig | 4 ++-- configs/jesurun_q5_defconfig | 3 ++- configs/mixtile_loftq_defconfig | 4 ++-- drivers/net/Kconfig | 25 +++++++++++++++++++++++++ include/configs/sunxi-common.h | 5 ----- 38 files changed, 86 insertions(+), 69 deletions(-)
diff --git a/configs/A10-OLinuXino-Lime_defconfig b/configs/A10-OLinuXino-Lime_defconfig index 7a8756620a..c275461d51 100644 --- a/configs/A10-OLinuXino-Lime_defconfig +++ b/configs/A10-OLinuXino-Lime_defconfig @@ -8,12 +8,13 @@ CONFIG_MMC0_CD_PIN="PH1" CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-olinuxino-lime" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC,SATAPWR=SUNXI_GPC(3)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPC(3)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set # CONFIG_CMD_FPGA is not set +CONFIG_SUNXI_EMAC=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 diff --git a/configs/A10s-OLinuXino-M_defconfig b/configs/A10s-OLinuXino-M_defconfig index 9c2a354ff4..9a319f6c9c 100644 --- a/configs/A10s-OLinuXino-M_defconfig +++ b/configs/A10s-OLinuXino-M_defconfig @@ -8,7 +8,6 @@ CONFIG_MMC_SUNXI_SLOT_EXTRA=1 CONFIG_USB1_VBUS_PIN="PB10" CONFIG_DEFAULT_DEVICE_TREE="sun5i-a10s-olinuxino-micro" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -17,5 +16,6 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_AXP152_POWER=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig index 0d7d5f042f..126ead3ca2 100644 --- a/configs/A20-OLinuXino-Lime2_defconfig +++ b/configs/A20-OLinuXino-Lime2_defconfig @@ -8,7 +8,7 @@ CONFIG_USB0_VBUS_DET="PH5" CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime2" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,SATAPWR=SUNXI_GPC(3)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,SATAPWR=SUNXI_GPC(3)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -20,7 +20,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DFU_RAM=y -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig index a90d681064..e134de2839 100644 --- a/configs/A20-OLinuXino-Lime_defconfig +++ b/configs/A20-OLinuXino-Lime_defconfig @@ -6,7 +6,7 @@ CONFIG_MMC0_CD_PIN="PH1" CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,SATAPWR=SUNXI_GPC(3)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPC(3)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,7 +15,7 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 diff --git a/configs/A20-OLinuXino_MICRO_defconfig b/configs/A20-OLinuXino_MICRO_defconfig index d0bfa9c3c0..4f32f2f680 100644 --- a/configs/A20-OLinuXino_MICRO_defconfig +++ b/configs/A20-OLinuXino_MICRO_defconfig @@ -9,7 +9,7 @@ CONFIG_VIDEO_VGA=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-micro" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,SATAPWR=SUNXI_GPB(8)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPB(8)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -18,7 +18,7 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_NET_ETHADDR_EEPROM=y CONFIG_NET_ETHADDR_EEPROM_I2C=y CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1 diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig index b835dc59b9..ae2e853b39 100644 --- a/configs/A20-Olimex-SOM-EVB_defconfig +++ b/configs/A20-Olimex-SOM-EVB_defconfig @@ -11,7 +11,7 @@ CONFIG_USB0_VBUS_DET="PH5" CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olimex-som-evb" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,SATAPWR=SUNXI_GPC(3)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,SATAPWR=SUNXI_GPC(3)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -20,7 +20,7 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO3_VOLT=2800 CONFIG_AXP_ALDO4_VOLT=2800 CONFIG_USB_EHCI_HCD=y diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig index 059559d393..9f47a13a4e 100644 --- a/configs/Bananapi_defconfig +++ b/configs/Bananapi_defconfig @@ -7,7 +7,7 @@ CONFIG_GMAC_TX_DELAY=3 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-bananapi" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,MACPWR=SUNXI_GPH(23)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -17,5 +17,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_NETCONSOLE=y -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig index 27b9e63e00..dd4c03dd44 100644 --- a/configs/Bananapro_defconfig +++ b/configs/Bananapro_defconfig @@ -9,7 +9,7 @@ CONFIG_GMAC_TX_DELAY=3 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-bananapro" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,MACPWR=SUNXI_GPH(23)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -19,6 +19,6 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set CONFIG_NETCONSOLE=y -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO4_VOLT=2500 CONFIG_USB_EHCI_HCD=y diff --git a/configs/CSQ_CS908_defconfig b/configs/CSQ_CS908_defconfig index 953ec253c0..cbfee3def4 100644 --- a/configs/CSQ_CS908_defconfig +++ b/configs/CSQ_CS908_defconfig @@ -6,7 +6,6 @@ CONFIG_USB1_VBUS_PIN="" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31s-cs908" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -14,7 +13,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_AXP_DLDO1_VOLT=3300 CONFIG_USB_EHCI_HCD=y diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig index ac283a2070..86c55500ac 100644 --- a/configs/Colombus_defconfig +++ b/configs/Colombus_defconfig @@ -16,7 +16,7 @@ CONFIG_VIDEO_LCD_PANEL_I2C_SCL="PA24" CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804=y CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-colombus" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII" +CONFIG_SYS_EXTRA_OPTIONS="RGMII" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -24,6 +24,6 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_USB_EHCI_HCD=y diff --git a/configs/Cubieboard2_defconfig b/configs/Cubieboard2_defconfig index 690ba49cfc..3e9510b253 100644 --- a/configs/Cubieboard2_defconfig +++ b/configs/Cubieboard2_defconfig @@ -6,7 +6,7 @@ CONFIG_MMC0_CD_PIN="PH1" CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubieboard2" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,SATAPWR=SUNXI_GPB(8)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPB(8)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,5 +15,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Cubieboard_defconfig b/configs/Cubieboard_defconfig index e1d1f1f8bb..fe56d1cc0b 100644 --- a/configs/Cubieboard_defconfig +++ b/configs/Cubieboard_defconfig @@ -6,7 +6,7 @@ CONFIG_MMC0_CD_PIN="PH1" CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-cubieboard" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC,SATAPWR=SUNXI_GPB(8)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPB(8)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,4 +15,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig index ca549bc298..e33804fc47 100644 --- a/configs/Cubietruck_defconfig +++ b/configs/Cubietruck_defconfig @@ -11,7 +11,7 @@ CONFIG_GMAC_TX_DELAY=1 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-cubietruck" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,SATAPWR=SUNXI_GPH(12)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,SATAPWR=SUNXI_GPH(12)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -23,7 +23,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_DFU_RAM=y -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_GADGET=y CONFIG_USB_GADGET=y diff --git a/configs/Hummingbird_A31_defconfig b/configs/Hummingbird_A31_defconfig index c1cbbc829a..e988b7d5bb 100644 --- a/configs/Hummingbird_A31_defconfig +++ b/configs/Hummingbird_A31_defconfig @@ -8,7 +8,7 @@ CONFIG_VIDEO_VGA_VIA_LCD=y CONFIG_VIDEO_VGA_EXTERNAL_DAC_EN="PH25" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-hummingbird" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII" +CONFIG_SYS_EXTRA_OPTIONS="RGMII" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -16,6 +16,6 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_USB_EHCI_HCD=y diff --git a/configs/Itead_Ibox_A20_defconfig b/configs/Itead_Ibox_A20_defconfig index c38d71f25a..80087723e9 100644 --- a/configs/Itead_Ibox_A20_defconfig +++ b/configs/Itead_Ibox_A20_defconfig @@ -6,7 +6,7 @@ CONFIG_MMC0_CD_PIN="PH1" CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-itead-ibox" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,SATAPWR=SUNXI_GPB(8)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPB(8)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,5 +15,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Lamobo_R1_defconfig b/configs/Lamobo_R1_defconfig index 92ae4e231d..6f83a4634f 100644 --- a/configs/Lamobo_R1_defconfig +++ b/configs/Lamobo_R1_defconfig @@ -7,7 +7,7 @@ CONFIG_GMAC_TX_DELAY=4 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-lamobo-r1" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23),SATAPWR=SUNXI_GPB(3)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,MACPWR=SUNXI_GPH(23),SATAPWR=SUNXI_GPB(3)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -16,5 +16,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig index 9c2cf8129f..9b1537e48d 100644 --- a/configs/Linksprite_pcDuino3_Nano_defconfig +++ b/configs/Linksprite_pcDuino3_Nano_defconfig @@ -8,7 +8,7 @@ CONFIG_GMAC_TX_DELAY=3 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3-nano" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,SATAPWR=SUNXI_GPH(2)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,SATAPWR=SUNXI_GPH(2)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -17,5 +17,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig index b245e7e0d7..21fb81ddc5 100644 --- a/configs/Linksprite_pcDuino3_defconfig +++ b/configs/Linksprite_pcDuino3_defconfig @@ -6,7 +6,7 @@ CONFIG_DRAM_ZQ=122 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,SATAPWR=SUNXI_GPH(2)" +CONFIG_SYS_EXTRA_OPTIONS="SATAPWR=SUNXI_GPH(2)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,5 +15,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Linksprite_pcDuino_defconfig b/configs/Linksprite_pcDuino_defconfig index 1d2ab19a0b..452f3bd212 100644 --- a/configs/Linksprite_pcDuino_defconfig +++ b/configs/Linksprite_pcDuino_defconfig @@ -5,7 +5,6 @@ CONFIG_USB1_VBUS_PIN="" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-pcduino" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -14,4 +13,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Marsboard_A10_defconfig b/configs/Marsboard_A10_defconfig index 34e78f1e8c..4deff8610a 100644 --- a/configs/Marsboard_A10_defconfig +++ b/configs/Marsboard_A10_defconfig @@ -4,7 +4,6 @@ CONFIG_MACH_SUN4I=y CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-marsboard" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -12,5 +11,6 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_SUNXI_NO_PMIC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Mele_A1000G_quad_defconfig b/configs/Mele_A1000G_quad_defconfig index 8f03835375..bbe60f13cc 100644 --- a/configs/Mele_A1000G_quad_defconfig +++ b/configs/Mele_A1000G_quad_defconfig @@ -7,7 +7,6 @@ CONFIG_USB1_VBUS_PIN="PC27" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-mele-a1000g-quad" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -15,7 +14,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_DCDC1_VOLT=3300 CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_AXP_DLDO1_VOLT=3300 diff --git a/configs/Mele_A1000_defconfig b/configs/Mele_A1000_defconfig index 4496688d3f..0df008e89a 100644 --- a/configs/Mele_A1000_defconfig +++ b/configs/Mele_A1000_defconfig @@ -6,7 +6,7 @@ CONFIG_VIDEO_COMPOSITE=y CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-a1000" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC,MACPWR=SUNXI_GPH(15)" +CONFIG_SYS_EXTRA_OPTIONS="MACPWR=SUNXI_GPH(15)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,4 +15,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Mele_I7_defconfig b/configs/Mele_I7_defconfig index 572b5219cc..55b756cdee 100644 --- a/configs/Mele_I7_defconfig +++ b/configs/Mele_I7_defconfig @@ -6,7 +6,6 @@ CONFIG_USB1_VBUS_PIN="PC27" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-i7" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -14,7 +13,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_DCDC1_VOLT=3300 CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_AXP_DLDO1_VOLT=3300 diff --git a/configs/Mele_M3_defconfig b/configs/Mele_M3_defconfig index dd1526954b..1e0b2780a1 100644 --- a/configs/Mele_M3_defconfig +++ b/configs/Mele_M3_defconfig @@ -8,7 +8,6 @@ CONFIG_VIDEO_VGA=y CONFIG_VIDEO_COMPOSITE=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-m3" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -17,5 +16,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig index 12e1d0cae4..17fbf74cf1 100644 --- a/configs/Mele_M5_defconfig +++ b/configs/Mele_M5_defconfig @@ -8,7 +8,6 @@ CONFIG_VIDEO_COMPOSITE=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-m5" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -17,5 +16,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig index a9dc159063..caf9aa3e09 100644 --- a/configs/Mele_M9_defconfig +++ b/configs/Mele_M9_defconfig @@ -6,7 +6,6 @@ CONFIG_USB1_VBUS_PIN="PC27" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-m9" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -14,7 +13,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_DCDC1_VOLT=3300 CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_AXP_DLDO1_VOLT=3300 diff --git a/configs/Orangepi_defconfig b/configs/Orangepi_defconfig index 3c9f74f3b4..31ba76fc95 100644 --- a/configs/Orangepi_defconfig +++ b/configs/Orangepi_defconfig @@ -10,7 +10,7 @@ CONFIG_GMAC_TX_DELAY=3 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-orangepi" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,MACPWR=SUNXI_GPH(23)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -19,5 +19,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig index f1d413b445..a6e8822442 100644 --- a/configs/Orangepi_mini_defconfig +++ b/configs/Orangepi_mini_defconfig @@ -12,7 +12,7 @@ CONFIG_GMAC_TX_DELAY=3 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-orangepi-mini" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPH(23)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,MACPWR=SUNXI_GPH(23)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -21,5 +21,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/Sinlinx_SinA31s_defconfig b/configs/Sinlinx_SinA31s_defconfig index 54c975a2b2..86aa769930 100644 --- a/configs/Sinlinx_SinA31s_defconfig +++ b/configs/Sinlinx_SinA31s_defconfig @@ -10,7 +10,6 @@ CONFIG_USB1_VBUS_PIN="" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31s-sina31s" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -18,6 +17,6 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_DLDO1_VOLT=3300 CONFIG_USB_EHCI_HCD=y diff --git a/configs/Sinovoip_BPI_M2_defconfig b/configs/Sinovoip_BPI_M2_defconfig index dbff2344bb..ad93c80b7b 100644 --- a/configs/Sinovoip_BPI_M2_defconfig +++ b/configs/Sinovoip_BPI_M2_defconfig @@ -6,7 +6,7 @@ CONFIG_USB1_VBUS_PIN="" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31s-sinovoip-bpi-m2" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII" +CONFIG_SYS_EXTRA_OPTIONS="RGMII" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -14,7 +14,7 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_AXP_ALDO2_VOLT=1800 CONFIG_AXP_DLDO1_VOLT=3000 diff --git a/configs/Wits_Pro_A20_DKT_defconfig b/configs/Wits_Pro_A20_DKT_defconfig index cd6e821958..1ff3ce00cf 100644 --- a/configs/Wits_Pro_A20_DKT_defconfig +++ b/configs/Wits_Pro_A20_DKT_defconfig @@ -11,7 +11,7 @@ CONFIG_VIDEO_LCD_PANEL_LVDS=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-wits-pro-a20-dkt" CONFIG_AHCI=y # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII" +CONFIG_SYS_EXTRA_OPTIONS="RGMII" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -20,5 +20,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/ba10_tv_box_defconfig b/configs/ba10_tv_box_defconfig index ec71159151..1fa0c2bc74 100644 --- a/configs/ba10_tv_box_defconfig +++ b/configs/ba10_tv_box_defconfig @@ -8,7 +8,6 @@ CONFIG_USB2_VBUS_PIN="PH12" CONFIG_VIDEO_COMPOSITE=y CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-ba10-tvbox" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -17,5 +16,6 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_HOST=y diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig index 9715bb9228..c03f32e577 100644 --- a/configs/i12-tvbox_defconfig +++ b/configs/i12-tvbox_defconfig @@ -5,7 +5,7 @@ CONFIG_DRAM_CLK=384 CONFIG_VIDEO_COMPOSITE=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-i12-tvbox" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,MACPWR=SUNXI_GPH(21)" +CONFIG_SYS_EXTRA_OPTIONS="MACPWR=SUNXI_GPH(21)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -14,5 +14,5 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/icnova-a20-swac_defconfig b/configs/icnova-a20-swac_defconfig index 30e75e3c71..0c0dfb14f8 100644 --- a/configs/icnova-a20-swac_defconfig +++ b/configs/icnova-a20-swac_defconfig @@ -12,7 +12,7 @@ CONFIG_VIDEO_LCD_POWER="PH22" CONFIG_VIDEO_LCD_PANEL_LVDS=y CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-icnova-swac" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,CMD_BMP" +CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,CMD_BMP" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -22,5 +22,5 @@ CONFIG_CMD_UNZIP=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_USB_EHCI_HCD=y diff --git a/configs/jesurun_q5_defconfig b/configs/jesurun_q5_defconfig index a6bec12fd2..d5a7d96bab 100644 --- a/configs/jesurun_q5_defconfig +++ b/configs/jesurun_q5_defconfig @@ -6,7 +6,7 @@ CONFIG_USB0_VBUS_PIN="PB9" CONFIG_VIDEO_COMPOSITE=y CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-jesurun-q5" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_EMAC,MACPWR=SUNXI_GPH(19)" +CONFIG_SYS_EXTRA_OPTIONS="MACPWR=SUNXI_GPH(19)" CONFIG_SPL=y CONFIG_SPL_I2C_SUPPORT=y # CONFIG_CMD_IMLS is not set @@ -15,5 +15,6 @@ CONFIG_SPL_I2C_SUPPORT=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set +CONFIG_SUNXI_EMAC=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_MUSB_HOST=y diff --git a/configs/mixtile_loftq_defconfig b/configs/mixtile_loftq_defconfig index ec6a4381ac..3bba9583bc 100644 --- a/configs/mixtile_loftq_defconfig +++ b/configs/mixtile_loftq_defconfig @@ -7,7 +7,7 @@ CONFIG_USB1_VBUS_PIN="PH24" CONFIG_USB2_VBUS_PIN="" CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-mixtile-loftq" # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set -CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPA(21)" +CONFIG_SYS_EXTRA_OPTIONS="RGMII,MACPWR=SUNXI_GPA(21)" CONFIG_SPL=y # CONFIG_CMD_IMLS is not set # CONFIG_CMD_FLASH is not set @@ -15,6 +15,6 @@ CONFIG_SPL=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_ETH_DESIGNWARE=y +CONFIG_SUNXI_GMAC=y CONFIG_AXP_ALDO1_VOLT=3300 CONFIG_USB_EHCI_HCD=y diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 70e36611ea..9f088e1e7b 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -161,6 +161,17 @@ config RTL8169 This driver supports Realtek 8169 series gigabit ethernet family of PCI/PCIe chipsets/adapters.
+config SUNXI_EMAC + bool "Allwinner sunxi Ethernet MAC support" + depends on DM_ETH + select MII + select PHYLIB + help + This driver provides the Allwinner based SoCs with 100 Megabit network + support. This driver is known to have performance issues and should + only be used on sun4i hardware. Newer hardware supports the + SUNXI_GMAC driver, which also works with 100 Megabit PHY's. + config SUN8I_EMAC bool "Allwinner Sun8i Ethernet MAC support" depends on DM_ETH @@ -170,6 +181,20 @@ config SUN8I_EMAC It can be found in H3/A64/A83T based SoCs and compatible with both External and Internal PHYs.
+config SUNXI_GMAC + bool "Allwinner sunxi Ethernet GMAC support" + depends on DM_ETH + select ETH_DESIGNWARE + select MII + select PHYLIB + select PHY_GIGE + help + This driver provides the Allwinner based SoCs network support based + on the Synopsys Designware gigabit driver. The driver supports both + RGMII and MII communications and can thus be used as a drop in + replacement of the SUNXI_EMAC driver. CONFIG_RGMII needs to be set for + gigabit PHY's that speak RGMII. + config XILINX_AXIEMAC depends on DM_ETH && (MICROBLAZE || ARCH_ZYNQ || ARCH_ZYNQMP) select PHYLIB diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 05ea172fe3..b3fed6fea1 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -290,15 +290,10 @@ extern int soft_i2c_gpio_scl; /* Ethernet support */ #ifdef CONFIG_SUNXI_EMAC #define CONFIG_PHY_ADDR 1 -#define CONFIG_MII /* MII PHY management */ -#define CONFIG_PHYLIB #endif
#ifdef CONFIG_SUNXI_GMAC -#define CONFIG_PHY_GIGE /* GMAC can use gigabit PHY */ #define CONFIG_PHY_ADDR 1 -#define CONFIG_MII /* MII PHY management */ -#define CONFIG_PHY_REALTEK #endif
#ifdef CONFIG_USB_EHCI_HCD

Expose the function to generate a MAC adddress based on the serial number. This can then later be moved completly out of the sunxi board specific stuff.
The setup_environment quirky function still exists as it is still used to fixup the FDT for drivers that need the MAC address available in the FDT. Once that is changed, we can clean up some more.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- arch/arm/include/asm/arch-sunxi/sys_proto.h | 2 + board/sunxi/board.c | 145 ++++++++++++++++++---------- 2 files changed, 94 insertions(+), 53 deletions(-)
diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h index a373319a2b..98effbf5c6 100644 --- a/arch/arm/include/asm/arch-sunxi/sys_proto.h +++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h @@ -30,4 +30,6 @@ void eth_init_board(void); static inline void eth_init_board(void) {} #endif
+int sunxi_gen_hwaddr(const int seq, unsigned char *enetaddr); + #endif diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 53656383d5..4ea6dc3828 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -21,6 +21,7 @@ #include <asm/arch/gpio.h> #include <asm/arch/mmc.h> #include <asm/arch/spl.h> +#include <asm/arch/sys_proto.h> #include <asm/arch/usb_phy.h> #ifndef CONFIG_ARM64 #include <asm/armv7.h> @@ -564,6 +565,72 @@ int g_dnl_board_usb_cable_connected(void) } #endif
+static int sunxi_get_board_serial(unsigned int *serial) +{ + int ret; + + ret = sunxi_get_sid(serial); + if (!ret || serial[0]) + return -ENOSYS; + + /* + * The single words 1 - 3 of the SID have quite a few bits + * which are the same on many models, so we take a crc32 + * of all 3 words, to get a more unique value. + * + * Note we only do this on newer SoCs as we cannot change + * the algorithm on older SoCs since those have been using + * fixed mac-addresses/serial based on only using word 3 for a + * long time and changing a fixed mac-address/serial with an + * u-boot update is not good. + */ +#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \ + !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \ + !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33) + serial[3] = crc32(0, (unsigned char *)&serial[1], 12); +#endif + + return 0; +} + + /* + * Generate a MAC address based on device index and the serial number. + * The first half of the of the first octet holds the eth index. + * + * In the second octet we forcefully mark the MAC address to a locally + * administered MAC address. + * + */ +int sunxi_gen_hwaddr(const int seq, unsigned char *enetaddr) +{ + uint8_t mac_addr[ARP_HLEN] = { 0x00 }; + unsigned int serial[4]; + int ret; + + if (!enetaddr || (seq < 0)) + return -ENOSYS; + + ret = sunxi_get_board_serial(serial); + if (!ret) + return ret; + + /* Ensure the NIC specific bytes of the mac are not all 0 */ + if ((serial[3] & 0xffffff) == 0) + serial[3] |= 0x800000; + + mac_addr[0] = (seq << 4); + mac_addr[1] = (serial[0] >> 0) & 0xff; + mac_addr[2] = (serial[3] >> 24) & 0xff; + mac_addr[3] = (serial[3] >> 16) & 0xff; + mac_addr[4] = (serial[3] >> 8) & 0xff; + mac_addr[5] = (serial[3] >> 0) & 0xff; + + set_local_ethaddr(mac_addr); + memcpy(enetaddr, mac_addr, ARP_HLEN); + + return 0; +} + #ifdef CONFIG_SERIAL_TAG void get_board_serial(struct tag_serialnr *serialnr) { @@ -623,71 +690,35 @@ static void parse_spl_header(const uint32_t spl_addr) */ static void setup_environment(const void *fdt) { - char serial_string[17] = { 0 }; - unsigned int sid[4]; - uint8_t mac_addr[6]; - char ethaddr[16]; + uint8_t enetaddr[ARP_HLEN]; + char ethaddr[ETH_ENETADDR_ENV_NAME_LEN]; int i, ret;
- ret = sunxi_get_sid(sid); - if (ret == 0 && sid[0] != 0) { - /* - * The single words 1 - 3 of the SID have quite a few bits - * which are the same on many models, so we take a crc32 - * of all 3 words, to get a more unique value. - * - * Note we only do this on newer SoCs as we cannot change - * the algorithm on older SoCs since those have been using - * fixed mac-addresses based on only using word 3 for a - * long time and changing a fixed mac-address with an - * u-boot update is not good. - */ -#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \ - !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \ - !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33) - sid[3] = crc32(0, (unsigned char *)&sid[1], 12); -#endif - - /* Ensure the NIC specific bytes of the mac are not all 0 */ - if ((sid[3] & 0xffffff) == 0) - sid[3] |= 0x800000; - - for (i = 0; i < 4; i++) { - sprintf(ethaddr, "ethernet%d", i); - if (!fdt_get_alias(fdt, ethaddr)) - continue; - - if (i == 0) - strcpy(ethaddr, "ethaddr"); - else - sprintf(ethaddr, "eth%daddr", i); - - if (getenv(ethaddr)) - continue; + for (i = 0; i < 4; i++) { + sprintf(ethaddr, "ethernet%d", i); + if (!fdt_get_alias(fdt, ethaddr)) + continue;
- /* Non OUI / registered MAC address */ - mac_addr[0] = (i << 4) | 0x02; - 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; + if (i == 0) + strcpy(ethaddr, "ethaddr"); + else + sprintf(ethaddr, "eth%daddr", i);
- eth_setenv_enetaddr(ethaddr, mac_addr); - } + if (getenv(ethaddr)) + continue;
- if (!getenv("serial#")) { - snprintf(serial_string, sizeof(serial_string), - "%08x%08x", sid[0], sid[3]); + ret = sunxi_gen_hwaddr(i, enetaddr); + if (!ret) + return;
- setenv("serial#", serial_string); - } + eth_setenv_enetaddr(ethaddr, enetaddr); } }
int misc_init_r(void) { __maybe_unused int ret; + unsigned int serial[4];
setenv("fel_booted", NULL); setenv("fel_scriptaddr", NULL); @@ -698,6 +729,14 @@ int misc_init_r(void) }
setup_environment(gd->fdt_blob); + if (!getenv("serial#") && sunxi_get_board_serial(serial)) { + char serial_string[17] = { 0 }; + + snprintf(serial_string, sizeof(serial_string), + "%08x%08x", serial[0], serial[3]); + + setenv("serial#", serial_string); + }
#ifndef CONFIG_MACH_SUN9I ret = sunxi_usb_phy_probe();

Expose the write_hwaddr net_ops hook to write the Ethernet address.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/sunxi_emac.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 99339db4bf..0dc37de242 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -565,11 +565,23 @@ static int sunxi_emac_eth_probe(struct udevice *dev) return sunxi_emac_init_phy(priv, dev); }
+static int sunxi_emac_eth_write_hwaddr(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + struct emac_eth_dev *priv = dev_get_priv(dev); + + if (!pdata) + return -ENOSYS; + + return _sunxi_write_hwaddr(priv, pdata->enetaddr); +} + static const struct eth_ops sunxi_emac_eth_ops = { .start = sunxi_emac_eth_start, .send = sunxi_emac_eth_send, .recv = sunxi_emac_eth_recv, .stop = sunxi_emac_eth_stop, + .write_hwaddr = sunxi_emac_eth_write_hwaddr, };
static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev)

The sun[8x]i network drivers have some common functions. Let's introduce a common file with the reading of the MAC address as a start.
In the future, we can move more sunxi shared/common code into this file.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/sunxi_common.c | 33 +++++++++++++++++++++++++++++++++ drivers/net/sunxi_common.h | 13 +++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 drivers/net/sunxi_common.c create mode 100644 drivers/net/sunxi_common.h
diff --git a/drivers/net/sunxi_common.c b/drivers/net/sunxi_common.c new file mode 100644 index 0000000000..a0c0548059 --- /dev/null +++ b/drivers/net/sunxi_common.c @@ -0,0 +1,33 @@ +/* + * (c) Copyright 2017 + * Author: Olliver Schinagl oliver@schinagl.nl + * + * SPX-License-Identifier: GPL-3.0+ + * + * Common code for the sunxi series of the ethernet sunxi glue code + * + */ + +#include <asm/arch/sys_proto.h> +#include <common.h> +#include <dm/device.h> +#include <net.h> +#include <linux/types.h> + +/* + * Set ethernet MAC address based on serial number. + * FIXME: For now we call sunxi_gen_hwaddr to generate the MAC address there. + * This is done because we have some devices, which expect their MAC address to + * to be passed via the environment and obtained from the FDT. Once that code + * has been refactored (it is quircky to say the least), the mac generating code + * should live here. + */ +int sunxi_eth_read_rom_hwaddr(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + + if (!pdata || (dev->seq < 0)) + return -ENOSYS; + + return sunxi_gen_hwaddr(dev->seq, pdata->enetaddr); +} diff --git a/drivers/net/sunxi_common.h b/drivers/net/sunxi_common.h new file mode 100644 index 0000000000..79d33e40bb --- /dev/null +++ b/drivers/net/sunxi_common.h @@ -0,0 +1,13 @@ +/* + * (c) Copyright 2017 + * Author: Olliver Schinagl oliver@schinagl.nl + * + * SPX-License-Identifier: GPL-3.0+ + * + * Common code for the sunxi series of the ethernet sunxi glue code + * + */ + +#include <dm/device.h> + +int sunxi_eth_read_rom_hwaddr(struct udevice *dev);

With this patch sunxi_emac can now get the MAC address from the board in a predetermined board specific manner.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/Makefile | 2 +- drivers/net/sunxi_emac.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 2493a48b88..c840770bd8 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -23,7 +23,7 @@ obj-$(CONFIG_DNET) += dnet.o obj-$(CONFIG_E1000) += e1000.o obj-$(CONFIG_E1000_SPI) += e1000_spi.o obj-$(CONFIG_EEPRO100) += eepro100.o -obj-$(CONFIG_SUNXI_EMAC) += sunxi_emac.o +obj-$(CONFIG_SUNXI_EMAC) += sunxi_common.o sunxi_emac.o obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_EP93XX) += ep93xx_eth.o diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 0dc37de242..b50f0eec09 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -16,6 +16,8 @@ #include <asm/arch/clock.h> #include <asm/arch/gpio.h>
+#include "sunxi_common.h" + /* EMAC register */ struct emac_regs { u32 ctl; /* 0x00 */ @@ -582,6 +584,7 @@ static const struct eth_ops sunxi_emac_eth_ops = { .recv = sunxi_emac_eth_recv, .stop = sunxi_emac_eth_stop, .write_hwaddr = sunxi_emac_eth_write_hwaddr, + .read_rom_hwaddr = sunxi_eth_read_rom_hwaddr, };
static int sunxi_emac_eth_ofdata_to_platdata(struct udevice *dev)

This patch removes the old sunxi_gmac glue layer and turns it into a proper sub-class driver.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- arch/arm/include/asm/arch-sunxi/sys_proto.h | 7 ---- arch/arm/mach-sunxi/board.c | 1 - board/sunxi/Makefile | 1 - drivers/net/Makefile | 1 + drivers/net/designware.c | 1 - board/sunxi/gmac.c => drivers/net/sunxi_gmac.c | 52 +++++++++++++++++++++++--- 6 files changed, 47 insertions(+), 16 deletions(-) rename board/sunxi/gmac.c => drivers/net/sunxi_gmac.c (69%)
diff --git a/arch/arm/include/asm/arch-sunxi/sys_proto.h b/arch/arm/include/asm/arch-sunxi/sys_proto.h index 98effbf5c6..42bdfc711a 100644 --- a/arch/arm/include/asm/arch-sunxi/sys_proto.h +++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h @@ -23,13 +23,6 @@ void sdelay(unsigned long); */ void return_to_fel(uint32_t lr, uint32_t sp);
-/* Board / SoC level designware gmac init */ -#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUNXI_GMAC -void eth_init_board(void); -#else -static inline void eth_init_board(void) {} -#endif - int sunxi_gen_hwaddr(const int seq, unsigned char *enetaddr);
#endif diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index 3a5840b9c0..64aed3180c 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -200,7 +200,6 @@ void s_init(void) timer_init(); gpio_init(); i2c_init_board(); - eth_init_board(); }
#ifdef CONFIG_SPL_BUILD diff --git a/board/sunxi/Makefile b/board/sunxi/Makefile index 43766e0ef4..f2dba9532a 100644 --- a/board/sunxi/Makefile +++ b/board/sunxi/Makefile @@ -9,7 +9,6 @@ # SPDX-License-Identifier: GPL-2.0+ # obj-y += board.o -obj-$(CONFIG_SUNXI_GMAC) += gmac.o obj-$(CONFIG_SUNXI_AHCI) += ahci.o obj-$(CONFIG_MACH_SUN4I) += dram_sun4i_auto.o obj-$(CONFIG_MACH_SUN5I) += dram_sun5i_auto.o diff --git a/drivers/net/Makefile b/drivers/net/Makefile index c840770bd8..3a0ab139c3 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_E1000) += e1000.o obj-$(CONFIG_E1000_SPI) += e1000_spi.o obj-$(CONFIG_EEPRO100) += eepro100.o obj-$(CONFIG_SUNXI_EMAC) += sunxi_common.o sunxi_emac.o +obj-$(CONFIG_SUNXI_GMAC) += sunxi_gmac.o obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_EP93XX) += ep93xx_eth.o diff --git a/drivers/net/designware.c b/drivers/net/designware.c index f9fb8e0886..3e18f28232 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -761,7 +761,6 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev) }
static const struct udevice_id designware_eth_ids[] = { - { .compatible = "allwinner,sun7i-a20-gmac" }, { .compatible = "altr,socfpga-stmmac" }, { .compatible = "amlogic,meson6-dwmac" }, { .compatible = "amlogic,meson-gx-dwmac" }, diff --git a/board/sunxi/gmac.c b/drivers/net/sunxi_gmac.c similarity index 69% rename from board/sunxi/gmac.c rename to drivers/net/sunxi_gmac.c index 69eb8ff2d9..15f8164c34 100644 --- a/board/sunxi/gmac.c +++ b/drivers/net/sunxi_gmac.c @@ -1,12 +1,24 @@ -#include <common.h> -#include <netdev.h> -#include <miiphy.h> -#include <asm/gpio.h> -#include <asm/io.h> +/* + * (C) Copyright 2016 Olliver Schinagl oliver@schinagl.nl + * + * SPDX-License-Identifier: GPL-2.0+ + * + * Allwinner GMAC ethernet IP driver for U-Boot + */ + +#include <asm/arch/cpu.h> #include <asm/arch/clock.h> #include <asm/arch/gpio.h> +#include <asm/io.h> +#include <common.h> +#include <dm.h> +#include <net.h> + +#include "designware.h"
-void eth_init_board(void) +DECLARE_GLOBAL_DATA_PTR; + +static int sunxi_gmac_eth_probe(struct udevice *dev) { int pin; struct sunxi_ccm_reg *const ccm = @@ -79,4 +91,32 @@ void eth_init_board(void) for (pin = SUNXI_GPA(26); pin <= SUNXI_GPA(27); pin++) sunxi_gpio_set_cfgpin(pin, SUN6I_GPA_GMAC); #endif + + return designware_eth_probe(dev); } + +const struct eth_ops sunxi_gmac_eth_ops = { + .start = designware_eth_start, + .send = designware_eth_send, + .recv = designware_eth_recv, + .free_pkt = designware_eth_free_pkt, + .stop = designware_eth_stop, + .write_hwaddr = designware_eth_write_hwaddr, +}; + +static const struct udevice_id sunxi_gmac_eth_ids[] = { + { .compatible = "allwinner,sun7i-a20-gmac" }, + { /* sentinel */ }, +}; + +U_BOOT_DRIVER(eth_sunxi_gmac) = { + .name = "sunxi-gmac", + .id = UCLASS_ETH, + .of_match = sunxi_gmac_eth_ids, + .ofdata_to_platdata = designware_eth_ofdata_to_platdata, + .probe = sunxi_gmac_eth_probe, + .ops = &sunxi_gmac_eth_ops, + .priv_auto_alloc_size = sizeof(struct dw_eth_dev), + .platdata_auto_alloc_size = sizeof(struct dw_eth_pdata), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +};

Commit e72ced234045f ("net: designware: Export the operation functions") started to expose some of the net_ops. The sunxi_gmac glue driver also needs the start function, so let us expose that as well.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/designware.c | 2 +- drivers/net/designware.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 3e18f28232..ac8258c8bd 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -585,7 +585,7 @@ int designware_initialize(ulong base_addr, u32 interface) #endif
#ifdef CONFIG_DM_ETH -static int designware_eth_start(struct udevice *dev) +int designware_eth_start(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); struct dw_eth_dev *priv = dev_get_priv(dev); diff --git a/drivers/net/designware.h b/drivers/net/designware.h index 7992d0ebee..24b64d975c 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -260,6 +260,7 @@ int designware_eth_send(struct udevice *dev, void *packet, int length); int designware_eth_recv(struct udevice *dev, int flags, uchar **packetp); int designware_eth_free_pkt(struct udevice *dev, uchar *packet, int length); +int designware_eth_start(struct udevice *dev); void designware_eth_stop(struct udevice *dev); int designware_eth_write_hwaddr(struct udevice *dev); #endif

With this patch sunxi_gmac can now get the MAC address from the board in a predetermined board specific manner.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/Makefile | 2 +- drivers/net/sunxi_gmac.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 3a0ab139c3..1c0bca229b 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -24,7 +24,7 @@ obj-$(CONFIG_E1000) += e1000.o obj-$(CONFIG_E1000_SPI) += e1000_spi.o obj-$(CONFIG_EEPRO100) += eepro100.o obj-$(CONFIG_SUNXI_EMAC) += sunxi_common.o sunxi_emac.o -obj-$(CONFIG_SUNXI_GMAC) += sunxi_gmac.o +obj-$(CONFIG_SUNXI_GMAC) += sunxi_common.o sunxi_gmac.o obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_EP93XX) += ep93xx_eth.o diff --git a/drivers/net/sunxi_gmac.c b/drivers/net/sunxi_gmac.c index 15f8164c34..0f6d124d2b 100644 --- a/drivers/net/sunxi_gmac.c +++ b/drivers/net/sunxi_gmac.c @@ -15,6 +15,7 @@ #include <net.h>
#include "designware.h" +#include "sunxi_common.h"
DECLARE_GLOBAL_DATA_PTR;
@@ -102,6 +103,7 @@ const struct eth_ops sunxi_gmac_eth_ops = { .free_pkt = designware_eth_free_pkt, .stop = designware_eth_stop, .write_hwaddr = designware_eth_write_hwaddr, + .read_rom_hwaddr = sunxi_eth_read_rom_hwaddr, };
static const struct udevice_id sunxi_gmac_eth_ids[] = {

With this patch sun8i_emac can now get the MAC address from the board in a predetermined board specific manner.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/Makefile | 2 +- drivers/net/sun8i_emac.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 1c0bca229b..b6e5640576 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -25,7 +25,7 @@ obj-$(CONFIG_E1000_SPI) += e1000_spi.o obj-$(CONFIG_EEPRO100) += eepro100.o obj-$(CONFIG_SUNXI_EMAC) += sunxi_common.o sunxi_emac.o obj-$(CONFIG_SUNXI_GMAC) += sunxi_common.o sunxi_gmac.o -obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o +obj-$(CONFIG_SUN8I_EMAC) += sunxi_common.o sun8i_emac.o obj-$(CONFIG_ENC28J60) += enc28j60.o obj-$(CONFIG_EP93XX) += ep93xx_eth.o obj-$(CONFIG_ETHOC) += ethoc.o diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index b87210bad7..f2838f9f8f 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -22,6 +22,8 @@ #include <miiphy.h> #include <net.h>
+#include "sunxi_common.h" + #define MDIO_CMD_MII_BUSY BIT(0) #define MDIO_CMD_MII_WRITE BIT(1)
@@ -705,6 +707,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev) static const struct eth_ops sun8i_emac_eth_ops = { .start = sun8i_emac_eth_start, .write_hwaddr = sun8i_eth_write_hwaddr, + .read_rom_hwaddr = sunxi_eth_read_rom_hwaddr, .send = sun8i_emac_eth_send, .recv = sun8i_emac_eth_recv, .free_pkt = sun8i_eth_free_pkt,

Fix a few whitespaces errors in the sun8i driver.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- drivers/net/Kconfig | 8 ++++---- drivers/net/sun8i_emac.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 9f088e1e7b..82685800aa 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -173,10 +173,10 @@ config SUNXI_EMAC SUNXI_GMAC driver, which also works with 100 Megabit PHY's.
config SUN8I_EMAC - bool "Allwinner Sun8i Ethernet MAC support" - depends on DM_ETH - select PHYLIB - help + bool "Allwinner Sun8i Ethernet MAC support" + depends on DM_ETH + select PHYLIB + help This driver supports the Allwinner based SUN8I/SUN50I Ethernet MAC. It can be found in H3/A64/A83T based SoCs and compatible with both External and Internal PHYs. diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index f2838f9f8f..6a4dc40b84 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -705,13 +705,13 @@ static int sun8i_emac_eth_probe(struct udevice *dev) }
static const struct eth_ops sun8i_emac_eth_ops = { - .start = sun8i_emac_eth_start, - .write_hwaddr = sun8i_eth_write_hwaddr, + .start = sun8i_emac_eth_start, + .write_hwaddr = sun8i_eth_write_hwaddr, .read_rom_hwaddr = sunxi_eth_read_rom_hwaddr, - .send = sun8i_emac_eth_send, - .recv = sun8i_emac_eth_recv, - .free_pkt = sun8i_eth_free_pkt, - .stop = sun8i_emac_eth_stop, + .send = sun8i_emac_eth_send, + .recv = sun8i_emac_eth_recv, + .free_pkt = sun8i_eth_free_pkt, + .stop = sun8i_emac_eth_stop, };
static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)

Currently, we silently ignore the return value of netops->read_rom_hwaddr(). This naturally is bad and we should check if the code ran successfully.
Signed-off-by: Olliver Schinagl oliver@schinagl.nl --- net/eth-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index c88b032868..024136a7cb 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -511,8 +511,8 @@ static int eth_post_probe(struct udevice *dev) pdata->enetaddr_src = ENETADDR_SRC_EEPROM; else /* Check if the device driver has a MAC address */ - if (eth_get_ops(dev)->read_rom_hwaddr) { - eth_get_ops(dev)->read_rom_hwaddr(dev); + if (eth_get_ops(dev)->read_rom_hwaddr && + !eth_get_ops(dev)->read_rom_hwaddr(dev)) { pdata->enetaddr_src = ENETADDR_SRC_DRIVER; }

On 04/10/2017 08:34 AM, Olliver Schinagl wrote:
First off: P.S. Joe, for some reason my previous patches where added with me as: "oliver@schinagl.nl oliver@schinagl.nl" I see that it comes from patchwork as such. Is there some way to fix this to "Olliver Schinagl oliver@schinagl.nl"?
Below the updated summary:
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. The series does a few small cleanups at the start, as either I ran into them while doing this series and fixed them along the way or actually depended on them.
A manufacturer wants to produce boards and may even have MAC addresses for boards. Maintaining unique environments on a per-board basis however is horrible. Also this data should be very persistent, and not easily deletable by simply wiping the environment or device tree. Finally there are chips available on the market with a pre-programmed MAC address chips (proms) that a board manufacturer wants to use. Because of this, the MAC needs to be stored be able to read from such an 'external' source.
The current idea of the eeprom layout, is to skip the first 8 bytes, so that other information can be stored there if needed, for example a header with some magic to identify the EEPROM. Or equivalent purposes.
After those 8 bytes the MAC address follows the first macaddress. The macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes. Following the first macaddress one can store a second, or a third etc etc macaddress.
The CRC8 is optional (via a define) but is strongly recommended to have. It helps preventing user error and more importantly, checks if the bytes read are actually a user inserted address. E.g. only writing 1 macaddress into the eeprom but trying to consume 2.
Interesting solution. We have used EEPROM to store board ID, version number, MAC addresses on many of our boards. We have a command "mac" to read/write these addresses. Would you take a look to see if it is possible to integrate?
York

Hey York,
On 10-04-17 17:52, York Sun wrote:
On 04/10/2017 08:34 AM, Olliver Schinagl wrote:
First off: P.S. Joe, for some reason my previous patches where added with me as: "oliver@schinagl.nl oliver@schinagl.nl" I see that it comes from patchwork as such. Is there some way to fix this to "Olliver Schinagl oliver@schinagl.nl"?
Below the updated summary:
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. The series does a few small cleanups at the start, as either I ran into them while doing this series and fixed them along the way or actually depended on them.
A manufacturer wants to produce boards and may even have MAC addresses for boards. Maintaining unique environments on a per-board basis however is horrible. Also this data should be very persistent, and not easily deletable by simply wiping the environment or device tree. Finally there are chips available on the market with a pre-programmed MAC address chips (proms) that a board manufacturer wants to use. Because of this, the MAC needs to be stored be able to read from such an 'external' source.
The current idea of the eeprom layout, is to skip the first 8 bytes, so that other information can be stored there if needed, for example a header with some magic to identify the EEPROM. Or equivalent purposes.
After those 8 bytes the MAC address follows the first macaddress. The macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes. Following the first macaddress one can store a second, or a third etc etc macaddress.
The CRC8 is optional (via a define) but is strongly recommended to have. It helps preventing user error and more importantly, checks if the bytes read are actually a user inserted address. E.g. only writing 1 macaddress into the eeprom but trying to consume 2.
Interesting solution. We have used EEPROM to store board ID, version number, MAC addresses on many of our boards. We have a command "mac" to read/write these addresses. Would you take a look to see if it is possible to integrate?
I feel bad for not noticing the mac command! I think that this indeed could get integrated, providing generic helpers.
Just wished you would have sent your suggestion during patch v1 or v2 :p
Olliver
York

On 04/10/2017 08:57 AM, Olliver Schinagl wrote:
Hey York,
On 10-04-17 17:52, York Sun wrote:
On 04/10/2017 08:34 AM, Olliver Schinagl wrote:
First off: P.S. Joe, for some reason my previous patches where added with me as: "oliver@schinagl.nl oliver@schinagl.nl" I see that it comes from patchwork as such. Is there some way to fix this to "Olliver Schinagl oliver@schinagl.nl"?
Below the updated summary:
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. The series does a few small cleanups at the start, as either I ran into them while doing this series and fixed them along the way or actually depended on them.
A manufacturer wants to produce boards and may even have MAC addresses for boards. Maintaining unique environments on a per-board basis however is horrible. Also this data should be very persistent, and not easily deletable by simply wiping the environment or device tree. Finally there are chips available on the market with a pre-programmed MAC address chips (proms) that a board manufacturer wants to use. Because of this, the MAC needs to be stored be able to read from such an 'external' source.
The current idea of the eeprom layout, is to skip the first 8 bytes, so that other information can be stored there if needed, for example a header with some magic to identify the EEPROM. Or equivalent purposes.
After those 8 bytes the MAC address follows the first macaddress. The macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes. Following the first macaddress one can store a second, or a third etc etc macaddress.
The CRC8 is optional (via a define) but is strongly recommended to have. It helps preventing user error and more importantly, checks if the bytes read are actually a user inserted address. E.g. only writing 1 macaddress into the eeprom but trying to consume 2.
Interesting solution. We have used EEPROM to store board ID, version number, MAC addresses on many of our boards. We have a command "mac" to read/write these addresses. Would you take a look to see if it is possible to integrate?
I feel bad for not noticing the mac command! I think that this indeed could get integrated, providing generic helpers.
Just wished you would have sent your suggestion during patch v1 or v2 :p
Sorry, for some reason I wasn't CC'ed for your earlier version. They were buried in thousands of emails.
York

Hey York,
On Mon, 2017-04-10 at 09:23 -0700, York Sun wrote:
On 04/10/2017 08:57 AM, Olliver Schinagl wrote:
Hey York,
On 10-04-17 17:52, York Sun wrote:
On 04/10/2017 08:34 AM, Olliver Schinagl wrote:
First off: P.S. Joe, for some reason my previous patches where added with me as: "oliver@schinagl.nl oliver@schinagl.nl" I see that it comes from patchwork as such. Is there some way to fix this to "Olliver Schinagl oliver@schinagl.nl"?
Below the updated summary:
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. The series does a few small cleanups at the start, as either I ran into them while doing this series and fixed them along the way or actually depended on them.
A manufacturer wants to produce boards and may even have MAC addresses for boards. Maintaining unique environments on a per-board basis however is horrible. Also this data should be very persistent, and not easily deletable by simply wiping the environment or device tree. Finally there are chips available on the market with a pre-programmed MAC address chips (proms) that a board manufacturer wants to use. Because of this, the MAC needs to be stored be able to read from such an 'external' source.
The current idea of the eeprom layout, is to skip the first 8 bytes, so that other information can be stored there if needed, for example a header with some magic to identify the EEPROM. Or equivalent purposes.
After those 8 bytes the MAC address follows the first macaddress. The macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes. Following the first macaddress one can store a second, or a third etc etc macaddress.
The CRC8 is optional (via a define) but is strongly recommended to have. It helps preventing user error and more importantly, checks if the bytes read are actually a user inserted address. E.g. only writing 1 macaddress into the eeprom but trying to consume 2.
Interesting solution. We have used EEPROM to store board ID, version number, MAC addresses on many of our boards. We have a command "mac" to read/write these addresses. Would you take a look to see if it is possible to integrate?
I feel bad for not noticing the mac command! I think that this indeed could get integrated, providing generic helpers.
Just wished you would have sent your suggestion during patch v1 or v2 :p
Sorry, for some reason I wasn't CC'ed for your earlier version. They were buried in thousands of emails.
Yeah, I saw, sorry.
As for the do_mac cmd, It looks something useful to add, I'll do that once Maxime's EEPROM patches have landed as I will add support for that then. Also I want to use the generic eeprom layout stuff for the layout then and at that point, it would be good to integrate the do_mac stuff.
The only thing I don't quite understand from looking at the code, is the name implies that you read/write/modify the MAC address in the rom with this, but I see that the two implementers have lots of other functions here, such as dumping the entire eeprom etc.
So what is the intend of do_mac? only MAC address related things, or full rom related tasks?
Olliver
York
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot

On 04/11/2017 07:38 AM, o.schinagl@ultimaker.com wrote:
Hey York,
On Mon, 2017-04-10 at 09:23 -0700, York Sun wrote:
On 04/10/2017 08:57 AM, Olliver Schinagl wrote:
Hey York,
On 10-04-17 17:52, York Sun wrote:
On 04/10/2017 08:34 AM, Olliver Schinagl wrote:
First off: P.S. Joe, for some reason my previous patches where added with me as: "oliver@schinagl.nl oliver@schinagl.nl" I see that it comes from patchwork as such. Is there some way to fix this to "Olliver Schinagl oliver@schinagl.nl"?
Below the updated summary:
This patch-series introduces methods to retrieve the MAC address from an onboard EEPROM. The series does a few small cleanups at the start, as either I ran into them while doing this series and fixed them along the way or actually depended on them.
A manufacturer wants to produce boards and may even have MAC addresses for boards. Maintaining unique environments on a per-board basis however is horrible. Also this data should be very persistent, and not easily deletable by simply wiping the environment or device tree. Finally there are chips available on the market with a pre-programmed MAC address chips (proms) that a board manufacturer wants to use. Because of this, the MAC needs to be stored be able to read from such an 'external' source.
The current idea of the eeprom layout, is to skip the first 8 bytes, so that other information can be stored there if needed, for example a header with some magic to identify the EEPROM. Or equivalent purposes.
After those 8 bytes the MAC address follows the first macaddress. The macaddress is appended by a CRC8 byte and then padded to make for nice 8 bytes. Following the first macaddress one can store a second, or a third etc etc macaddress.
The CRC8 is optional (via a define) but is strongly recommended to have. It helps preventing user error and more importantly, checks if the bytes read are actually a user inserted address. E.g. only writing 1 macaddress into the eeprom but trying to consume 2.
Interesting solution. We have used EEPROM to store board ID, version number, MAC addresses on many of our boards. We have a command "mac" to read/write these addresses. Would you take a look to see if it is possible to integrate?
I feel bad for not noticing the mac command! I think that this indeed could get integrated, providing generic helpers.
Just wished you would have sent your suggestion during patch v1 or v2 :p
Sorry, for some reason I wasn't CC'ed for your earlier version. They were buried in thousands of emails.
Yeah, I saw, sorry.
As for the do_mac cmd, It looks something useful to add, I'll do that once Maxime's EEPROM patches have landed as I will add support for that then. Also I want to use the generic eeprom layout stuff for the layout then and at that point, it would be good to integrate the do_mac stuff.
The only thing I don't quite understand from looking at the code, is the name implies that you read/write/modify the MAC address in the rom with this, but I see that the two implementers have lots of other functions here, such as dumping the entire eeprom etc.
So what is the intend of do_mac? only MAC address related things, or full rom related tasks?
The EEPROM we have holds more than just MAC addresses. It also has system ID, errata, number of ports, and CRC32 checksum. You can see them in cmd/mac.c, or board/freescale/common/sys_eeprom.c.
The command "mac" can read data out, and it can write. This is EEPROM on I2C bus. We were requested to provide a tool to update the errata number and etc.
York
participants (5)
-
Joe Hershberger
-
o.schinagl@ultimaker.com
-
Olliver Schinagl
-
Simon Glass
-
York Sun