[U-Boot] [PATCH v2 0/11] dm: net: Conversion patches for sunxi driver model Ethernet

This series enables driver model Ethernet for the pcDuino3, converting the designware Ethernet MAC in the process. It also moves all sunxi board to use Kconfig for their basic Ethernet settings.
This series is based on u-boot-dm/next and requires Joe's patch here:
http://patchwork.ozlabs.org/patch/458111/
It is available at u-boot-dm in branch net-working.
Changes in v2: - Add Ethernet for Orangepi, galileo - Add Ethernet for Orangepi_mini, Wits_Pro_A20_DKT, Mele_I7 - Drop bugfix patches that were incorporated in the Ethernet dm conversion - Drop the CONFIG_BOOTP_VCI_STRING patch - Rebase on dm/next - Remove unwanted printf() - Use the new recv() method and the free_pkt() method
Simon Glass (11): sunxi: Replace the pcDuino3 config with FDT version Kconfig: Move CONFIG_DESIGNWARE_ETH to Kconfig dts: sunxi: Bring in Ethernet device tree bindings dm: core: Support allocating driver-private data for DMA dm: net: Use existing Ethernet init for driver model Avoid calling print_eths() with driver model dm: net: Adjust PHY interface to work with CONFIG_DM_ETH dm: net: Tidy up designware driver ready for driver model dm: net: Adjust designware driver to support driver model dm: sunxi: Support driver model for Ethernet dm: sunxi: Use driver model for Ethernet on Linksprite pcDuino3
arch/arm/cpu/arm926ejs/spear/cpu.c | 2 +- arch/arm/cpu/armv7/socfpga/misc.c | 2 +- board/bf609-ezkit/bf609-ezkit.c | 2 +- board/spear/spear300/spear300.c | 2 +- board/spear/spear310/spear310.c | 2 +- board/spear/spear320/spear320.c | 2 +- board/spear/spear600/spear600.c | 2 +- board/st/stv0991/stv0991.c | 2 +- board/sunxi/gmac.c | 10 +- common/cmd_bdinfo.c | 2 +- common/miiphyutil.c | 1 + configs/A20-OLinuXino-Lime2_defconfig | 3 + configs/A20-OLinuXino-Lime_defconfig | 3 + configs/A20-OLinuXino_MICRO_defconfig | 3 + configs/Bananapi_defconfig | 3 + configs/Bananapro_defconfig | 3 + configs/CSQ_CS908_defconfig | 3 + configs/Colombus_defconfig | 3 + configs/Cubieboard2_defconfig | 3 + configs/Cubietruck_defconfig | 3 + configs/Hummingbird_A31_defconfig | 3 + configs/Linksprite_pcDuino3_Nano_defconfig | 3 + configs/Linksprite_pcDuino3_defconfig | 11 + configs/Linksprite_pcDuino3_fdt_defconfig | 15 -- configs/Mele_I7_defconfig | 3 + configs/Mele_M3_defconfig | 3 + configs/Mele_M5_defconfig | 3 + configs/Mele_M9_defconfig | 3 + configs/Orangepi_defconfig | 3 + configs/Orangepi_mini_defconfig | 3 + configs/Wits_Pro_A20_DKT_defconfig | 3 + configs/axs101_defconfig | 5 +- configs/axs103_defconfig | 3 + configs/bf609-ezkit_defconfig | 3 + configs/galileo_defconfig | 3 + configs/i12-tvbox_defconfig | 3 + configs/socfpga_cyclone5_defconfig | 3 + configs/socfpga_socrates_defconfig | 3 + configs/spear300_defconfig | 3 + configs/spear300_nand_defconfig | 3 + configs/spear300_usbtty_defconfig | 3 + configs/spear300_usbtty_nand_defconfig | 3 + configs/spear310_defconfig | 3 + configs/spear310_nand_defconfig | 3 + configs/spear310_pnor_defconfig | 3 + configs/spear310_usbtty_defconfig | 3 + configs/spear310_usbtty_nand_defconfig | 3 + configs/spear310_usbtty_pnor_defconfig | 3 + configs/spear320_defconfig | 3 + configs/spear320_nand_defconfig | 3 + configs/spear320_pnor_defconfig | 3 + configs/spear320_usbtty_defconfig | 3 + configs/spear320_usbtty_nand_defconfig | 3 + configs/spear320_usbtty_pnor_defconfig | 3 + configs/spear600_defconfig | 3 + configs/spear600_nand_defconfig | 3 + configs/spear600_usbtty_defconfig | 3 + configs/spear600_usbtty_nand_defconfig | 3 + configs/stv0991_defconfig | 3 + configs/tb100_defconfig | 3 + configs/x600_defconfig | 3 + .../net/allwinner,sun4i-emac.txt | 19 ++ .../net/allwinner,sun4i-mdio.txt | 27 +++ .../net/allwinner,sun7i-a20-gmac.txt | 27 +++ doc/device-tree-bindings/net/ethernet.txt | 25 +++ doc/device-tree-bindings/net/stmmac.txt | 63 ++++++ drivers/core/device.c | 11 +- drivers/net/Kconfig | 7 + drivers/net/Makefile | 2 +- drivers/net/designware.c | 250 +++++++++++++++++---- drivers/net/designware.h | 3 +- drivers/net/phy/phy.c | 22 ++ include/configs/axs101.h | 1 - include/configs/bf609-ezkit.h | 1 - include/configs/socfpga_common.h | 1 - include/configs/spear-common.h | 1 - include/configs/stv0991.h | 1 - include/configs/sunxi-common.h | 1 - include/configs/tb100.h | 1 - include/configs/x600.h | 1 - include/dm/device.h | 3 + include/net.h | 2 + include/phy.h | 23 +- net/eth.c | 78 ++++--- 84 files changed, 647 insertions(+), 124 deletions(-) delete mode 100644 configs/Linksprite_pcDuino3_fdt_defconfig create mode 100644 doc/device-tree-bindings/net/allwinner,sun4i-emac.txt create mode 100644 doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt create mode 100644 doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt create mode 100644 doc/device-tree-bindings/net/ethernet.txt create mode 100644 doc/device-tree-bindings/net/stmmac.txt

We currently have Linksprite_pcDuino3 and Linksprite_pcDuino3_fdt. Drop the former in favour of the latter.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Hans de Goede hdegoede@redhat.com Acked-by: Ian Campbell ijc@hellion.org.uk ---
Changes in v2: - Rebase on dm/next
configs/Linksprite_pcDuino3_defconfig | 7 +++++++ configs/Linksprite_pcDuino3_fdt_defconfig | 15 --------------- 2 files changed, 7 insertions(+), 15 deletions(-) delete mode 100644 configs/Linksprite_pcDuino3_fdt_defconfig
diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig index e642069..ff817d5 100644 --- a/configs/Linksprite_pcDuino3_defconfig +++ b/configs/Linksprite_pcDuino3_defconfig @@ -7,3 +7,10 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=122 CONFIG_DRAM_EMR1=4 +CONFIG_DM=y +CONFIG_DM_GPIO=y +CONFIG_DM_SERIAL=y +CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3" +CONFIG_OF_CONTROL=y +CONFIG_SPL_DISABLE_OF_CONTROL=y +CONFIG_OF_SEPARATE=y diff --git a/configs/Linksprite_pcDuino3_fdt_defconfig b/configs/Linksprite_pcDuino3_fdt_defconfig deleted file mode 100644 index 7690d1e..0000000 --- a/configs/Linksprite_pcDuino3_fdt_defconfig +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG_SPL=y -CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER,SUNXI_GMAC,AHCI,SATAPWR=SUNXI_GPH(2),USB_EHCI" -CONFIG_FDTFILE="sun7i-a20-pcduino3.dtb" -CONFIG_DM=y -CONFIG_DM_GPIO=y -CONFIG_DM_SERIAL=y -CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3" -CONFIG_OF_CONTROL=y -CONFIG_OF_SEPARATE=y -CONFIG_ARM=y -CONFIG_ARCH_SUNXI=y -CONFIG_MACH_SUN7I=y -CONFIG_DRAM_CLK=480 -CONFIG_DRAM_ZQ=122 -CONFIG_DRAM_EMR1=4

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
We currently have Linksprite_pcDuino3 and Linksprite_pcDuino3_fdt. Drop the former in favour of the latter.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Hans de Goede hdegoede@redhat.com Acked-by: Ian Campbell ijc@hellion.org.uk
Changes in v2:
- Rebase on dm/next
configs/Linksprite_pcDuino3_defconfig | 7 +++++++ configs/Linksprite_pcDuino3_fdt_defconfig | 15 --------------- 2 files changed, 7 insertions(+), 15 deletions(-) delete mode 100644 configs/Linksprite_pcDuino3_fdt_defconfig
Applied to u-boot-dm/next.

Move this to Kconfig and clean up board config files that use it. Also rename it to CONFIG_ETH_DESIGNWARE to fit with the naming that exists in drivers/net/Kconfig.
Signed-off-by: Simon Glass sjg@chromium.org Version 1: Acked-by: Joe Hershberger joe.hershberger@ni.com
---
Changes in v2: - Add Ethernet for Orangepi, galileo - Add Ethernet for Orangepi_mini, Wits_Pro_A20_DKT, Mele_I7 - Rebase on dm/next
arch/arm/cpu/arm926ejs/spear/cpu.c | 2 +- arch/arm/cpu/armv7/socfpga/misc.c | 2 +- board/bf609-ezkit/bf609-ezkit.c | 2 +- board/spear/spear300/spear300.c | 2 +- board/spear/spear310/spear310.c | 2 +- board/spear/spear320/spear320.c | 2 +- board/spear/spear600/spear600.c | 2 +- board/st/stv0991/stv0991.c | 2 +- configs/A20-OLinuXino-Lime2_defconfig | 3 +++ configs/A20-OLinuXino-Lime_defconfig | 3 +++ configs/A20-OLinuXino_MICRO_defconfig | 3 +++ configs/Bananapi_defconfig | 3 +++ configs/Bananapro_defconfig | 3 +++ configs/CSQ_CS908_defconfig | 3 +++ configs/Colombus_defconfig | 3 +++ configs/Cubieboard2_defconfig | 3 +++ configs/Cubietruck_defconfig | 3 +++ configs/Hummingbird_A31_defconfig | 3 +++ configs/Linksprite_pcDuino3_Nano_defconfig | 3 +++ configs/Linksprite_pcDuino3_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 | 3 +++ configs/Orangepi_mini_defconfig | 3 +++ configs/Wits_Pro_A20_DKT_defconfig | 3 +++ configs/axs101_defconfig | 5 ++++- configs/axs103_defconfig | 3 +++ configs/bf609-ezkit_defconfig | 3 +++ configs/galileo_defconfig | 3 +++ configs/i12-tvbox_defconfig | 3 +++ configs/socfpga_cyclone5_defconfig | 3 +++ configs/socfpga_socrates_defconfig | 3 +++ configs/spear300_defconfig | 3 +++ configs/spear300_nand_defconfig | 3 +++ configs/spear300_usbtty_defconfig | 3 +++ configs/spear300_usbtty_nand_defconfig | 3 +++ configs/spear310_defconfig | 3 +++ configs/spear310_nand_defconfig | 3 +++ configs/spear310_pnor_defconfig | 3 +++ configs/spear310_usbtty_defconfig | 3 +++ configs/spear310_usbtty_nand_defconfig | 3 +++ configs/spear310_usbtty_pnor_defconfig | 3 +++ configs/spear320_defconfig | 3 +++ configs/spear320_nand_defconfig | 3 +++ configs/spear320_pnor_defconfig | 3 +++ configs/spear320_usbtty_defconfig | 3 +++ configs/spear320_usbtty_nand_defconfig | 3 +++ configs/spear320_usbtty_pnor_defconfig | 3 +++ configs/spear600_defconfig | 3 +++ configs/spear600_nand_defconfig | 3 +++ configs/spear600_usbtty_defconfig | 3 +++ configs/spear600_usbtty_nand_defconfig | 3 +++ configs/stv0991_defconfig | 3 +++ configs/tb100_defconfig | 3 +++ configs/x600_defconfig | 3 +++ drivers/net/Kconfig | 7 +++++++ drivers/net/Makefile | 2 +- include/configs/axs101.h | 1 - include/configs/bf609-ezkit.h | 1 - include/configs/socfpga_common.h | 1 - include/configs/spear-common.h | 1 - include/configs/stv0991.h | 1 - include/configs/sunxi-common.h | 1 - include/configs/tb100.h | 1 - include/configs/x600.h | 1 - 67 files changed, 164 insertions(+), 18 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/spear/cpu.c b/arch/arm/cpu/arm926ejs/spear/cpu.c index 697e094..1ce9db7 100644 --- a/arch/arm/cpu/arm926ejs/spear/cpu.c +++ b/arch/arm/cpu/arm926ejs/spear/cpu.c @@ -32,7 +32,7 @@ int arch_cpu_init(void) periph_clk_cfg |= CONFIG_SPEAR_UART48M; writel(periph_clk_cfg, &misc_p->periph_clk_cfg); #endif -#if defined(CONFIG_DESIGNWARE_ETH) +#if defined(CONFIG_ETH_DESIGNWARE) periph1_clken |= MISC_ETHENB; #endif #if defined(CONFIG_DW_UDC) diff --git a/arch/arm/cpu/armv7/socfpga/misc.c b/arch/arm/cpu/armv7/socfpga/misc.c index 7873c38..0f8b4d0 100644 --- a/arch/arm/cpu/armv7/socfpga/misc.c +++ b/arch/arm/cpu/armv7/socfpga/misc.c @@ -49,7 +49,7 @@ void enable_caches(void) /* * DesignWare Ethernet initialization */ -#ifdef CONFIG_DESIGNWARE_ETH +#ifdef CONFIG_ETH_DESIGNWARE int cpu_eth_init(bd_t *bis) { #if CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS diff --git a/board/bf609-ezkit/bf609-ezkit.c b/board/bf609-ezkit/bf609-ezkit.c index 43a4330..86da028 100644 --- a/board/bf609-ezkit/bf609-ezkit.c +++ b/board/bf609-ezkit/bf609-ezkit.c @@ -33,7 +33,7 @@ int board_early_init_f(void) return 0; }
-#ifdef CONFIG_DESIGNWARE_ETH +#ifdef CONFIG_ETH_DESIGNWARE int board_eth_init(bd_t *bis) { int ret = 0; diff --git a/board/spear/spear300/spear300.c b/board/spear/spear300/spear300.c index 6b6bd9f..396b5bd 100644 --- a/board/spear/spear300/spear300.c +++ b/board/spear/spear300/spear300.c @@ -51,7 +51,7 @@ int board_eth_init(bd_t *bis) { int ret = 0;
-#if defined(CONFIG_DESIGNWARE_ETH) +#if defined(CONFIG_ETH_DESIGNWARE) u32 interface = PHY_INTERFACE_MODE_MII; if (designware_initialize(CONFIG_SPEAR_ETHBASE, interface) >= 0) ret++; diff --git a/board/spear/spear310/spear310.c b/board/spear/spear310/spear310.c index a4c6a8e..6f39ef1 100644 --- a/board/spear/spear310/spear310.c +++ b/board/spear/spear310/spear310.c @@ -52,7 +52,7 @@ int board_eth_init(bd_t *bis) { int ret = 0;
-#if defined(CONFIG_DESIGNWARE_ETH) +#if defined(CONFIG_ETH_DESIGNWARE) u32 interface = PHY_INTERFACE_MODE_MII; if (designware_initialize(CONFIG_SPEAR_ETHBASE, interface) >= 0) ret++; diff --git a/board/spear/spear320/spear320.c b/board/spear/spear320/spear320.c index ab732a7..52196af 100644 --- a/board/spear/spear320/spear320.c +++ b/board/spear/spear320/spear320.c @@ -63,7 +63,7 @@ int board_eth_init(bd_t *bis) { int ret = 0;
-#if defined(CONFIG_DESIGNWARE_ETH) +#if defined(CONFIG_ETH_DESIGNWARE) u32 interface = PHY_INTERFACE_MODE_MII; if (designware_initialize(CONFIG_SPEAR_ETHBASE, interface) >= 0) ret++; diff --git a/board/spear/spear600/spear600.c b/board/spear/spear600/spear600.c index 8472002..fc0918f 100644 --- a/board/spear/spear600/spear600.c +++ b/board/spear/spear600/spear600.c @@ -46,7 +46,7 @@ int board_eth_init(bd_t *bis) { int ret = 0;
-#if defined(CONFIG_DESIGNWARE_ETH) +#if defined(CONFIG_ETH_DESIGNWARE) u32 interface = PHY_INTERFACE_MODE_MII; #if defined(CONFIG_DW_AUTONEG) interface = PHY_INTERFACE_MODE_GMII; diff --git a/board/st/stv0991/stv0991.c b/board/st/stv0991/stv0991.c index f465699..38f6e1d 100644 --- a/board/st/stv0991/stv0991.c +++ b/board/st/stv0991/stv0991.c @@ -94,7 +94,7 @@ int board_eth_init(bd_t *bis) { int ret = 0;
-#if defined(CONFIG_DESIGNWARE_ETH) +#if defined(CONFIG_ETH_DESIGNWARE) u32 interface = PHY_INTERFACE_MODE_MII; if (designware_initialize(GMAC_BASE_ADDR, interface) >= 0) ret++; diff --git a/configs/A20-OLinuXino-Lime2_defconfig b/configs/A20-OLinuXino-Lime2_defconfig index 8c76360..cbfc8a3 100644 --- a/configs/A20-OLinuXino-Lime2_defconfig +++ b/configs/A20-OLinuXino-Lime2_defconfig @@ -7,3 +7,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/A20-OLinuXino-Lime_defconfig b/configs/A20-OLinuXino-Lime_defconfig index 8d71d5f..7868d6e 100644 --- a/configs/A20-OLinuXino-Lime_defconfig +++ b/configs/A20-OLinuXino-Lime_defconfig @@ -7,3 +7,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/A20-OLinuXino_MICRO_defconfig b/configs/A20-OLinuXino_MICRO_defconfig index 377bd46..11fb760 100644 --- a/configs/A20-OLinuXino_MICRO_defconfig +++ b/configs/A20-OLinuXino_MICRO_defconfig @@ -11,3 +11,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=384 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Bananapi_defconfig b/configs/Bananapi_defconfig index bad6081..36a8671 100644 --- a/configs/Bananapi_defconfig +++ b/configs/Bananapi_defconfig @@ -8,3 +8,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=432 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Bananapro_defconfig b/configs/Bananapro_defconfig index 2274c80..236a992 100644 --- a/configs/Bananapro_defconfig +++ b/configs/Bananapro_defconfig @@ -10,3 +10,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=432 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/CSQ_CS908_defconfig b/configs/CSQ_CS908_defconfig index ec84acb..776636e 100644 --- a/configs/CSQ_CS908_defconfig +++ b/configs/CSQ_CS908_defconfig @@ -13,3 +13,6 @@ CONFIG_AXP221_ALDO1_VOLT=3300 # No Vbus gpio for either usb CONFIG_USB1_VBUS_PIN="" CONFIG_USB2_VBUS_PIN="" +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig index d6aad5e..810c88f 100644 --- a/configs/Colombus_defconfig +++ b/configs/Colombus_defconfig @@ -10,3 +10,6 @@ CONFIG_DRAM_ZQ=251 CONFIG_AXP221_ALDO1_VOLT=3300 # No Vbus gpio for usb1 CONFIG_USB1_VBUS_PIN="" +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Cubieboard2_defconfig b/configs/Cubieboard2_defconfig index 05b11a0..9a253b5 100644 --- a/configs/Cubieboard2_defconfig +++ b/configs/Cubieboard2_defconfig @@ -7,3 +7,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=480 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Cubietruck_defconfig b/configs/Cubietruck_defconfig index fa48331..b8418f7 100644 --- a/configs/Cubietruck_defconfig +++ b/configs/Cubietruck_defconfig @@ -9,3 +9,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=432 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Hummingbird_A31_defconfig b/configs/Hummingbird_A31_defconfig index 7fd5a2a..8a11e09 100644 --- a/configs/Hummingbird_A31_defconfig +++ b/configs/Hummingbird_A31_defconfig @@ -14,3 +14,6 @@ CONFIG_AXP221_ALDO1_VOLT=3300 CONFIG_USB1_VBUS_PIN="PH24" # No Vbus gpio for usb2 CONFIG_USB2_VBUS_PIN="" +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Linksprite_pcDuino3_Nano_defconfig b/configs/Linksprite_pcDuino3_Nano_defconfig index 15a883a..9d171bd 100644 --- a/configs/Linksprite_pcDuino3_Nano_defconfig +++ b/configs/Linksprite_pcDuino3_Nano_defconfig @@ -9,3 +9,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=408 CONFIG_DRAM_ZQ=122 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig index ff817d5..8c76a736 100644 --- a/configs/Linksprite_pcDuino3_defconfig +++ b/configs/Linksprite_pcDuino3_defconfig @@ -14,3 +14,6 @@ CONFIG_DEFAULT_DEVICE_TREE="sun7i-a20-pcduino3" CONFIG_OF_CONTROL=y CONFIG_SPL_DISABLE_OF_CONTROL=y CONFIG_OF_SEPARATE=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Mele_I7_defconfig b/configs/Mele_I7_defconfig index 0e9a950..e91d507 100644 --- a/configs/Mele_I7_defconfig +++ b/configs/Mele_I7_defconfig @@ -24,3 +24,6 @@ CONFIG_AXP221_ALDO1_VOLT=3300 CONFIG_USB1_VBUS_PIN="PC27" # No Vbus gpio for usb2 CONFIG_USB2_VBUS_PIN="" +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Mele_M3_defconfig b/configs/Mele_M3_defconfig index a28e0a0..a74dd2d 100644 --- a/configs/Mele_M3_defconfig +++ b/configs/Mele_M3_defconfig @@ -10,3 +10,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=384 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Mele_M5_defconfig b/configs/Mele_M5_defconfig index 1442318..d0f0425 100644 --- a/configs/Mele_M5_defconfig +++ b/configs/Mele_M5_defconfig @@ -11,3 +11,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=432 CONFIG_DRAM_ZQ=122 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Mele_M9_defconfig b/configs/Mele_M9_defconfig index f9d4ccc..592322d 100644 --- a/configs/Mele_M9_defconfig +++ b/configs/Mele_M9_defconfig @@ -18,3 +18,6 @@ CONFIG_AXP221_ALDO1_VOLT=3300 CONFIG_USB1_VBUS_PIN="PC27" # No Vbus gpio for usb2 CONFIG_USB2_VBUS_PIN="" +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Orangepi_defconfig b/configs/Orangepi_defconfig index 28fadcd..2c57eec 100644 --- a/configs/Orangepi_defconfig +++ b/configs/Orangepi_defconfig @@ -11,3 +11,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=432 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Orangepi_mini_defconfig b/configs/Orangepi_mini_defconfig index 330679b..28edf88 100644 --- a/configs/Orangepi_mini_defconfig +++ b/configs/Orangepi_mini_defconfig @@ -13,3 +13,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=432 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/Wits_Pro_A20_DKT_defconfig b/configs/Wits_Pro_A20_DKT_defconfig index 9147ead..92c33b3 100644 --- a/configs/Wits_Pro_A20_DKT_defconfig +++ b/configs/Wits_Pro_A20_DKT_defconfig @@ -13,3 +13,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=384 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/axs101_defconfig b/configs/axs101_defconfig index 34ed963..9ef04df 100644 --- a/configs/axs101_defconfig +++ b/configs/axs101_defconfig @@ -3,4 +3,7 @@ CONFIG_TARGET_AXS101=y CONFIG_SYS_CLK_FREQ=750000000 CONFIG_ARC_CACHE_LINE_SHIFT=5 CONFIG_SYS_DCACHE_OFF=y -CONFIG_SYS_TEXT_BASE=0x81000000 \ No newline at end of file +CONFIG_SYS_TEXT_BASE=0x81000000 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/axs103_defconfig b/configs/axs103_defconfig index c63dd4a..3f7b21f 100644 --- a/configs/axs103_defconfig +++ b/configs/axs103_defconfig @@ -3,3 +3,6 @@ CONFIG_SYS_CLK_FREQ=50000000 CONFIG_ARC=y CONFIG_ISA_ARCV2=y CONFIG_TARGET_AXS101=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/bf609-ezkit_defconfig b/configs/bf609-ezkit_defconfig index 2bfb6a5..96f746e 100644 --- a/configs/bf609-ezkit_defconfig +++ b/configs/bf609-ezkit_defconfig @@ -1,2 +1,5 @@ CONFIG_BLACKFIN=y CONFIG_TARGET_BF609_EZKIT=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/galileo_defconfig b/configs/galileo_defconfig index f208651..9b0f969 100644 --- a/configs/galileo_defconfig +++ b/configs/galileo_defconfig @@ -4,3 +4,6 @@ CONFIG_TARGET_GALILEO=y CONFIG_OF_CONTROL=y CONFIG_OF_SEPARATE=y CONFIG_DEFAULT_DEVICE_TREE="galileo" +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/i12-tvbox_defconfig b/configs/i12-tvbox_defconfig index 157997f..b10f4d0 100644 --- a/configs/i12-tvbox_defconfig +++ b/configs/i12-tvbox_defconfig @@ -7,3 +7,6 @@ CONFIG_MACH_SUN7I=y CONFIG_DRAM_CLK=384 CONFIG_DRAM_ZQ=127 CONFIG_DRAM_EMR1=4 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/socfpga_cyclone5_defconfig b/configs/socfpga_cyclone5_defconfig index 0ebfbfc..6dd04bc 100644 --- a/configs/socfpga_cyclone5_defconfig +++ b/configs/socfpga_cyclone5_defconfig @@ -6,3 +6,6 @@ CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_socdk" CONFIG_DM=y CONFIG_DM_SPI=y CONFIG_DM_SPI_FLASH=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/socfpga_socrates_defconfig b/configs/socfpga_socrates_defconfig index 873b721..db9093e 100644 --- a/configs/socfpga_socrates_defconfig +++ b/configs/socfpga_socrates_defconfig @@ -6,3 +6,6 @@ CONFIG_DEFAULT_DEVICE_TREE="socfpga_cyclone5_socrates" CONFIG_DM=y CONFIG_DM_SPI=y CONFIG_DM_SPI_FLASH=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear300_defconfig b/configs/spear300_defconfig index 25a08df..df0b190 100644 --- a/configs/spear300_defconfig +++ b/configs/spear300_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear300" CONFIG_ARM=y CONFIG_TARGET_SPEAR300=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear300_nand_defconfig b/configs/spear300_nand_defconfig index a4b70e8..a49492c 100644 --- a/configs/spear300_nand_defconfig +++ b/configs/spear300_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear300,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR300=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear300_usbtty_defconfig b/configs/spear300_usbtty_defconfig index d750cf4..3d60d7f 100644 --- a/configs/spear300_usbtty_defconfig +++ b/configs/spear300_usbtty_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear300,usbtty" CONFIG_ARM=y CONFIG_TARGET_SPEAR300=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear300_usbtty_nand_defconfig b/configs/spear300_usbtty_nand_defconfig index 8bafdb5..ffe4f59 100644 --- a/configs/spear300_usbtty_nand_defconfig +++ b/configs/spear300_usbtty_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear300,usbtty,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR300=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear310_defconfig b/configs/spear310_defconfig index 8a9ec85..16a6bc3 100644 --- a/configs/spear310_defconfig +++ b/configs/spear310_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear310" CONFIG_ARM=y CONFIG_TARGET_SPEAR310=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear310_nand_defconfig b/configs/spear310_nand_defconfig index 1439ac5..05e3c96 100644 --- a/configs/spear310_nand_defconfig +++ b/configs/spear310_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear310,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR310=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear310_pnor_defconfig b/configs/spear310_pnor_defconfig index 19604b3..384cb54 100644 --- a/configs/spear310_pnor_defconfig +++ b/configs/spear310_pnor_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear310,FLASH_PNOR" CONFIG_ARM=y CONFIG_TARGET_SPEAR310=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear310_usbtty_defconfig b/configs/spear310_usbtty_defconfig index 6342a56..0115f2c 100644 --- a/configs/spear310_usbtty_defconfig +++ b/configs/spear310_usbtty_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear310,usbtty" CONFIG_ARM=y CONFIG_TARGET_SPEAR310=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear310_usbtty_nand_defconfig b/configs/spear310_usbtty_nand_defconfig index 5b9f1f6..2d82b66 100644 --- a/configs/spear310_usbtty_nand_defconfig +++ b/configs/spear310_usbtty_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear310,usbtty,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR310=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear310_usbtty_pnor_defconfig b/configs/spear310_usbtty_pnor_defconfig index 0567936..579df36 100644 --- a/configs/spear310_usbtty_pnor_defconfig +++ b/configs/spear310_usbtty_pnor_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear310,usbtty,FLASH_PNOR" CONFIG_ARM=y CONFIG_TARGET_SPEAR310=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear320_defconfig b/configs/spear320_defconfig index 3d91bb1..7bd51a8 100644 --- a/configs/spear320_defconfig +++ b/configs/spear320_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear320" CONFIG_ARM=y CONFIG_TARGET_SPEAR320=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear320_nand_defconfig b/configs/spear320_nand_defconfig index fd0f908..d7c995c 100644 --- a/configs/spear320_nand_defconfig +++ b/configs/spear320_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear320,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR320=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear320_pnor_defconfig b/configs/spear320_pnor_defconfig index 6cce316..a56a4e0 100644 --- a/configs/spear320_pnor_defconfig +++ b/configs/spear320_pnor_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear320,FLASH_PNOR" CONFIG_ARM=y CONFIG_TARGET_SPEAR320=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear320_usbtty_defconfig b/configs/spear320_usbtty_defconfig index 7ad3d84..c2fb481 100644 --- a/configs/spear320_usbtty_defconfig +++ b/configs/spear320_usbtty_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear320,usbtty" CONFIG_ARM=y CONFIG_TARGET_SPEAR320=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear320_usbtty_nand_defconfig b/configs/spear320_usbtty_nand_defconfig index a5ad90b..98368ed 100644 --- a/configs/spear320_usbtty_nand_defconfig +++ b/configs/spear320_usbtty_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear320,usbtty,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR320=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear320_usbtty_pnor_defconfig b/configs/spear320_usbtty_pnor_defconfig index 6b110ef..e428d25 100644 --- a/configs/spear320_usbtty_pnor_defconfig +++ b/configs/spear320_usbtty_pnor_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear320,usbtty,FLASH_PNOR" CONFIG_ARM=y CONFIG_TARGET_SPEAR320=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear600_defconfig b/configs/spear600_defconfig index f1cb0aa..dae0d59 100644 --- a/configs/spear600_defconfig +++ b/configs/spear600_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear600" CONFIG_ARM=y CONFIG_TARGET_SPEAR600=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear600_nand_defconfig b/configs/spear600_nand_defconfig index 172c187..cdd98fc 100644 --- a/configs/spear600_nand_defconfig +++ b/configs/spear600_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear600,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR600=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear600_usbtty_defconfig b/configs/spear600_usbtty_defconfig index cf8b0ec..1e28edf 100644 --- a/configs/spear600_usbtty_defconfig +++ b/configs/spear600_usbtty_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear600,usbtty" CONFIG_ARM=y CONFIG_TARGET_SPEAR600=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/spear600_usbtty_nand_defconfig b/configs/spear600_usbtty_nand_defconfig index 8bd2f07..2f8fd5e 100644 --- a/configs/spear600_usbtty_nand_defconfig +++ b/configs/spear600_usbtty_nand_defconfig @@ -1,3 +1,6 @@ CONFIG_SYS_EXTRA_OPTIONS="spear600,usbtty,nand" CONFIG_ARM=y CONFIG_TARGET_SPEAR600=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/stv0991_defconfig b/configs/stv0991_defconfig index e8cf311..838d191 100644 --- a/configs/stv0991_defconfig +++ b/configs/stv0991_defconfig @@ -4,3 +4,6 @@ CONFIG_TARGET_STV0991=y CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_DM=y CONFIG_DM_SERIAL=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/tb100_defconfig b/configs/tb100_defconfig index b0e8c9f..a6351fa 100644 --- a/configs/tb100_defconfig +++ b/configs/tb100_defconfig @@ -3,3 +3,6 @@ CONFIG_TARGET_TB100=y CONFIG_SYS_CLK_FREQ=500000000 CONFIG_ARC_CACHE_LINE_SHIFT=5 CONFIG_SYS_TEXT_BASE=0x84000000 +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/configs/x600_defconfig b/configs/x600_defconfig index c8bec67..7cd239b 100644 --- a/configs/x600_defconfig +++ b/configs/x600_defconfig @@ -1,3 +1,6 @@ CONFIG_SPL=y CONFIG_ARM=y CONFIG_TARGET_X600=y +CONFIG_ETH_DESIGNWARE=y +CONFIG_NETDEVICES=y +CONFIG_NET=y diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 5bd66ea..973258a 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -39,4 +39,11 @@ config ETH_SANDBOX_RAW network traffic to be tested from within sandbox. See board/sandbox/README.sandbox for more details.
+config ETH_DESIGNWARE + bool "Synopsys Designware Ethernet MAC" + help + This MAC is present in SoCs from various vendors. It supports + 100Mbit and 1 Gbit operation. You must enable CONFIG_PHYLIB to + provide the PHY (physical media interface). + endif # NETDEVICES diff --git a/drivers/net/Makefile b/drivers/net/Makefile index 3fc3c30..217ae75 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -16,7 +16,7 @@ obj-$(CONFIG_BFIN_MAC) += bfin_mac.o obj-$(CONFIG_CALXEDA_XGMAC) += calxedaxgmac.o obj-$(CONFIG_CS8900) += cs8900.o obj-$(CONFIG_TULIP) += dc2114x.o -obj-$(CONFIG_DESIGNWARE_ETH) += designware.o +obj-$(CONFIG_ETH_DESIGNWARE) += designware.o obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o obj-$(CONFIG_DNET) += dnet.o obj-$(CONFIG_E1000) += e1000.o diff --git a/include/configs/axs101.h b/include/configs/axs101.h index 5fb8aca..ed63048 100644 --- a/include/configs/axs101.h +++ b/include/configs/axs101.h @@ -110,7 +110,6 @@ /* * Ethernet configuration */ -#define CONFIG_DESIGNWARE_ETH #define CONFIG_DW_AUTONEG #define CONFIG_NET_MULTI
diff --git a/include/configs/bf609-ezkit.h b/include/configs/bf609-ezkit.h index 878009f..7507d57 100644 --- a/include/configs/bf609-ezkit.h +++ b/include/configs/bf609-ezkit.h @@ -71,7 +71,6 @@ #define CONFIG_NETCONSOLE #define CONFIG_NET_MULTI #define CONFIG_HOSTNAME "bf609-ezkit" -#define CONFIG_DESIGNWARE_ETH #define CONFIG_PHY_ADDR 1 #define CONFIG_DW_PORTS 1 #define CONFIG_DW_ALTDESCRIPTOR diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h index 6d93472..1ecd56f 100644 --- a/include/configs/socfpga_common.h +++ b/include/configs/socfpga_common.h @@ -99,7 +99,6 @@ * Ethernet on SoC (EMAC) */ #if defined(CONFIG_CMD_NET) && !defined(CONFIG_SOCFPGA_VIRTUAL_TARGET) -#define CONFIG_DESIGNWARE_ETH #define CONFIG_NET_MULTI #define CONFIG_DW_ALTDESCRIPTOR #define CONFIG_MII diff --git a/include/configs/spear-common.h b/include/configs/spear-common.h index 16281f5..409cf54 100644 --- a/include/configs/spear-common.h +++ b/include/configs/spear-common.h @@ -18,7 +18,6 @@
/* Ethernet driver configuration */ #define CONFIG_MII -#define CONFIG_DESIGNWARE_ETH #define CONFIG_NET_MULTI #define CONFIG_PHYLIB #define CONFIG_PHY_RESET_DELAY 10000 /* in usec */ diff --git a/include/configs/stv0991.h b/include/configs/stv0991.h index 156e0fa..ab1e61c 100644 --- a/include/configs/stv0991.h +++ b/include/configs/stv0991.h @@ -55,7 +55,6 @@ #define CONFIG_MII #define CONFIG_PHYLIB #define CONFIG_CMD_NET -#define CONFIG_DESIGNWARE_ETH #define CONFIG_DW_ALTDESCRIPTOR #define CONFIG_PHY_MICREL
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 1f7a1cb..b542da7 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -284,7 +284,6 @@ extern int soft_i2c_gpio_scl; #endif
#ifdef CONFIG_SUNXI_GMAC -#define CONFIG_DESIGNWARE_ETH /* GMAC can use designware driver */ #define CONFIG_DW_AUTONEG #define CONFIG_PHY_GIGE /* GMAC can use gigabit PHY */ #define CONFIG_PHY_ADDR 1 diff --git a/include/configs/tb100.h b/include/configs/tb100.h index 46df406..bc69f1d 100644 --- a/include/configs/tb100.h +++ b/include/configs/tb100.h @@ -66,7 +66,6 @@ /* * Ethernet configuration */ -#define CONFIG_DESIGNWARE_ETH #define ETH0_BASE_ADDRESS 0xFE100000 #define ETH1_BASE_ADDRESS 0xFE110000
diff --git a/include/configs/x600.h b/include/configs/x600.h index 241bf65..27a66a5 100644 --- a/include/configs/x600.h +++ b/include/configs/x600.h @@ -74,7 +74,6 @@
/* Ethernet config options */ #define CONFIG_MII -#define CONFIG_DESIGNWARE_ETH #define CONFIG_NET_MULTI #define CONFIG_PHYLIB #define CONFIG_PHY_RESET_DELAY 10000 /* in usec */

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
Move this to Kconfig and clean up board config files that use it. Also rename it to CONFIG_ETH_DESIGNWARE to fit with the naming that exists in drivers/net/Kconfig.
Signed-off-by: Simon Glass sjg@chromium.org Version 1: Acked-by: Joe Hershberger joe.hershberger@ni.com
Changes in v2:
- Add Ethernet for Orangepi, galileo
- Add Ethernet for Orangepi_mini, Wits_Pro_A20_DKT, Mele_I7
- Rebase on dm/next
Applied to u-boot-dm/next.

