Skip to contentSkip to conversation

Retrieve MAC address from EEPROM

PATCH Superseded Olliver Schinagl 8 participants 74 messages May 15, 2017 – Dec 4, 2017

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v6 cover Retrieve MAC address from EEPROM

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
Signature · 1 line
2.11.0
#1 lore raw

PATCH v6 1/28 ARM: dts: sunxi: Change node name for pwrseq pin on Olinuxino-lime2-emmc

From: Emmanuel Vadot <[email protected]>

The node name for the power seq pin is mmc2 at 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.

---
 arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/dts/sun7i-a20-olinuxino-lime2-emmc.dts +1 -1
index 5ea4915f6d..10d307408f 100644
@@ -56,7 +56,7 @@
 };
 
 &pio {
-	mmc2_pins_nrst: mmc2 at 0 {
+	mmc2_pins_nrst: mmc2-rst-pin {
 		allwinner,pins = "PC16";
 		allwinner,function = "gpio_out";
 		allwinner,drive = <SUN4I_PINCTRL_10_MA>;
Signature · 1 line
2.11.0
#2 lore raw

PATCH v6 2/28 sun7i: Add support for Olimex A20-OLinuXino-LIME2-eMMC

In reply to 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.

---
 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
board/sunxi/MAINTAINERS +5 -0
index 1c8817375d..1d3742c744 100644
@@ -89,6 +89,11 @@ M:	Iain Paton <[email protected]>
 S:	Maintained
 F:	configs/A20-OLinuXino-Lime2_defconfig
 
+A20-OLINUXINO-LIME2-EMMC BOARD
+M:	Olliver Schinagl <[email protected]>
+S:	Maintained
+F:	configs/A20-OLinuXino-Lime2-eMMC_defconfig
+
 A33-OLINUXINO BOARD
 M:	Stefan Mavrodiev <[email protected]>
 S:	Maintained
configs/A20-OLinuXino-Lime2-eMMC_defconfig new file +36 -0
new file mode 100644
index 0000000000..034ae983a5
@@ -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
Signature · 1 line
2.11.0
#3 lore raw

PATCH v6 3/28 net: core: Add PHY_GIGE as a Kconfig symbol

In reply to 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.

---
 drivers/net/Kconfig            | 4 ++++
 include/configs/sunxi-common.h | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/Kconfig +4 -0
index 9cd0d94cbd..336557f395 100644
@@ -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
 
include/configs/sunxi-common.h +0 -1
index 997a92c8be..3d8a130f38 100644
@@ -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
Signature · 1 line
2.11.0
#4 lore raw

PATCH v6 3/28 net: core: Add PHY_GIGE as a Kconfig symbol

Quoted 4 lines · 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.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/830ab7fa/attachment.sig>
#6 lore raw

PATCH v6 4/28 net: sunxi simplify defconfig

In reply to 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.

---
 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(-)
configs/A20-OLinuXino-Lime2-eMMC_defconfig +0 -2
index 034ae983a5..76525f4603 100644
@@ -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
configs/A20-OLinuXino-Lime2_defconfig +0 -2
index 1f2daa6706..aa8a5d5f2b 100644
@@ -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
configs/A20-OLinuXino-Lime_defconfig +1 -2
index 7f63d4af54..b4b2f66ccb 100644
@@ -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
configs/A20-OLinuXino_MICRO_defconfig +1 -2
index 89e87e799b..d59a480e8d 100644
@@ -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
configs/A20-Olimex-SOM-EVB_defconfig +0 -2
index 6c87648d4f..d52aefc984 100644
@@ -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
configs/Bananapi_defconfig +0 -2
index fe75eef513..5a45506571 100644
@@ -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
configs/Bananapro_defconfig +0 -2
index df65922e83..1503c41d3e 100644
@@ -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
configs/CSQ_CS908_defconfig +1 -2
index a6fcbf5ecf..cac210c1e8 100644
@@ -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
configs/Colombus_defconfig +0 -2
index 1359281ff4..7ce5d5ae2b 100644
@@ -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
configs/Cubieboard2_defconfig +1 -2
index 02c503f672..09b423104e 100644
@@ -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
configs/Cubietruck_defconfig +0 -2
index f9d56c8f9d..44082ccd30 100644
@@ -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
configs/Hummingbird_A31_defconfig +0 -2
index 6f9b103207..c25bccc3f5 100644
@@ -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
configs/Itead_Ibox_A20_defconfig +1 -2
index 4bae19f2fa..2179306666 100644
@@ -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
configs/Lamobo_R1_defconfig +0 -2
index cc29d606a9..e7b9ad7920 100644
@@ -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
configs/Linksprite_pcDuino3_Nano_defconfig +0 -2
index 80416cb7b1..74789ca56e 100644
@@ -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
configs/Linksprite_pcDuino3_defconfig +1 -2
index b9f89a013e..1aa253abcb 100644
@@ -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
configs/Mele_A1000G_quad_defconfig +1 -2
index 5b1b5f5d7c..0152b21303 100644
@@ -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
configs/Mele_I7_defconfig +1 -2
index b60969787c..12f0c1a83c 100644
@@ -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
configs/Mele_M3_defconfig +1 -2
index 08e8c2dbde..382c45b800 100644
@@ -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
configs/Mele_M5_defconfig +1 -2
index 4c377e3daf..594b230ff1 100644
@@ -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
configs/Mele_M9_defconfig +1 -2
index dc7901f9af..64a111ec6a 100644
@@ -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
configs/Orangepi_defconfig +0 -2
index b8c1ea4d7c..34eeb92fa6 100644
@@ -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
configs/Orangepi_mini_defconfig +0 -2
index 19c35ef103..2609c54bc2 100644
@@ -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
configs/Sinlinx_SinA31s_defconfig +1 -2
index 7f815a32cb..bdf6ebe9f5 100644
@@ -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
configs/Sinovoip_BPI_M2_defconfig +0 -2
index a2cadbc271..78afc6d668 100644
@@ -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
configs/Wits_Pro_A20_DKT_defconfig +0 -2
index 8658ef6b4c..979c6a6ae8 100644
@@ -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
configs/i12-tvbox_defconfig +1 -2
index 4245491b6a..b609514de8 100644
@@ -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
configs/icnova-a20-swac_defconfig +1 -2
index 6f79c587ee..63bbd37f97 100644
@@ -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
configs/mixtile_loftq_defconfig +0 -2
index 6264b3a151..47289c6616 100644
@@ -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
drivers/net/Kconfig +43 -11

71 lines not on this page · raw message

include/configs/sunxi-common.h +0 -3
index 3d8a130f38..8f97b80619 100644
@@ -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
 
Signature · 1 line
2.11.0
#7 lore raw

PATCH v6 4/28 net: sunxi simplify defconfig

Quoted 10 lines · 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.

Quoted 5 lines

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.

This doesn't make any sense. You have two *separate* blocks on the A20, the EMAC and the GMAC, and yet, you want SUN7I_EMAC to not represent the EMAC found, but the GMAC with an MII phy?

The current configuration we have is fine as it is, there's no need to change it, especially for something that is so confusing.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/484dc9d4/attachment.sig>
#8 lore raw

PATCH v6 4/28 net: sunxi simplify defconfig

In reply to Olliver Schinagl
Quoted 51 lines · 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.

---
 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(-)

[...]

drivers/net/Kconfig config PCH_GBE · line 154

Quoted 11 lines
drivers/net/Kconfig +3 -0
index 336557f395..c0d141754f 100644
@@ -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
+

This is a generic config that describes any MII - arguably it could be cleaned up to mean MDIO.

drivers/net/Kconfig config PCH_GBE · line 153

Quoted 2 lines
drivers/net/Kconfig +0 -1
 config RGMII
-       bool "Enable RGMII"

This wasn't a very generically useful config option (meaning there are many devices which use RGMII and don't specify this) so it should probably see expanded use or at least have some depends on in the config that limit it's appearance to drivers that care.

drivers/net/Kconfig config PCH_GBE · line 156

Quoted 4 lines
drivers/net/Kconfig +1 -3
-       help
-         Enable the support of the Reduced Gigabit Media-Independent
-         Interface (RGMII).
+       bool

It doesn't seem great to hide this, but maybe that's a better approach than making it depend on the correct drivers.

Quoted 42 lines
drivers/net/Kconfig +24 -7
 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

drivers/net/Kconfig config RTL8169 · line 210

Quoted 10 lines
drivers/net/Kconfig +10 -0
+       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

Presumably you would still need to define MII here.

Quoted 33 lines
drivers/net/Kconfig +5 -0
+       help
+         If connecting the sun7i MAC to a gigabit ethernet PHY, select
+         this option.
+
+endchoice
 
 config SUN8I_EMAC
         bool "Allwinner Sun8i Ethernet MAC support"
include/configs/sunxi-common.h +0 -4
index 3d8a130f38..8f97b80619 100644
@@ -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
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#9 lore raw

PATCH v6 5/28 net: sunxi: Re-add RTL8211X_PHY_FORCE_MASTER

In reply to Olliver Schinagl

Commit 8728c97eff5bd9 (" configs: Re-sync") potentially broke the lime2 as it removed the RTL8211X_PHY_FORCE_MASTER flag.

Re-add this flag.

---
 configs/A20-OLinuXino-Lime2_defconfig | 1 +
 configs/A20-Olimex-SOM-EVB_defconfig  | 1 +
 2 files changed, 2 insertions(+)
configs/A20-OLinuXino-Lime2_defconfig +1 -0
index aa8a5d5f2b..14d1159ead 100644
@@ -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
configs/A20-Olimex-SOM-EVB_defconfig +1 -0
index d52aefc984..59388ba7f4 100644
@@ -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
Signature · 1 line
2.11.0
#11 lore raw

PATCH v6 6/28 net: sunxi: Restore sunxi_[eg]mac behavior

In reply to 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.

---
 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(-)
arch/arm/include/asm/arch-sunxi/sys_proto.h +1 -1
index a373319a2b..850236ed42 100644
@@ -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) {}
board/sunxi/Makefile +1 -1
index 43766e0ef4..b4768b9b9b 100644
@@ -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
configs/A20-OLinuXino-Lime2_defconfig +1 -0
index 14d1159ead..14a51ef3f9 100644
@@ -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
configs/A20-OLinuXino-Lime_defconfig +1 -0
index b4b2f66ccb..3fdf7c64aa 100644
@@ -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
configs/A20-OLinuXino_MICRO_defconfig +1 -0
index d59a480e8d..ea7bc73dda 100644
@@ -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
configs/A20-Olimex-SOM-EVB_defconfig +1 -0
index 59388ba7f4..8a2dfad526 100644
@@ -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
configs/Bananapi_defconfig +1 -0
index 5a45506571..eac3175f2d 100644
@@ -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
configs/Bananapro_defconfig +1 -0
index 1503c41d3e..ef1ff21a39 100644
@@ -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
configs/CSQ_CS908_defconfig +1 -0
index cac210c1e8..b771ab068d 100644
@@ -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
configs/Colombus_defconfig +1 -0
index 7ce5d5ae2b..dd4eefb98a 100644
@@ -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
configs/Cubieboard2_defconfig +1 -0
index 09b423104e..072ac047a6 100644
@@ -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
configs/Cubietruck_defconfig +1 -0
index 44082ccd30..fe15fea717 100644
@@ -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
configs/Hummingbird_A31_defconfig +1 -0
index c25bccc3f5..245b33d6dc 100644
@@ -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
configs/Itead_Ibox_A20_defconfig +1 -0
index 2179306666..496b860954 100644
@@ -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
configs/Lamobo_R1_defconfig +1 -0
index e7b9ad7920..7979f4da21 100644
@@ -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
configs/Linksprite_pcDuino3_Nano_defconfig +1 -0
index 74789ca56e..6586c2168f 100644
@@ -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
configs/Linksprite_pcDuino3_defconfig +1 -0
index 1aa253abcb..f0290d82dd 100644
@@ -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
configs/Mele_A1000G_quad_defconfig +1 -0
index 0152b21303..798745d40b 100644
@@ -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
configs/Mele_I7_defconfig +1 -0
index 12f0c1a83c..8ccc93bb86 100644
@@ -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
configs/Mele_M3_defconfig +1 -0
index 382c45b800..e5fcdd34cf 100644
@@ -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
configs/Mele_M5_defconfig +1 -0
index 594b230ff1..45c0d26791 100644
@@ -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
configs/Mele_M9_defconfig +1 -0
index 64a111ec6a..efa52f92f8 100644
@@ -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
configs/Orangepi_defconfig +1 -0
index 34eeb92fa6..2fe3f5978d 100644
@@ -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
configs/Orangepi_mini_defconfig +1 -0
index 2609c54bc2..71a93b58a5 100644
@@ -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
configs/Sinlinx_SinA31s_defconfig +1 -0
index bdf6ebe9f5..c6f98e4572 100644
@@ -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
configs/Sinovoip_BPI_M2_defconfig +1 -0
index 78afc6d668..fe5845e670 100644
@@ -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
configs/Wits_Pro_A20_DKT_defconfig +1 -0
index 979c6a6ae8..57298f1ea4 100644
@@ -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
configs/i12-tvbox_defconfig +1 -0
index b609514de8..f423e57867 100644
@@ -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
configs/icnova-a20-swac_defconfig +1 -0
index 63bbd37f97..f158220225 100644
@@ -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
configs/mixtile_loftq_defconfig +1 -0
index 47289c6616..4c81b3d7b3 100644
@@ -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
drivers/net/Kconfig +5 -0
index c0d141754f..04e8cf39c8 100644
@@ -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
drivers/net/Makefile +1 -1
index aedb2cc90d..c5dd52bee2 100644
@@ -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
include/configs/sunxi-common.h +3 -6
index 8f97b80619..5d2c5b9040 100644
@@ -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
scripts/config_whitelist.txt +0 -2
index cd0165f934..1e2bf24d5a 100644
@@ -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
Signature · 1 line
2.11.0
#12 lore raw

PATCH v6 6/28 net: sunxi: Restore sunxi_[eg]mac behavior

Quoted 82 lines · 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.

---
 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(-)
arch/arm/include/asm/arch-sunxi/sys_proto.h +1 -1
index a373319a2b..850236ed42 100644
@@ -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) {}
board/sunxi/Makefile +1 -1
index 43766e0ef4..b4768b9b9b 100644
@@ -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
configs/A20-OLinuXino-Lime2_defconfig +0 -0
index 14d1159ead..14a51ef3f9 100644

