aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/mv643xx_eth.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/mv643xx_eth.c')
-rw-r--r--drivers/net/mv643xx_eth.c71
1 files changed, 21 insertions, 50 deletions
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c
index ff2b613a7436..df572018595e 100644
--- a/drivers/net/mv643xx_eth.c
+++ b/drivers/net/mv643xx_eth.c
@@ -266,13 +266,14 @@ static void mv643xx_eth_update_mac_address(struct net_device *dev)
266static void mv643xx_eth_set_rx_mode(struct net_device *dev) 266static void mv643xx_eth_set_rx_mode(struct net_device *dev)
267{ 267{
268 struct mv643xx_private *mp = netdev_priv(dev); 268 struct mv643xx_private *mp = netdev_priv(dev);
269 u32 config_reg;
269 270
271 config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num));
270 if (dev->flags & IFF_PROMISC) 272 if (dev->flags & IFF_PROMISC)
271 mp->port_config |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; 273 config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
272 else 274 else
273 mp->port_config &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; 275 config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
274 276 mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), config_reg);
275 mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), mp->port_config);
276 277
277 eth_port_set_multicast_list(dev); 278 eth_port_set_multicast_list(dev);
278} 279}
@@ -1454,9 +1455,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1454 struct resource *res; 1455 struct resource *res;
1455 int err; 1456 int err;
1456 struct ethtool_cmd cmd; 1457 struct ethtool_cmd cmd;
1457 u32 pscr; 1458 int duplex = DUPLEX_HALF;
1458 int duplex; 1459 int speed = 0; /* default to auto-negotiation */
1459 int speed;
1460 1460
1461 dev = alloc_etherdev(sizeof(struct mv643xx_private)); 1461 dev = alloc_etherdev(sizeof(struct mv643xx_private));
1462 if (!dev) 1462 if (!dev)
@@ -1515,33 +1515,17 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1515 1515
1516 /* set default config values */ 1516 /* set default config values */
1517 eth_port_uc_addr_get(dev, dev->dev_addr); 1517 eth_port_uc_addr_get(dev, dev->dev_addr);
1518 mp->port_config = MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE;
1519 mp->port_config_extend = MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE;
1520 mp->port_sdma_config = MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE;
1521 mp->port_serial_control = MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE;
1522 mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE; 1518 mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
1523 mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE; 1519 mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE;
1524 1520
1525 pd = pdev->dev.platform_data; 1521 pd = pdev->dev.platform_data;
1526 if (pd) { 1522 if (pd) {
1527 if (pd->mac_addr != NULL) 1523 if (pd->mac_addr)
1528 memcpy(dev->dev_addr, pd->mac_addr, 6); 1524 memcpy(dev->dev_addr, pd->mac_addr, 6);
1529 1525
1530 if (pd->phy_addr || pd->force_phy_addr) 1526 if (pd->phy_addr || pd->force_phy_addr)
1531 ethernet_phy_set(port_num, pd->phy_addr); 1527 ethernet_phy_set(port_num, pd->phy_addr);
1532 1528
1533 if (pd->port_config || pd->force_port_config)
1534 mp->port_config = pd->port_config;
1535
1536 if (pd->port_config_extend || pd->force_port_config_extend)
1537 mp->port_config_extend = pd->port_config_extend;
1538
1539 if (pd->port_sdma_config || pd->force_port_sdma_config)
1540 mp->port_sdma_config = pd->port_sdma_config;
1541
1542 if (pd->port_serial_control || pd->force_port_serial_control)
1543 mp->port_serial_control = pd->port_serial_control;
1544
1545 if (pd->rx_queue_size) 1529 if (pd->rx_queue_size)
1546 mp->rx_ring_size = pd->rx_queue_size; 1530 mp->rx_ring_size = pd->rx_queue_size;
1547 1531
@@ -1557,6 +1541,9 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1557 mp->rx_sram_size = pd->rx_sram_size; 1541 mp->rx_sram_size = pd->rx_sram_size;
1558 mp->rx_sram_addr = pd->rx_sram_addr; 1542 mp->rx_sram_addr = pd->rx_sram_addr;
1559 } 1543 }
1544
1545 duplex = pd->duplex;
1546 speed = pd->speed;
1560 } 1547 }
1561 1548
1562 /* Hook up MII support for ethtool */ 1549 /* Hook up MII support for ethtool */
@@ -1575,28 +1562,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
1575 goto out; 1562 goto out;
1576 } 1563 }
1577 1564
1578 pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); 1565 ethernet_phy_reset(port_num);
1579 pscr &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
1580 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1581 pscr = mp->port_serial_control;
1582 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1583
1584 if (!(pscr & MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX) &&
1585 !(pscr & MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII))
1586 speed = 0;
1587 else if (pscr & MV643XX_ETH_PORT_STATUS_GMII_1000)
1588 speed = SPEED_1000;
1589 else if (pscr & MV643XX_ETH_PORT_STATUS_MII_100)
1590 speed = SPEED_100;
1591 else
1592 speed = SPEED_10;
1593
1594 if (pscr & MV643XX_ETH_PORT_STATUS_FULL_DUPLEX)
1595 duplex = DUPLEX_FULL;
1596 else
1597 duplex = DUPLEX_HALF;
1598
1599 ethernet_phy_reset(mp->port_num);
1600 mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii); 1566 mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii);
1601 mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd); 1567 mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd);
1602 mv643xx_eth_update_pscr(dev, &cmd); 1568 mv643xx_eth_update_pscr(dev, &cmd);
@@ -1971,13 +1937,17 @@ static void eth_port_start(struct net_device *dev)
1971 eth_port_uc_addr_set(port_num, dev->dev_addr); 1937 eth_port_uc_addr_set(port_num, dev->dev_addr);
1972 1938
1973 /* Assign port configuration and command. */ 1939 /* Assign port configuration and command. */
1974 mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num), mp->port_config); 1940 mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
1941 MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE);
1942
1943 mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
1944 MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE);
1975 1945
1976 pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); 1946 pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
1977 pscr &= ~MV643XX_ETH_SERIAL_PORT_ENABLE; 1947
1948 pscr &= ~(MV643XX_ETH_SERIAL_PORT_ENABLE | MV643XX_ETH_FORCE_LINK_PASS);
1978 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); 1949 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1979 1950
1980 pscr &= ~MV643XX_ETH_FORCE_LINK_PASS;
1981 pscr |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL | 1951 pscr |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
1982 MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII | 1952 MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII |
1983 MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX | 1953 MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX |
@@ -1990,7 +1960,8 @@ static void eth_port_start(struct net_device *dev)
1990 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); 1960 mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
1991 1961
1992 /* Assign port SDMA configuration */ 1962 /* Assign port SDMA configuration */
1993 mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num), mp->port_sdma_config); 1963 mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num),
1964 MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE);
1994 1965
1995 /* Enable port Rx. */ 1966 /* Enable port Rx. */
1996 mv643xx_eth_port_enable_rx(port_num, mp->port_rx_queue_command); 1967 mv643xx_eth_port_enable_rx(port_num, mp->port_rx_queue_command);