All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] net: smc911x: Convert to DM
@ 2020-03-15 16:58 Marek Vasut
  2020-03-15 16:58 ` [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull} Marek Vasut
                   ` (12 more replies)
  0 siblings, 13 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Perform DM conversion of the SMC911x driver. Note that as I do not have
any hardware with this chip, I only compile-tested this conversion. But
it seems Yamada-san has one, so please test.

Note that the DT compatible is set only for 9115 , so this might need
to be changed.

Note that this is compile-tested, but not hardware tested, so please do
send me patches, thanks.

Marek Vasut (12):
  net: smc911x: Remove pkt_data_{push,pull}
  net: smc911x: Replace malloc()+memset() with calloc()
  net: smc911x: Rename smc911x_rx() to smc911x_recv()
  net: smc911x: Invert the logic in smc911x_miiphy_{read,write}()
  net: smc911x: Fix potential memleak() in init fail path
  net: smc911x: Inline all functions from header file
  net: smc911x: Drop weak alias from 32bit accessors
  net: smc911x: Convert IO accessors to {read,write}{w,l}()
  net: smc911x: Pass around driver private data
  net: smc911x: Clean up the status handling in smc911x_recv()
  net: smc911x: Split non-DM specific bits from common code
  net: smc911x: Add DM support

 board/renesas/blanche/blanche.c      |   2 +
 drivers/net/smc911x.c                | 523 +++++++++++++++++++++------
 drivers/net/smc911x.h                | 157 --------
 examples/standalone/Makefile         |   5 +-
 examples/standalone/smc911x_eeprom.c | 150 ++++++++
 5 files changed, 577 insertions(+), 260 deletions(-)

Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

