Commit 84dd619e authored by Dale Farnsworth's avatar Dale Farnsworth Committed by Jeff Garzik

mv643xx_eth: Place explicit port number in mv643xx_eth_platform_data

We were using the platform_device.id field to identify which ethernet
port is used for mv643xx_eth device.  This is not generally correct.
It will be incorrect, for example, if a hardware platform uses a single
port but not the first port.  Here, we add an explicit port_number field
to struct mv643xx_eth_platform_data.

This makes the mv643xx_eth_platform_data structure required, but that
isn't an issue since all users currently provide it already.
Signed-off-by: default avatarDale Farnsworth <dale@farnsworth.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent b2cbbd8e
...@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_resources[] = { ...@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth0_pd = { static struct mv643xx_eth_platform_data eth0_pd = {
.port_number = 0,
.tx_sram_addr = MV_SRAM_BASE_ETH0, .tx_sram_addr = MV_SRAM_BASE_ETH0,
.tx_sram_size = MV_SRAM_TXRING_SIZE, .tx_sram_size = MV_SRAM_TXRING_SIZE,
.tx_queue_size = MV_SRAM_TXRING_SIZE / 16, .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
...@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_resources[] = { ...@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth1_pd = { static struct mv643xx_eth_platform_data eth1_pd = {
.port_number = 1,
.tx_sram_addr = MV_SRAM_BASE_ETH1, .tx_sram_addr = MV_SRAM_BASE_ETH1,
.tx_sram_size = MV_SRAM_TXRING_SIZE, .tx_sram_size = MV_SRAM_TXRING_SIZE,
.tx_queue_size = MV_SRAM_TXRING_SIZE / 16, .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
...@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_resources[] = { ...@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_resources[] = {
}, },
}; };
static struct mv643xx_eth_platform_data eth2_pd; static struct mv643xx_eth_platform_data eth2_pd = {
.port_number = 2,
};
static struct platform_device eth2_device = { static struct platform_device eth2_device = {
.name = MV643XX_ETH_NAME, .name = MV643XX_ETH_NAME,
......
...@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_resources[] = { ...@@ -48,6 +48,8 @@ static struct resource mv64x60_eth0_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth0_pd = { static struct mv643xx_eth_platform_data eth0_pd = {
.port_number = 0,
.tx_sram_addr = MV_SRAM_BASE_ETH0, .tx_sram_addr = MV_SRAM_BASE_ETH0,
.tx_sram_size = MV_SRAM_TXRING_SIZE, .tx_sram_size = MV_SRAM_TXRING_SIZE,
.tx_queue_size = MV_SRAM_TXRING_SIZE / 16, .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
...@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_resources[] = { ...@@ -77,6 +79,8 @@ static struct resource mv64x60_eth1_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth1_pd = { static struct mv643xx_eth_platform_data eth1_pd = {
.port_number = 1,
.tx_sram_addr = MV_SRAM_BASE_ETH1, .tx_sram_addr = MV_SRAM_BASE_ETH1,
.tx_sram_size = MV_SRAM_TXRING_SIZE, .tx_sram_size = MV_SRAM_TXRING_SIZE,
.tx_queue_size = MV_SRAM_TXRING_SIZE / 16, .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
...@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_resources[] = { ...@@ -105,7 +109,9 @@ static struct resource mv64x60_eth2_resources[] = {
}, },
}; };
static struct mv643xx_eth_platform_data eth2_pd; static struct mv643xx_eth_platform_data eth2_pd = {
.port_number = 2,
};
static struct platform_device eth2_device = { static struct platform_device eth2_device = {
.name = MV643XX_ETH_NAME, .name = MV643XX_ETH_NAME,
......
...@@ -47,6 +47,8 @@ static struct resource mv64x60_eth0_resources[] = { ...@@ -47,6 +47,8 @@ static struct resource mv64x60_eth0_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth0_pd = { static struct mv643xx_eth_platform_data eth0_pd = {
.port_number = 0,
.tx_sram_addr = MV_SRAM_BASE_ETH0, .tx_sram_addr = MV_SRAM_BASE_ETH0,
.tx_sram_size = MV_SRAM_TXRING_SIZE, .tx_sram_size = MV_SRAM_TXRING_SIZE,
.tx_queue_size = MV_SRAM_TXRING_SIZE / 16, .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
...@@ -76,6 +78,8 @@ static struct resource mv64x60_eth1_resources[] = { ...@@ -76,6 +78,8 @@ static struct resource mv64x60_eth1_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth1_pd = { static struct mv643xx_eth_platform_data eth1_pd = {
.port_number = 1,
.tx_sram_addr = MV_SRAM_BASE_ETH1, .tx_sram_addr = MV_SRAM_BASE_ETH1,
.tx_sram_size = MV_SRAM_TXRING_SIZE, .tx_sram_size = MV_SRAM_TXRING_SIZE,
.tx_queue_size = MV_SRAM_TXRING_SIZE / 16, .tx_queue_size = MV_SRAM_TXRING_SIZE / 16,
......
...@@ -58,6 +58,7 @@ static struct resource mv643xx_eth0_resources[] = { ...@@ -58,6 +58,7 @@ static struct resource mv643xx_eth0_resources[] = {
static struct mv643xx_eth_platform_data eth0_pd = { static struct mv643xx_eth_platform_data eth0_pd = {
.port_number = 0,
.tx_sram_addr = PEGASOS2_SRAM_BASE_ETH0, .tx_sram_addr = PEGASOS2_SRAM_BASE_ETH0,
.tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE, .tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
.tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16, .tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
...@@ -87,6 +88,7 @@ static struct resource mv643xx_eth1_resources[] = { ...@@ -87,6 +88,7 @@ static struct resource mv643xx_eth1_resources[] = {
}; };
static struct mv643xx_eth_platform_data eth1_pd = { static struct mv643xx_eth_platform_data eth1_pd = {
.port_number = 1,
.tx_sram_addr = PEGASOS2_SRAM_BASE_ETH1, .tx_sram_addr = PEGASOS2_SRAM_BASE_ETH1,
.tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE, .tx_sram_size = PEGASOS2_SRAM_TXRING_SIZE,
.tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16, .tx_queue_size = PEGASOS2_SRAM_TXRING_SIZE/16,
......
...@@ -339,7 +339,9 @@ static struct resource mv64x60_eth0_resources[] = { ...@@ -339,7 +339,9 @@ static struct resource mv64x60_eth0_resources[] = {
}, },
}; };
static struct mv643xx_eth_platform_data eth0_pd; static struct mv643xx_eth_platform_data eth0_pd = {
.port_number = 0,
};
static struct platform_device eth0_device = { static struct platform_device eth0_device = {
.name = MV643XX_ETH_NAME, .name = MV643XX_ETH_NAME,
...@@ -362,7 +364,9 @@ static struct resource mv64x60_eth1_resources[] = { ...@@ -362,7 +364,9 @@ static struct resource mv64x60_eth1_resources[] = {
}, },
}; };
static struct mv643xx_eth_platform_data eth1_pd; static struct mv643xx_eth_platform_data eth1_pd = {
.port_number = 1,
};
static struct platform_device eth1_device = { static struct platform_device eth1_device = {
.name = MV643XX_ETH_NAME, .name = MV643XX_ETH_NAME,
...@@ -385,7 +389,9 @@ static struct resource mv64x60_eth2_resources[] = { ...@@ -385,7 +389,9 @@ static struct resource mv64x60_eth2_resources[] = {
}, },
}; };
static struct mv643xx_eth_platform_data eth2_pd; static struct mv643xx_eth_platform_data eth2_pd = {
.port_number = 2,
};
static struct platform_device eth2_device = { static struct platform_device eth2_device = {
.name = MV643XX_ETH_NAME, .name = MV643XX_ETH_NAME,
......
...@@ -1309,7 +1309,7 @@ static void mv643xx_init_ethtool_cmd(struct net_device *dev, int phy_address, ...@@ -1309,7 +1309,7 @@ static void mv643xx_init_ethtool_cmd(struct net_device *dev, int phy_address,
static int mv643xx_eth_probe(struct platform_device *pdev) static int mv643xx_eth_probe(struct platform_device *pdev)
{ {
struct mv643xx_eth_platform_data *pd; struct mv643xx_eth_platform_data *pd;
int port_num = pdev->id; int port_num;
struct mv643xx_private *mp; struct mv643xx_private *mp;
struct net_device *dev; struct net_device *dev;
u8 *p; u8 *p;
...@@ -1319,6 +1319,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1319,6 +1319,12 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
int duplex = DUPLEX_HALF; int duplex = DUPLEX_HALF;
int speed = 0; /* default to auto-negotiation */ int speed = 0; /* default to auto-negotiation */
pd = pdev->dev.platform_data;
if (pd == NULL) {
printk(KERN_ERR "No mv643xx_eth_platform_data\n");
return -ENODEV;
}
dev = alloc_etherdev(sizeof(struct mv643xx_private)); dev = alloc_etherdev(sizeof(struct mv643xx_private));
if (!dev) if (!dev)
return -ENOMEM; return -ENOMEM;
...@@ -1331,8 +1337,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1331,8 +1337,6 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
BUG_ON(!res); BUG_ON(!res);
dev->irq = res->start; dev->irq = res->start;
mp->port_num = port_num;
dev->open = mv643xx_eth_open; dev->open = mv643xx_eth_open;
dev->stop = mv643xx_eth_stop; dev->stop = mv643xx_eth_stop;
dev->hard_start_xmit = mv643xx_eth_start_xmit; dev->hard_start_xmit = mv643xx_eth_start_xmit;
...@@ -1373,39 +1377,40 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1373,39 +1377,40 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
spin_lock_init(&mp->lock); spin_lock_init(&mp->lock);
port_num = pd->port_number;
/* 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->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; if (is_valid_ether_addr(pd->mac_addr))
if (pd) { memcpy(dev->dev_addr, pd->mac_addr, 6);
if (is_valid_ether_addr(pd->mac_addr))
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->rx_queue_size) if (pd->rx_queue_size)
mp->rx_ring_size = pd->rx_queue_size; mp->rx_ring_size = pd->rx_queue_size;
if (pd->tx_queue_size) if (pd->tx_queue_size)
mp->tx_ring_size = pd->tx_queue_size; mp->tx_ring_size = pd->tx_queue_size;
if (pd->tx_sram_size) { if (pd->tx_sram_size) {
mp->tx_sram_size = pd->tx_sram_size; mp->tx_sram_size = pd->tx_sram_size;
mp->tx_sram_addr = pd->tx_sram_addr; mp->tx_sram_addr = pd->tx_sram_addr;
} }
if (pd->rx_sram_size) {
mp->rx_sram_size = pd->rx_sram_size;
mp->rx_sram_addr = pd->rx_sram_addr;
}
duplex = pd->duplex; if (pd->rx_sram_size) {
speed = pd->speed; mp->rx_sram_size = pd->rx_sram_size;
mp->rx_sram_addr = pd->rx_sram_addr;
} }
duplex = pd->duplex;
speed = pd->speed;
mp->port_num = port_num;
/* Hook up MII support for ethtool */ /* Hook up MII support for ethtool */
mp->mii.dev = dev; mp->mii.dev = dev;
mp->mii.mdio_read = mv643xx_mdio_read; mp->mii.mdio_read = mv643xx_mdio_read;
......
...@@ -1288,6 +1288,7 @@ struct mv64xxx_i2c_pdata { ...@@ -1288,6 +1288,7 @@ 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 {
int port_number;
u16 force_phy_addr; /* force override if phy_addr == 0 */ u16 force_phy_addr; /* force override if phy_addr == 0 */
u16 phy_addr; u16 phy_addr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment