Skip to contentSkip to conversation

device model bringup of cpsw on am335x bone black

PATCH Superseded Mugunthan V N 2 participants 16 messages Sep 7, 2015 – Oct 22, 2015 Network drivers

lore
Share & tools
lore
#0 lore raw

v2 cover device model bringup of cpsw on am335x bone black

This patch seires enables cpsw to adopt driver model. This has been tested on AM335x beagle bone black and GP EVM (logs [1]). Also pushed a branch for testing [2]

This patch depends on [3] for getting cpsw address space from DT

[1]: http://pastebin.ubuntu.com/12305998/
[2]: git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git cpsw-dt-conversion-v2 [3]: http://patchwork.ozlabs.org/patch/504918/

Changes from initial version:
* Dropped "drivers: of: add support for get device address based on index" and used http://patchwork.ozlabs.org/patch/504918/ as it fixes the same
* Added AM335x GP EVM also with the series.

Mugunthan V N (6):
am335x_evm: prepare for eth driver model support
am335x_evm: do not define usb ether gadget when Eth DM is defined
drivers: net: cpsw: prepare driver for device model migration
drivers: net: cpsw: convert driver to adopt device driver model
defconfig: am335x: bbb: enable ethernet driver model
defconfig: am335x: gp_evm: enable ethernet driver model

 board/ti/am335x/board.c                  |   7 +
 configs/am335x_boneblack_vboot_defconfig |   1 +
 configs/am335x_gp_evm_defconfig          |   1 +
 drivers/net/cpsw.c                       | 378 +++++++++++++++++++++++++++----
 include/configs/am335x_evm.h             |   3 +
 include/cpsw.h                           |   2 +
 6 files changed, 347 insertions(+), 45 deletions(-)
Signature · 1 line
2.6.0.rc0.24.gec371ff
#1 lore raw

PATCH v2 1/6 am335x_evm: prepare for eth driver model support

Prepare board file so that ethernet registration are commented for DM conversion

---
 board/ti/am335x/board.c | 7 +++++++
 1 file changed, 7 insertions(+)
board/ti/am335x/board.c +7 -0
index 1dc2ed0..f0cb1e2 100644
@@ -38,7 +38,10 @@ DECLARE_GLOBAL_DATA_PTR;
 /* GPIO that controls power to DDR on EVM-SK */
 #define GPIO_DDR_VTT_EN		7
 
+#if defined(CONFIG_SPL_BUILD) || \
+	(defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_DM_ETH))
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
+#endif
 
 /*
  * Read header information from EEPROM into global structure.
@@ -513,6 +516,8 @@ int board_late_init(void)
 }
 #endif
 
+#ifndef CONFIG_DM_ETH
+
 #if (defined(CONFIG_DRIVER_TI_CPSW) && !defined(CONFIG_SPL_BUILD)) || \
 	(defined(CONFIG_SPL_ETH_SUPPORT) && defined(CONFIG_SPL_BUILD))
 static void cpsw_control(int enabled)
@@ -670,3 +675,5 @@ int board_eth_init(bd_t *bis)
 	return n;
 }
 #endif
+
+#endif /* CONFIG_DM_ETH */
Signature · 1 line
2.6.0.rc0.24.gec371ff
#2 lore raw

PATCH v2 1/6 am335x_evm: prepare for eth driver model support

Quoted 5 lines · Mugunthan V N

Prepare board file so that ethernet registration are commented for DM conversion

Applied to u-boot/master, thanks!

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

PATCH v2 2/6 am335x_evm: do not define usb ether gadget when Eth DM is defined

In reply to Mugunthan V N

Since usb ether gadget doesn't have support for driver model, so not defining usb ether gadget when ethernet driver model is defined.

---
 include/configs/am335x_evm.h | 3 +++
 1 file changed, 3 insertions(+)
include/configs/am335x_evm.h +3 -0
index e89c49e..56de3d4 100644
@@ -315,9 +315,12 @@
 #endif
 
 #ifdef CONFIG_USB_MUSB_GADGET
+/* Removing USB gadget and can be enabled adter adding support usb DM */
+#ifndef CONFIG_DM_ETH
 #define CONFIG_USB_ETHER
 #define CONFIG_USB_ETH_RNDIS
 #define CONFIG_USBNET_HOST_ADDR	"de:ad:be:af:00:00"
+#endif /* CONFIG_DM_ETH */
 
 /* USB TI's IDs */
 #define CONFIG_G_DNL_VENDOR_NUM 0x0451
