Skip to contentSkip to conversation

From Simon:

PATCH Superseded Simon Glass 3 participants 23 messages Nov 27, 2016 – Dec 26, 2016

Subsystems (2)

v3 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v3 cover From Simon:

This v3 patch is an update on Sjoerd's original v2 series from Feburary. I have dealt with the changes requested at the time, and adjusted the way that the speed change is handled.

Tested on firefly-rk3288, rock2.

Original cover letter:
To add support I've taken a slightly different approach then some of the other boards with a designware IP block, by creating a new driver to take care of the platfrom glue which subclasses the main designware driver instead of adding the compatibility string the designware driver directly and doing the SoC specific setup in the board files. This seems quite a bit more elegant in a device model based world.

I've only tested this series on a Radxa Rock 2 board, it would be great if someone could test this on other boards with the designware IP especially for those with the reset GPIO in devicetree (e.g. some of the Allwinner boards).

Compared to the first one round the pinctrl related bits were dropped as RK3288 now has a full pinctrl driver. Furthermore the started hook in the designware driver was renamed to fix_mac_speed in line with what linux uses and moved to the dw_link_adjust function.

Changes in v3:
- Add a few new patches
- Add comments for struct gmac_rk3288_platdata
- Add new patch to adjust dw_adjust_link() to return an error
- Add new patch to enable networking on evb-rk3288
- Add new patch to export the operation functions
- Add new patch to split the link init into a separate function
- Adjust binding to use r/tx-delay instead of r/tx_delay
- Drop the 'net: designware: Add a fix_mac_speed hook' patch
- Sort includes
- Use debug() instead of printf() for error
- Use function calls instead of fix_mac_speed() hook
- Use new clk interface

Changes in v2:
- Adjust to new hook name
- Fix various coding style nits

Simon Glass (4):
net: designware: Adjust dw_adjust_link() to return an error
net: designware: Split the link init into a separate function
net: designware: Export the operation functions
rockchip: evb-rk3339: Enable DHCP

Sjoerd Simons (5):
net: designware: Export various functions/struct to allow subclassing
net: gmac_rk3288: Add RK3288 GMAC driver
rockchip: Enable networking support on rock2 and firefly
rockchip: Add PXE and DHCP to the default boot targets
rockchip: Drop Ethernet from the TODO

 configs/evb-rk3399_defconfig      |   3 +
 configs/firefly-rk3288_defconfig  |   4 +
 configs/rock2_defconfig           |   4 +
 doc/README.rockchip               |   1 -
 drivers/net/Kconfig               |   7 ++
 drivers/net/Makefile              |   1 +
 drivers/net/designware.c          |  57 ++++++++++----
 drivers/net/designware.h          |  13 ++++
 drivers/net/gmac_rk3288.c         | 154 ++++++++++++++++++++++++++++++++++++++
 include/configs/rockchip-common.h |   4 +-
 10 files changed, 230 insertions(+), 18 deletions(-)
 create mode 100644 drivers/net/gmac_rk3288.c
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v3 1/9 net: designware: Export various functions/struct to allow subclassing

From: Sjoerd Simons <[email protected]>

To allow other DM drivers to subclass the designware driver various functions and structures need to be exported. Export these.

---

Changes in v3: None
Changes in v2: None

 drivers/net/designware.c | 6 +++---
 drivers/net/designware.h | 4 ++++
 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/designware.c +3 -3
index 9e6d726..6ef36bc 100644
@@ -628,7 +628,7 @@ static int designware_eth_bind(struct udevice *dev)
 	return 0;
 }
 
-static int designware_eth_probe(struct udevice *dev)
+int designware_eth_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct dw_eth_dev *priv = dev_get_priv(dev);
@@ -678,7 +678,7 @@ static int designware_eth_remove(struct udevice *dev)
 	return 0;
 }
 
