[PATCHv6 00/28] Retrieve MAC address from EEPROM

classic Classic list List threaded Threaded
73 messages Options
1234
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 00/28] Retrieve MAC address from EEPROM

Olliver Schinagl
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 as suggested by Igor Grinberg
* Add EEPROM/Mac commands suggested by York Sun

The series was initially based ontop of Joe's u-boot_net/next branches, but I
rebased it ontop of u-boot/master to get the latest sunxi changes, including:
sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC
ARM: dts: sunxi: Change node name for pwrseq pin on Olinuxino-lime2-emmc

Which are on their way to being merged in master. So once those land into master
this all should apply cleanly. Sorry Joe!

=======
Changes since v5:
* Removed changes to eth_legacy as per Simon's request
* Adapted, improved and fixed the emac/gmac Kconfig conversion
* Renamed sunxi_[eg]mac to sun[47]_mac to be more clear and allowing preparing
  to merge common parts into sunxi_common
* Added a few more MAC helpers
* Added PHY_GIGE as Kconfig symbol

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.

Emmanuel Vadot (1):
  ARM: dts: sunxi: Change node name for pwrseq pin on
    Olinuxino-lime2-emmc

Olliver Schinagl (27):
  sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC
  net: core: Add PHY_GIGE as a Kconfig symbol
  net: sunxi simplify defconfig
  net: sunxi: Re-add RTL8211X_PHY_FORCE_MASTER
  net: sunxi: Restore sunxi_[eg]mac behavior
  net: sunxi: Move GMAC_TX_DELAY to the driver
  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 MAC address helper functions
  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
  net: core: Check return value of read_rom_hwaddr
  fdt: fixup_eth: Remove code duplication with a function
  fdt: fixup_eth: improve error catching/reduce identation
  arm: sunxi: Expose function to generate sunxi-specific a MAC address
  net: sunxi_emac: Write HW address via net_ops hook
  net: sunxi: Rename sunxi_emac to a more specific sun4i_mac
  net: sunxi: Have sunxi common functions together
  net: sun4i_mac: Add read_rom_hwaddr hook
  net: sun7i_mac: Make the sun7i a dw driver subclass
  net: dw: Expose designware_eth_start
  net: sun7i_mac: Add read_rom_hwaddr hook
  net: sun8i_gmac: Add read_rom_hwaddr hook
  net: sun8i: fix whitespace
  net: sunxi: Enable eeprom on OLinuXino Lime boards (again)

 arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts |   2 +-
 arch/arm/include/asm/arch-sunxi/sys_proto.h     |   4 +-
 arch/arm/mach-sunxi/Kconfig                     |  14 +-
 arch/arm/mach-sunxi/board.c                     |   1 -
 board/sunxi/MAINTAINERS                         |   5 +
 board/sunxi/Makefile                            |   1 -
 board/sunxi/board.c                             | 146 ++++++++-----
 common/fdt_support.c                            |  33 ++-
 configs/A10-OLinuXino-Lime_defconfig            |   4 +-
 configs/A20-OLinuXino-Lime2-eMMC_defconfig      |  36 ++++
 configs/A20-OLinuXino-Lime2_defconfig           |   8 +-
 configs/A20-OLinuXino-Lime_defconfig            |   8 +-
 configs/A20-OLinuXino_MICRO_defconfig           |   8 +-
 configs/A20-Olimex-SOM-EVB_defconfig            |   4 +-
 configs/Bananapi_defconfig                      |   3 +-
 configs/Bananapro_defconfig                     |   3 +-
 configs/CSQ_CS908_defconfig                     |   4 +-
 configs/Colombus_defconfig                      |   3 +-
 configs/Cubieboard2_defconfig                   |   4 +-
 configs/Cubietruck_defconfig                    |   3 +-
 configs/Hummingbird_A31_defconfig               |   3 +-
 configs/Itead_Ibox_A20_defconfig                |   4 +-
 configs/Lamobo_R1_defconfig                     |   3 +-
 configs/Linksprite_pcDuino3_Nano_defconfig      |   3 +-
 configs/Linksprite_pcDuino3_defconfig           |   4 +-
 configs/Mele_A1000G_quad_defconfig              |   4 +-
 configs/Mele_I7_defconfig                       |   4 +-
 configs/Mele_M3_defconfig                       |   4 +-
 configs/Mele_M5_defconfig                       |   4 +-
 configs/Mele_M9_defconfig                       |   4 +-
 configs/Orangepi_defconfig                      |   3 +-
 configs/Orangepi_mini_defconfig                 |   3 +-
 configs/Sinlinx_SinA31s_defconfig               |   4 +-
 configs/Sinovoip_BPI_M2_defconfig               |   3 +-
 configs/Wits_Pro_A20_DKT_defconfig              |   3 +-
 configs/i12-tvbox_defconfig                     |   4 +-
 configs/icnova-a20-swac_defconfig               |   4 +-
 configs/mixtile_loftq_defconfig                 |   3 +-
 doc/README.enetaddr                             |  95 +++++++++
 drivers/net/Kconfig                             |  76 +++++--
 drivers/net/Makefile                            |   5 +-
 drivers/net/designware.c                        |   3 +-
 drivers/net/designware.h                        |   1 +
 drivers/net/{sunxi_emac.c => sun4i_mac.c}       | 267 +++++++++++++-----------
 board/sunxi/gmac.c => drivers/net/sun7i_mac.c   |  54 ++++-
 drivers/net/sun8i_emac.c                        |  15 +-
 drivers/net/sunxi_common.c                      |  33 +++
 drivers/net/sunxi_common.h                      |  13 ++
 include/configs/sunxi-common.h                  |  13 +-
 include/net.h                                   |  76 ++++++-
 net/Kconfig                                     |  59 ++++++
 net/eth-uclass.c                                |  65 +++---
 net/eth_common.c                                |  53 ++++-
 net/eth_legacy.c                                |   4 +-
 scripts/config_whitelist.txt                    |   2 -
 55 files changed, 842 insertions(+), 350 deletions(-)
 create mode 100644 configs/A20-OLinuXino-Lime2-eMMC_defconfig
 rename drivers/net/{sunxi_emac.c => sun4i_mac.c} (59%)
 rename board/sunxi/gmac.c => drivers/net/sun7i_mac.c (67%)
 create mode 100644 drivers/net/sunxi_common.c
 create mode 100644 drivers/net/sunxi_common.h

--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 01/28] ARM: dts: sunxi: Change node name for pwrseq pin on Olinuxino-lime2-emmc

Olliver Schinagl
From: Emmanuel Vadot <[hidden email]>

The node name for the power seq pin is mmc2@0 like the mmc2_pins_a one.
This makes the original node (mmc2_pins_a) scrapped out of the dtb and
result in a unusable eMMC if U-Boot didn't configured the pins to the
correct functions.

Signed-off-by: Emmanuel Vadot <[hidden email]>
Signed-off-by: Maxime Ripard <[hidden email]>
Signed-off-by: Olliver Schinagl <[hidden email]>
---
 arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts b/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts
index 5ea4915f6d..10d307408f 100644
--- a/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts
+++ b/arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts
@@ -56,7 +56,7 @@
 };
 
 &pio {
- mmc2_pins_nrst: mmc2@0 {
+ mmc2_pins_nrst: mmc2-rst-pin {
  allwinner,pins = "PC16";
  allwinner,function = "gpio_out";
  allwinner,drive = <SUN4I_PINCTRL_10_MA>;
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 02/28] sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC

Olliver Schinagl
In reply to this post by Olliver Schinagl
This patch adds support for the Olimex OLinuXino Lime2 with eMMC flash
storage.
https://www.olimex.com/Products/OLinuXino/A20/A20-OLinuXino-LIME2-eMMC/

It is a assembly variant of the regular Lime2 but featuring eMMC for
storage.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 board/sunxi/MAINTAINERS                    |  5 +++++
 configs/A20-OLinuXino-Lime2-eMMC_defconfig | 36 ++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 configs/A20-OLinuXino-Lime2-eMMC_defconfig

diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS
index 1c8817375d..1d3742c744 100644
--- a/board/sunxi/MAINTAINERS
+++ b/board/sunxi/MAINTAINERS
@@ -89,6 +89,11 @@ M: Iain Paton <[hidden email]>
 S: Maintained
 F: configs/A20-OLinuXino-Lime2_defconfig
 
+A20-OLINUXINO-LIME2-EMMC BOARD
+M: Olliver Schinagl <[hidden email]>
+S: Maintained
+F: configs/A20-OLinuXino-Lime2-eMMC_defconfig
+
 A33-OLINUXINO BOARD
 M: Stefan Mavrodiev <[hidden email]>
 S: Maintained
diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
new file mode 100644
index 0000000000..034ae983a5
--- /dev/null
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -0,0 +1,36 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_MACH_SUN7I=y
+CONFIG_DRAM_CLK=384
+CONFIG_MMC0_CD_PIN="PH1"
+CONFIG_MMC_SUNXI_SLOT_EXTRA=2
+CONFIG_USB0_VBUS_PIN="PC17"
+CONFIG_USB0_VBUS_DET="PH5"
+CONFIG_I2C1_ENABLE=y
+CONFIG_SATAPWR="PC3"
+CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime2-emmc"
+CONFIG_AHCI=y
+# CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
+CONFIG_SPL=y
+CONFIG_SPL_I2C_SUPPORT=y
+# CONFIG_CMD_IMLS is not set
+# CONFIG_CMD_FLASH is not set
+CONFIG_CMD_DFU=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+# CONFIG_CMD_FPGA is not set
+# CONFIG_SPL_DOS_PARTITION is not set
+# CONFIG_SPL_ISO_PARTITION is not set
+# CONFIG_SPL_PARTITION_UUIDS is not set
+CONFIG_DFU_RAM=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_RGMII=y
+CONFIG_SUN7I_GMAC=y
+CONFIG_AXP_ALDO3_VOLT=2800
+CONFIG_AXP_ALDO4_VOLT=2800
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_MUSB_GADGET=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_G_DNL_MANUFACTURER="Allwinner Technology"
+CONFIG_G_DNL_VENDOR_NUM=0x1f3a
+CONFIG_G_DNL_PRODUCT_NUM=0x1010
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 03/28] net: core: Add PHY_GIGE as a Kconfig symbol

Olliver Schinagl
In reply to this post by Olliver Schinagl
Add the CONFIG_PHY_GIGE option as a hidden Kconfig symbol so that we
can select it from the menu as a dependency.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 drivers/net/Kconfig            | 4 ++++
 include/configs/sunxi-common.h | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9cd0d94cbd..336557f395 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -155,6 +155,9 @@ config RGMII
   Enable the support of the Reduced Gigabit Media-Independent
   Interface (RGMII).
 
+config PHY_GIGE
+ bool
+
 config RTL8139
  bool "Realtek 8139 series Ethernet controller driver"
  help
@@ -169,6 +172,7 @@ config RTL8169
 
 config SUN7I_GMAC
  bool "Enable Allwinner GMAC Ethernet support"
+ select PHY_GIGE
  help
   Enable the support for Sun7i GMAC Ethernet controller
 
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 997a92c8be..3d8a130f38 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -294,7 +294,6 @@ extern int soft_i2c_gpio_scl;
 #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
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 04/28] net: sunxi simplify defconfig

Olliver Schinagl
In reply to this post by Olliver Schinagl
We currently have a few dependencies explicitly set in the sunxi
defconfigs. Things such as, RGMII, DESIGNWARE_ETH in combination with
SUN7I_GMAC. When selecting SUN7I_GMAC we already imply DESIGNWARE_ETH
for example.

This patch puts this logic into the Kconfig thus simplifying the
defconfigs. For a user it is also no more logical when enabling one of
the drivers in Kconfig to have the proper dependencies automatically
selected.

