* [U-Boot] [PATCH v2 1/6] am335x_evm: prepare for eth driver model support
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
@ 2015-09-07 8:52 ` Mugunthan V N
2015-10-22 21:19 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-09-07 8:52 ` [U-Boot] [PATCH v2 2/6] am335x_evm: do not define usb ether gadget when Eth DM is defined Mugunthan V N
` (5 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Mugunthan V N @ 2015-09-07 8:52 UTC (permalink / raw)
To: u-boot
Prepare board file so that ethernet registration are
commented for DM conversion
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
board/ti/am335x/board.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index 1dc2ed0..f0cb1e2 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -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 */
--
2.6.0.rc0.24.gec371ff
^ permalink raw reply related [flat|nested] 16+ messages in thread* [U-Boot] [PATCH v2 2/6] am335x_evm: do not define usb ether gadget when Eth DM is defined
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
2015-09-07 8:52 ` [U-Boot] [PATCH v2 1/6] am335x_evm: prepare for eth driver model support Mugunthan V N
@ 2015-09-07 8:52 ` Mugunthan V N
2015-10-22 21:19 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-09-07 8:52 ` [U-Boot] [PATCH v2 3/6] drivers: net: cpsw: prepare driver for device model migration Mugunthan V N
` (4 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Mugunthan V N @ 2015-09-07 8:52 UTC (permalink / raw)
To: u-boot
Since usb ether gadget doesn't have support for driver model, so
not defining usb ether gadget when ethernet driver model is
defined.
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
include/configs/am335x_evm.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index e89c49e..56de3d4 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -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
--
2.6.0.rc0.24.gec371ff
^ permalink raw reply related [flat|nested] 16+ messages in thread* [U-Boot] [PATCH v2 3/6] drivers: net: cpsw: prepare driver for device model migration
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
2015-09-07 8:52 ` [U-Boot] [PATCH v2 1/6] am335x_evm: prepare for eth driver model support Mugunthan V N
2015-09-07 8:52 ` [U-Boot] [PATCH v2 2/6] am335x_evm: do not define usb ether gadget when Eth DM is defined Mugunthan V N
@ 2015-09-07 8:52 ` Mugunthan V N
2015-10-22 21:19 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-09-07 8:52 ` [U-Boot] [PATCH v2 4/6] drivers: net: cpsw: convert driver to adopt device driver model Mugunthan V N
` (3 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Mugunthan V N @ 2015-09-07 8:52 UTC (permalink / raw)
To: u-boot
prepare driver for device model migration
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
drivers/net/cpsw.c | 133 +++++++++++++++++++++++++++++++++++------------------
1 file changed, 89 insertions(+), 44 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index fb4d621..a114d4d 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -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;
}
--
2.6.0.rc0.24.gec371ff
^ permalink raw reply related [flat|nested] 16+ messages in thread* [U-Boot] [PATCH v2 4/6] drivers: net: cpsw: convert driver to adopt device driver model
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
` (2 preceding siblings ...)
2015-09-07 8:52 ` [U-Boot] [PATCH v2 3/6] drivers: net: cpsw: prepare driver for device model migration Mugunthan V N
@ 2015-09-07 8:52 ` Mugunthan V N
2015-10-22 21:19 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-09-07 8:52 ` [U-Boot] [PATCH v2 5/6] defconfig: am335x: bbb: enable ethernet " Mugunthan V N
` (2 subsequent siblings)
6 siblings, 1 reply; 16+ messages in thread
From: Mugunthan V N @ 2015-09-07 8:52 UTC (permalink / raw)
To: u-boot
adopt cpsw driver to device driver model
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
drivers/net/cpsw.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
include/cpsw.h | 2 +
2 files changed, 246 insertions(+), 1 deletion(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index a114d4d..3dff9df 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -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 */
diff --git a/include/cpsw.h b/include/cpsw.h
index 547b40c..cf1d30b 100644
--- a/include/cpsw.h
+++ b/include/cpsw.h
@@ -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 */
--
2.6.0.rc0.24.gec371ff
^ permalink raw reply related [flat|nested] 16+ messages in thread* [U-Boot] [PATCH v2 5/6] defconfig: am335x: bbb: enable ethernet driver model
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
` (3 preceding siblings ...)
2015-09-07 8:52 ` [U-Boot] [PATCH v2 4/6] drivers: net: cpsw: convert driver to adopt device driver model Mugunthan V N
@ 2015-09-07 8:52 ` Mugunthan V N
2015-10-22 21:19 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-09-07 8:52 ` [U-Boot] [PATCH v2 6/6] defconfig: am335x: gp_evm: " Mugunthan V N
2015-09-21 10:51 ` [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
6 siblings, 1 reply; 16+ messages in thread
From: Mugunthan V N @ 2015-09-07 8:52 UTC (permalink / raw)
To: u-boot
enable ethernet driver model for am335x beagle bone black as cpsw
supports driver model
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
---
configs/am335x_boneblack_vboot_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/am335x_boneblack_vboot_defconfig b/configs/am335x_boneblack_vboot_defconfig
index b52ddfd..117a146 100644
--- a/configs/am335x_boneblack_vboot_defconfig
+++ b/configs/am335x_boneblack_vboot_defconfig
@@ -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
--
2.6.0.rc0.24.gec371ff
^ permalink raw reply related [flat|nested] 16+ messages in thread* [U-Boot] [PATCH v2 6/6] defconfig: am335x: gp_evm: enable ethernet driver model
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
` (4 preceding siblings ...)
2015-09-07 8:52 ` [U-Boot] [PATCH v2 5/6] defconfig: am335x: bbb: enable ethernet " Mugunthan V N
@ 2015-09-07 8:52 ` Mugunthan V N
2015-09-22 13:50 ` Tom Rini
2015-10-22 21:20 ` [U-Boot] [U-Boot, v2, " Tom Rini
2015-09-21 10:51 ` [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
6 siblings, 2 replies; 16+ messages in thread
From: Mugunthan V N @ 2015-09-07 8:52 UTC (permalink / raw)
To: u-boot
enable ethernet driver model for am335x gp evm as cpsw supports
driver model
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
---
configs/am335x_gp_evm_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/configs/am335x_gp_evm_defconfig b/configs/am335x_gp_evm_defconfig
index 62d3b6b..c87d7a9 100644
--- a/configs/am335x_gp_evm_defconfig
+++ b/configs/am335x_gp_evm_defconfig
@@ -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
--
2.6.0.rc0.24.gec371ff
^ permalink raw reply related [flat|nested] 16+ messages in thread* [U-Boot] [PATCH v2 6/6] defconfig: am335x: gp_evm: enable ethernet driver model
2015-09-07 8:52 ` [U-Boot] [PATCH v2 6/6] defconfig: am335x: gp_evm: " Mugunthan V N
@ 2015-09-22 13:50 ` Tom Rini
2015-10-22 21:20 ` [U-Boot] [U-Boot, v2, " Tom Rini
1 sibling, 0 replies; 16+ messages in thread
From: Tom Rini @ 2015-09-22 13:50 UTC (permalink / raw)
To: u-boot
On Mon, Sep 07, 2015 at 02:22:23PM +0530, Mugunthan V N wrote:
> enable ethernet driver model for am335x gp evm as cpsw supports
> driver model
>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
--
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>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [U-Boot, v2, 6/6] defconfig: am335x: gp_evm: enable ethernet driver model
2015-09-07 8:52 ` [U-Boot] [PATCH v2 6/6] defconfig: am335x: gp_evm: " Mugunthan V N
2015-09-22 13:50 ` Tom Rini
@ 2015-10-22 21:20 ` Tom Rini
1 sibling, 0 replies; 16+ messages in thread
From: Tom Rini @ 2015-10-22 21:20 UTC (permalink / raw)
To: u-boot
On Mon, Sep 07, 2015 at 02:22:23PM +0530, Mugunthan V N wrote:
> enable ethernet driver model for am335x gp evm as cpsw supports
> driver model
>
> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Applied to u-boot/master, thanks!
--
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>
^ permalink raw reply [flat|nested] 16+ messages in thread
* [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black
2015-09-07 8:52 [U-Boot] [PATCH v2 0/6] device model bringup of cpsw on am335x bone black Mugunthan V N
` (5 preceding siblings ...)
2015-09-07 8:52 ` [U-Boot] [PATCH v2 6/6] defconfig: am335x: gp_evm: " Mugunthan V N
@ 2015-09-21 10:51 ` Mugunthan V N
2015-09-21 11:48 ` Tom Rini
6 siblings, 1 reply; 16+ messages in thread
From: Mugunthan V N @ 2015-09-21 10:51 UTC (permalink / raw)
To: u-boot
On Monday 07 September 2015 02:22 PM, Mugunthan V N wrote:
> 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.
>
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
^ permalink raw reply [flat|nested] 16+ messages in thread