fec_mpc52xx.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180
  1. /*
  2. * Driver for the MPC5200 Fast Ethernet Controller
  3. *
  4. * Originally written by Dale Farnsworth <dfarnsworth@mvista.com> and
  5. * now maintained by Sylvain Munaut <tnt@246tNt.com>
  6. *
  7. * Copyright (C) 2007 Domen Puncer, Telargo, Inc.
  8. * Copyright (C) 2007 Sylvain Munaut <tnt@246tNt.com>
  9. * Copyright (C) 2003-2004 MontaVista, Software, Inc.
  10. *
  11. * This file is licensed under the terms of the GNU General Public License
  12. * version 2. This program is licensed "as is" without any warranty of any
  13. * kind, whether express or implied.
  14. *
  15. */
  16. #include <linux/module.h>
  17. #include <linux/kernel.h>
  18. #include <linux/types.h>
  19. #include <linux/spinlock.h>
  20. #include <linux/errno.h>
  21. #include <linux/init.h>
  22. #include <linux/crc32.h>
  23. #include <linux/hardirq.h>
  24. #include <linux/delay.h>
  25. #include <linux/of_device.h>
  26. #include <linux/of_platform.h>
  27. #include <linux/netdevice.h>
  28. #include <linux/etherdevice.h>
  29. #include <linux/ethtool.h>
  30. #include <linux/skbuff.h>
  31. #include <asm/io.h>
  32. #include <asm/delay.h>
  33. #include <asm/mpc52xx.h>
  34. #include <sysdev/bestcomm/bestcomm.h>
  35. #include <sysdev/bestcomm/fec.h>
  36. #include "fec_mpc52xx.h"
  37. #define DRIVER_NAME "mpc52xx-fec"
  38. #define FEC5200_PHYADDR_NONE (-1)
  39. #define FEC5200_PHYADDR_7WIRE (-2)
  40. /* Private driver data structure */
  41. struct mpc52xx_fec_priv {
  42. int duplex;
  43. int speed;
  44. int r_irq;
  45. int t_irq;
  46. struct mpc52xx_fec __iomem *fec;
  47. struct bcom_task *rx_dmatsk;
  48. struct bcom_task *tx_dmatsk;
  49. spinlock_t lock;
  50. int msg_enable;
  51. /* MDIO link details */
  52. int phy_addr;
  53. unsigned int phy_speed;
  54. struct phy_device *phydev;
  55. enum phy_state link;
  56. };
  57. static irqreturn_t mpc52xx_fec_interrupt(int, void *);
  58. static irqreturn_t mpc52xx_fec_rx_interrupt(int, void *);
  59. static irqreturn_t mpc52xx_fec_tx_interrupt(int, void *);
  60. static void mpc52xx_fec_stop(struct net_device *dev);
  61. static void mpc52xx_fec_start(struct net_device *dev);
  62. static void mpc52xx_fec_reset(struct net_device *dev);
  63. static u8 mpc52xx_fec_mac_addr[6];
  64. module_param_array_named(mac, mpc52xx_fec_mac_addr, byte, NULL, 0);
  65. MODULE_PARM_DESC(mac, "six hex digits, ie. 0x1,0x2,0xc0,0x01,0xba,0xbe");
  66. #define MPC52xx_MESSAGES_DEFAULT ( NETIF_MSG_DRV | NETIF_MSG_PROBE | \
  67. NETIF_MSG_LINK | NETIF_MSG_IFDOWN | NETIF_MSG_IFUP)
  68. static int debug = -1; /* the above default */
  69. module_param(debug, int, 0);
  70. MODULE_PARM_DESC(debug, "debugging messages level");
  71. static void mpc52xx_fec_tx_timeout(struct net_device *dev)
  72. {
  73. dev_warn(&dev->dev, "transmit timed out\n");
  74. mpc52xx_fec_reset(dev);
  75. dev->stats.tx_errors++;
  76. netif_wake_queue(dev);
  77. }
  78. static void mpc52xx_fec_set_paddr(struct net_device *dev, u8 *mac)
  79. {
  80. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  81. struct mpc52xx_fec __iomem *fec = priv->fec;
  82. out_be32(&fec->paddr1, *(u32 *)(&mac[0]));
  83. out_be32(&fec->paddr2, (*(u16 *)(&mac[4]) << 16) | FEC_PADDR2_TYPE);
  84. }
  85. static void mpc52xx_fec_get_paddr(struct net_device *dev, u8 *mac)
  86. {
  87. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  88. struct mpc52xx_fec __iomem *fec = priv->fec;
  89. *(u32 *)(&mac[0]) = in_be32(&fec->paddr1);
  90. *(u16 *)(&mac[4]) = in_be32(&fec->paddr2) >> 16;
  91. }
  92. static int mpc52xx_fec_set_mac_address(struct net_device *dev, void *addr)
  93. {
  94. struct sockaddr *sock = addr;
  95. memcpy(dev->dev_addr, sock->sa_data, dev->addr_len);
  96. mpc52xx_fec_set_paddr(dev, sock->sa_data);
  97. return 0;
  98. }
  99. static void mpc52xx_fec_free_rx_buffers(struct net_device *dev, struct bcom_task *s)
  100. {
  101. while (!bcom_queue_empty(s)) {
  102. struct bcom_fec_bd *bd;
  103. struct sk_buff *skb;
  104. skb = bcom_retrieve_buffer(s, NULL, (struct bcom_bd **)&bd);
  105. dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_FROM_DEVICE);
  106. kfree_skb(skb);
  107. }
  108. }
  109. static int mpc52xx_fec_alloc_rx_buffers(struct net_device *dev, struct bcom_task *rxtsk)
  110. {
  111. while (!bcom_queue_full(rxtsk)) {
  112. struct sk_buff *skb;
  113. struct bcom_fec_bd *bd;
  114. skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE);
  115. if (skb == NULL)
  116. return -EAGAIN;
  117. /* zero out the initial receive buffers to aid debugging */
  118. memset(skb->data, 0, FEC_RX_BUFFER_SIZE);
  119. bd = (struct bcom_fec_bd *)bcom_prepare_next_buffer(rxtsk);
  120. bd->status = FEC_RX_BUFFER_SIZE;
  121. bd->skb_pa = dma_map_single(&dev->dev, skb->data,
  122. FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
  123. bcom_submit_next_buffer(rxtsk, skb);
  124. }
  125. return 0;
  126. }
  127. /* based on generic_adjust_link from fs_enet-main.c */
  128. static void mpc52xx_fec_adjust_link(struct net_device *dev)
  129. {
  130. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  131. struct phy_device *phydev = priv->phydev;
  132. int new_state = 0;
  133. if (phydev->link != PHY_DOWN) {
  134. if (phydev->duplex != priv->duplex) {
  135. struct mpc52xx_fec __iomem *fec = priv->fec;
  136. u32 rcntrl;
  137. u32 tcntrl;
  138. new_state = 1;
  139. priv->duplex = phydev->duplex;
  140. rcntrl = in_be32(&fec->r_cntrl);
  141. tcntrl = in_be32(&fec->x_cntrl);
  142. rcntrl &= ~FEC_RCNTRL_DRT;
  143. tcntrl &= ~FEC_TCNTRL_FDEN;
  144. if (phydev->duplex == DUPLEX_FULL)
  145. tcntrl |= FEC_TCNTRL_FDEN; /* FD enable */
  146. else
  147. rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */
  148. out_be32(&fec->r_cntrl, rcntrl);
  149. out_be32(&fec->x_cntrl, tcntrl);
  150. }
  151. if (phydev->speed != priv->speed) {
  152. new_state = 1;
  153. priv->speed = phydev->speed;
  154. }
  155. if (priv->link == PHY_DOWN) {
  156. new_state = 1;
  157. priv->link = phydev->link;
  158. }
  159. } else if (priv->link) {
  160. new_state = 1;
  161. priv->link = PHY_DOWN;
  162. priv->speed = 0;
  163. priv->duplex = -1;
  164. }
  165. if (new_state && netif_msg_link(priv))
  166. phy_print_status(phydev);
  167. }
  168. static int mpc52xx_fec_init_phy(struct net_device *dev)
  169. {
  170. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  171. struct phy_device *phydev;
  172. char phy_id[BUS_ID_SIZE];
  173. snprintf(phy_id, sizeof(phy_id), "%x:%02x",
  174. (unsigned int)dev->base_addr, priv->phy_addr);
  175. priv->link = PHY_DOWN;
  176. priv->speed = 0;
  177. priv->duplex = -1;
  178. phydev = phy_connect(dev, phy_id, &mpc52xx_fec_adjust_link, 0, PHY_INTERFACE_MODE_MII);
  179. if (IS_ERR(phydev)) {
  180. dev_err(&dev->dev, "phy_connect failed\n");
  181. return PTR_ERR(phydev);
  182. }
  183. dev_info(&dev->dev, "attached phy %i to driver %s\n",
  184. phydev->addr, phydev->drv->name);
  185. priv->phydev = phydev;
  186. return 0;
  187. }
  188. static int mpc52xx_fec_phy_start(struct net_device *dev)
  189. {
  190. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  191. int err;
  192. if (priv->phy_addr < 0)
  193. return 0;
  194. err = mpc52xx_fec_init_phy(dev);
  195. if (err) {
  196. dev_err(&dev->dev, "mpc52xx_fec_init_phy failed\n");
  197. return err;
  198. }
  199. /* reset phy - this also wakes it from PDOWN */
  200. phy_write(priv->phydev, MII_BMCR, BMCR_RESET);
  201. phy_start(priv->phydev);
  202. return 0;
  203. }
  204. static void mpc52xx_fec_phy_stop(struct net_device *dev)
  205. {
  206. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  207. if (!priv->phydev)
  208. return;
  209. phy_disconnect(priv->phydev);
  210. /* power down phy */
  211. phy_stop(priv->phydev);
  212. phy_write(priv->phydev, MII_BMCR, BMCR_PDOWN);
  213. }
  214. static int mpc52xx_fec_phy_mii_ioctl(struct mpc52xx_fec_priv *priv,
  215. struct mii_ioctl_data *mii_data, int cmd)
  216. {
  217. if (!priv->phydev)
  218. return -ENOTSUPP;
  219. return phy_mii_ioctl(priv->phydev, mii_data, cmd);
  220. }
  221. static void mpc52xx_fec_phy_hw_init(struct mpc52xx_fec_priv *priv)
  222. {
  223. struct mpc52xx_fec __iomem *fec = priv->fec;
  224. if (priv->phydev)
  225. return;
  226. out_be32(&fec->mii_speed, priv->phy_speed);
  227. }
  228. static int mpc52xx_fec_open(struct net_device *dev)
  229. {
  230. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  231. int err = -EBUSY;
  232. if (request_irq(dev->irq, &mpc52xx_fec_interrupt, IRQF_SHARED,
  233. DRIVER_NAME "_ctrl", dev)) {
  234. dev_err(&dev->dev, "ctrl interrupt request failed\n");
  235. goto out;
  236. }
  237. if (request_irq(priv->r_irq, &mpc52xx_fec_rx_interrupt, 0,
  238. DRIVER_NAME "_rx", dev)) {
  239. dev_err(&dev->dev, "rx interrupt request failed\n");
  240. goto free_ctrl_irq;
  241. }
  242. if (request_irq(priv->t_irq, &mpc52xx_fec_tx_interrupt, 0,
  243. DRIVER_NAME "_tx", dev)) {
  244. dev_err(&dev->dev, "tx interrupt request failed\n");
  245. goto free_2irqs;
  246. }
  247. bcom_fec_rx_reset(priv->rx_dmatsk);
  248. bcom_fec_tx_reset(priv->tx_dmatsk);
  249. err = mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk);
  250. if (err) {
  251. dev_err(&dev->dev, "mpc52xx_fec_alloc_rx_buffers failed\n");
  252. goto free_irqs;
  253. }
  254. err = mpc52xx_fec_phy_start(dev);
  255. if (err)
  256. goto free_skbs;
  257. bcom_enable(priv->rx_dmatsk);
  258. bcom_enable(priv->tx_dmatsk);
  259. mpc52xx_fec_start(dev);
  260. netif_start_queue(dev);
  261. return 0;
  262. free_skbs:
  263. mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk);
  264. free_irqs:
  265. free_irq(priv->t_irq, dev);
  266. free_2irqs:
  267. free_irq(priv->r_irq, dev);
  268. free_ctrl_irq:
  269. free_irq(dev->irq, dev);
  270. out:
  271. return err;
  272. }
  273. static int mpc52xx_fec_close(struct net_device *dev)
  274. {
  275. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  276. netif_stop_queue(dev);
  277. mpc52xx_fec_stop(dev);
  278. mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk);
  279. free_irq(dev->irq, dev);
  280. free_irq(priv->r_irq, dev);
  281. free_irq(priv->t_irq, dev);
  282. mpc52xx_fec_phy_stop(dev);
  283. return 0;
  284. }
  285. /* This will only be invoked if your driver is _not_ in XOFF state.
  286. * What this means is that you need not check it, and that this
  287. * invariant will hold if you make sure that the netif_*_queue()
  288. * calls are done at the proper times.
  289. */
  290. static int mpc52xx_fec_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
  291. {
  292. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  293. struct bcom_fec_bd *bd;
  294. if (bcom_queue_full(priv->tx_dmatsk)) {
  295. if (net_ratelimit())
  296. dev_err(&dev->dev, "transmit queue overrun\n");
  297. return 1;
  298. }
  299. spin_lock_irq(&priv->lock);
  300. dev->trans_start = jiffies;
  301. bd = (struct bcom_fec_bd *)
  302. bcom_prepare_next_buffer(priv->tx_dmatsk);
  303. bd->status = skb->len | BCOM_FEC_TX_BD_TFD | BCOM_FEC_TX_BD_TC;
  304. bd->skb_pa = dma_map_single(&dev->dev, skb->data, skb->len, DMA_TO_DEVICE);
  305. bcom_submit_next_buffer(priv->tx_dmatsk, skb);
  306. if (bcom_queue_full(priv->tx_dmatsk)) {
  307. netif_stop_queue(dev);
  308. }
  309. spin_unlock_irq(&priv->lock);
  310. return 0;
  311. }
  312. #ifdef CONFIG_NET_POLL_CONTROLLER
  313. static void mpc52xx_fec_poll_controller(struct net_device *dev)
  314. {
  315. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  316. disable_irq(priv->t_irq);
  317. mpc52xx_fec_tx_interrupt(priv->t_irq, dev);
  318. enable_irq(priv->t_irq);
  319. disable_irq(priv->r_irq);
  320. mpc52xx_fec_rx_interrupt(priv->r_irq, dev);
  321. enable_irq(priv->r_irq);
  322. }
  323. #endif
  324. /* This handles BestComm transmit task interrupts
  325. */
  326. static irqreturn_t mpc52xx_fec_tx_interrupt(int irq, void *dev_id)
  327. {
  328. struct net_device *dev = dev_id;
  329. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  330. spin_lock(&priv->lock);
  331. while (bcom_buffer_done(priv->tx_dmatsk)) {
  332. struct sk_buff *skb;
  333. struct bcom_fec_bd *bd;
  334. skb = bcom_retrieve_buffer(priv->tx_dmatsk, NULL,
  335. (struct bcom_bd **)&bd);
  336. dma_unmap_single(&dev->dev, bd->skb_pa, skb->len, DMA_TO_DEVICE);
  337. dev_kfree_skb_irq(skb);
  338. }
  339. netif_wake_queue(dev);
  340. spin_unlock(&priv->lock);
  341. return IRQ_HANDLED;
  342. }
  343. static irqreturn_t mpc52xx_fec_rx_interrupt(int irq, void *dev_id)
  344. {
  345. struct net_device *dev = dev_id;
  346. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  347. while (bcom_buffer_done(priv->rx_dmatsk)) {
  348. struct sk_buff *skb;
  349. struct sk_buff *rskb;
  350. struct bcom_fec_bd *bd;
  351. u32 status;
  352. rskb = bcom_retrieve_buffer(priv->rx_dmatsk, &status,
  353. (struct bcom_bd **)&bd);
  354. dma_unmap_single(&dev->dev, bd->skb_pa, rskb->len, DMA_FROM_DEVICE);
  355. /* Test for errors in received frame */
  356. if (status & BCOM_FEC_RX_BD_ERRORS) {
  357. /* Drop packet and reuse the buffer */
  358. bd = (struct bcom_fec_bd *)
  359. bcom_prepare_next_buffer(priv->rx_dmatsk);
  360. bd->status = FEC_RX_BUFFER_SIZE;
  361. bd->skb_pa = dma_map_single(&dev->dev, rskb->data,
  362. FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
  363. bcom_submit_next_buffer(priv->rx_dmatsk, rskb);
  364. dev->stats.rx_dropped++;
  365. continue;
  366. }
  367. /* skbs are allocated on open, so now we allocate a new one,
  368. * and remove the old (with the packet) */
  369. skb = dev_alloc_skb(FEC_RX_BUFFER_SIZE);
  370. if (skb) {
  371. /* Process the received skb */
  372. int length = status & BCOM_FEC_RX_BD_LEN_MASK;
  373. skb_put(rskb, length - 4); /* length without CRC32 */
  374. rskb->dev = dev;
  375. rskb->protocol = eth_type_trans(rskb, dev);
  376. netif_rx(rskb);
  377. } else {
  378. /* Can't get a new one : reuse the same & drop pkt */
  379. dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n");
  380. dev->stats.rx_dropped++;
  381. skb = rskb;
  382. }
  383. bd = (struct bcom_fec_bd *)
  384. bcom_prepare_next_buffer(priv->rx_dmatsk);
  385. bd->status = FEC_RX_BUFFER_SIZE;
  386. bd->skb_pa = dma_map_single(&dev->dev, skb->data,
  387. FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
  388. bcom_submit_next_buffer(priv->rx_dmatsk, skb);
  389. }
  390. return IRQ_HANDLED;
  391. }
  392. static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id)
  393. {
  394. struct net_device *dev = dev_id;
  395. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  396. struct mpc52xx_fec __iomem *fec = priv->fec;
  397. u32 ievent;
  398. ievent = in_be32(&fec->ievent);
  399. ievent &= ~FEC_IEVENT_MII; /* mii is handled separately */
  400. if (!ievent)
  401. return IRQ_NONE;
  402. out_be32(&fec->ievent, ievent); /* clear pending events */
  403. /* on fifo error, soft-reset fec */
  404. if (ievent & (FEC_IEVENT_RFIFO_ERROR | FEC_IEVENT_XFIFO_ERROR)) {
  405. if (net_ratelimit() && (ievent & FEC_IEVENT_RFIFO_ERROR))
  406. dev_warn(&dev->dev, "FEC_IEVENT_RFIFO_ERROR\n");
  407. if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR))
  408. dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n");
  409. mpc52xx_fec_reset(dev);
  410. netif_wake_queue(dev);
  411. return IRQ_HANDLED;
  412. }
  413. if (ievent & ~FEC_IEVENT_TFINT)
  414. dev_dbg(&dev->dev, "ievent: %08x\n", ievent);
  415. return IRQ_HANDLED;
  416. }
  417. /*
  418. * Get the current statistics.
  419. * This may be called with the card open or closed.
  420. */
  421. static struct net_device_stats *mpc52xx_fec_get_stats(struct net_device *dev)
  422. {
  423. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  424. struct net_device_stats *stats = &dev->stats;
  425. struct mpc52xx_fec __iomem *fec = priv->fec;
  426. stats->rx_bytes = in_be32(&fec->rmon_r_octets);
  427. stats->rx_packets = in_be32(&fec->rmon_r_packets);
  428. stats->rx_errors = in_be32(&fec->rmon_r_crc_align) +
  429. in_be32(&fec->rmon_r_undersize) +
  430. in_be32(&fec->rmon_r_oversize) +
  431. in_be32(&fec->rmon_r_frag) +
  432. in_be32(&fec->rmon_r_jab);
  433. stats->tx_bytes = in_be32(&fec->rmon_t_octets);
  434. stats->tx_packets = in_be32(&fec->rmon_t_packets);
  435. stats->tx_errors = in_be32(&fec->rmon_t_crc_align) +
  436. in_be32(&fec->rmon_t_undersize) +
  437. in_be32(&fec->rmon_t_oversize) +
  438. in_be32(&fec->rmon_t_frag) +
  439. in_be32(&fec->rmon_t_jab);
  440. stats->multicast = in_be32(&fec->rmon_r_mc_pkt);
  441. stats->collisions = in_be32(&fec->rmon_t_col);
  442. /* detailed rx_errors: */
  443. stats->rx_length_errors = in_be32(&fec->rmon_r_undersize)
  444. + in_be32(&fec->rmon_r_oversize)
  445. + in_be32(&fec->rmon_r_frag)
  446. + in_be32(&fec->rmon_r_jab);
  447. stats->rx_over_errors = in_be32(&fec->r_macerr);
  448. stats->rx_crc_errors = in_be32(&fec->ieee_r_crc);
  449. stats->rx_frame_errors = in_be32(&fec->ieee_r_align);
  450. stats->rx_fifo_errors = in_be32(&fec->rmon_r_drop);
  451. stats->rx_missed_errors = in_be32(&fec->rmon_r_drop);
  452. /* detailed tx_errors: */
  453. stats->tx_aborted_errors = 0;
  454. stats->tx_carrier_errors = in_be32(&fec->ieee_t_cserr);
  455. stats->tx_fifo_errors = in_be32(&fec->rmon_t_drop);
  456. stats->tx_heartbeat_errors = in_be32(&fec->ieee_t_sqe);
  457. stats->tx_window_errors = in_be32(&fec->ieee_t_lcol);
  458. return stats;
  459. }
  460. /*
  461. * Read MIB counters in order to reset them,
  462. * then zero all the stats fields in memory
  463. */
  464. static void mpc52xx_fec_reset_stats(struct net_device *dev)
  465. {
  466. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  467. struct mpc52xx_fec __iomem *fec = priv->fec;
  468. out_be32(&fec->mib_control, FEC_MIB_DISABLE);
  469. memset_io(&fec->rmon_t_drop, 0,
  470. offsetof(struct mpc52xx_fec, reserved10) -
  471. offsetof(struct mpc52xx_fec, rmon_t_drop));
  472. out_be32(&fec->mib_control, 0);
  473. memset(&dev->stats, 0, sizeof(dev->stats));
  474. }
  475. /*
  476. * Set or clear the multicast filter for this adaptor.
  477. */
  478. static void mpc52xx_fec_set_multicast_list(struct net_device *dev)
  479. {
  480. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  481. struct mpc52xx_fec __iomem *fec = priv->fec;
  482. u32 rx_control;
  483. rx_control = in_be32(&fec->r_cntrl);
  484. if (dev->flags & IFF_PROMISC) {
  485. rx_control |= FEC_RCNTRL_PROM;
  486. out_be32(&fec->r_cntrl, rx_control);
  487. } else {
  488. rx_control &= ~FEC_RCNTRL_PROM;
  489. out_be32(&fec->r_cntrl, rx_control);
  490. if (dev->flags & IFF_ALLMULTI) {
  491. out_be32(&fec->gaddr1, 0xffffffff);
  492. out_be32(&fec->gaddr2, 0xffffffff);
  493. } else {
  494. u32 crc;
  495. int i;
  496. struct dev_mc_list *dmi;
  497. u32 gaddr1 = 0x00000000;
  498. u32 gaddr2 = 0x00000000;
  499. dmi = dev->mc_list;
  500. for (i=0; i<dev->mc_count; i++) {
  501. crc = ether_crc_le(6, dmi->dmi_addr) >> 26;
  502. if (crc >= 32)
  503. gaddr1 |= 1 << (crc-32);
  504. else
  505. gaddr2 |= 1 << crc;
  506. dmi = dmi->next;
  507. }
  508. out_be32(&fec->gaddr1, gaddr1);
  509. out_be32(&fec->gaddr2, gaddr2);
  510. }
  511. }
  512. }
  513. /**
  514. * mpc52xx_fec_hw_init
  515. * @dev: network device
  516. *
  517. * Setup various hardware setting, only needed once on start
  518. */
  519. static void mpc52xx_fec_hw_init(struct net_device *dev)
  520. {
  521. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  522. struct mpc52xx_fec __iomem *fec = priv->fec;
  523. int i;
  524. /* Whack a reset. We should wait for this. */
  525. out_be32(&fec->ecntrl, FEC_ECNTRL_RESET);
  526. for (i = 0; i < FEC_RESET_DELAY; ++i) {
  527. if ((in_be32(&fec->ecntrl) & FEC_ECNTRL_RESET) == 0)
  528. break;
  529. udelay(1);
  530. }
  531. if (i == FEC_RESET_DELAY)
  532. dev_err(&dev->dev, "FEC Reset timeout!\n");
  533. /* set pause to 0x20 frames */
  534. out_be32(&fec->op_pause, FEC_OP_PAUSE_OPCODE | 0x20);
  535. /* high service request will be deasserted when there's < 7 bytes in fifo
  536. * low service request will be deasserted when there's < 4*7 bytes in fifo
  537. */
  538. out_be32(&fec->rfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7);
  539. out_be32(&fec->tfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7);
  540. /* alarm when <= x bytes in FIFO */
  541. out_be32(&fec->rfifo_alarm, 0x0000030c);
  542. out_be32(&fec->tfifo_alarm, 0x00000100);
  543. /* begin transmittion when 256 bytes are in FIFO (or EOF or FIFO full) */
  544. out_be32(&fec->x_wmrk, FEC_FIFO_WMRK_256B);
  545. /* enable crc generation */
  546. out_be32(&fec->xmit_fsm, FEC_XMIT_FSM_APPEND_CRC | FEC_XMIT_FSM_ENABLE_CRC);
  547. out_be32(&fec->iaddr1, 0x00000000); /* No individual filter */
  548. out_be32(&fec->iaddr2, 0x00000000); /* No individual filter */
  549. /* set phy speed.
  550. * this can't be done in phy driver, since it needs to be called
  551. * before fec stuff (even on resume) */
  552. mpc52xx_fec_phy_hw_init(priv);
  553. }
  554. /**
  555. * mpc52xx_fec_start
  556. * @dev: network device
  557. *
  558. * This function is called to start or restart the FEC during a link
  559. * change. This happens on fifo errors or when switching between half
  560. * and full duplex.
  561. */
  562. static void mpc52xx_fec_start(struct net_device *dev)
  563. {
  564. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  565. struct mpc52xx_fec __iomem *fec = priv->fec;
  566. u32 rcntrl;
  567. u32 tcntrl;
  568. u32 tmp;
  569. /* clear sticky error bits */
  570. tmp = FEC_FIFO_STATUS_ERR | FEC_FIFO_STATUS_UF | FEC_FIFO_STATUS_OF;
  571. out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status) & tmp);
  572. out_be32(&fec->tfifo_status, in_be32(&fec->tfifo_status) & tmp);
  573. /* FIFOs will reset on mpc52xx_fec_enable */
  574. out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_ENABLE_IS_RESET);
  575. /* Set station address. */
  576. mpc52xx_fec_set_paddr(dev, dev->dev_addr);
  577. mpc52xx_fec_set_multicast_list(dev);
  578. /* set max frame len, enable flow control, select mii mode */
  579. rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */
  580. rcntrl |= FEC_RCNTRL_FCE;
  581. if (priv->phy_addr != FEC5200_PHYADDR_7WIRE)
  582. rcntrl |= FEC_RCNTRL_MII_MODE;
  583. if (priv->duplex == DUPLEX_FULL)
  584. tcntrl = FEC_TCNTRL_FDEN; /* FD enable */
  585. else {
  586. rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */
  587. tcntrl = 0;
  588. }
  589. out_be32(&fec->r_cntrl, rcntrl);
  590. out_be32(&fec->x_cntrl, tcntrl);
  591. /* Clear any outstanding interrupt. */
  592. out_be32(&fec->ievent, 0xffffffff);
  593. /* Enable interrupts we wish to service. */
  594. out_be32(&fec->imask, FEC_IMASK_ENABLE);
  595. /* And last, enable the transmit and receive processing. */
  596. out_be32(&fec->ecntrl, FEC_ECNTRL_ETHER_EN);
  597. out_be32(&fec->r_des_active, 0x01000000);
  598. }
  599. /**
  600. * mpc52xx_fec_stop
  601. * @dev: network device
  602. *
  603. * stop all activity on fec and empty dma buffers
  604. */
  605. static void mpc52xx_fec_stop(struct net_device *dev)
  606. {
  607. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  608. struct mpc52xx_fec __iomem *fec = priv->fec;
  609. unsigned long timeout;
  610. /* disable all interrupts */
  611. out_be32(&fec->imask, 0);
  612. /* Disable the rx task. */
  613. bcom_disable(priv->rx_dmatsk);
  614. /* Wait for tx queue to drain, but only if we're in process context */
  615. if (!in_interrupt()) {
  616. timeout = jiffies + msecs_to_jiffies(2000);
  617. while (time_before(jiffies, timeout) &&
  618. !bcom_queue_empty(priv->tx_dmatsk))
  619. msleep(100);
  620. if (time_after_eq(jiffies, timeout))
  621. dev_err(&dev->dev, "queues didn't drain\n");
  622. #if 1
  623. if (time_after_eq(jiffies, timeout)) {
  624. dev_err(&dev->dev, " tx: index: %i, outdex: %i\n",
  625. priv->tx_dmatsk->index,
  626. priv->tx_dmatsk->outdex);
  627. dev_err(&dev->dev, " rx: index: %i, outdex: %i\n",
  628. priv->rx_dmatsk->index,
  629. priv->rx_dmatsk->outdex);
  630. }
  631. #endif
  632. }
  633. bcom_disable(priv->tx_dmatsk);
  634. /* Stop FEC */
  635. out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) & ~FEC_ECNTRL_ETHER_EN);
  636. return;
  637. }
  638. /* reset fec and bestcomm tasks */
  639. static void mpc52xx_fec_reset(struct net_device *dev)
  640. {
  641. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  642. struct mpc52xx_fec __iomem *fec = priv->fec;
  643. mpc52xx_fec_stop(dev);
  644. out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status));
  645. out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_RESET_FIFO);
  646. mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk);
  647. mpc52xx_fec_hw_init(dev);
  648. phy_stop(priv->phydev);
  649. phy_write(priv->phydev, MII_BMCR, BMCR_RESET);
  650. phy_start(priv->phydev);
  651. bcom_fec_rx_reset(priv->rx_dmatsk);
  652. bcom_fec_tx_reset(priv->tx_dmatsk);
  653. mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk);
  654. bcom_enable(priv->rx_dmatsk);
  655. bcom_enable(priv->tx_dmatsk);
  656. mpc52xx_fec_start(dev);
  657. }
  658. /* ethtool interface */
  659. static void mpc52xx_fec_get_drvinfo(struct net_device *dev,
  660. struct ethtool_drvinfo *info)
  661. {
  662. strcpy(info->driver, DRIVER_NAME);
  663. }
  664. static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  665. {
  666. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  667. return phy_ethtool_gset(priv->phydev, cmd);
  668. }
  669. static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  670. {
  671. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  672. return phy_ethtool_sset(priv->phydev, cmd);
  673. }
  674. static u32 mpc52xx_fec_get_msglevel(struct net_device *dev)
  675. {
  676. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  677. return priv->msg_enable;
  678. }
  679. static void mpc52xx_fec_set_msglevel(struct net_device *dev, u32 level)
  680. {
  681. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  682. priv->msg_enable = level;
  683. }
  684. static const struct ethtool_ops mpc52xx_fec_ethtool_ops = {
  685. .get_drvinfo = mpc52xx_fec_get_drvinfo,
  686. .get_settings = mpc52xx_fec_get_settings,
  687. .set_settings = mpc52xx_fec_set_settings,
  688. .get_link = ethtool_op_get_link,
  689. .get_msglevel = mpc52xx_fec_get_msglevel,
  690. .set_msglevel = mpc52xx_fec_set_msglevel,
  691. };
  692. static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  693. {
  694. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  695. return mpc52xx_fec_phy_mii_ioctl(priv, if_mii(rq), cmd);
  696. }
  697. /* ======================================================================== */
  698. /* OF Driver */
  699. /* ======================================================================== */
  700. static int __devinit
  701. mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
  702. {
  703. int rv;
  704. struct net_device *ndev;
  705. struct mpc52xx_fec_priv *priv = NULL;
  706. struct resource mem;
  707. struct device_node *phy_node;
  708. const phandle *phy_handle;
  709. const u32 *prop;
  710. int prop_size;
  711. phys_addr_t rx_fifo;
  712. phys_addr_t tx_fifo;
  713. /* Get the ether ndev & it's private zone */
  714. ndev = alloc_etherdev(sizeof(struct mpc52xx_fec_priv));
  715. if (!ndev)
  716. return -ENOMEM;
  717. priv = netdev_priv(ndev);
  718. /* Reserve FEC control zone */
  719. rv = of_address_to_resource(op->node, 0, &mem);
  720. if (rv) {
  721. printk(KERN_ERR DRIVER_NAME ": "
  722. "Error while parsing device node resource\n" );
  723. return rv;
  724. }
  725. if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) {
  726. printk(KERN_ERR DRIVER_NAME
  727. " - invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
  728. (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec));
  729. return -EINVAL;
  730. }
  731. if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec), DRIVER_NAME))
  732. return -EBUSY;
  733. /* Init ether ndev with what we have */
  734. ndev->open = mpc52xx_fec_open;
  735. ndev->stop = mpc52xx_fec_close;
  736. ndev->hard_start_xmit = mpc52xx_fec_hard_start_xmit;
  737. ndev->do_ioctl = mpc52xx_fec_ioctl;
  738. ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops;
  739. ndev->get_stats = mpc52xx_fec_get_stats;
  740. ndev->set_mac_address = mpc52xx_fec_set_mac_address;
  741. ndev->set_multicast_list = mpc52xx_fec_set_multicast_list;
  742. ndev->tx_timeout = mpc52xx_fec_tx_timeout;
  743. ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT;
  744. ndev->base_addr = mem.start;
  745. #ifdef CONFIG_NET_POLL_CONTROLLER
  746. ndev->poll_controller = mpc52xx_fec_poll_controller;
  747. #endif
  748. priv->t_irq = priv->r_irq = ndev->irq = NO_IRQ; /* IRQ are free for now */
  749. spin_lock_init(&priv->lock);
  750. /* ioremap the zones */
  751. priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec));
  752. if (!priv->fec) {
  753. rv = -ENOMEM;
  754. goto probe_error;
  755. }
  756. /* Bestcomm init */
  757. rx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, rfifo_data);
  758. tx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, tfifo_data);
  759. priv->rx_dmatsk = bcom_fec_rx_init(FEC_RX_NUM_BD, rx_fifo, FEC_RX_BUFFER_SIZE);
  760. priv->tx_dmatsk = bcom_fec_tx_init(FEC_TX_NUM_BD, tx_fifo);
  761. if (!priv->rx_dmatsk || !priv->tx_dmatsk) {
  762. printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" );
  763. rv = -ENOMEM;
  764. goto probe_error;
  765. }
  766. /* Get the IRQ we need one by one */
  767. /* Control */
  768. ndev->irq = irq_of_parse_and_map(op->node, 0);
  769. /* RX */
  770. priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk);
  771. /* TX */
  772. priv->t_irq = bcom_get_task_irq(priv->tx_dmatsk);
  773. /* MAC address init */
  774. if (!is_zero_ether_addr(mpc52xx_fec_mac_addr))
  775. memcpy(ndev->dev_addr, mpc52xx_fec_mac_addr, 6);
  776. else
  777. mpc52xx_fec_get_paddr(ndev, ndev->dev_addr);
  778. priv->msg_enable = netif_msg_init(debug, MPC52xx_MESSAGES_DEFAULT);
  779. /*
  780. * Link mode configuration
  781. */
  782. /* Start with safe defaults for link connection */
  783. priv->phy_addr = FEC5200_PHYADDR_NONE;
  784. priv->speed = 100;
  785. priv->duplex = DUPLEX_HALF;
  786. priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1;
  787. /* the 7-wire property means don't use MII mode */
  788. if (of_find_property(op->node, "fsl,7-wire-mode", NULL))
  789. priv->phy_addr = FEC5200_PHYADDR_7WIRE;
  790. /* The current speed preconfigures the speed of the MII link */
  791. prop = of_get_property(op->node, "current-speed", &prop_size);
  792. if (prop && (prop_size >= sizeof(u32) * 2)) {
  793. priv->speed = prop[0];
  794. priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF;
  795. }
  796. /* If there is a phy handle, setup link to that phy */
  797. phy_handle = of_get_property(op->node, "phy-handle", &prop_size);
  798. if (phy_handle && (prop_size >= sizeof(phandle))) {
  799. phy_node = of_find_node_by_phandle(*phy_handle);
  800. prop = of_get_property(phy_node, "reg", &prop_size);
  801. if (prop && (prop_size >= sizeof(u32)))
  802. if ((*prop >= 0) && (*prop < PHY_MAX_ADDR))
  803. priv->phy_addr = *prop;
  804. of_node_put(phy_node);
  805. }
  806. /* Hardware init */
  807. mpc52xx_fec_hw_init(ndev);
  808. mpc52xx_fec_reset_stats(ndev);
  809. SET_NETDEV_DEV(ndev, &op->dev);
  810. /* Register the new network device */
  811. rv = register_netdev(ndev);
  812. if (rv < 0)
  813. goto probe_error;
  814. /* Now report the link setup */
  815. switch (priv->phy_addr) {
  816. case FEC5200_PHYADDR_NONE:
  817. dev_info(&ndev->dev, "Fixed speed MII link: %i%cD\n",
  818. priv->speed, priv->duplex ? 'F' : 'H');
  819. break;
  820. case FEC5200_PHYADDR_7WIRE:
  821. dev_info(&ndev->dev, "using 7-wire PHY mode\n");
  822. break;
  823. default:
  824. dev_info(&ndev->dev, "Using PHY at MDIO address %i\n",
  825. priv->phy_addr);
  826. }
  827. /* We're done ! */
  828. dev_set_drvdata(&op->dev, ndev);
  829. return 0;
  830. /* Error handling - free everything that might be allocated */
  831. probe_error:
  832. irq_dispose_mapping(ndev->irq);
  833. if (priv->rx_dmatsk)
  834. bcom_fec_rx_release(priv->rx_dmatsk);
  835. if (priv->tx_dmatsk)
  836. bcom_fec_tx_release(priv->tx_dmatsk);
  837. if (priv->fec)
  838. iounmap(priv->fec);
  839. release_mem_region(mem.start, sizeof(struct mpc52xx_fec));
  840. free_netdev(ndev);
  841. return rv;
  842. }
  843. static int
  844. mpc52xx_fec_remove(struct of_device *op)
  845. {
  846. struct net_device *ndev;
  847. struct mpc52xx_fec_priv *priv;
  848. ndev = dev_get_drvdata(&op->dev);
  849. priv = netdev_priv(ndev);
  850. unregister_netdev(ndev);
  851. irq_dispose_mapping(ndev->irq);
  852. bcom_fec_rx_release(priv->rx_dmatsk);
  853. bcom_fec_tx_release(priv->tx_dmatsk);
  854. iounmap(priv->fec);
  855. release_mem_region(ndev->base_addr, sizeof(struct mpc52xx_fec));
  856. free_netdev(ndev);
  857. dev_set_drvdata(&op->dev, NULL);
  858. return 0;
  859. }
  860. #ifdef CONFIG_PM
  861. static int mpc52xx_fec_of_suspend(struct of_device *op, pm_message_t state)
  862. {
  863. struct net_device *dev = dev_get_drvdata(&op->dev);
  864. if (netif_running(dev))
  865. mpc52xx_fec_close(dev);
  866. return 0;
  867. }
  868. static int mpc52xx_fec_of_resume(struct of_device *op)
  869. {
  870. struct net_device *dev = dev_get_drvdata(&op->dev);
  871. mpc52xx_fec_hw_init(dev);
  872. mpc52xx_fec_reset_stats(dev);
  873. if (netif_running(dev))
  874. mpc52xx_fec_open(dev);
  875. return 0;
  876. }
  877. #endif
  878. static struct of_device_id mpc52xx_fec_match[] = {
  879. { .type = "network", .compatible = "fsl,mpc5200b-fec", },
  880. { .type = "network", .compatible = "fsl,mpc5200-fec", },
  881. { .type = "network", .compatible = "mpc5200-fec", },
  882. { }
  883. };
  884. MODULE_DEVICE_TABLE(of, mpc52xx_fec_match);
  885. static struct of_platform_driver mpc52xx_fec_driver = {
  886. .owner = THIS_MODULE,
  887. .name = DRIVER_NAME,
  888. .match_table = mpc52xx_fec_match,
  889. .probe = mpc52xx_fec_probe,
  890. .remove = mpc52xx_fec_remove,
  891. #ifdef CONFIG_PM
  892. .suspend = mpc52xx_fec_of_suspend,
  893. .resume = mpc52xx_fec_of_resume,
  894. #endif
  895. };
  896. /* ======================================================================== */
  897. /* Module */
  898. /* ======================================================================== */
  899. static int __init
  900. mpc52xx_fec_init(void)
  901. {
  902. #ifdef CONFIG_FEC_MPC52xx_MDIO
  903. int ret;
  904. ret = of_register_platform_driver(&mpc52xx_fec_mdio_driver);
  905. if (ret) {
  906. printk(KERN_ERR DRIVER_NAME ": failed to register mdio driver\n");
  907. return ret;
  908. }
  909. #endif
  910. return of_register_platform_driver(&mpc52xx_fec_driver);
  911. }
  912. static void __exit
  913. mpc52xx_fec_exit(void)
  914. {
  915. of_unregister_platform_driver(&mpc52xx_fec_driver);
  916. #ifdef CONFIG_FEC_MPC52xx_MDIO
  917. of_unregister_platform_driver(&mpc52xx_fec_mdio_driver);
  918. #endif
  919. }
  920. module_init(mpc52xx_fec_init);
  921. module_exit(mpc52xx_fec_exit);
  922. MODULE_LICENSE("GPL");
  923. MODULE_AUTHOR("Dale Farnsworth");
  924. MODULE_DESCRIPTION("Ethernet driver for the Freescale MPC52xx FEC");