Commit 427d269f authored by Andrew Victor's avatar Andrew Victor Committed by Jeff Garzik

[PATCH] AT91RM9200 Ethernet #3: Cleanup

Moved global ether_clk variable into controller data structure.
Patch from David Brownell.

Davicom 9161 PHY was being incorrectly displayed as "9196".
Patch from Brian Stafford.

clk_get() doesn't return NULL on error, so the return value needs to be
tested with IS_ERR().

Whitespace cleanup.
Signed-off-by: default avatarAndrew Victor <andrew@sanpeople.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent ca5585ed
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
#define DRV_VERSION "1.0" #define DRV_VERSION "1.0"
static struct net_device *at91_dev; static struct net_device *at91_dev;
static struct clk *ether_clk;
static struct timer_list check_timer; static struct timer_list check_timer;
#define LINK_POLL_INTERVAL (HZ) #define LINK_POLL_INTERVAL (HZ)
...@@ -575,10 +574,8 @@ static void at91ether_set_rx_mode(struct net_device *dev) ...@@ -575,10 +574,8 @@ static void at91ether_set_rx_mode(struct net_device *dev)
at91_emac_write(AT91_EMAC_CFG, cfg); at91_emac_write(AT91_EMAC_CFG, cfg);
} }
/* ......................... ETHTOOL SUPPORT ........................... */ /* ......................... ETHTOOL SUPPORT ........................... */
static int mdio_read(struct net_device *dev, int phy_id, int location) static int mdio_read(struct net_device *dev, int phy_id, int location)
{ {
unsigned int value; unsigned int value;
...@@ -722,7 +719,7 @@ static int at91ether_open(struct net_device *dev) ...@@ -722,7 +719,7 @@ static int at91ether_open(struct net_device *dev)
if (!is_valid_ether_addr(dev->dev_addr)) if (!is_valid_ether_addr(dev->dev_addr))
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
clk_enable(ether_clk); /* Re-enable Peripheral clock */ clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */
/* Clear internal statistics */ /* Clear internal statistics */
ctl = at91_emac_read(AT91_EMAC_CTL); ctl = at91_emac_read(AT91_EMAC_CTL);
...@@ -756,6 +753,7 @@ static int at91ether_open(struct net_device *dev) ...@@ -756,6 +753,7 @@ static int at91ether_open(struct net_device *dev)
*/ */
static int at91ether_close(struct net_device *dev) static int at91ether_close(struct net_device *dev)
{ {
struct at91_private *lp = (struct at91_private *) dev->priv;
unsigned long ctl; unsigned long ctl;
/* Disable Receiver and Transmitter */ /* Disable Receiver and Transmitter */
...@@ -772,7 +770,7 @@ static int at91ether_close(struct net_device *dev) ...@@ -772,7 +770,7 @@ static int at91ether_close(struct net_device *dev)
netif_stop_queue(dev); netif_stop_queue(dev);
clk_disable(ether_clk); /* Disable Peripheral clock */ clk_disable(lp->ether_clk); /* Disable Peripheral clock */
return 0; return 0;
} }
...@@ -933,7 +931,8 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re ...@@ -933,7 +931,8 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re
/* /*
* Initialize the ethernet interface * Initialize the ethernet interface
*/ */
static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev) static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address,
struct platform_device *pdev, struct clk *ether_clk)
{ {
struct at91_eth_data *board_data = pdev->dev.platform_data; struct at91_eth_data *board_data = pdev->dev.platform_data;
struct net_device *dev; struct net_device *dev;
...@@ -967,6 +966,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add ...@@ -967,6 +966,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
return -ENOMEM; return -ENOMEM;
} }
lp->board_data = *board_data; lp->board_data = *board_data;
lp->ether_clk = ether_clk;
platform_set_drvdata(pdev, dev); platform_set_drvdata(pdev, dev);
spin_lock_init(&lp->lock); spin_lock_init(&lp->lock);
...@@ -1050,7 +1050,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add ...@@ -1050,7 +1050,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID))
printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)");
else if (phy_type == MII_LXT971A_ID) else if (phy_type == MII_LXT971A_ID)
printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name);
else if (phy_type == MII_RTL8201_ID) else if (phy_type == MII_RTL8201_ID)
...@@ -1076,9 +1076,10 @@ static int __init at91ether_probe(struct platform_device *pdev) ...@@ -1076,9 +1076,10 @@ static int __init at91ether_probe(struct platform_device *pdev)
int detected = -1; int detected = -1;
unsigned long phy_id; unsigned long phy_id;
unsigned short phy_address = 0; unsigned short phy_address = 0;
struct clk *ether_clk;
ether_clk = clk_get(&pdev->dev, "ether_clk"); ether_clk = clk_get(&pdev->dev, "ether_clk");
if (!ether_clk) { if (IS_ERR(ether_clk)) {
printk(KERN_ERR "at91_ether: no clock defined\n"); printk(KERN_ERR "at91_ether: no clock defined\n");
return -ENODEV; return -ENODEV;
} }
...@@ -1101,7 +1102,7 @@ static int __init at91ether_probe(struct platform_device *pdev) ...@@ -1101,7 +1102,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
case MII_DP83847_ID: /* National Semiconductor DP83847: */ case MII_DP83847_ID: /* National Semiconductor DP83847: */
case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */ case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */
case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */ case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */
detected = at91ether_setup(phy_id, phy_address, pdev); detected = at91ether_setup(phy_id, phy_address, pdev, ether_clk);
break; break;
} }
...@@ -1120,7 +1121,7 @@ static int __devexit at91ether_remove(struct platform_device *pdev) ...@@ -1120,7 +1121,7 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
unregister_netdev(at91_dev); unregister_netdev(at91_dev);
free_irq(at91_dev->irq, at91_dev); free_irq(at91_dev->irq, at91_dev);
dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
clk_put(ether_clk); clk_put(lp->ether_clk);
free_netdev(at91_dev); free_netdev(at91_dev);
at91_dev = NULL; at91_dev = NULL;
......
...@@ -80,6 +80,7 @@ struct at91_private ...@@ -80,6 +80,7 @@ struct at91_private
struct net_device_stats stats; struct net_device_stats stats;
struct mii_if_info mii; /* ethtool support */ struct mii_if_info mii; /* ethtool support */
struct at91_eth_data board_data; /* board-specific configuration */ struct at91_eth_data board_data; /* board-specific configuration */
struct clk *ether_clk; /* clock */
/* PHY */ /* PHY */
unsigned long phy_type; /* type of PHY (PHY_ID) */ unsigned long phy_type; /* type of PHY (PHY_ID) */
......
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