-static const struct eth_ops designware_eth_ops = {
+const struct eth_ops designware_eth_ops = {
 	.start			= designware_eth_start,
 	.send			= designware_eth_send,
 	.recv			= designware_eth_recv,
@@ -687,7 +687,7 @@ static const struct eth_ops designware_eth_ops = {
 	.write_hwaddr		= designware_eth_write_hwaddr,
 };
 
-static int designware_eth_ofdata_to_platdata(struct udevice *dev)
+int designware_eth_ofdata_to_platdata(struct udevice *dev)
 {
 	struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
 #ifdef CONFIG_DM_GPIO
drivers/net/designware.h +4 -0
index d345c5b..087ebef 100644
@@ -245,6 +245,10 @@ struct dw_eth_dev {
 };
 
 #ifdef CONFIG_DM_ETH
+int designware_eth_ofdata_to_platdata(struct udevice *dev);
+int designware_eth_probe(struct udevice *dev);
+extern const struct eth_ops designware_eth_ops;
+
 struct dw_eth_pdata {
 	struct eth_pdata eth_pdata;
 	u32 reset_delays[3];
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH v3 1/9 net: designware: Export various functions/struct to allow subclassing

Quoted 9 lines · Simon Glass

From: Sjoerd Simons <[email protected]>

To allow other DM drivers to subclass the designware driver various functions and structures need to be exported. Export these.

#3 lore raw

PATCH v3 2/9 net: designware: Adjust dw_adjust_link() to return an error

In reply to Simon Glass

This function can fail, so return the error if there is one.

---

Changes in v3:
- Add new patch to adjust dw_adjust_link() to return an error

Changes in v2: None

 drivers/net/designware.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/net/designware.c +8 -4
index 6ef36bc..ebcef8b 100644
@@ -230,14 +230,14 @@ static int _dw_write_hwaddr(struct dw_eth_dev *priv, u8 *mac_id)
 	return 0;
 }
 
-static void dw_adjust_link(struct eth_mac_regs *mac_p,
-			   struct phy_device *phydev)
+static int dw_adjust_link(struct dw_eth_dev *priv, struct eth_mac_regs *mac_p,
+			  struct phy_device *phydev)
 {
 	u32 conf = readl(&mac_p->conf) | FRAMEBURSTENABLE | DISABLERXOWN;
 
 	if (!phydev->link) {
 		printf("%s: No link.\n", phydev->dev->name);
-		return;
+		return 0;
 	}
 
 	if (phydev->speed != 1000)
@@ -256,6 +256,8 @@ static void dw_adjust_link(struct eth_mac_regs *mac_p,
 	printf("Speed: %d, %s duplex%s\n", phydev->speed,
 	       (phydev->duplex) ? "full" : "half",
 	       (phydev->port == PORT_FIBRE) ? ", fiber mode" : "");
+
+	return 0;
 }
 
 static void _dw_eth_halt(struct dw_eth_dev *priv)
@@ -321,7 +323,9 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 		return ret;
 	}
 
-	dw_adjust_link(mac_p, priv->phydev);
+	ret = dw_adjust_link(priv, mac_p, priv->phydev);
+	if (ret)
+		return ret;
 
 	if (!priv->phydev->link)
 		return -EIO;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#5 lore raw

PATCH v3 3/9 net: designware: Split the link init into a separate function

In reply to Simon Glass

With rockchip we need to make adjustments after the link speed is set but before enabling received/transmit. In preparation for this, split these two pieces into separate functions.

---

Changes in v3:
- Add new patch to split the link init into a separate function

Changes in v2: None

 drivers/net/designware.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/net/designware.c +24 -2
index ebcef8b..0c596a7 100644
@@ -327,6 +327,13 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 	if (ret)
 		return ret;
 
+	return 0;
+}
+
+static int designware_eth_enable(struct dw_eth_dev *priv)
+{
+	struct eth_mac_regs *mac_p = priv->mac_regs_p;
+
 	if (!priv->phydev->link)
 		return -EIO;
 
@@ -484,7 +491,13 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
 #ifndef CONFIG_DM_ETH
 static int dw_eth_init(struct eth_device *dev, bd_t *bis)
 {
-	return _dw_eth_init(dev->priv, dev->enetaddr);
+	int ret;
+
+	ret = _dw_eth_init(dev->priv, dev->enetaddr);
+	if (!ret)
+		ret = designware_eth_enable(dev->priv);
+
+	return ret;
 }
 
 static int dw_eth_send(struct eth_device *dev, void *packet, int length)
@@ -575,8 +588,17 @@ int designware_initialize(ulong base_addr, u32 interface)
 static int designware_eth_start(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
+	struct dw_eth_dev *priv = dev_get_priv(dev);
+	int ret;
 
-	return _dw_eth_init(dev->priv, pdata->enetaddr);
+	ret = _dw_eth_init(priv, pdata->enetaddr);
+	if (ret)
+		return ret;
+	ret = designware_eth_enable(priv);
+	if (ret)
+		return ret;
+
+	return 0;
 }
 
 static int designware_eth_send(struct udevice *dev, void *packet, int length)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#7 lore raw

PATCH v3 4/9 net: designware: Export the operation functions

In reply to Simon Glass

Export all functions so that drivers can use them, or not, as the need arises.

---

Changes in v3:
- Add new patch to export the operation functions

Changes in v2: None

 drivers/net/designware.c | 19 +++++++++----------
 drivers/net/designware.h |  9 +++++++++
 2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/designware.c +9 -10
index 0c596a7..f242fc6 100644
@@ -271,7 +271,7 @@ static void _dw_eth_halt(struct dw_eth_dev *priv)
 	phy_shutdown(priv->phydev);
 }
 
-static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
+int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 {
 	struct eth_mac_regs *mac_p = priv->mac_regs_p;
 	struct eth_dma_regs *dma_p = priv->dma_regs_p;
@@ -330,7 +330,7 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
 	return 0;
 }
 
-static int designware_eth_enable(struct dw_eth_dev *priv)
+int designware_eth_enable(struct dw_eth_dev *priv)
 {
 	struct eth_mac_regs *mac_p = priv->mac_regs_p;
 
@@ -493,7 +493,7 @@ static int dw_eth_init(struct eth_device *dev, bd_t *bis)
 {
 	int ret;
 
-	ret = _dw_eth_init(dev->priv, dev->enetaddr);
+	ret = designware_eth_init(dev->priv, dev->enetaddr);
 	if (!ret)
 		ret = designware_eth_enable(dev->priv);
 
@@ -591,7 +591,7 @@ static int designware_eth_start(struct udevice *dev)
 	struct dw_eth_dev *priv = dev_get_priv(dev);
 	int ret;
 
-	ret = _dw_eth_init(priv, pdata->enetaddr);
+	ret = designware_eth_init(priv, pdata->enetaddr);
 	if (ret)
 		return ret;
 	ret = designware_eth_enable(priv);
@@ -601,36 +601,35 @@ static int designware_eth_start(struct udevice *dev)
 	return 0;
 }
 
-static int designware_eth_send(struct udevice *dev, void *packet, int length)
+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, int flags, uchar **packetp)
+int designware_eth_recv(struct udevice *dev, int flags, 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)
+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)
+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)
+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);
drivers/net/designware.h +9 -0
index 087ebef..7992d0e 100644
@@ -253,6 +253,15 @@ struct dw_eth_pdata {
 	struct eth_pdata eth_pdata;
 	u32 reset_delays[3];
 };