-- 
2.25.0

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull}
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-16 23:52   ` Joe Hershberger
  2020-03-15 16:58 ` [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc() Marek Vasut
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

These functions are never used and are likely a pre-DM remnant
from times long past, just remove them.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 257b0385c2..24b4eaeb3f 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -13,11 +13,6 @@
 
 #include "smc911x.h"
 
-u32 pkt_data_pull(struct eth_device *dev, u32 addr) \
-	__attribute__ ((weak, alias ("smc911x_reg_read")));
-void pkt_data_push(struct eth_device *dev, u32 addr, u32 val) \
-	__attribute__ ((weak, alias ("smc911x_reg_write")));
-
 static void smc911x_handle_mac_address(struct eth_device *dev)
 {
 	unsigned long addrh, addrl;
@@ -157,7 +152,7 @@ static int smc911x_send(struct eth_device *dev, void *packet, int length)
 	tmplen = (length + 3) / 4;
 
 	while (tmplen--)
-		pkt_data_push(dev, TX_DATA_FIFO, *data++);
+		smc911x_reg_write(dev, TX_DATA_FIFO, *data++);
 
 	/* wait for transmission */
 	while (!((smc911x_reg_read(dev, TX_FIFO_INF) &
@@ -203,7 +198,7 @@ static int smc911x_rx(struct eth_device *dev)
 
 		tmplen = (pktlen + 3) / 4;
 		while (tmplen--)
-			*data++ = pkt_data_pull(dev, RX_DATA_FIFO);
+			*data++ = smc911x_reg_read(dev, RX_DATA_FIFO);
 
 		if (status & RX_STS_ES)
 			printf(DRIVERNAME
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc()
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
  2020-03-15 16:58 ` [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull} Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-16 23:58   ` Joe Hershberger
  2020-03-17  6:20   ` Masahiro Yamada
  2020-03-15 16:58 ` [PATCH 03/12] net: smc911x: Rename smc911x_rx() to smc911x_recv() Marek Vasut
                   ` (10 subsequent siblings)
  12 siblings, 2 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Replace combination of malloc()+memset() with calloc() as the behavior
is exactly the same and the amount of code is reduced.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 24b4eaeb3f..a78b7817ac 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -242,11 +242,10 @@ int smc911x_initialize(u8 dev_num, int base_addr)
 	unsigned long addrl, addrh;
 	struct eth_device *dev;
 
-	dev = malloc(sizeof(*dev));
+	dev = calloc(1, sizeof(*dev));
 	if (!dev) {
 		return -1;
 	}
-	memset(dev, 0, sizeof(*dev));
 
 	dev->iobase = base_addr;
 
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 03/12] net: smc911x: Rename smc911x_rx() to smc911x_recv()
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
  2020-03-15 16:58 ` [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull} Marek Vasut
  2020-03-15 16:58 ` [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc() Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-15 16:58 ` [PATCH 04/12] net: smc911x: Invert the logic in smc911x_miiphy_{read, write}() Marek Vasut
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Rename the function to keep the naming scheme consistent,
no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index a78b7817ac..1c436a2964 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -184,7 +184,7 @@ static void smc911x_halt(struct eth_device *dev)
 	smc911x_handle_mac_address(dev);
 }
 
-static int smc911x_rx(struct eth_device *dev)
+static int smc911x_recv(struct eth_device *dev)
 {
 	u32 *data = (u32 *)net_rx_packets[0];
 	u32 pktlen, tmplen;
@@ -270,7 +270,7 @@ int smc911x_initialize(u8 dev_num, int base_addr)
 	dev->init = smc911x_init;
 	dev->halt = smc911x_halt;
 	dev->send = smc911x_send;
-	dev->recv = smc911x_rx;
+	dev->recv = smc911x_recv;
 	sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num);
 
 	eth_register(dev);
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 04/12] net: smc911x: Invert the logic in smc911x_miiphy_{read, write}()
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (2 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 03/12] net: smc911x: Rename smc911x_rx() to smc911x_recv() Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-15 16:58 ` [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path Marek Vasut
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Invert the logic in the aforementioned functions to reduce indent,
no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 1c436a2964..81f8f0d017 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -216,24 +216,29 @@ static int smc911x_recv(struct eth_device *dev)
 static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad,
 			       int reg)
 {
-	u16 val = 0;
 	struct eth_device *dev = eth_get_dev_by_name(bus->name);
-	if (dev) {
-		int retval = smc911x_eth_phy_read(dev, phy, reg, &val);
-		if (retval < 0)
-			return retval;
-		return val;
-	}
-	return -ENODEV;
+	u16 val = 0;
+	int ret;
+
+	if (!dev)
+		return -ENODEV;
+
+	ret = smc911x_eth_phy_read(dev, phy, reg, &val);
+	if (ret < 0)
+		return ret;
+
+	return val;
 }
 /* wrapper for smc911x_eth_phy_write */
 static int smc911x_miiphy_write(struct mii_dev *bus, int phy, int devad,
 				int reg, u16 val)
 {
 	struct eth_device *dev = eth_get_dev_by_name(bus->name);
-	if (dev)
-		return smc911x_eth_phy_write(dev, phy, reg, val);
-	return -ENODEV;
+
+	if (!dev)
+		return -ENODEV;
+
+	return smc911x_eth_phy_write(dev, phy, reg, val);
 }
 #endif
 
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (3 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 04/12] net: smc911x: Invert the logic in smc911x_miiphy_{read, write}() Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  0:03   ` Joe Hershberger
  2020-03-17  6:21   ` Masahiro Yamada
  2020-03-15 16:58 ` [PATCH 06/12] net: smc911x: Inline all functions from header file Marek Vasut
                   ` (7 subsequent siblings)
  12 siblings, 2 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Fix memleak in the init fail path, where if allocation or registration
of MDIO bus fails, then ethernet interface is not unregistered and the
private data are not freed, yet the probe function reports a failure.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 81f8f0d017..44cb45af61 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -249,7 +249,7 @@ int smc911x_initialize(u8 dev_num, int base_addr)
 
 	dev = calloc(1, sizeof(*dev));
 	if (!dev) {
-		return -1;
+		return -ENODEV;
 	}
 
 	dev->iobase = base_addr;
@@ -283,15 +283,23 @@ int smc911x_initialize(u8 dev_num, int base_addr)
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 	int retval;
 	struct mii_dev *mdiodev = mdio_alloc();
-	if (!mdiodev)
+	if (!mdiodev) {
+		eth_unregister(dev);
+		free(dev);
 		return -ENOMEM;
+	}
+
 	strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
 	mdiodev->read = smc911x_miiphy_read;
 	mdiodev->write = smc911x_miiphy_write;
 
 	retval = mdio_register(mdiodev);
-	if (retval < 0)
+	if (retval < 0) {
+		mdio_free(mdiodev);
+		eth_unregister(dev);
+		free(dev);
 		return retval;
+	}
 #endif
 
 	return 1;
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 06/12] net: smc911x: Inline all functions from header file
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (4 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  0:06   ` Joe Hershberger
  2020-03-17  6:25   ` Masahiro Yamada
  2020-03-15 16:58 ` [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors Marek Vasut
                   ` (6 subsequent siblings)
  12 siblings, 2 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Inline all the functions from the header file, as they are not used
outside of the driver or the standalone EEPROM example.

Note that this does introduce considerable amount of duplication in
the standalone EEPROM example, however that one has to be rewritten
anyway, roughly such that the SMC911x driver would expose DM EEPROM
interface and the standalone example would use that.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c                | 157 ++++++++++++++++++++++++++-
 drivers/net/smc911x.h                | 157 ---------------------------
 examples/standalone/smc911x_eeprom.c | 156 ++++++++++++++++++++++++++
 3 files changed, 312 insertions(+), 158 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 44cb45af61..c806757605 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -10,9 +10,165 @@
 #include <malloc.h>
 #include <net.h>
 #include <miiphy.h>
+#include <linux/types.h>
 
 #include "smc911x.h"
 
+struct chip_id {
+	u16 id;
+	char *name;
+};
+
+static const struct chip_id chip_ids[] =  {
+	{ CHIP_89218, "LAN89218" },
+	{ CHIP_9115, "LAN9115" },
+	{ CHIP_9116, "LAN9116" },
+	{ CHIP_9117, "LAN9117" },
+	{ CHIP_9118, "LAN9118" },
+	{ CHIP_9211, "LAN9211" },
+	{ CHIP_9215, "LAN9215" },
+	{ CHIP_9216, "LAN9216" },
+	{ CHIP_9217, "LAN9217" },
+	{ CHIP_9218, "LAN9218" },
+	{ CHIP_9220, "LAN9220" },
+	{ CHIP_9221, "LAN9221" },
+	{ 0, NULL },
+};
+
+#define DRIVERNAME "smc911x"
+
+#if defined (CONFIG_SMC911X_32_BIT) && \
+	defined (CONFIG_SMC911X_16_BIT)
+#error "SMC911X: Only one of CONFIG_SMC911X_32_BIT and \
+	CONFIG_SMC911X_16_BIT shall be set"
+#endif
+
+#if defined (CONFIG_SMC911X_32_BIT)
+static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
+{
+	return *(volatile u32*)(dev->iobase + offset);
+}
+u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+	__attribute__((weak, alias("__smc911x_reg_read")));
+
+static inline void __smc911x_reg_write(struct eth_device *dev,
+					u32 offset, u32 val)
+{
+	*(volatile u32*)(dev->iobase + offset) = val;
+}
+void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
+	__attribute__((weak, alias("__smc911x_reg_write")));
+#elif defined (CONFIG_SMC911X_16_BIT)
+static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+{
+	volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
+	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+}
+static inline void smc911x_reg_write(struct eth_device *dev,
+					u32 offset, u32 val)
+{
+	*(volatile u16 *)(dev->iobase + offset) = (u16)val;
+	*(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
+}
+#else
+#error "SMC911X: undefined bus width"
+#endif /* CONFIG_SMC911X_16_BIT */
+
+static u32 smc911x_get_mac_csr(struct eth_device *dev, u8 reg)
+{
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+	smc911x_reg_write(dev, MAC_CSR_CMD,
+			MAC_CSR_CMD_CSR_BUSY | MAC_CSR_CMD_R_NOT_W | reg);
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+
+	return smc911x_reg_read(dev, MAC_CSR_DATA);
+}
+
+static void smc911x_set_mac_csr(struct eth_device *dev, u8 reg, u32 data)
+{
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+	smc911x_reg_write(dev, MAC_CSR_DATA, data);
+	smc911x_reg_write(dev, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+}
+
+static int smc911x_detect_chip(struct eth_device *dev)
+{
+	unsigned long val, i;
+
+	val = smc911x_reg_read(dev, BYTE_TEST);
+	if (val == 0xffffffff) {
+		/* Special case -- no chip present */
+		return -1;
+	} else if (val != 0x87654321) {
+		printf(DRIVERNAME ": Invalid chip endian 0x%08lx\n", val);
+		return -1;
+	}
+
+	val = smc911x_reg_read(dev, ID_REV) >> 16;
+	for (i = 0; chip_ids[i].id != 0; i++) {
+		if (chip_ids[i].id == val) break;
+	}
+	if (!chip_ids[i].id) {
+		printf(DRIVERNAME ": Unknown chip ID %04lx\n", val);
+		return -1;
+	}
+
+	dev->priv = (void *)&chip_ids[i];
+
+	return 0;
+}
+
+static void smc911x_reset(struct eth_device *dev)
+{
+	int timeout;
+
+	/*
+	 *  Take out of PM setting first
+	 *  Device is already wake up if PMT_CTRL_READY bit is set
+	 */
+	if ((smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) == 0) {
+		/* Write to the bytetest will take out of powerdown */
+		smc911x_reg_write(dev, BYTE_TEST, 0x0);
+
+		timeout = 10;
+
+		while (timeout-- &&
+			!(smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY))
+			udelay(10);
+		if (timeout < 0) {
+			printf(DRIVERNAME
+				": timeout waiting for PM restore\n");
+			return;
+		}
+	}
+
+	/* Disable interrupts */
+	smc911x_reg_write(dev, INT_EN, 0);
+
+	smc911x_reg_write(dev, HW_CFG, HW_CFG_SRST);
+
+	timeout = 1000;
+	while (timeout-- && smc911x_reg_read(dev, E2P_CMD) & E2P_CMD_EPC_BUSY)
+		udelay(10);
+
+	if (timeout < 0) {
+		printf(DRIVERNAME ": reset timeout\n");
+		return;
+	}
+
+	/* Reset the FIFO level and flow control settings */
+	smc911x_set_mac_csr(dev, FLOW, FLOW_FCPT | FLOW_FCEN);
+	smc911x_reg_write(dev, AFC_CFG, 0x0050287F);
+
+	/* Set to LED outputs */
+	smc911x_reg_write(dev, GPIO_CFG, 0x70070000);
+}
+
 static void smc911x_handle_mac_address(struct eth_device *dev)
 {
 	unsigned long addrh, addrl;
@@ -117,7 +273,6 @@ static void smc911x_enable(struct eth_device *dev)
 
 	smc911x_set_mac_csr(dev, MAC_CR, MAC_CR_TXEN | MAC_CR_RXEN |
 				MAC_CR_HBDIS);
-
 }
 
 static int smc911x_init(struct eth_device *dev, bd_t * bd)
diff --git a/drivers/net/smc911x.h b/drivers/net/smc911x.h
index 3145fbde2b..ce66900f4c 100644
--- a/drivers/net/smc911x.h
+++ b/drivers/net/smc911x.h
@@ -8,47 +8,6 @@
 #ifndef _SMC911X_H_
 #define _SMC911X_H_
 
-#include <linux/types.h>
-
-#define DRIVERNAME "smc911x"
-
-#if defined (CONFIG_SMC911X_32_BIT) && \
-	defined (CONFIG_SMC911X_16_BIT)
-#error "SMC911X: Only one of CONFIG_SMC911X_32_BIT and \
-	CONFIG_SMC911X_16_BIT shall be set"
-#endif
-
-#if defined (CONFIG_SMC911X_32_BIT)
-static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
-{
-	return *(volatile u32*)(dev->iobase + offset);
-}
-u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
-	__attribute__((weak, alias("__smc911x_reg_read")));
-
-static inline void __smc911x_reg_write(struct eth_device *dev,
-					u32 offset, u32 val)
-{
-	*(volatile u32*)(dev->iobase + offset) = val;
-}
-void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
-	__attribute__((weak, alias("__smc911x_reg_write")));
-#elif defined (CONFIG_SMC911X_16_BIT)
-static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
-{
-	volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
-	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
-}
-static inline void smc911x_reg_write(struct eth_device *dev,
-					u32 offset, u32 val)
-{
-	*(volatile u16 *)(dev->iobase + offset) = (u16)val;
-	*(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
-}
-#else
-#error "SMC911X: undefined bus width"
-#endif /* CONFIG_SMC911X_16_BIT */
-
 /* Below are the register offsets and bit definitions
  * of the Lan911x memory space
  */
@@ -380,120 +339,4 @@ static inline void smc911x_reg_write(struct eth_device *dev,
 #define CHIP_9220	0x9220
 #define CHIP_9221	0x9221
 
-struct chip_id {
-	u16 id;
-	char *name;
-};
-
-static const struct chip_id chip_ids[] =  {
-	{ CHIP_89218, "LAN89218" },
-	{ CHIP_9115, "LAN9115" },
-	{ CHIP_9116, "LAN9116" },
-	{ CHIP_9117, "LAN9117" },
-	{ CHIP_9118, "LAN9118" },
-	{ CHIP_9211, "LAN9211" },
-	{ CHIP_9215, "LAN9215" },
-	{ CHIP_9216, "LAN9216" },
-	{ CHIP_9217, "LAN9217" },
-	{ CHIP_9218, "LAN9218" },
-	{ CHIP_9220, "LAN9220" },
-	{ CHIP_9221, "LAN9221" },
-	{ 0, NULL },
-};
-
-static u32 smc911x_get_mac_csr(struct eth_device *dev, u8 reg)
-{
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
-		;
-	smc911x_reg_write(dev, MAC_CSR_CMD,
-			MAC_CSR_CMD_CSR_BUSY | MAC_CSR_CMD_R_NOT_W | reg);
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
-		;
-
-	return smc911x_reg_read(dev, MAC_CSR_DATA);
-}
-
-static void smc911x_set_mac_csr(struct eth_device *dev, u8 reg, u32 data)
-{
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
-		;
-	smc911x_reg_write(dev, MAC_CSR_DATA, data);
-	smc911x_reg_write(dev, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
-		;
-}
-
-static int smc911x_detect_chip(struct eth_device *dev)
-{
-	unsigned long val, i;
-
-	val = smc911x_reg_read(dev, BYTE_TEST);
-	if (val == 0xffffffff) {
-		/* Special case -- no chip present */
-		return -1;
-	} else if (val != 0x87654321) {
-		printf(DRIVERNAME ": Invalid chip endian 0x%08lx\n", val);
-		return -1;
-	}
-
-	val = smc911x_reg_read(dev, ID_REV) >> 16;
-	for (i = 0; chip_ids[i].id != 0; i++) {
-		if (chip_ids[i].id == val) break;
-	}
-	if (!chip_ids[i].id) {
-		printf(DRIVERNAME ": Unknown chip ID %04lx\n", val);
-		return -1;
-	}
-
-	dev->priv = (void *)&chip_ids[i];
-
-	return 0;
-}
-
-static void smc911x_reset(struct eth_device *dev)
-{
-	int timeout;
-
-	/*
-	 *  Take out of PM setting first
-	 *  Device is already wake up if PMT_CTRL_READY bit is set
-	 */
-	if ((smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) == 0) {
-		/* Write to the bytetest will take out of powerdown */
-		smc911x_reg_write(dev, BYTE_TEST, 0x0);
-
-		timeout = 10;
-
-		while (timeout-- &&
-			!(smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY))
-			udelay(10);
-		if (timeout < 0) {
-			printf(DRIVERNAME
-				": timeout waiting for PM restore\n");
-			return;
-		}
-	}
-
-	/* Disable interrupts */
-	smc911x_reg_write(dev, INT_EN, 0);
-
-	smc911x_reg_write(dev, HW_CFG, HW_CFG_SRST);
-
-	timeout = 1000;
-	while (timeout-- && smc911x_reg_read(dev, E2P_CMD) & E2P_CMD_EPC_BUSY)
-		udelay(10);
-
-	if (timeout < 0) {
-		printf(DRIVERNAME ": reset timeout\n");
-		return;
-	}
-
-	/* Reset the FIFO level and flow control settings */
-	smc911x_set_mac_csr(dev, FLOW, FLOW_FCPT | FLOW_FCEN);
-	smc911x_reg_write(dev, AFC_CFG, 0x0050287F);
-
-	/* Set to LED outputs */
-	smc911x_reg_write(dev, GPIO_CFG, 0x70070000);
-}
-
 #endif
diff --git a/examples/standalone/smc911x_eeprom.c b/examples/standalone/smc911x_eeprom.c
index 2c05ed902d..19ad9e6297 100644
--- a/examples/standalone/smc911x_eeprom.c
+++ b/examples/standalone/smc911x_eeprom.c
@@ -18,8 +18,164 @@
 #include <console.h>
 #include <exports.h>
 #include <linux/ctype.h>
+#include <linux/types.h>
 #include "../drivers/net/smc911x.h"
 
+#define DRIVERNAME "smc911x"
+
+#if defined (CONFIG_SMC911X_32_BIT) && \
+	defined (CONFIG_SMC911X_16_BIT)
+#error "SMC911X: Only one of CONFIG_SMC911X_32_BIT and \
+	CONFIG_SMC911X_16_BIT shall be set"
+#endif
+
+struct chip_id {
+	u16 id;
+	char *name;
+};
+
+static const struct chip_id chip_ids[] =  {
+	{ CHIP_89218, "LAN89218" },
+	{ CHIP_9115, "LAN9115" },
+	{ CHIP_9116, "LAN9116" },
+	{ CHIP_9117, "LAN9117" },
+	{ CHIP_9118, "LAN9118" },
+	{ CHIP_9211, "LAN9211" },
+	{ CHIP_9215, "LAN9215" },
+	{ CHIP_9216, "LAN9216" },
+	{ CHIP_9217, "LAN9217" },
+	{ CHIP_9218, "LAN9218" },
+	{ CHIP_9220, "LAN9220" },
+	{ CHIP_9221, "LAN9221" },
+	{ 0, NULL },
+};
+
+#if defined (CONFIG_SMC911X_32_BIT)
+static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
+{
+	return *(volatile u32*)(dev->iobase + offset);
+}
+u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+	__attribute__((weak, alias("__smc911x_reg_read")));
+
+static inline void __smc911x_reg_write(struct eth_device *dev,
+					u32 offset, u32 val)
+{
+	*(volatile u32*)(dev->iobase + offset) = val;
+}
+void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
+	__attribute__((weak, alias("__smc911x_reg_write")));
+#elif defined (CONFIG_SMC911X_16_BIT)
+static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+{
+	volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
+	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+}
+static inline void smc911x_reg_write(struct eth_device *dev,
+					u32 offset, u32 val)
+{
+	*(volatile u16 *)(dev->iobase + offset) = (u16)val;
+	*(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
+}
+#else
+#error "SMC911X: undefined bus width"
+#endif /* CONFIG_SMC911X_16_BIT */
+
+static u32 smc911x_get_mac_csr(struct eth_device *dev, u8 reg)
+{
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+	smc911x_reg_write(dev, MAC_CSR_CMD,
+			MAC_CSR_CMD_CSR_BUSY | MAC_CSR_CMD_R_NOT_W | reg);
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+
+	return smc911x_reg_read(dev, MAC_CSR_DATA);
+}
+
+static void smc911x_set_mac_csr(struct eth_device *dev, u8 reg, u32 data)
+{
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+	smc911x_reg_write(dev, MAC_CSR_DATA, data);
+	smc911x_reg_write(dev, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
+	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+		;
+}
+
+static int smc911x_detect_chip(struct eth_device *dev)
+{
+	unsigned long val, i;
+
+	val = smc911x_reg_read(dev, BYTE_TEST);
+	if (val == 0xffffffff) {
+		/* Special case -- no chip present */
+		return -1;
+	} else if (val != 0x87654321) {
+		printf(DRIVERNAME ": Invalid chip endian 0x%08lx\n", val);
+		return -1;
+	}
+
+	val = smc911x_reg_read(dev, ID_REV) >> 16;
+	for (i = 0; chip_ids[i].id != 0; i++) {
+		if (chip_ids[i].id == val) break;
+	}
+	if (!chip_ids[i].id) {
+		printf(DRIVERNAME ": Unknown chip ID %04lx\n", val);
+		return -1;
+	}
+
+	dev->priv = (void *)&chip_ids[i];
+
+	return 0;
+}
+
+static void smc911x_reset(struct eth_device *dev)
+{
+	int timeout;
+
+	/*
+	 *  Take out of PM setting first
+	 *  Device is already wake up if PMT_CTRL_READY bit is set
+	 */
+	if ((smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) == 0) {
+		/* Write to the bytetest will take out of powerdown */
+		smc911x_reg_write(dev, BYTE_TEST, 0x0);
+
+		timeout = 10;
+
+		while (timeout-- &&
+			!(smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY))
+			udelay(10);
+		if (timeout < 0) {
+			printf(DRIVERNAME
+				": timeout waiting for PM restore\n");
+			return;
+		}
+	}
+
+	/* Disable interrupts */
+	smc911x_reg_write(dev, INT_EN, 0);
+
+	smc911x_reg_write(dev, HW_CFG, HW_CFG_SRST);
+
+	timeout = 1000;
+	while (timeout-- && smc911x_reg_read(dev, E2P_CMD) & E2P_CMD_EPC_BUSY)
+		udelay(10);
+
+	if (timeout < 0) {
+		printf(DRIVERNAME ": reset timeout\n");
+		return;
+	}
+
+	/* Reset the FIFO level and flow control settings */
+	smc911x_set_mac_csr(dev, FLOW, FLOW_FCPT | FLOW_FCEN);
+	smc911x_reg_write(dev, AFC_CFG, 0x0050287F);
+
+	/* Set to LED outputs */
+	smc911x_reg_write(dev, GPIO_CFG, 0x70070000);
+}
+
 /**
  *	smsc_ctrlc - detect press of CTRL+C (common ctrlc() isnt exported!?)
  */
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (5 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 06/12] net: smc911x: Inline all functions from header file Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  0:06   ` Joe Hershberger
                     ` (2 more replies)
  2020-03-15 16:58 ` [PATCH 08/12] net: smc911x: Convert IO accessors to {read, write}{w, l}() Marek Vasut
                   ` (5 subsequent siblings)
  12 siblings, 3 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

These accessors are not overriden by any board, and even if they were,
this is something which should be handled via DM now, so remove the
weak alias option. Moreover, drop the inline keyword, as the compiler
can decide better.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c                | 14 ++++----------
 examples/standalone/smc911x_eeprom.c | 16 +++++-----------
 2 files changed, 9 insertions(+), 21 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index c806757605..d798df9ec6 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -44,28 +44,22 @@ static const struct chip_id chip_ids[] =  {
 #endif
 
 #if defined (CONFIG_SMC911X_32_BIT)
-static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
+static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
 {
 	return *(volatile u32*)(dev->iobase + offset);
 }
-u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
-	__attribute__((weak, alias("__smc911x_reg_read")));
 
-static inline void __smc911x_reg_write(struct eth_device *dev,
-					u32 offset, u32 val)
+static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
 {
 	*(volatile u32*)(dev->iobase + offset) = val;
 }
-void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
-	__attribute__((weak, alias("__smc911x_reg_write")));
 #elif defined (CONFIG_SMC911X_16_BIT)
-static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
 {
 	volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
 	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
 }
-static inline void smc911x_reg_write(struct eth_device *dev,
-					u32 offset, u32 val)
+static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
 {
 	*(volatile u16 *)(dev->iobase + offset) = (u16)val;
 	*(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
diff --git a/examples/standalone/smc911x_eeprom.c b/examples/standalone/smc911x_eeprom.c
index 19ad9e6297..270588bcf5 100644
--- a/examples/standalone/smc911x_eeprom.c
+++ b/examples/standalone/smc911x_eeprom.c
@@ -51,28 +51,22 @@ static const struct chip_id chip_ids[] =  {
 };
 
 #if defined (CONFIG_SMC911X_32_BIT)
-static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
+static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
 {
 	return *(volatile u32*)(dev->iobase + offset);
 }
-u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
-	__attribute__((weak, alias("__smc911x_reg_read")));
 
-static inline void __smc911x_reg_write(struct eth_device *dev,
-					u32 offset, u32 val)
+static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
 {
 	*(volatile u32*)(dev->iobase + offset) = val;
 }
-void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
-	__attribute__((weak, alias("__smc911x_reg_write")));
 #elif defined (CONFIG_SMC911X_16_BIT)
-static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
 {
 	volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
-	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+	return (*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16);
 }
-static inline void smc911x_reg_write(struct eth_device *dev,
-					u32 offset, u32 val)
+static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
 {
 	*(volatile u16 *)(dev->iobase + offset) = (u16)val;
 	*(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 08/12] net: smc911x: Convert IO accessors to {read, write}{w, l}()
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (6 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  0:08   ` Joe Hershberger
  2020-03-15 16:58 ` [PATCH 09/12] net: smc911x: Pass around driver private data Marek Vasut
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Convert the IO accessors to standard ones instead of using volatile
void pointers, as those do not cover all the bus access details.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index d798df9ec6..d2a7726077 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -10,6 +10,7 @@
 #include <malloc.h>
 #include <net.h>
 #include <miiphy.h>
+#include <linux/io.h>
 #include <linux/types.h>
 
 #include "smc911x.h"
@@ -46,23 +47,23 @@ static const struct chip_id chip_ids[] =  {
 #if defined (CONFIG_SMC911X_32_BIT)
 static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
 {
-	return *(volatile u32*)(dev->iobase + offset);
+	return readl(dev->iobase + offset);
 }
 
 static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
 {
-	*(volatile u32*)(dev->iobase + offset) = val;
+	writel(val, dev->iobase + offset);
 }
 #elif defined (CONFIG_SMC911X_16_BIT)
 static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
 {
-	volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
-	return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
+	return (readw(dev->iobase + offset) & 0xffff) |
+	       (readw(dev->iobase + offset + 2) << 16);
 }
 static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
 {
-	*(volatile u16 *)(dev->iobase + offset) = (u16)val;
-	*(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
+	writew(val & 0xffff, dev->iobase + offset);
+	writew(val >> 16, dev->iobase + offset + 2);
 }
 #else
 #error "SMC911X: undefined bus width"
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 09/12] net: smc911x: Pass around driver private data
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (7 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 08/12] net: smc911x: Convert IO accessors to {read, write}{w, l}() Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  0:10   ` Joe Hershberger
  2020-03-15 16:58 ` [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv() Marek Vasut
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Introduce a private data structure for this driver with embedded
struct eth_device and pass it around. This prepares the driver to
work with both DM and non-DM systems.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 234 ++++++++++++++++++++++--------------------
 1 file changed, 125 insertions(+), 109 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index d2a7726077..fc874e8d2a 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -20,6 +20,13 @@ struct chip_id {
 	char *name;
 };
 
+struct smc911x_priv {
+	struct eth_device	dev;
+	phys_addr_t		iobase;
+	const struct chip_id	*chipid;
+	unsigned char		enetaddr[6];
+};
+
 static const struct chip_id chip_ids[] =  {
 	{ CHIP_89218, "LAN89218" },
 	{ CHIP_9115, "LAN9115" },
@@ -45,57 +52,57 @@ static const struct chip_id chip_ids[] =  {
 #endif
 
 #if defined (CONFIG_SMC911X_32_BIT)
-static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+static u32 smc911x_reg_read(struct smc911x_priv *priv, u32 offset)
 {
-	return readl(dev->iobase + offset);
+	return readl(priv->iobase + offset);
 }
 
-static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
+static void smc911x_reg_write(struct smc911x_priv *priv, u32 offset, u32 val)
 {
-	writel(val, dev->iobase + offset);
+	writel(val, priv->iobase + offset);
 }
 #elif defined (CONFIG_SMC911X_16_BIT)
-static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
+static u32 smc911x_reg_read(struct smc911x_priv *priv, u32 offset)
 {
-	return (readw(dev->iobase + offset) & 0xffff) |
-	       (readw(dev->iobase + offset + 2) << 16);
+	return (readw(priv->iobase + offset) & 0xffff) |
+	       (readw(priv->iobase + offset + 2) << 16);
 }
-static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
+static void smc911x_reg_write(struct smc911x_priv *priv, u32 offset, u32 val)
 {
-	writew(val & 0xffff, dev->iobase + offset);
-	writew(val >> 16, dev->iobase + offset + 2);
+	writew(val & 0xffff, priv->iobase + offset);
+	writew(val >> 16, priv->iobase + offset + 2);
 }
 #else
 #error "SMC911X: undefined bus width"
 #endif /* CONFIG_SMC911X_16_BIT */
 
-static u32 smc911x_get_mac_csr(struct eth_device *dev, u8 reg)
+static u32 smc911x_get_mac_csr(struct smc911x_priv *priv, u8 reg)
 {
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+	while (smc911x_reg_read(priv, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
 		;
-	smc911x_reg_write(dev, MAC_CSR_CMD,
+	smc911x_reg_write(priv, MAC_CSR_CMD,
 			MAC_CSR_CMD_CSR_BUSY | MAC_CSR_CMD_R_NOT_W | reg);
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+	while (smc911x_reg_read(priv, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
 		;
 
-	return smc911x_reg_read(dev, MAC_CSR_DATA);
+	return smc911x_reg_read(priv, MAC_CSR_DATA);
 }
 
-static void smc911x_set_mac_csr(struct eth_device *dev, u8 reg, u32 data)
+static void smc911x_set_mac_csr(struct smc911x_priv *priv, u8 reg, u32 data)
 {
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+	while (smc911x_reg_read(priv, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
 		;
-	smc911x_reg_write(dev, MAC_CSR_DATA, data);
-	smc911x_reg_write(dev, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
-	while (smc911x_reg_read(dev, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
+	smc911x_reg_write(priv, MAC_CSR_DATA, data);
+	smc911x_reg_write(priv, MAC_CSR_CMD, MAC_CSR_CMD_CSR_BUSY | reg);
+	while (smc911x_reg_read(priv, MAC_CSR_CMD) & MAC_CSR_CMD_CSR_BUSY)
 		;
 }
 
-static int smc911x_detect_chip(struct eth_device *dev)
+static int smc911x_detect_chip(struct smc911x_priv *priv)
 {
 	unsigned long val, i;
 
-	val = smc911x_reg_read(dev, BYTE_TEST);
+	val = smc911x_reg_read(priv, BYTE_TEST);
 	if (val == 0xffffffff) {
 		/* Special case -- no chip present */
 		return -1;
@@ -104,7 +111,7 @@ static int smc911x_detect_chip(struct eth_device *dev)
 		return -1;
 	}
 
-	val = smc911x_reg_read(dev, ID_REV) >> 16;
+	val = smc911x_reg_read(priv, ID_REV) >> 16;
 	for (i = 0; chip_ids[i].id != 0; i++) {
 		if (chip_ids[i].id == val) break;
 	}
@@ -113,12 +120,12 @@ static int smc911x_detect_chip(struct eth_device *dev)
 		return -1;
 	}
 
-	dev->priv = (void *)&chip_ids[i];
+	priv->chipid = &chip_ids[i];
 
 	return 0;
 }
 
-static void smc911x_reset(struct eth_device *dev)
+static void smc911x_reset(struct smc911x_priv *priv)
 {
 	int timeout;
 
@@ -126,14 +133,14 @@ static void smc911x_reset(struct eth_device *dev)
 	 *  Take out of PM setting first
 	 *  Device is already wake up if PMT_CTRL_READY bit is set
 	 */
-	if ((smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY) == 0) {
+	if ((smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY) == 0) {
 		/* Write to the bytetest will take out of powerdown */
-		smc911x_reg_write(dev, BYTE_TEST, 0x0);
+		smc911x_reg_write(priv, BYTE_TEST, 0x0);
 
 		timeout = 10;
 
 		while (timeout-- &&
-			!(smc911x_reg_read(dev, PMT_CTRL) & PMT_CTRL_READY))
+			!(smc911x_reg_read(priv, PMT_CTRL) & PMT_CTRL_READY))
 			udelay(10);
 		if (timeout < 0) {
 			printf(DRIVERNAME
@@ -143,12 +150,12 @@ static void smc911x_reset(struct eth_device *dev)
 	}
 
 	/* Disable interrupts */
-	smc911x_reg_write(dev, INT_EN, 0);
+	smc911x_reg_write(priv, INT_EN, 0);
 
-	smc911x_reg_write(dev, HW_CFG, HW_CFG_SRST);
+	smc911x_reg_write(priv, HW_CFG, HW_CFG_SRST);
 
 	timeout = 1000;
-	while (timeout-- && smc911x_reg_read(dev, E2P_CMD) & E2P_CMD_EPC_BUSY)
+	while (timeout-- && smc911x_reg_read(priv, E2P_CMD) & E2P_CMD_EPC_BUSY)
 		udelay(10);
 
 	if (timeout < 0) {
@@ -157,83 +164,83 @@ static void smc911x_reset(struct eth_device *dev)
 	}
 
 	/* Reset the FIFO level and flow control settings */
-	smc911x_set_mac_csr(dev, FLOW, FLOW_FCPT | FLOW_FCEN);
-	smc911x_reg_write(dev, AFC_CFG, 0x0050287F);
+	smc911x_set_mac_csr(priv, FLOW, FLOW_FCPT | FLOW_FCEN);
+	smc911x_reg_write(priv, AFC_CFG, 0x0050287F);
 
 	/* Set to LED outputs */
-	smc911x_reg_write(dev, GPIO_CFG, 0x70070000);
+	smc911x_reg_write(priv, GPIO_CFG, 0x70070000);
 }
 
-static void smc911x_handle_mac_address(struct eth_device *dev)
+static void smc911x_handle_mac_address(struct smc911x_priv *priv)
 {
 	unsigned long addrh, addrl;
-	uchar *m = dev->enetaddr;
+	unsigned char *m = priv->enetaddr;
 
 	addrl = m[0] | (m[1] << 8) | (m[2] << 16) | (m[3] << 24);
 	addrh = m[4] | (m[5] << 8);
-	smc911x_set_mac_csr(dev, ADDRL, addrl);
-	smc911x_set_mac_csr(dev, ADDRH, addrh);
+	smc911x_set_mac_csr(priv, ADDRL, addrl);
+	smc911x_set_mac_csr(priv, ADDRH, addrh);
 
 	printf(DRIVERNAME ": MAC %pM\n", m);
 }
 
-static int smc911x_eth_phy_read(struct eth_device *dev,
+static int smc911x_eth_phy_read(struct smc911x_priv *priv,
 				u8 phy, u8 reg, u16 *val)
 {
-	while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
+	while (smc911x_get_mac_csr(priv, MII_ACC) & MII_ACC_MII_BUSY)
 		;
 
-	smc911x_set_mac_csr(dev, MII_ACC, phy << 11 | reg << 6 |
+	smc911x_set_mac_csr(priv, MII_ACC, phy << 11 | reg << 6 |
 				MII_ACC_MII_BUSY);
 
-	while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
+	while (smc911x_get_mac_csr(priv, MII_ACC) & MII_ACC_MII_BUSY)
 		;
 
-	*val = smc911x_get_mac_csr(dev, MII_DATA);
+	*val = smc911x_get_mac_csr(priv, MII_DATA);
 
 	return 0;
 }
 
-static int smc911x_eth_phy_write(struct eth_device *dev,
+static int smc911x_eth_phy_write(struct smc911x_priv *priv,
 				u8 phy, u8 reg, u16  val)
 {
-	while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
+	while (smc911x_get_mac_csr(priv, MII_ACC) & MII_ACC_MII_BUSY)
 		;
 
-	smc911x_set_mac_csr(dev, MII_DATA, val);
-	smc911x_set_mac_csr(dev, MII_ACC,
+	smc911x_set_mac_csr(priv, MII_DATA, val);
+	smc911x_set_mac_csr(priv, MII_ACC,
 		phy << 11 | reg << 6 | MII_ACC_MII_BUSY | MII_ACC_MII_WRITE);
 
-	while (smc911x_get_mac_csr(dev, MII_ACC) & MII_ACC_MII_BUSY)
+	while (smc911x_get_mac_csr(priv, MII_ACC) & MII_ACC_MII_BUSY)
 		;
 	return 0;
 }
 
-static int smc911x_phy_reset(struct eth_device *dev)
+static int smc911x_phy_reset(struct smc911x_priv *priv)
 {
 	u32 reg;
 
-	reg = smc911x_reg_read(dev, PMT_CTRL);
+	reg = smc911x_reg_read(priv, PMT_CTRL);
 	reg &= ~0xfffff030;
 	reg |= PMT_CTRL_PHY_RST;
-	smc911x_reg_write(dev, PMT_CTRL, reg);
+	smc911x_reg_write(priv, PMT_CTRL, reg);
 
 	mdelay(100);
 
 	return 0;
 }
 
-static void smc911x_phy_configure(struct eth_device *dev)
+static void smc911x_phy_configure(struct smc911x_priv *priv)
 {
 	int timeout;
 	u16 status;
 
-	smc911x_phy_reset(dev);
+	smc911x_phy_reset(priv);
 
-	smc911x_eth_phy_write(dev, 1, MII_BMCR, BMCR_RESET);
+	smc911x_eth_phy_write(priv, 1, MII_BMCR, BMCR_RESET);
 	mdelay(1);
-	smc911x_eth_phy_write(dev, 1, MII_ADVERTISE, 0x01e1);
-	smc911x_eth_phy_write(dev, 1, MII_BMCR, BMCR_ANENABLE |
+	smc911x_eth_phy_write(priv, 1, MII_ADVERTISE, 0x01e1);
+	smc911x_eth_phy_write(priv, 1, MII_BMCR, BMCR_ANENABLE |
 				BMCR_ANRESTART);
 
 	timeout = 5000;
@@ -242,7 +249,7 @@ static void smc911x_phy_configure(struct eth_device *dev)
 		if ((timeout--) == 0)
 			goto err_out;
 
-		if (smc911x_eth_phy_read(dev, 1, MII_BMSR, &status) != 0)
+		if (smc911x_eth_phy_read(priv, 1, MII_BMSR, &status) != 0)
 			goto err_out;
 	} while (!(status & BMSR_LSTATUS));
 
@@ -254,64 +261,66 @@ err_out:
 	printf(DRIVERNAME ": autonegotiation timed out\n");
 }
 
-static void smc911x_enable(struct eth_device *dev)
+static void smc911x_enable(struct smc911x_priv *priv)
 {
 	/* Enable TX */
-	smc911x_reg_write(dev, HW_CFG, 8 << 16 | HW_CFG_SF);
+	smc911x_reg_write(priv, HW_CFG, 8 << 16 | HW_CFG_SF);
 
-	smc911x_reg_write(dev, GPT_CFG, GPT_CFG_TIMER_EN | 10000);
+	smc911x_reg_write(priv, GPT_CFG, GPT_CFG_TIMER_EN | 10000);
 
-	smc911x_reg_write(dev, TX_CFG, TX_CFG_TX_ON);
+	smc911x_reg_write(priv, TX_CFG, TX_CFG_TX_ON);
 
 	/* no padding to start of packets */
-	smc911x_reg_write(dev, RX_CFG, 0);
+	smc911x_reg_write(priv, RX_CFG, 0);
 
-	smc911x_set_mac_csr(dev, MAC_CR, MAC_CR_TXEN | MAC_CR_RXEN |
+	smc911x_set_mac_csr(priv, MAC_CR, MAC_CR_TXEN | MAC_CR_RXEN |
 				MAC_CR_HBDIS);
 }
 
 static int smc911x_init(struct eth_device *dev, bd_t * bd)
 {
-	struct chip_id *id = dev->priv;
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
+	const struct chip_id *id = priv->chipid;
 
 	printf(DRIVERNAME ": detected %s controller\n", id->name);
 
-	smc911x_reset(dev);
+	smc911x_reset(priv);
 
 	/* Configure the PHY, initialize the link state */
-	smc911x_phy_configure(dev);
+	smc911x_phy_configure(priv);
 
-	smc911x_handle_mac_address(dev);
+	smc911x_handle_mac_address(priv);
 
 	/* Turn on Tx + Rx */
-	smc911x_enable(dev);
+	smc911x_enable(priv);
 
 	return 0;
 }
 
 static int smc911x_send(struct eth_device *dev, void *packet, int length)
 {
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
 	u32 *data = (u32*)packet;
 	u32 tmplen;
 	u32 status;
 
-	smc911x_reg_write(dev, TX_DATA_FIFO, TX_CMD_A_INT_FIRST_SEG |
+	smc911x_reg_write(priv, TX_DATA_FIFO, TX_CMD_A_INT_FIRST_SEG |
 				TX_CMD_A_INT_LAST_SEG | length);
-	smc911x_reg_write(dev, TX_DATA_FIFO, length);
+	smc911x_reg_write(priv, TX_DATA_FIFO, length);
 
 	tmplen = (length + 3) / 4;
 
 	while (tmplen--)
-		smc911x_reg_write(dev, TX_DATA_FIFO, *data++);
+		smc911x_reg_write(priv, TX_DATA_FIFO, *data++);
 
 	/* wait for transmission */
-	while (!((smc911x_reg_read(dev, TX_FIFO_INF) &
+	while (!((smc911x_reg_read(priv, TX_FIFO_INF) &
 					TX_FIFO_INF_TSUSED) >> 16));
 
 	/* get status. Ignore 'no carrier' error, it has no meaning for
 	 * full duplex operation
 	 */
-	status = smc911x_reg_read(dev, TX_STATUS_FIFO) &
+	status = smc911x_reg_read(priv, TX_STATUS_FIFO) &
 			(TX_STS_LOC | TX_STS_LATE_COLL | TX_STS_MANY_COLL |
 			TX_STS_MANY_DEFER | TX_STS_UNDERRUN);
 
@@ -330,25 +339,28 @@ static int smc911x_send(struct eth_device *dev, void *packet, int length)
 
 static void smc911x_halt(struct eth_device *dev)
 {
-	smc911x_reset(dev);
-	smc911x_handle_mac_address(dev);
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
+
+	smc911x_reset(priv);
+	smc911x_handle_mac_address(priv);
 }
 
 static int smc911x_recv(struct eth_device *dev)
 {
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
 	u32 *data = (u32 *)net_rx_packets[0];
 	u32 pktlen, tmplen;
 	u32 status;
 
-	if ((smc911x_reg_read(dev, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16) {
-		status = smc911x_reg_read(dev, RX_STATUS_FIFO);
+	if ((smc911x_reg_read(priv, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16) {
+		status = smc911x_reg_read(priv, RX_STATUS_FIFO);
 		pktlen = (status & RX_STS_PKT_LEN) >> 16;
 
-		smc911x_reg_write(dev, RX_CFG, 0);
+		smc911x_reg_write(priv, RX_CFG, 0);
 
 		tmplen = (pktlen + 3) / 4;
 		while (tmplen--)
-			*data++ = smc911x_reg_read(dev, RX_DATA_FIFO);
+			*data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
 
 		if (status & RX_STS_ES)
 			printf(DRIVERNAME
@@ -367,87 +379,91 @@ static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad,
 			       int reg)
 {
 	struct eth_device *dev = eth_get_dev_by_name(bus->name);
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
 	u16 val = 0;
 	int ret;
 
-	if (!dev)
+	if (!dev || !priv)
 		return -ENODEV;
 
-	ret = smc911x_eth_phy_read(dev, phy, reg, &val);
+	ret = smc911x_eth_phy_read(priv, phy, reg, &val);
 	if (ret < 0)
 		return ret;
 
 	return val;
 }
+
 /* wrapper for smc911x_eth_phy_write */
 static int smc911x_miiphy_write(struct mii_dev *bus, int phy, int devad,
 				int reg, u16 val)
 {
 	struct eth_device *dev = eth_get_dev_by_name(bus->name);
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
 
-	if (!dev)
+	if (!dev || !priv)
 		return -ENODEV;
 
-	return smc911x_eth_phy_write(dev, phy, reg, val);
+	return smc911x_eth_phy_write(priv, phy, reg, val);
 }
 #endif
 
 int smc911x_initialize(u8 dev_num, int base_addr)
 {
 	unsigned long addrl, addrh;
-	struct eth_device *dev;
+	struct smc911x_priv *priv;
 
-	dev = calloc(1, sizeof(*dev));
-	if (!dev) {
+	priv = calloc(1, sizeof(*priv));
+	if (!priv)
 		return -ENODEV;
-	}
 
-	dev->iobase = base_addr;
+	priv->iobase = base_addr;
+	priv->dev.iobase = base_addr;
 
 	/* Try to detect chip. Will fail if not present. */
-	if (smc911x_detect_chip(dev)) {
-		free(dev);
+	if (smc911x_detect_chip(priv)) {
+		free(priv);
 		return 0;
 	}
 
-	addrh = smc911x_get_mac_csr(dev, ADDRH);
-	addrl = smc911x_get_mac_csr(dev, ADDRL);
+	addrh = smc911x_get_mac_csr(priv, ADDRH);
+	addrl = smc911x_get_mac_csr(priv, ADDRL);
 	if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
 		/* address is obtained from optional eeprom */
-		dev->enetaddr[0] = addrl;
-		dev->enetaddr[1] = addrl >>  8;
-		dev->enetaddr[2] = addrl >> 16;
-		dev->enetaddr[3] = addrl >> 24;
-		dev->enetaddr[4] = addrh;
-		dev->enetaddr[5] = addrh >> 8;
+		priv->enetaddr[0] = addrl;
+		priv->enetaddr[1] = addrl >>  8;
+		priv->enetaddr[2] = addrl >> 16;
+		priv->enetaddr[3] = addrl >> 24;
+		priv->enetaddr[4] = addrh;
+		priv->enetaddr[5] = addrh >> 8;
 	}
 
-	dev->init = smc911x_init;
-	dev->halt = smc911x_halt;
-	dev->send = smc911x_send;
-	dev->recv = smc911x_recv;
-	sprintf(dev->name, "%s-%hu", DRIVERNAME, dev_num);
+	priv->dev.init = smc911x_init;
+	priv->dev.halt = smc911x_halt;
+	priv->dev.send = smc911x_send;
+	priv->dev.recv = smc911x_recv;
+	sprintf(priv->dev.name, "%s-%hu", DRIVERNAME, dev_num);
 
-	eth_register(dev);
+	eth_register(&priv->dev);
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 	int retval;
 	struct mii_dev *mdiodev = mdio_alloc();
+
 	if (!mdiodev) {
-		eth_unregister(dev);
-		free(dev);
+		eth_unregister(&priv->dev);
+		free(priv);
 		return -ENOMEM;
 	}
 
-	strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
+	strncpy(mdiodev->name, priv->dev.name, MDIO_NAME_LEN);
 	mdiodev->read = smc911x_miiphy_read;
 	mdiodev->write = smc911x_miiphy_write;
 
 	retval = mdio_register(mdiodev);
 	if (retval < 0) {
 		mdio_free(mdiodev);
-		eth_unregister(dev);
-		free(dev);
+		eth_unregister(&priv->dev);
+		free(priv);
 		return retval;
 	}
 #endif
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv()
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (8 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 09/12] net: smc911x: Pass around driver private data Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  6:30   ` Masahiro Yamada
  2020-03-17 17:07   ` Joe Hershberger
  2020-03-15 16:58 ` [PATCH 11/12] net: smc911x: Split non-DM specific bits from common code Marek Vasut
                   ` (2 subsequent siblings)
  12 siblings, 2 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Invest the status handling logic in smc911x_recv(), to make the
function easier to read, no functional change.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index fc874e8d2a..a6da586448 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -352,23 +352,26 @@ static int smc911x_recv(struct eth_device *dev)
 	u32 pktlen, tmplen;
 	u32 status;
 
-	if ((smc911x_reg_read(priv, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16) {
-		status = smc911x_reg_read(priv, RX_STATUS_FIFO);
-		pktlen = (status & RX_STS_PKT_LEN) >> 16;
+	status = smc911x_reg_read(priv, RX_FIFO_INF);
+	status = (status & RX_FIFO_INF_RXSUSED) >> 16;
+	if (!status)
+		return 0;
 
-		smc911x_reg_write(priv, RX_CFG, 0);
+	status = smc911x_reg_read(priv, RX_STATUS_FIFO);
+	pktlen = (status & RX_STS_PKT_LEN) >> 16;
 
-		tmplen = (pktlen + 3) / 4;
-		while (tmplen--)
-			*data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
+	smc911x_reg_write(priv, RX_CFG, 0);
 
-		if (status & RX_STS_ES)
-			printf(DRIVERNAME
-				": dropped bad packet. Status: 0x%08x\n",
-				status);
-		else
-			net_process_received_packet(net_rx_packets[0], pktlen);
-	}
+	tmplen = (pktlen + 3) / 4;
+	while (tmplen--)
+		*data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
+
+	if (status & RX_STS_ES)
+		printf(DRIVERNAME
+			": dropped bad packet. Status: 0x%08x\n",
+			status);
+	else
+		net_process_received_packet(net_rx_packets[0], pktlen);
 
 	return 0;
 }
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 11/12] net: smc911x: Split non-DM specific bits from common code
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (9 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv() Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17 17:09   ` Joe Hershberger
  2020-03-15 16:58 ` [PATCH 12/12] net: smc911x: Add DM support Marek Vasut
  2020-03-17  6:17 ` [PATCH 00/12] net: smc911x: Convert to DM Masahiro Yamada
  12 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Split network handling functions into non-DM specific parts and
common code in preparation for conversion to DM.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 drivers/net/smc911x.c | 57 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 14 deletions(-)

diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index a6da586448..71c7a2e632 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -277,9 +277,8 @@ static void smc911x_enable(struct smc911x_priv *priv)
 				MAC_CR_HBDIS);
 }
 
-static int smc911x_init(struct eth_device *dev, bd_t * bd)
+static int smc911x_init_common(struct smc911x_priv *priv)
 {
-	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
 	const struct chip_id *id = priv->chipid;
 
 	printf(DRIVERNAME ": detected %s controller\n", id->name);
@@ -297,9 +296,9 @@ static int smc911x_init(struct eth_device *dev, bd_t * bd)
 	return 0;
 }
 
-static int smc911x_send(struct eth_device *dev, void *packet, int length)
+static int smc911x_send_common(struct smc911x_priv *priv,
+			       void *packet, int length)
 {
-	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
 	u32 *data = (u32*)packet;
 	u32 tmplen;
 	u32 status;
@@ -337,18 +336,14 @@ static int smc911x_send(struct eth_device *dev, void *packet, int length)
 	return -1;
 }
 
-static void smc911x_halt(struct eth_device *dev)
+static void smc911x_halt_common(struct smc911x_priv *priv)
 {
-	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
-
 	smc911x_reset(priv);
 	smc911x_handle_mac_address(priv);
 }
 
-static int smc911x_recv(struct eth_device *dev)
+static int smc911x_recv_common(struct smc911x_priv *priv, u32 *data)
 {
-	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
-	u32 *data = (u32 *)net_rx_packets[0];
 	u32 pktlen, tmplen;
 	u32 status;
 
@@ -366,14 +361,14 @@ static int smc911x_recv(struct eth_device *dev)
 	while (tmplen--)
 		*data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
 
-	if (status & RX_STS_ES)
+	if (status & RX_STS_ES) {
 		printf(DRIVERNAME
 			": dropped bad packet. Status: 0x%08x\n",
 			status);
-	else
-		net_process_received_packet(net_rx_packets[0], pktlen);
+		return 0;
+	}
 
-	return 0;
+	return pktlen;
 }
 
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
@@ -410,6 +405,40 @@ static int smc911x_miiphy_write(struct mii_dev *bus, int phy, int devad,
 }
 #endif
 
+static int smc911x_init(struct eth_device *dev, bd_t *bd)
+{
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
+
+	return smc911x_init_common(priv);
+}
+
+static void smc911x_halt(struct eth_device *dev)
+{
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
+
+	smc911x_halt_common(priv);
+}
+
+static int smc911x_send(struct eth_device *dev, void *packet, int length)
+{
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
+
+	return smc911x_send_common(priv, packet, length);
+}
+
+static int smc911x_recv(struct eth_device *dev)
+{
+	struct smc911x_priv *priv = container_of(dev, struct smc911x_priv, dev);
+	u32 *data = (u32 *)net_rx_packets[0];
+	int ret;
+
+	ret = smc911x_recv_common(priv, data);
+	if (ret)
+		net_process_received_packet(net_rx_packets[0], ret);
+
+	return ret;
+}
+
 int smc911x_initialize(u8 dev_num, int base_addr)
 {
 	unsigned long addrl, addrh;
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 12/12] net: smc911x: Add DM support
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (10 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 11/12] net: smc911x: Split non-DM specific bits from common code Marek Vasut
@ 2020-03-15 16:58 ` Marek Vasut
  2020-03-17  6:55   ` Masahiro Yamada
  2020-03-17 17:20   ` Joe Hershberger
  2020-03-17  6:17 ` [PATCH 00/12] net: smc911x: Convert to DM Masahiro Yamada
  12 siblings, 2 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-15 16:58 UTC (permalink / raw)
  To: u-boot

Add support for U-Boot DM and DT probing. Furthermore, build the
SMC911x standalone EEPROM example only for the non-DM case, as it
is not converted yet.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
---
 board/renesas/blanche/blanche.c |   2 +
 drivers/net/smc911x.c           | 114 ++++++++++++++++++++++++++++++++
 examples/standalone/Makefile    |   5 +-
 3 files changed, 120 insertions(+), 1 deletion(-)

diff --git a/board/renesas/blanche/blanche.c b/board/renesas/blanche/blanche.c
index 7232370d6f..eec1dde106 100644
--- a/board/renesas/blanche/blanche.c
+++ b/board/renesas/blanche/blanche.c
@@ -313,6 +313,7 @@ int board_init(void)
 }
 
 /* Added for BLANCHE(R-CarV2H board) */
+#ifndef CONFIG_DM_ETH
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
@@ -337,6 +338,7 @@ int board_eth_init(bd_t *bis)
 
 	return rc;
 }
+#endif
 
 int dram_init(void)
 {
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
index 71c7a2e632..8abc5e97ac 100644
--- a/drivers/net/smc911x.c
+++ b/drivers/net/smc911x.c
@@ -21,7 +21,9 @@ struct chip_id {
 };
 
 struct smc911x_priv {
+#ifndef CONFIG_DM_ETH
 	struct eth_device	dev;
+#endif
 	phys_addr_t		iobase;
 	const struct chip_id	*chipid;
 	unsigned char		enetaddr[6];
@@ -371,6 +373,8 @@ static int smc911x_recv_common(struct smc911x_priv *priv, u32 *data)
 	return pktlen;
 }
 
+#ifndef CONFIG_DM_ETH
+
 #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 /* wrapper for smc911x_eth_phy_read */
 static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad,
@@ -502,3 +506,113 @@ int smc911x_initialize(u8 dev_num, int base_addr)
 
 	return 1;
 }
+
+#else	/* ifdef CONFIG_DM_ETH */
+
+static int smc911x_start(struct udevice *dev)
+{
+	struct eth_pdata *plat = dev_get_platdata(dev);
+	struct smc911x_priv *priv = dev_get_priv(dev);
+
+	memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr));
+
+	return smc911x_init_common(priv);
+}
+
+static void smc911x_stop(struct udevice *dev)
+{
+	struct smc911x_priv *priv = dev_get_priv(dev);
+
+	smc911x_halt_common(priv);
+}
+
+static int smc911x_send(struct udevice *dev, void *packet, int length)
+{
+	struct smc911x_priv *priv = dev_get_priv(dev);
+	int ret;
+
+	ret = smc911x_send_common(priv, packet, length);
+
+	return ret ? 0 : -ETIMEDOUT;
+}
+
+static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+	struct smc911x_priv *priv = dev_get_priv(dev);
+	u32 *data = (u32 *)net_rx_packets[0];
+	int ret;
+
+	ret = smc911x_recv_common(priv, data);
+	if (ret)
+		*packetp = (void *)data;
+
+	return ret ? ret : -EAGAIN;
+}
+
+static int smc911x_bind(struct udevice *dev)
+{
+	return device_set_name(dev, dev->name);
+}
+
+static int smc911x_probe(struct udevice *dev)
+{
+	struct smc911x_priv *priv = dev_get_priv(dev);
+	unsigned long addrh, addrl;
+	int ret;
+
+	/* Try to detect chip. Will fail if not present. */
+	ret = smc911x_detect_chip(priv);
+	if (ret)
+		return ret;
+
+	addrh = smc911x_get_mac_csr(priv, ADDRH);
+	addrl = smc911x_get_mac_csr(priv, ADDRL);
+	if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
+		/* address is obtained from optional eeprom */
+		priv->enetaddr[0] = addrl;
+		priv->enetaddr[1] = addrl >>  8;
+		priv->enetaddr[2] = addrl >> 16;
+		priv->enetaddr[3] = addrl >> 24;
+		priv->enetaddr[4] = addrh;
+		priv->enetaddr[5] = addrh >> 8;
+	}
+
+	return 0;
+}
+
+static int smc911x_ofdata_to_platdata(struct udevice *dev)
+{
+	struct smc911x_priv *priv = dev_get_priv(dev);
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+
+	pdata->iobase = devfdt_get_addr(dev);
+	priv->iobase = pdata->iobase;
+
+	return 0;
+}
+
+static const struct eth_ops smc911x_ops = {
+	.start	= smc911x_start,
+	.send	= smc911x_send,
+	.recv	= smc911x_recv,
+	.stop	= smc911x_stop,
+};
+
+static const struct udevice_id smc911x_ids[] = {
+	{ .compatible = "smsc,lan9115" },
+	{ }
+};
+
+U_BOOT_DRIVER(smc911x) = {
+	.name		= "eth_smc911x",
+	.id		= UCLASS_ETH,
+	.of_match	= smc911x_ids,
+	.bind		= smc911x_bind,
+	.ofdata_to_platdata = smc911x_ofdata_to_platdata,
+	.probe		= smc911x_probe,
+	.ops		= &smc911x_ops,
+	.priv_auto_alloc_size = sizeof(struct smc911x_priv),
+	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
+	.flags		= DM_FLAG_ALLOC_PRIV_DMA,
+};
+#endif
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 0b17a91804..6b061bac69 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -5,10 +5,13 @@
 
 extra-y        := hello_world
 extra-$(CONFIG_SMC91111)           += smc91111_eeprom
