diff options
Diffstat (limited to 'drivers/net/cpmac.c')
-rw-r--r-- | drivers/net/cpmac.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/drivers/net/cpmac.c b/drivers/net/cpmac.c index ec6b0af3d46b..017a5361b980 100644 --- a/drivers/net/cpmac.c +++ b/drivers/net/cpmac.c | |||
@@ -302,13 +302,7 @@ static int cpmac_mdio_reset(struct mii_bus *bus) | |||
302 | 302 | ||
303 | static int mii_irqs[PHY_MAX_ADDR] = { PHY_POLL, }; | 303 | static int mii_irqs[PHY_MAX_ADDR] = { PHY_POLL, }; |
304 | 304 | ||
305 | static struct mii_bus cpmac_mii = { | 305 | static struct mii_bus *cpmac_mii; |
306 | .name = "cpmac-mii", | ||
307 | .read = cpmac_mdio_read, | ||
308 | .write = cpmac_mdio_write, | ||
309 | .reset = cpmac_mdio_reset, | ||
310 | .irq = mii_irqs, | ||
311 | }; | ||
312 | 306 | ||
313 | static int cpmac_config(struct net_device *dev, struct ifmap *map) | 307 | static int cpmac_config(struct net_device *dev, struct ifmap *map) |
314 | { | 308 | { |
@@ -1116,7 +1110,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1116 | for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { | 1110 | for (phy_id = 0; phy_id < PHY_MAX_ADDR; phy_id++) { |
1117 | if (!(pdata->phy_mask & (1 << phy_id))) | 1111 | if (!(pdata->phy_mask & (1 << phy_id))) |
1118 | continue; | 1112 | continue; |
1119 | if (!cpmac_mii.phy_map[phy_id]) | 1113 | if (!cpmac_mii->phy_map[phy_id]) |
1120 | continue; | 1114 | continue; |
1121 | break; | 1115 | break; |
1122 | } | 1116 | } |
@@ -1168,7 +1162,7 @@ static int __devinit cpmac_probe(struct platform_device *pdev) | |||
1168 | priv->msg_enable = netif_msg_init(debug_level, 0xff); | 1162 | priv->msg_enable = netif_msg_init(debug_level, 0xff); |
1169 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); | 1163 | memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr)); |
1170 | 1164 | ||
1171 | priv->phy = phy_connect(dev, cpmac_mii.phy_map[phy_id]->dev.bus_id, | 1165 | priv->phy = phy_connect(dev, cpmac_mii->phy_map[phy_id]->dev.bus_id, |
1172 | &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); | 1166 | &cpmac_adjust_link, 0, PHY_INTERFACE_MODE_MII); |
1173 | if (IS_ERR(priv->phy)) { | 1167 | if (IS_ERR(priv->phy)) { |
1174 | if (netif_msg_drv(priv)) | 1168 | if (netif_msg_drv(priv)) |
@@ -1216,11 +1210,22 @@ int __devinit cpmac_init(void) | |||
1216 | u32 mask; | 1210 | u32 mask; |
1217 | int i, res; | 1211 | int i, res; |
1218 | 1212 | ||
1219 | cpmac_mii.priv = ioremap(AR7_REGS_MDIO, 256); | 1213 | cpmac_mii = mdiobus_alloc(); |
1214 | if (cpmac_mii == NULL) | ||
1215 | return -ENOMEM; | ||
1216 | |||
1217 | cpmac_mii->name = "cpmac-mii"; | ||
1218 | cpmac_mii->read = cpmac_mdio_read; | ||
1219 | cpmac_mii->write = cpmac_mdio_write; | ||
1220 | cpmac_mii->reset = cpmac_mdio_reset; | ||
1221 | cpmac_mii->irq = mii_irqs; | ||
1222 | |||
1223 | cpmac_mii->priv = ioremap(AR7_REGS_MDIO, 256); | ||
1220 | 1224 | ||
1221 | if (!cpmac_mii.priv) { | 1225 | if (!cpmac_mii->priv) { |
1222 | printk(KERN_ERR "Can't ioremap mdio registers\n"); | 1226 | printk(KERN_ERR "Can't ioremap mdio registers\n"); |
1223 | return -ENXIO; | 1227 | res = -ENXIO; |
1228 | goto fail_alloc; | ||
1224 | } | 1229 | } |
1225 | 1230 | ||
1226 | #warning FIXME: unhardcode gpio&reset bits | 1231 | #warning FIXME: unhardcode gpio&reset bits |
@@ -1230,10 +1235,10 @@ int __devinit cpmac_init(void) | |||
1230 | ar7_device_reset(AR7_RESET_BIT_CPMAC_HI); | 1235 | ar7_device_reset(AR7_RESET_BIT_CPMAC_HI); |
1231 | ar7_device_reset(AR7_RESET_BIT_EPHY); | 1236 | ar7_device_reset(AR7_RESET_BIT_EPHY); |
1232 | 1237 | ||
1233 | cpmac_mii.reset(&cpmac_mii); | 1238 | cpmac_mii->reset(cpmac_mii); |
1234 | 1239 | ||
1235 | for (i = 0; i < 300000; i++) | 1240 | for (i = 0; i < 300000; i++) |
1236 | if ((mask = cpmac_read(cpmac_mii.priv, CPMAC_MDIO_ALIVE))) | 1241 | if ((mask = cpmac_read(cpmac_mii->priv, CPMAC_MDIO_ALIVE))) |
1237 | break; | 1242 | break; |
1238 | else | 1243 | else |
1239 | cpu_relax(); | 1244 | cpu_relax(); |
@@ -1244,10 +1249,10 @@ int __devinit cpmac_init(void) | |||
1244 | mask = 0; | 1249 | mask = 0; |
1245 | } | 1250 | } |
1246 | 1251 | ||
1247 | cpmac_mii.phy_mask = ~(mask | 0x80000000); | 1252 | cpmac_mii->phy_mask = ~(mask | 0x80000000); |
1248 | snprintf(cpmac_mii.id, MII_BUS_ID_SIZE, "0"); | 1253 | snprintf(cpmac_mii->id, MII_BUS_ID_SIZE, "0"); |
1249 | 1254 | ||
1250 | res = mdiobus_register(&cpmac_mii); | 1255 | res = mdiobus_register(cpmac_mii); |
1251 | if (res) | 1256 | if (res) |
1252 | goto fail_mii; | 1257 | goto fail_mii; |
1253 | 1258 | ||
@@ -1258,10 +1263,13 @@ int __devinit cpmac_init(void) | |||
1258 | return 0; | 1263 | return 0; |
1259 | 1264 | ||
1260 | fail_cpmac: | 1265 | fail_cpmac: |
1261 | mdiobus_unregister(&cpmac_mii); | 1266 | mdiobus_unregister(cpmac_mii); |
1262 | 1267 | ||
1263 | fail_mii: | 1268 | fail_mii: |
1264 | iounmap(cpmac_mii.priv); | 1269 | iounmap(cpmac_mii->priv); |
1270 | |||
1271 | fail_alloc: | ||
1272 | mdiobus_free(cpmac_mii); | ||
1265 | 1273 | ||
1266 | return res; | 1274 | return res; |
1267 | } | 1275 | } |
@@ -1269,8 +1277,9 @@ fail_mii: | |||
1269 | void __devexit cpmac_exit(void) | 1277 | void __devexit cpmac_exit(void) |
1270 | { | 1278 | { |
1271 | platform_driver_unregister(&cpmac_driver); | 1279 | platform_driver_unregister(&cpmac_driver); |
1272 | mdiobus_unregister(&cpmac_mii); | 1280 | mdiobus_unregister(cpmac_mii); |
1273 | iounmap(cpmac_mii.priv); | 1281 | mdiobus_free(cpmac_mii); |
1282 | iounmap(cpmac_mii->priv); | ||
1274 | } | 1283 | } |
1275 | 1284 | ||
1276 | module_init(cpmac_init); | 1285 | module_init(cpmac_init); |