Skip to contentSkip to conversation

dm: net: Conversion patches for sunxi driver model Ethernet

PATCH New Simon Glass 2 participants 23 messages Apr 5, 2015 – Apr 9, 2015

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

v2 cover 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
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#1 lore raw

PATCH v2 1/11 sunxi: Replace the pcDuino3 config with FDT version

We currently have Linksprite_pcDuino3 and Linksprite_pcDuino3_fdt. Drop the former in favour of the latter.

---

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
configs/Linksprite_pcDuino3_defconfig +7 -0
index e642069..ff817d5 100644
@@ -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
configs/Linksprite_pcDuino3_fdt_defconfig deleted +0 -15
deleted file mode 100644
index 7690d1e..0000000
@@ -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
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#2 lore raw

PATCH v2 1/11 sunxi: Replace the pcDuino3 config with FDT version

Quoted 8 lines · Simon Glass

We currently have Linksprite_pcDuino3 and Linksprite_pcDuino3_fdt. Drop the former in favour of the latter.

---

Quoted 7 lines

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.

#3 lore raw

PATCH v2 2/11 Kconfig: Move CONFIG_DESIGNWARE_ETH to Kconfig

In reply to Simon Glass

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.

Version 1:

---

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(-)
arch/arm/cpu/arm926ejs/spear/cpu.c +1 -1
index 697e094..1ce9db7 100644
@@ -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)
arch/arm/cpu/armv7/socfpga/misc.c +1 -1
index 7873c38..0f8b4d0 100644
@@ -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
board/bf609-ezkit/bf609-ezkit.c +1 -1
index 43a4330..86da028 100644
@@ -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;
board/spear/spear300/spear300.c +1 -1
index 6b6bd9f..396b5bd 100644
@@ -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++;
board/spear/spear310/spear310.c +1 -1
index a4c6a8e..6f39ef1 100644
@@ -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++;
board/spear/spear320/spear320.c +1 -1
index ab732a7..52196af 100644
@@ -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++;
board/spear/spear600/spear600.c +1 -1
index 8472002..fc0918f 100644
@@ -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;
board/st/stv0991/stv0991.c +1 -1
index f465699..38f6e1d 100644
@@ -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++;
configs/A20-OLinuXino-Lime2_defconfig +3 -0
index 8c76360..cbfc8a3 100644
@@ -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
configs/A20-OLinuXino-Lime_defconfig +3 -0
index 8d71d5f..7868d6e 100644
@@ -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
configs/A20-OLinuXino_MICRO_defconfig +3 -0
index 377bd46..11fb760 100644
@@ -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
configs/Bananapi_defconfig +3 -0
index bad6081..36a8671 100644
@@ -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
configs/Bananapro_defconfig +3 -0
index 2274c80..236a992 100644
@@ -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
configs/CSQ_CS908_defconfig +3 -0
index ec84acb..776636e 100644
@@ -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
configs/Colombus_defconfig +3 -0
index d6aad5e..810c88f 100644
@@ -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
configs/Cubieboard2_defconfig +3 -0
index 05b11a0..9a253b5 100644
@@ -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
configs/Cubietruck_defconfig +3 -0
index fa48331..b8418f7 100644
@@ -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
configs/Hummingbird_A31_defconfig +3 -0
index 7fd5a2a..8a11e09 100644
@@ -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
configs/Linksprite_pcDuino3_Nano_defconfig +3 -0
index 15a883a..9d171bd 100644
@@ -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
configs/Linksprite_pcDuino3_defconfig +3 -0
index ff817d5..8c76a736 100644
@@ -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
configs/Mele_I7_defconfig +3 -0
index 0e9a950..e91d507 100644
@@ -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
configs/Mele_M3_defconfig +3 -0
index a28e0a0..a74dd2d 100644
@@ -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
configs/Mele_M5_defconfig +3 -0
index 1442318..d0f0425 100644
@@ -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
configs/Mele_M9_defconfig +3 -0
index f9d4ccc..592322d 100644
@@ -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
configs/Orangepi_defconfig +3 -0
index 28fadcd..2c57eec 100644
@@ -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
configs/Orangepi_mini_defconfig +3 -0
index 330679b..28edf88 100644
@@ -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
configs/Wits_Pro_A20_DKT_defconfig +3 -0
index 9147ead..92c33b3 100644
@@ -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
configs/axs101_defconfig +4 -1
index 34ed963..9ef04df 100644
@@ -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
configs/axs103_defconfig +3 -0
index c63dd4a..3f7b21f 100644
@@ -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
configs/bf609-ezkit_defconfig +3 -0
index 2bfb6a5..96f746e 100644
@@ -1,2 +1,5 @@
 CONFIG_BLACKFIN=y
 CONFIG_TARGET_BF609_EZKIT=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_NETDEVICES=y
