* [PATCH 1/4] net: cpsw: Pass correct slave
@ 2014-05-15 6:56 Sascha Hauer
2014-05-15 6:56 ` [PATCH 2/4] net: cpsw: print slave_num in dev_dbg Sascha Hauer
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:56 UTC (permalink / raw)
To: barebox
Pass the current slave to cpsw_slave_init/cpsw_update_link,
not the first one.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/cpsw.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index ec3263d..f11b2d9 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -801,8 +801,8 @@ static int cpsw_open(struct eth_device *edev)
ALE_SECURE);
cpsw_ale_add_mcast(priv, ethbdaddr, 1 << priv->host_port);
- cpsw_slave_init(&priv->slaves[0], priv);
- cpsw_update_link(&priv->slaves[0], priv);
+ cpsw_slave_init(slave, priv);
+ cpsw_update_link(slave, priv);
/* init descriptor pool */
for (i = 0; i < NUM_DESCS; i++) {
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/4] net: cpsw: print slave_num in dev_dbg
2014-05-15 6:56 [PATCH 1/4] net: cpsw: Pass correct slave Sascha Hauer
@ 2014-05-15 6:56 ` Sascha Hauer
2014-05-15 6:56 ` [PATCH 3/4] net: cpsw: Always write mac_control register Sascha Hauer
2014-05-15 6:56 ` [PATCH 4/4] net: cpsw: Allow multiple slaves Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:56 UTC (permalink / raw)
To: barebox
Since the cpsw has two slaves which handle one network interface
each the slave number is interesting during debugging. Print the
number.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/cpsw.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index f11b2d9..46fa53d 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -542,7 +542,7 @@ static int cpsw_get_hwaddr(struct eth_device *edev, unsigned char *mac)
struct cpsw_slave *slave = edev->priv;
struct cpsw_priv *priv = slave->cpsw;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
return -1;
}
@@ -552,7 +552,7 @@ static int cpsw_set_hwaddr(struct eth_device *edev, unsigned char *mac)
struct cpsw_slave *slave = edev->priv;
struct cpsw_priv *priv = slave->cpsw;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
memcpy(&priv->mac_addr, mac, sizeof(priv->mac_addr));
@@ -568,7 +568,7 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
struct phy_device *phydev = slave->edev.phydev;
u32 mac_control = 0;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
if (!phydev)
return;
@@ -609,7 +609,7 @@ static int cpsw_update_link(struct cpsw_slave *slave, struct cpsw_priv *priv)
{
int link = 0;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
cpsw_slave_update_link(slave, priv, &link);
@@ -621,7 +621,7 @@ static void cpsw_adjust_link(struct eth_device *edev)
struct cpsw_slave *slave = edev->priv;
struct cpsw_priv *priv = slave->cpsw;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
cpsw_update_link(slave, priv);
}
@@ -638,7 +638,7 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv)
{
u32 slave_port;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
soft_reset(priv, &slave->sliver->soft_reset);
@@ -769,7 +769,7 @@ static int cpsw_open(struct eth_device *edev)
struct cpsw_priv *priv = slave->cpsw;
int i, ret;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
ret = phy_device_connect(edev, &priv->miibus, slave->phy_id,
cpsw_adjust_link, 0, slave->phy_if);
@@ -855,6 +855,8 @@ static void cpsw_halt(struct eth_device *edev)
struct cpsw_slave *slave = edev->priv;
struct cpsw_priv *priv = slave->cpsw;
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
+
writel(0, priv->dma_regs + CPDMA_TXCONTROL);
writel(0, priv->dma_regs + CPDMA_RXCONTROL);
@@ -872,7 +874,7 @@ static int cpsw_send(struct eth_device *edev, void *packet, int length)
void *buffer;
int ret, len;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
/* first reap completed packets */
while (cpdma_process(priv, &priv->tx_chan, &buffer, &len) >= 0);
@@ -917,7 +919,7 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
void *regs = priv->regs;
struct eth_device *edev = &slave->edev;
- dev_dbg(priv->dev, "* %s\n", __func__);
+ dev_dbg(priv->dev, "* %s slave %d\n", __func__, slave->slave_num);
slave->slave_num = slave_num;
slave->regs = regs + priv->slave_ofs + priv->slave_size * slave_num;
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/4] net: cpsw: Always write mac_control register
2014-05-15 6:56 [PATCH 1/4] net: cpsw: Pass correct slave Sascha Hauer
2014-05-15 6:56 ` [PATCH 2/4] net: cpsw: print slave_num in dev_dbg Sascha Hauer
@ 2014-05-15 6:56 ` Sascha Hauer
2014-05-15 6:56 ` [PATCH 4/4] net: cpsw: Allow multiple slaves Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:56 UTC (permalink / raw)
To: barebox
Instead of keeping track of the mac_control register value and
only writing to it when it changed just always write it. This is
more safe anyway since the mac_control register content is altered
in the soft_reset functions.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/cpsw.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index 46fa53d..d31cbb6 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -178,7 +178,6 @@ struct cpsw_slave {
struct cpsw_slave_regs *regs;
struct cpsw_sliver_regs *sliver;
int slave_num;
- u32 mac_control;
int phy_id;
phy_interface_t phy_if;
struct eth_device edev;
@@ -590,9 +589,6 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
mac_control |= BIT(0); /* FULLDUPLEXEN */
}
- if (mac_control == slave->mac_control)
- return;
-
if (mac_control) {
dev_dbg(priv->dev, "link up on port %d, speed %d, %s duplex\n",
slave->slave_num, phydev->speed,
@@ -602,7 +598,6 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
}
writel(mac_control, &slave->sliver->mac_control);
- slave->mac_control = mac_control;
}
static int cpsw_update_link(struct cpsw_slave *slave, struct cpsw_priv *priv)
@@ -649,8 +644,6 @@ static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv)
/* setup max packet size, and mac address */
writel(PKT_MAX, &slave->sliver->rx_maxlen);
- slave->mac_control = 0; /* no link yet */
-
/* enable forwarding */
slave_port = cpsw_get_slave_port(priv, slave->slave_num);
cpsw_ale_port_state(priv, slave_port, ALE_PORT_STATE_FORWARD);
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 4/4] net: cpsw: Allow multiple slaves
2014-05-15 6:56 [PATCH 1/4] net: cpsw: Pass correct slave Sascha Hauer
2014-05-15 6:56 ` [PATCH 2/4] net: cpsw: print slave_num in dev_dbg Sascha Hauer
2014-05-15 6:56 ` [PATCH 3/4] net: cpsw: Always write mac_control register Sascha Hauer
@ 2014-05-15 6:56 ` Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2014-05-15 6:56 UTC (permalink / raw)
To: barebox
The driver is ready now for handling both slaved, so add support
for it.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/cpsw.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index d31cbb6..d55f62a 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -572,9 +572,6 @@ static void cpsw_slave_update_link(struct cpsw_slave *slave,
if (!phydev)
return;
- if (slave->slave_num)
- return;
-
if (phydev->link) {
*link = 1;
mac_control = BIT(5); /* MIIEN */
@@ -1086,9 +1083,6 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
cpsw_gmii_sel_am335x(slave);
}
- /* Only one slave supported by this driver */
- priv->num_slaves = 1;
-
return 0;
}
@@ -1100,7 +1094,7 @@ int cpsw_probe(struct device_d *dev)
uint64_t start;
uint32_t phy_mask;
struct cpsw_data *cpsw_data;
- int ret;
+ int i, ret;
dev_dbg(dev, "* %s\n", __func__);
@@ -1192,9 +1186,11 @@ int cpsw_probe(struct device_d *dev)
mdiobus_register(&priv->miibus);
- ret = cpsw_slave_setup(&priv->slaves[0], 0, priv);
- if (ret)
- goto out;
+ for (i = 0; i < priv->num_slaves; i++) {
+ ret = cpsw_slave_setup(&priv->slaves[i], i, priv);
+ if (ret)
+ goto out;
+ }
return 0;
out:
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-15 6:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15 6:56 [PATCH 1/4] net: cpsw: Pass correct slave Sascha Hauer
2014-05-15 6:56 ` [PATCH 2/4] net: cpsw: print slave_num in dev_dbg Sascha Hauer
2014-05-15 6:56 ` [PATCH 3/4] net: cpsw: Always write mac_control register Sascha Hauer
2014-05-15 6:56 ` [PATCH 4/4] net: cpsw: Allow multiple slaves Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox