moxart_ether.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /* MOXA ART Ethernet (RTL8201CP) driver.
  2. *
  3. * Copyright (C) 2013 Jonas Jensen
  4. *
  5. * Jonas Jensen <jonas.jensen@gmail.com>
  6. *
  7. * Based on code from
  8. * Moxa Technology Co., Ltd. <www.moxa.com>
  9. *
  10. * This file is licensed under the terms of the GNU General Public
  11. * License version 2. This program is licensed "as is" without any
  12. * warranty of any kind, whether express or implied.
  13. */
  14. #include <linux/module.h>
  15. #include <linux/netdevice.h>
  16. #include <linux/etherdevice.h>
  17. #include <linux/skbuff.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/ethtool.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/irq.h>
  23. #include <linux/of_address.h>
  24. #include <linux/of_irq.h>
  25. #include <linux/crc32.h>
  26. #include <linux/crc32c.h>
  27. #include <linux/circ_buf.h>
  28. #include "moxart_ether.h"
  29. static inline void moxart_desc_write(u32 data, u32 *desc)
  30. {
  31. *desc = cpu_to_le32(data);
  32. }
  33. static inline u32 moxart_desc_read(u32 *desc)
  34. {
  35. return le32_to_cpu(*desc);
  36. }
  37. static inline void moxart_emac_write(struct net_device *ndev,
  38. unsigned int reg, unsigned long value)
  39. {
  40. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  41. writel(value, priv->base + reg);
  42. }
  43. static void moxart_update_mac_address(struct net_device *ndev)
  44. {
  45. moxart_emac_write(ndev, REG_MAC_MS_ADDRESS,
  46. ((ndev->dev_addr[0] << 8) | (ndev->dev_addr[1])));
  47. moxart_emac_write(ndev, REG_MAC_MS_ADDRESS + 4,
  48. ((ndev->dev_addr[2] << 24) |
  49. (ndev->dev_addr[3] << 16) |
  50. (ndev->dev_addr[4] << 8) |
  51. (ndev->dev_addr[5])));
  52. }
  53. static int moxart_set_mac_address(struct net_device *ndev, void *addr)
  54. {
  55. struct sockaddr *address = addr;
  56. if (!is_valid_ether_addr(address->sa_data))
  57. return -EADDRNOTAVAIL;
  58. memcpy(ndev->dev_addr, address->sa_data, ndev->addr_len);
  59. moxart_update_mac_address(ndev);
  60. return 0;
  61. }
  62. static void moxart_mac_free_memory(struct net_device *ndev)
  63. {
  64. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  65. int i;
  66. for (i = 0; i < RX_DESC_NUM; i++)
  67. dma_unmap_single(&ndev->dev, priv->rx_mapping[i],
  68. priv->rx_buf_size, DMA_FROM_DEVICE);
  69. if (priv->tx_desc_base)
  70. dma_free_coherent(NULL, TX_REG_DESC_SIZE * TX_DESC_NUM,
  71. priv->tx_desc_base, priv->tx_base);
  72. if (priv->rx_desc_base)
  73. dma_free_coherent(NULL, RX_REG_DESC_SIZE * RX_DESC_NUM,
  74. priv->rx_desc_base, priv->rx_base);
  75. kfree(priv->tx_buf_base);
  76. kfree(priv->rx_buf_base);
  77. }
  78. static void moxart_mac_reset(struct net_device *ndev)
  79. {
  80. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  81. writel(SW_RST, priv->base + REG_MAC_CTRL);
  82. while (readl(priv->base + REG_MAC_CTRL) & SW_RST)
  83. mdelay(10);
  84. writel(0, priv->base + REG_INTERRUPT_MASK);
  85. priv->reg_maccr = RX_BROADPKT | FULLDUP | CRC_APD | RX_FTL;
  86. }
  87. static void moxart_mac_enable(struct net_device *ndev)
  88. {
  89. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  90. writel(0x00001010, priv->base + REG_INT_TIMER_CTRL);
  91. writel(0x00000001, priv->base + REG_APOLL_TIMER_CTRL);
  92. writel(0x00000390, priv->base + REG_DMA_BLEN_CTRL);
  93. priv->reg_imr |= (RPKT_FINISH_M | XPKT_FINISH_M);
  94. writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
  95. priv->reg_maccr |= (RCV_EN | XMT_EN | RDMA_EN | XDMA_EN);
  96. writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
  97. }
  98. static void moxart_mac_setup_desc_ring(struct net_device *ndev)
  99. {
  100. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  101. void *desc;
  102. int i;
  103. for (i = 0; i < TX_DESC_NUM; i++) {
  104. desc = priv->tx_desc_base + i * TX_REG_DESC_SIZE;
  105. memset(desc, 0, TX_REG_DESC_SIZE);
  106. priv->tx_buf[i] = priv->tx_buf_base + priv->tx_buf_size * i;
  107. }
  108. moxart_desc_write(TX_DESC1_END, desc + TX_REG_OFFSET_DESC1);
  109. priv->tx_head = 0;
  110. priv->tx_tail = 0;
  111. for (i = 0; i < RX_DESC_NUM; i++) {
  112. desc = priv->rx_desc_base + i * RX_REG_DESC_SIZE;
  113. memset(desc, 0, RX_REG_DESC_SIZE);
  114. moxart_desc_write(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0);
  115. moxart_desc_write(RX_BUF_SIZE & RX_DESC1_BUF_SIZE_MASK,
  116. desc + RX_REG_OFFSET_DESC1);
  117. priv->rx_buf[i] = priv->rx_buf_base + priv->rx_buf_size * i;
  118. priv->rx_mapping[i] = dma_map_single(&ndev->dev,
  119. priv->rx_buf[i],
  120. priv->rx_buf_size,
  121. DMA_FROM_DEVICE);
  122. if (dma_mapping_error(&ndev->dev, priv->rx_mapping[i]))
  123. netdev_err(ndev, "DMA mapping error\n");
  124. moxart_desc_write(priv->rx_mapping[i],
  125. desc + RX_REG_OFFSET_DESC2 + RX_DESC2_ADDRESS_PHYS);
  126. moxart_desc_write((uintptr_t)priv->rx_buf[i],
  127. desc + RX_REG_OFFSET_DESC2 + RX_DESC2_ADDRESS_VIRT);
  128. }
  129. moxart_desc_write(RX_DESC1_END, desc + RX_REG_OFFSET_DESC1);
  130. priv->rx_head = 0;
  131. /* reset the MAC controller TX/RX desciptor base address */
  132. writel(priv->tx_base, priv->base + REG_TXR_BASE_ADDRESS);
  133. writel(priv->rx_base, priv->base + REG_RXR_BASE_ADDRESS);
  134. }
  135. static int moxart_mac_open(struct net_device *ndev)
  136. {
  137. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  138. if (!is_valid_ether_addr(ndev->dev_addr))
  139. return -EADDRNOTAVAIL;
  140. napi_enable(&priv->napi);
  141. moxart_mac_reset(ndev);
  142. moxart_update_mac_address(ndev);
  143. moxart_mac_setup_desc_ring(ndev);
  144. moxart_mac_enable(ndev);
  145. netif_start_queue(ndev);
  146. netdev_dbg(ndev, "%s: IMR=0x%x, MACCR=0x%x\n",
  147. __func__, readl(priv->base + REG_INTERRUPT_MASK),
  148. readl(priv->base + REG_MAC_CTRL));
  149. return 0;
  150. }
  151. static int moxart_mac_stop(struct net_device *ndev)
  152. {
  153. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  154. napi_disable(&priv->napi);
  155. netif_stop_queue(ndev);
  156. /* disable all interrupts */
  157. writel(0, priv->base + REG_INTERRUPT_MASK);
  158. /* disable all functions */
  159. writel(0, priv->base + REG_MAC_CTRL);
  160. return 0;
  161. }
  162. static int moxart_rx_poll(struct napi_struct *napi, int budget)
  163. {
  164. struct moxart_mac_priv_t *priv = container_of(napi,
  165. struct moxart_mac_priv_t,
  166. napi);
  167. struct net_device *ndev = priv->ndev;
  168. struct sk_buff *skb;
  169. void *desc;
  170. unsigned int desc0, len;
  171. int rx_head = priv->rx_head;
  172. int rx = 0;
  173. while (rx < budget) {
  174. desc = priv->rx_desc_base + (RX_REG_DESC_SIZE * rx_head);
  175. desc0 = moxart_desc_read(desc + RX_REG_OFFSET_DESC0);
  176. rmb(); /* ensure desc0 is up to date */
  177. if (desc0 & RX_DESC0_DMA_OWN)
  178. break;
  179. if (desc0 & (RX_DESC0_ERR | RX_DESC0_CRC_ERR | RX_DESC0_FTL |
  180. RX_DESC0_RUNT | RX_DESC0_ODD_NB)) {
  181. net_dbg_ratelimited("packet error\n");
  182. priv->stats.rx_dropped++;
  183. priv->stats.rx_errors++;
  184. goto rx_next;
  185. }
  186. len = desc0 & RX_DESC0_FRAME_LEN_MASK;
  187. if (len > RX_BUF_SIZE)
  188. len = RX_BUF_SIZE;
  189. dma_sync_single_for_cpu(&ndev->dev,
  190. priv->rx_mapping[rx_head],
  191. priv->rx_buf_size, DMA_FROM_DEVICE);
  192. skb = netdev_alloc_skb_ip_align(ndev, len);
  193. if (unlikely(!skb)) {
  194. net_dbg_ratelimited("netdev_alloc_skb_ip_align failed\n");
  195. priv->stats.rx_dropped++;
  196. priv->stats.rx_errors++;
  197. goto rx_next;
  198. }
  199. memcpy(skb->data, priv->rx_buf[rx_head], len);
  200. skb_put(skb, len);
  201. skb->protocol = eth_type_trans(skb, ndev);
  202. napi_gro_receive(&priv->napi, skb);
  203. rx++;
  204. priv->stats.rx_packets++;
  205. priv->stats.rx_bytes += len;
  206. if (desc0 & RX_DESC0_MULTICAST)
  207. priv->stats.multicast++;
  208. rx_next:
  209. wmb(); /* prevent setting ownership back too early */
  210. moxart_desc_write(RX_DESC0_DMA_OWN, desc + RX_REG_OFFSET_DESC0);
  211. rx_head = RX_NEXT(rx_head);
  212. priv->rx_head = rx_head;
  213. }
  214. if (rx < budget) {
  215. napi_complete(napi);
  216. }
  217. priv->reg_imr |= RPKT_FINISH_M;
  218. writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
  219. return rx;
  220. }
  221. static int moxart_tx_queue_space(struct net_device *ndev)
  222. {
  223. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  224. return CIRC_SPACE(priv->tx_head, priv->tx_tail, TX_DESC_NUM);
  225. }
  226. static void moxart_tx_finished(struct net_device *ndev)
  227. {
  228. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  229. unsigned tx_head = priv->tx_head;
  230. unsigned tx_tail = priv->tx_tail;
  231. while (tx_tail != tx_head) {
  232. dma_unmap_single(&ndev->dev, priv->tx_mapping[tx_tail],
  233. priv->tx_len[tx_tail], DMA_TO_DEVICE);
  234. priv->stats.tx_packets++;
  235. priv->stats.tx_bytes += priv->tx_skb[tx_tail]->len;
  236. dev_kfree_skb_irq(priv->tx_skb[tx_tail]);
  237. priv->tx_skb[tx_tail] = NULL;
  238. tx_tail = TX_NEXT(tx_tail);
  239. }
  240. priv->tx_tail = tx_tail;
  241. if (netif_queue_stopped(ndev) &&
  242. moxart_tx_queue_space(ndev) >= TX_WAKE_THRESHOLD)
  243. netif_wake_queue(ndev);
  244. }
  245. static irqreturn_t moxart_mac_interrupt(int irq, void *dev_id)
  246. {
  247. struct net_device *ndev = (struct net_device *) dev_id;
  248. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  249. unsigned int ists = readl(priv->base + REG_INTERRUPT_STATUS);
  250. if (ists & XPKT_OK_INT_STS)
  251. moxart_tx_finished(ndev);
  252. if (ists & RPKT_FINISH) {
  253. if (napi_schedule_prep(&priv->napi)) {
  254. priv->reg_imr &= ~RPKT_FINISH_M;
  255. writel(priv->reg_imr, priv->base + REG_INTERRUPT_MASK);
  256. __napi_schedule(&priv->napi);
  257. }
  258. }
  259. return IRQ_HANDLED;
  260. }
  261. static int moxart_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
  262. {
  263. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  264. void *desc;
  265. unsigned int len;
  266. unsigned int tx_head;
  267. u32 txdes1;
  268. int ret = NETDEV_TX_BUSY;
  269. spin_lock_irq(&priv->txlock);
  270. tx_head = priv->tx_head;
  271. desc = priv->tx_desc_base + (TX_REG_DESC_SIZE * tx_head);
  272. if (moxart_tx_queue_space(ndev) == 1)
  273. netif_stop_queue(ndev);
  274. if (moxart_desc_read(desc + TX_REG_OFFSET_DESC0) & TX_DESC0_DMA_OWN) {
  275. net_dbg_ratelimited("no TX space for packet\n");
  276. priv->stats.tx_dropped++;
  277. goto out_unlock;
  278. }
  279. rmb(); /* ensure data is only read that had TX_DESC0_DMA_OWN cleared */
  280. len = skb->len > TX_BUF_SIZE ? TX_BUF_SIZE : skb->len;
  281. priv->tx_mapping[tx_head] = dma_map_single(&ndev->dev, skb->data,
  282. len, DMA_TO_DEVICE);
  283. if (dma_mapping_error(&ndev->dev, priv->tx_mapping[tx_head])) {
  284. netdev_err(ndev, "DMA mapping error\n");
  285. goto out_unlock;
  286. }
  287. priv->tx_len[tx_head] = len;
  288. priv->tx_skb[tx_head] = skb;
  289. moxart_desc_write(priv->tx_mapping[tx_head],
  290. desc + TX_REG_OFFSET_DESC2 + TX_DESC2_ADDRESS_PHYS);
  291. moxart_desc_write((uintptr_t)skb->data,
  292. desc + TX_REG_OFFSET_DESC2 + TX_DESC2_ADDRESS_VIRT);
  293. if (skb->len < ETH_ZLEN) {
  294. memset(&skb->data[skb->len],
  295. 0, ETH_ZLEN - skb->len);
  296. len = ETH_ZLEN;
  297. }
  298. dma_sync_single_for_device(&ndev->dev, priv->tx_mapping[tx_head],
  299. priv->tx_buf_size, DMA_TO_DEVICE);
  300. txdes1 = TX_DESC1_LTS | TX_DESC1_FTS | (len & TX_DESC1_BUF_SIZE_MASK);
  301. if (tx_head == TX_DESC_NUM_MASK)
  302. txdes1 |= TX_DESC1_END;
  303. moxart_desc_write(txdes1, desc + TX_REG_OFFSET_DESC1);
  304. wmb(); /* flush descriptor before transferring ownership */
  305. moxart_desc_write(TX_DESC0_DMA_OWN, desc + TX_REG_OFFSET_DESC0);
  306. /* start to send packet */
  307. writel(0xffffffff, priv->base + REG_TX_POLL_DEMAND);
  308. priv->tx_head = TX_NEXT(tx_head);
  309. netif_trans_update(ndev);
  310. ret = NETDEV_TX_OK;
  311. out_unlock:
  312. spin_unlock_irq(&priv->txlock);
  313. return ret;
  314. }
  315. static struct net_device_stats *moxart_mac_get_stats(struct net_device *ndev)
  316. {
  317. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  318. return &priv->stats;
  319. }
  320. static void moxart_mac_setmulticast(struct net_device *ndev)
  321. {
  322. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  323. struct netdev_hw_addr *ha;
  324. int crc_val;
  325. netdev_for_each_mc_addr(ha, ndev) {
  326. crc_val = crc32_le(~0, ha->addr, ETH_ALEN);
  327. crc_val = (crc_val >> 26) & 0x3f;
  328. if (crc_val >= 32) {
  329. writel(readl(priv->base + REG_MCAST_HASH_TABLE1) |
  330. (1UL << (crc_val - 32)),
  331. priv->base + REG_MCAST_HASH_TABLE1);
  332. } else {
  333. writel(readl(priv->base + REG_MCAST_HASH_TABLE0) |
  334. (1UL << crc_val),
  335. priv->base + REG_MCAST_HASH_TABLE0);
  336. }
  337. }
  338. }
  339. static void moxart_mac_set_rx_mode(struct net_device *ndev)
  340. {
  341. struct moxart_mac_priv_t *priv = netdev_priv(ndev);
  342. spin_lock_irq(&priv->txlock);
  343. (ndev->flags & IFF_PROMISC) ? (priv->reg_maccr |= RCV_ALL) :
  344. (priv->reg_maccr &= ~RCV_ALL);
  345. (ndev->flags & IFF_ALLMULTI) ? (priv->reg_maccr |= RX_MULTIPKT) :
  346. (priv->reg_maccr &= ~RX_MULTIPKT);
  347. if ((ndev->flags & IFF_MULTICAST) && netdev_mc_count(ndev)) {
  348. priv->reg_maccr |= HT_MULTI_EN;
  349. moxart_mac_setmulticast(ndev);
  350. } else {
  351. priv->reg_maccr &= ~HT_MULTI_EN;
  352. }
  353. writel(priv->reg_maccr, priv->base + REG_MAC_CTRL);
  354. spin_unlock_irq(&priv->txlock);
  355. }
  356. static struct net_device_ops moxart_netdev_ops = {
  357. .ndo_open = moxart_mac_open,
  358. .ndo_stop = moxart_mac_stop,
  359. .ndo_start_xmit = moxart_mac_start_xmit,
  360. .ndo_get_stats = moxart_mac_get_stats,
  361. .ndo_set_rx_mode = moxart_mac_set_rx_mode,
  362. .ndo_set_mac_address = moxart_set_mac_address,
  363. .ndo_validate_addr = eth_validate_addr,
  364. .ndo_change_mtu = eth_change_mtu,
  365. };
  366. static int moxart_mac_probe(struct platform_device *pdev)
  367. {
  368. struct device *p_dev = &pdev->dev;
  369. struct device_node *node = p_dev->of_node;
  370. struct net_device *ndev;
  371. struct moxart_mac_priv_t *priv;
  372. struct resource *res;
  373. unsigned int irq;
  374. int ret;
  375. ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t));
  376. if (!ndev)
  377. return -ENOMEM;
  378. irq = irq_of_parse_and_map(node, 0);
  379. if (irq <= 0) {
  380. netdev_err(ndev, "irq_of_parse_and_map failed\n");
  381. ret = -EINVAL;
  382. goto irq_map_fail;
  383. }
  384. priv = netdev_priv(ndev);
  385. priv->ndev = ndev;
  386. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  387. ndev->base_addr = res->start;
  388. priv->base = devm_ioremap_resource(p_dev, res);
  389. if (IS_ERR(priv->base)) {
  390. dev_err(p_dev, "devm_ioremap_resource failed\n");
  391. ret = PTR_ERR(priv->base);
  392. goto init_fail;
  393. }
  394. spin_lock_init(&priv->txlock);
  395. priv->tx_buf_size = TX_BUF_SIZE;
  396. priv->rx_buf_size = RX_BUF_SIZE;
  397. priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE *
  398. TX_DESC_NUM, &priv->tx_base,
  399. GFP_DMA | GFP_KERNEL);
  400. if (priv->tx_desc_base == NULL) {
  401. ret = -ENOMEM;
  402. goto init_fail;
  403. }
  404. priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE *
  405. RX_DESC_NUM, &priv->rx_base,
  406. GFP_DMA | GFP_KERNEL);
  407. if (priv->rx_desc_base == NULL) {
  408. ret = -ENOMEM;
  409. goto init_fail;
  410. }
  411. priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM,
  412. GFP_ATOMIC);
  413. if (!priv->tx_buf_base) {
  414. ret = -ENOMEM;
  415. goto init_fail;
  416. }
  417. priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM,
  418. GFP_ATOMIC);
  419. if (!priv->rx_buf_base) {
  420. ret = -ENOMEM;
  421. goto init_fail;
  422. }
  423. platform_set_drvdata(pdev, ndev);
  424. ret = devm_request_irq(p_dev, irq, moxart_mac_interrupt, 0,
  425. pdev->name, ndev);
  426. if (ret) {
  427. netdev_err(ndev, "devm_request_irq failed\n");
  428. goto init_fail;
  429. }
  430. ndev->netdev_ops = &moxart_netdev_ops;
  431. netif_napi_add(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM);
  432. ndev->priv_flags |= IFF_UNICAST_FLT;
  433. ndev->irq = irq;
  434. SET_NETDEV_DEV(ndev, &pdev->dev);
  435. ret = register_netdev(ndev);
  436. if (ret) {
  437. free_netdev(ndev);
  438. goto init_fail;
  439. }
  440. netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n",
  441. __func__, ndev->irq, ndev->dev_addr);
  442. return 0;
  443. init_fail:
  444. netdev_err(ndev, "init failed\n");
  445. moxart_mac_free_memory(ndev);
  446. irq_map_fail:
  447. free_netdev(ndev);
  448. return ret;
  449. }
  450. static int moxart_remove(struct platform_device *pdev)
  451. {
  452. struct net_device *ndev = platform_get_drvdata(pdev);
  453. unregister_netdev(ndev);
  454. free_irq(ndev->irq, ndev);
  455. moxart_mac_free_memory(ndev);
  456. free_netdev(ndev);
  457. return 0;
  458. }
  459. static const struct of_device_id moxart_mac_match[] = {
  460. { .compatible = "moxa,moxart-mac" },
  461. { }
  462. };
  463. MODULE_DEVICE_TABLE(of, moxart_mac_match);
  464. static struct platform_driver moxart_mac_driver = {
  465. .probe = moxart_mac_probe,
  466. .remove = moxart_remove,
  467. .driver = {
  468. .name = "moxart-ethernet",
  469. .of_match_table = moxart_mac_match,
  470. },
  471. };
  472. module_platform_driver(moxart_mac_driver);
  473. MODULE_DESCRIPTION("MOXART RTL8201CP Ethernet driver");
  474. MODULE_LICENSE("GPL v2");
  475. MODULE_AUTHOR("Jonas Jensen <jonas.jensen@gmail.com>");