+CONFIG_NET=y
configs/galileo_defconfig +3 -0
index f208651..9b0f969 100644
@@ -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
configs/i12-tvbox_defconfig +3 -0
index 157997f..b10f4d0 100644
@@ -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
configs/socfpga_cyclone5_defconfig +3 -0
index 0ebfbfc..6dd04bc 100644
@@ -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
configs/socfpga_socrates_defconfig +3 -0
index 873b721..db9093e 100644
@@ -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
configs/spear300_defconfig +3 -0
index 25a08df..df0b190 100644
@@ -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
configs/spear300_nand_defconfig +3 -0
index a4b70e8..a49492c 100644
@@ -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
configs/spear300_usbtty_defconfig +3 -0
index d750cf4..3d60d7f 100644
@@ -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
configs/spear300_usbtty_nand_defconfig +3 -0
index 8bafdb5..ffe4f59 100644
@@ -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
configs/spear310_defconfig +3 -0
index 8a9ec85..16a6bc3 100644
@@ -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
configs/spear310_nand_defconfig +3 -0
index 1439ac5..05e3c96 100644
@@ -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
configs/spear310_pnor_defconfig +3 -0
index 19604b3..384cb54 100644
@@ -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
configs/spear310_usbtty_defconfig +3 -0
index 6342a56..0115f2c 100644
@@ -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
configs/spear310_usbtty_nand_defconfig +3 -0
index 5b9f1f6..2d82b66 100644
@@ -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
configs/spear310_usbtty_pnor_defconfig +3 -0
index 0567936..579df36 100644
@@ -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
configs/spear320_defconfig +3 -0
index 3d91bb1..7bd51a8 100644
@@ -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
configs/spear320_nand_defconfig +3 -0
index fd0f908..d7c995c 100644
@@ -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
configs/spear320_pnor_defconfig +3 -0
index 6cce316..a56a4e0 100644
@@ -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
configs/spear320_usbtty_defconfig +3 -0
index 7ad3d84..c2fb481 100644
@@ -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
configs/spear320_usbtty_nand_defconfig +3 -0
index a5ad90b..98368ed 100644
@@ -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
configs/spear320_usbtty_pnor_defconfig +3 -0
index 6b110ef..e428d25 100644
@@ -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
configs/spear600_defconfig +3 -0
index f1cb0aa..dae0d59 100644
@@ -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
configs/spear600_nand_defconfig +3 -0
index 172c187..cdd98fc 100644
@@ -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
configs/spear600_usbtty_defconfig +3 -0
index cf8b0ec..1e28edf 100644
@@ -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
configs/spear600_usbtty_nand_defconfig +3 -0
index 8bd2f07..2f8fd5e 100644
@@ -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
configs/stv0991_defconfig +3 -0
index e8cf311..838d191 100644
@@ -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
configs/tb100_defconfig +3 -0
index b0e8c9f..a6351fa 100644
@@ -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
configs/x600_defconfig +3 -0
index c8bec67..7cd239b 100644
@@ -1,3 +1,6 @@
 CONFIG_SPL=y
 CONFIG_ARM=y
 CONFIG_TARGET_X600=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_NETDEVICES=y
+CONFIG_NET=y
drivers/net/Kconfig +7 -0
index 5bd66ea..973258a 100644
@@ -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
drivers/net/Makefile +1 -1
index 3fc3c30..217ae75 100644
@@ -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
include/configs/axs101.h +0 -1
index 5fb8aca..ed63048 100644
@@ -110,7 +110,6 @@
 /*
  * Ethernet configuration
  */
-#define CONFIG_DESIGNWARE_ETH
 #define CONFIG_DW_AUTONEG
 #define CONFIG_NET_MULTI
 
include/configs/bf609-ezkit.h +0 -1
index 878009f..7507d57 100644
@@ -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
include/configs/socfpga_common.h +0 -1
index 6d93472..1ecd56f 100644
@@ -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
include/configs/spear-common.h +0 -1
index 16281f5..409cf54 100644
@@ -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 */
include/configs/stv0991.h +0 -1
index 156e0fa..ab1e61c 100644
@@ -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
 
include/configs/sunxi-common.h +0 -1
index 1f7a1cb..b542da7 100644
@@ -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
include/configs/tb100.h +0 -1
index 46df406..bc69f1d 100644
@@ -66,7 +66,6 @@
 /*
  * Ethernet configuration
  */
-#define CONFIG_DESIGNWARE_ETH
 #define ETH0_BASE_ADDRESS		0xFE100000
 #define ETH1_BASE_ADDRESS		0xFE110000
 
include/configs/x600.h +0 -1
index 241bf65..27a66a5 100644
@@ -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 */
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#4 lore raw

PATCH v2 2/11 Kconfig: Move CONFIG_DESIGNWARE_ETH to Kconfig

Quoted 6 lines · Simon Glass

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.

Version 1:

Quoted 8 lines

---

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.

#5 lore raw

PATCH v2 3/11 dts: sunxi: Bring in Ethernet device tree bindings

In reply to Simon Glass

Since we will use these bindings on sunxi, bring them in from Linux 4.0-rc1.

---

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
doc/device-tree-bindings/net/allwinner,sun4i-emac.txt new file +19 -0
new file mode 100644
index 0000000..10640b1
@@ -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 at 01c0b000 {
+       compatible = "allwinner,sun4i-a10-emac";
+       reg = <0x01c0b000 0x1000>;
+       interrupts = <55>;
+       clocks = <&ahb_gates 17>;
+       phy = <&phy0>;
+};
doc/device-tree-bindings/net/allwinner,sun4i-mdio.txt new file +27 -0
new file mode 100644
index 0000000..4ec5641
@@ -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 at 01c0b080 {
+	compatible = "allwinner,sun4i-a10-mdio";
+	reg = <0x01c0b080 0x14>;
+	#address-cells = <1>;
+	#size-cells = <0>;
+};
+
+And at the board level:
+
+mdio at 01c0b080 {
+	phy-supply = <&reg_emac_3v3>;
+
+	phy0: ethernet-phy at 0 {
+		reg = <0>;
+	};
+};
doc/device-tree-bindings/net/allwinner,sun7i-a20-gmac.txt new file +27 -0
new file mode 100644
index 0000000..ea4d752
@@ -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 at 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";
+	};
doc/device-tree-bindings/net/ethernet.txt new file +25 -0
new file mode 100644
index 0000000..3fc3605
@@ -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.
doc/device-tree-bindings/net/stmmac.txt new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#6 lore raw

PATCH v2 3/11 dts: sunxi: Bring in Ethernet device tree bindings

Quoted 9 lines · Simon Glass

Since we will use these bindings on sunxi, bring them in from Linux 4.0-rc1.

---

Changes in v2: None

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

#7 lore raw

PATCH v2 4/11 dm: core: Support allocating driver-private data for DMA

In reply to Simon Glass

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.

---
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(-)
drivers/core/device.c +10 -1
index 7483405..872b703 100644
@@ -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;
include/dm/device.h +3 -0
index 6980954..f27b34b 100644
@@ -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
  *
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#8 lore raw

PATCH v2 5/11 dm: net: Use existing Ethernet init for driver model

In reply to Simon Glass

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.

---

Changes in v2: None

 net/eth.c | 78 ++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 42 insertions(+), 36 deletions(-)
