fec_mpc52xx.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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, BUS_ID_SIZE, "%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. dev->last_rx = jiffies;
  378. } else {
  379. /* Can't get a new one : reuse the same & drop pkt */
  380. dev_notice(&dev->dev, "Memory squeeze, dropping packet.\n");
  381. dev->stats.rx_dropped++;
  382. skb = rskb;
  383. }
  384. bd = (struct bcom_fec_bd *)
  385. bcom_prepare_next_buffer(priv->rx_dmatsk);
  386. bd->status = FEC_RX_BUFFER_SIZE;
  387. bd->skb_pa = dma_map_single(&dev->dev, skb->data,
  388. FEC_RX_BUFFER_SIZE, DMA_FROM_DEVICE);
  389. bcom_submit_next_buffer(priv->rx_dmatsk, skb);
  390. }
  391. return IRQ_HANDLED;
  392. }
  393. static irqreturn_t mpc52xx_fec_interrupt(int irq, void *dev_id)
  394. {
  395. struct net_device *dev = dev_id;
  396. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  397. struct mpc52xx_fec __iomem *fec = priv->fec;
  398. u32 ievent;
  399. ievent = in_be32(&fec->ievent);
  400. ievent &= ~FEC_IEVENT_MII; /* mii is handled separately */
  401. if (!ievent)
  402. return IRQ_NONE;
  403. out_be32(&fec->ievent, ievent); /* clear pending events */
  404. /* on fifo error, soft-reset fec */
  405. if (ievent & (FEC_IEVENT_RFIFO_ERROR | FEC_IEVENT_XFIFO_ERROR)) {
  406. if (net_ratelimit() && (ievent & FEC_IEVENT_RFIFO_ERROR))
  407. dev_warn(&dev->dev, "FEC_IEVENT_RFIFO_ERROR\n");
  408. if (net_ratelimit() && (ievent & FEC_IEVENT_XFIFO_ERROR))
  409. dev_warn(&dev->dev, "FEC_IEVENT_XFIFO_ERROR\n");
  410. mpc52xx_fec_reset(dev);
  411. netif_wake_queue(dev);
  412. return IRQ_HANDLED;
  413. }
  414. if (ievent & ~FEC_IEVENT_TFINT)
  415. dev_dbg(&dev->dev, "ievent: %08x\n", ievent);
  416. return IRQ_HANDLED;
  417. }
  418. /*
  419. * Get the current statistics.
  420. * This may be called with the card open or closed.
  421. */
  422. static struct net_device_stats *mpc52xx_fec_get_stats(struct net_device *dev)
  423. {
  424. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  425. struct net_device_stats *stats = &dev->stats;
  426. struct mpc52xx_fec __iomem *fec = priv->fec;
  427. stats->rx_bytes = in_be32(&fec->rmon_r_octets);
  428. stats->rx_packets = in_be32(&fec->rmon_r_packets);
  429. stats->rx_errors = in_be32(&fec->rmon_r_crc_align) +
  430. in_be32(&fec->rmon_r_undersize) +
  431. in_be32(&fec->rmon_r_oversize) +
  432. in_be32(&fec->rmon_r_frag) +
  433. in_be32(&fec->rmon_r_jab);
  434. stats->tx_bytes = in_be32(&fec->rmon_t_octets);
  435. stats->tx_packets = in_be32(&fec->rmon_t_packets);
  436. stats->tx_errors = in_be32(&fec->rmon_t_crc_align) +
  437. in_be32(&fec->rmon_t_undersize) +
  438. in_be32(&fec->rmon_t_oversize) +
  439. in_be32(&fec->rmon_t_frag) +
  440. in_be32(&fec->rmon_t_jab);
  441. stats->multicast = in_be32(&fec->rmon_r_mc_pkt);
  442. stats->collisions = in_be32(&fec->rmon_t_col);
  443. /* detailed rx_errors: */
  444. stats->rx_length_errors = in_be32(&fec->rmon_r_undersize)
  445. + in_be32(&fec->rmon_r_oversize)
  446. + in_be32(&fec->rmon_r_frag)
  447. + in_be32(&fec->rmon_r_jab);
  448. stats->rx_over_errors = in_be32(&fec->r_macerr);
  449. stats->rx_crc_errors = in_be32(&fec->ieee_r_crc);
  450. stats->rx_frame_errors = in_be32(&fec->ieee_r_align);
  451. stats->rx_fifo_errors = in_be32(&fec->rmon_r_drop);
  452. stats->rx_missed_errors = in_be32(&fec->rmon_r_drop);
  453. /* detailed tx_errors: */
  454. stats->tx_aborted_errors = 0;
  455. stats->tx_carrier_errors = in_be32(&fec->ieee_t_cserr);
  456. stats->tx_fifo_errors = in_be32(&fec->rmon_t_drop);
  457. stats->tx_heartbeat_errors = in_be32(&fec->ieee_t_sqe);
  458. stats->tx_window_errors = in_be32(&fec->ieee_t_lcol);
  459. return stats;
  460. }
  461. /*
  462. * Read MIB counters in order to reset them,
  463. * then zero all the stats fields in memory
  464. */
  465. static void mpc52xx_fec_reset_stats(struct net_device *dev)
  466. {
  467. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  468. struct mpc52xx_fec __iomem *fec = priv->fec;
  469. out_be32(&fec->mib_control, FEC_MIB_DISABLE);
  470. memset_io(&fec->rmon_t_drop, 0,
  471. offsetof(struct mpc52xx_fec, reserved10) -
  472. offsetof(struct mpc52xx_fec, rmon_t_drop));
  473. out_be32(&fec->mib_control, 0);
  474. memset(&dev->stats, 0, sizeof(dev->stats));
  475. }
  476. /*
  477. * Set or clear the multicast filter for this adaptor.
  478. */
  479. static void mpc52xx_fec_set_multicast_list(struct net_device *dev)
  480. {
  481. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  482. struct mpc52xx_fec __iomem *fec = priv->fec;
  483. u32 rx_control;
  484. rx_control = in_be32(&fec->r_cntrl);
  485. if (dev->flags & IFF_PROMISC) {
  486. rx_control |= FEC_RCNTRL_PROM;
  487. out_be32(&fec->r_cntrl, rx_control);
  488. } else {
  489. rx_control &= ~FEC_RCNTRL_PROM;
  490. out_be32(&fec->r_cntrl, rx_control);
  491. if (dev->flags & IFF_ALLMULTI) {
  492. out_be32(&fec->gaddr1, 0xffffffff);
  493. out_be32(&fec->gaddr2, 0xffffffff);
  494. } else {
  495. u32 crc;
  496. int i;
  497. struct dev_mc_list *dmi;
  498. u32 gaddr1 = 0x00000000;
  499. u32 gaddr2 = 0x00000000;
  500. dmi = dev->mc_list;
  501. for (i=0; i<dev->mc_count; i++) {
  502. crc = ether_crc_le(6, dmi->dmi_addr) >> 26;
  503. if (crc >= 32)
  504. gaddr1 |= 1 << (crc-32);
  505. else
  506. gaddr2 |= 1 << crc;
  507. dmi = dmi->next;
  508. }
  509. out_be32(&fec->gaddr1, gaddr1);
  510. out_be32(&fec->gaddr2, gaddr2);
  511. }
  512. }
  513. }
  514. /**
  515. * mpc52xx_fec_hw_init
  516. * @dev: network device
  517. *
  518. * Setup various hardware setting, only needed once on start
  519. */
  520. static void mpc52xx_fec_hw_init(struct net_device *dev)
  521. {
  522. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  523. struct mpc52xx_fec __iomem *fec = priv->fec;
  524. int i;
  525. /* Whack a reset. We should wait for this. */
  526. out_be32(&fec->ecntrl, FEC_ECNTRL_RESET);
  527. for (i = 0; i < FEC_RESET_DELAY; ++i) {
  528. if ((in_be32(&fec->ecntrl) & FEC_ECNTRL_RESET) == 0)
  529. break;
  530. udelay(1);
  531. }
  532. if (i == FEC_RESET_DELAY)
  533. dev_err(&dev->dev, "FEC Reset timeout!\n");
  534. /* set pause to 0x20 frames */
  535. out_be32(&fec->op_pause, FEC_OP_PAUSE_OPCODE | 0x20);
  536. /* high service request will be deasserted when there's < 7 bytes in fifo
  537. * low service request will be deasserted when there's < 4*7 bytes in fifo
  538. */
  539. out_be32(&fec->rfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7);
  540. out_be32(&fec->tfifo_cntrl, FEC_FIFO_CNTRL_FRAME | FEC_FIFO_CNTRL_LTG_7);
  541. /* alarm when <= x bytes in FIFO */
  542. out_be32(&fec->rfifo_alarm, 0x0000030c);
  543. out_be32(&fec->tfifo_alarm, 0x00000100);
  544. /* begin transmittion when 256 bytes are in FIFO (or EOF or FIFO full) */
  545. out_be32(&fec->x_wmrk, FEC_FIFO_WMRK_256B);
  546. /* enable crc generation */
  547. out_be32(&fec->xmit_fsm, FEC_XMIT_FSM_APPEND_CRC | FEC_XMIT_FSM_ENABLE_CRC);
  548. out_be32(&fec->iaddr1, 0x00000000); /* No individual filter */
  549. out_be32(&fec->iaddr2, 0x00000000); /* No individual filter */
  550. /* set phy speed.
  551. * this can't be done in phy driver, since it needs to be called
  552. * before fec stuff (even on resume) */
  553. mpc52xx_fec_phy_hw_init(priv);
  554. }
  555. /**
  556. * mpc52xx_fec_start
  557. * @dev: network device
  558. *
  559. * This function is called to start or restart the FEC during a link
  560. * change. This happens on fifo errors or when switching between half
  561. * and full duplex.
  562. */
  563. static void mpc52xx_fec_start(struct net_device *dev)
  564. {
  565. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  566. struct mpc52xx_fec __iomem *fec = priv->fec;
  567. u32 rcntrl;
  568. u32 tcntrl;
  569. u32 tmp;
  570. /* clear sticky error bits */
  571. tmp = FEC_FIFO_STATUS_ERR | FEC_FIFO_STATUS_UF | FEC_FIFO_STATUS_OF;
  572. out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status) & tmp);
  573. out_be32(&fec->tfifo_status, in_be32(&fec->tfifo_status) & tmp);
  574. /* FIFOs will reset on mpc52xx_fec_enable */
  575. out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_ENABLE_IS_RESET);
  576. /* Set station address. */
  577. mpc52xx_fec_set_paddr(dev, dev->dev_addr);
  578. mpc52xx_fec_set_multicast_list(dev);
  579. /* set max frame len, enable flow control, select mii mode */
  580. rcntrl = FEC_RX_BUFFER_SIZE << 16; /* max frame length */
  581. rcntrl |= FEC_RCNTRL_FCE;
  582. if (priv->phy_addr != FEC5200_PHYADDR_7WIRE)
  583. rcntrl |= FEC_RCNTRL_MII_MODE;
  584. if (priv->duplex == DUPLEX_FULL)
  585. tcntrl = FEC_TCNTRL_FDEN; /* FD enable */
  586. else {
  587. rcntrl |= FEC_RCNTRL_DRT; /* disable Rx on Tx (HD) */
  588. tcntrl = 0;
  589. }
  590. out_be32(&fec->r_cntrl, rcntrl);
  591. out_be32(&fec->x_cntrl, tcntrl);
  592. /* Clear any outstanding interrupt. */
  593. out_be32(&fec->ievent, 0xffffffff);
  594. /* Enable interrupts we wish to service. */
  595. out_be32(&fec->imask, FEC_IMASK_ENABLE);
  596. /* And last, enable the transmit and receive processing. */
  597. out_be32(&fec->ecntrl, FEC_ECNTRL_ETHER_EN);
  598. out_be32(&fec->r_des_active, 0x01000000);
  599. }
  600. /**
  601. * mpc52xx_fec_stop
  602. * @dev: network device
  603. *
  604. * stop all activity on fec and empty dma buffers
  605. */
  606. static void mpc52xx_fec_stop(struct net_device *dev)
  607. {
  608. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  609. struct mpc52xx_fec __iomem *fec = priv->fec;
  610. unsigned long timeout;
  611. /* disable all interrupts */
  612. out_be32(&fec->imask, 0);
  613. /* Disable the rx task. */
  614. bcom_disable(priv->rx_dmatsk);
  615. /* Wait for tx queue to drain, but only if we're in process context */
  616. if (!in_interrupt()) {
  617. timeout = jiffies + msecs_to_jiffies(2000);
  618. while (time_before(jiffies, timeout) &&
  619. !bcom_queue_empty(priv->tx_dmatsk))
  620. msleep(100);
  621. if (time_after_eq(jiffies, timeout))
  622. dev_err(&dev->dev, "queues didn't drain\n");
  623. #if 1
  624. if (time_after_eq(jiffies, timeout)) {
  625. dev_err(&dev->dev, " tx: index: %i, outdex: %i\n",
  626. priv->tx_dmatsk->index,
  627. priv->tx_dmatsk->outdex);
  628. dev_err(&dev->dev, " rx: index: %i, outdex: %i\n",
  629. priv->rx_dmatsk->index,
  630. priv->rx_dmatsk->outdex);
  631. }
  632. #endif
  633. }
  634. bcom_disable(priv->tx_dmatsk);
  635. /* Stop FEC */
  636. out_be32(&fec->ecntrl, in_be32(&fec->ecntrl) & ~FEC_ECNTRL_ETHER_EN);
  637. return;
  638. }
  639. /* reset fec and bestcomm tasks */
  640. static void mpc52xx_fec_reset(struct net_device *dev)
  641. {
  642. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  643. struct mpc52xx_fec __iomem *fec = priv->fec;
  644. mpc52xx_fec_stop(dev);
  645. out_be32(&fec->rfifo_status, in_be32(&fec->rfifo_status));
  646. out_be32(&fec->reset_cntrl, FEC_RESET_CNTRL_RESET_FIFO);
  647. mpc52xx_fec_free_rx_buffers(dev, priv->rx_dmatsk);
  648. mpc52xx_fec_hw_init(dev);
  649. phy_stop(priv->phydev);
  650. phy_write(priv->phydev, MII_BMCR, BMCR_RESET);
  651. phy_start(priv->phydev);
  652. bcom_fec_rx_reset(priv->rx_dmatsk);
  653. bcom_fec_tx_reset(priv->tx_dmatsk);
  654. mpc52xx_fec_alloc_rx_buffers(dev, priv->rx_dmatsk);
  655. bcom_enable(priv->rx_dmatsk);
  656. bcom_enable(priv->tx_dmatsk);
  657. mpc52xx_fec_start(dev);
  658. }
  659. /* ethtool interface */
  660. static void mpc52xx_fec_get_drvinfo(struct net_device *dev,
  661. struct ethtool_drvinfo *info)
  662. {
  663. strcpy(info->driver, DRIVER_NAME);
  664. }
  665. static int mpc52xx_fec_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  666. {
  667. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  668. return phy_ethtool_gset(priv->phydev, cmd);
  669. }
  670. static int mpc52xx_fec_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  671. {
  672. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  673. return phy_ethtool_sset(priv->phydev, cmd);
  674. }
  675. static u32 mpc52xx_fec_get_msglevel(struct net_device *dev)
  676. {
  677. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  678. return priv->msg_enable;
  679. }
  680. static void mpc52xx_fec_set_msglevel(struct net_device *dev, u32 level)
  681. {
  682. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  683. priv->msg_enable = level;
  684. }
  685. static const struct ethtool_ops mpc52xx_fec_ethtool_ops = {
  686. .get_drvinfo = mpc52xx_fec_get_drvinfo,
  687. .get_settings = mpc52xx_fec_get_settings,
  688. .set_settings = mpc52xx_fec_set_settings,
  689. .get_link = ethtool_op_get_link,
  690. .get_msglevel = mpc52xx_fec_get_msglevel,
  691. .set_msglevel = mpc52xx_fec_set_msglevel,
  692. };
  693. static int mpc52xx_fec_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
  694. {
  695. struct mpc52xx_fec_priv *priv = netdev_priv(dev);
  696. return mpc52xx_fec_phy_mii_ioctl(priv, if_mii(rq), cmd);
  697. }
  698. /* ======================================================================== */
  699. /* OF Driver */
  700. /* ======================================================================== */
  701. static int __devinit
  702. mpc52xx_fec_probe(struct of_device *op, const struct of_device_id *match)
  703. {
  704. int rv;
  705. struct net_device *ndev;
  706. struct mpc52xx_fec_priv *priv = NULL;
  707. struct resource mem;
  708. struct device_node *phy_node;
  709. const phandle *phy_handle;
  710. const u32 *prop;
  711. int prop_size;
  712. phys_addr_t rx_fifo;
  713. phys_addr_t tx_fifo;
  714. /* Get the ether ndev & it's private zone */
  715. ndev = alloc_etherdev(sizeof(struct mpc52xx_fec_priv));
  716. if (!ndev)
  717. return -ENOMEM;
  718. priv = netdev_priv(ndev);
  719. /* Reserve FEC control zone */
  720. rv = of_address_to_resource(op->node, 0, &mem);
  721. if (rv) {
  722. printk(KERN_ERR DRIVER_NAME ": "
  723. "Error while parsing device node resource\n" );
  724. return rv;
  725. }
  726. if ((mem.end - mem.start + 1) < sizeof(struct mpc52xx_fec)) {
  727. printk(KERN_ERR DRIVER_NAME
  728. " - invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
  729. (unsigned long)(mem.end - mem.start + 1), sizeof(struct mpc52xx_fec));
  730. return -EINVAL;
  731. }
  732. if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec), DRIVER_NAME))
  733. return -EBUSY;
  734. /* Init ether ndev with what we have */
  735. ndev->open = mpc52xx_fec_open;
  736. ndev->stop = mpc52xx_fec_close;
  737. ndev->hard_start_xmit = mpc52xx_fec_hard_start_xmit;
  738. ndev->do_ioctl = mpc52xx_fec_ioctl;
  739. ndev->ethtool_ops = &mpc52xx_fec_ethtool_ops;
  740. ndev->get_stats = mpc52xx_fec_get_stats;
  741. ndev->set_mac_address = mpc52xx_fec_set_mac_address;
  742. ndev->set_multicast_list = mpc52xx_fec_set_multicast_list;
  743. ndev->tx_timeout = mpc52xx_fec_tx_timeout;
  744. ndev->watchdog_timeo = FEC_WATCHDOG_TIMEOUT;
  745. ndev->base_addr = mem.start;
  746. #ifdef CONFIG_NET_POLL_CONTROLLER
  747. ndev->poll_controller = mpc52xx_fec_poll_controller;
  748. #endif
  749. priv->t_irq = priv->r_irq = ndev->irq = NO_IRQ; /* IRQ are free for now */
  750. spin_lock_init(&priv->lock);
  751. /* ioremap the zones */
  752. priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec));
  753. if (!priv->fec) {
  754. rv = -ENOMEM;
  755. goto probe_error;
  756. }
  757. /* Bestcomm init */
  758. rx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, rfifo_data);
  759. tx_fifo = ndev->base_addr + offsetof(struct mpc52xx_fec, tfifo_data);
  760. priv->rx_dmatsk = bcom_fec_rx_init(FEC_RX_NUM_BD, rx_fifo, FEC_RX_BUFFER_SIZE);
  761. priv->tx_dmatsk = bcom_fec_tx_init(FEC_TX_NUM_BD, tx_fifo);
  762. if (!priv->rx_dmatsk || !priv->tx_dmatsk) {
  763. printk(KERN_ERR DRIVER_NAME ": Can not init SDMA tasks\n" );
  764. rv = -ENOMEM;
  765. goto probe_error;
  766. }
  767. /* Get the IRQ we need one by one */
  768. /* Control */
  769. ndev->irq = irq_of_parse_and_map(op->node, 0);
  770. /* RX */
  771. priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk);
  772. /* TX */
  773. priv->t_irq = bcom_get_task_irq(priv->tx_dmatsk);
  774. /* MAC address init */
  775. if (!is_zero_ether_addr(mpc52xx_fec_mac_addr))
  776. memcpy(ndev->dev_addr, mpc52xx_fec_mac_addr, 6);
  777. else
  778. mpc52xx_fec_get_paddr(ndev, ndev->dev_addr);
  779. priv->msg_enable = netif_msg_init(debug, MPC52xx_MESSAGES_DEFAULT);
  780. /*
  781. * Link mode configuration
  782. */
  783. /* Start with safe defaults for link connection */
  784. priv->phy_addr = FEC5200_PHYADDR_NONE;
  785. priv->speed = 100;
  786. priv->duplex = DUPLEX_HALF;
  787. priv->phy_speed = ((mpc52xx_find_ipb_freq(op->node) >> 20) / 5) << 1;
  788. /* the 7-wire property means don't use MII mode */
  789. if (of_find_property(op->node, "fsl,7-wire-mode", NULL))
  790. priv->phy_addr = FEC5200_PHYADDR_7WIRE;
  791. /* The current speed preconfigures the speed of the MII link */
  792. prop = of_get_property(op->node, "current-speed", &prop_size);
  793. if (prop && (prop_size >= sizeof(u32) * 2)) {
  794. priv->speed = prop[0];
  795. priv->duplex = prop[1] ? DUPLEX_FULL : DUPLEX_HALF;
  796. }
  797. /* If there is a phy handle, setup link to that phy */
  798. phy_handle = of_get_property(op->node, "phy-handle", &prop_size);
  799. if (phy_handle && (prop_size >= sizeof(phandle))) {
  800. phy_node = of_find_node_by_phandle(*phy_handle);
  801. prop = of_get_property(phy_node, "reg", &prop_size);
  802. if (prop && (prop_size >= sizeof(u32)))
  803. if ((*prop >= 0) && (*prop < PHY_MAX_ADDR))
  804. priv->phy_addr = *prop;
  805. of_node_put(phy_node);
  806. }
  807. /* Hardware init */
  808. mpc52xx_fec_hw_init(ndev);
  809. mpc52xx_fec_reset_stats(ndev);
  810. SET_NETDEV_DEV(ndev, &op->dev);
  811. /* Register the new network device */
  812. rv = register_netdev(ndev);
  813. if (rv < 0)
  814. goto probe_error;
  815. /* Now report the link setup */
  816. switch (priv->phy_addr) {
  817. case FEC5200_PHYADDR_NONE:
  818. dev_info(&ndev->dev, "Fixed speed MII link: %i%cD\n",
  819. priv->speed, priv->duplex ? 'F' : 'H');
  820. break;
  821. case FEC5200_PHYADDR_7WIRE:
  822. dev_info(&ndev->dev, "using 7-wire PHY mode\n");
  823. break;
  824. default:
  825. dev_info(&ndev->dev, "Using PHY at MDIO address %i\n",
  826. priv->phy_addr);
  827. }
  828. /* We're done ! */
  829. dev_set_drvdata(&op->dev, ndev);
  830. return 0;
  831. /* Error handling - free everything that might be allocated */
  832. probe_error:
  833. irq_dispose_mapping(ndev->irq);
  834. if (priv->rx_dmatsk)
  835. bcom_fec_rx_release(priv->rx_dmatsk);
  836. if (priv->tx_dmatsk)
  837. bcom_fec_tx_release(priv->tx_dmatsk);
  838. if (priv->fec)
  839. iounmap(priv->fec);
  840. release_mem_region(mem.start, sizeof(struct mpc52xx_fec));
  841. free_netdev(ndev);
  842. return rv;
  843. }
  844. static int
  845. mpc52xx_fec_remove(struct of_device *op)
  846. {
  847. struct net_device *ndev;
  848. struct mpc52xx_fec_priv *priv;
  849. ndev = dev_get_drvdata(&op->dev);
  850. priv = netdev_priv(ndev);
  851. unregister_netdev(ndev);
  852. irq_dispose_mapping(ndev->irq);
  853. bcom_fec_rx_release(priv->rx_dmatsk);
  854. bcom_fec_tx_release(priv->tx_dmatsk);
  855. iounmap(priv->fec);
  856. release_mem_region(ndev->base_addr, sizeof(struct mpc52xx_fec));
  857. free_netdev(ndev);
  858. dev_set_drvdata(&op->dev, NULL);
  859. return 0;
  860. }
  861. #ifdef CONFIG_PM
  862. static int mpc52xx_fec_of_suspend(struct of_device *op, pm_message_t state)
  863. {
  864. struct net_device *dev = dev_get_drvdata(&op->dev);
  865. if (netif_running(dev))
  866. mpc52xx_fec_close(dev);
  867. return 0;
  868. }
  869. static int mpc52xx_fec_of_resume(struct of_device *op)
  870. {
  871. struct net_device *dev = dev_get_drvdata(&op->dev);
  872. mpc52xx_fec_hw_init(dev);
  873. mpc52xx_fec_reset_stats(dev);
  874. if (netif_running(dev))
  875. mpc52xx_fec_open(dev);
  876. return 0;
  877. }
  878. #endif
  879. static struct of_device_id mpc52xx_fec_match[] = {
  880. { .type = "network", .compatible = "fsl,mpc5200b-fec", },
  881. { .type = "network", .compatible = "fsl,mpc5200-fec", },
  882. { .type = "network", .compatible = "mpc5200-fec", },
  883. { }
  884. };
  885. MODULE_DEVICE_TABLE(of, mpc52xx_fec_match);
  886. static struct of_platform_driver mpc52xx_fec_driver = {
  887. .owner = THIS_MODULE,
  888. .name = DRIVER_NAME,
  889. .match_table = mpc52xx_fec_match,
  890. .probe = mpc52xx_fec_probe,
  891. .remove = mpc52xx_fec_remove,
  892. #ifdef CONFIG_PM
  893. .suspend = mpc52xx_fec_of_suspend,
  894. .resume = mpc52xx_fec_of_resume,
  895. #endif
  896. };
  897. /* ======================================================================== */
  898. /* Module */
  899. /* ======================================================================== */
  900. static int __init
  901. mpc52xx_fec_init(void)
  902. {
  903. #ifdef CONFIG_FEC_MPC52xx_MDIO
  904. int ret;
  905. ret = of_register_platform_driver(&mpc52xx_fec_mdio_driver);
  906. if (ret) {
  907. printk(KERN_ERR DRIVER_NAME ": failed to register mdio driver\n");
  908. return ret;
  909. }
  910. #endif
  911. return of_register_platform_driver(&mpc52xx_fec_driver);
  912. }
  913. static void __exit
  914. mpc52xx_fec_exit(void)
  915. {
  916. of_unregister_platform_driver(&mpc52xx_fec_driver);
  917. #ifdef CONFIG_FEC_MPC52xx_MDIO
  918. of_unregister_platform_driver(&mpc52xx_fec_mdio_driver);
  919. #endif
  920. }
  921. module_init(mpc52xx_fec_init);
  922. module_exit(mpc52xx_fec_exit);
  923. MODULE_LICENSE("GPL");
  924. MODULE_AUTHOR("Dale Farnsworth");
  925. MODULE_DESCRIPTION("Ethernet driver for the Freescale MPC52xx FEC");