+
+int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr);
+int designware_eth_enable(struct dw_eth_dev *priv);
+int designware_eth_send(struct udevice *dev, void *packet, int length);
+int designware_eth_recv(struct udevice *dev, int flags, uchar **packetp);
+int designware_eth_free_pkt(struct udevice *dev, uchar *packet,
+				   int length);
+void designware_eth_stop(struct udevice *dev);
+int designware_eth_write_hwaddr(struct udevice *dev);
 #endif
 
 #endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
#8 lore raw

PATCH v3 4/9 net: designware: Export the operation functions

Quoted 4 lines · Simon Glass

Export all functions so that drivers can use them, or not, as the need arises.

With a minor nit below,

Quoted 16 lines

---

Changes in v3:
- Add new patch to export the operation functions

Changes in v2: None

 drivers/net/designware.c | 19 +++++++++----------
 drivers/net/designware.h |  9 +++++++++
 2 files changed, 18 insertions(+), 10 deletions(-)
drivers/net/designware.c +0 -0
index 0c596a7..f242fc6 100644

drivers/net/designware.c static void _dw_eth_halt(struct dw_eth_dev *priv) · line 274

Quoted 5 lines
drivers/net/designware.c +1 -1
@@ -271,7 +271,7 @@ static void _dw_eth_halt(struct dw_eth_dev *priv)
        phy_shutdown(priv->phydev);
 }
 
-static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
+int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)

Modern functions are called "_start", not init. Also, this already uses stop below, instead of halt. It would be nice to keep them symmetric.

Quoted 6 lines
drivers/net/designware.c +0 -0
 {
        struct eth_mac_regs *mac_p = priv->mac_regs_p;
        struct eth_dma_regs *dma_p = priv->dma_regs_p;
@@ -330,7 +330,7 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr)
        return 0;
 }
#9 lore raw

PATCH v3 5/9 net: gmac_rk3288: Add RK3288 GMAC driver

In reply to Simon Glass

From: Sjoerd Simons <[email protected]>

Add a new driver for the GMAC ethernet interface present in Rockchip RK3288 SOCs. This driver subclasses the generic design-ware driver to add the glue needed specifically for Rockchip.

---

Changes in v3:
- Add comments for struct gmac_rk3288_platdata
- Adjust binding to use r/tx-delay instead of r/tx_delay
- Sort includes
- Use debug() instead of printf() for error
- Use function calls instead of fix_mac_speed() hook
- Use new clk interface

Changes in v2:
- Adjust to new hook name
- Fix various coding style nits

 drivers/net/Kconfig       |   7 +++
 drivers/net/Makefile      |   1 +
 drivers/net/gmac_rk3288.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 162 insertions(+)
 create mode 100644 drivers/net/gmac_rk3288.c
drivers/net/Kconfig +7 -0
index f25d3ff..0027a2e 100644
@@ -215,4 +215,11 @@ config PIC32_ETH
 	  This driver implements 10/100 Mbps Ethernet and MAC layer for
 	  Microchip PIC32 microcontrollers.
 
+config GMAC_RK3288
+	bool "Rockchip RK3288 Synopsys Designware Ethernet MAC"
+	depends on DM_ETH && ETH_DESIGNWARE
+	help
+	  This driver provides Rockchip RK3288 network support based on the
+	  Synopsys Designware driver.
+
 endif # NETDEVICES
drivers/net/Makefile +1 -0
index 9a7bfc6..348e98b 100644
@@ -34,6 +34,7 @@ obj-$(CONFIG_FTGMAC100) += ftgmac100.o
 obj-$(CONFIG_FTMAC110) += ftmac110.o
 obj-$(CONFIG_FTMAC100) += ftmac100.o
 obj-$(CONFIG_GRETH) += greth.o
+obj-$(CONFIG_GMAC_RK3288) += gmac_rk3288.o
 obj-$(CONFIG_DRIVER_TI_KEYSTONE_NET) += keystone_net.o
 obj-$(CONFIG_KS8851_MLL) += ks8851_mll.o
 obj-$(CONFIG_LAN91C96) += lan91c96.o
drivers/net/gmac_rk3288.c new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
#11 lore raw

PATCH v3 6/9 rockchip: Enable networking support on rock2 and firefly

In reply to Simon Glass

From: Sjoerd Simons <[email protected]>

Enable the various configuration option required to get the ethernet interface up and running on Radxa Rock2 and Firefly.

---

Changes in v3: None
Changes in v2: None

 configs/firefly-rk3288_defconfig | 4 ++++
 configs/rock2_defconfig          | 4 ++++
 2 files changed, 8 insertions(+)
configs/firefly-rk3288_defconfig +4 -0
index 4910c80..82787dc 100644
@@ -44,6 +44,10 @@ CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
 CONFIG_ROCKCHIP_DWMMC=y
+CONFIG_DM_ETH=y
+CONFIG_NETDEVICES=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_GMAC_RK3288=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
configs/rock2_defconfig +4 -0
index 1883f07..f8436d6 100644
@@ -43,6 +43,10 @@ CONFIG_SPL_CLK=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
 CONFIG_ROCKCHIP_DWMMC=y
+CONFIG_DM_ETH=y
+CONFIG_NETDEVICES=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_GMAC_RK3288=y
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 # CONFIG_SPL_PINCTRL_FULL is not set
Signature · 1 line
2.8.0.rc3.226.g39d4020
#12 lore raw

PATCH v3 7/9 rockchip: evb-rk3339: Enable DHCP

In reply to Simon Glass

This is the only RK3288 device without DHCP. Enable it so that we can use a common BOOT_TARGET_DEVICES setting. It is likely useful to be able to use USB networking, at least. Full networking can be enabled when a suitable platform needs it.

---

Changes in v3:
- Add new patch to enable networking on evb-rk3288

Changes in v2: None

 configs/evb-rk3399_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/evb-rk3399_defconfig +3 -0
index 40a8295..be522fb 100644
@@ -11,6 +11,9 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer
#13 lore raw

PATCH v3 7/9 rockchip: evb-rk3339: Enable DHCP

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:47 schrieb Simon Glass:

Quoted 1 line

This is the only RK3288 device without DHCP. Enable it so that we

                      ^^ rk3288/rk3399?
Quoted 9 lines

can use a common BOOT_TARGET_DEVICES setting. It is likely useful to be able to use USB networking, at least. Full networking can be enabled when a suitable platform needs it.

---

Changes in v3:
- Add new patch to enable networking on evb-rk3288

same here :-)

Heiko

Quoted 20 lines

Changes in v2: None

 configs/evb-rk3399_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/evb-rk3399_defconfig +3 -0
index 40a8295..be522fb 100644
@@ -11,6 +11,9 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_MII=y
+CONFIG_CMD_PING=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_EXT2=y
 CONFIG_CMD_EXT4=y
#14 lore raw

PATCH v3 8/9 rockchip: Add PXE and DHCP to the default boot targets

In reply to Simon Glass

From: Sjoerd Simons <[email protected]>

Now that at least on the firefly board we have network support, enable PXE and DHCP boot targets by default.

---

Changes in v3: None
Changes in v2: None

 include/configs/rockchip-common.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
include/configs/rockchip-common.h +3 -1
index 9ec71c4..be53e65 100644
@@ -14,7 +14,9 @@
 /* First try to boot from SD (index 0), then eMMC (index 1 */
 #define BOOT_TARGET_DEVICES(func) \
 	func(MMC, mmc, 0) \
-	func(MMC, mmc, 1)
+	func(MMC, mmc, 1) \
+	func(PXE, pxe, na) \
+	func(DHCP, dchp, na)
 
  /* Enable gpt partition table */
 #define CONFIG_CMD_GPT
Signature · 1 line
2.8.0.rc3.226.g39d4020
#15 lore raw

PATCH v3 9/9 rockchip: Drop Ethernet from the TODO

In reply to Simon Glass

From: Sjoerd Simons <[email protected]>

Now that ethernet support works, it can be dropped from the rockchip TODO

---

Changes in v3:
- Add a few new patches
- Drop the 'net: designware: Add a fix_mac_speed hook' patch

Changes in v2: None

 doc/README.rockchip | 1 -
 1 file changed, 1 deletion(-)
doc/README.rockchip +0 -1
index 06ec80e..43cafc7 100644
@@ -219,7 +219,6 @@ Immediate priorities are:
 - USB host
 - USB device
 - Run CPU at full speed (code exists but we only see ~60 DMIPS maximum)