One thing to note, the sun7i driver can be connected in two modes,
RGMII and MII mode and we use both throughout the boards. To make this
easy we split up the CONFIG_SUNXI_GMAC symbol into the SUN7I_GMAC and
the SUN7I_EMAC symbol, where the SUN7I_EMAC indicates a MII connected
designware IP.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 configs/A20-OLinuXino-Lime2-eMMC_defconfig |  2 --
 configs/A20-OLinuXino-Lime2_defconfig      |  2 --
 configs/A20-OLinuXino-Lime_defconfig       |  3 +-
 configs/A20-OLinuXino_MICRO_defconfig      |  3 +-
 configs/A20-Olimex-SOM-EVB_defconfig       |  2 --
 configs/Bananapi_defconfig                 |  2 --
 configs/Bananapro_defconfig                |  2 --
 configs/CSQ_CS908_defconfig                |  3 +-
 configs/Colombus_defconfig                 |  2 --
 configs/Cubieboard2_defconfig              |  3 +-
 configs/Cubietruck_defconfig               |  2 --
 configs/Hummingbird_A31_defconfig          |  2 --
 configs/Itead_Ibox_A20_defconfig           |  3 +-
 configs/Lamobo_R1_defconfig                |  2 --
 configs/Linksprite_pcDuino3_Nano_defconfig |  2 --
 configs/Linksprite_pcDuino3_defconfig      |  3 +-
 configs/Mele_A1000G_quad_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                 |  2 --
 configs/Orangepi_mini_defconfig            |  2 --
 configs/Sinlinx_SinA31s_defconfig          |  3 +-
 configs/Sinovoip_BPI_M2_defconfig          |  2 --
 configs/Wits_Pro_A20_DKT_defconfig         |  2 --
 configs/i12-tvbox_defconfig                |  3 +-
 configs/icnova-a20-swac_defconfig          |  3 +-
 configs/mixtile_loftq_defconfig            |  2 --
 drivers/net/Kconfig                        | 54 ++++++++++++++++++++++++------
 include/configs/sunxi-common.h             |  3 --
 31 files changed, 57 insertions(+), 72 deletions(-)

diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 034ae983a5..76525f4603 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -22,8 +22,6 @@ 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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
index 1f2daa6706..aa8a5d5f2b 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -21,8 +21,6 @@ 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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig
index 7f63d4af54..b4b2f66ccb 100644
--- a/configs/A20-OLinuXino-Lime_defconfig
+++ b/configs/A20-OLinuXino-Lime_defconfig
@@ -16,8 +16,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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=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 89e87e799b..d59a480e8d 100644
--- a/configs/A20-OLinuXino_MICRO_defconfig
+++ b/configs/A20-OLinuXino_MICRO_defconfig
@@ -19,8 +19,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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig
index 6c87648d4f..d52aefc984 100644
--- a/configs/A20-Olimex-SOM-EVB_defconfig
+++ b/configs/A20-Olimex-SOM-EVB_defconfig
@@ -20,8 +20,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_ETH_DESIGNWARE=y
-CONFIG_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig
index fe75eef513..5a45506571 100644
--- a/configs/Bananapi_defconfig
+++ b/configs/Bananapi_defconfig
@@ -17,7 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig
index df65922e83..1503c41d3e 100644
--- a/configs/Bananapro_defconfig
+++ b/configs/Bananapro_defconfig
@@ -19,8 +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_RGMII=y
 CONFIG_SUN7I_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 a6fcbf5ecf..cac210c1e8 100644
--- a/configs/CSQ_CS908_defconfig
+++ b/configs/CSQ_CS908_defconfig
@@ -13,8 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=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 1359281ff4..7ce5d5ae2b 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -23,8 +23,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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Cubieboard2_defconfig b/configs/Cubieboard2_defconfig
index 02c503f672..09b423104e 100644
--- a/configs/Cubieboard2_defconfig
+++ b/configs/Cubieboard2_defconfig
@@ -15,6 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig
index f9d56c8f9d..44082ccd30 100644
--- a/configs/Cubietruck_defconfig
+++ b/configs/Cubietruck_defconfig
@@ -23,8 +23,6 @@ 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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_MUSB_GADGET=y
diff --git a/configs/Hummingbird_A31_defconfig b/configs/Hummingbird_A31_defconfig
index 6f9b103207..c25bccc3f5 100644
--- a/configs/Hummingbird_A31_defconfig
+++ b/configs/Hummingbird_A31_defconfig
@@ -15,8 +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_RGMII=y
 CONFIG_SUN7I_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 4bae19f2fa..2179306666 100644
--- a/configs/Itead_Ibox_A20_defconfig
+++ b/configs/Itead_Ibox_A20_defconfig
@@ -15,6 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Lamobo_R1_defconfig b/configs/Lamobo_R1_defconfig
index cc29d606a9..e7b9ad7920 100644
--- a/configs/Lamobo_R1_defconfig
+++ b/configs/Lamobo_R1_defconfig
@@ -17,7 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig
index 80416cb7b1..74789ca56e 100644
--- a/configs/Linksprite_pcDuino3_Nano_defconfig
+++ b/configs/Linksprite_pcDuino3_Nano_defconfig
@@ -17,7 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig
index b9f89a013e..1aa253abcb 100644
--- a/configs/Linksprite_pcDuino3_defconfig
+++ b/configs/Linksprite_pcDuino3_defconfig
@@ -15,6 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Mele_A1000G_quad_defconfig b/configs/Mele_A1000G_quad_defconfig
index 5b1b5f5d7c..0152b21303 100644
--- a/configs/Mele_A1000G_quad_defconfig
+++ b/configs/Mele_A1000G_quad_defconfig
@@ -14,8 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_AXP_DCDC1_VOLT=3300
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_DLDO1_VOLT=3300
diff --git a/configs/Mele_I7_defconfig b/configs/Mele_I7_defconfig
index b60969787c..12f0c1a83c 100644
--- a/configs/Mele_I7_defconfig
+++ b/configs/Mele_I7_defconfig
@@ -13,8 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=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 08e8c2dbde..382c45b800 100644
--- a/configs/Mele_M3_defconfig
+++ b/configs/Mele_M3_defconfig
@@ -16,6 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig
index 4c377e3daf..594b230ff1 100644
--- a/configs/Mele_M5_defconfig
+++ b/configs/Mele_M5_defconfig
@@ -16,6 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig
index dc7901f9af..64a111ec6a 100644
--- a/configs/Mele_M9_defconfig
+++ b/configs/Mele_M9_defconfig
@@ -13,8 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=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 b8c1ea4d7c..34eeb92fa6 100644
--- a/configs/Orangepi_defconfig
+++ b/configs/Orangepi_defconfig
@@ -19,7 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig
index 19c35ef103..2609c54bc2 100644
--- a/configs/Orangepi_mini_defconfig
+++ b/configs/Orangepi_mini_defconfig
@@ -21,7 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Sinlinx_SinA31s_defconfig b/configs/Sinlinx_SinA31s_defconfig
index 7f815a32cb..bdf6ebe9f5 100644
--- a/configs/Sinlinx_SinA31s_defconfig
+++ b/configs/Sinlinx_SinA31s_defconfig
@@ -17,7 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=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 a2cadbc271..78afc6d668 100644
--- a/configs/Sinovoip_BPI_M2_defconfig
+++ b/configs/Sinovoip_BPI_M2_defconfig
@@ -13,8 +13,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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_ALDO2_VOLT=1800
diff --git a/configs/Wits_Pro_A20_DKT_defconfig b/configs/Wits_Pro_A20_DKT_defconfig
index 8658ef6b4c..979c6a6ae8 100644
--- a/configs/Wits_Pro_A20_DKT_defconfig
+++ b/configs/Wits_Pro_A20_DKT_defconfig
@@ -19,7 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig
index 4245491b6a..b609514de8 100644
--- a/configs/i12-tvbox_defconfig
+++ b/configs/i12-tvbox_defconfig
@@ -14,6 +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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/icnova-a20-swac_defconfig b/configs/icnova-a20-swac_defconfig
index 6f79c587ee..63bbd37f97 100644
--- a/configs/icnova-a20-swac_defconfig
+++ b/configs/icnova-a20-swac_defconfig
@@ -21,6 +21,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_SUN7I_GMAC=y
+CONFIG_SUN7I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/mixtile_loftq_defconfig b/configs/mixtile_loftq_defconfig
index 6264b3a151..47289c6616 100644
--- a/configs/mixtile_loftq_defconfig
+++ b/configs/mixtile_loftq_defconfig
@@ -15,8 +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_RGMII=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 336557f395..c0d141754f 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -149,11 +149,11 @@ config PCH_GBE
   This MAC is present in Intel Platform Controller Hub EG20T. It
   supports 10/100/1000 Mbps operation.
 