Signature · 1 line
2.6.0.rc0.24.gec371ff
#4 lore raw

PATCH v2 2/6 am335x_evm: do not define usb ether gadget when Eth DM is defined

Quoted 6 lines · Mugunthan V N

Since usb ether gadget doesn't have support for driver model, so not defining usb ether gadget when ethernet driver model is defined.

Applied to u-boot/master, thanks!

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

PATCH v2 3/6 drivers: net: cpsw: prepare driver for device model migration

In reply to Mugunthan V N

prepare driver for device model migration

---
 drivers/net/cpsw.c | 133 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 89 insertions(+), 44 deletions(-)
drivers/net/cpsw.c +89 -44
index fb4d621..a114d4d 100644
@@ -745,9 +745,8 @@ static int cpdma_process(struct cpsw_priv *priv, struct cpdma_chan *chan,
 	return 0;
 }
 
-static int cpsw_init(struct eth_device *dev, bd_t *bis)
+static int _cpsw_init(struct cpsw_priv *priv, u8 *enetaddr)
 {
-	struct cpsw_priv	*priv = dev->priv;
 	struct cpsw_slave	*slave;
 	int i, ret;
 
@@ -772,8 +771,7 @@ static int cpsw_init(struct eth_device *dev, bd_t *bis)
 
 	cpsw_ale_port_state(priv, priv->host_port, ALE_PORT_STATE_FORWARD);
 
-	cpsw_ale_add_ucast(priv, priv->dev->enetaddr, priv->host_port,
-			   ALE_SECURE);
+	cpsw_ale_add_ucast(priv, enetaddr, priv->host_port, ALE_SECURE);
 	cpsw_ale_add_mcast(priv, net_bcast_ethaddr, 1 << priv->host_port);
 
 	for_active_slave(slave, priv)
@@ -857,10 +855,8 @@ static int cpsw_init(struct eth_device *dev, bd_t *bis)
 	return 0;
 }
 
-static void cpsw_halt(struct eth_device *dev)
+static void _cpsw_halt(struct cpsw_priv *priv)
 {
-	struct cpsw_priv	*priv = dev->priv;
-
 	writel(0, priv->dma_regs + CPDMA_TXCONTROL);
 	writel(0, priv->dma_regs + CPDMA_RXCONTROL);
 
@@ -870,12 +866,10 @@ static void cpsw_halt(struct eth_device *dev)
 	/* clear dma state */
 	setbit_and_wait_for_clear32(priv->dma_regs + CPDMA_SOFTRESET);
 
-	priv->data.control(0);
 }
 
-static int cpsw_send(struct eth_device *dev, void *packet, int length)
+static int _cpsw_send(struct cpsw_priv *priv, void *packet, int length)
 {
-	struct cpsw_priv	*priv = dev->priv;
 	void *buffer;
 	int len;
 	int timeout = CPDMA_TIMEOUT;
@@ -896,20 +890,21 @@ static int cpsw_send(struct eth_device *dev, void *packet, int length)
 	return cpdma_submit(priv, &priv->tx_chan, packet, length);
 }
 
-static int cpsw_recv(struct eth_device *dev)
+static int _cpsw_recv(struct cpsw_priv *priv, uchar **pkt)
 {
-	struct cpsw_priv	*priv = dev->priv;
 	void *buffer;
 	int len;
+	int ret = -EAGAIN;
 
-	while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
-		invalidate_dcache_range((unsigned long)buffer,
-					(unsigned long)buffer + PKTSIZE_ALIGN);
-		net_process_received_packet(buffer, len);
-		cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE);
-	}
+	ret = cpdma_process(priv, &priv->rx_chan, &buffer, &len);
+	if (ret < 0)
+		return ret;
 
-	return 0;
+	invalidate_dcache_range((unsigned long)buffer,
+				(unsigned long)buffer + PKTSIZE_ALIGN);
+	*pkt = buffer;
+
+	return len;
 }
 
 static void cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
@@ -923,15 +918,14 @@ static void cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
 	slave->sliver	= regs + data->sliver_reg_ofs;
 }
 
-static int cpsw_phy_init(struct eth_device *dev, struct cpsw_slave *slave)
+static int cpsw_phy_init(struct cpsw_priv *priv, struct cpsw_slave *slave)
 {
-	struct cpsw_priv *priv = (struct cpsw_priv *)dev->priv;
 	struct phy_device *phydev;
 	u32 supported = PHY_GBIT_FEATURES;
 
 	phydev = phy_connect(priv->bus,
 			slave->data->phy_addr,
-			dev,
+			priv->dev,
 			slave->data->phy_if);
 
 	if (!phydev)
@@ -946,30 +940,14 @@ static int cpsw_phy_init(struct eth_device *dev, struct cpsw_slave *slave)
 	return 1;
 }
 
-int cpsw_register(struct cpsw_platform_data *data)
+int _cpsw_register(struct cpsw_priv *priv)
 {
-	struct cpsw_priv	*priv;
 	struct cpsw_slave	*slave;
+	struct cpsw_platform_data *data = &priv->data;
 	void			*regs = (void *)data->cpsw_base;
-	struct eth_device	*dev;
-
-	dev = calloc(sizeof(*dev), 1);
-	if (!dev)
-		return -ENOMEM;
-
-	priv = calloc(sizeof(*priv), 1);
-	if (!priv) {
-		free(dev);
-		return -ENOMEM;
-	}
-
-	priv->data = *data;
-	priv->dev = dev;
 
 	priv->slaves = malloc(sizeof(struct cpsw_slave) * data->slaves);
 	if (!priv->slaves) {
-		free(dev);
-		free(priv);
 		return -ENOMEM;
 	}
 
@@ -987,6 +965,70 @@ int cpsw_register(struct cpsw_platform_data *data)
 		idx = idx + 1;
 	}
 
+	cpsw_mdio_init(priv->dev->name, data->mdio_base, data->mdio_div);
+	priv->bus = miiphy_get_dev_by_name(priv->dev->name);
+	for_active_slave(slave, priv)
+		cpsw_phy_init(priv, slave);
+
+	return 0;
+}
+
+static int cpsw_init(struct eth_device *dev, bd_t *bis)
+{
+	struct cpsw_priv	*priv = dev->priv;
+
+	return _cpsw_init(priv, dev->enetaddr);
+}
+
+static void cpsw_halt(struct eth_device *dev)
+{
+	struct cpsw_priv *priv = dev->priv;
+
+	return _cpsw_halt(priv);
+}
+
+static int cpsw_send(struct eth_device *dev, void *packet, int length)
+{
+	struct cpsw_priv	*priv = dev->priv;
+
+	return _cpsw_send(priv, packet, length);
+}
+
+static int cpsw_recv(struct eth_device *dev)
+{
+	struct cpsw_priv *priv = dev->priv;
+	uchar *pkt = NULL;
+	int len;
+
+	len = _cpsw_recv(priv, &pkt);
+
+	if (len > 0) {
+		net_process_received_packet(pkt, len);
+		cpdma_submit(priv, &priv->rx_chan, pkt, PKTSIZE);
+	}
+
+	return len;
+}
+
+int cpsw_register(struct cpsw_platform_data *data)
+{
+	struct cpsw_priv	*priv;
+	struct eth_device	*dev;
+	int ret;
+
+	dev = calloc(sizeof(*dev), 1);
+	if (!dev)
+		return -ENOMEM;
+
+	priv = calloc(sizeof(*priv), 1);
+	if (!priv) {
+		free(dev);
+		return -ENOMEM;
+	}
+
+	priv->dev = dev;
+	priv->data = *data;
+
 	strcpy(dev->name, "cpsw");
 	dev->iobase	= 0;
 	dev->init	= cpsw_init;
@@ -997,10 +1039,13 @@ int cpsw_register(struct cpsw_platform_data *data)
 
 	eth_register(dev);
 
-	cpsw_mdio_init(dev->name, data->mdio_base, data->mdio_div);
-	priv->bus = miiphy_get_dev_by_name(dev->name);
-	for_active_slave(slave, priv)
-		cpsw_phy_init(dev, slave);
+	ret = _cpsw_register(priv);
+	if (ret < 0) {
+		eth_unregister(dev);
+		free(dev);
+		free(priv);
+		return ret;
+	}
 
 	return 1;
 }
Signature · 1 line
2.6.0.rc0.24.gec371ff
#6 lore raw

PATCH v2 3/6 drivers: net: cpsw: prepare driver for device model migration

Quoted 4 lines · Mugunthan V N

prepare driver for device model migration

Applied to u-boot/master, thanks!

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

PATCH v2 4/6 drivers: net: cpsw: convert driver to adopt device driver model

In reply to Mugunthan V N

adopt cpsw driver to device driver model

---
 drivers/net/cpsw.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 include/cpsw.h     |   2 +
 2 files changed, 246 insertions(+), 1 deletion(-)
drivers/net/cpsw.c +244 -1
index a114d4d..3dff9df 100644
@@ -25,6 +25,9 @@
 #include <asm/io.h>
 #include <phy.h>
 #include <asm/arch/cpu.h>
+#include <dm.h>
+
+DECLARE_GLOBAL_DATA_PTR;
 
 #define BITMASK(bits)		(BIT(bits) - 1)
 #define PHY_REG_MASK		0x1f
@@ -37,6 +40,23 @@
 #define FULLDUPLEXEN		BIT(0)
 #define MIIEN			BIT(15)
 
+/* reg offset */
+#define CPSW_HOST_PORT_OFFSET	0x108
+#define CPSW_SLAVE0_OFFSET	0x208
+#define CPSW_SLAVE1_OFFSET	0x308
+#define CPSW_SLAVE_SIZE		0x100
+#define CPSW_CPDMA_OFFSET	0x800
+#define CPSW_HW_STATS		0x900
+#define CPSW_STATERAM_OFFSET	0xa00
+#define CPSW_CPTS_OFFSET	0xc00
+#define CPSW_ALE_OFFSET		0xd00
+#define CPSW_SLIVER0_OFFSET	0xd80
+#define CPSW_SLIVER1_OFFSET	0xdc0
+#define CPSW_BD_OFFSET		0x2000
+#define CPSW_MDIO_DIV		0xff
+
+#define AM335X_GMII_SEL_OFFSET	0x630
+
 /* DMA Registers */
 #define CPDMA_TXCONTROL		0x004
 #define CPDMA_RXCONTROL		0x014
@@ -218,7 +238,11 @@ struct cpdma_chan {
 				(priv)->data.slaves; slave++)
 
 struct cpsw_priv {
+#ifdef CONFIG_DM_ETH
+	struct udevice			*dev;
+#else
 	struct eth_device		*dev;
+#endif
 	struct cpsw_platform_data	data;
 	int				host_port;
 
@@ -522,7 +546,7 @@ static int cpsw_mdio_write(struct mii_dev *bus, int phy_id, int dev_addr,
 	return 0;
 }
 
-static void cpsw_mdio_init(char *name, u32 mdio_base, u32 div)
+static void cpsw_mdio_init(const char *name, u32 mdio_base, u32 div)
 {
 	struct mii_dev *bus = mdio_alloc();
 
@@ -563,8 +587,15 @@ static inline void setbit_and_wait_for_clear32(void *addr)
 static void cpsw_set_slave_mac(struct cpsw_slave *slave,
 			       struct cpsw_priv *priv)
 {
+#ifdef CONFIG_DM_ETH
+	struct eth_pdata *pdata = dev_get_platdata(priv->dev);
+
+	writel(mac_hi(pdata->enetaddr), &slave->regs->sa_hi);
+	writel(mac_lo(pdata->enetaddr), &slave->regs->sa_lo);
+#else
 	__raw_writel(mac_hi(priv->dev->enetaddr), &slave->regs->sa_hi);
 	__raw_writel(mac_lo(priv->dev->enetaddr), &slave->regs->sa_lo);
+#endif
 }
 
 static void cpsw_slave_update_link(struct cpsw_slave *slave,
@@ -973,6 +1004,7 @@ int _cpsw_register(struct cpsw_priv *priv)
 	return 0;
 }
 
+#ifndef CONFIG_DM_ETH
 static int cpsw_init(struct eth_device *dev, bd_t *bis)
 {
 	struct cpsw_priv	*priv = dev->priv;
@@ -1049,3 +1081,214 @@ int cpsw_register(struct cpsw_platform_data *data)
 
 	return 1;
 }
+#else
+static int cpsw_eth_start(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+	struct cpsw_priv *priv = dev_get_priv(dev);
+
+	return _cpsw_init(priv, pdata->enetaddr);
+}
+
+static int cpsw_eth_send(struct udevice *dev, void *packet, int length)
+{
+	struct cpsw_priv *priv = dev_get_priv(dev);
+
+	return _cpsw_send(priv, packet, length);
+}
+
+static int cpsw_eth_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+	struct cpsw_priv *priv = dev_get_priv(dev);
+
+	return _cpsw_recv(priv, packetp);
+}
+
+static int cpsw_eth_free_pkt(struct udevice *dev, uchar *packet,
+				   int length)
+{
+	struct cpsw_priv *priv = dev_get_priv(dev);
+
+	return cpdma_submit(priv, &priv->rx_chan, packet, PKTSIZE);
+}
+
+static void cpsw_eth_stop(struct udevice *dev)
+{
+	struct cpsw_priv *priv = dev_get_priv(dev);
+
+	return _cpsw_halt(priv);
+}
+
+
+static int cpsw_eth_probe(struct udevice *dev)
+{
+	struct cpsw_priv *priv = dev_get_priv(dev);
+
+	priv->dev = dev;
+
+	return _cpsw_register(priv);
+}
+
+static const struct eth_ops cpsw_eth_ops = {
+	.start		= cpsw_eth_start,
+	.send		= cpsw_eth_send,
+	.recv		= cpsw_eth_recv,
+	.free_pkt	= cpsw_eth_free_pkt,
+	.stop		= cpsw_eth_stop,
+};
+
+static int cpsw_eth_ofdata_to_platdata(struct udevice *dev)
+{
+	struct eth_pdata *pdata = dev_get_platdata(dev);
+	struct cpsw_priv *priv = dev_get_priv(dev);
+	const char *phy_mode;
+	const void *fdt = gd->fdt_blob;
+	int node = dev->of_offset;
+	int subnode;
+	int slave_index = 0;
+	uint32_t mac_hi, mac_lo;
+	fdt32_t gmii = 0;
+	int active_slave;
+
+	pdata->iobase = dev_get_addr(dev);
+	priv->data.version = CPSW_CTRL_VERSION_2;
+	priv->data.bd_ram_ofs = CPSW_BD_OFFSET;
+	priv->data.ale_reg_ofs = CPSW_ALE_OFFSET;
+	priv->data.cpdma_reg_ofs = CPSW_CPDMA_OFFSET;
+	priv->data.mdio_div = CPSW_MDIO_DIV;
+	priv->data.host_port_reg_ofs = CPSW_HOST_PORT_OFFSET,
+
+	pdata->phy_interface = -1;
+
+	priv->data.cpsw_base = pdata->iobase;
+	priv->data.channels = fdtdec_get_int(fdt, node, "cpdma_channels", -1);
+	if (priv->data.channels <= 0) {
+		printf("error: cpdma_channels not found in dt\n");
+		return -ENOENT;
+	}
+
+	priv->data.slaves = fdtdec_get_int(fdt, node, "slaves", -1);
+	if (priv->data.slaves <= 0) {
+		printf("error: slaves not found in dt\n");
+		return -ENOENT;
+	}
+	priv->data.slave_data = malloc(sizeof(struct cpsw_slave_data) *
+				       priv->data.slaves);
+
+	priv->data.ale_entries = fdtdec_get_int(fdt, node, "ale_entries", -1);
+	if (priv->data.ale_entries <= 0) {
+		printf("error: ale_entries not found in dt\n");
+		return -ENOENT;
+	}
+
+	priv->data.bd_ram_ofs = fdtdec_get_int(fdt, node, "bd_ram_size", -1);
+	if (priv->data.bd_ram_ofs <= 0) {
+		printf("error: bd_ram_size not found in dt\n");
+		return -ENOENT;
+	}
+
+	priv->data.mac_control = fdtdec_get_int(fdt, node, "mac_control", -1);
+	if (priv->data.mac_control <= 0) {
+		printf("error: ale_entries not found in dt\n");
+		return -ENOENT;
+	}
+
+	active_slave = fdtdec_get_int(fdt, node, "active_slave", 0);
+	priv->data.active_slave = active_slave;
+
+	fdt_for_each_subnode(fdt, subnode, node) {
+		int len;
+		const char *name;
+
+		name = fdt_get_name(fdt, subnode, &len);
+		if (!strncmp(name, "mdio", 4)) {
+			priv->data.mdio_base = fdtdec_get_addr(fdt, subnode,
+							       "reg");
+		}
+
+		if (!strncmp(name, "slave", 5)) {
+			u32 phy_id[2];
+
+			if (slave_index >= priv->data.slaves) {
+				printf("error: num slaves and slave nodes did not match\n");
+				return -EINVAL;
+			}
+			phy_mode = fdt_getprop(fdt, subnode, "phy-mode", NULL);
+			if (phy_mode)
+				priv->data.slave_data[slave_index].phy_if =
+					phy_get_interface_by_name(phy_mode);
+			fdtdec_get_int_array(fdt, subnode, "phy_id", phy_id, 2);
+			priv->data.slave_data[slave_index].phy_addr = phy_id[1];
+			slave_index++;
+		}
+
+		if (!strncmp(name, "cpsw-phy-sel", 12)) {
+			priv->data.gmii_sel = fdtdec_get_addr(fdt, subnode,
+							      "reg");
+		}
+	}
+
+	priv->data.slave_data[0].slave_reg_ofs = CPSW_SLAVE0_OFFSET;
+	priv->data.slave_data[0].sliver_reg_ofs = CPSW_SLIVER0_OFFSET;
+
+	if (priv->data.slaves == 2) {
+		priv->data.slave_data[1].slave_reg_ofs = CPSW_SLAVE1_OFFSET;
+		priv->data.slave_data[1].sliver_reg_ofs = CPSW_SLIVER1_OFFSET;
+	}
+
+	subnode = fdtdec_lookup_phandle(fdt, node, "syscon");
+	priv->data.mac_id = fdt_translate_address((void *)fdt, subnode, &gmii);
+	priv->data.mac_id += AM335X_GMII_SEL_OFFSET;
+	priv->data.mac_id += active_slave * 8;
+
+	/* try reading mac address from efuse */
+	mac_lo = readl(priv->data.mac_id);
+	mac_hi = readl(priv->data.mac_id + 4);
+	pdata->enetaddr[0] = mac_hi & 0xFF;
+	pdata->enetaddr[1] = (mac_hi & 0xFF00) >> 8;
+	pdata->enetaddr[2] = (mac_hi & 0xFF0000) >> 16;
+	pdata->enetaddr[3] = (mac_hi & 0xFF000000) >> 24;
+	pdata->enetaddr[4] = mac_lo & 0xFF;
+	pdata->enetaddr[5] = (mac_lo & 0xFF00) >> 8;
+
+	pdata->phy_interface = priv->data.slave_data[active_slave].phy_if;
+	if (pdata->phy_interface == -1) {
+		debug("%s: Invalid PHY interface '%s'\n", __func__, phy_mode);
+		return -EINVAL;
+	}
+	switch (pdata->phy_interface) {
+	case PHY_INTERFACE_MODE_MII:
+		writel(MII_MODE_ENABLE, priv->data.gmii_sel);
+		break;
+	case PHY_INTERFACE_MODE_RMII:
+		writel(RMII_MODE_ENABLE, priv->data.gmii_sel);
+		break;
+	case PHY_INTERFACE_MODE_RGMII:
+	case PHY_INTERFACE_MODE_RGMII_ID:
+	case PHY_INTERFACE_MODE_RGMII_RXID:
+	case PHY_INTERFACE_MODE_RGMII_TXID:
+		writel(RGMII_MODE_ENABLE, priv->data.gmii_sel);
+		break;
+	}
+	return 0;
+}
+
+
+static const struct udevice_id cpsw_eth_ids[] = {
+	{ .compatible = "ti,cpsw" },
+	{ .compatible = "ti,am335x-cpsw" },
+	{ }
+};
+
+U_BOOT_DRIVER(eth_cpsw) = {
+	.name	= "eth_cpsw",
+	.id	= UCLASS_ETH,
+	.of_match = cpsw_eth_ids,
+	.ofdata_to_platdata = cpsw_eth_ofdata_to_platdata,
+	.probe	= cpsw_eth_probe,
+	.ops	= &cpsw_eth_ops,
+	.priv_auto_alloc_size = sizeof(struct cpsw_priv),
+	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
+	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
+#endif /* CONFIG_DM_ETH */
include/cpsw.h +2 -0
index 547b40c..cf1d30b 100644
@@ -31,6 +31,8 @@ enum {
 struct cpsw_platform_data {
 	u32	mdio_base;
 	u32	cpsw_base;
+	u32	mac_id;
+	u32	gmii_sel;
 	int	mdio_div;
 	int	channels;	/* number of cpdma channels (symmetric)	*/
 	u32	cpdma_reg_ofs;	/* cpdma register offset		*/
Signature · 1 line
2.6.0.rc0.24.gec371ff
#8 lore raw

PATCH v2 4/6 drivers: net: cpsw: convert driver to adopt device driver model

Quoted 4 lines · Mugunthan V N

adopt cpsw driver to device driver model

Applied to u-boot/master, thanks!

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

PATCH v2 5/6 defconfig: am335x: bbb: enable ethernet driver model

In reply to Mugunthan V N

enable ethernet driver model for am335x beagle bone black as cpsw supports driver model

---
 configs/am335x_boneblack_vboot_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am335x_boneblack_vboot_defconfig +1 -0
index b52ddfd..117a146 100644
@@ -13,3 +13,4 @@ CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT,ENABLE_VBOOT"
 # CONFIG_CMD_SETEXPR is not set
 CONFIG_OF_CONTROL=y
 CONFIG_SPI_FLASH=y
+CONFIG_DM_ETH=y
Signature · 1 line
2.6.0.rc0.24.gec371ff
#10 lore raw

PATCH v2 5/6 defconfig: am335x: bbb: enable ethernet driver model

Quoted 5 lines · Mugunthan V N

enable ethernet driver model for am335x beagle bone black as cpsw supports driver model

Applied to u-boot/master, thanks!

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

PATCH v2 6/6 defconfig: am335x: gp_evm: enable ethernet driver model

In reply to Mugunthan V N

enable ethernet driver model for am335x gp evm as cpsw supports driver model

---
 configs/am335x_gp_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am335x_gp_evm_defconfig +1 -0
index 62d3b6b..c87d7a9 100644
@@ -12,3 +12,4 @@ CONFIG_OF_CONTROL=y
 CONFIG_SPL_DISABLE_OF_CONTROL=y
 CONFIG_SPI_FLASH=y
 CONFIG_RSA=y
+CONFIG_DM_ETH=y
Signature · 1 line
2.6.0.rc0.24.gec371ff
#12 lore raw

PATCH v2 6/6 defconfig: am335x: gp_evm: enable ethernet driver model

Quoted 4 lines · Mugunthan V N

enable ethernet driver model for am335x gp evm as cpsw supports driver model

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

PATCH v2 6/6 defconfig: am335x: gp_evm: enable ethernet driver model

In reply to Mugunthan V N
Quoted 5 lines · Mugunthan V N

enable ethernet driver model for am335x gp evm as cpsw supports driver model

Applied to u-boot/master, thanks!

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

v2 cover device model bringup of cpsw on am335x bone black

In reply to Mugunthan V N
Quoted 6 lines · Mugunthan V N

This patch seires enables cpsw to adopt driver model. This has been tested on AM335x beagle bone black and GP EVM (logs [1]). Also pushed a branch for testing [2]

This patch depends on [3] for getting cpsw address space from DT

Quoted 9 lines

[1]: http://pastebin.ubuntu.com/12305998/
[2]: git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git cpsw-dt-conversion-v2 [3]: http://patchwork.ozlabs.org/patch/504918/

Changes from initial version:
* Dropped "drivers: of: add support for get device address based on index" and used http://patchwork.ozlabs.org/patch/504918/ as it fixes the same
* Added AM335x GP EVM also with the series.

Tom

patch [3] is applied to u-boot-dm git repo. So can you apply this patch series if you do not have any more comments?

Regards
Mugunthan V N

#15 lore raw

v2 cover device model bringup of cpsw on am335x bone black

Quoted 17 lines · Mugunthan V N
Quoted 6 lines · Mugunthan V N

This patch seires enables cpsw to adopt driver model. This has been tested on AM335x beagle bone black and GP EVM (logs [1]). Also pushed a branch for testing [2]

This patch depends on [3] for getting cpsw address space from DT

Quoted 9 lines

[1]: http://pastebin.ubuntu.com/12305998/
[2]: git://git.ti.com/~mugunthanvnm/ti-u-boot/mugunth-ti-u-boot.git cpsw-dt-conversion-v2 [3]: http://patchwork.ozlabs.org/patch/504918/

Changes from initial version:
* Dropped "drivers: of: add support for get device address based on index" and used http://patchwork.ozlabs.org/patch/504918/ as it fixes the same
* Added AM335x GP EVM also with the series.

Quoted 4 lines

Tom

patch [3] is applied to u-boot-dm git repo. So can you apply this patch series if you do not have any more comments?

Patch [3] is required to fix some regression between x86 and Tegra (depending on which patches we did or didn't have, some 64bit HW wasn't working). This series was too late for this merge window so I'll pick it up for v2016.01. Thanks!

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