aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bfin_mac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bfin_mac.c')
-rw-r--r--drivers/net/bfin_mac.c59
1 files changed, 33 insertions, 26 deletions
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c
index 3db7db1828e7..b458d607a9c6 100644
--- a/drivers/net/bfin_mac.c
+++ b/drivers/net/bfin_mac.c
@@ -253,7 +253,7 @@ init_error:
253 * MII operations 253 * MII operations
254 */ 254 */
255/* Wait until the previous MDC/MDIO transaction has completed */ 255/* Wait until the previous MDC/MDIO transaction has completed */
256static void mdio_poll(void) 256static void bfin_mdio_poll(void)
257{ 257{
258 int timeout_cnt = MAX_TIMEOUT_CNT; 258 int timeout_cnt = MAX_TIMEOUT_CNT;
259 259
@@ -269,25 +269,25 @@ static void mdio_poll(void)
269} 269}
270 270
271/* Read an off-chip register in a PHY through the MDC/MDIO port */ 271/* Read an off-chip register in a PHY through the MDC/MDIO port */
272static int mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum) 272static int bfin_mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
273{ 273{
274 mdio_poll(); 274 bfin_mdio_poll();
275 275
276 /* read mode */ 276 /* read mode */
277 bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) | 277 bfin_write_EMAC_STAADD(SET_PHYAD((u16) phy_addr) |
278 SET_REGAD((u16) regnum) | 278 SET_REGAD((u16) regnum) |
279 STABUSY); 279 STABUSY);
280 280
281 mdio_poll(); 281 bfin_mdio_poll();
282 282
283 return (int) bfin_read_EMAC_STADAT(); 283 return (int) bfin_read_EMAC_STADAT();
284} 284}
285 285
286/* Write an off-chip register in a PHY through the MDC/MDIO port */ 286/* Write an off-chip register in a PHY through the MDC/MDIO port */
287static int mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum, 287static int bfin_mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
288 u16 value) 288 u16 value)
289{ 289{
290 mdio_poll(); 290 bfin_mdio_poll();
291 291
292 bfin_write_EMAC_STADAT((u32) value); 292 bfin_write_EMAC_STADAT((u32) value);
293 293
@@ -297,12 +297,12 @@ static int mdiobus_write(struct mii_bus *bus, int phy_addr, int regnum,
297 STAOP | 297 STAOP |
298 STABUSY); 298 STABUSY);
299 299
300 mdio_poll(); 300 bfin_mdio_poll();
301 301
302 return 0; 302 return 0;
303} 303}
304 304
305static int mdiobus_reset(struct mii_bus *bus) 305static int bfin_mdiobus_reset(struct mii_bus *bus)
306{ 306{
307 return 0; 307 return 0;
308} 308}
@@ -398,7 +398,7 @@ static int mii_probe(struct net_device *dev)
398 398
399 /* search for connect PHY device */ 399 /* search for connect PHY device */
400 for (i = 0; i < PHY_MAX_ADDR; i++) { 400 for (i = 0; i < PHY_MAX_ADDR; i++) {
401 struct phy_device *const tmp_phydev = lp->mii_bus.phy_map[i]; 401 struct phy_device *const tmp_phydev = lp->mii_bus->phy_map[i];
402 402
403 if (!tmp_phydev) 403 if (!tmp_phydev)
404 continue; /* no PHY here... */ 404 continue; /* no PHY here... */
@@ -811,14 +811,14 @@ static void bfin_mac_enable(void)
811{ 811{
812 u32 opmode; 812 u32 opmode;
813 813
814 pr_debug("%s: %s\n", DRV_NAME, __FUNCTION__); 814 pr_debug("%s: %s\n", DRV_NAME, __func__);
815 815
816 /* Set RX DMA */ 816 /* Set RX DMA */
817 bfin_write_DMA1_NEXT_DESC_PTR(&(rx_list_head->desc_a)); 817 bfin_write_DMA1_NEXT_DESC_PTR(&(rx_list_head->desc_a));
818 bfin_write_DMA1_CONFIG(rx_list_head->desc_a.config); 818 bfin_write_DMA1_CONFIG(rx_list_head->desc_a.config);
819 819
820 /* Wait MII done */ 820 /* Wait MII done */
821 mdio_poll(); 821 bfin_mdio_poll();
822 822
823 /* We enable only RX here */ 823 /* We enable only RX here */
824 /* ASTP : Enable Automatic Pad Stripping 824 /* ASTP : Enable Automatic Pad Stripping
@@ -847,7 +847,7 @@ static void bfin_mac_enable(void)
847/* Our watchdog timed out. Called by the networking layer */ 847/* Our watchdog timed out. Called by the networking layer */
848static void bfin_mac_timeout(struct net_device *dev) 848static void bfin_mac_timeout(struct net_device *dev)
849{ 849{
850 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 850 pr_debug("%s: %s\n", dev->name, __func__);
851 851
852 bfin_mac_disable(); 852 bfin_mac_disable();
853 853
@@ -949,7 +949,7 @@ static int bfin_mac_open(struct net_device *dev)
949{ 949{
950 struct bfin_mac_local *lp = netdev_priv(dev); 950 struct bfin_mac_local *lp = netdev_priv(dev);
951 int retval; 951 int retval;
952 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 952 pr_debug("%s: %s\n", dev->name, __func__);
953 953
954 /* 954 /*
955 * Check that the address is valid. If its not, refuse 955 * Check that the address is valid. If its not, refuse
@@ -989,7 +989,7 @@ static int bfin_mac_open(struct net_device *dev)
989static int bfin_mac_close(struct net_device *dev) 989static int bfin_mac_close(struct net_device *dev)
990{ 990{
991 struct bfin_mac_local *lp = netdev_priv(dev); 991 struct bfin_mac_local *lp = netdev_priv(dev);
992 pr_debug("%s: %s\n", dev->name, __FUNCTION__); 992 pr_debug("%s: %s\n", dev->name, __func__);
993 993
994 netif_stop_queue(dev); 994 netif_stop_queue(dev);
995 netif_carrier_off(dev); 995 netif_carrier_off(dev);
@@ -1058,17 +1058,21 @@ static int __devinit bfin_mac_probe(struct platform_device *pdev)
1058 setup_mac_addr(ndev->dev_addr); 1058 setup_mac_addr(ndev->dev_addr);
1059 1059
1060 /* MDIO bus initial */ 1060 /* MDIO bus initial */
1061 lp->mii_bus.priv = ndev; 1061 lp->mii_bus = mdiobus_alloc();
1062 lp->mii_bus.read = mdiobus_read; 1062 if (lp->mii_bus == NULL)
1063 lp->mii_bus.write = mdiobus_write; 1063 goto out_err_mdiobus_alloc;
1064 lp->mii_bus.reset = mdiobus_reset; 1064
1065 lp->mii_bus.name = "bfin_mac_mdio"; 1065 lp->mii_bus->priv = ndev;
1066 snprintf(lp->mii_bus.id, MII_BUS_ID_SIZE, "0"); 1066 lp->mii_bus->read = bfin_mdiobus_read;
1067 lp->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); 1067 lp->mii_bus->write = bfin_mdiobus_write;
1068 lp->mii_bus->reset = bfin_mdiobus_reset;
1069 lp->mii_bus->name = "bfin_mac_mdio";
1070 snprintf(lp->mii_bus->id, MII_BUS_ID_SIZE, "0");
1071 lp->mii_bus->irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL);
1068 for (i = 0; i < PHY_MAX_ADDR; ++i) 1072 for (i = 0; i < PHY_MAX_ADDR; ++i)
1069 lp->mii_bus.irq[i] = PHY_POLL; 1073 lp->mii_bus->irq[i] = PHY_POLL;
1070 1074
1071 rc = mdiobus_register(&lp->mii_bus); 1075 rc = mdiobus_register(lp->mii_bus);
1072 if (rc) { 1076 if (rc) {
1073 dev_err(&pdev->dev, "Cannot register MDIO bus!\n"); 1077 dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
1074 goto out_err_mdiobus_register; 1078 goto out_err_mdiobus_register;
@@ -1121,8 +1125,10 @@ out_err_reg_ndev:
1121 free_irq(IRQ_MAC_RX, ndev); 1125 free_irq(IRQ_MAC_RX, ndev);
1122out_err_request_irq: 1126out_err_request_irq:
1123out_err_mii_probe: 1127out_err_mii_probe:
1124 mdiobus_unregister(&lp->mii_bus); 1128 mdiobus_unregister(lp->mii_bus);
1125out_err_mdiobus_register: 1129out_err_mdiobus_register:
1130 mdiobus_free(lp->mii_bus);
1131out_err_mdiobus_alloc:
1126 peripheral_free_list(pin_req); 1132 peripheral_free_list(pin_req);
1127out_err_setup_pin_mux: 1133out_err_setup_pin_mux:
1128out_err_probe_mac: 1134out_err_probe_mac:
@@ -1139,7 +1145,8 @@ static int __devexit bfin_mac_remove(struct platform_device *pdev)
1139 1145
1140 platform_set_drvdata(pdev, NULL); 1146 platform_set_drvdata(pdev, NULL);
1141 1147
1142 mdiobus_unregister(&lp->mii_bus); 1148 mdiobus_unregister(lp->mii_bus);
1149 mdiobus_free(lp->mii_bus);
1143 1150
1144 unregister_netdev(ndev); 1151 unregister_netdev(ndev);
1145 1152