+config MII
+ bool
+
 config RGMII
- bool "Enable RGMII"
- help
-  Enable the support of the Reduced Gigabit Media-Independent
-  Interface (RGMII).
+ bool
 
 config PHY_GIGE
  bool
@@ -170,17 +170,49 @@ config RTL8169
   This driver supports Realtek 8169 series gigabit ethernet family of
   PCI/PCIe chipsets/adapters.
 
-config SUN7I_GMAC
- bool "Enable Allwinner GMAC Ethernet support"
- select PHY_GIGE
- help
-  Enable the support for Sun7i GMAC Ethernet controller
-
 config SUN4I_EMAC
  bool "Allwinner Sun4i Ethernet MAC support"
  depends on DM_ETH
+ select MII
+ select PHYLIB
+ help
+  This driver provides the Allwinner based SoCs with 100 Megabit
+  network support as it is found on the sun4i and sun7i. This driver
+  is known to have performance issues and should only be used on
+  sun4i hardware. Newer hardware supports the SUN7I_EMAC driver,
+  which also works with 100 Megabit PHY's.
+
+choice
+ prompt "Allwinner Sun7i GMAC support"
  help
-  This driver supports the Allwinner based SUN4I Ethernet MAC.
+  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 SUN4I_EMAC driver.
+
+config SUN7I_NONE
+ bool "Disable"
+
+config SUN7I_EMAC
+ bool "MII"
+ select ETH_DESIGNWARE
+ select PHYLIB
+ select MII
+ help
+  If connecting the sun7i MAC to an ethernet (10/100) only PHY,
+  select this option.
+
+config SUN7I_GMAC
+ bool "RGMII"
+ select ETH_DESIGNWARE
+ select PHYLIB
+ select RGMII
+ select PHY_GIGE
+ help
+  If connecting the sun7i MAC to a gigabit ethernet PHY, select
+  this option.
+
+endchoice
 
 config SUN8I_EMAC
         bool "Allwinner Sun8i Ethernet MAC support"
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 3d8a130f38..8f97b80619 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -289,13 +289,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_ADDR 1
-#define CONFIG_MII /* MII PHY management */
 #define CONFIG_PHY_REALTEK
 #endif
 
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 05/28] net: sunxi: Re-add RTL8211X_PHY_FORCE_MASTER

Olliver Schinagl
In reply to this post by Olliver Schinagl
Commit 8728c97eff5bd9 (" configs: Re-sync") potentially broke the lime2
as it removed the RTL8211X_PHY_FORCE_MASTER flag.

Re-add this flag.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 configs/A20-OLinuXino-Lime2_defconfig | 1 +
 configs/A20-Olimex-SOM-EVB_defconfig  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
index aa8a5d5f2b..14d1159ead 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_RTL8211X_PHY_FORCE_MASTER=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig
index d52aefc984..59388ba7f4 100644
--- a/configs/A20-Olimex-SOM-EVB_defconfig
+++ b/configs/A20-Olimex-SOM-EVB_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_RTL8211X_PHY_FORCE_MASTER=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 06/28] net: sunxi: Restore sunxi_[eg]mac behavior

Olliver Schinagl
In reply to this post by Olliver Schinagl
Commit 4d43d065db326 ("sunxi: Move SUNXI_GMAC to Kconfig") renamed
SUNXI_[EG]MAC but did not update include/configs/sunxi-common.h where
based on these two symbols other config symbols where being set, such
as CONFIG_PHY_REALTEK for SUNXI_GMAC boards and the CONFIG_PHY_ADDR
being set to a safe default.

This patch restores that behavior by adding the PHY_REALTEK to the
defconfigs, where they belong and by setting the address based on the
new config symbols.