configs/A20-OLinuXino-Lime2_defconfig CONFIG_CMD_USB_MASS_STORAGE=y · line 25

Quoted 4 lines
configs/A20-OLinuXino-Lime2_defconfig +1 -0
@@ -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

Would it make sense to either select this at the platform level or to imply it in the driver Kconfig?

Quoted 3 lines
configs/A20-OLinuXino-Lime2_defconfig +0 -0
 CONFIG_RTL8211X_PHY_FORCE_MASTER=y
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800

[...]

Quoted 86 lines
drivers/net/Kconfig +5 -0
index c0d141754f..04e8cf39c8 100644
@@ -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
drivers/net/Makefile +1 -1
index aedb2cc90d..c5dd52bee2 100644
@@ -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
include/configs/sunxi-common.h +3 -6
index 8f97b80619..5d2c5b9040 100644
@@ -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
scripts/config_whitelist.txt +0 -3
index cd0165f934..1e2bf24d5a 100644
@@ -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
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#13 lore raw

PATCH v6 7/28 net: sunxi: Move GMAC_TX_DELAY to the driver

In reply to 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.

---
 arch/arm/mach-sunxi/Kconfig | 6 ------
 drivers/net/Kconfig         | 7 +++++++
 2 files changed, 7 insertions(+), 6 deletions(-)
arch/arm/mach-sunxi/Kconfig +0 -6
index 8d9900e00b..be060b65dc 100644
@@ -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
drivers/net/Kconfig +7 -0
index 04e8cf39c8..782348f872 100644
@@ -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
Signature · 1 line
2.11.0
#15 lore raw

PATCH v6 8/28 net: cosmetic: Do not use magic values for ARP_HLEN

In reply to Olliver Schinagl

Previously overlooked magic value in commit a40db6d51171 ("net: cosmetic: Do not use magic values for ARP_HLEN")

---
 include/net.h    | 4 ++--
 net/eth_common.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
include/net.h +2 -2
index ed5259a807..c703c62c99 100644
@@ -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 */
net/eth_common.c +1 -1
index 58fa295771..049c1ee6f9 100644
@@ -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;
Signature · 1 line
2.11.0
#16 lore raw

PATCH v6 8/28 net: cosmetic: Do not use magic values for ARP_HLEN

Quoted 4 lines · Olliver Schinagl

Previously overlooked magic value in commit a40db6d51171 ("net: cosmetic: Do not use magic values for ARP_HLEN")

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/4d669172/attachment.sig>
#18 lore raw

PATCH v6 9/28 net: core: Sanitize get/set operations for enetaddr

In reply to 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.

---
 common/fdt_support.c |  2 +-
 include/net.h        |  1 +
 net/eth_common.c     | 14 +++++++++-----
 3 files changed, 11 insertions(+), 6 deletions(-)
common/fdt_support.c +1 -1
index c6a76b7ad2..d462bf0642 100644
@@ -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;
include/net.h +1 -0
index c703c62c99..ad2a8a3678 100644
@@ -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);
 
net/eth_common.c +9 -5
index 049c1ee6f9..0fe4d260d8 100644
@@ -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);
Signature · 1 line
2.11.0
#19 lore raw

PATCH v6 9/28 net: core: Sanitize get/set operations for enetaddr

Quoted 10 lines · 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.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/ceb2eee9/attachment.sig>
#20 lore raw

PATCH v6 9/28 net: core: Sanitize get/set operations for enetaddr

In reply to Olliver Schinagl
Quoted 10 lines · 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.

#21 lore raw

PATCH v6 10/28 net: core: Inform the user of the device MAC address

In reply to 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.

---
 net/eth-uclass.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
net/eth-uclass.c +6 -3
index c3cc3152a2..781376955a 100644
@@ -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;
 }
 
Signature · 1 line
2.11.0
#22 lore raw

PATCH v6 10/28 net: core: Inform the user of the device MAC address

Quoted 11 lines · 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.

#23 lore raw

PATCH v6 11/28 net: core: Add MAC address helper functions

In reply to 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

---
 include/net.h | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)
include/net.h +40 -3
index ad2a8a3678..00677a0a89 100644
@@ -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 */
Signature · 1 line
2.11.0
#24 lore raw

PATCH v6 11/28 net: core: Add MAC address helper functions

Quoted 6 lines · 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.

Quoted 8 lines

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

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/b82ed116/attachment.sig>
#25 lore raw

PATCH v6 11/28 net: core: Add MAC address helper functions

In reply to Olliver Schinagl
Quoted 6 lines · 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.

Quoted 8 lines

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

#26 lore raw

PATCH v6 12/28 net: Add ability to set MAC address via EEPROM

In reply to 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.

---
 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(-)
arch/arm/mach-sunxi/Kconfig +4 -4
index be060b65dc..cf5af4fe18 100644
@@ -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.
configs/A10-OLinuXino-Lime_defconfig +0 -1
index ec16a44fbd..d4513144eb 100644
@@ -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
configs/A20-OLinuXino-Lime2-eMMC_defconfig +0 -1
index 76525f4603..fd743a5f45 100644
@@ -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
configs/A20-OLinuXino-Lime2_defconfig +0 -1
index 14a51ef3f9..a932ec7b7b 100644
@@ -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
configs/A20-OLinuXino-Lime_defconfig +0 -1
index 3fdf7c64aa..41667384f4 100644
@@ -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
configs/A20-OLinuXino_MICRO_defconfig +0 -1
index ea7bc73dda..b1f80835c9 100644
@@ -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"
doc/README.enetaddr +95 -0

101 lines not on this page · raw message

include/net.h +14 -0
index 00677a0a89..392dc95fdc 100644
@@ -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).
net/Kconfig +59 -0

65 lines not on this page · raw message

net/eth-uclass.c +20 -22

65 lines not on this page · raw message