-- Ethernet
 - NAND flash
 - Support for other Rockchip parts
 - Boot U-Boot proper over USB OTG (at present only SPL works)
Signature · 1 line
2.8.0.rc3.226.g39d4020
maintainer
#16 lore raw

v3 cover From Simon:

In reply to Simon Glass

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 5 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary. I have dealt with the changes requested at the time, and adjusted the way that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms)
Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #################################################################

         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason. I'm not sure if just my switch is some special snowflake (TL-SG1024 from TP- Link) or there is some other voodoo at work here.

The rootfs over nfs seems to work fine on 1000MBit though.

Heiko

Quoted 62 lines

Original cover letter:
To add support I've taken a slightly different approach then some of the other boards with a designware IP block, by creating a new driver to take care of the platfrom glue which subclasses the main designware driver instead of adding the compatibility string the designware driver directly and doing the SoC specific setup in the board files. This seems quite a bit more elegant in a device model based world.

I've only tested this series on a Radxa Rock 2 board, it would be great if someone could test this on other boards with the designware IP especially for those with the reset GPIO in devicetree (e.g. some of the Allwinner boards).

Compared to the first one round the pinctrl related bits were dropped as RK3288 now has a full pinctrl driver. Furthermore the started hook in the designware driver was renamed to fix_mac_speed in line with what linux uses and moved to the dw_link_adjust function.

Changes in v3:
- Add a few new patches
- Add comments for struct gmac_rk3288_platdata
- Add new patch to adjust dw_adjust_link() to return an error
- Add new patch to enable networking on evb-rk3288
- Add new patch to export the operation functions
- Add new patch to split the link init into a separate function
- Adjust binding to use r/tx-delay instead of r/tx_delay
- Drop the 'net: designware: Add a fix_mac_speed hook' patch
- Sort includes
- Use debug() instead of printf() for error
- Use function calls instead of fix_mac_speed() hook
- Use new clk interface

Changes in v2:
- Adjust to new hook name
- Fix various coding style nits

Simon Glass (4):
net: designware: Adjust dw_adjust_link() to return an error
net: designware: Split the link init into a separate function
net: designware: Export the operation functions
rockchip: evb-rk3339: Enable DHCP

Sjoerd Simons (5):
net: designware: Export various functions/struct to allow subclassing
net: gmac_rk3288: Add RK3288 GMAC driver
rockchip: Enable networking support on rock2 and firefly
rockchip: Add PXE and DHCP to the default boot targets
rockchip: Drop Ethernet from the TODO

 configs/evb-rk3399_defconfig      |   3 +
 configs/firefly-rk3288_defconfig  |   4 +
 configs/rock2_defconfig           |   4 +
 doc/README.rockchip               |   1 -
 drivers/net/Kconfig               |   7 ++
 drivers/net/Makefile              |   1 +
 drivers/net/designware.c          |  57 ++++++++++----
 drivers/net/designware.h          |  13 ++++
 drivers/net/gmac_rk3288.c         | 154
++++++++++++++++++++++++++++++++++++++ include/configs/rockchip-common.h | 
 4 +-
 10 files changed, 230 insertions(+), 18 deletions(-)
 create mode 100644 drivers/net/gmac_rk3288.c
#17 lore raw

v3 cover From Simon:

Hi Heiko,

Quoted 52 lines · Heiko St?bner

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 5 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary. I have dealt with the changes requested at the time, and adjusted the way that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms)
Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #################################################################

         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

Quoted 5 lines

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason. I'm not sure if just my switch is some special snowflake (TL-SG1024 from TP- Link) or there is some other voodoo at work here.

The rootfs over nfs seems to work fine on 1000MBit though.

Yes I see some timeouts, although I don't think it is anything to do with the driver conversion. Or does this not happen unless my patches are applied?

Quoted 4 lines

Heiko

[..]

Regards,
Simon

maintainer
#18 lore raw

v3 cover From Simon:

Am Dienstag, 29. November 2016, 19:47:10 schrieb Simon Glass:

Quoted 61 lines

Hi Heiko,

Quoted 58 lines · Heiko St?bner

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 5 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary. I have dealt with the changes requested at the time, and adjusted the way that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms)
Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #################################################################

         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason. I'm not sure if just my switch is some special snowflake (TL-SG1024 from TP- Link) or there is some other voodoo at work here.

Quoted 5 lines
Quoted 1 line

The rootfs over nfs seems to work fine on 1000MBit though.

Yes I see some timeouts, although I don't think it is anything to do with the driver conversion. Or does this not happen unless my patches are applied?

nope, really looks like some other parts are just not fast enough? And the setup of GRF and so on, look the same as in the linux kernel, so should be fine as well.

Heiko

maintainer
#19 lore raw

v3 cover From Simon:

Hi Simon,

Am Mittwoch, 30. November 2016, 12:52:22 schrieb Heiko St?bner:

Quoted 13 lines

Am Dienstag, 29. November 2016, 19:47:10 schrieb Simon Glass:

Quoted 12 lines · Heiko St?bner
Quoted 11 lines

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 7 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary.
I have dealt with the changes requested at the time, and adjusted the way
that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

so assuming the 1000MBit issue comes from somewhere else, this series

Quoted 66 lines
Quoted 54 lines
Quoted 54 lines

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading:
#################################################################

         ###############################################################
         ##
         ###############################################################
         ##
         ###############################################################
         ##
         ###############################################################
         ##
         ###############################################################
         ##
         ###############################################################
         ##
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason.
I'm not sure if just my switch is some special snowflake (TL-SG1024 from TP- Link) or there is some other voodoo at work here.

Quoted 5 lines
Quoted 1 line

The rootfs over nfs seems to work fine on 1000MBit though.

Yes I see some timeouts, although I don't think it is anything to do with the driver conversion. Or does this not happen unless my patches are applied?

nope, really looks like some other parts are just not fast enough? And the setup of GRF and so on, look the same as in the linux kernel, so should be fine as well.

Heiko

#20 lore raw

v3 cover From Simon:

In reply to Heiko Stübner

Hi Heiko,

Quoted 64 lines · Heiko St?bner

Am Dienstag, 29. November 2016, 19:47:10 schrieb Simon Glass:

Quoted 63 lines

Hi Heiko,

Quoted 59 lines · Heiko St?bner

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 5 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary. I have dealt with the changes requested at the time, and adjusted the way that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms)
Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #################################################################

         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason. I'm not sure if just my switch is some special snowflake (TL-SG1024 from TP- Link) or there is some other voodoo at work here.

The rootfs over nfs seems to work fine on 1000MBit though.

Quoted 7 lines
Quoted 3 lines

Yes I see some timeouts, although I don't think it is anything to do with the driver conversion. Or does this not happen unless my patches are applied?

nope, really looks like some other parts are just not fast enough? And the setup of GRF and so on, look the same as in the linux kernel, so should be fine as well.

So to be clear, are you saying that the same problem happens on a downstream tree that you tried, or not?

In terms of 'not fast enough' you could try turning off HDMI if that is on. Also see veyron_init() and see if you can adapt that to firefly to get the clock speed up?

Regards,
Simon

maintainer
#21 lore raw

v3 cover From Simon:

Am Mittwoch, 30. November 2016, 19:20:30 schrieb Simon Glass:

Quoted 82 lines

Hi Heiko,

Quoted 79 lines · Heiko St?bner

Am Dienstag, 29. November 2016, 19:47:10 schrieb Simon Glass:

Quoted 77 lines

Hi Heiko,

Quoted 63 lines · Heiko St?bner

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 7 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary.
I have dealt with the changes requested at the time, and adjusted the way
that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading:
#################################################################

         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

Quoted 7 lines

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason.
I'm not sure if just my switch is some special snowflake (TL-SG1024 from
TP- Link) or there is some other voodoo at work here.