Additionally, we use the new renamed symbol in the Makefiles to
actually compile the drivers.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 arch/arm/include/asm/arch-sunxi/sys_proto.h | 2 +-
 board/sunxi/Makefile                        | 2 +-
 configs/A20-OLinuXino-Lime2_defconfig       | 1 +
 configs/A20-OLinuXino-Lime_defconfig        | 1 +
 configs/A20-OLinuXino_MICRO_defconfig       | 1 +
 configs/A20-Olimex-SOM-EVB_defconfig        | 1 +
 configs/Bananapi_defconfig                  | 1 +
 configs/Bananapro_defconfig                 | 1 +
 configs/CSQ_CS908_defconfig                 | 1 +
 configs/Colombus_defconfig                  | 1 +
 configs/Cubieboard2_defconfig               | 1 +
 configs/Cubietruck_defconfig                | 1 +
 configs/Hummingbird_A31_defconfig           | 1 +
 configs/Itead_Ibox_A20_defconfig            | 1 +
 configs/Lamobo_R1_defconfig                 | 1 +
 configs/Linksprite_pcDuino3_Nano_defconfig  | 1 +
 configs/Linksprite_pcDuino3_defconfig       | 1 +
 configs/Mele_A1000G_quad_defconfig          | 1 +
 configs/Mele_I7_defconfig                   | 1 +
 configs/Mele_M3_defconfig                   | 1 +
 configs/Mele_M5_defconfig                   | 1 +
 configs/Mele_M9_defconfig                   | 1 +
 configs/Orangepi_defconfig                  | 1 +
 configs/Orangepi_mini_defconfig             | 1 +
 configs/Sinlinx_SinA31s_defconfig           | 1 +
 configs/Sinovoip_BPI_M2_defconfig           | 1 +
 configs/Wits_Pro_A20_DKT_defconfig          | 1 +
 configs/i12-tvbox_defconfig                 | 1 +
 configs/icnova-a20-swac_defconfig           | 1 +
 configs/mixtile_loftq_defconfig             | 1 +
 drivers/net/Kconfig                         | 5 +++++
 drivers/net/Makefile                        | 2 +-
 include/configs/sunxi-common.h              | 9 +++------
 scripts/config_whitelist.txt                | 2 --
 34 files changed, 39 insertions(+), 11 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..850236ed42 100644
--- a/arch/arm/include/asm/arch-sunxi/sys_proto.h
+++ b/arch/arm/include/asm/arch-sunxi/sys_proto.h
@@ -24,7 +24,7 @@ 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
+#if !defined CONFIG_SPL_BUILD && defined CONFIG_SUN7I_MAC
 void eth_init_board(void);
 #else
 static inline void eth_init_board(void) {}
diff --git a/board/sunxi/Makefile b/board/sunxi/Makefile
index 43766e0ef4..b4768b9b9b 100644
--- a/board/sunxi/Makefile
+++ b/board/sunxi/Makefile
@@ -9,7 +9,7 @@
 # SPDX-License-Identifier: GPL-2.0+
 #
 obj-y += board.o
-obj-$(CONFIG_SUNXI_GMAC) += gmac.o
+obj-$(CONFIG_SUN7I_MAC) += 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/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
index 14d1159ead..14a51ef3f9 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -22,6 +22,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_RTL8211X_PHY_FORCE_MASTER=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig
index b4b2f66ccb..3fdf7c64aa 100644
--- a/configs/A20-OLinuXino-Lime_defconfig
+++ b/configs/A20-OLinuXino-Lime_defconfig
@@ -17,6 +17,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=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 d59a480e8d..ea7bc73dda 100644
--- a/configs/A20-OLinuXino_MICRO_defconfig
+++ b/configs/A20-OLinuXino_MICRO_defconfig
@@ -20,6 +20,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/A20-Olimex-SOM-EVB_defconfig b/configs/A20-Olimex-SOM-EVB_defconfig
index 59388ba7f4..8a2dfad526 100644
--- a/configs/A20-Olimex-SOM-EVB_defconfig
+++ b/configs/A20-Olimex-SOM-EVB_defconfig
@@ -21,6 +21,7 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_RTL8211X_PHY_FORCE_MASTER=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig
index 5a45506571..eac3175f2d 100644
--- a/configs/Bananapi_defconfig
+++ b/configs/Bananapi_defconfig
@@ -18,4 +18,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_NETCONSOLE=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig
index 1503c41d3e..ef1ff21a39 100644
--- a/configs/Bananapro_defconfig
+++ b/configs/Bananapro_defconfig
@@ -20,5 +20,6 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_NETCONSOLE=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_AXP_ALDO4_VOLT=2500
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/CSQ_CS908_defconfig b/configs/CSQ_CS908_defconfig
index cac210c1e8..b771ab068d 100644
--- a/configs/CSQ_CS908_defconfig
+++ b/configs/CSQ_CS908_defconfig
@@ -14,6 +14,7 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=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 7ce5d5ae2b..dd4eefb98a 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -24,5 +24,6 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Cubieboard2_defconfig b/configs/Cubieboard2_defconfig
index 09b423104e..072ac047a6 100644
--- a/configs/Cubieboard2_defconfig
+++ b/configs/Cubieboard2_defconfig
@@ -16,4 +16,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig
index 44082ccd30..fe15fea717 100644
--- a/configs/Cubietruck_defconfig
+++ b/configs/Cubietruck_defconfig
@@ -24,6 +24,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=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 c25bccc3f5..245b33d6dc 100644
--- a/configs/Hummingbird_A31_defconfig
+++ b/configs/Hummingbird_A31_defconfig
@@ -16,5 +16,6 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=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 2179306666..496b860954 100644
--- a/configs/Itead_Ibox_A20_defconfig
+++ b/configs/Itead_Ibox_A20_defconfig
@@ -16,4 +16,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Lamobo_R1_defconfig b/configs/Lamobo_R1_defconfig
index e7b9ad7920..7979f4da21 100644
--- a/configs/Lamobo_R1_defconfig
+++ b/configs/Lamobo_R1_defconfig
@@ -18,4 +18,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig
index 74789ca56e..6586c2168f 100644
--- a/configs/Linksprite_pcDuino3_Nano_defconfig
+++ b/configs/Linksprite_pcDuino3_Nano_defconfig
@@ -18,4 +18,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig
index 1aa253abcb..f0290d82dd 100644
--- a/configs/Linksprite_pcDuino3_defconfig
+++ b/configs/Linksprite_pcDuino3_defconfig
@@ -16,4 +16,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Mele_A1000G_quad_defconfig b/configs/Mele_A1000G_quad_defconfig
index 0152b21303..798745d40b 100644
--- a/configs/Mele_A1000G_quad_defconfig
+++ b/configs/Mele_A1000G_quad_defconfig
@@ -15,6 +15,7 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_AXP_DCDC1_VOLT=3300
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_AXP_DLDO1_VOLT=3300
diff --git a/configs/Mele_I7_defconfig b/configs/Mele_I7_defconfig
index 12f0c1a83c..8ccc93bb86 100644
--- a/configs/Mele_I7_defconfig
+++ b/configs/Mele_I7_defconfig
@@ -14,6 +14,7 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=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 382c45b800..e5fcdd34cf 100644
--- a/configs/Mele_M3_defconfig
+++ b/configs/Mele_M3_defconfig
@@ -17,4 +17,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig
index 594b230ff1..45c0d26791 100644
--- a/configs/Mele_M5_defconfig
+++ b/configs/Mele_M5_defconfig
@@ -17,4 +17,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig
index 64a111ec6a..efa52f92f8 100644
--- a/configs/Mele_M9_defconfig
+++ b/configs/Mele_M9_defconfig
@@ -14,6 +14,7 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=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 34eeb92fa6..2fe3f5978d 100644
--- a/configs/Orangepi_defconfig
+++ b/configs/Orangepi_defconfig
@@ -20,4 +20,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig
index 2609c54bc2..71a93b58a5 100644
--- a/configs/Orangepi_mini_defconfig
+++ b/configs/Orangepi_mini_defconfig
@@ -22,4 +22,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/Sinlinx_SinA31s_defconfig b/configs/Sinlinx_SinA31s_defconfig
index bdf6ebe9f5..c6f98e4572 100644
--- a/configs/Sinlinx_SinA31s_defconfig
+++ b/configs/Sinlinx_SinA31s_defconfig
@@ -18,5 +18,6 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=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 78afc6d668..fe5845e670 100644
--- a/configs/Sinovoip_BPI_M2_defconfig
+++ b/configs/Sinovoip_BPI_M2_defconfig
@@ -14,6 +14,7 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=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 979c6a6ae8..57298f1ea4 100644
--- a/configs/Wits_Pro_A20_DKT_defconfig
+++ b/configs/Wits_Pro_A20_DKT_defconfig
@@ -20,4 +20,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig
index b609514de8..f423e57867 100644
--- a/configs/i12-tvbox_defconfig
+++ b/configs/i12-tvbox_defconfig
@@ -15,4 +15,5 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/icnova-a20-swac_defconfig b/configs/icnova-a20-swac_defconfig
index 63bbd37f97..f158220225 100644
--- a/configs/icnova-a20-swac_defconfig
+++ b/configs/icnova-a20-swac_defconfig
@@ -22,4 +22,5 @@ CONFIG_CMD_UNZIP=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_USB_EHCI_HCD=y
diff --git a/configs/mixtile_loftq_defconfig b/configs/mixtile_loftq_defconfig
index 47289c6616..4c81b3d7b3 100644
--- a/configs/mixtile_loftq_defconfig
+++ b/configs/mixtile_loftq_defconfig
@@ -16,5 +16,6 @@ CONFIG_SPL=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_GMAC=y
+CONFIG_PHY_REALTEK=y
 CONFIG_AXP_ALDO1_VOLT=3300
 CONFIG_USB_EHCI_HCD=y
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index c0d141754f..04e8cf39c8 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -182,6 +182,9 @@ config SUN4I_EMAC
   sun4i hardware. Newer hardware supports the SUN7I_EMAC driver,
   which also works with 100 Megabit PHY's.
 