net/eth_common.c +37 -0
index 0fe4d260d8..24488746c9 100644
@@ -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;
net/eth_legacy.c +2 -0
index e4bd0f4c1a..4276058800 100644
@@ -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)) {
Signature · 1 line
2.11.0
#27 lore raw

PATCH v6 12/28 net: Add ability to set MAC address via EEPROM

Quoted 87 lines · 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.

---
 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(-)
arch/arm/mach-sunxi/Kconfig +4 -4
index be060b65dc..cf5af4fe18 100644
@@ -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.
configs/A10-OLinuXino-Lime_defconfig +0 -0
index ec16a44fbd..d4513144eb 100644

configs/A10-OLinuXino-Lime_defconfig CONFIG_DRAM_CLK=480 · line 8

Quoted 4 lines
configs/A10-OLinuXino-Lime_defconfig +0 -1
@@ -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

Didn't that just remove the option if NET_ETHADDR_EEPROM is disabled (which is its default) ?

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/78276555/attachment.sig>
#28 lore raw

PATCH v6 12/28 net: Add ability to set MAC address via EEPROM

Hey Maxime,

Quoted 87 lines · Maxime Ripard
Quoted 86 lines · 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.

---
 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(-)
arch/arm/mach-sunxi/Kconfig +4 -4
index be060b65dc..cf5af4fe18 100644
@@ -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.
configs/A10-OLinuXino-Lime_defconfig +0 -0
index ec16a44fbd..d4513144eb 100644
Quoted 8 lines

configs/A10-OLinuXino-Lime_defconfig CONFIG_DRAM_CLK=480 · line 8

Quoted 5 lines
configs/A10-OLinuXino-Lime_defconfig +0 -1
@@ -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

Didn't that just remove the option if NET_ETHADDR_EEPROM is disabled (which is its default) ?

I initially forced I2C1_ENABLE on all the Olimex boards before finding that I could do:

default y if (NET_ETHADDR_EEPROM_I2C_BUS = 1)

So by defining NET_ETHADDR_EEPROM_I2C_BUS = x in the defconfig, the correct I2C1_ENABLE is being set, so we do not need to hardcode this in the defconfig anymore.

Or am I miss-understanding you?

Olliver

Quoted 3 lines

Maxime

#29 lore raw

PATCH v6 12/28 net: Add ability to set MAC address via EEPROM

Quoted 101 lines · Olliver Schinagl

Hey Maxime,

Quoted 87 lines · Maxime Ripard
Quoted 86 lines · 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.

---
 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(-)
arch/arm/mach-sunxi/Kconfig +4 -4
index be060b65dc..cf5af4fe18 100644
@@ -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.
configs/A10-OLinuXino-Lime_defconfig +0 -0
index ec16a44fbd..d4513144eb 100644
Quoted 8 lines

configs/A10-OLinuXino-Lime_defconfig CONFIG_DRAM_CLK=480 · line 8

Quoted 5 lines
configs/A10-OLinuXino-Lime_defconfig +0 -1
@@ -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

Didn't that just remove the option if NET_ETHADDR_EEPROM is disabled (which is its default) ?

I initially forced I2C1_ENABLE on all the Olimex boards before finding that I could do:

Quoted 7 lines

default y if (NET_ETHADDR_EEPROM_I2C_BUS = 1)

So by defining NET_ETHADDR_EEPROM_I2C_BUS = x in the defconfig, the correct I2C1_ENABLE is being set, so we do not need to hardcode this in the defconfig anymore.

Or am I miss-understanding you?

My point is: before, you had the I2C enabled using the defconfig (and the defconfig alone), and you don't have that anymore.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170516/cad86e6a/attachment.sig>
#30 lore raw

PATCH v6 12/28 net: Add ability to set MAC address via EEPROM

In reply to Olliver Schinagl

Hi Oliver,

Quoted 28 lines · 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.

Quoted 15 lines
---
 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(-)

Please don't implement this feature in legacy code / legacy I2C. New features should only use DM - otherwise it just makes it harder and harder to ever finish the port.

Regards,
Simon

#31 lore raw

PATCH v6 12/28 net: Add ability to set MAC address via EEPROM

In reply to Olliver Schinagl

Hi Olliver,

Quoted 11 lines · 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).

Note that Olimex has started to write their own data to the EEPROM for their A20 boards:
https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/A20/A20-eeprom-contents/Olimex-A20-EEPROM-september-2017.pdf

Quoted 12 lines

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.

Quoted 5 lines

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.

Regards,
Jonathan

#32 lore raw

PATCH v6 13/28 net: core: print the source of the MAC address

In reply to 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.

---
 include/net.h    | 14 ++++++++++++++
 net/eth-uclass.c | 18 +++++++++++++++---
 2 files changed, 29 insertions(+), 3 deletions(-)
include/net.h +14 -0
index 392dc95fdc..762ff2b319 100644
@@ -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;
 };
net/eth-uclass.c +15 -3
index 02ee926f74..c88b032868 100644
@@ -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]");
Signature · 1 line
2.11.0
#34 lore raw

PATCH v6 14/28 net: cosmetic: A MAC address is not limited to SROM

In reply to 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.

---
 net/eth_legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/eth_legacy.c +1 -1
index 4276058800..800b91c327 100644
@@ -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);
Signature · 1 line
2.11.0
#35 lore raw

PATCH v6 14/28 net: cosmetic: A MAC address is not limited to SROM

Quoted 13 lines · 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.

---
 net/eth_legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/eth_legacy.c +0 -0
index 4276058800..800b91c327 100644

net/eth_legacy.c int eth_write_hwaddr(struct eth_device *dev, const char *base_name, · line 152

Quoted 8 lines
net/eth_legacy.c +1 -1
@@ -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);

We need to add a space in the print then as the output is manually aligned.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/bb6cbfa9/attachment.sig>
#36 lore raw

PATCH v6 14/28 net: cosmetic: A MAC address is not limited to SROM

Hey Tom,

Quoted 9 lines · Tom Rini
Quoted 8 lines · 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.

---
 net/eth_legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

net/eth_legacy.c int eth_write_hwaddr(struct eth_device *dev, const char *base_name, · line 152

Quoted 13 lines
net/eth_legacy.c +1 -1
index 4276058800..800b91c327 100644
@@ -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);

We need to add a space in the print then as the output is manually aligned.

I did not realize, I'll add a space to this one, and a space to the already merged one as well.

Olliver

#37 lore raw

PATCH v6 14/28 net: cosmetic: A MAC address is not limited to SROM

In reply to Tom Rini
Quoted 9 lines · Tom Rini
Quoted 8 lines · 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.

---
 net/eth_legacy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

net/eth_legacy.c int eth_write_hwaddr(struct eth_device *dev, const char *base_name, · line 152

Quoted 13 lines
net/eth_legacy.c +1 -1
index 4276058800..800b91c327 100644
@@ -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);

We need to add a space in the print then as the output is manually aligned.

Agreed.

#38 lore raw

PATCH v6 15/28 net: core: Check return value of read_rom_hwaddr

In reply to 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.

---
 net/eth-uclass.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/eth-uclass.c +2 -2
index c88b032868..024136a7cb 100644
@@ -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;
 		}
 
Signature · 1 line
2.11.0
#39 lore raw

PATCH v6 15/28 net: core: Check return value of read_rom_hwaddr

Quoted 4 lines · 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.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/683974e2/attachment.sig>
#41 lore raw

PATCH v6 16/28 fdt: fixup_eth: Remove code duplication with a function

In reply to 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.

---
 common/fdt_support.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
common/fdt_support.c +5 -10
index d462bf0642..4d05465232 100644
@@ -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);
Signature · 1 line
2.11.0
#43 lore raw

PATCH v6 17/28 fdt: fixup_eth: improve error catching/reduce identation

In reply to 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.

---
 common/fdt_support.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
common/fdt_support.c +10 -10
index 4d05465232..71cbee43e0 100644
@@ -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",
Signature · 1 line
2.11.0
#45 lore raw

PATCH v6 18/28 arm: sunxi: Expose function to generate sunxi-specific a MAC address

In reply to 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.

---
 arch/arm/include/asm/arch-sunxi/sys_proto.h |   2 +
 board/sunxi/board.c                         | 146 ++++++++++++++++++----------
 2 files changed, 95 insertions(+), 53 deletions(-)
arch/arm/include/asm/arch-sunxi/sys_proto.h +2 -0
index 850236ed42..f264c84b56 100644
@@ -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
board/sunxi/board.c +93 -53

182 lines not on this page · raw message

Signature · 1 line
2.11.0
#46 lore raw

PATCH v6 18/28 arm: sunxi: Expose function to generate sunxi-specific a MAC address

Typo in the subject line...

"arm: sunxi: Expose function to generate _a_ sunxi-specific MAC address"

Quoted 8 lines · 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.

Looks fine other than the subject.

#47 lore raw

PATCH v6 19/28 net: sunxi_emac: Write HW address via net_ops hook

In reply to Olliver Schinagl

Expose the write_hwaddr net_ops hook to write the Ethernet address.

---
 drivers/net/sunxi_emac.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/net/sunxi_emac.c +12 -0
index 99339db4bf..0dc37de242 100644
@@ -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)
Signature · 1 line
2.11.0
#49 lore raw

PATCH v6 20/28 net: sunxi: Rename sunxi_emac to a more specific sun4i_mac

In reply to Olliver Schinagl

The sunxi_emac driver is very specific to the IP used in the sun4i. Thus rename it to what it actually is, the MAC driver for the sun4i MAC.

The rename also changes the variable and function names inside the driver. There are no code changes in this patch however.

While here, use the BIT() macro for bitfields as well.

---
 drivers/net/Makefile                      |   2 +-
 drivers/net/{sunxi_emac.c => sun4i_mac.c} | 260 +++++++++++++++---------------
 2 files changed, 133 insertions(+), 129 deletions(-)
 rename drivers/net/{sunxi_emac.c => sun4i_mac.c} (60%)
drivers/net/Makefile +1 -1
index c5dd52bee2..9834d67146 100644
@@ -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_SUN4I_EMAC) += sunxi_emac.o
+obj-$(CONFIG_SUN4I_EMAC) += sun4i_mac.o
 obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
 obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_EP93XX) += ep93xx_eth.o
drivers/net/sun4i_mac.c renamed from drivers/net/sunxi_emac.c +132 -128

532 lines not on this page · raw message

Signature · 1 line
2.11.0
#50 lore raw

PATCH v6 20/28 net: sunxi: Rename sunxi_emac to a more specific sun4i_mac

Quoted 7 lines · Olliver Schinagl

The sunxi_emac driver is very specific to the IP used in the sun4i. Thus rename it to what it actually is, the MAC driver for the sun4i MAC.

The rename also changes the variable and function names inside the driver. There are no code changes in this patch however.

While here, use the BIT() macro for bitfields as well.

This should be in a separate patch.

Quoted 4 lines
---
 drivers/net/Makefile                      |   2 +-
 drivers/net/{sunxi_emac.c => sun4i_mac.c} | 260 +++++++++++++++---------------

The IP is called EMAC everywhere, please keep that name.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/4a10bf4e/attachment.sig>
#51 lore raw

PATCH v6 21/28 net: sunxi: Have sunxi common functions together

In reply to Olliver Schinagl

The sun[8x]i network drivers have some common functions. Let's introduce a common file with the reading of the MAC address as a start.

In the future, we can move more sunxi shared/common code into this file.

---
 drivers/net/sunxi_common.c | 33 +++++++++++++++++++++++++++++++++
 drivers/net/sunxi_common.h | 13 +++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 drivers/net/sunxi_common.c
 create mode 100644 drivers/net/sunxi_common.h
drivers/net/sunxi_common.c new file +33 -0
new file mode 100644
index 0000000000..a22fd2bfe7
@@ -0,0 +1,33 @@
+/*
+ * (c) Copyright 2017
+ * Author: Olliver Schinagl <[email protected]>
+ *
+ * SPX-License-Identifier:	GPL-3.0+
+ *
+ * Common code for the sunxi series of the ethernet sunxi mac driver
+ *
+ */
+
+#include <asm/arch/sys_proto.h>
+#include <common.h>
+#include <dm/device.h>
+#include <net.h>
+#include <linux/types.h>
+
+/*
+ * Set ethernet MAC address based on serial number.
+ * FIXME: For now we call sunxi_gen_hwaddr to generate the MAC address there.
+ * This is done because we have some devices, which expect their MAC address to
+ * to be passed via the environment and obtained from the FDT. Once that code
+ * has been refactored (it is quircky to say the least), the mac generating code
+ * should live here.
+ */
+int sunxi_mac_read_rom_hwaddr(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+
+	if (!pdata || (dev->seq < 0))
+		return -ENOSYS;
+
+	return sunxi_gen_hwaddr(dev->seq, pdata->enetaddr);
+}
drivers/net/sunxi_common.h new file +13 -0
new file mode 100644
index 0000000000..99ef5e6f25
@@ -0,0 +1,13 @@
+/*
+ * (c) Copyright 2017
+ * Author: Olliver Schinagl <[email protected]>
+ *
+ * SPX-License-Identifier:	GPL-3.0+
+ *
+ * Common code for the sunxi series of the ethernet sunxi mac drivers
+ *
+ */
+
+#include <dm/device.h>
+
+int sunxi_mac_read_rom_hwaddr(struct udevice *dev);
Signature · 1 line
2.11.0
#53 lore raw

PATCH v6 21/28 net: sunxi: Have sunxi common functions together

In reply to Olliver Schinagl
Quoted 11 lines · Olliver Schinagl

The sun[8x]i network drivers have some common functions. Let's introduce a common file with the reading of the MAC address as a start.

In the future, we can move more sunxi shared/common code into this file.

---
 drivers/net/sunxi_common.c | 33 +++++++++++++++++++++++++++++++++
 drivers/net/sunxi_common.h | 13 +++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 drivers/net/sunxi_common.c

I actually would like you to add this file to the Makefile in this change.

Quoted 1 line
 create mode 100644 drivers/net/sunxi_common.h

Thanks,
-Joe

#54 lore raw

PATCH v6 22/28 net: sun4i_mac: Add read_rom_hwaddr hook

In reply to Olliver Schinagl

With this patch sun4i_mac can now get the MAC address from the board in a predetermined board specific manner.

---
 drivers/net/Makefile    | 2 +-
 drivers/net/sun4i_mac.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/Makefile +1 -1
index 9834d67146..594f54f714 100644
@@ -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_SUN4I_EMAC) += sun4i_mac.o
+obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
 obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
 obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_EP93XX) += ep93xx_eth.o
drivers/net/sun4i_mac.c +3 -0
index ea52bd8a17..06d7e63efc 100644
@@ -17,6 +17,8 @@
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
 
+#include "sunxi_common.h"
+
 /* EMAC register  */
 struct sun4i_mac_regs {
 	u32 ctl;	/* 0x00 */
@@ -586,6 +588,7 @@ static const struct eth_ops sun4i_mac_eth_ops = {
 	.recv			= sun4i_mac_eth_recv,
 	.stop			= sun4i_mac_eth_stop,
 	.write_hwaddr		= sun4i_mac_eth_write_hwaddr,
+	.read_rom_hwaddr	= sunxi_mac_read_rom_hwaddr,
 };
 
 static int sun4i_mac_eth_ofdata_to_platdata(struct udevice *dev)
Signature · 1 line
2.11.0
#55 lore raw

PATCH v6 22/28 net: sun4i_mac: Add read_rom_hwaddr hook

Quoted 2 lines · Olliver Schinagl

With this patch sun4i_mac can now get the MAC address from the board in a predetermined board specific manner.

I think this patch should be squashed into to one before it.

Thanks,
-Joe

#56 lore raw

PATCH v6 23/28 net: sun7i_mac: Make the sun7i a dw driver subclass

In reply to Olliver Schinagl

This patch removes the old sunxi_gmac glue layer and turns it into a proper sub-class driver.

---
 arch/arm/mach-sunxi/board.c                   |  1 -
 board/sunxi/Makefile                          |  1 -
 drivers/net/Makefile                          |  1 +
 drivers/net/designware.c                      |  1 -
 board/sunxi/gmac.c => drivers/net/sun7i_mac.c | 52 +++++++++++++++++++++++----
 5 files changed, 47 insertions(+), 9 deletions(-)
 rename board/sunxi/gmac.c => drivers/net/sun7i_mac.c (69%)
arch/arm/mach-sunxi/board.c +0 -1
index 65b1ebd837..728da01a49 100644
@@ -207,7 +207,6 @@ void s_init(void)
 #ifndef CONFIG_DM_I2C
 	i2c_init_board();
 #endif
-	eth_init_board();
 }
 
 #ifdef CONFIG_SPL_BUILD
board/sunxi/Makefile +0 -1
index b4768b9b9b..f2dba9532a 100644
@@ -9,7 +9,6 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 obj-y	+= board.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
drivers/net/Makefile +1 -0
index 594f54f714..86dee7d746 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
 obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
+obj-$(CONFIG_SUN7I_MAC) += sun7i_mac.o
 obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
 obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_EP93XX) += ep93xx_eth.o
drivers/net/designware.c +0 -1
index f9fb8e0886..3e18f28232 100644
@@ -761,7 +761,6 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
 }
 
 static const struct udevice_id designware_eth_ids[] = {
-	{ .compatible = "allwinner,sun7i-a20-gmac" },
 	{ .compatible = "altr,socfpga-stmmac" },
 	{ .compatible = "amlogic,meson6-dwmac" },
 	{ .compatible = "amlogic,meson-gx-dwmac" },
drivers/net/sun7i_mac.c renamed from board/sunxi/gmac.c +46 -6

62 lines not on this page · raw message

Signature · 1 line
2.11.0
#57 lore raw

PATCH v6 23/28 net: sun7i_mac: Make the sun7i a dw driver subclass

Quoted 2 lines · Olliver Schinagl

This patch removes the old sunxi_gmac glue layer and turns it into a proper sub-class driver.

And renames it. Please split that into two patches.

Quoted 9 lines
---
 arch/arm/mach-sunxi/board.c                   |  1 -
 board/sunxi/Makefile                          |  1 -
 drivers/net/Makefile                          |  1 +
 drivers/net/designware.c                      |  1 -
 board/sunxi/gmac.c => drivers/net/sun7i_mac.c | 52 +++++++++++++++++++++++----
 5 files changed, 47 insertions(+), 9 deletions(-)
 rename board/sunxi/gmac.c => drivers/net/sun7i_mac.c (69%)

And that block is used GMAC everywhere, please keep that name.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/1bf7f8ef/attachment.sig>
#58 lore raw

PATCH v6 24/28 net: dw: Expose designware_eth_start

In reply to Olliver Schinagl

Commit e72ced234045f ("net: designware: Export the operation functions") started to expose some of the net_ops. The sunxi_gmac glue driver also needs the start function, so let us expose that as well.

---
 drivers/net/designware.c | 2 +-
 drivers/net/designware.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/designware.c +1 -1
index 3e18f28232..ac8258c8bd 100644
@@ -585,7 +585,7 @@ int designware_initialize(ulong base_addr, u32 interface)
 #endif
 
 #ifdef CONFIG_DM_ETH
-static int designware_eth_start(struct udevice *dev)
+int designware_eth_start(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct dw_eth_dev *priv = dev_get_priv(dev);
drivers/net/designware.h +1 -0
index 7992d0ebee..24b64d975c 100644
@@ -260,6 +260,7 @@ int designware_eth_send(struct udevice *dev, void *packet, int length);
 int designware_eth_recv(struct udevice *dev, int flags, uchar **packetp);
 int designware_eth_free_pkt(struct udevice *dev, uchar *packet,
 				   int length);
+int designware_eth_start(struct udevice *dev);
 void designware_eth_stop(struct udevice *dev);
 int designware_eth_write_hwaddr(struct udevice *dev);
 #endif
Signature · 1 line
2.11.0
#59 lore raw

PATCH v6 24/28 net: dw: Expose designware_eth_start

Quoted 9 lines · Olliver Schinagl

Commit e72ced234045f ("net: designware: Export the operation functions") started to expose some of the net_ops. The sunxi_gmac glue driver also needs the start function, so let us expose that as well.

---
 drivers/net/designware.c | 2 +-
 drivers/net/designware.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
#61 lore raw

PATCH v6 25/28 net: sun7i_mac: Add read_rom_hwaddr hook

In reply to Olliver Schinagl

With this patch sun7i_mac can now get the MAC address from the board in a predetermined board specific manner.

---
 drivers/net/Makefile    | 2 +-
 drivers/net/sun7i_mac.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/Makefile +1 -1
index 86dee7d746..5df5567536 100644
@@ -23,7 +23,7 @@ obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
 obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
-obj-$(CONFIG_SUN7I_MAC) += sun7i_mac.o
+obj-$(CONFIG_SUN7I_MAC) += sunxi_common.o sun7i_mac.o
 obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
 obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_EP93XX) += ep93xx_eth.o
drivers/net/sun7i_mac.c +2 -0
index f8c6a58c08..b10a6ec03a 100644
@@ -15,6 +15,7 @@
 #include <net.h>
 
 #include "designware.h"
+#include "sunxi_common.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -102,6 +103,7 @@ const struct eth_ops sun7i_mac_eth_ops = {
 	.free_pkt		= designware_eth_free_pkt,
 	.stop			= designware_eth_stop,
 	.write_hwaddr		= designware_eth_write_hwaddr,
+	.read_rom_hwaddr	= sunxi_mac_read_rom_hwaddr,
 };
 
 static const struct udevice_id sun7i_mac_eth_ids[] = {
Signature · 1 line
2.11.0
#62 lore raw

PATCH v6 25/28 net: sun7i_mac: Add read_rom_hwaddr hook

Quoted 14 lines · Olliver Schinagl

With this patch sun7i_mac can now get the MAC address from the board in a predetermined board specific manner.

---
 drivers/net/Makefile    | 2 +-
 drivers/net/sun7i_mac.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/net/Makefile +0 -0
index 86dee7d746..5df5567536 100644

drivers/net/Makefile obj-$(CONFIG_E1000) += e1000.o · line 26

Quoted 5 lines
drivers/net/Makefile +1 -1
@@ -23,7 +23,7 @@ obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
 obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
-obj-$(CONFIG_SUN7I_MAC) += sun7i_mac.o
+obj-$(CONFIG_SUN7I_MAC) += sunxi_common.o sun7i_mac.o

Shouldn't that be turned in a Kconfig option selected by both drivers?

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/32ad6149/attachment.sig>
#63 lore raw

PATCH v6 25/28 net: sun7i_mac: Add read_rom_hwaddr hook

Hey Maxime,

Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Olliver Schinagl

With this patch sun7i_mac can now get the MAC address from the board in a predetermined board specific manner.

---
 drivers/net/Makefile    | 2 +-
 drivers/net/sun7i_mac.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/net/Makefile obj-$(CONFIG_E1000) += e1000.o · line 26

Quoted 10 lines
drivers/net/Makefile +1 -1
index 86dee7d746..5df5567536 100644
@@ -23,7 +23,7 @@ obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
 obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
-obj-$(CONFIG_SUN7I_MAC) += sun7i_mac.o
+obj-$(CONFIG_SUN7I_MAC) += sunxi_common.o sun7i_mac.o

Shouldn't that be turned in a Kconfig option selected by both drivers?

What do you mean? There are some common functions that all of them share, such as reading the MAC address.

Or do you mean we should make the net_op rom_read_hwaddr() a configurable Kconfig?

Olliver

Quoted 3 lines

Maxime

#64 lore raw

PATCH v6 25/28 net: sun7i_mac: Add read_rom_hwaddr hook

Quoted 25 lines · Olliver Schinagl

Hey Maxime,

Quoted 10 lines · Maxime Ripard
Quoted 9 lines · Olliver Schinagl

With this patch sun7i_mac can now get the MAC address from the board in a predetermined board specific manner.

---
 drivers/net/Makefile    | 2 +-
 drivers/net/sun7i_mac.c | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
Quoted 12 lines

drivers/net/Makefile obj-$(CONFIG_E1000) += e1000.o · line 26

Quoted 10 lines
drivers/net/Makefile +1 -1
index 86dee7d746..5df5567536 100644
@@ -23,7 +23,7 @@ obj-$(CONFIG_E1000) += e1000.o
 obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
 obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
-obj-$(CONFIG_SUN7I_MAC) += sun7i_mac.o
+obj-$(CONFIG_SUN7I_MAC) += sunxi_common.o sun7i_mac.o

Shouldn't that be turned in a Kconfig option selected by both drivers?

Quoted 5 lines

What do you mean? There are some common functions that all of them share, such as reading the MAC address.

Or do you mean we should make the net_op rom_read_hwaddr() a configurable Kconfig?

I meant having a KConfig symbol to compile sunxi_common, and then have that symbol selected by the three EMAC/GMAC Kconfig symbol.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170516/35507f52/attachment.sig>
#65 lore raw

PATCH v6 26/28 net: sun8i_gmac: Add read_rom_hwaddr hook

In reply to Olliver Schinagl

With this patch sun8i_emac can now get the MAC address from the board in a predetermined board specific manner.

---
 drivers/net/Makefile     | 2 +-
 drivers/net/sun8i_emac.c | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/net/Makefile +1 -1
index 5df5567536..8464062d83 100644
@@ -24,7 +24,7 @@ obj-$(CONFIG_E1000_SPI) += e1000_spi.o
 obj-$(CONFIG_EEPRO100) += eepro100.o
 obj-$(CONFIG_SUN4I_EMAC) += sunxi_common.o sun4i_mac.o
 obj-$(CONFIG_SUN7I_MAC) += sunxi_common.o sun7i_mac.o
-obj-$(CONFIG_SUN8I_EMAC) += sun8i_emac.o
+obj-$(CONFIG_SUN8I_EMAC) += sunxi_common.o sun8i_emac.o
 obj-$(CONFIG_ENC28J60) += enc28j60.o
 obj-$(CONFIG_EP93XX) += ep93xx_eth.o
 obj-$(CONFIG_ETHOC) += ethoc.o
drivers/net/sun8i_emac.c +3 -0
index a3dbe2823b..5093f9c83d 100644
@@ -25,6 +25,8 @@
 #include <asm-generic/gpio.h>
 #endif
 
+#include "sunxi_common.h"
+
 #define MDIO_CMD_MII_BUSY		BIT(0)
 #define MDIO_CMD_MII_WRITE		BIT(1)
 
@@ -757,6 +759,7 @@ static int sun8i_emac_eth_probe(struct udevice *dev)
 static const struct eth_ops sun8i_emac_eth_ops = {
 	.start                  = sun8i_emac_eth_start,
 	.write_hwaddr           = sun8i_eth_write_hwaddr,
+	.read_rom_hwaddr	= sunxi_mac_read_rom_hwaddr,
 	.send                   = sun8i_emac_eth_send,
 	.recv                   = sun8i_emac_eth_recv,
 	.free_pkt               = sun8i_eth_free_pkt,
Signature · 1 line
2.11.0
#66 lore raw

PATCH v6 27/28 net: sun8i: fix whitespace

In reply to Olliver Schinagl

Fix a few whitespaces errors in the sun8i driver.

---
 drivers/net/Kconfig      |  8 ++++----
 drivers/net/sun8i_emac.c | 12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/net/Kconfig +4 -4
index 782348f872..d9d700ac15 100644
@@ -227,10 +227,10 @@ config GMAC_TX_DELAY
 	  Set the GMAC Transmit Clock Delay Chain value.
 
 config SUN8I_EMAC
-        bool "Allwinner Sun8i Ethernet MAC support"
-        depends on DM_ETH
-        select PHYLIB
-        help
+	bool "Allwinner Sun8i Ethernet MAC support"
+	depends on DM_ETH
+	select PHYLIB
+	help
           This driver supports the  Allwinner based SUN8I/SUN50I Ethernet MAC.
 	  It can be found in H3/A64/A83T based SoCs and compatible with both
 	  External and Internal PHYs.
drivers/net/sun8i_emac.c +6 -6
index 5093f9c83d..84e1d7d208 100644
@@ -757,13 +757,13 @@ static int sun8i_emac_eth_probe(struct udevice *dev)
 }
 
 static const struct eth_ops sun8i_emac_eth_ops = {
-	.start                  = sun8i_emac_eth_start,
-	.write_hwaddr           = sun8i_eth_write_hwaddr,
+	.start			= sun8i_emac_eth_start,
+	.write_hwaddr		= sun8i_eth_write_hwaddr,
 	.read_rom_hwaddr	= sunxi_mac_read_rom_hwaddr,
-	.send                   = sun8i_emac_eth_send,
-	.recv                   = sun8i_emac_eth_recv,
-	.free_pkt               = sun8i_eth_free_pkt,
-	.stop                   = sun8i_emac_eth_stop,
+	.send			= sun8i_emac_eth_send,
+	.recv			= sun8i_emac_eth_recv,
+	.free_pkt		= sun8i_eth_free_pkt,
+	.stop			= sun8i_emac_eth_stop,
 };
 
 static int sun8i_emac_eth_ofdata_to_platdata(struct udevice *dev)
Signature · 1 line
2.11.0
#68 lore raw

PATCH v6 28/28 net: sunxi: Enable eeprom on OLinuXino Lime boards (again)

In reply to Olliver Schinagl

With commit 2681e78a5ee ("configs: Re-sync") we lost the EEPROM settings from the defconfig files. Let us re-add them.

---
 configs/A10-OLinuXino-Lime_defconfig       | 3 +++
 configs/A20-OLinuXino-Lime2-eMMC_defconfig | 3 +++
 configs/A20-OLinuXino-Lime2_defconfig      | 3 +++
 configs/A20-OLinuXino-Lime_defconfig       | 3 +++
 configs/A20-OLinuXino_MICRO_defconfig      | 3 +++
 5 files changed, 15 insertions(+)
configs/A10-OLinuXino-Lime_defconfig +3 -0
index d4513144eb..993f7b81d4 100644
@@ -18,6 +18,9 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_ISO_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN4I_EMAC=y
+CONFIG_NET_ETHADDR_EEPROM=y
+CONFIG_NET_ETHADDR_EEPROM_I2C=y
+CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
configs/A20-OLinuXino-Lime2-eMMC_defconfig +3 -0
index fd743a5f45..ccb7a664d4 100644
@@ -22,6 +22,9 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 # CONFIG_SPL_PARTITION_UUIDS is not set
 CONFIG_DFU_RAM=y
 CONFIG_SUN7I_GMAC=y
+CONFIG_NET_ETHADDR_EEPROM=y
+CONFIG_NET_ETHADDR_EEPROM_I2C=y
+CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
configs/A20-OLinuXino-Lime2_defconfig +3 -0
index a932ec7b7b..43337cfc24 100644
@@ -23,6 +23,9 @@ CONFIG_DFU_RAM=y
 CONFIG_SUN7I_GMAC=y
 CONFIG_PHY_REALTEK=y
 CONFIG_RTL8211X_PHY_FORCE_MASTER=y
+CONFIG_NET_ETHADDR_EEPROM=y
+CONFIG_NET_ETHADDR_EEPROM_I2C=y
+CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
configs/A20-OLinuXino-Lime_defconfig +3 -0
index 41667384f4..802989518b 100644
@@ -17,6 +17,9 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
 CONFIG_PHY_REALTEK=y
+CONFIG_NET_ETHADDR_EEPROM=y
+CONFIG_NET_ETHADDR_EEPROM_I2C=y
+CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
configs/A20-OLinuXino_MICRO_defconfig +3 -0
index b1f80835c9..68e9984ac1 100644
@@ -20,6 +20,9 @@ CONFIG_SPL_I2C_SUPPORT=y
 # CONFIG_SPL_EFI_PARTITION is not set
 CONFIG_SUN7I_EMAC=y
 CONFIG_PHY_REALTEK=y
+CONFIG_NET_ETHADDR_EEPROM=y
+CONFIG_NET_ETHADDR_EEPROM_I2C=y
+CONFIG_NET_ETHADDR_EEPROM_I2C_BUS=1
 CONFIG_AXP_ALDO3_VOLT=2800
 CONFIG_AXP_ALDO4_VOLT=2800
 CONFIG_USB_EHCI_HCD=y
Signature · 1 line
2.11.0
#70 lore raw

v6 cover Retrieve MAC address from EEPROM

In reply to Olliver Schinagl

Hey all,

Quoted 38 lines · 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

Quoted 7 lines

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!

So I accidentally added those too to this patch series as well (first two patches). Which are technically not part of this series and are on their way as it is. Does patchwork figure out this automatically, or do you prefer a resend with the 2 patches removed?

Olliver

Quoted 149 lines

=======
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
#71 lore raw

v6 cover Retrieve MAC address from EEPROM

Quoted 46 lines · Olliver Schinagl

Hey all,

Quoted 43 lines · 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

Quoted 7 lines
Quoted 2 lines

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

So I accidentally added those too to this patch series as well (first two patches). Which are technically not part of this series and are on their way as it is. Does patchwork figure out this automatically, or do you prefer a resend with the 2 patches removed?

I've made patchwork reflect things correctly.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170515/e38cb692/attachment.sig>
#72 lore raw

v6 cover Retrieve MAC address from EEPROM

Quoted 50 lines · Tom Rini
Quoted 49 lines · Olliver Schinagl

Hey all,

Quoted 45 lines · 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!

Quoted 6 lines
Quoted 4 lines

So I accidentally added those too to this patch series as well (first two patches). Which are technically not part of this series and are on their way as it is. Does patchwork figure out this automatically, or do you prefer a resend with the 2 patches removed?

I've made patchwork reflect things correctly.

Few of the patches need re-work, so updated patchwork status as "Changes Requested" for the series.

thanks!

Signature · 4 lines
Jagan Teki
Free Software Engineer | www.openedev.com
U-Boot, Linux | Upstream Maintainer
Hyderabad, India.
#73 lore raw

v6 cover Retrieve MAC address from EEPROM

In reply to Olliver Schinagl

Hello,

Quoted 2 lines

* Renamed sunxi_[eg]mac to sun[47]_mac to be more clear and allowing preparing to merge common parts into sunxi_common

Wouldn't those better renamed to sun[47]i_mac instead, for consistency ?

Signature · 1 line
Vincent Legoll