-extra-$(CONFIG_SMC911X)            += smc911x_eeprom
 extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
 extra-$(CONFIG_PPC)                += sched
 
+ifndef CONFIG_DM_ETH
+extra-$(CONFIG_SMC911X)            += smc911x_eeprom
+endif
+
 #
 # Some versions of make do not handle trailing white spaces properly;
 # leading to build failures. The problem was found with GNU Make 3.80.
-- 
2.25.0

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull}
  2020-03-15 16:58 ` [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull} Marek Vasut
@ 2020-03-16 23:52   ` Joe Hershberger
  0 siblings, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-16 23:52 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 11:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> These functions are never used and are likely a pre-DM remnant
> from times long past, just remove them.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc()
  2020-03-15 16:58 ` [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc() Marek Vasut
@ 2020-03-16 23:58   ` Joe Hershberger
  2020-03-17  6:20   ` Masahiro Yamada
  1 sibling, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-16 23:58 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:00 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Replace combination of malloc()+memset() with calloc() as the behavior
> is exactly the same and the amount of code is reduced.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path
  2020-03-15 16:58 ` [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path Marek Vasut
@ 2020-03-17  0:03   ` Joe Hershberger
  2020-03-17  6:21   ` Masahiro Yamada
  1 sibling, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17  0:03 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 11:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Fix memleak in the init fail path, where if allocation or registration
> of MDIO bus fails, then ethernet interface is not unregistered and the
> private data are not freed, yet the probe function reports a failure.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 06/12] net: smc911x: Inline all functions from header file
  2020-03-15 16:58 ` [PATCH 06/12] net: smc911x: Inline all functions from header file Marek Vasut
@ 2020-03-17  0:06   ` Joe Hershberger
  2020-03-17  6:25   ` Masahiro Yamada
  1 sibling, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17  0:06 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:00 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Inline all the functions from the header file, as they are not used
> outside of the driver or the standalone EEPROM example.
>
> Note that this does introduce considerable amount of duplication in
> the standalone EEPROM example, however that one has to be rewritten
> anyway, roughly such that the SMC911x driver would expose DM EEPROM
> interface and the standalone example would use that.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors
  2020-03-15 16:58 ` [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors Marek Vasut
@ 2020-03-17  0:06   ` Joe Hershberger
  2020-03-17  6:27   ` Masahiro Yamada
  2020-03-17  6:45   ` Masahiro Yamada
  2 siblings, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17  0:06 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:00 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> These accessors are not overriden by any board, and even if they were,
> this is something which should be handled via DM now, so remove the
> weak alias option. Moreover, drop the inline keyword, as the compiler
> can decide better.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 08/12] net: smc911x: Convert IO accessors to {read, write}{w, l}()
  2020-03-15 16:58 ` [PATCH 08/12] net: smc911x: Convert IO accessors to {read, write}{w, l}() Marek Vasut
@ 2020-03-17  0:08   ` Joe Hershberger
  0 siblings, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17  0:08 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:00 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Convert the IO accessors to standard ones instead of using volatile
> void pointers, as those do not cover all the bus access details.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 09/12] net: smc911x: Pass around driver private data
  2020-03-15 16:58 ` [PATCH 09/12] net: smc911x: Pass around driver private data Marek Vasut
@ 2020-03-17  0:10   ` Joe Hershberger
  0 siblings, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17  0:10 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:01 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Introduce a private data structure for this driver with embedded
> struct eth_device and pass it around. This prepares the driver to
> work with both DM and non-DM systems.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 00/12] net: smc911x: Convert to DM
  2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
                   ` (11 preceding siblings ...)
  2020-03-15 16:58 ` [PATCH 12/12] net: smc911x: Add DM support Marek Vasut
@ 2020-03-17  6:17 ` Masahiro Yamada
  2020-03-21 16:52   ` Marek Vasut
  12 siblings, 1 reply; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:17 UTC (permalink / raw)
  To: u-boot

Hi Marek,


On Mon, Mar 16, 2020 at 1:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Perform DM conversion of the SMC911x driver. Note that as I do not have
> any hardware with this chip, I only compile-tested this conversion. But
> it seems Yamada-san has one, so please test.

With a quick test on my board, it worked for me.

I will leave comments to each patch, but
they are mostly nit-picking.

Thanks for the cleanups and the conversion.




>
> Note that the DT compatible is set only for 9115 , so this might need
> to be changed.
>
> Note that this is compile-tested, but not hardware tested, so please do
> send me patches, thanks.
>
> Marek Vasut (12):
>   net: smc911x: Remove pkt_data_{push,pull}
>   net: smc911x: Replace malloc()+memset() with calloc()
>   net: smc911x: Rename smc911x_rx() to smc911x_recv()
>   net: smc911x: Invert the logic in smc911x_miiphy_{read,write}()
>   net: smc911x: Fix potential memleak() in init fail path
>   net: smc911x: Inline all functions from header file
>   net: smc911x: Drop weak alias from 32bit accessors
>   net: smc911x: Convert IO accessors to {read,write}{w,l}()
>   net: smc911x: Pass around driver private data
>   net: smc911x: Clean up the status handling in smc911x_recv()
>   net: smc911x: Split non-DM specific bits from common code
>   net: smc911x: Add DM support
>
>  board/renesas/blanche/blanche.c      |   2 +
>  drivers/net/smc911x.c                | 523 +++++++++++++++++++++------
>  drivers/net/smc911x.h                | 157 --------
>  examples/standalone/Makefile         |   5 +-
>  examples/standalone/smc911x_eeprom.c | 150 ++++++++
>  5 files changed, 577 insertions(+), 260 deletions(-)
>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>
> --
> 2.25.0
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc()
  2020-03-15 16:58 ` [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc() Marek Vasut
  2020-03-16 23:58   ` Joe Hershberger
@ 2020-03-17  6:20   ` Masahiro Yamada
  1 sibling, 0 replies; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:20 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 2:00 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Replace combination of malloc()+memset() with calloc() as the behavior
> is exactly the same and the amount of code is reduced.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>  drivers/net/smc911x.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 24b4eaeb3f..a78b7817ac 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -242,11 +242,10 @@ int smc911x_initialize(u8 dev_num, int base_addr)
>         unsigned long addrl, addrh;
>         struct eth_device *dev;
>
> -       dev = malloc(sizeof(*dev));
> +       dev = calloc(1, sizeof(*dev));
>         if (!dev) {
>                 return -1;
>         }
> -       memset(dev, 0, sizeof(*dev));
>
>         dev->iobase = base_addr;
>



My personal preference is kzalloc(), but
the reason is just I am addicted to Linux.
So, I do not mind this.

(Another reason I tend to avoid calloc() is I always
forget the order of 'nmemb' and 'size' arguments)


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path
  2020-03-15 16:58 ` [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path Marek Vasut
  2020-03-17  0:03   ` Joe Hershberger
@ 2020-03-17  6:21   ` Masahiro Yamada
  2020-03-21 16:30     ` Marek Vasut
  1 sibling, 1 reply; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:21 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 1:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Fix memleak in the init fail path, where if allocation or registration
> of MDIO bus fails, then ethernet interface is not unregistered and the
> private data are not freed, yet the probe function reports a failure.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>  drivers/net/smc911x.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 81f8f0d017..44cb45af61 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -249,7 +249,7 @@ int smc911x_initialize(u8 dev_num, int base_addr)
>
>         dev = calloc(1, sizeof(*dev));
>         if (!dev) {
> -               return -1;
> +               return -ENODEV;
>         }


Our convention is to return -ENOMEM
when memory allocation fails.

If you like to do some additional cleanups here,
you can remove the unneeded braces around the single
statement, which will fix the checkpatch warning.



>
>         dev->iobase = base_addr;
> @@ -283,15 +283,23 @@ int smc911x_initialize(u8 dev_num, int base_addr)
>  #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
>         int retval;
>         struct mii_dev *mdiodev = mdio_alloc();
> -       if (!mdiodev)
> +       if (!mdiodev) {
> +               eth_unregister(dev);
> +               free(dev);
>                 return -ENOMEM;
> +       }
> +
>         strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
>         mdiodev->read = smc911x_miiphy_read;
>         mdiodev->write = smc911x_miiphy_write;
>
>         retval = mdio_register(mdiodev);
> -       if (retval < 0)
> +       if (retval < 0) {
> +               mdio_free(mdiodev);
> +               eth_unregister(dev);
> +               free(dev);
>                 return retval;


Using "goto <label>" is a general tip to
simplify the failure path.



> +       }
>  #endif
>
>         return 1;
> --
> 2.25.0
>

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 06/12] net: smc911x: Inline all functions from header file
  2020-03-15 16:58 ` [PATCH 06/12] net: smc911x: Inline all functions from header file Marek Vasut
  2020-03-17  0:06   ` Joe Hershberger
@ 2020-03-17  6:25   ` Masahiro Yamada
  1 sibling, 0 replies; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:25 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 2:00 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Inline all the functions from the header file, as they are not used
> outside of the driver or the standalone EEPROM example.

Meh for 'static inline' in .c files,
but you will rip it off in the next commit.
So, the resulted code seems good.

(I would drop inline when I move the code, though...)




>
> Note that this does introduce considerable amount of duplication in
> the standalone EEPROM example, however that one has to be rewritten
> anyway, roughly such that the SMC911x driver would expose DM EEPROM
> interface and the standalone example would use that.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---


--
Best Regards

Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors
  2020-03-15 16:58 ` [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors Marek Vasut
  2020-03-17  0:06   ` Joe Hershberger
@ 2020-03-17  6:27   ` Masahiro Yamada
  2020-03-17  6:45   ` Masahiro Yamada
  2 siblings, 0 replies; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:27 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 2:00 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> These accessors are not overriden by any board, and even if they were,
> this is something which should be handled via DM now, so remove the
> weak alias option. Moreover, drop the inline keyword, as the compiler
> can decide better.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>


This is good.


I would swap the patch order 06 and 07 so that
I would need to touch only one file, though.




> ---
>  drivers/net/smc911x.c                | 14 ++++----------
>  examples/standalone/smc911x_eeprom.c | 16 +++++-----------
>  2 files changed, 9 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index c806757605..d798df9ec6 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -44,28 +44,22 @@ static const struct chip_id chip_ids[] =  {
>  #endif
>
>  #if defined (CONFIG_SMC911X_32_BIT)
> -static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
> +static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
>  {
>         return *(volatile u32*)(dev->iobase + offset);
>  }
> -u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
> -       __attribute__((weak, alias("__smc911x_reg_read")));
>
> -static inline void __smc911x_reg_write(struct eth_device *dev,
> -                                       u32 offset, u32 val)
> +static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
>  {
>         *(volatile u32*)(dev->iobase + offset) = val;
>  }
> -void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
> -       __attribute__((weak, alias("__smc911x_reg_write")));
>  #elif defined (CONFIG_SMC911X_16_BIT)
> -static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
> +static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
>  {
>         volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
>         return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
>  }
> -static inline void smc911x_reg_write(struct eth_device *dev,
> -                                       u32 offset, u32 val)
> +static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
>  {
>         *(volatile u16 *)(dev->iobase + offset) = (u16)val;
>         *(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
> diff --git a/examples/standalone/smc911x_eeprom.c b/examples/standalone/smc911x_eeprom.c
> index 19ad9e6297..270588bcf5 100644
> --- a/examples/standalone/smc911x_eeprom.c
> +++ b/examples/standalone/smc911x_eeprom.c
> @@ -51,28 +51,22 @@ static const struct chip_id chip_ids[] =  {
>  };
>
>  #if defined (CONFIG_SMC911X_32_BIT)
> -static inline u32 __smc911x_reg_read(struct eth_device *dev, u32 offset)
> +static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
>  {
>         return *(volatile u32*)(dev->iobase + offset);
>  }
> -u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
> -       __attribute__((weak, alias("__smc911x_reg_read")));
>
> -static inline void __smc911x_reg_write(struct eth_device *dev,
> -                                       u32 offset, u32 val)
> +static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
>  {
>         *(volatile u32*)(dev->iobase + offset) = val;
>  }
> -void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
> -       __attribute__((weak, alias("__smc911x_reg_write")));
>  #elif defined (CONFIG_SMC911X_16_BIT)
> -static inline u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
> +static u32 smc911x_reg_read(struct eth_device *dev, u32 offset)
>  {
>         volatile u16 *addr_16 = (u16 *)(dev->iobase + offset);
> -       return ((*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16));
> +       return (*addr_16 & 0x0000ffff) | (*(addr_16 + 1) << 16);
>  }
> -static inline void smc911x_reg_write(struct eth_device *dev,
> -                                       u32 offset, u32 val)
> +static void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)
>  {
>         *(volatile u16 *)(dev->iobase + offset) = (u16)val;
>         *(volatile u16 *)(dev->iobase + offset + 2) = (u16)(val >> 16);
> --
> 2.25.0
>

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv()
  2020-03-15 16:58 ` [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv() Marek Vasut
@ 2020-03-17  6:30   ` Masahiro Yamada
  2020-03-17 17:07   ` Joe Hershberger
  1 sibling, 0 replies; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:30 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 2:01 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Invest the status handling logic in smc911x_recv(), to make the
> function easier to read, no functional change.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>  drivers/net/smc911x.c | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index fc874e8d2a..a6da586448 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -352,23 +352,26 @@ static int smc911x_recv(struct eth_device *dev)
>         u32 pktlen, tmplen;
>         u32 status;
>
> -       if ((smc911x_reg_read(priv, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16) {
> -               status = smc911x_reg_read(priv, RX_STATUS_FIFO);
> -               pktlen = (status & RX_STS_PKT_LEN) >> 16;
> +       status = smc911x_reg_read(priv, RX_FIFO_INF);
> +       status = (status & RX_FIFO_INF_RXSUSED) >> 16;
> +       if (!status)
> +               return 0;


If you are only interested in whether the
RX_FIFO_INF_RXSUSED field is zero or not,
">> 16" seems unneeded.


    status = smc911x_reg_read(priv, RX_FIFO_INF);
    if (!(status & RX_FIFO_INF_RXSUSED))
            return 0;

is simpler.



> -               smc911x_reg_write(priv, RX_CFG, 0);
> +       status = smc911x_reg_read(priv, RX_STATUS_FIFO);
> +       pktlen = (status & RX_STS_PKT_LEN) >> 16;
>
> -               tmplen = (pktlen + 3) / 4;
> -               while (tmplen--)
> -                       *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
> +       smc911x_reg_write(priv, RX_CFG, 0);
>
> -               if (status & RX_STS_ES)
> -                       printf(DRIVERNAME
> -                               ": dropped bad packet. Status: 0x%08x\n",
> -                               status);
> -               else
> -                       net_process_received_packet(net_rx_packets[0], pktlen);
> -       }
> +       tmplen = (pktlen + 3) / 4;
> +       while (tmplen--)
> +               *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
> +
> +       if (status & RX_STS_ES)
> +               printf(DRIVERNAME
> +                       ": dropped bad packet. Status: 0x%08x\n",
> +                       status);
> +       else
> +               net_process_received_packet(net_rx_packets[0], pktlen);
>
>         return 0;
>  }
> --
> 2.25.0
>

-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors
  2020-03-15 16:58 ` [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors Marek Vasut
  2020-03-17  0:06   ` Joe Hershberger
  2020-03-17  6:27   ` Masahiro Yamada
@ 2020-03-17  6:45   ` Masahiro Yamada
  2 siblings, 0 replies; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:45 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 2:00 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> These accessors are not overriden by any board, and even if they were,

One more nit.

overriden -> overridden



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 12/12] net: smc911x: Add DM support
  2020-03-15 16:58 ` [PATCH 12/12] net: smc911x: Add DM support Marek Vasut
@ 2020-03-17  6:55   ` Masahiro Yamada
  2020-03-21 16:51     ` Marek Vasut
  2020-03-17 17:20   ` Joe Hershberger
  1 sibling, 1 reply; 36+ messages in thread
From: Masahiro Yamada @ 2020-03-17  6:55 UTC (permalink / raw)
  To: u-boot

On Mon, Mar 16, 2020 at 2:01 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Add support for U-Boot DM and DT probing. Furthermore, build the
> SMC911x standalone EEPROM example only for the non-DM case, as it
> is not converted yet.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>  board/renesas/blanche/blanche.c |   2 +


Do you need to touch this board in the same commit?
It is unclear to me why.


One more thing, CONFIG_SMC911X_BASE is only used for
non DM_ETH case.

So, can you hide this config option?

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 4d1013c98466..dcda139156f0 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -390,6 +390,7 @@ if SMC911X

 config SMC911X_BASE
        hex "SMC911X Base Address"
+       depends on !DM_ETH
        help
          Define this to hold the physical address
          of the device (I/O space)


Lastly, mismatch between From: and Signed-off-by.

Without "+renesas" in From,
With "+renesas" in Signed-off-by.

So that you are paid correctly for this work. Just in case.  :)


Anyway, this series worked for me with DM_ETH=y.
Good work. Thanks.









>  drivers/net/smc911x.c           | 114 ++++++++++++++++++++++++++++++++
>  examples/standalone/Makefile    |   5 +-
>  3 files changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/board/renesas/blanche/blanche.c b/board/renesas/blanche/blanche.c
> index 7232370d6f..eec1dde106 100644
> --- a/board/renesas/blanche/blanche.c
> +++ b/board/renesas/blanche/blanche.c
> @@ -313,6 +313,7 @@ int board_init(void)
>  }
>
>  /* Added for BLANCHE(R-CarV2H board) */
> +#ifndef CONFIG_DM_ETH
>  int board_eth_init(bd_t *bis)
>  {
>         int rc = 0;
> @@ -337,6 +338,7 @@ int board_eth_init(bd_t *bis)
>
>         return rc;
>  }
> +#endif
>
>  int dram_init(void)
>  {
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 71c7a2e632..8abc5e97ac 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -21,7 +21,9 @@ struct chip_id {
>  };
>
>  struct smc911x_priv {
> +#ifndef CONFIG_DM_ETH
>         struct eth_device       dev;
> +#endif
>         phys_addr_t             iobase;
>         const struct chip_id    *chipid;
>         unsigned char           enetaddr[6];
> @@ -371,6 +373,8 @@ static int smc911x_recv_common(struct smc911x_priv *priv, u32 *data)
>         return pktlen;
>  }
>
> +#ifndef CONFIG_DM_ETH
> +
>  #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
>  /* wrapper for smc911x_eth_phy_read */
>  static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad,
> @@ -502,3 +506,113 @@ int smc911x_initialize(u8 dev_num, int base_addr)
>
>         return 1;
>  }
> +
> +#else  /* ifdef CONFIG_DM_ETH */
> +
> +static int smc911x_start(struct udevice *dev)
> +{
> +       struct eth_pdata *plat = dev_get_platdata(dev);
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +
> +       memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr));
> +
> +       return smc911x_init_common(priv);
> +}
> +
> +static void smc911x_stop(struct udevice *dev)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +
> +       smc911x_halt_common(priv);
> +}
> +
> +static int smc911x_send(struct udevice *dev, void *packet, int length)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       int ret;
> +
> +       ret = smc911x_send_common(priv, packet, length);
> +
> +       return ret ? 0 : -ETIMEDOUT;
> +}
> +
> +static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       u32 *data = (u32 *)net_rx_packets[0];
> +       int ret;
> +
> +       ret = smc911x_recv_common(priv, data);
> +       if (ret)
> +               *packetp = (void *)data;
> +
> +       return ret ? ret : -EAGAIN;
> +}
> +
> +static int smc911x_bind(struct udevice *dev)
> +{
> +       return device_set_name(dev, dev->name);
> +}
> +
> +static int smc911x_probe(struct udevice *dev)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       unsigned long addrh, addrl;
> +       int ret;
> +
> +       /* Try to detect chip. Will fail if not present. */
> +       ret = smc911x_detect_chip(priv);
> +       if (ret)
> +               return ret;
> +
> +       addrh = smc911x_get_mac_csr(priv, ADDRH);
> +       addrl = smc911x_get_mac_csr(priv, ADDRL);
> +       if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
> +               /* address is obtained from optional eeprom */
> +               priv->enetaddr[0] = addrl;
> +               priv->enetaddr[1] = addrl >>  8;
> +               priv->enetaddr[2] = addrl >> 16;
> +               priv->enetaddr[3] = addrl >> 24;
> +               priv->enetaddr[4] = addrh;
> +               priv->enetaddr[5] = addrh >> 8;
> +       }
> +
> +       return 0;
> +}
> +
> +static int smc911x_ofdata_to_platdata(struct udevice *dev)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       struct eth_pdata *pdata = dev_get_platdata(dev);
> +
> +       pdata->iobase = devfdt_get_addr(dev);
> +       priv->iobase = pdata->iobase;
> +
> +       return 0;
> +}
> +
> +static const struct eth_ops smc911x_ops = {
> +       .start  = smc911x_start,
> +       .send   = smc911x_send,
> +       .recv   = smc911x_recv,
> +       .stop   = smc911x_stop,
> +};
> +
> +static const struct udevice_id smc911x_ids[] = {
> +       { .compatible = "smsc,lan9115" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(smc911x) = {
> +       .name           = "eth_smc911x",
> +       .id             = UCLASS_ETH,
> +       .of_match       = smc911x_ids,
> +       .bind           = smc911x_bind,
> +       .ofdata_to_platdata = smc911x_ofdata_to_platdata,
> +       .probe          = smc911x_probe,
> +       .ops            = &smc911x_ops,
> +       .priv_auto_alloc_size = sizeof(struct smc911x_priv),
> +       .platdata_auto_alloc_size = sizeof(struct eth_pdata),
> +       .flags          = DM_FLAG_ALLOC_PRIV_DMA,
> +};
> +#endif
> diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
> index 0b17a91804..6b061bac69 100644
> --- a/examples/standalone/Makefile
> +++ b/examples/standalone/Makefile
> @@ -5,10 +5,13 @@
>
>  extra-y        := hello_world
>  extra-$(CONFIG_SMC91111)           += smc91111_eeprom
> -extra-$(CONFIG_SMC911X)            += smc911x_eeprom
>  extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
>  extra-$(CONFIG_PPC)                += sched
>
> +ifndef CONFIG_DM_ETH
> +extra-$(CONFIG_SMC911X)            += smc911x_eeprom
> +endif
> +
>  #
>  # Some versions of make do not handle trailing white spaces properly;
>  # leading to build failures. The problem was found with GNU Make 3.80.
> --
> 2.25.0
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply related	[flat|nested] 36+ messages in thread

* [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv()
  2020-03-15 16:58 ` [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv() Marek Vasut
  2020-03-17  6:30   ` Masahiro Yamada
@ 2020-03-17 17:07   ` Joe Hershberger
  1 sibling, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17 17:07 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:01 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Invest the status handling logic in smc911x_recv(), to make the
> function easier to read, no functional change.

Invest -> Invert

> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>  drivers/net/smc911x.c | 31 +++++++++++++++++--------------
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index fc874e8d2a..a6da586448 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -352,23 +352,26 @@ static int smc911x_recv(struct eth_device *dev)
>         u32 pktlen, tmplen;
>         u32 status;
>
> -       if ((smc911x_reg_read(priv, RX_FIFO_INF) & RX_FIFO_INF_RXSUSED) >> 16) {
> -               status = smc911x_reg_read(priv, RX_STATUS_FIFO);
> -               pktlen = (status & RX_STS_PKT_LEN) >> 16;
> +       status = smc911x_reg_read(priv, RX_FIFO_INF);
> +       status = (status & RX_FIFO_INF_RXSUSED) >> 16;
> +       if (!status)
> +               return 0;
>
> -               smc911x_reg_write(priv, RX_CFG, 0);
> +       status = smc911x_reg_read(priv, RX_STATUS_FIFO);
> +       pktlen = (status & RX_STS_PKT_LEN) >> 16;
>
> -               tmplen = (pktlen + 3) / 4;
> -               while (tmplen--)
> -                       *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
> +       smc911x_reg_write(priv, RX_CFG, 0);
>
> -               if (status & RX_STS_ES)
> -                       printf(DRIVERNAME
> -                               ": dropped bad packet. Status: 0x%08x\n",
> -                               status);
> -               else
> -                       net_process_received_packet(net_rx_packets[0], pktlen);
> -       }
> +       tmplen = (pktlen + 3) / 4;
> +       while (tmplen--)
> +               *data++ = smc911x_reg_read(priv, RX_DATA_FIFO);
> +
> +       if (status & RX_STS_ES)
> +               printf(DRIVERNAME
> +                       ": dropped bad packet. Status: 0x%08x\n",
> +                       status);
> +       else
> +               net_process_received_packet(net_rx_packets[0], pktlen);
>
>         return 0;
>  }
> --
> 2.25.0
>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 11/12] net: smc911x: Split non-DM specific bits from common code
  2020-03-15 16:58 ` [PATCH 11/12] net: smc911x: Split non-DM specific bits from common code Marek Vasut
@ 2020-03-17 17:09   ` Joe Hershberger
  0 siblings, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17 17:09 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:01 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Split network handling functions into non-DM specific parts and
> common code in preparation for conversion to DM.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 12/12] net: smc911x: Add DM support
  2020-03-15 16:58 ` [PATCH 12/12] net: smc911x: Add DM support Marek Vasut
  2020-03-17  6:55   ` Masahiro Yamada
@ 2020-03-17 17:20   ` Joe Hershberger
  1 sibling, 0 replies; 36+ messages in thread
From: Joe Hershberger @ 2020-03-17 17:20 UTC (permalink / raw)
  To: u-boot

On Sun, Mar 15, 2020 at 12:01 PM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> Add support for U-Boot DM and DT probing. Furthermore, build the
> SMC911x standalone EEPROM example only for the non-DM case, as it
> is not converted yet.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>  board/renesas/blanche/blanche.c |   2 +
>  drivers/net/smc911x.c           | 114 ++++++++++++++++++++++++++++++++
>  examples/standalone/Makefile    |   5 +-
>  3 files changed, 120 insertions(+), 1 deletion(-)
>
> diff --git a/board/renesas/blanche/blanche.c b/board/renesas/blanche/blanche.c
> index 7232370d6f..eec1dde106 100644
> --- a/board/renesas/blanche/blanche.c
> +++ b/board/renesas/blanche/blanche.c
> @@ -313,6 +313,7 @@ int board_init(void)
>  }
>
>  /* Added for BLANCHE(R-CarV2H board) */
> +#ifndef CONFIG_DM_ETH
>  int board_eth_init(bd_t *bis)
>  {
>         int rc = 0;
> @@ -337,6 +338,7 @@ int board_eth_init(bd_t *bis)
>
>         return rc;
>  }
> +#endif
>
>  int dram_init(void)
>  {
> diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c
> index 71c7a2e632..8abc5e97ac 100644
> --- a/drivers/net/smc911x.c
> +++ b/drivers/net/smc911x.c
> @@ -21,7 +21,9 @@ struct chip_id {
>  };
>
>  struct smc911x_priv {
> +#ifndef CONFIG_DM_ETH
>         struct eth_device       dev;
> +#endif
>         phys_addr_t             iobase;
>         const struct chip_id    *chipid;
>         unsigned char           enetaddr[6];
> @@ -371,6 +373,8 @@ static int smc911x_recv_common(struct smc911x_priv *priv, u32 *data)
>         return pktlen;
>  }
>
> +#ifndef CONFIG_DM_ETH

Please use positive logic here.

> +
>  #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
>  /* wrapper for smc911x_eth_phy_read */
>  static int smc911x_miiphy_read(struct mii_dev *bus, int phy, int devad,
> @@ -502,3 +506,113 @@ int smc911x_initialize(u8 dev_num, int base_addr)
>
>         return 1;
>  }
> +
> +#else  /* ifdef CONFIG_DM_ETH */
> +
> +static int smc911x_start(struct udevice *dev)
> +{
> +       struct eth_pdata *plat = dev_get_platdata(dev);
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +
> +       memcpy(priv->enetaddr, plat->enetaddr, sizeof(plat->enetaddr));
> +
> +       return smc911x_init_common(priv);
> +}
> +
> +static void smc911x_stop(struct udevice *dev)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +
> +       smc911x_halt_common(priv);
> +}
> +
> +static int smc911x_send(struct udevice *dev, void *packet, int length)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       int ret;
> +
> +       ret = smc911x_send_common(priv, packet, length);
> +
> +       return ret ? 0 : -ETIMEDOUT;
> +}
> +
> +static int smc911x_recv(struct udevice *dev, int flags, uchar **packetp)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       u32 *data = (u32 *)net_rx_packets[0];
> +       int ret;
> +
> +       ret = smc911x_recv_common(priv, data);
> +       if (ret)
> +               *packetp = (void *)data;
> +
> +       return ret ? ret : -EAGAIN;
> +}
> +
> +static int smc911x_bind(struct udevice *dev)
> +{
> +       return device_set_name(dev, dev->name);
> +}
> +
> +static int smc911x_probe(struct udevice *dev)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       unsigned long addrh, addrl;
> +       int ret;
> +
> +       /* Try to detect chip. Will fail if not present. */
> +       ret = smc911x_detect_chip(priv);
> +       if (ret)
> +               return ret;
> +
> +       addrh = smc911x_get_mac_csr(priv, ADDRH);
> +       addrl = smc911x_get_mac_csr(priv, ADDRL);
> +       if (!(addrl == 0xffffffff && addrh == 0x0000ffff)) {
> +               /* address is obtained from optional eeprom */
> +               priv->enetaddr[0] = addrl;
> +               priv->enetaddr[1] = addrl >>  8;
> +               priv->enetaddr[2] = addrl >> 16;
> +               priv->enetaddr[3] = addrl >> 24;
> +               priv->enetaddr[4] = addrh;
> +               priv->enetaddr[5] = addrh >> 8;
> +       }

Can you make a common function for sharing the MAC address parsing?

> +
> +       return 0;
> +}
> +
> +static int smc911x_ofdata_to_platdata(struct udevice *dev)
> +{
> +       struct smc911x_priv *priv = dev_get_priv(dev);
> +       struct eth_pdata *pdata = dev_get_platdata(dev);
> +
> +       pdata->iobase = devfdt_get_addr(dev);
> +       priv->iobase = pdata->iobase;
> +
> +       return 0;
> +}
> +
> +static const struct eth_ops smc911x_ops = {
> +       .start  = smc911x_start,
> +       .send   = smc911x_send,
> +       .recv   = smc911x_recv,
> +       .stop   = smc911x_stop,
> +};
> +
> +static const struct udevice_id smc911x_ids[] = {
> +       { .compatible = "smsc,lan9115" },
> +       { }
> +};
> +
> +U_BOOT_DRIVER(smc911x) = {
> +       .name           = "eth_smc911x",
> +       .id             = UCLASS_ETH,
> +       .of_match       = smc911x_ids,
> +       .bind           = smc911x_bind,
> +       .ofdata_to_platdata = smc911x_ofdata_to_platdata,
> +       .probe          = smc911x_probe,
> +       .ops            = &smc911x_ops,
> +       .priv_auto_alloc_size = sizeof(struct smc911x_priv),
> +       .platdata_auto_alloc_size = sizeof(struct eth_pdata),
> +       .flags          = DM_FLAG_ALLOC_PRIV_DMA,
> +};
> +#endif
> diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
> index 0b17a91804..6b061bac69 100644
> --- a/examples/standalone/Makefile
> +++ b/examples/standalone/Makefile
> @@ -5,10 +5,13 @@
>
>  extra-y        := hello_world
>  extra-$(CONFIG_SMC91111)           += smc91111_eeprom
> -extra-$(CONFIG_SMC911X)            += smc911x_eeprom
>  extra-$(CONFIG_SPI_FLASH_ATMEL)    += atmel_df_pow2
>  extra-$(CONFIG_PPC)                += sched
>
> +ifndef CONFIG_DM_ETH
> +extra-$(CONFIG_SMC911X)            += smc911x_eeprom
> +endif
> +
>  #
>  # Some versions of make do not handle trailing white spaces properly;
>  # leading to build failures. The problem was found with GNU Make 3.80.
> --
> 2.25.0
>

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path
  2020-03-17  6:21   ` Masahiro Yamada
@ 2020-03-21 16:30     ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-21 16:30 UTC (permalink / raw)
  To: u-boot

On 3/17/20 7:21 AM, Masahiro Yamada wrote:
[...]
>> @@ -283,15 +283,23 @@ int smc911x_initialize(u8 dev_num, int base_addr)
>>  #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
>>         int retval;
>>         struct mii_dev *mdiodev = mdio_alloc();
>> -       if (!mdiodev)
>> +       if (!mdiodev) {
>> +               eth_unregister(dev);
>> +               free(dev);
>>                 return -ENOMEM;
>> +       }
>> +
>>         strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN);
>>         mdiodev->read = smc911x_miiphy_read;
>>         mdiodev->write = smc911x_miiphy_write;
>>
>>         retval = mdio_register(mdiodev);
>> -       if (retval < 0)
>> +       if (retval < 0) {
>> +               mdio_free(mdiodev);
>> +               eth_unregister(dev);
>> +               free(dev);
>>                 return retval;
> 
> 
> Using "goto <label>" is a general tip to
> simplify the failure path.

It's even better to pull the entire MII registration into a separate
function to avoid all the ifdeffery, so I'll rather do that in a
separate patch. And then it's possible to use the goto labels without it
looking ugly.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 12/12] net: smc911x: Add DM support
  2020-03-17  6:55   ` Masahiro Yamada
@ 2020-03-21 16:51     ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-21 16:51 UTC (permalink / raw)
  To: u-boot

On 3/17/20 7:55 AM, Masahiro Yamada wrote:
> On Mon, Mar 16, 2020 at 2:01 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>>
>> Add support for U-Boot DM and DT probing. Furthermore, build the
>> SMC911x standalone EEPROM example only for the non-DM case, as it
>> is not converted yet.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Joe Hershberger <joe.hershberger@ni.com>
>> Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
>> ---
>>  board/renesas/blanche/blanche.c |   2 +
> 
> 
> Do you need to touch this board in the same commit?
> It is unclear to me why.

Nope, that should be separate.

> One more thing, CONFIG_SMC911X_BASE is only used for
> non DM_ETH case.
> 
> So, can you hide this config option?
> 
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 4d1013c98466..dcda139156f0 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -390,6 +390,7 @@ if SMC911X
> 
>  config SMC911X_BASE
>         hex "SMC911X Base Address"
> +       depends on !DM_ETH
>         help
>           Define this to hold the physical address
>           of the device (I/O space)
> 
> 
> Lastly, mismatch between From: and Signed-off-by.
> 
> Without "+renesas" in From,
> With "+renesas" in Signed-off-by.

Do you have a git config to handle that correctly with gmail ?

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 00/12] net: smc911x: Convert to DM
  2020-03-17  6:17 ` [PATCH 00/12] net: smc911x: Convert to DM Masahiro Yamada
@ 2020-03-21 16:52   ` Marek Vasut
  2020-03-24  1:41     ` Adam Ford
  0 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2020-03-21 16:52 UTC (permalink / raw)
  To: u-boot

On 3/17/20 7:17 AM, Masahiro Yamada wrote:
> Hi Marek,

Hi,

> On Mon, Mar 16, 2020 at 1:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>>
>> Perform DM conversion of the SMC911x driver. Note that as I do not have
>> any hardware with this chip, I only compile-tested this conversion. But
>> it seems Yamada-san has one, so please test.
> 
> With a quick test on my board, it worked for me.
> 
> I will leave comments to each patch, but
> they are mostly nit-picking.
> 
> Thanks for the cleanups and the conversion.

I fixed most of those, thanks for testing.

I also got access to the V2H blanche and there it works too, so maybe
some future revision of this could be queued up for next.

-- 
Best regards,
Marek Vasut

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 00/12] net: smc911x: Convert to DM
  2020-03-21 16:52   ` Marek Vasut
@ 2020-03-24  1:41     ` Adam Ford
  2020-03-25 15:32       ` Marek Vasut
  0 siblings, 1 reply; 36+ messages in thread
From: Adam Ford @ 2020-03-24  1:41 UTC (permalink / raw)
  To: u-boot

On Sat, Mar 21, 2020 at 11:57 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>
> On 3/17/20 7:17 AM, Masahiro Yamada wrote:
> > Hi Marek,
>
> Hi,
>
> > On Mon, Mar 16, 2020 at 1:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
> >>
> >> Perform DM conversion of the SMC911x driver. Note that as I do not have

Thanks for taking this on.

> >> any hardware with this chip, I only compile-tested this conversion. But
> >> it seems Yamada-san has one, so please test.

I have a DM3730 with this chip.  Without DM_ETH, the
omap3_logic_defconfig doesn't compile with the following errors:

drivers/net/smc911x.c: In function ?smc911x_initialize?:
drivers/net/smc911x.c:477:2: error: ?dev? undeclared (first use in
this function)
  477 |  dev = kzalloc(sizeof(*priv), GFP_KERNEL);
      |  ^~~
drivers/net/smc911x.c:477:2: note: each undeclared identifier is
reported only once for each function it appears in
drivers/net/smc911x.c:477:8: warning: implicit declaration of function
?kzalloc?; did you mean ?calloc?? [-Wimplicit-function-declaration]
  477 |  dev = kzalloc(sizeof(*priv), GFP_KERNEL);
      |        ^~~~~~~
      |        calloc
drivers/net/smc911x.c:477:31: error: ?GFP_KERNEL? undeclared (first
use in this function)
  477 |  dev = kzalloc(sizeof(*priv), GFP_KERNEL);
      |                               ^~~~~~~~~~
make[1]: *** [scripts/Makefile.build:279: drivers/net/smc911x.o] Error 1

> >
> > With a quick test on my board, it worked for me.
> >
> > I will leave comments to each patch, but
> > they are mostly nit-picking.
> >
> > Thanks for the cleanups and the conversion.
>
> I fixed most of those, thanks for testing.

If I enable DM_ETH, I need to make a few changes to the device tree,
but with those changes, I was able to get the Ethernet working.
The OMAP3 boards have the Ethernet node attached to their GPMC bus
which currently doesn't have a driver.  Making the GPMC compatible
with 'simple-bus' wasn't sufficient. With only that change, the system
would hang while trying to probe the network interface.

What I ended up having to do was add the following to my root node:

ethernet at 08000000 {
     compatible = "smsc,lan9221","smsc,lan9115";
     reg = <0x08000000>;
     bank-width = <2>;
     vddvario-supply = <&vddvario>;
     vdd33a-supply = <&vdd33a>;
     reg-io-width = <4>;
     smsc,save-mac-address;
};

I didn't look to see if I needed all those entries, but I was able to
get an IP address and ping a different computer.
If there is a future revision to fix the default build errors, I can
add similar comments with my tested-by if you want to CC me.

adam
>
> I also got access to the V2H blanche and there it works too, so maybe
> some future revision of this could be queued up for next.
>
> --
> Best regards,
> Marek Vasut

^ permalink raw reply	[flat|nested] 36+ messages in thread

* [PATCH 00/12] net: smc911x: Convert to DM
  2020-03-24  1:41     ` Adam Ford
@ 2020-03-25 15:32       ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2020-03-25 15:32 UTC (permalink / raw)
  To: u-boot

On 3/24/20 2:41 AM, Adam Ford wrote:
> On Sat, Mar 21, 2020 at 11:57 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>>
>> On 3/17/20 7:17 AM, Masahiro Yamada wrote:
>>> Hi Marek,
>>
>> Hi,
>>
>>> On Mon, Mar 16, 2020 at 1:59 AM Marek Vasut <marek.vasut@gmail.com> wrote:
>>>>
>>>> Perform DM conversion of the SMC911x driver. Note that as I do not have
> 
> Thanks for taking this on.
> 
>>>> any hardware with this chip, I only compile-tested this conversion. But
>>>> it seems Yamada-san has one, so please test.
> 
> I have a DM3730 with this chip.  Without DM_ETH, the
> omap3_logic_defconfig doesn't compile with the following errors:
> 
> drivers/net/smc911x.c: In function ?smc911x_initialize?:
> drivers/net/smc911x.c:477:2: error: ?dev? undeclared (first use in
> this function)
>   477 |  dev = kzalloc(sizeof(*priv), GFP_KERNEL);
>       |  ^~~
> drivers/net/smc911x.c:477:2: note: each undeclared identifier is
> reported only once for each function it appears in
> drivers/net/smc911x.c:477:8: warning: implicit declaration of function
> ?kzalloc?; did you mean ?calloc?? [-Wimplicit-function-declaration]
>   477 |  dev = kzalloc(sizeof(*priv), GFP_KERNEL);
>       |        ^~~~~~~
>       |        calloc
> drivers/net/smc911x.c:477:31: error: ?GFP_KERNEL? undeclared (first
> use in this function)
>   477 |  dev = kzalloc(sizeof(*priv), GFP_KERNEL);
>       |                               ^~~~~~~~~~
> make[1]: *** [scripts/Makefile.build:279: drivers/net/smc911x.o] Error 1

Well, replace the kzalloc with calloc.

>>> With a quick test on my board, it worked for me.
>>>
>>> I will leave comments to each patch, but
>>> they are mostly nit-picking.
>>>
>>> Thanks for the cleanups and the conversion.
>>
>> I fixed most of those, thanks for testing.
> 
> If I enable DM_ETH, I need to make a few changes to the device tree,
> but with those changes, I was able to get the Ethernet working.
> The OMAP3 boards have the Ethernet node attached to their GPMC bus
> which currently doesn't have a driver.  Making the GPMC compatible
> with 'simple-bus' wasn't sufficient. With only that change, the system
> would hang while trying to probe the network interface.
> 
> What I ended up having to do was add the following to my root node:
> 
> ethernet at 08000000 {
>      compatible = "smsc,lan9221","smsc,lan9115";
>      reg = <0x08000000>;
>      bank-width = <2>;
>      vddvario-supply = <&vddvario>;
>      vdd33a-supply = <&vdd33a>;
>      reg-io-width = <4>;
>      smsc,save-mac-address;
> };
> 
> I didn't look to see if I needed all those entries, but I was able to
> get an IP address and ping a different computer.
> If there is a future revision to fix the default build errors, I can
> add similar comments with my tested-by if you want to CC me.

I'm about to send a V3.

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2020-03-25 15:32 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 16:58 [PATCH 00/12] net: smc911x: Convert to DM Marek Vasut
2020-03-15 16:58 ` [PATCH 01/12] net: smc911x: Remove pkt_data_{push,pull} Marek Vasut
2020-03-16 23:52   ` Joe Hershberger
2020-03-15 16:58 ` [PATCH 02/12] net: smc911x: Replace malloc()+memset() with calloc() Marek Vasut
2020-03-16 23:58   ` Joe Hershberger
2020-03-17  6:20   ` Masahiro Yamada
2020-03-15 16:58 ` [PATCH 03/12] net: smc911x: Rename smc911x_rx() to smc911x_recv() Marek Vasut
2020-03-15 16:58 ` [PATCH 04/12] net: smc911x: Invert the logic in smc911x_miiphy_{read, write}() Marek Vasut
2020-03-15 16:58 ` [PATCH 05/12] net: smc911x: Fix potential memleak() in init fail path Marek Vasut
2020-03-17  0:03   ` Joe Hershberger
2020-03-17  6:21   ` Masahiro Yamada
2020-03-21 16:30     ` Marek Vasut
2020-03-15 16:58 ` [PATCH 06/12] net: smc911x: Inline all functions from header file Marek Vasut
2020-03-17  0:06   ` Joe Hershberger
2020-03-17  6:25   ` Masahiro Yamada
2020-03-15 16:58 ` [PATCH 07/12] net: smc911x: Drop weak alias from 32bit accessors Marek Vasut
2020-03-17  0:06   ` Joe Hershberger
2020-03-17  6:27   ` Masahiro Yamada
2020-03-17  6:45   ` Masahiro Yamada
2020-03-15 16:58 ` [PATCH 08/12] net: smc911x: Convert IO accessors to {read, write}{w, l}() Marek Vasut
2020-03-17  0:08   ` Joe Hershberger
2020-03-15 16:58 ` [PATCH 09/12] net: smc911x: Pass around driver private data Marek Vasut
2020-03-17  0:10   ` Joe Hershberger
2020-03-15 16:58 ` [PATCH 10/12] net: smc911x: Clean up the status handling in smc911x_recv() Marek Vasut
2020-03-17  6:30   ` Masahiro Yamada
2020-03-17 17:07   ` Joe Hershberger
2020-03-15 16:58 ` [PATCH 11/12] net: smc911x: Split non-DM specific bits from common code Marek Vasut
2020-03-17 17:09   ` Joe Hershberger
2020-03-15 16:58 ` [PATCH 12/12] net: smc911x: Add DM support Marek Vasut
2020-03-17  6:55   ` Masahiro Yamada
2020-03-21 16:51     ` Marek Vasut
2020-03-17 17:20   ` Joe Hershberger
2020-03-17  6:17 ` [PATCH 00/12] net: smc911x: Convert to DM Masahiro Yamada
2020-03-21 16:52   ` Marek Vasut
2020-03-24  1:41     ` Adam Ford
2020-03-25 15:32       ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.