Since we will use these bindings on sunxi, bring them in from Linux 4.0-rc1.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Ian Campbell ijc@hellion.org.uk ---
Changes in v2: None
.../net/allwinner,sun4i-emac.txt | 19 +++++++ .../net/allwinner,sun4i-mdio.txt | 27 ++++++++++ .../net/allwinner,sun7i-a20-gmac.txt | 27 ++++++++++ doc/device-tree-bindings/net/ethernet.txt | 25 +++++++++ doc/device-tree-bindings/net/stmmac.txt | 63 ++++++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 doc/device-tree-bindings/net/allwinner,sun4i-emac.txt create mode 100644 doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt create mode 100644 doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt create mode 100644 doc/device-tree-bindings/net/ethernet.txt create mode 100644 doc/device-tree-bindings/net/stmmac.txt
diff --git a/doc/device-tree-bindings/net/allwinner,sun4i-emac.txt b/doc/device-tree-bindings/net/allwinner,sun4i-emac.txt new file mode 100644 index 0000000..10640b1 --- /dev/null +++ b/doc/device-tree-bindings/net/allwinner,sun4i-emac.txt @@ -0,0 +1,19 @@ +* Allwinner EMAC ethernet controller + +Required properties: +- compatible: should be "allwinner,sun4i-a10-emac" (Deprecated: + "allwinner,sun4i-emac") +- reg: address and length of the register set for the device. +- interrupts: interrupt for the device +- phy: see ethernet.txt file in the same directory. +- clocks: A phandle to the reference clock for this device + +Example: + +emac: ethernet@01c0b000 { + compatible = "allwinner,sun4i-a10-emac"; + reg = <0x01c0b000 0x1000>; + interrupts = <55>; + clocks = <&ahb_gates 17>; + phy = <&phy0>; +}; diff --git a/doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt b/doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt new file mode 100644 index 0000000..4ec5641 --- /dev/null +++ b/doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt @@ -0,0 +1,27 @@ +* Allwinner A10 MDIO Ethernet Controller interface + +Required properties: +- compatible: should be "allwinner,sun4i-a10-mdio" + (Deprecated: "allwinner,sun4i-mdio"). +- reg: address and length of the register set for the device. + +Optional properties: +- phy-supply: phandle to a regulator if the PHY needs one + +Example at the SoC level: +mdio@01c0b080 { + compatible = "allwinner,sun4i-a10-mdio"; + reg = <0x01c0b080 0x14>; + #address-cells = <1>; + #size-cells = <0>; +}; + +And at the board level: + +mdio@01c0b080 { + phy-supply = <®_emac_3v3>; + + phy0: ethernet-phy@0 { + reg = <0>; + }; +}; diff --git a/doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt b/doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt new file mode 100644 index 0000000..ea4d752 --- /dev/null +++ b/doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt @@ -0,0 +1,27 @@ +* Allwinner GMAC ethernet controller + +This device is a platform glue layer for stmmac. +Please see stmmac.txt for the other unchanged properties. + +Required properties: + - compatible: Should be "allwinner,sun7i-a20-gmac" + - clocks: Should contain the GMAC main clock, and tx clock + The tx clock type should be "allwinner,sun7i-a20-gmac-clk" + - clock-names: Should contain the clock names "stmmaceth", + and "allwinner_gmac_tx" + +Optional properties: +- phy-supply: phandle to a regulator if the PHY needs one + +Examples: + + gmac: ethernet@01c50000 { + compatible = "allwinner,sun7i-a20-gmac"; + reg = <0x01c50000 0x10000>, + <0x01c20164 0x4>; + interrupts = <0 85 1>; + interrupt-names = "macirq"; + clocks = <&ahb_gates 49>, <&gmac_tx>; + clock-names = "stmmaceth", "allwinner_gmac_tx"; + phy-mode = "mii"; + }; diff --git a/doc/device-tree-bindings/net/ethernet.txt b/doc/device-tree-bindings/net/ethernet.txt new file mode 100644 index 0000000..3fc3605 --- /dev/null +++ b/doc/device-tree-bindings/net/ethernet.txt @@ -0,0 +1,25 @@ +The following properties are common to the Ethernet controllers: + +- local-mac-address: array of 6 bytes, specifies the MAC address that was + assigned to the network device; +- mac-address: array of 6 bytes, specifies the MAC address that was last used by + the boot program; should be used in cases where the MAC address assigned to + the device by the boot program is different from the "local-mac-address" + property; +- max-speed: number, specifies maximum speed in Mbit/s supported by the device; +- max-frame-size: number, maximum transfer unit (IEEE defined MTU), rather than + the maximum frame size (there's contradiction in ePAPR). +- phy-mode: string, operation mode of the PHY interface; supported values are + "mii", "gmii", "sgmii", "qsgmii", "tbi", "rev-mii", "rmii", "rgmii", "rgmii-id", + "rgmii-rxid", "rgmii-txid", "rtbi", "smii", "xgmii"; this is now a de-facto + standard property; +- phy-connection-type: the same as "phy-mode" property but described in ePAPR; +- phy-handle: phandle, specifies a reference to a node representing a PHY + device; this property is described in ePAPR and so preferred; +- phy: the same as "phy-handle" property, not recommended for new bindings. +- phy-device: the same as "phy-handle" property, not recommended for new + bindings. + +Child nodes of the Ethernet controller are typically the individual PHY devices +connected via the MDIO bus (sometimes the MDIO bus controller is separate). +They are described in the phy.txt file in this same directory. diff --git a/doc/device-tree-bindings/net/stmmac.txt b/doc/device-tree-bindings/net/stmmac.txt new file mode 100644 index 0000000..5f02517 --- /dev/null +++ b/doc/device-tree-bindings/net/stmmac.txt @@ -0,0 +1,63 @@ +* STMicroelectronics 10/100/1000 Ethernet driver (GMAC) + +Required properties: +- compatible: Should be "snps,dwmac-<ip_version>" "snps,dwmac" + For backwards compatibility: "st,spear600-gmac" is also supported. +- reg: Address and length of the register set for the device +- interrupt-parent: Should be the phandle for the interrupt controller + that services interrupts for this device +- interrupts: Should contain the STMMAC interrupts +- interrupt-names: Should contain the interrupt names "macirq" + "eth_wake_irq" if this interrupt is supported in the "interrupts" + property +- phy-mode: See ethernet.txt file in the same directory. +- snps,reset-gpio gpio number for phy reset. +- snps,reset-active-low boolean flag to indicate if phy reset is active low. +- snps,reset-delays-us is triplet of delays + The 1st cell is reset pre-delay in micro seconds. + The 2nd cell is reset pulse in micro seconds. + The 3rd cell is reset post-delay in micro seconds. +- snps,pbl Programmable Burst Length +- snps,fixed-burst Program the DMA to use the fixed burst mode +- snps,mixed-burst Program the DMA to use the mixed burst mode +- snps,force_thresh_dma_mode Force DMA to use the threshold mode for + both tx and rx +- snps,force_sf_dma_mode Force DMA to use the Store and Forward + mode for both tx and rx. This flag is + ignored if force_thresh_dma_mode is set. +- snps,multicast-filter-bins: Number of multicast filter hash bins + supported by this device instance +- snps,perfect-filter-entries: Number of perfect filter entries supported + by this device instance + +Optional properties: +- resets: Should contain a phandle to the STMMAC reset signal, if any +- reset-names: Should contain the reset signal name "stmmaceth", if a + reset phandle is given +- max-frame-size: See ethernet.txt file in the same directory +- clocks: If present, the first clock should be the GMAC main clock, + further clocks may be specified in derived bindings. +- clock-names: One name for each entry in the clocks property, the + first one should be "stmmaceth". +- clk_ptp_ref: this is the PTP reference clock; in case of the PTP is + available this clock is used for programming the Timestamp Addend Register. + If not passed then the system clock will be used and this is fine on some + platforms. +- snps,burst_len: The AXI burst lenth value of the AXI BUS MODE register. + +Examples: + + gmac0: ethernet@e0800000 { + compatible = "st,spear600-gmac"; + reg = <0xe0800000 0x8000>; + interrupt-parent = <&vic1>; + interrupts = <24 23>; + interrupt-names = "macirq", "eth_wake_irq"; + mac-address = [000000000000]; /* Filled in by U-Boot */ + max-frame-size = <3800>; + phy-mode = "gmii"; + snps,multicast-filter-bins = <256>; + snps,perfect-filter-entries = <128>; + clocks = <&clock>; + clock-names = "stmmaceth"; + };

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
Since we will use these bindings on sunxi, bring them in from Linux 4.0-rc1.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Ian Campbell ijc@hellion.org.uk
Changes in v2: None
.../net/allwinner,sun4i-emac.txt | 19 +++++++ .../net/allwinner,sun4i-mdio.txt | 27 ++++++++++ .../net/allwinner,sun7i-a20-gmac.txt | 27 ++++++++++ doc/device-tree-bindings/net/ethernet.txt | 25 +++++++++ doc/device-tree-bindings/net/stmmac.txt | 63 ++++++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 doc/device-tree-bindings/net/allwinner,sun4i-emac.txt create mode 100644 doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt create mode 100644 doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt create mode 100644 doc/device-tree-bindings/net/ethernet.txt create mode 100644 doc/device-tree-bindings/net/stmmac.txt
Applied to u-boot-dm/next.

Some driver want to put DMA buffers in their private data. Add a flag to tell driver model to align driver-private data to a cache boundary so that DMA will work correctly in this case.
Signed-off-by: Simon Glass sjg@chromium.org --- This patch can be dropped once this one is applied:
http://patchwork.ozlabs.org/patch/454670/
Changes in v2: None
drivers/core/device.c | 11 ++++++++++- include/dm/device.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/core/device.c b/drivers/core/device.c index 7483405..872b703 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -182,7 +182,16 @@ int device_probe_child(struct udevice *dev, void *parent_priv)
/* Allocate private data if requested */ if (drv->priv_auto_alloc_size) { - dev->priv = calloc(1, drv->priv_auto_alloc_size); + if (drv->flags & DM_FLAG_ALLOC_PRIV_DMA) { + dev->priv = memalign(ARCH_DMA_MINALIGN, + drv->priv_auto_alloc_size); + if (dev->priv) { + memset(dev->priv, '\0', + drv->priv_auto_alloc_size); + } + } else { + dev->priv = calloc(1, drv->priv_auto_alloc_size); + } if (!dev->priv) { ret = -ENOMEM; goto fail; diff --git a/include/dm/device.h b/include/dm/device.h index 6980954..f27b34b 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -30,6 +30,9 @@ struct driver_info; /* DM is responsible for allocating and freeing parent_platdata */ #define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3)
+/* Allocate driver private data on a DMA boundary */ +#define DM_FLAG_ALLOC_PRIV_DMA (1 << 4) + /** * struct udevice - An instance of a driver *

At present even with driver model is used there is still much manual init of related devices: PHY, environment and board init. Until these requirements are dealt with in another way we need to keep them around.
Break out the init portion of the legacy eth_initialize() into a separate function and call it from both the legacy and driver model eth_initialize() functions.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com ---
Changes in v2: None
net/eth.c | 78 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 36 deletions(-)
diff --git a/net/eth.c b/net/eth.c index 889ad8f..ede9367 100644 --- a/net/eth.c +++ b/net/eth.c @@ -79,6 +79,45 @@ static int eth_mac_skip(int index)
static void eth_current_changed(void);
+/* + * CPU and board-specific Ethernet initializations. Aliased function + * signals caller to move on + */ +static int __def_eth_init(bd_t *bis) +{ + return -1; +} +int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init"))); +int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init"))); + +static void eth_common_init(void) +{ + bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); +#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) + miiphy_init(); +#endif + +#ifdef CONFIG_PHYLIB + phy_init(); +#endif + + eth_env_init(); + + /* + * If board-specific initialization exists, call it. + * If not, call a CPU-specific one + */ + if (board_eth_init != __def_eth_init) { + if (board_eth_init(gd->bd) < 0) + printf("Board Net Initialization Failed\n"); + } else if (cpu_eth_init != __def_eth_init) { + if (cpu_eth_init(gd->bd) < 0) + printf("CPU Net Initialization Failed\n"); + } else { + printf("Net Initialization Skipped\n"); + } +} + #ifdef CONFIG_DM_ETH /** * struct eth_device_priv - private structure for each Ethernet device @@ -390,8 +429,7 @@ int eth_initialize(void) int num_devices = 0; struct udevice *dev;
- bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); - eth_env_init(); + eth_common_init();
/* * Devices need to write the hwaddr even if not started so that Linux @@ -518,16 +556,6 @@ UCLASS_DRIVER(eth) = { #endif
#ifndef CONFIG_DM_ETH -/* - * CPU and board-specific Ethernet initializations. Aliased function - * signals caller to move on - */ -static int __def_eth_init(bd_t *bis) -{ - return -1; -} -int cpu_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init"))); -int board_eth_init(bd_t *bis) __attribute__((weak, alias("__def_eth_init")));
#ifdef CONFIG_API static struct { @@ -702,32 +730,10 @@ int eth_unregister(struct eth_device *dev) int eth_initialize(void) { int num_devices = 0; + eth_devices = NULL; eth_current = NULL; - - bootstage_mark(BOOTSTAGE_ID_NET_ETH_START); -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) - miiphy_init(); -#endif - -#ifdef CONFIG_PHYLIB - phy_init(); -#endif - - eth_env_init(); - - /* - * If board-specific initialization exists, call it. - * If not, call a CPU-specific one - */ - if (board_eth_init != __def_eth_init) { - if (board_eth_init(gd->bd) < 0) - printf("Board Net Initialization Failed\n"); - } else if (cpu_eth_init != __def_eth_init) { - if (cpu_eth_init(gd->bd) < 0) - printf("CPU Net Initialization Failed\n"); - } else - printf("Net Initialization Skipped\n"); + eth_common_init();
if (!eth_devices) { puts("No ethernet found.\n");

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
At present even with driver model is used there is still much manual init of related devices: PHY, environment and board init. Until these requirements are dealt with in another way we need to keep them around.
Break out the init portion of the legacy eth_initialize() into a separate function and call it from both the legacy and driver model eth_initialize() functions.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com
Changes in v2: None
net/eth.c | 78 ++++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 42 insertions(+), 36 deletions(-)
Applied to u-boot-dm/next.

This function is not supported with driver model.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com --- Note from Joe Hershberger joe.hershberger@ni.com
At this point I don't see much value in listing the Ethernet devices in bdinfo. It seems like a bit of a spurious thing to display and as such I didn't feel like rewriting it to be compatible with DM or implementing the functions bdinfo's print_eths() uses. Also, it is only supported on ARM and Microblaze. The inconsistency also led to my decision to drop it.
Changes in v2: None
common/cmd_bdinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index b4cce25..f16d5c7 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -377,7 +377,7 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, print_num("-> size", bd->bi_dram[i].size); }
-#if defined(CONFIG_CMD_NET) +#if defined(CONFIG_CMD_NET) && !defined(CONFIG_DM_ETH) print_eths(); #endif printf("baudrate = %u bps\n", gd->baudrate);

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
This function is not supported with driver model.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com
Note from Joe Hershberger joe.hershberger@ni.com
At this point I don't see much value in listing the Ethernet devices in bdinfo. It seems like a bit of a spurious thing to display and as such I didn't feel like rewriting it to be compatible with DM or implementing the functions bdinfo's print_eths() uses. Also, it is only supported on ARM and Microblaze. The inconsistency also led to my decision to drop it.
Changes in v2: None
common/cmd_bdinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next.

When driver model is used for Ethernet a few functions are passed a udevice instead of an eth_device. Also add a function to find a PHY type given its name. This will be used to decode the device tree node.
Finally, put a phy_interface field in struct eth_pdata since this is an important part of the platform data for Ethernet.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com ---
Changes in v2: None
common/miiphyutil.c | 1 + drivers/net/phy/phy.c | 22 ++++++++++++++++++++++ include/net.h | 2 ++ include/phy.h | 23 ++++++++++++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/common/miiphyutil.c b/common/miiphyutil.c index 74812e6..c88c28a 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -11,6 +11,7 @@ */
#include <common.h> +#include <dm.h> #include <miiphy.h> #include <phy.h>
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index df7e945..9d88afe 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -11,6 +11,7 @@
#include <config.h> #include <common.h> +#include <dm.h> #include <malloc.h> #include <net.h> #include <command.h> @@ -754,7 +755,11 @@ struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, return get_phy_device_by_mask(bus, phy_mask, interface); }
+#ifdef CONFIG_DM_ETH +void phy_connect_dev(struct phy_device *phydev, struct udevice *dev) +#else void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev) +#endif { /* Soft Reset the PHY */ phy_reset(phydev); @@ -767,8 +772,13 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev) debug("%s connected to %s\n", dev->name, phydev->drv->name); }
+#ifdef CONFIG_DM_ETH +struct phy_device *phy_connect(struct mii_dev *bus, int addr, + struct udevice *dev, phy_interface_t interface) +#else struct phy_device *phy_connect(struct mii_dev *bus, int addr, struct eth_device *dev, phy_interface_t interface) +#endif { struct phy_device *phydev;
@@ -813,3 +823,15 @@ int phy_shutdown(struct phy_device *phydev)
return 0; } + +int phy_get_interface_by_name(const char *str) +{ + int i; + + for (i = 0; i < PHY_INTERFACE_MODE_COUNT; i++) { + if (!strcmp(str, phy_interface_strings[i])) + return i; + } + + return -1; +} diff --git a/include/net.h b/include/net.h index f9df532..2b4f9f3 100644 --- a/include/net.h +++ b/include/net.h @@ -84,10 +84,12 @@ enum eth_state_t { * * @iobase: The base address of the hardware registers * @enetaddr: The Ethernet MAC address that is loaded from EEPROM or env + * @phy_interface: PHY interface to use - see PHY_INTERFACE_MODE_... */ struct eth_pdata { phys_addr_t iobase; unsigned char enetaddr[6]; + int phy_interface; };
/** diff --git a/include/phy.h b/include/phy.h index d117fc1..384dc23 100644 --- a/include/phy.h +++ b/include/phy.h @@ -51,7 +51,9 @@ typedef enum { PHY_INTERFACE_MODE_RGMII_TXID, PHY_INTERFACE_MODE_RTBI, PHY_INTERFACE_MODE_XGMII, - PHY_INTERFACE_MODE_NONE /* Must be last */ + PHY_INTERFACE_MODE_NONE, /* Must be last */ + + PHY_INTERFACE_MODE_COUNT, } phy_interface_t;
static const char *phy_interface_strings[] = { @@ -142,7 +144,11 @@ struct phy_device { struct phy_driver *drv; void *priv;
+#ifdef CONFIG_DM_ETH + struct udevice *dev; +#else struct eth_device *dev; +#endif
/* forced speed & duplex (no autoneg) * partner speed & duplex & pause (autoneg) @@ -205,10 +211,17 @@ int phy_init(void); int phy_reset(struct phy_device *phydev); struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, phy_interface_t interface); +#ifdef CONFIG_DM_ETH +void phy_connect_dev(struct phy_device *phydev, struct udevice *dev); +struct phy_device *phy_connect(struct mii_dev *bus, int addr, + struct udevice *dev, + phy_interface_t interface); +#else void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev); struct phy_device *phy_connect(struct mii_dev *bus, int addr, struct eth_device *dev, phy_interface_t interface); +#endif int phy_startup(struct phy_device *phydev); int phy_config(struct phy_device *phydev); int phy_shutdown(struct phy_device *phydev); @@ -242,6 +255,14 @@ int phy_vitesse_init(void);
int board_phy_config(struct phy_device *phydev);
+/** + * phy_get_interface_by_name() - Look up a PHY interface name + * + * @str: PHY interface name, e.g. "mii" + * @return PHY_INTERFACE_MODE_... value, or -1 if not found + */ +int phy_get_interface_by_name(const char *str); + /* PHY UIDs for various PHYs that are referenced in external code */ #define PHY_UID_CS4340 0x13e51002 #define PHY_UID_TN2020 0x00a19410

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
When driver model is used for Ethernet a few functions are passed a udevice instead of an eth_device. Also add a function to find a PHY type given its name. This will be used to decode the device tree node.
Finally, put a phy_interface field in struct eth_pdata since this is an important part of the platform data for Ethernet.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com
Changes in v2: None
common/miiphyutil.c | 1 + drivers/net/phy/phy.c | 22 ++++++++++++++++++++++ include/net.h | 2 ++ include/phy.h | 23 ++++++++++++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next.

Adjust the error handling to use errno.h instead of returning -1. Change leaf functions to pass in the arguments they require rather than struct eth_device. Apart from simplifying the code it makes is easier to reuse these functions for driver model, since mostly they actually only use struct dw_eth_priv (which we can keep).
Create a stub for each Ethernet operation function. This will allow use to share code with the driver model versions.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com ---
Changes in v2: None
drivers/net/designware.c | 87 +++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 34 deletions(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c index cc01604..5b36d4f 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -6,10 +6,11 @@ */
/* - * Designware ethernet IP driver for u-boot + * Designware ethernet IP driver for U-Boot */
#include <common.h> +#include <errno.h> #include <miiphy.h> #include <malloc.h> #include <linux/compiler.h> @@ -40,7 +41,7 @@ static int dw_mdio_read(struct mii_dev *bus, int addr, int devad, int reg) udelay(10); };
- return -1; + return -ETIMEDOUT; }
static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, @@ -49,7 +50,7 @@ static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, struct eth_mac_regs *mac_p = bus->priv; ulong start; u16 miiaddr; - int ret = -1, timeout = CONFIG_MDIO_TIMEOUT; + int ret = -ETIMEDOUT, timeout = CONFIG_MDIO_TIMEOUT;
writel(val, &mac_p->miidata); miiaddr = ((addr << MIIADDRSHIFT) & MII_ADDRMSK) | @@ -69,27 +70,26 @@ static int dw_mdio_write(struct mii_dev *bus, int addr, int devad, int reg, return ret; }
-static int dw_mdio_init(char *name, struct eth_mac_regs *mac_regs_p) +static int dw_mdio_init(const char *name, struct eth_mac_regs *mac_regs_p) { struct mii_dev *bus = mdio_alloc();
if (!bus) { printf("Failed to allocate MDIO bus\n"); - return -1; + return -ENOMEM; }
bus->read = dw_mdio_read; bus->write = dw_mdio_write; - sprintf(bus->name, name); + snprintf(bus->name, sizeof(bus->name), name);
bus->priv = (void *)mac_regs_p;
return mdio_register(bus); }
-static void tx_descs_init(struct eth_device *dev) +static void tx_descs_init(struct dw_eth_dev *priv) { - struct dw_eth_dev *priv = dev->priv; struct eth_dma_regs *dma_p = priv->dma_regs_p; struct dmamacdescr *desc_table_p = &priv->tx_mac_descrtable[0]; char *txbuffs = &priv->txbuffs[0]; @@ -128,9 +128,8 @@ static void tx_descs_init(struct eth_device *dev) priv->tx_currdescnum = 0; }
-static void rx_descs_init(struct eth_device *dev) +static void rx_descs_init(struct dw_eth_dev *priv) { - struct dw_eth_dev *priv = dev->priv; struct eth_dma_regs *dma_p = priv->dma_regs_p; struct dmamacdescr *desc_table_p = &priv->rx_mac_descrtable[0]; char *rxbuffs = &priv->rxbuffs[0]; @@ -170,12 +169,10 @@ static void rx_descs_init(struct eth_device *dev) priv->rx_currdescnum = 0; }
-static int dw_write_hwaddr(struct eth_device *dev) +static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 *mac_id) { - struct dw_eth_dev *priv = dev->priv; struct eth_mac_regs *mac_p = priv->mac_regs_p; u32 macid_lo, macid_hi; - u8 *mac_id = &dev->enetaddr[0];
macid_lo = mac_id[0] + (mac_id[1] << 8) + (mac_id[2] << 16) + (mac_id[3] << 24); @@ -213,9 +210,8 @@ static void dw_adjust_link(struct eth_mac_regs *mac_p, (phydev->port == PORT_FIBRE) ? ", fiber mode" : ""); }
-static void dw_eth_halt(struct eth_device *dev) +static void _dw_eth_halt(struct dw_eth_dev *priv) { - struct dw_eth_dev *priv = dev->priv; struct eth_mac_regs *mac_p = priv->mac_regs_p; struct eth_dma_regs *dma_p = priv->dma_regs_p;
@@ -225,12 +221,12 @@ static void dw_eth_halt(struct eth_device *dev) phy_shutdown(priv->phydev); }
-static int dw_eth_init(struct eth_device *dev, bd_t *bis) +static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr) { - struct dw_eth_dev *priv = dev->priv; struct eth_mac_regs *mac_p = priv->mac_regs_p; struct eth_dma_regs *dma_p = priv->dma_regs_p; unsigned int start; + int ret;
writel(readl(&dma_p->busmode) | DMAMAC_SRST, &dma_p->busmode);
@@ -238,7 +234,7 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis) while (readl(&dma_p->busmode) & DMAMAC_SRST) { if (get_timer(start) >= CONFIG_MACRESET_TIMEOUT) { printf("DMA reset timeout\n"); - return -1; + return -ETIMEDOUT; }
mdelay(100); @@ -246,10 +242,10 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
/* Soft reset above clears HW address registers. * So we have to set it here once again */ - dw_write_hwaddr(dev); + _dw_write_hwaddr(priv, enetaddr);
- rx_descs_init(dev); - tx_descs_init(dev); + rx_descs_init(priv); + tx_descs_init(priv);
writel(FIXEDBURST | PRIORXTX_41 | DMA_PBL, &dma_p->busmode);
@@ -268,25 +264,25 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis) #endif
/* Start up the PHY */ - if (phy_startup(priv->phydev)) { + ret = phy_startup(priv->phydev); + if (ret) { printf("Could not initialize PHY %s\n", priv->phydev->dev->name); - return -1; + return ret; }
dw_adjust_link(mac_p, priv->phydev);
if (!priv->phydev->link) - return -1; + return -EIO;
writel(readl(&mac_p->conf) | RXENABLE | TXENABLE, &mac_p->conf);
return 0; }
-static int dw_eth_send(struct eth_device *dev, void *packet, int length) +static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length) { - struct dw_eth_dev *priv = dev->priv; struct eth_dma_regs *dma_p = priv->dma_regs_p; u32 desc_num = priv->tx_currdescnum; struct dmamacdescr *desc_p = &priv->tx_mac_descrtable[desc_num]; @@ -309,7 +305,7 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length) /* Check if the descriptor is owned by CPU */ if (desc_p->txrx_status & DESC_TXSTS_OWNBYDMA) { printf("CPU not owner of tx frame\n"); - return -1; + return -EPERM; }
memcpy(desc_p->dmamac_addr, packet, length); @@ -347,9 +343,8 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length) return 0; }
-static int dw_eth_recv(struct eth_device *dev) +static int _dw_eth_recv(struct dw_eth_dev *priv) { - struct dw_eth_dev *priv = dev->priv; u32 status, desc_num = priv->rx_currdescnum; struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num]; int length = 0; @@ -395,9 +390,8 @@ static int dw_eth_recv(struct eth_device *dev) return length; }
-static int dw_phy_init(struct eth_device *dev) +static int dw_phy_init(struct dw_eth_dev *priv, void *dev) { - struct dw_eth_dev *priv = dev->priv; struct phy_device *phydev; int mask = 0xffffffff;
@@ -407,7 +401,7 @@ static int dw_phy_init(struct eth_device *dev)
phydev = phy_find_by_mask(priv->bus, mask, priv->interface); if (!phydev) - return -1; + return -ENODEV;
phy_connect_dev(phydev, dev);
@@ -417,7 +411,32 @@ static int dw_phy_init(struct eth_device *dev) priv->phydev = phydev; phy_config(phydev);
- return 1; + return 0; +} + +static int dw_eth_init(struct eth_device *dev, bd_t *bis) +{ + return _dw_eth_init(dev->priv, dev->enetaddr); +} + +static int dw_eth_send(struct eth_device *dev, void *packet, int length) +{ + return _dw_eth_send(dev->priv, packet, length); +} + +static int dw_eth_recv(struct eth_device *dev) +{ + return _dw_eth_recv(dev->priv); +} + +static void dw_eth_halt(struct eth_device *dev) +{ + return _dw_eth_halt(dev->priv); +} + +static int dw_write_hwaddr(struct eth_device *dev) +{ + return _dw_write_hwaddr(dev->priv, dev->enetaddr); }
int designware_initialize(ulong base_addr, u32 interface) @@ -465,5 +484,5 @@ int designware_initialize(ulong base_addr, u32 interface) dw_mdio_init(dev->name, priv->mac_regs_p); priv->bus = miiphy_get_dev_by_name(dev->name);
- return dw_phy_init(dev); + return dw_phy_init(priv, dev); }

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
Adjust the error handling to use errno.h instead of returning -1. Change leaf functions to pass in the arguments they require rather than struct eth_device. Apart from simplifying the code it makes is easier to reuse these functions for driver model, since mostly they actually only use struct dw_eth_priv (which we can keep).
Create a stub for each Ethernet operation function. This will allow use to share code with the driver model versions.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com
Changes in v2: None
drivers/net/designware.c | 87 +++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 34 deletions(-)
Applied to u-boot-dm/next.

Add driver model support to the designware driver. This reuses most of the existing code except for some duplication in the probe() method.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Use the new recv() method and the free_pkt() method
drivers/net/designware.c | 167 ++++++++++++++++++++++++++++++++++++++++++----- drivers/net/designware.h | 3 +- 2 files changed, 153 insertions(+), 17 deletions(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 5b36d4f..a4fe7a4 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -10,6 +10,7 @@ */
#include <common.h> +#include <dm.h> #include <errno.h> #include <miiphy.h> #include <malloc.h> @@ -18,6 +19,8 @@ #include <asm/io.h> #include "designware.h"
+DECLARE_GLOBAL_DATA_PTR; + #if !defined(CONFIG_PHYLIB) # error "DesignWare Ether MAC requires PHYLIB - missing CONFIG_PHYLIB" #endif @@ -343,11 +346,11 @@ static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length) return 0; }
-static int _dw_eth_recv(struct dw_eth_dev *priv) +static int _dw_eth_recv(struct dw_eth_dev *priv, uchar **packetp) { u32 status, desc_num = priv->rx_currdescnum; struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num]; - int length = 0; + int length = -EAGAIN; uint32_t desc_start = (uint32_t)desc_p; uint32_t desc_end = desc_start + roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN); @@ -368,26 +371,35 @@ static int _dw_eth_recv(struct dw_eth_dev *priv) /* Invalidate received data */ data_end = data_start + roundup(length, ARCH_DMA_MINALIGN); invalidate_dcache_range(data_start, data_end); + *packetp = desc_p->dmamac_addr; + }
- NetReceive(desc_p->dmamac_addr, length); + return length; +}
- /* - * Make the current descriptor valid again and go to - * the next one - */ - desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA; +static int _dw_free_pkt(struct dw_eth_dev *priv) +{ + u32 desc_num = priv->rx_currdescnum; + struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num]; + uint32_t desc_start = (uint32_t)desc_p; + uint32_t desc_end = desc_start + + roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
- /* Flush only status field - others weren't changed */ - flush_dcache_range(desc_start, desc_end); + /* + * Make the current descriptor valid again and go to + * the next one + */ + desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
- /* Test the wrap-around condition. */ - if (++desc_num >= CONFIG_RX_DESCR_NUM) - desc_num = 0; - } + /* Flush only status field - others weren't changed */ + flush_dcache_range(desc_start, desc_end);
+ /* Test the wrap-around condition. */ + if (++desc_num >= CONFIG_RX_DESCR_NUM) + desc_num = 0; priv->rx_currdescnum = desc_num;
- return length; + return 0; }
static int dw_phy_init(struct dw_eth_dev *priv, void *dev) @@ -414,6 +426,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev) return 0; }
+#ifndef CONFIG_DM_ETH static int dw_eth_init(struct eth_device *dev, bd_t *bis) { return _dw_eth_init(dev->priv, dev->enetaddr); @@ -426,7 +439,17 @@ static int dw_eth_send(struct eth_device *dev, void *packet, int length)
static int dw_eth_recv(struct eth_device *dev) { - return _dw_eth_recv(dev->priv); + uchar *packet; + int length; + + length = _dw_eth_recv(dev->priv, &packet); + if (length == -EAGAIN) + return 0; + NetReceive(packet, length); + + _dw_free_pkt(dev->priv); + + return 0; }
static void dw_eth_halt(struct eth_device *dev) @@ -486,3 +509,115 @@ int designware_initialize(ulong base_addr, u32 interface)
return dw_phy_init(priv, dev); } +#endif + +#ifdef CONFIG_DM_ETH +static int designware_eth_start(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + + return _dw_eth_init(dev->priv, pdata->enetaddr); +} + +static int designware_eth_send(struct udevice *dev, void *packet, int length) +{ + struct dw_eth_dev *priv = dev_get_priv(dev); + + return _dw_eth_send(priv, packet, length); +} + +static int designware_eth_recv(struct udevice *dev, uchar **packetp) +{ + struct dw_eth_dev *priv = dev_get_priv(dev); + + return _dw_eth_recv(priv, packetp); +} + +static int designware_eth_free_pkt(struct udevice *dev, uchar *packet, + int length) +{ + struct dw_eth_dev *priv = dev_get_priv(dev); + + return _dw_free_pkt(priv); +} + +static void designware_eth_stop(struct udevice *dev) +{ + struct dw_eth_dev *priv = dev_get_priv(dev); + + return _dw_eth_halt(priv); +} + +static int designware_eth_write_hwaddr(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + struct dw_eth_dev *priv = dev_get_priv(dev); + + return _dw_write_hwaddr(priv, pdata->enetaddr); +} + +static int designware_eth_probe(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + struct dw_eth_dev *priv = dev_get_priv(dev); + int ret; + + debug("%s, iobase=%lx, priv=%p\n", __func__, pdata->iobase, priv); + priv->mac_regs_p = (struct eth_mac_regs *)pdata->iobase; + priv->dma_regs_p = (struct eth_dma_regs *)(pdata->iobase + + DW_DMA_BASE_OFFSET); + priv->interface = pdata->phy_interface; + + dw_mdio_init(dev->name, priv->mac_regs_p); + priv->bus = miiphy_get_dev_by_name(dev->name); + + ret = dw_phy_init(priv, dev); + debug("%s, ret=%d\n", __func__, ret); + + return ret; +} + +static const struct eth_ops designware_eth_ops = { + .start = designware_eth_start, + .send = designware_eth_send, + .recv = designware_eth_recv, + .free_pkt = designware_eth_free_pkt, + .stop = designware_eth_stop, + .write_hwaddr = designware_eth_write_hwaddr, +}; + +static int designware_eth_ofdata_to_platdata(struct udevice *dev) +{ + struct eth_pdata *pdata = dev_get_platdata(dev); + const char *phy_mode; + + pdata->iobase = dev_get_addr(dev); + pdata->phy_interface = -1; + phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode", NULL); + if (phy_mode) + pdata->phy_interface = phy_get_interface_by_name(phy_mode); + if (pdata->phy_interface == -1) { + debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode); + return -EINVAL; + } + + return 0; +} + +static const struct udevice_id designware_eth_ids[] = { + { .compatible = "allwinner,sun7i-a20-gmac" }, + { } +}; + +U_BOOT_DRIVER(eth_sandbox) = { + .name = "eth_designware", + .id = UCLASS_ETH, + .of_match = designware_eth_ids, + .ofdata_to_platdata = designware_eth_ofdata_to_platdata, + .probe = designware_eth_probe, + .ops = &designware_eth_ops, + .priv_auto_alloc_size = sizeof(struct dw_eth_dev), + .platdata_auto_alloc_size = sizeof(struct eth_pdata), + .flags = DM_FLAG_ALLOC_PRIV_DMA, +}; +#endif diff --git a/drivers/net/designware.h b/drivers/net/designware.h index 49d900c..4b9ec39 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -228,8 +228,9 @@ struct dw_eth_dev {
struct eth_mac_regs *mac_regs_p; struct eth_dma_regs *dma_regs_p; - +#ifndef CONFIG_DM_ETH struct eth_device *dev; +#endif struct phy_device *phydev; struct mii_dev *bus; };

