fec_mpc52xx.c 30 KB

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