diff options
-rw-r--r-- | drivers/net/arm/at91_ether.c | 29 | ||||
-rw-r--r-- | drivers/net/arm/at91_ether.h | 1 |
2 files changed, 16 insertions, 14 deletions
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c index cc773662d9f9..d081241f613d 100644 --- a/drivers/net/arm/at91_ether.c +++ b/drivers/net/arm/at91_ether.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #define DRV_VERSION "1.0" | 43 | #define DRV_VERSION "1.0" |
44 | 44 | ||
45 | static struct net_device *at91_dev; | 45 | static struct net_device *at91_dev; |
46 | static struct clk *ether_clk; | ||
47 | 46 | ||
48 | static struct timer_list check_timer; | 47 | static struct timer_list check_timer; |
49 | #define LINK_POLL_INTERVAL (HZ) | 48 | #define LINK_POLL_INTERVAL (HZ) |
@@ -519,7 +518,7 @@ static int hash_get_index(__u8 *addr) | |||
519 | hash_index |= (bitval << j); | 518 | hash_index |= (bitval << j); |
520 | } | 519 | } |
521 | 520 | ||
522 | return hash_index; | 521 | return hash_index; |
523 | } | 522 | } |
524 | 523 | ||
525 | /* | 524 | /* |
@@ -575,10 +574,8 @@ static void at91ether_set_rx_mode(struct net_device *dev) | |||
575 | at91_emac_write(AT91_EMAC_CFG, cfg); | 574 | at91_emac_write(AT91_EMAC_CFG, cfg); |
576 | } | 575 | } |
577 | 576 | ||
578 | |||
579 | /* ......................... ETHTOOL SUPPORT ........................... */ | 577 | /* ......................... ETHTOOL SUPPORT ........................... */ |
580 | 578 | ||
581 | |||
582 | static int mdio_read(struct net_device *dev, int phy_id, int location) | 579 | static int mdio_read(struct net_device *dev, int phy_id, int location) |
583 | { | 580 | { |
584 | unsigned int value; | 581 | unsigned int value; |
@@ -719,10 +716,10 @@ static int at91ether_open(struct net_device *dev) | |||
719 | struct at91_private *lp = (struct at91_private *) dev->priv; | 716 | struct at91_private *lp = (struct at91_private *) dev->priv; |
720 | unsigned long ctl; | 717 | unsigned long ctl; |
721 | 718 | ||
722 | if (!is_valid_ether_addr(dev->dev_addr)) | 719 | if (!is_valid_ether_addr(dev->dev_addr)) |
723 | return -EADDRNOTAVAIL; | 720 | return -EADDRNOTAVAIL; |
724 | 721 | ||
725 | clk_enable(ether_clk); /* Re-enable Peripheral clock */ | 722 | clk_enable(lp->ether_clk); /* Re-enable Peripheral clock */ |
726 | 723 | ||
727 | /* Clear internal statistics */ | 724 | /* Clear internal statistics */ |
728 | ctl = at91_emac_read(AT91_EMAC_CTL); | 725 | ctl = at91_emac_read(AT91_EMAC_CTL); |
@@ -756,6 +753,7 @@ static int at91ether_open(struct net_device *dev) | |||
756 | */ | 753 | */ |
757 | static int at91ether_close(struct net_device *dev) | 754 | static int at91ether_close(struct net_device *dev) |
758 | { | 755 | { |
756 | struct at91_private *lp = (struct at91_private *) dev->priv; | ||
759 | unsigned long ctl; | 757 | unsigned long ctl; |
760 | 758 | ||
761 | /* Disable Receiver and Transmitter */ | 759 | /* Disable Receiver and Transmitter */ |
@@ -772,7 +770,7 @@ static int at91ether_close(struct net_device *dev) | |||
772 | 770 | ||
773 | netif_stop_queue(dev); | 771 | netif_stop_queue(dev); |
774 | 772 | ||
775 | clk_disable(ether_clk); /* Disable Peripheral clock */ | 773 | clk_disable(lp->ether_clk); /* Disable Peripheral clock */ |
776 | 774 | ||
777 | return 0; | 775 | return 0; |
778 | } | 776 | } |
@@ -904,7 +902,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re | |||
904 | if (intstatus & AT91_EMAC_RCOM) /* Receive complete */ | 902 | if (intstatus & AT91_EMAC_RCOM) /* Receive complete */ |
905 | at91ether_rx(dev); | 903 | at91ether_rx(dev); |
906 | 904 | ||
907 | if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */ | 905 | if (intstatus & AT91_EMAC_TCOM) { /* Transmit complete */ |
908 | /* The TCOM bit is set even if the transmission failed. */ | 906 | /* The TCOM bit is set even if the transmission failed. */ |
909 | if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY)) | 907 | if (intstatus & (AT91_EMAC_TUND | AT91_EMAC_RTRY)) |
910 | lp->stats.tx_errors += 1; | 908 | lp->stats.tx_errors += 1; |
@@ -933,7 +931,8 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id, struct pt_regs *re | |||
933 | /* | 931 | /* |
934 | * Initialize the ethernet interface | 932 | * Initialize the ethernet interface |
935 | */ | 933 | */ |
936 | static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, struct platform_device *pdev) | 934 | static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_address, |
935 | struct platform_device *pdev, struct clk *ether_clk) | ||
937 | { | 936 | { |
938 | struct at91_eth_data *board_data = pdev->dev.platform_data; | 937 | struct at91_eth_data *board_data = pdev->dev.platform_data; |
939 | struct net_device *dev; | 938 | struct net_device *dev; |
@@ -967,6 +966,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
967 | return -ENOMEM; | 966 | return -ENOMEM; |
968 | } | 967 | } |
969 | lp->board_data = *board_data; | 968 | lp->board_data = *board_data; |
969 | lp->ether_clk = ether_clk; | ||
970 | platform_set_drvdata(pdev, dev); | 970 | platform_set_drvdata(pdev, dev); |
971 | 971 | ||
972 | spin_lock_init(&lp->lock); | 972 | spin_lock_init(&lp->lock); |
@@ -1050,7 +1050,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
1050 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], | 1050 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], |
1051 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); | 1051 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); |
1052 | if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) | 1052 | if ((phy_type == MII_DM9161_ID) || (lp->phy_type == MII_DM9161A_ID)) |
1053 | printk(KERN_INFO "%s: Davicom 9196 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); | 1053 | printk(KERN_INFO "%s: Davicom 9161 PHY %s\n", dev->name, (lp->phy_media == PORT_FIBRE) ? "(Fiber)" : "(Copper)"); |
1054 | else if (phy_type == MII_LXT971A_ID) | 1054 | else if (phy_type == MII_LXT971A_ID) |
1055 | printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); | 1055 | printk(KERN_INFO "%s: Intel LXT971A PHY\n", dev->name); |
1056 | else if (phy_type == MII_RTL8201_ID) | 1056 | else if (phy_type == MII_RTL8201_ID) |
@@ -1076,9 +1076,10 @@ static int __init at91ether_probe(struct platform_device *pdev) | |||
1076 | int detected = -1; | 1076 | int detected = -1; |
1077 | unsigned long phy_id; | 1077 | unsigned long phy_id; |
1078 | unsigned short phy_address = 0; | 1078 | unsigned short phy_address = 0; |
1079 | struct clk *ether_clk; | ||
1079 | 1080 | ||
1080 | ether_clk = clk_get(&pdev->dev, "ether_clk"); | 1081 | ether_clk = clk_get(&pdev->dev, "ether_clk"); |
1081 | if (!ether_clk) { | 1082 | if (IS_ERR(ether_clk)) { |
1082 | printk(KERN_ERR "at91_ether: no clock defined\n"); | 1083 | printk(KERN_ERR "at91_ether: no clock defined\n"); |
1083 | return -ENODEV; | 1084 | return -ENODEV; |
1084 | } | 1085 | } |
@@ -1101,7 +1102,7 @@ static int __init at91ether_probe(struct platform_device *pdev) | |||
1101 | case MII_DP83847_ID: /* National Semiconductor DP83847: */ | 1102 | case MII_DP83847_ID: /* National Semiconductor DP83847: */ |
1102 | case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */ | 1103 | case MII_AC101L_ID: /* Altima AC101L: PHY_ID1 = 0x22, PHY_ID2 = 0x5520 */ |
1103 | case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */ | 1104 | case MII_KS8721_ID: /* Micrel KS8721: PHY_ID1 = 0x22, PHY_ID2 = 0x1610 */ |
1104 | detected = at91ether_setup(phy_id, phy_address, pdev); | 1105 | detected = at91ether_setup(phy_id, phy_address, pdev, ether_clk); |
1105 | break; | 1106 | break; |
1106 | } | 1107 | } |
1107 | 1108 | ||
@@ -1120,7 +1121,7 @@ static int __devexit at91ether_remove(struct platform_device *pdev) | |||
1120 | unregister_netdev(at91_dev); | 1121 | unregister_netdev(at91_dev); |
1121 | free_irq(at91_dev->irq, at91_dev); | 1122 | free_irq(at91_dev->irq, at91_dev); |
1122 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); | 1123 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); |
1123 | clk_put(ether_clk); | 1124 | clk_put(lp->ether_clk); |
1124 | 1125 | ||
1125 | free_netdev(at91_dev); | 1126 | free_netdev(at91_dev); |
1126 | at91_dev = NULL; | 1127 | at91_dev = NULL; |
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h index 9885735c9c8a..d1e72e02be3a 100644 --- a/drivers/net/arm/at91_ether.h +++ b/drivers/net/arm/at91_ether.h | |||
@@ -80,6 +80,7 @@ struct at91_private | |||
80 | struct net_device_stats stats; | 80 | struct net_device_stats stats; |
81 | struct mii_if_info mii; /* ethtool support */ | 81 | struct mii_if_info mii; /* ethtool support */ |
82 | struct at91_eth_data board_data; /* board-specific configuration */ | 82 | struct at91_eth_data board_data; /* board-specific configuration */ |
83 | struct clk *ether_clk; /* clock */ | ||
83 | 84 | ||
84 | /* PHY */ | 85 | /* PHY */ |
85 | unsigned long phy_type; /* type of PHY (PHY_ID) */ | 86 | unsigned long phy_type; /* type of PHY (PHY_ID) */ |