projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
e1000: releasing semaphore once no longer needed
[oweals/u-boot.git]
/
drivers
/
net
/
cpsw.c
diff --git
a/drivers/net/cpsw.c
b/drivers/net/cpsw.c
index 7a36850198f40020ebc33765084f36f734e68b08..fb4d621a88eec816aaec5c6dba53228cf1e02f66 100644
(file)
--- a/
drivers/net/cpsw.c
+++ b/
drivers/net/cpsw.c
@@
-51,8
+51,6
@@
#define CPDMA_RXCP_VER1 0x160
#define CPDMA_RXCP_VER2 0x260
#define CPDMA_RXCP_VER1 0x160
#define CPDMA_RXCP_VER2 0x260
-#define CPDMA_RAM_ADDR 0x4a102000
-
/* Descriptor mode bits */
#define CPDMA_DESC_SOP BIT(31)
#define CPDMA_DESC_EOP BIT(30)
/* Descriptor mode bits */
#define CPDMA_DESC_SOP BIT(31)
#define CPDMA_DESC_EOP BIT(30)
@@
-109,7
+107,13
@@
struct cpsw_slave_regs {
u32 flow_thresh;
u32 port_vlan;
u32 tx_pri_map;
u32 flow_thresh;
u32 port_vlan;
u32 tx_pri_map;
+#ifdef CONFIG_AM33XX
u32 gap_thresh;
u32 gap_thresh;
+#elif defined(CONFIG_TI814X)
+ u32 ts_ctl;
+ u32 ts_seq_ltype;
+ u32 ts_vlan;
+#endif
u32 sa_lo;
u32 sa_hi;
};
u32 sa_lo;
u32 sa_hi;
};
@@
-207,6
+211,8
@@
struct cpdma_chan {
#define chan_read(chan, fld) __raw_readl((chan)->fld)
#define chan_read_ptr(chan, fld) ((void *)__raw_readl((chan)->fld))
#define chan_read(chan, fld) __raw_readl((chan)->fld)
#define chan_read_ptr(chan, fld) ((void *)__raw_readl((chan)->fld))
+#define for_active_slave(slave, priv) \
+ slave = (priv)->slaves + (priv)->data.active_slave; if (slave)
#define for_each_slave(slave, priv) \
for (slave = (priv)->slaves; slave != (priv)->slaves + \
(priv)->data.slaves; slave++)
#define for_each_slave(slave, priv) \
for (slave = (priv)->slaves; slave != (priv)->slaves + \
(priv)->data.slaves; slave++)
@@
-229,7
+235,6
@@
struct cpsw_priv {
struct phy_device *phydev;
struct mii_dev *bus;
struct phy_device *phydev;
struct mii_dev *bus;
- u32 mdio_link;
u32 phy_mask;
};
u32 phy_mask;
};
@@
-284,7
+289,7
@@
static inline void cpsw_ale_get_addr(u32 *ale_entry, u8 *addr)
addr[i] = cpsw_ale_get_field(ale_entry, 40 - 8*i, 8);
}
addr[i] = cpsw_ale_get_field(ale_entry, 40 - 8*i, 8);
}
-static inline void cpsw_ale_set_addr(u32 *ale_entry, u8 *addr)
+static inline void cpsw_ale_set_addr(u32 *ale_entry,
const
u8 *addr)
{
int i;
{
int i;
@@
-316,7
+321,7
@@
static int cpsw_ale_write(struct cpsw_priv *priv, int idx, u32 *ale_entry)
return idx;
}
return idx;
}
-static int cpsw_ale_match_addr(struct cpsw_priv *priv,
u8*
addr)
+static int cpsw_ale_match_addr(struct cpsw_priv *priv,
const u8 *
addr)
{
u32 ale_entry[ALE_ENTRY_WORDS];
int type, idx;
{
u32 ale_entry[ALE_ENTRY_WORDS];
int type, idx;
@@
-369,7
+374,7
@@
static int cpsw_ale_find_ageable(struct cpsw_priv *priv)
return -ENOENT;
}
return -ENOENT;
}
-static int cpsw_ale_add_ucast(struct cpsw_priv *priv, u8 *addr,
+static int cpsw_ale_add_ucast(struct cpsw_priv *priv,
const
u8 *addr,
int port, int flags)
{
u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
int port, int flags)
{
u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
@@
-394,7
+399,8
@@
static int cpsw_ale_add_ucast(struct cpsw_priv *priv, u8 *addr,
return 0;
}
return 0;
}
-static int cpsw_ale_add_mcast(struct cpsw_priv *priv, u8 *addr, int port_mask)
+static int cpsw_ale_add_mcast(struct cpsw_priv *priv, const u8 *addr,
+ int port_mask)
{
u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
int idx, mask;
{
u32 ale_entry[ALE_ENTRY_WORDS] = {0, 0, 0};
int idx, mask;
@@
-483,7
+489,7
@@
static inline void wait_for_idle(void)
static int cpsw_mdio_read(struct mii_dev *bus, int phy_id,
int dev_addr, int phy_reg)
{
static int cpsw_mdio_read(struct mii_dev *bus, int phy_id,
int dev_addr, int phy_reg)
{
-
unsigned shor
t data;
+
in
t data;
u32 reg;
if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK)
u32 reg;
if (phy_reg & ~PHY_REG_MASK || phy_id & ~PHY_ID_MASK)
@@
-564,9
+570,14
@@
static void cpsw_set_slave_mac(struct cpsw_slave *slave,
static void cpsw_slave_update_link(struct cpsw_slave *slave,
struct cpsw_priv *priv, int *link)
{
static void cpsw_slave_update_link(struct cpsw_slave *slave,
struct cpsw_priv *priv, int *link)
{
- struct phy_device *phy
= priv->phydev
;
+ struct phy_device *phy;
u32 mac_control = 0;
u32 mac_control = 0;
+ phy = priv->phydev;
+
+ if (!phy)
+ return;
+
phy_startup(phy);
*link = phy->link;
phy_startup(phy);
*link = phy->link;
@@
-600,21
+611,10
@@
static int cpsw_update_link(struct cpsw_priv *priv)
int link = 0;
struct cpsw_slave *slave;
int link = 0;
struct cpsw_slave *slave;
- for_
each
_slave(slave, priv)
+ for_
active
_slave(slave, priv)
cpsw_slave_update_link(slave, priv, &link);
cpsw_slave_update_link(slave, priv, &link);
- priv->mdio_link = readl(&mdio_regs->link);
- return link;
-}
-
-static int cpsw_check_link(struct cpsw_priv *priv)
-{
- u32 link = 0;
-
- link = __raw_readl(&mdio_regs->link) & priv->phy_mask;
- if ((link) && (link == priv->mdio_link))
- return 1;
- return
cpsw_update_link(priv)
;
+ return
link
;
}
static inline u32 cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num)
}
static inline u32 cpsw_get_slave_port(struct cpsw_priv *priv, u32 slave_num)
@@
-645,9
+645,9
@@
static void cpsw_slave_init(struct cpsw_slave *slave, struct cpsw_priv *priv)
slave_port = cpsw_get_slave_port(priv, slave->slave_num);
cpsw_ale_port_state(priv, slave_port, ALE_PORT_STATE_FORWARD);
slave_port = cpsw_get_slave_port(priv, slave->slave_num);
cpsw_ale_port_state(priv, slave_port, ALE_PORT_STATE_FORWARD);
- cpsw_ale_add_mcast(priv,
NetBcastA
ddr, 1 << slave_port);
+ cpsw_ale_add_mcast(priv,
net_bcast_etha
ddr, 1 << slave_port);
- priv->phy_mask |= 1 << slave->data->phy_
id
;
+ priv->phy_mask |= 1 << slave->data->phy_
addr
;
}
static struct cpdma_desc *cpdma_desc_alloc(struct cpsw_priv *priv)
}
static struct cpdma_desc *cpdma_desc_alloc(struct cpsw_priv *priv)
@@
-768,14
+768,15
@@
static int cpsw_init(struct eth_device *dev, bd_t *bis)
/* enable statistics collection only on the host port */
__raw_writel(BIT(priv->host_port), &priv->regs->stat_port_en);
/* enable statistics collection only on the host port */
__raw_writel(BIT(priv->host_port), &priv->regs->stat_port_en);
+ __raw_writel(0x7, &priv->regs->stat_port_en);
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_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_mcast(priv,
NetBcastA
ddr, 1 << priv->host_port);
+ cpsw_ale_add_mcast(priv,
net_bcast_etha
ddr, 1 << priv->host_port);
- for_
each
_slave(slave, priv)
+ for_
active
_slave(slave, priv)
cpsw_slave_init(slave, priv);
cpsw_update_link(priv);
cpsw_slave_init(slave, priv);
cpsw_update_link(priv);
@@
-845,7
+846,7
@@
static int cpsw_init(struct eth_device *dev, bd_t *bis)
/* submit rx descs */
for (i = 0; i < PKTBUFSRX; i++) {
/* submit rx descs */
for (i = 0; i < PKTBUFSRX; i++) {
- ret = cpdma_submit(priv, &priv->rx_chan,
NetRxP
ackets[i],
+ ret = cpdma_submit(priv, &priv->rx_chan,
net_rx_p
ackets[i],
PKTSIZE);
if (ret < 0) {
printf("error %d submitting rx desc\n", ret);
PKTSIZE);
if (ret < 0) {
printf("error %d submitting rx desc\n", ret);
@@
-879,9
+880,6
@@
static int cpsw_send(struct eth_device *dev, void *packet, int length)
int len;
int timeout = CPDMA_TIMEOUT;
int len;
int timeout = CPDMA_TIMEOUT;
- if (!cpsw_check_link(priv))
- return -EIO;
-
flush_dcache_range((unsigned long)packet,
(unsigned long)packet + length);
flush_dcache_range((unsigned long)packet,
(unsigned long)packet + length);
@@
-904,12
+902,10
@@
static int cpsw_recv(struct eth_device *dev)
void *buffer;
int len;
void *buffer;
int len;
- cpsw_update_link(priv);
-
while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
invalidate_dcache_range((unsigned long)buffer,
(unsigned long)buffer + PKTSIZE_ALIGN);
while (cpdma_process(priv, &priv->rx_chan, &buffer, &len) >= 0) {
invalidate_dcache_range((unsigned long)buffer,
(unsigned long)buffer + PKTSIZE_ALIGN);
-
NetReceive
(buffer, len);
+
net_process_received_packet
(buffer, len);
cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE);
}
cpdma_submit(priv, &priv->rx_chan, buffer, PKTSIZE);
}
@@
-931,17
+927,16
@@
static int cpsw_phy_init(struct eth_device *dev, struct cpsw_slave *slave)
{
struct cpsw_priv *priv = (struct cpsw_priv *)dev->priv;
struct phy_device *phydev;
{
struct cpsw_priv *priv = (struct cpsw_priv *)dev->priv;
struct phy_device *phydev;
- u32 supported = (SUPPORTED_10baseT_Half |
- SUPPORTED_10baseT_Full |
- SUPPORTED_100baseT_Half |
- SUPPORTED_100baseT_Full |
- SUPPORTED_1000baseT_Full);
+ u32 supported = PHY_GBIT_FEATURES;
phydev = phy_connect(priv->bus,
phydev = phy_connect(priv->bus,
-
CONFIG_PHY_ADDR
,
+
slave->data->phy_addr
,
dev,
slave->data->phy_if);
dev,
slave->data->phy_if);
+ if (!phydev)
+ return -1;
+
phydev->supported &= supported;
phydev->advertising = phydev->supported;
phydev->supported &= supported;
phydev->advertising = phydev->supported;
@@
-978,12
+973,12
@@
int cpsw_register(struct cpsw_platform_data *data)
return -ENOMEM;
}
return -ENOMEM;
}
- priv->descs = (void *)CPDMA_RAM_ADDR;
priv->host_port = data->host_port_num;
priv->regs = regs;
priv->host_port_regs = regs + data->host_port_reg_ofs;
priv->dma_regs = regs + data->cpdma_reg_ofs;
priv->ale_regs = regs + data->ale_reg_ofs;
priv->host_port = data->host_port_num;
priv->regs = regs;
priv->host_port_regs = regs + data->host_port_reg_ofs;
priv->dma_regs = regs + data->cpdma_reg_ofs;
priv->ale_regs = regs + data->ale_reg_ofs;
+ priv->descs = (void *)regs + data->bd_ram_ofs;
int idx = 0;
int idx = 0;
@@
-1004,7
+999,7
@@
int cpsw_register(struct cpsw_platform_data *data)
cpsw_mdio_init(dev->name, data->mdio_base, data->mdio_div);
priv->bus = miiphy_get_dev_by_name(dev->name);
cpsw_mdio_init(dev->name, data->mdio_base, data->mdio_div);
priv->bus = miiphy_get_dev_by_name(dev->name);
- for_
each
_slave(slave, priv)
+ for_
active
_slave(slave, priv)
cpsw_phy_init(dev, slave);
return 1;
cpsw_phy_init(dev, slave);
return 1;