+config SUN7I_MAC
+ bool
+
 choice
  prompt "Allwinner Sun7i GMAC support"
  help
@@ -196,6 +199,7 @@ config SUN7I_NONE
 config SUN7I_EMAC
  bool "MII"
  select ETH_DESIGNWARE
+ select SUN7I_MAC
  select PHYLIB
  select MII
  help
@@ -205,6 +209,7 @@ config SUN7I_EMAC
 config SUN7I_GMAC
  bool "RGMII"
  select ETH_DESIGNWARE
+ select SUN7I_MAC
  select PHYLIB
  select RGMII
  select PHY_GIGE
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index aedb2cc90d..c5dd52bee2 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -22,7 +22,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_SUN4I_EMAC) += sunxi_emac.o
 obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
 obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_EP93XX) += ep93xx_eth.o
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 8f97b80619..5d2c5b9040 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -287,15 +287,12 @@ extern int soft_i2c_gpio_scl;
 #endif /* CONFIG_VIDEO */
 
 /* Ethernet support */
-#ifdef CONFIG_SUNXI_EMAC
+#if defined(CONFIG_SUN4I_EMAC) || \
+    defined(CONFIG_SUN7I_EMAC) || \
+    defined(CONFIG_SUN7I_GMAC)
 #define CONFIG_PHY_ADDR 1
 #endif
 
-#ifdef CONFIG_SUNXI_GMAC
-#define CONFIG_PHY_ADDR 1
-#define CONFIG_PHY_REALTEK
-#endif
-
 #ifdef CONFIG_USB_EHCI_HCD
 #define CONFIG_USB_OHCI_NEW
 #define CONFIG_USB_OHCI_SUNXI
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index cd0165f934..1e2bf24d5a 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -2796,8 +2796,6 @@ CONFIG_STV0991_HZ
 CONFIG_STV0991_HZ_CLOCK
 CONFIG_ST_SMI
 CONFIG_SUNXI_AHCI
-CONFIG_SUNXI_EMAC
-CONFIG_SUNXI_GMAC
 CONFIG_SUNXI_GPIO
 CONFIG_SUNXI_MAX_FB_SIZE
 CONFIG_SUNXI_USB_PHYS
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 07/28] net: sunxi: Move GMAC_TX_DELAY to the driver

Olliver Schinagl
In reply to this post by Olliver Schinagl
The GMAC_TX_DELAY symbol sets and is dependent on the SUN7I_GMAC
driver. Move it from the generic ARCH section to the driver specific
section.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 arch/arm/mach-sunxi/Kconfig | 6 ------
 drivers/net/Kconfig         | 7 +++++++
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 8d9900e00b..be060b65dc 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -748,12 +748,6 @@ config SATAPWR
   format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of
   port H.
 