The rootfs over nfs seems to work fine on 1000MBit though.

Yes I see some timeouts, although I don't think it is anything to do with the driver conversion. Or does this not happen unless my patches are applied?

Quoted 6 lines
Quoted 3 lines

nope, really looks like some other parts are just not fast enough? And the setup of GRF and so on, look the same as in the linux kernel, so should be fine as well.

So to be clear, are you saying that the same problem happens on a downstream tree that you tried, or not?

nope, didn't say that. The firefly actually is my first board using the internal ethernet. My other boards normally use usb-ethernet adapters as the arc-emac used in other socs isn't supported at all yet.

Quoted 3 lines

In terms of 'not fast enough' you could try turning off HDMI if that is on. Also see veyron_init() and see if you can adapt that to firefly to get the clock speed up?

Sadly not until after the 11th of december. But I guess we could just merge it now and hopefully fixup the special case later on. It seems to work always at 100MBit and it seems also at 1000MBit on your side.

Heiko

#22 lore raw

v3 cover From Simon:

Hi Heiko,

Quoted 95 lines · Heiko St?bner

Am Mittwoch, 30. November 2016, 19:20:30 schrieb Simon Glass:

Quoted 82 lines

Hi Heiko,

Quoted 79 lines · Heiko St?bner

Am Dienstag, 29. November 2016, 19:47:10 schrieb Simon Glass:

Quoted 77 lines

Hi Heiko,

Quoted 63 lines · Heiko St?bner

Hi Simon,

Am Sonntag, 27. November 2016, 10:01:40 schrieb Simon Glass:

Quoted 7 lines

This v3 patch is an update on Sjoerd's original v2 series from Feburary.
I have dealt with the changes requested at the time, and adjusted the way
that the speed change is handled.

Tested on firefly-rk3288, rock2.

Tested on a firefly as well. Though I get mixed results in my netboot environment. At 100MBit (manually limited) everything seems fine:

----------------------
Speed: 100, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.58 (269 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.58 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading:
#################################################################

         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         ##############################################################
         ###
         #########################
         2.9 MiB/s

done
Bytes transferred = 7033483 (6b528b hex)
----------------------

5 out of 5 boots worked fine.

but at 1000MHz I only get:

----------------------
Speed: 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.140.57 (270 ms) Using ethernet at ff290000 device
TFTP from server 192.168.140.1; our IP address is 192.168.140.57 Filename 'hstuebner/firefly.vmlinuz'.
Load address: 0x4000000
Loading: #####T #T #T ##T T #T #T T ####T #T #### Retry count exceeded; starting again
----------------------

Quoted 7 lines

on 5 boots. 1 lonely boot also worked at 1000MBit for some unknown reason.
I'm not sure if just my switch is some special snowflake (TL-SG1024 from
TP- Link) or there is some other voodoo at work here.

The rootfs over nfs seems to work fine on 1000MBit though.

Yes I see some timeouts, although I don't think it is anything to do with the driver conversion. Or does this not happen unless my patches are applied?

Quoted 6 lines
Quoted 3 lines

nope, really looks like some other parts are just not fast enough? And the setup of GRF and so on, look the same as in the linux kernel, so should be fine as well.

So to be clear, are you saying that the same problem happens on a downstream tree that you tried, or not?

nope, didn't say that. The firefly actually is my first board using the internal ethernet. My other boards normally use usb-ethernet adapters as the arc-emac used in other socs isn't supported at all yet.

Quoted 7 lines
Quoted 3 lines

In terms of 'not fast enough' you could try turning off HDMI if that is on. Also see veyron_init() and see if you can adapt that to firefly to get the clock speed up?

Sadly not until after the 11th of december. But I guess we could just merge it now and hopefully fixup the special case later on. It seems to work always at 100MBit and it seems also at 1000MBit on your side.

I decided to hold off until we get a bit more testing. Let me know what you fine.

Regards,
Simon