diff options
author | Dale Farnsworth <dale@farnsworth.org> | 2006-01-27 03:18:01 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2006-01-27 11:11:16 -0500 |
commit | 01999873a455fe9104e91820c72849e608239928 (patch) | |
tree | 24695d2629535ed0ccfdaa26d028705bca0eaecf | |
parent | d0412d967032b9e147bcbacc9ff0c0342636cf2d (diff) |
[PATCH] mv643xx_eth: Clean up platform_data configuration
We shouldn't expose the hardware register contents in platform_data.
The only things we allow the user to configure are autoneg, speed, and
duplex. Add specific platform_data fields for these values and remove
the registers configs.
Signed-off-by: Dale Farnsworth <dale@farnsworth.org>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r-- | arch/ppc/platforms/hdpu.c | 5 | ||||
-rw-r--r-- | drivers/net/mv643xx_eth.c | 71 | ||||
-rw-r--r-- | drivers/net/mv643xx_eth.h | 4 | ||||
-rw-r--r-- | include/linux/mv643xx.h | 24 |
4 files changed, 31 insertions, 73 deletions
diff --git a/arch/ppc/platforms/hdpu.c b/arch/ppc/platforms/hdpu.c index 50039a204c24..f945416960e9 100644 --- a/arch/ppc/platforms/hdpu.c +++ b/arch/ppc/platforms/hdpu.c | |||
@@ -319,11 +319,10 @@ static void __init hdpu_fixup_eth_pdata(struct platform_device *pd) | |||
319 | struct mv643xx_eth_platform_data *eth_pd; | 319 | struct mv643xx_eth_platform_data *eth_pd; |
320 | eth_pd = pd->dev.platform_data; | 320 | eth_pd = pd->dev.platform_data; |
321 | 321 | ||
322 | eth_pd->port_serial_control = | ||
323 | mv64x60_read(&bh, MV643XX_ETH_PORT_SERIAL_CONTROL_REG(pd->id) & ~1); | ||
324 | |||
325 | eth_pd->force_phy_addr = 1; | 322 | eth_pd->force_phy_addr = 1; |
326 | eth_pd->phy_addr = pd->id; | 323 | eth_pd->phy_addr = pd->id; |
324 | eth_pd->speed = SPEED_100; | ||
325 | eth_pd->duplex = DUPLEX_FULL; | ||
327 | eth_pd->tx_queue_size = 400; | 326 | eth_pd->tx_queue_size = 400; |
328 | eth_pd->rx_queue_size = 800; | 327 | eth_pd->rx_queue_size = 800; |
329 | } | 328 | } |
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) | |||
266 | static void mv643xx_eth_set_rx_mode(struct net_device *dev) | 266 | static 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); |
diff --git a/drivers/net/mv643xx_eth.h b/drivers/net/mv643xx_eth.h index f2e5da79dde8..a553054e8da7 100644 --- a/drivers/net/mv643xx_eth.h +++ b/drivers/net/mv643xx_eth.h | |||
@@ -321,10 +321,6 @@ struct mv643xx_mib_counters { | |||
321 | 321 | ||
322 | struct mv643xx_private { | 322 | struct mv643xx_private { |
323 | int port_num; /* User Ethernet port number */ | 323 | int port_num; /* User Ethernet port number */ |
324 | u32 port_config; /* User port configuration value*/ | ||
325 | u32 port_config_extend; /* User port config extend value*/ | ||
326 | u32 port_sdma_config; /* User port SDMA config value */ | ||
327 | u32 port_serial_control; /* User port serial control value */ | ||
328 | u32 port_tx_queue_command; /* Port active Tx queues summary*/ | 324 | u32 port_tx_queue_command; /* Port active Tx queues summary*/ |
329 | u32 port_rx_queue_command; /* Port active Rx queues summary*/ | 325 | u32 port_rx_queue_command; /* Port active Rx queues summary*/ |
330 | 326 | ||
diff --git a/include/linux/mv643xx.h b/include/linux/mv643xx.h index 7ffbeac7d2bb..955d3069d727 100644 --- a/include/linux/mv643xx.h +++ b/include/linux/mv643xx.h | |||
@@ -1288,23 +1288,15 @@ struct mv64xxx_i2c_pdata { | |||
1288 | #define MV643XX_ETH_NAME "mv643xx_eth" | 1288 | #define MV643XX_ETH_NAME "mv643xx_eth" |
1289 | 1289 | ||
1290 | struct mv643xx_eth_platform_data { | 1290 | struct mv643xx_eth_platform_data { |
1291 | /* | ||
1292 | * Non-values for mac_addr, phy_addr, port_config, etc. | ||
1293 | * override the default value. Setting the corresponding | ||
1294 | * force_* field, causes the default value to be overridden | ||
1295 | * even when zero. | ||
1296 | */ | ||
1297 | unsigned int force_phy_addr:1; | ||
1298 | unsigned int force_port_config:1; | ||
1299 | unsigned int force_port_config_extend:1; | ||
1300 | unsigned int force_port_sdma_config:1; | ||
1301 | unsigned int force_port_serial_control:1; | ||
1302 | int phy_addr; | ||
1303 | char *mac_addr; /* pointer to mac address */ | 1291 | char *mac_addr; /* pointer to mac address */ |
1304 | u32 port_config; | 1292 | u16 force_phy_addr; /* force override if phy_addr == 0 */ |
1305 | u32 port_config_extend; | 1293 | u16 phy_addr; |
1306 | u32 port_sdma_config; | 1294 | |
1307 | u32 port_serial_control; | 1295 | /* If speed is 0, then speed and duplex are autonegotiated. */ |
1296 | int speed; /* 0, SPEED_10, SPEED_100, SPEED_1000 */ | ||
1297 | int duplex; /* DUPLEX_HALF or DUPLEX_FULL */ | ||
1298 | |||
1299 | /* non-zero values of the following fields override defaults */ | ||
1308 | u32 tx_queue_size; | 1300 | u32 tx_queue_size; |
1309 | u32 rx_queue_size; | 1301 | u32 rx_queue_size; |
1310 | u32 tx_sram_addr; | 1302 | u32 tx_sram_addr; |