-config GMAC_TX_DELAY
- int "GMAC Transmit Clock Delay Chain"
- default 0
- ---help---
- Set the GMAC Transmit Clock Delay Chain value.
-
 config SPL_STACK_R_ADDR
  default 0x4fe00000 if MACH_SUN4I
  default 0x4fe00000 if MACH_SUN5I
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 04e8cf39c8..782348f872 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -219,6 +219,13 @@ config SUN7I_GMAC
 
 endchoice
 
+config GMAC_TX_DELAY
+ depends on SUN7I_GMAC
+ int "- GMAC Transmit Clock Delay Chain"
+ default 0
+ help
+  Set the GMAC Transmit Clock Delay Chain value.
+
 config SUN8I_EMAC
         bool "Allwinner Sun8i Ethernet MAC support"
         depends on DM_ETH
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 08/28] net: cosmetic: Do not use magic values for ARP_HLEN

Olliver Schinagl
In reply to this post by Olliver Schinagl
Previously overlooked magic value in commit a40db6d51171 ("net: cosmetic: Do
not use magic values for ARP_HLEN")

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 include/net.h    | 4 ++--
 net/eth_common.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/net.h b/include/net.h
index ed5259a807..c703c62c99 100644
--- a/include/net.h
+++ b/include/net.h
@@ -275,7 +275,7 @@ int usb_ether_init(void);
  * Args:
  * base_name - base name for device (normally "eth")
  * index - device index number (0 for first)
- * enetaddr - returns 6 byte hardware address
+ * enetaddr - returns ARP_HLEN byte hardware address
  * Returns:
  * Return true if the address is valid.
  */
@@ -818,7 +818,7 @@ static inline void net_random_ethaddr(uchar *addr)
  int i;
  unsigned int seed = get_timer(0);
 
- for (i = 0; i < 6; i++)
+ for (i = 0; i < ARP_HLEN; i++)
  addr[i] = rand_r(&seed);
 
  addr[0] &= 0xfe; /* clear multicast bit */
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;
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 09/28] net: core: Sanitize get/set operations for enetaddr

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 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 c703c62c99..ad2a8a3678 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);
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 10/28] net: core: Inform the user of the device MAC address

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 net/eth-uclass.c | 9 ++++++---
 1 file changed, 6 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;
 }
 
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 11/28] net: core: Add MAC address helper functions

Olliver Schinagl
In reply to this post by Olliver Schinagl
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.

Unicast and multicast addresses are distinguised by setting the
least-significant bit of the first octet of the address. Having a
function to check and set this U/M bit from a function it nice to
make a generated mac address a unicast address.

This patch introduces both these helper functions

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 include/net.h | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/include/net.h b/include/net.h
index ad2a8a3678..00677a0a89 100644
--- a/include/net.h
+++ b/include/net.h
@@ -767,6 +767,9 @@ static inline int is_zero_ethaddr(const u8 *addr)
  return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
 }
 
+/* IEEE802 Unicast/Multicast bit */
+#define IEEE802_UM_BIT 0x1
+
 /**
  * is_multicast_ethaddr - Determine if the Ethernet address is a multicast.
  * @addr: Pointer to a six-byte array containing the Ethernet address
@@ -776,7 +779,41 @@ static inline int is_zero_ethaddr(const u8 *addr)
  */
 static inline int is_multicast_ethaddr(const u8 *addr)
 {
- return 0x01 & addr[0];
+ return addr[0] & IEEE802_UM_BIT;
+}
+
+/**
+ * set_unicast_ethaddr - Make the supplied Ethernet address an unicast.
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ */
+static inline void set_unicast_ethaddr(u8 *addr)
+{
+ addr[0] &= ~IEEE802_UM_BIT;
+}
+
+/* IEEE802 Universal/Local administration bit */
+#define IEEE802_UL_BIT 0x02
+
+/**
+ * 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 addr[0] & IEEE802_UL_BIT;
+}
+
+/**
+ * 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] |= IEEE802_UL_BIT;
 }
 
 /*
@@ -822,8 +859,8 @@ static inline void net_random_ethaddr(uchar *addr)
  for (i = 0; i < ARP_HLEN; i++)
  addr[i] = rand_r(&seed);
 
- addr[0] &= 0xfe; /* clear multicast bit */
- addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
+ addr[0] &= ~IEEE802_UM_BIT;
+ set_local_ethaddr(addr);
 }
 
 /* Convert an IP address to a string */
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 12/28] net: Add ability to set MAC address via EEPROM

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 arch/arm/mach-sunxi/Kconfig                |  8 +--
 configs/A10-OLinuXino-Lime_defconfig       |  1 -
 configs/A20-OLinuXino-Lime2-eMMC_defconfig |  1 -
 configs/A20-OLinuXino-Lime2_defconfig      |  1 -
 configs/A20-OLinuXino-Lime_defconfig       |  1 -
 configs/A20-OLinuXino_MICRO_defconfig      |  1 -
 doc/README.enetaddr                        | 95 ++++++++++++++++++++++++++++++
 include/net.h                              | 14 +++++
 net/Kconfig                                | 59 +++++++++++++++++++
 net/eth-uclass.c                           | 42 +++++++------
 net/eth_common.c                           | 37 ++++++++++++
 net/eth_legacy.c                           |  2 +
 12 files changed, 231 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index be060b65dc..cf5af4fe18 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -479,14 +479,14 @@ config I2C0_ENABLE
 
 config I2C1_ENABLE
  bool "Enable I2C/TWI controller 1"
- default n
+ default y if (NET_ETHADDR_EEPROM_I2C_BUS = 1)
  select CMD_I2C
  ---help---
  See I2C0_ENABLE help text.
 
 config I2C2_ENABLE
  bool "Enable I2C/TWI controller 2"
- default n
+ default y if (NET_ETHADDR_EEPROM_I2C_BUS = 2)
  select CMD_I2C
  ---help---
  See I2C0_ENABLE help text.
@@ -494,7 +494,7 @@ config I2C2_ENABLE
 if MACH_SUN6I || MACH_SUN7I
 config I2C3_ENABLE
  bool "Enable I2C/TWI controller 3"
- default n
+ default y if (NET_ETHADDR_EEPROM_I2C_BUS = 3)
  select CMD_I2C
  ---help---
  See I2C0_ENABLE help text.
@@ -513,7 +513,7 @@ endif
 if MACH_SUN7I
 config I2C4_ENABLE
  bool "Enable I2C/TWI controller 4"
- default n
+ default y if (NET_ETHADDR_EEPROM_I2C_BUS = 4)
  select CMD_I2C
  ---help---
  See I2C0_ENABLE help text.
diff --git a/configs/A10-OLinuXino-Lime_defconfig b/configs/A10-OLinuXino-Lime_defconfig
index ec16a44fbd..d4513144eb 100644
--- a/configs/A10-OLinuXino-Lime_defconfig
+++ b/configs/A10-OLinuXino-Lime_defconfig
@@ -5,7 +5,6 @@ CONFIG_DRAM_CLK=480
 CONFIG_DRAM_EMR1=4
 CONFIG_SYS_CLK_FREQ=912000000
 CONFIG_MMC0_CD_PIN="PH1"
-CONFIG_I2C1_ENABLE=y
 CONFIG_SATAPWR="PC3"
 CONFIG_DEFAULT_DEVICE_TREE="sun4i-a10-olinuxino-lime"
 CONFIG_AHCI=y
diff --git a/configs/A20-OLinuXino-Lime2-eMMC_defconfig b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
index 76525f4603..fd743a5f45 100644
--- a/configs/A20-OLinuXino-Lime2-eMMC_defconfig
+++ b/configs/A20-OLinuXino-Lime2-eMMC_defconfig
@@ -6,7 +6,6 @@ CONFIG_MMC0_CD_PIN="PH1"
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 CONFIG_USB0_VBUS_PIN="PC17"
 CONFIG_USB0_VBUS_DET="PH5"
-CONFIG_I2C1_ENABLE=y
 CONFIG_SATAPWR="PC3"
 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime2-emmc"
 CONFIG_AHCI=y
diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig
index 14a51ef3f9..a932ec7b7b 100644
--- a/configs/A20-OLinuXino-Lime2_defconfig
+++ b/configs/A20-OLinuXino-Lime2_defconfig
@@ -5,7 +5,6 @@ CONFIG_DRAM_CLK=384
 CONFIG_MMC0_CD_PIN="PH1"
 CONFIG_USB0_VBUS_PIN="PC17"
 CONFIG_USB0_VBUS_DET="PH5"
-CONFIG_I2C1_ENABLE=y
 CONFIG_SATAPWR="PC3"
 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime2"
 CONFIG_AHCI=y
diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig
index 3fdf7c64aa..41667384f4 100644
--- a/configs/A20-OLinuXino-Lime_defconfig
+++ b/configs/A20-OLinuXino-Lime_defconfig
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_MACH_SUN7I=y
 CONFIG_DRAM_CLK=384
 CONFIG_MMC0_CD_PIN="PH1"
-CONFIG_I2C1_ENABLE=y
 CONFIG_SATAPWR="PC3"
 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-lime"
 CONFIG_AHCI=y
diff --git a/configs/A20-OLinuXino_MICRO_defconfig b/configs/A20-OLinuXino_MICRO_defconfig
index ea7bc73dda..b1f80835c9 100644
--- a/configs/A20-OLinuXino_MICRO_defconfig
+++ b/configs/A20-OLinuXino_MICRO_defconfig
@@ -5,7 +5,6 @@ CONFIG_DRAM_CLK=384
 CONFIG_MMC0_CD_PIN="PH1"
 CONFIG_MMC3_CD_PIN="PH11"
 CONFIG_MMC_SUNXI_SLOT_EXTRA=3
-CONFIG_I2C1_ENABLE=y
 CONFIG_VIDEO_VGA=y
 CONFIG_SATAPWR="PB8"
 CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-olinuxino-micro"
diff --git a/doc/README.enetaddr b/doc/README.enetaddr
index 50e4899787..6f51137710 100644
--- a/doc/README.enetaddr
+++ b/doc/README.enetaddr
@@ -47,6 +47,101 @@ 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> i2c dev 1
+u-boot> i2c md 0x50 0x08 0x01
+u-boot> i2c md 0x50 0x09 0x23
+u-boot> i2c md 0x50 0x0a 0x45
+u-boot> i2c md 0x50 0x0b 0x67
+u-boot> i2c md 0x50 0x0c 0x89
+u-boot> i2c md 0x50 0x0d 0xab
+u-boot> i2c md 0x50 0x0e 0xbe
+
 -------
  Usage
 -------
diff --git a/include/net.h b/include/net.h
index 00677a0a89..392dc95fdc 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 e4bd0f4c1a..4276058800 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)) {
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 13/28] net: core: print the source of the MAC address

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 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 392dc95fdc..762ff2b319 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]");
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 14/28] net: cosmetic: A MAC address is not limited to SROM

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 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 4276058800..800b91c327 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);
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 15/28] net: core: Check return value of read_rom_hwaddr

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 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;
  }
 
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 16/28] fdt: fixup_eth: Remove code duplication with a function

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 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);
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 17/28] fdt: fixup_eth: improve error catching/reduce identation

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 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",
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 18/28] arm: sunxi: Expose function to generate sunxi-specific a MAC address

Olliver Schinagl
In reply to this post by Olliver Schinagl
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 <[hidden email]>
---
 arch/arm/include/asm/arch-sunxi/sys_proto.h |   2 +
 board/sunxi/board.c                         | 146 ++++++++++++++++++----------
 2 files changed, 95 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 850236ed42..f264c84b56 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 01de42d031..db56fba233 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>
@@ -596,6 +597,73 @@ 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);
+ set_unicast_ethaddr(mac_addr);
+ memcpy(enetaddr, mac_addr, ARP_HLEN);
+
+ return 0;
+}
+
 #ifdef CONFIG_SERIAL_TAG
 void get_board_serial(struct tag_serialnr *serialnr)
 {
@@ -655,71 +723,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);
@@ -730,6 +762,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();
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCHv6 19/28] net: sunxi_emac: Write HW address via net_ops hook

Olliver Schinagl
In reply to this post by Olliver Schinagl
Expose the write_hwaddr net_ops hook to write the Ethernet address.

Signed-off-by: Olliver Schinagl <[hidden email]>
---
 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)
--
2.11.0

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
1234
Loading...