提交 01999873 编写于 作者: D Dale Farnsworth 提交者: Jeff Garzik

[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: NDale Farnsworth <dale@farnsworth.org>
Signed-off-by: NJeff Garzik <jgarzik@pobox.com>
上级 d0412d96
...@@ -319,11 +319,10 @@ static void __init hdpu_fixup_eth_pdata(struct platform_device *pd) ...@@ -319,11 +319,10 @@ static void __init hdpu_fixup_eth_pdata(struct platform_device *pd)
struct mv643xx_eth_platform_data *eth_pd; struct mv643xx_eth_platform_data *eth_pd;
eth_pd = pd->dev.platform_data; eth_pd = pd->dev.platform_data;
eth_pd->port_serial_control =
mv64x60_read(&bh, MV643XX_ETH_PORT_SERIAL_CONTROL_REG(pd->id) & ~1);
eth_pd->force_phy_addr = 1; eth_pd->force_phy_addr = 1;
eth_pd->phy_addr = pd->id; eth_pd->phy_addr = pd->id;
eth_pd->speed = SPEED_100;
eth_pd->duplex = DUPLEX_FULL;
eth_pd->tx_queue_size = 400; eth_pd->tx_queue_size = 400;
eth_pd->rx_queue_size = 800; eth_pd->rx_queue_size = 800;
} }
......
...@@ -266,13 +266,14 @@ static void mv643xx_eth_update_mac_address(struct net_device *dev) ...@@ -266,13 +266,14 @@ static void mv643xx_eth_update_mac_address(struct net_device *dev)
static void mv643xx_eth_set_rx_mode(struct net_device *dev) static void mv643xx_eth_set_rx_mode(struct net_device *dev)
{ {
struct mv643xx_private *mp = netdev_priv(dev); struct mv643xx_private *mp = netdev_priv(dev);
u32 config_reg;
config_reg = mv_read(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num));
if (dev->flags & IFF_PROMISC) if (dev->flags & IFF_PROMISC)
mp->port_config |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; config_reg |= (u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
else else
mp->port_config &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE; config_reg &= ~(u32) MV643XX_ETH_UNICAST_PROMISCUOUS_MODE;
mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), config_reg);
mv_write(MV643XX_ETH_PORT_CONFIG_REG(mp->port_num), mp->port_config);
eth_port_set_multicast_list(dev); eth_port_set_multicast_list(dev);
} }
...@@ -1454,9 +1455,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1454,9 +1455,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
struct resource *res; struct resource *res;
int err; int err;
struct ethtool_cmd cmd; struct ethtool_cmd cmd;
u32 pscr; int duplex = DUPLEX_HALF;
int duplex; int speed = 0; /* default to auto-negotiation */
int speed;
dev = alloc_etherdev(sizeof(struct mv643xx_private)); dev = alloc_etherdev(sizeof(struct mv643xx_private));
if (!dev) if (!dev)
...@@ -1515,33 +1515,17 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1515,33 +1515,17 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
/* set default config values */ /* set default config values */
eth_port_uc_addr_get(dev, dev->dev_addr); eth_port_uc_addr_get(dev, dev->dev_addr);
mp->port_config = MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE;
mp->port_config_extend = MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE;
mp->port_sdma_config = MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE;
mp->port_serial_control = MV643XX_ETH_PORT_SERIAL_CONTROL_DEFAULT_VALUE;
mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE; mp->rx_ring_size = MV643XX_ETH_PORT_DEFAULT_RECEIVE_QUEUE_SIZE;
mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE; mp->tx_ring_size = MV643XX_ETH_PORT_DEFAULT_TRANSMIT_QUEUE_SIZE;
pd = pdev->dev.platform_data; pd = pdev->dev.platform_data;
if (pd) { if (pd) {
if (pd->mac_addr != NULL) if (pd->mac_addr)
memcpy(dev->dev_addr, pd->mac_addr, 6); memcpy(dev->dev_addr, pd->mac_addr, 6);
if (pd->phy_addr || pd->force_phy_addr) if (pd->phy_addr || pd->force_phy_addr)
ethernet_phy_set(port_num, pd->phy_addr); ethernet_phy_set(port_num, pd->phy_addr);
if (pd->port_config || pd->force_port_config)
mp->port_config = pd->port_config;
if (pd->port_config_extend || pd->force_port_config_extend)
mp->port_config_extend = pd->port_config_extend;
if (pd->port_sdma_config || pd->force_port_sdma_config)
mp->port_sdma_config = pd->port_sdma_config;
if (pd->port_serial_control || pd->force_port_serial_control)
mp->port_serial_control = pd->port_serial_control;
if (pd->rx_queue_size) if (pd->rx_queue_size)
mp->rx_ring_size = pd->rx_queue_size; mp->rx_ring_size = pd->rx_queue_size;
...@@ -1557,6 +1541,9 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1557,6 +1541,9 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
mp->rx_sram_size = pd->rx_sram_size; mp->rx_sram_size = pd->rx_sram_size;
mp->rx_sram_addr = pd->rx_sram_addr; mp->rx_sram_addr = pd->rx_sram_addr;
} }
duplex = pd->duplex;
speed = pd->speed;
} }
/* Hook up MII support for ethtool */ /* Hook up MII support for ethtool */
...@@ -1575,28 +1562,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1575,28 +1562,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
goto out; goto out;
} }
pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); ethernet_phy_reset(port_num);
pscr &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
pscr = mp->port_serial_control;
mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
if (!(pscr & MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX) &&
!(pscr & MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII))
speed = 0;
else if (pscr & MV643XX_ETH_PORT_STATUS_GMII_1000)
speed = SPEED_1000;
else if (pscr & MV643XX_ETH_PORT_STATUS_MII_100)
speed = SPEED_100;
else
speed = SPEED_10;
if (pscr & MV643XX_ETH_PORT_STATUS_FULL_DUPLEX)
duplex = DUPLEX_FULL;
else
duplex = DUPLEX_HALF;
ethernet_phy_reset(mp->port_num);
mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii); mp->mii.supports_gmii = mii_check_gmii_support(&mp->mii);
mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd); mv643xx_init_ethtool_cmd(dev, mp->mii.phy_id, speed, duplex, &cmd);
mv643xx_eth_update_pscr(dev, &cmd); mv643xx_eth_update_pscr(dev, &cmd);
...@@ -1971,13 +1937,17 @@ static void eth_port_start(struct net_device *dev) ...@@ -1971,13 +1937,17 @@ static void eth_port_start(struct net_device *dev)
eth_port_uc_addr_set(port_num, dev->dev_addr); eth_port_uc_addr_set(port_num, dev->dev_addr);
/* Assign port configuration and command. */ /* Assign port configuration and command. */
mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num), mp->port_config); mv_write(MV643XX_ETH_PORT_CONFIG_REG(port_num),
MV643XX_ETH_PORT_CONFIG_DEFAULT_VALUE);
mv_write(MV643XX_ETH_PORT_CONFIG_EXTEND_REG(port_num),
MV643XX_ETH_PORT_CONFIG_EXTEND_DEFAULT_VALUE);
pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num)); pscr = mv_read(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num));
pscr &= ~MV643XX_ETH_SERIAL_PORT_ENABLE;
pscr &= ~(MV643XX_ETH_SERIAL_PORT_ENABLE | MV643XX_ETH_FORCE_LINK_PASS);
mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
pscr &= ~MV643XX_ETH_FORCE_LINK_PASS;
pscr |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL | pscr |= MV643XX_ETH_DISABLE_AUTO_NEG_FOR_FLOW_CTRL |
MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII | MV643XX_ETH_DISABLE_AUTO_NEG_SPEED_GMII |
MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX | MV643XX_ETH_DISABLE_AUTO_NEG_FOR_DUPLX |
...@@ -1990,7 +1960,8 @@ static void eth_port_start(struct net_device *dev) ...@@ -1990,7 +1960,8 @@ static void eth_port_start(struct net_device *dev)
mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr); mv_write(MV643XX_ETH_PORT_SERIAL_CONTROL_REG(port_num), pscr);
/* Assign port SDMA configuration */ /* Assign port SDMA configuration */
mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num), mp->port_sdma_config); mv_write(MV643XX_ETH_SDMA_CONFIG_REG(port_num),
MV643XX_ETH_PORT_SDMA_CONFIG_DEFAULT_VALUE);
/* Enable port Rx. */ /* Enable port Rx. */
mv643xx_eth_port_enable_rx(port_num, mp->port_rx_queue_command); mv643xx_eth_port_enable_rx(port_num, mp->port_rx_queue_command);
......
...@@ -321,10 +321,6 @@ struct mv643xx_mib_counters { ...@@ -321,10 +321,6 @@ struct mv643xx_mib_counters {
struct mv643xx_private { struct mv643xx_private {
int port_num; /* User Ethernet port number */ int port_num; /* User Ethernet port number */
u32 port_config; /* User port configuration value*/
u32 port_config_extend; /* User port config extend value*/
u32 port_sdma_config; /* User port SDMA config value */
u32 port_serial_control; /* User port serial control value */
u32 port_tx_queue_command; /* Port active Tx queues summary*/ u32 port_tx_queue_command; /* Port active Tx queues summary*/
u32 port_rx_queue_command; /* Port active Rx queues summary*/ u32 port_rx_queue_command; /* Port active Rx queues summary*/
......
...@@ -1288,23 +1288,15 @@ struct mv64xxx_i2c_pdata { ...@@ -1288,23 +1288,15 @@ struct mv64xxx_i2c_pdata {
#define MV643XX_ETH_NAME "mv643xx_eth" #define MV643XX_ETH_NAME "mv643xx_eth"
struct mv643xx_eth_platform_data { struct mv643xx_eth_platform_data {
/*
* Non-values for mac_addr, phy_addr, port_config, etc.
* override the default value. Setting the corresponding
* force_* field, causes the default value to be overridden
* even when zero.
*/
unsigned int force_phy_addr:1;
unsigned int force_port_config:1;
unsigned int force_port_config_extend:1;
unsigned int force_port_sdma_config:1;
unsigned int force_port_serial_control:1;
int phy_addr;
char *mac_addr; /* pointer to mac address */ char *mac_addr; /* pointer to mac address */
u32 port_config; u16 force_phy_addr; /* force override if phy_addr == 0 */
u32 port_config_extend; u16 phy_addr;
u32 port_sdma_config;
u32 port_serial_control; /* If speed is 0, then speed and duplex are autonegotiated. */
int speed; /* 0, SPEED_10, SPEED_100, SPEED_1000 */
int duplex; /* DUPLEX_HALF or DUPLEX_FULL */
/* non-zero values of the following fields override defaults */
u32 tx_queue_size; u32 tx_queue_size;
u32 rx_queue_size; u32 rx_queue_size;
u32 tx_sram_addr; u32 tx_sram_addr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册