net/eth.c +42 -36
index 889ad8f..ede9367 100644
@@ -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");
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#9 lore raw

PATCH v2 5/11 dm: net: Use existing Ethernet init for driver model

Quoted 8 lines · Simon Glass

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.

Quoted 8 lines

---

Changes in v2: None

 net/eth.c | 78 ++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 42 insertions(+), 36 deletions(-)

Applied to u-boot-dm/next.

#10 lore raw

PATCH v2 6/11 Avoid calling print_eths() with driver model

In reply to Simon Glass

This function is not supported with driver model.

---
Note from Joe Hershberger <[email protected]>

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(-)
common/cmd_bdinfo.c +1 -1
index b4cce25..f16d5c7 100644
@@ -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);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#11 lore raw

PATCH v2 6/11 Avoid calling print_eths() with driver model

Quoted 13 lines · Simon Glass

This function is not supported with driver model.

---
Note from Joe Hershberger <[email protected]>

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.

Quoted 4 lines

Changes in v2: None

 common/cmd_bdinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm/next.

#12 lore raw

PATCH v2 7/11 dm: net: Adjust PHY interface to work with CONFIG_DM_ETH

In reply to Simon Glass

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.

---

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(-)
common/miiphyutil.c +1 -0
index 74812e6..c88c28a 100644
@@ -11,6 +11,7 @@
  */
 
 #include <common.h>
+#include <dm.h>
 #include <miiphy.h>
 #include <phy.h>
 
drivers/net/phy/phy.c +22 -0
index df7e945..9d88afe 100644
@@ -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;
+}
include/net.h +2 -0
index f9df532..2b4f9f3 100644
@@ -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;
 };
 
 /**
include/phy.h +22 -1
index d117fc1..384dc23 100644
@@ -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
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#13 lore raw

PATCH v2 7/11 dm: net: Adjust PHY interface to work with CONFIG_DM_ETH

Quoted 11 lines · Simon Glass

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.

---

Quoted 7 lines

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.

#14 lore raw

PATCH v2 8/11 dm: net: Tidy up designware driver ready for driver model

In reply to Simon Glass

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.

---

Changes in v2: None

 drivers/net/designware.c | 87 +++++++++++++++++++++++++++++-------------------
 1 file changed, 53 insertions(+), 34 deletions(-)
drivers/net/designware.c +53 -34
index cc01604..5b36d4f 100644
@@ -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);
 }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#15 lore raw

PATCH v2 8/11 dm: net: Tidy up designware driver ready for driver model

Quoted 9 lines · Simon Glass

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.

Quoted 8 lines

---

Changes in v2: None

 drivers/net/designware.c | 87 +++++++++++++++++++++++++++++-------------------
 1 file changed, 53 insertions(+), 34 deletions(-)

Applied to u-boot-dm/next.

#16 lore raw

PATCH v2 9/11 dm: net: Adjust designware driver to support driver model

In reply to Simon Glass

Add driver model support to the designware driver. This reuses most of the existing code except for some duplication in the probe() method.

---

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(-)
drivers/net/designware.c +151 -16
index 5b36d4f..a4fe7a4 100644
@@ -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
drivers/net/designware.h +2 -1
index 49d900c..4b9ec39 100644
@@ -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;
 };
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#17 lore raw

PATCH v2 9/11 dm: net: Adjust designware driver to support driver model

Hi Simon,

Quoted 6 lines · Simon Glass

Add driver model support to the designware driver. This reuses most of the existing code except for some duplication in the probe() method.

---

Quoted 4 lines

Changes in v2:
- Use the new recv() method and the free_pkt() method

 drivers/net/designware.c | 167

++++++++++++++++++++++++++++++++++++++++++-----

drivers/net/designware.c static int _dw_eth_send(struct dw_eth_dev *priv,

Quoted 25 lines
 drivers/net/designware.h |   3 +-
 2 files changed, 153 insertions(+), 17 deletions(-)
drivers/net/designware.c +3 -0
index 5b36d4f..a4fe7a4 100644
@@ -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)

Quoted 14 lines
drivers/net/designware.c +2 -2
        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);

drivers/net/designware.c static int _dw_eth_recv(struct dw_eth_dev *priv) · line 372

Quoted 2 lines
drivers/net/designware.c +0 -0
@@ -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);

drivers/net/designware.c static int _dw_eth_recv(struct dw_eth_dev *priv) · line 372

Quoted 5 lines
drivers/net/designware.c +2 -1
                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.

drivers/net/designware.c static int dw_phy_init(struct dw_eth_dev *priv, void

Quoted 42 lines
drivers/net/designware.c +20 -12
+       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)

drivers/net/designware.c static int dw_eth_send(struct eth_device *dev, void

Quoted 8 lines
drivers/net/designware.c +1 -0
        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)

drivers/net/designware.c static int dw_eth_send(struct eth_device *dev, void *packet, int length) · line 448

Quoted 11 lines
drivers/net/designware.c +7 -1
 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/

drivers/net/designware.c int designware_initialize(ulong base_addr, u32

Quoted 8 lines
drivers/net/designware.c +4 -0
+
+       _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)

Quoted 4 lines
drivers/net/designware.c +1 -0
        return dw_phy_init(priv, dev);
 }
+#endif

drivers/net/designware.c int designware_initialize(ulong base_addr, u32 interface)

Quoted 10 lines
drivers/net/designware.c +10 -0
+
+#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)

Quoted 64 lines
drivers/net/designware.c +64 -0
+{
+       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,

drivers/net/designware.c int designware_initialize(ulong base_addr, u32 interface)

Quoted 10 lines
drivers/net/designware.c +10 -0
+};
+
+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);

drivers/net/designware.c int designware_initialize(ulong base_addr, u32 · line 597

Quoted 2 lines
drivers/net/designware.c +2 -0
+       if (phy_mode)
+               pdata->phy_interface =

phy_get_interface_by_name(phy_mode);

drivers/net/designware.c int designware_initialize(ulong base_addr, u32 · line 599

Quoted 2 lines
drivers/net/designware.c +2 -0
+       if (pdata->phy_interface == -1) {
+               debug("%s: Invalid PHY interface '%s'\n", __func__,

phy_mode);

Quoted 41 lines
drivers/net/designware.c +23 -0
+               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
drivers/net/designware.h +2 -2
index 49d900c..4b9ec39 100644
@@ -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

#18 lore raw

PATCH v2 9/11 dm: net: Adjust designware driver to support driver model

Quoted 4 lines · Joe Hershberger

Hi Simon,

Quoted 1 line · Simon Glass
Quoted 15 lines
Quoted 5 lines

Add driver model support to the designware driver. This reuses most of the existing code except for some duplication in the probe() method.

---

Quoted 7 lines

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.

#19 lore raw

PATCH v2 10/11 dm: sunxi: Support driver model for Ethernet

In reply to Simon Glass

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.

---

Changes in v2:
- Remove unwanted printf()

 board/sunxi/gmac.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
board/sunxi/gmac.c +7 -3
index 8849132..1540633 100644
@@ -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
 }
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#20 lore raw

PATCH v2 10/11 dm: sunxi: Support driver model for Ethernet

Quoted 5 lines · Simon Glass

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.

Quoted 8 lines

---

Changes in v2:
- Remove unwanted printf()

 board/sunxi/gmac.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Applied to u-boot-dm/next.

#21 lore raw

PATCH v2 11/11 dm: sunxi: Use driver model for Ethernet on Linksprite pcDuino3

In reply to Simon Glass

Switch this board over to use driver model for Ethernet.

---

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(+)
configs/Linksprite_pcDuino3_defconfig +1 -0
index 8c76a736..e5aabdb 100644
@@ -17,3 +17,4 @@ CONFIG_OF_SEPARATE=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_NETDEVICES=y
 CONFIG_NET=y
+CONFIG_DM_ETH=y
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#22 lore raw

PATCH v2 11/11 dm: sunxi: Use driver model for Ethernet on Linksprite pcDuino3

Quoted 11 lines · Simon Glass

Switch this board over to use driver model for Ethernet.

---

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.