Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs_enet: Remove !CONFIG_PPC_CPM_NEW_BINDING code

Now that arch/ppc is gone we always define CONFIG_PPC_CPM_NEW_BINDING so
we can remove all the code associated with !CONFIG_PPC_CPM_NEW_BINDING.

Also fixed some asm/of_platform.h to linux/of_platform.h (and of_device.h)

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>

+5 -696
-5
drivers/net/fs_enet/Makefile
··· 8 8 fs_enet-$(CONFIG_FS_ENET_HAS_FEC) += mac-fec.o 9 9 fs_enet-$(CONFIG_FS_ENET_HAS_FCC) += mac-fcc.o 10 10 11 - ifeq ($(CONFIG_PPC_CPM_NEW_BINDING),y) 12 11 obj-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o 13 12 obj-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o 14 - else 15 - fs_enet-$(CONFIG_FS_ENET_MDIO_FEC) += mii-fec.o 16 - fs_enet-$(CONFIG_FS_ENET_MDIO_FCC) += mii-bitbang.o 17 - endif 18 13 19 14 fs_enet-objs := fs_enet-main.o $(fs_enet-m)
+1 -309
drivers/net/fs_enet/fs_enet-main.c
··· 36 36 #include <linux/fs.h> 37 37 #include <linux/platform_device.h> 38 38 #include <linux/phy.h> 39 + #include <linux/of_platform.h> 39 40 40 41 #include <linux/vmalloc.h> 41 42 #include <asm/pgtable.h> 42 43 #include <asm/irq.h> 43 44 #include <asm/uaccess.h> 44 45 45 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 46 - #include <linux/of_platform.h> 47 - #endif 48 - 49 46 #include "fs_enet.h" 50 47 51 48 /*************************************************/ 52 - 53 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 54 - static char version[] __devinitdata = 55 - DRV_MODULE_NAME ".c:v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")" "\n"; 56 - #endif 57 49 58 50 MODULE_AUTHOR("Pantelis Antoniou <panto@intracom.gr>"); 59 51 MODULE_DESCRIPTION("Freescale Ethernet Driver"); ··· 949 957 extern int fs_mii_connect(struct net_device *dev); 950 958 extern void fs_mii_disconnect(struct net_device *dev); 951 959 952 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 953 - static struct net_device *fs_init_instance(struct device *dev, 954 - struct fs_platform_info *fpi) 955 - { 956 - struct net_device *ndev = NULL; 957 - struct fs_enet_private *fep = NULL; 958 - int privsize, i, r, err = 0, registered = 0; 959 - 960 - fpi->fs_no = fs_get_id(fpi); 961 - /* guard */ 962 - if ((unsigned int)fpi->fs_no >= FS_MAX_INDEX) 963 - return ERR_PTR(-EINVAL); 964 - 965 - privsize = sizeof(*fep) + (sizeof(struct sk_buff **) * 966 - (fpi->rx_ring + fpi->tx_ring)); 967 - 968 - ndev = alloc_etherdev(privsize); 969 - if (!ndev) { 970 - err = -ENOMEM; 971 - goto err; 972 - } 973 - 974 - fep = netdev_priv(ndev); 975 - 976 - fep->dev = dev; 977 - dev_set_drvdata(dev, ndev); 978 - fep->fpi = fpi; 979 - if (fpi->init_ioports) 980 - fpi->init_ioports((struct fs_platform_info *)fpi); 981 - 982 - #ifdef CONFIG_FS_ENET_HAS_FEC 983 - if (fs_get_fec_index(fpi->fs_no) >= 0) 984 - fep->ops = &fs_fec_ops; 985 - #endif 986 - 987 - #ifdef CONFIG_FS_ENET_HAS_SCC 988 - if (fs_get_scc_index(fpi->fs_no) >=0) 989 - fep->ops = &fs_scc_ops; 990 - #endif 991 - 992 - #ifdef CONFIG_FS_ENET_HAS_FCC 993 - if (fs_get_fcc_index(fpi->fs_no) >= 0) 994 - fep->ops = &fs_fcc_ops; 995 - #endif 996 - 997 - if (fep->ops == NULL) { 998 - printk(KERN_ERR DRV_MODULE_NAME 999 - ": %s No matching ops found (%d).\n", 1000 - ndev->name, fpi->fs_no); 1001 - err = -EINVAL; 1002 - goto err; 1003 - } 1004 - 1005 - r = (*fep->ops->setup_data)(ndev); 1006 - if (r != 0) { 1007 - printk(KERN_ERR DRV_MODULE_NAME 1008 - ": %s setup_data failed\n", 1009 - ndev->name); 1010 - err = r; 1011 - goto err; 1012 - } 1013 - 1014 - /* point rx_skbuff, tx_skbuff */ 1015 - fep->rx_skbuff = (struct sk_buff **)&fep[1]; 1016 - fep->tx_skbuff = fep->rx_skbuff + fpi->rx_ring; 1017 - 1018 - /* init locks */ 1019 - spin_lock_init(&fep->lock); 1020 - spin_lock_init(&fep->tx_lock); 1021 - 1022 - /* 1023 - * Set the Ethernet address. 1024 - */ 1025 - for (i = 0; i < 6; i++) 1026 - ndev->dev_addr[i] = fpi->macaddr[i]; 1027 - 1028 - r = (*fep->ops->allocate_bd)(ndev); 1029 - 1030 - if (fep->ring_base == NULL) { 1031 - printk(KERN_ERR DRV_MODULE_NAME 1032 - ": %s buffer descriptor alloc failed (%d).\n", ndev->name, r); 1033 - err = r; 1034 - goto err; 1035 - } 1036 - 1037 - /* 1038 - * Set receive and transmit descriptor base. 1039 - */ 1040 - fep->rx_bd_base = fep->ring_base; 1041 - fep->tx_bd_base = fep->rx_bd_base + fpi->rx_ring; 1042 - 1043 - /* initialize ring size variables */ 1044 - fep->tx_ring = fpi->tx_ring; 1045 - fep->rx_ring = fpi->rx_ring; 1046 - 1047 - /* 1048 - * The FEC Ethernet specific entries in the device structure. 1049 - */ 1050 - ndev->open = fs_enet_open; 1051 - ndev->hard_start_xmit = fs_enet_start_xmit; 1052 - ndev->tx_timeout = fs_timeout; 1053 - ndev->watchdog_timeo = 2 * HZ; 1054 - ndev->stop = fs_enet_close; 1055 - ndev->get_stats = fs_enet_get_stats; 1056 - ndev->set_multicast_list = fs_set_multicast_list; 1057 - 1058 - #ifdef CONFIG_NET_POLL_CONTROLLER 1059 - ndev->poll_controller = fs_enet_netpoll; 1060 - #endif 1061 - 1062 - netif_napi_add(ndev, &fep->napi, 1063 - fs_enet_rx_napi, fpi->napi_weight); 1064 - 1065 - ndev->ethtool_ops = &fs_ethtool_ops; 1066 - ndev->do_ioctl = fs_ioctl; 1067 - 1068 - init_timer(&fep->phy_timer_list); 1069 - 1070 - netif_carrier_off(ndev); 1071 - 1072 - err = register_netdev(ndev); 1073 - if (err != 0) { 1074 - printk(KERN_ERR DRV_MODULE_NAME 1075 - ": %s register_netdev failed.\n", ndev->name); 1076 - goto err; 1077 - } 1078 - registered = 1; 1079 - 1080 - 1081 - return ndev; 1082 - 1083 - err: 1084 - if (ndev != NULL) { 1085 - if (registered) 1086 - unregister_netdev(ndev); 1087 - 1088 - if (fep && fep->ops) { 1089 - (*fep->ops->free_bd)(ndev); 1090 - (*fep->ops->cleanup_data)(ndev); 1091 - } 1092 - 1093 - free_netdev(ndev); 1094 - } 1095 - 1096 - dev_set_drvdata(dev, NULL); 1097 - 1098 - return ERR_PTR(err); 1099 - } 1100 - 1101 - static int fs_cleanup_instance(struct net_device *ndev) 1102 - { 1103 - struct fs_enet_private *fep; 1104 - const struct fs_platform_info *fpi; 1105 - struct device *dev; 1106 - 1107 - if (ndev == NULL) 1108 - return -EINVAL; 1109 - 1110 - fep = netdev_priv(ndev); 1111 - if (fep == NULL) 1112 - return -EINVAL; 1113 - 1114 - fpi = fep->fpi; 1115 - 1116 - unregister_netdev(ndev); 1117 - 1118 - dma_free_coherent(fep->dev, (fpi->tx_ring + fpi->rx_ring) * sizeof(cbd_t), 1119 - (void __force *)fep->ring_base, fep->ring_mem_addr); 1120 - 1121 - /* reset it */ 1122 - (*fep->ops->cleanup_data)(ndev); 1123 - 1124 - dev = fep->dev; 1125 - if (dev != NULL) { 1126 - dev_set_drvdata(dev, NULL); 1127 - fep->dev = NULL; 1128 - } 1129 - 1130 - free_netdev(ndev); 1131 - 1132 - return 0; 1133 - } 1134 - #endif 1135 - 1136 960 /**************************************************************************************/ 1137 961 1138 962 /* handy pointer to the immap */ ··· 975 1167 976 1168 /**************************************************************************************/ 977 1169 978 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 979 1170 static int __devinit find_phy(struct device_node *np, 980 1171 struct fs_platform_info *fpi) 981 1172 { ··· 1206 1399 of_unregister_platform_driver(&fs_enet_driver); 1207 1400 cleanup_immap(); 1208 1401 } 1209 - #else 1210 - static int __devinit fs_enet_probe(struct device *dev) 1211 - { 1212 - struct net_device *ndev; 1213 - 1214 - /* no fixup - no device */ 1215 - if (dev->platform_data == NULL) { 1216 - printk(KERN_INFO "fs_enet: " 1217 - "probe called with no platform data; " 1218 - "remove unused devices\n"); 1219 - return -ENODEV; 1220 - } 1221 - 1222 - ndev = fs_init_instance(dev, dev->platform_data); 1223 - if (IS_ERR(ndev)) 1224 - return PTR_ERR(ndev); 1225 - return 0; 1226 - } 1227 - 1228 - static int fs_enet_remove(struct device *dev) 1229 - { 1230 - return fs_cleanup_instance(dev_get_drvdata(dev)); 1231 - } 1232 - 1233 - static struct device_driver fs_enet_fec_driver = { 1234 - .name = "fsl-cpm-fec", 1235 - .bus = &platform_bus_type, 1236 - .probe = fs_enet_probe, 1237 - .remove = fs_enet_remove, 1238 - #ifdef CONFIG_PM 1239 - /* .suspend = fs_enet_suspend, TODO */ 1240 - /* .resume = fs_enet_resume, TODO */ 1241 - #endif 1242 - }; 1243 - 1244 - static struct device_driver fs_enet_scc_driver = { 1245 - .name = "fsl-cpm-scc", 1246 - .bus = &platform_bus_type, 1247 - .probe = fs_enet_probe, 1248 - .remove = fs_enet_remove, 1249 - #ifdef CONFIG_PM 1250 - /* .suspend = fs_enet_suspend, TODO */ 1251 - /* .resume = fs_enet_resume, TODO */ 1252 - #endif 1253 - }; 1254 - 1255 - static struct device_driver fs_enet_fcc_driver = { 1256 - .name = "fsl-cpm-fcc", 1257 - .bus = &platform_bus_type, 1258 - .probe = fs_enet_probe, 1259 - .remove = fs_enet_remove, 1260 - #ifdef CONFIG_PM 1261 - /* .suspend = fs_enet_suspend, TODO */ 1262 - /* .resume = fs_enet_resume, TODO */ 1263 - #endif 1264 - }; 1265 - 1266 - static int __init fs_init(void) 1267 - { 1268 - int r; 1269 - 1270 - printk(KERN_INFO 1271 - "%s", version); 1272 - 1273 - r = setup_immap(); 1274 - if (r != 0) 1275 - return r; 1276 - 1277 - #ifdef CONFIG_FS_ENET_HAS_FCC 1278 - /* let's insert mii stuff */ 1279 - r = fs_enet_mdio_bb_init(); 1280 - 1281 - if (r != 0) { 1282 - printk(KERN_ERR DRV_MODULE_NAME 1283 - "BB PHY init failed.\n"); 1284 - return r; 1285 - } 1286 - r = driver_register(&fs_enet_fcc_driver); 1287 - if (r != 0) 1288 - goto err; 1289 - #endif 1290 - 1291 - #ifdef CONFIG_FS_ENET_HAS_FEC 1292 - r = fs_enet_mdio_fec_init(); 1293 - if (r != 0) { 1294 - printk(KERN_ERR DRV_MODULE_NAME 1295 - "FEC PHY init failed.\n"); 1296 - return r; 1297 - } 1298 - 1299 - r = driver_register(&fs_enet_fec_driver); 1300 - if (r != 0) 1301 - goto err; 1302 - #endif 1303 - 1304 - #ifdef CONFIG_FS_ENET_HAS_SCC 1305 - r = driver_register(&fs_enet_scc_driver); 1306 - if (r != 0) 1307 - goto err; 1308 - #endif 1309 - 1310 - return 0; 1311 - err: 1312 - cleanup_immap(); 1313 - return r; 1314 - } 1315 - 1316 - static void __exit fs_cleanup(void) 1317 - { 1318 - driver_unregister(&fs_enet_fec_driver); 1319 - driver_unregister(&fs_enet_fcc_driver); 1320 - driver_unregister(&fs_enet_scc_driver); 1321 - cleanup_immap(); 1322 - } 1323 - #endif 1324 1402 1325 1403 #ifdef CONFIG_NET_POLL_CONTROLLER 1326 1404 static void fs_enet_netpoll(struct net_device *dev)
-4
drivers/net/fs_enet/fs_enet.h
··· 138 138 }; 139 139 140 140 /***************************************************************************/ 141 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 142 - int fs_enet_mdio_bb_init(void); 143 - int fs_enet_mdio_fec_init(void); 144 - #endif 145 141 146 142 void fs_init_bds(struct net_device *dev); 147 143 void fs_cleanup_bds(struct net_device *dev);
+1 -66
drivers/net/fs_enet/mac-fcc.c
··· 33 33 #include <linux/fs.h> 34 34 #include <linux/platform_device.h> 35 35 #include <linux/phy.h> 36 + #include <linux/of_device.h> 36 37 37 38 #include <asm/immap_cpm2.h> 38 39 #include <asm/mpc8260.h> ··· 42 41 #include <asm/pgtable.h> 43 42 #include <asm/irq.h> 44 43 #include <asm/uaccess.h> 45 - 46 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 47 - #include <asm/of_device.h> 48 - #endif 49 44 50 45 #include "fs_enet.h" 51 46 ··· 84 87 85 88 static int do_pd_setup(struct fs_enet_private *fep) 86 89 { 87 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 88 90 struct of_device *ofdev = to_of_device(fep->dev); 89 91 struct fs_platform_info *fpi = fep->fpi; 90 92 int ret = -EINVAL; ··· 121 125 iounmap(fep->fcc.fccp); 122 126 out: 123 127 return ret; 124 - #else 125 - struct platform_device *pdev = to_platform_device(fep->dev); 126 - struct resource *r; 127 - 128 - /* Fill out IRQ field */ 129 - fep->interrupt = platform_get_irq(pdev, 0); 130 - if (fep->interrupt < 0) 131 - return -EINVAL; 132 - 133 - /* Attach the memory for the FCC Parameter RAM */ 134 - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_pram"); 135 - fep->fcc.ep = ioremap(r->start, r->end - r->start + 1); 136 - if (fep->fcc.ep == NULL) 137 - return -EINVAL; 138 - 139 - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "fcc_regs"); 140 - fep->fcc.fccp = ioremap(r->start, r->end - r->start + 1); 141 - if (fep->fcc.fccp == NULL) 142 - return -EINVAL; 143 - 144 - if (fep->fpi->fcc_regs_c) { 145 - fep->fcc.fcccp = (void __iomem *)fep->fpi->fcc_regs_c; 146 - } else { 147 - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, 148 - "fcc_regs_c"); 149 - fep->fcc.fcccp = ioremap(r->start, 150 - r->end - r->start + 1); 151 - } 152 - 153 - if (fep->fcc.fcccp == NULL) 154 - return -EINVAL; 155 - 156 - fep->fcc.mem = (void __iomem *)fep->fpi->mem_offset; 157 - if (fep->fcc.mem == NULL) 158 - return -EINVAL; 159 - 160 - return 0; 161 - #endif 162 128 } 163 129 164 130 #define FCC_NAPI_RX_EVENT_MSK (FCC_ENET_RXF | FCC_ENET_RXB) ··· 131 173 static int setup_data(struct net_device *dev) 132 174 { 133 175 struct fs_enet_private *fep = netdev_priv(dev); 134 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 135 - struct fs_platform_info *fpi = fep->fpi; 136 - 137 - fpi->cp_command = (fpi->cp_page << 26) | 138 - (fpi->cp_block << 21) | 139 - (12 << 6); 140 - 141 - fep->fcc.idx = fs_get_fcc_index(fpi->fs_no); 142 - if ((unsigned int)fep->fcc.idx >= 3) /* max 3 FCCs */ 143 - return -EINVAL; 144 - #endif 145 176 146 177 if (do_pd_setup(fep) != 0) 147 178 return -EINVAL; ··· 251 304 fcc_enet_t __iomem *ep = fep->fcc.ep; 252 305 dma_addr_t rx_bd_base_phys, tx_bd_base_phys; 253 306 u16 paddrh, paddrm, paddrl; 254 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 255 - u16 mem_addr; 256 - #endif 257 307 const unsigned char *mac; 258 308 int i; 259 309 ··· 282 338 * this area. 283 339 */ 284 340 285 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 286 341 W16(ep, fen_genfcc.fcc_riptr, fpi->dpram_offset); 287 342 W16(ep, fen_genfcc.fcc_tiptr, fpi->dpram_offset + 32); 288 343 289 344 W16(ep, fen_padptr, fpi->dpram_offset + 64); 290 - #else 291 - mem_addr = (u32) fep->fcc.mem; /* de-fixup dpram offset */ 292 - 293 - W16(ep, fen_genfcc.fcc_riptr, (mem_addr & 0xffff)); 294 - W16(ep, fen_genfcc.fcc_tiptr, ((mem_addr + 32) & 0xffff)); 295 - 296 - W16(ep, fen_padptr, mem_addr + 64); 297 - #endif 298 345 299 346 /* fill with special symbol... */ 300 347 memset_io(fep->fcc.mem + fpi->dpram_offset + 64, 0x88, 32);
+1 -22
drivers/net/fs_enet/mac-fec.c
··· 32 32 #include <linux/bitops.h> 33 33 #include <linux/fs.h> 34 34 #include <linux/platform_device.h> 35 + #include <linux/of_device.h> 35 36 36 37 #include <asm/irq.h> 37 38 #include <asm/uaccess.h> ··· 42 41 #include <asm/pgtable.h> 43 42 #include <asm/mpc8xx.h> 44 43 #include <asm/cpm1.h> 45 - #endif 46 - 47 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 48 - #include <asm/of_device.h> 49 44 #endif 50 45 51 46 #include "fs_enet.h" ··· 96 99 97 100 static int do_pd_setup(struct fs_enet_private *fep) 98 101 { 99 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 100 102 struct of_device *ofdev = to_of_device(fep->dev); 101 103 102 104 fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); ··· 107 111 return -EINVAL; 108 112 109 113 return 0; 110 - #else 111 - struct platform_device *pdev = to_platform_device(fep->dev); 112 - struct resource *r; 113 - 114 - /* Fill out IRQ field */ 115 - fep->interrupt = platform_get_irq_byname(pdev,"interrupt"); 116 - if (fep->interrupt < 0) 117 - return -EINVAL; 118 - 119 - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); 120 - fep->fec.fecp = ioremap(r->start, r->end - r->start + 1); 121 - 122 - if(fep->fec.fecp == NULL) 123 - return -EINVAL; 124 - 125 - return 0; 126 - #endif 127 114 } 128 115 129 116 #define FEC_NAPI_RX_EVENT_MSK (FEC_ENET_RXF | FEC_ENET_RXB)
+1 -36
drivers/net/fs_enet/mac-scc.c
··· 32 32 #include <linux/bitops.h> 33 33 #include <linux/fs.h> 34 34 #include <linux/platform_device.h> 35 + #include <linux/of_platform.h> 35 36 36 37 #include <asm/irq.h> 37 38 #include <asm/uaccess.h> ··· 42 41 #include <asm/pgtable.h> 43 42 #include <asm/mpc8xx.h> 44 43 #include <asm/cpm1.h> 45 - #endif 46 - 47 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 48 - #include <linux/of_platform.h> 49 44 #endif 50 45 51 46 #include "fs_enet.h" ··· 96 99 97 100 static int do_pd_setup(struct fs_enet_private *fep) 98 101 { 99 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 100 102 struct of_device *ofdev = to_of_device(fep->dev); 101 103 102 104 fep->interrupt = of_irq_to_resource(ofdev->node, 0, NULL); ··· 111 115 iounmap(fep->scc.sccp); 112 116 return -EINVAL; 113 117 } 114 - #else 115 - struct platform_device *pdev = to_platform_device(fep->dev); 116 - struct resource *r; 117 - 118 - /* Fill out IRQ field */ 119 - fep->interrupt = platform_get_irq_byname(pdev, "interrupt"); 120 - if (fep->interrupt < 0) 121 - return -EINVAL; 122 - 123 - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); 124 - fep->scc.sccp = ioremap(r->start, r->end - r->start + 1); 125 - 126 - if (fep->scc.sccp == NULL) 127 - return -EINVAL; 128 - 129 - r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pram"); 130 - fep->scc.ep = ioremap(r->start, r->end - r->start + 1); 131 - 132 - if (fep->scc.ep == NULL) 133 - return -EINVAL; 134 - #endif 135 118 136 119 return 0; 137 120 } ··· 123 148 static int setup_data(struct net_device *dev) 124 149 { 125 150 struct fs_enet_private *fep = netdev_priv(dev); 126 - 127 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 128 - struct fs_platform_info *fpi = fep->fpi; 129 - 130 - fep->scc.idx = fs_get_scc_index(fpi->fs_no); 131 - if ((unsigned int)fep->fcc.idx >= 4) /* max 4 SCCs */ 132 - return -EINVAL; 133 - 134 - fpi->cp_command = fep->fcc.idx << 6; 135 - #endif 136 151 137 152 do_pd_setup(fep); 138 153
-107
drivers/net/fs_enet/mii-bitbang.c
··· 22 22 #include <linux/mii.h> 23 23 #include <linux/platform_device.h> 24 24 #include <linux/mdio-bitbang.h> 25 - 26 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 27 25 #include <linux/of_platform.h> 28 - #endif 29 26 30 27 #include "fs_enet.h" 31 28 ··· 107 110 .get_mdio_data = mdio_read, 108 111 }; 109 112 110 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 111 113 static int __devinit fs_mii_bitbang_init(struct mii_bus *bus, 112 114 struct device_node *np) 113 115 { ··· 267 271 268 272 module_init(fs_enet_mdio_bb_init); 269 273 module_exit(fs_enet_mdio_bb_exit); 270 - #else 271 - static int __devinit fs_mii_bitbang_init(struct bb_info *bitbang, 272 - struct fs_mii_bb_platform_info *fmpi) 273 - { 274 - bitbang->dir = (u32 __iomem *)fmpi->mdio_dir.offset; 275 - bitbang->dat = (u32 __iomem *)fmpi->mdio_dat.offset; 276 - bitbang->mdio_msk = 1U << (31 - fmpi->mdio_dat.bit); 277 - bitbang->mdc_msk = 1U << (31 - fmpi->mdc_dat.bit); 278 - 279 - return 0; 280 - } 281 - 282 - static int __devinit fs_enet_mdio_probe(struct device *dev) 283 - { 284 - struct platform_device *pdev = to_platform_device(dev); 285 - struct fs_mii_bb_platform_info *pdata; 286 - struct mii_bus *new_bus; 287 - struct bb_info *bitbang; 288 - int err = 0; 289 - 290 - if (NULL == dev) 291 - return -EINVAL; 292 - 293 - bitbang = kzalloc(sizeof(struct bb_info), GFP_KERNEL); 294 - 295 - if (NULL == bitbang) 296 - return -ENOMEM; 297 - 298 - bitbang->ctrl.ops = &bb_ops; 299 - 300 - new_bus = alloc_mdio_bitbang(&bitbang->ctrl); 301 - 302 - if (NULL == new_bus) 303 - return -ENOMEM; 304 - 305 - new_bus->name = "BB MII Bus", 306 - snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 307 - 308 - new_bus->phy_mask = ~0x9; 309 - pdata = (struct fs_mii_bb_platform_info *)pdev->dev.platform_data; 310 - 311 - if (NULL == pdata) { 312 - printk(KERN_ERR "gfar mdio %d: Missing platform data!\n", pdev->id); 313 - return -ENODEV; 314 - } 315 - 316 - /*set up workspace*/ 317 - fs_mii_bitbang_init(bitbang, pdata); 318 - 319 - new_bus->priv = bitbang; 320 - 321 - new_bus->irq = pdata->irq; 322 - 323 - new_bus->dev = dev; 324 - dev_set_drvdata(dev, new_bus); 325 - 326 - err = mdiobus_register(new_bus); 327 - 328 - if (0 != err) { 329 - printk (KERN_ERR "%s: Cannot register as MDIO bus\n", 330 - new_bus->name); 331 - goto bus_register_fail; 332 - } 333 - 334 - return 0; 335 - 336 - bus_register_fail: 337 - free_mdio_bitbang(new_bus); 338 - kfree(bitbang); 339 - 340 - return err; 341 - } 342 - 343 - static int fs_enet_mdio_remove(struct device *dev) 344 - { 345 - struct mii_bus *bus = dev_get_drvdata(dev); 346 - 347 - mdiobus_unregister(bus); 348 - 349 - dev_set_drvdata(dev, NULL); 350 - 351 - free_mdio_bitbang(bus); 352 - 353 - return 0; 354 - } 355 - 356 - static struct device_driver fs_enet_bb_mdio_driver = { 357 - .name = "fsl-bb-mdio", 358 - .bus = &platform_bus_type, 359 - .probe = fs_enet_mdio_probe, 360 - .remove = fs_enet_mdio_remove, 361 - }; 362 - 363 - int fs_enet_mdio_bb_init(void) 364 - { 365 - return driver_register(&fs_enet_bb_mdio_driver); 366 - } 367 - 368 - void fs_enet_mdio_bb_exit(void) 369 - { 370 - driver_unregister(&fs_enet_bb_mdio_driver); 371 - } 372 - #endif
+1 -143
drivers/net/fs_enet/mii-fec.c
··· 31 31 #include <linux/ethtool.h> 32 32 #include <linux/bitops.h> 33 33 #include <linux/platform_device.h> 34 + #include <linux/of_platform.h> 34 35 35 36 #include <asm/pgtable.h> 36 37 #include <asm/irq.h> 37 38 #include <asm/uaccess.h> 38 - 39 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 40 - #include <linux/of_platform.h> 41 - #endif 42 39 43 40 #include "fs_enet.h" 44 41 #include "fec.h" ··· 47 50 #define mk_mii_end 0 48 51 49 52 #define FEC_MII_LOOPS 10000 50 - 51 - #ifndef CONFIG_PPC_CPM_NEW_BINDING 52 - static int match_has_phy (struct device *dev, void* data) 53 - { 54 - struct platform_device* pdev = container_of(dev, struct platform_device, dev); 55 - struct fs_platform_info* fpi; 56 - if(strcmp(pdev->name, (char*)data)) 57 - { 58 - return 0; 59 - } 60 - 61 - fpi = pdev->dev.platform_data; 62 - if((fpi)&&(fpi->has_phy)) 63 - return 1; 64 - return 0; 65 - } 66 - 67 - static int fs_mii_fec_init(struct fec_info* fec, struct fs_mii_fec_platform_info *fmpi) 68 - { 69 - struct resource *r; 70 - fec_t __iomem *fecp; 71 - char* name = "fsl-cpm-fec"; 72 - 73 - /* we need fec in order to be useful */ 74 - struct platform_device *fec_pdev = 75 - container_of(bus_find_device(&platform_bus_type, NULL, name, match_has_phy), 76 - struct platform_device, dev); 77 - 78 - if(fec_pdev == NULL) { 79 - printk(KERN_ERR"Unable to find PHY for %s", name); 80 - return -ENODEV; 81 - } 82 - 83 - r = platform_get_resource_byname(fec_pdev, IORESOURCE_MEM, "regs"); 84 - 85 - fec->fecp = fecp = ioremap(r->start,sizeof(fec_t)); 86 - fec->mii_speed = fmpi->mii_speed; 87 - 88 - setbits32(&fecp->fec_r_cntrl, FEC_RCNTRL_MII_MODE); /* MII enable */ 89 - setbits32(&fecp->fec_ecntrl, FEC_ECNTRL_PINMUX | FEC_ECNTRL_ETHER_EN); 90 - out_be32(&fecp->fec_ievent, FEC_ENET_MII); 91 - out_be32(&fecp->fec_mii_speed, fec->mii_speed); 92 - 93 - return 0; 94 - } 95 - #endif 96 53 97 54 static int fs_enet_fec_mii_read(struct mii_bus *bus , int phy_id, int location) 98 55 { ··· 102 151 return 0; 103 152 } 104 153 105 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 106 154 static void __devinit add_phy(struct mii_bus *bus, struct device_node *np) 107 155 { 108 156 const u32 *data; ··· 236 286 237 287 module_init(fs_enet_mdio_fec_init); 238 288 module_exit(fs_enet_mdio_fec_exit); 239 - #else 240 - static int __devinit fs_enet_fec_mdio_probe(struct device *dev) 241 - { 242 - struct platform_device *pdev = to_platform_device(dev); 243 - struct fs_mii_fec_platform_info *pdata; 244 - struct mii_bus *new_bus; 245 - struct fec_info *fec; 246 - int err = 0; 247 - if (NULL == dev) 248 - return -EINVAL; 249 - new_bus = kzalloc(sizeof(struct mii_bus), GFP_KERNEL); 250 - 251 - if (NULL == new_bus) 252 - return -ENOMEM; 253 - 254 - fec = kzalloc(sizeof(struct fec_info), GFP_KERNEL); 255 - 256 - if (NULL == fec) 257 - return -ENOMEM; 258 - 259 - new_bus->name = "FEC MII Bus", 260 - new_bus->read = &fs_enet_fec_mii_read, 261 - new_bus->write = &fs_enet_fec_mii_write, 262 - new_bus->reset = &fs_enet_fec_mii_reset, 263 - snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", pdev->id); 264 - 265 - pdata = (struct fs_mii_fec_platform_info *)pdev->dev.platform_data; 266 - 267 - if (NULL == pdata) { 268 - printk(KERN_ERR "fs_enet FEC mdio %d: Missing platform data!\n", pdev->id); 269 - return -ENODEV; 270 - } 271 - 272 - /*set up workspace*/ 273 - 274 - fs_mii_fec_init(fec, pdata); 275 - new_bus->priv = fec; 276 - 277 - new_bus->irq = pdata->irq; 278 - 279 - new_bus->dev = dev; 280 - dev_set_drvdata(dev, new_bus); 281 - 282 - err = mdiobus_register(new_bus); 283 - 284 - if (0 != err) { 285 - printk (KERN_ERR "%s: Cannot register as MDIO bus\n", 286 - new_bus->name); 287 - goto bus_register_fail; 288 - } 289 - 290 - return 0; 291 - 292 - bus_register_fail: 293 - kfree(new_bus); 294 - 295 - return err; 296 - } 297 - 298 - 299 - static int fs_enet_fec_mdio_remove(struct device *dev) 300 - { 301 - struct mii_bus *bus = dev_get_drvdata(dev); 302 - 303 - mdiobus_unregister(bus); 304 - 305 - dev_set_drvdata(dev, NULL); 306 - kfree(bus->priv); 307 - 308 - bus->priv = NULL; 309 - kfree(bus); 310 - 311 - return 0; 312 - } 313 - 314 - static struct device_driver fs_enet_fec_mdio_driver = { 315 - .name = "fsl-cpm-fec-mdio", 316 - .bus = &platform_bus_type, 317 - .probe = fs_enet_fec_mdio_probe, 318 - .remove = fs_enet_fec_mdio_remove, 319 - }; 320 - 321 - int fs_enet_mdio_fec_init(void) 322 - { 323 - return driver_register(&fs_enet_fec_mdio_driver); 324 - } 325 - 326 - void fs_enet_mdio_fec_exit(void) 327 - { 328 - driver_unregister(&fs_enet_fec_mdio_driver); 329 - } 330 - #endif
-4
include/linux/fs_enet_pd.h
··· 135 135 u32 device_flags; 136 136 137 137 int phy_addr; /* the phy address (-1 no phy) */ 138 - #ifdef CONFIG_PPC_CPM_NEW_BINDING 139 138 char bus_id[16]; 140 - #else 141 - const char* bus_id; 142 - #endif 143 139 int phy_irq; /* the phy irq (if it exists) */ 144 140 145 141 const struct fs_mii_bus_info *bus_info;