Hi Simon,
On Sun, Apr 5, 2015 at 5:07 PM, Simon Glass sjg@chromium.org wrote:
Add driver model support to the designware driver. This reuses most of the existing code except for some duplication in the probe() method.
Signed-off-by: Simon Glass sjg@chromium.org
Acked-by: Joe Hershberger joe.hershberger@ni.com
Changes in v2:
- Use the new recv() method and the free_pkt() method
drivers/net/designware.c | 167
++++++++++++++++++++++++++++++++++++++++++-----
drivers/net/designware.h | 3 +- 2 files changed, 153 insertions(+), 17 deletions(-)
diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 5b36d4f..a4fe7a4 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -10,6 +10,7 @@ */
#include <common.h> +#include <dm.h> #include <errno.h> #include <miiphy.h> #include <malloc.h> @@ -18,6 +19,8 @@ #include <asm/io.h> #include "designware.h"
+DECLARE_GLOBAL_DATA_PTR;
#if !defined(CONFIG_PHYLIB) # error "DesignWare Ether MAC requires PHYLIB - missing CONFIG_PHYLIB" #endif @@ -343,11 +346,11 @@ static int _dw_eth_send(struct dw_eth_dev *priv,
void *packet, int length)
return 0;
}
-static int _dw_eth_recv(struct dw_eth_dev *priv) +static int _dw_eth_recv(struct dw_eth_dev *priv, uchar **packetp) { u32 status, desc_num = priv->rx_currdescnum; struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
int length = 0;
int length = -EAGAIN; uint32_t desc_start = (uint32_t)desc_p; uint32_t desc_end = desc_start + roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
@@ -368,26 +371,35 @@ static int _dw_eth_recv(struct dw_eth_dev *priv) /* Invalidate received data */ data_end = data_start + roundup(length,
ARCH_DMA_MINALIGN);
invalidate_dcache_range(data_start, data_end);
*packetp = desc_p->dmamac_addr;
}
NetReceive(desc_p->dmamac_addr, length);
This line will conflict when http://patchwork.ozlabs.org/patch/458099/ is applied.
return length;
+}
/*
* Make the current descriptor valid again and go to
* the next one
*/
desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
+static int _dw_free_pkt(struct dw_eth_dev *priv) +{
u32 desc_num = priv->rx_currdescnum;
struct dmamacdescr *desc_p = &priv->rx_mac_descrtable[desc_num];
uint32_t desc_start = (uint32_t)desc_p;
uint32_t desc_end = desc_start +
roundup(sizeof(*desc_p), ARCH_DMA_MINALIGN);
/* Flush only status field - others weren't changed */
flush_dcache_range(desc_start, desc_end);
/*
* Make the current descriptor valid again and go to
* the next one
*/
desc_p->txrx_status |= DESC_RXSTS_OWNBYDMA;
/* Test the wrap-around condition. */
if (++desc_num >= CONFIG_RX_DESCR_NUM)
desc_num = 0;
}
/* Flush only status field - others weren't changed */
flush_dcache_range(desc_start, desc_end);
/* Test the wrap-around condition. */
if (++desc_num >= CONFIG_RX_DESCR_NUM)
desc_num = 0; priv->rx_currdescnum = desc_num;
return length;
return 0;
}
static int dw_phy_init(struct dw_eth_dev *priv, void *dev) @@ -414,6 +426,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void
*dev)
return 0;
}
+#ifndef CONFIG_DM_ETH static int dw_eth_init(struct eth_device *dev, bd_t *bis) { return _dw_eth_init(dev->priv, dev->enetaddr); @@ -426,7 +439,17 @@ static int dw_eth_send(struct eth_device *dev, void
*packet, int length)
static int dw_eth_recv(struct eth_device *dev) {
return _dw_eth_recv(dev->priv);
uchar *packet;
int length;
length = _dw_eth_recv(dev->priv, &packet);
if (length == -EAGAIN)
return 0;
NetReceive(packet, length);
This line will need to be updated in http://patchwork.ozlabs.org/patch/458099/
_dw_free_pkt(dev->priv);
return 0;
}
static void dw_eth_halt(struct eth_device *dev) @@ -486,3 +509,115 @@ int designware_initialize(ulong base_addr, u32
interface)
return dw_phy_init(priv, dev);
} +#endif
+#ifdef CONFIG_DM_ETH +static int designware_eth_start(struct udevice *dev) +{
struct eth_pdata *pdata = dev_get_platdata(dev);
return _dw_eth_init(dev->priv, pdata->enetaddr);
+}
+static int designware_eth_send(struct udevice *dev, void *packet, int
length)
+{
struct dw_eth_dev *priv = dev_get_priv(dev);
return _dw_eth_send(priv, packet, length);
+}
+static int designware_eth_recv(struct udevice *dev, uchar **packetp) +{
struct dw_eth_dev *priv = dev_get_priv(dev);
return _dw_eth_recv(priv, packetp);
+}
+static int designware_eth_free_pkt(struct udevice *dev, uchar *packet,
int length)
+{
struct dw_eth_dev *priv = dev_get_priv(dev);
return _dw_free_pkt(priv);
+}
+static void designware_eth_stop(struct udevice *dev) +{
struct dw_eth_dev *priv = dev_get_priv(dev);
return _dw_eth_halt(priv);
+}
+static int designware_eth_write_hwaddr(struct udevice *dev) +{
struct eth_pdata *pdata = dev_get_platdata(dev);
struct dw_eth_dev *priv = dev_get_priv(dev);
return _dw_write_hwaddr(priv, pdata->enetaddr);
+}
+static int designware_eth_probe(struct udevice *dev) +{
struct eth_pdata *pdata = dev_get_platdata(dev);
struct dw_eth_dev *priv = dev_get_priv(dev);
int ret;
debug("%s, iobase=%lx, priv=%p\n", __func__, pdata->iobase, priv);
priv->mac_regs_p = (struct eth_mac_regs *)pdata->iobase;
priv->dma_regs_p = (struct eth_dma_regs *)(pdata->iobase +
DW_DMA_BASE_OFFSET);
priv->interface = pdata->phy_interface;
dw_mdio_init(dev->name, priv->mac_regs_p);
priv->bus = miiphy_get_dev_by_name(dev->name);
ret = dw_phy_init(priv, dev);
debug("%s, ret=%d\n", __func__, ret);
return ret;
+}
+static const struct eth_ops designware_eth_ops = {
.start = designware_eth_start,
.send = designware_eth_send,
.recv = designware_eth_recv,
.free_pkt = designware_eth_free_pkt,
.stop = designware_eth_stop,
.write_hwaddr = designware_eth_write_hwaddr,
+};
+static int designware_eth_ofdata_to_platdata(struct udevice *dev) +{
struct eth_pdata *pdata = dev_get_platdata(dev);
const char *phy_mode;
pdata->iobase = dev_get_addr(dev);
pdata->phy_interface = -1;
phy_mode = fdt_getprop(gd->fdt_blob, dev->of_offset, "phy-mode",
NULL);
if (phy_mode)
pdata->phy_interface =
phy_get_interface_by_name(phy_mode);
if (pdata->phy_interface == -1) {
debug("%s: Invalid PHY interface '%s'\n", __func__,
phy_mode);
return -EINVAL;
}
return 0;
+}
+static const struct udevice_id designware_eth_ids[] = {
{ .compatible = "allwinner,sun7i-a20-gmac" },
{ }
+};
+U_BOOT_DRIVER(eth_sandbox) = {
.name = "eth_designware",
.id = UCLASS_ETH,
.of_match = designware_eth_ids,
.ofdata_to_platdata = designware_eth_ofdata_to_platdata,
.probe = designware_eth_probe,
.ops = &designware_eth_ops,
.priv_auto_alloc_size = sizeof(struct dw_eth_dev),
.platdata_auto_alloc_size = sizeof(struct eth_pdata),
.flags = DM_FLAG_ALLOC_PRIV_DMA,
+}; +#endif diff --git a/drivers/net/designware.h b/drivers/net/designware.h index 49d900c..4b9ec39 100644 --- a/drivers/net/designware.h +++ b/drivers/net/designware.h @@ -228,8 +228,9 @@ struct dw_eth_dev {
struct eth_mac_regs *mac_regs_p; struct eth_dma_regs *dma_regs_p;
+#ifndef CONFIG_DM_ETH struct eth_device *dev; +#endif struct phy_device *phydev; struct mii_dev *bus; }; -- 2.2.0.rc0.207.ga3a616c

On 6 April 2015 at 15:09, Joe Hershberger joe.hershberger@gmail.com wrote:
Hi Simon,
On Sun, Apr 5, 2015 at 5:07 PM, Simon Glass sjg@chromium.org wrote:
Add driver model support to the designware driver. This reuses most of the existing code except for some duplication in the probe() method.
Signed-off-by: Simon Glass sjg@chromium.org
Acked-by: Joe Hershberger joe.hershberger@ni.com
Changes in v2:
- Use the new recv() method and the free_pkt() method
drivers/net/designware.c | 167 ++++++++++++++++++++++++++++++++++++++++++----- drivers/net/designware.h | 3 +- 2 files changed, 153 insertions(+), 17 deletions(-)
Applied to u-boot-dm/next.

Adjust the Ethernet initialisation code to support driver model. It is no-longer necessary to call designware_initialize(). The device will be probed when it is used. The PHY type and GMAC base will come from the device tree.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Remove unwanted printf()
board/sunxi/gmac.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/board/sunxi/gmac.c b/board/sunxi/gmac.c index 8849132..1540633 100644 --- a/board/sunxi/gmac.c +++ b/board/sunxi/gmac.c @@ -80,11 +80,15 @@ int sunxi_gmac_initialize(bd_t *bis) sunxi_gpio_set_cfgpin(pin, SUN6I_GPA0_GMAC); #endif
-#ifdef CONFIG_RGMII +#ifdef CONFIG_DM_ETH + return 0; +#else +# ifdef CONFIG_RGMII return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_RGMII); -#elif defined CONFIG_GMII +# elif defined CONFIG_GMII return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_GMII); -#else +# else return designware_initialize(SUNXI_GMAC_BASE, PHY_INTERFACE_MODE_MII); +# endif #endif }

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
Adjust the Ethernet initialisation code to support driver model. It is no-longer necessary to call designware_initialize(). The device will be probed when it is used. The PHY type and GMAC base will come from the device tree.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Remove unwanted printf()
board/sunxi/gmac.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next.

Switch this board over to use driver model for Ethernet.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Drop bugfix patches that were incorporated in the Ethernet dm conversion - Drop the CONFIG_BOOTP_VCI_STRING patch
configs/Linksprite_pcDuino3_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/Linksprite_pcDuino3_defconfig b/configs/Linksprite_pcDuino3_defconfig index 8c76a736..e5aabdb 100644 --- a/configs/Linksprite_pcDuino3_defconfig +++ b/configs/Linksprite_pcDuino3_defconfig @@ -17,3 +17,4 @@ CONFIG_OF_SEPARATE=y CONFIG_ETH_DESIGNWARE=y CONFIG_NETDEVICES=y CONFIG_NET=y +CONFIG_DM_ETH=y

On 5 April 2015 at 16:07, Simon Glass sjg@chromium.org wrote:
Switch this board over to use driver model for Ethernet.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Drop bugfix patches that were incorporated in the Ethernet dm conversion
- Drop the CONFIG_BOOTP_VCI_STRING patch
configs/Linksprite_pcDuino3_defconfig | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm/next.
participants (2)
-
Joe Hershberger
-
Simon Glass