ibm_emac_mal.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. /*
  2. * drivers/net/ibm_emac/ibm_emac_mal.c
  3. *
  4. * Memory Access Layer (MAL) support
  5. *
  6. * Copyright (c) 2004, 2005 Zultys Technologies.
  7. * Eugene Surovegin <eugene.surovegin@zultys.com> or <ebs@ebshome.net>
  8. *
  9. * Based on original work by
  10. * Benjamin Herrenschmidt <benh@kernel.crashing.org>,
  11. * David Gibson <hermes@gibson.dropbear.id.au>,
  12. *
  13. * Armin Kuster <akuster@mvista.com>
  14. * Copyright 2002 MontaVista Softare Inc.
  15. *
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU General Public License as published by the
  18. * Free Software Foundation; either version 2 of the License, or (at your
  19. * option) any later version.
  20. *
  21. */
  22. #include <linux/config.h>
  23. #include <linux/module.h>
  24. #include <linux/kernel.h>
  25. #include <linux/errno.h>
  26. #include <linux/netdevice.h>
  27. #include <linux/init.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/dma-mapping.h>
  30. #include <asm/ocp.h>
  31. #include "ibm_emac_core.h"
  32. #include "ibm_emac_mal.h"
  33. #include "ibm_emac_debug.h"
  34. int __init mal_register_commac(struct ibm_ocp_mal *mal,
  35. struct mal_commac *commac)
  36. {
  37. unsigned long flags;
  38. local_irq_save(flags);
  39. MAL_DBG("%d: reg(%08x, %08x)" NL, mal->def->index,
  40. commac->tx_chan_mask, commac->rx_chan_mask);
  41. /* Don't let multiple commacs claim the same channel(s) */
  42. if ((mal->tx_chan_mask & commac->tx_chan_mask) ||
  43. (mal->rx_chan_mask & commac->rx_chan_mask)) {
  44. local_irq_restore(flags);
  45. printk(KERN_WARNING "mal%d: COMMAC channels conflict!\n",
  46. mal->def->index);
  47. return -EBUSY;
  48. }
  49. mal->tx_chan_mask |= commac->tx_chan_mask;
  50. mal->rx_chan_mask |= commac->rx_chan_mask;
  51. list_add(&commac->list, &mal->list);
  52. local_irq_restore(flags);
  53. return 0;
  54. }
  55. void __exit mal_unregister_commac(struct ibm_ocp_mal *mal,
  56. struct mal_commac *commac)
  57. {
  58. unsigned long flags;
  59. local_irq_save(flags);
  60. MAL_DBG("%d: unreg(%08x, %08x)" NL, mal->def->index,
  61. commac->tx_chan_mask, commac->rx_chan_mask);
  62. mal->tx_chan_mask &= ~commac->tx_chan_mask;
  63. mal->rx_chan_mask &= ~commac->rx_chan_mask;
  64. list_del_init(&commac->list);
  65. local_irq_restore(flags);
  66. }
  67. int mal_set_rcbs(struct ibm_ocp_mal *mal, int channel, unsigned long size)
  68. {
  69. struct ocp_func_mal_data *maldata = mal->def->additions;
  70. BUG_ON(channel < 0 || channel >= maldata->num_rx_chans ||
  71. size > MAL_MAX_RX_SIZE);
  72. MAL_DBG("%d: set_rbcs(%d, %lu)" NL, mal->def->index, channel, size);
  73. if (size & 0xf) {
  74. printk(KERN_WARNING
  75. "mal%d: incorrect RX size %lu for the channel %d\n",
  76. mal->def->index, size, channel);
  77. return -EINVAL;
  78. }
  79. set_mal_dcrn(mal, MAL_RCBS(channel), size >> 4);
  80. return 0;
  81. }
  82. int mal_tx_bd_offset(struct ibm_ocp_mal *mal, int channel)
  83. {
  84. struct ocp_func_mal_data *maldata = mal->def->additions;
  85. BUG_ON(channel < 0 || channel >= maldata->num_tx_chans);
  86. return channel * NUM_TX_BUFF;
  87. }
  88. int mal_rx_bd_offset(struct ibm_ocp_mal *mal, int channel)
  89. {
  90. struct ocp_func_mal_data *maldata = mal->def->additions;
  91. BUG_ON(channel < 0 || channel >= maldata->num_rx_chans);
  92. return maldata->num_tx_chans * NUM_TX_BUFF + channel * NUM_RX_BUFF;
  93. }
  94. void mal_enable_tx_channel(struct ibm_ocp_mal *mal, int channel)
  95. {
  96. local_bh_disable();
  97. MAL_DBG("%d: enable_tx(%d)" NL, mal->def->index, channel);
  98. set_mal_dcrn(mal, MAL_TXCASR,
  99. get_mal_dcrn(mal, MAL_TXCASR) | MAL_CHAN_MASK(channel));
  100. local_bh_enable();
  101. }
  102. void mal_disable_tx_channel(struct ibm_ocp_mal *mal, int channel)
  103. {
  104. set_mal_dcrn(mal, MAL_TXCARR, MAL_CHAN_MASK(channel));
  105. MAL_DBG("%d: disable_tx(%d)" NL, mal->def->index, channel);
  106. }
  107. void mal_enable_rx_channel(struct ibm_ocp_mal *mal, int channel)
  108. {
  109. local_bh_disable();
  110. MAL_DBG("%d: enable_rx(%d)" NL, mal->def->index, channel);
  111. set_mal_dcrn(mal, MAL_RXCASR,
  112. get_mal_dcrn(mal, MAL_RXCASR) | MAL_CHAN_MASK(channel));
  113. local_bh_enable();
  114. }
  115. void mal_disable_rx_channel(struct ibm_ocp_mal *mal, int channel)
  116. {
  117. set_mal_dcrn(mal, MAL_RXCARR, MAL_CHAN_MASK(channel));
  118. MAL_DBG("%d: disable_rx(%d)" NL, mal->def->index, channel);
  119. }
  120. void mal_poll_add(struct ibm_ocp_mal *mal, struct mal_commac *commac)
  121. {
  122. local_bh_disable();
  123. MAL_DBG("%d: poll_add(%p)" NL, mal->def->index, commac);
  124. list_add_tail(&commac->poll_list, &mal->poll_list);
  125. local_bh_enable();
  126. }
  127. void mal_poll_del(struct ibm_ocp_mal *mal, struct mal_commac *commac)
  128. {
  129. local_bh_disable();
  130. MAL_DBG("%d: poll_del(%p)" NL, mal->def->index, commac);
  131. list_del(&commac->poll_list);
  132. local_bh_enable();
  133. }
  134. /* synchronized by mal_poll() */
  135. static inline void mal_enable_eob_irq(struct ibm_ocp_mal *mal)
  136. {
  137. MAL_DBG2("%d: enable_irq" NL, mal->def->index);
  138. set_mal_dcrn(mal, MAL_CFG, get_mal_dcrn(mal, MAL_CFG) | MAL_CFG_EOPIE);
  139. }
  140. /* synchronized by __LINK_STATE_RX_SCHED bit in ndev->state */
  141. static inline void mal_disable_eob_irq(struct ibm_ocp_mal *mal)
  142. {
  143. set_mal_dcrn(mal, MAL_CFG, get_mal_dcrn(mal, MAL_CFG) & ~MAL_CFG_EOPIE);
  144. MAL_DBG2("%d: disable_irq" NL, mal->def->index);
  145. }
  146. static irqreturn_t mal_serr(int irq, void *dev_instance, struct pt_regs *regs)
  147. {
  148. struct ibm_ocp_mal *mal = dev_instance;
  149. u32 esr = get_mal_dcrn(mal, MAL_ESR);
  150. /* Clear the error status register */
  151. set_mal_dcrn(mal, MAL_ESR, esr);
  152. MAL_DBG("%d: SERR %08x" NL, mal->def->index, esr);
  153. if (esr & MAL_ESR_EVB) {
  154. if (esr & MAL_ESR_DE) {
  155. /* We ignore Descriptor error,
  156. * TXDE or RXDE interrupt will be generated anyway.
  157. */
  158. return IRQ_HANDLED;
  159. }
  160. if (esr & MAL_ESR_PEIN) {
  161. /* PLB error, it's probably buggy hardware or
  162. * incorrect physical address in BD (i.e. bug)
  163. */
  164. if (net_ratelimit())
  165. printk(KERN_ERR
  166. "mal%d: system error, PLB (ESR = 0x%08x)\n",
  167. mal->def->index, esr);
  168. return IRQ_HANDLED;
  169. }
  170. /* OPB error, it's probably buggy hardware or incorrect EBC setup */
  171. if (net_ratelimit())
  172. printk(KERN_ERR
  173. "mal%d: system error, OPB (ESR = 0x%08x)\n",
  174. mal->def->index, esr);
  175. }
  176. return IRQ_HANDLED;
  177. }
  178. static inline void mal_schedule_poll(struct ibm_ocp_mal *mal)
  179. {
  180. if (likely(netif_rx_schedule_prep(&mal->poll_dev))) {
  181. MAL_DBG2("%d: schedule_poll" NL, mal->def->index);
  182. mal_disable_eob_irq(mal);
  183. __netif_rx_schedule(&mal->poll_dev);
  184. } else
  185. MAL_DBG2("%d: already in poll" NL, mal->def->index);
  186. }
  187. static irqreturn_t mal_txeob(int irq, void *dev_instance, struct pt_regs *regs)
  188. {
  189. struct ibm_ocp_mal *mal = dev_instance;
  190. u32 r = get_mal_dcrn(mal, MAL_TXEOBISR);
  191. MAL_DBG2("%d: txeob %08x" NL, mal->def->index, r);
  192. mal_schedule_poll(mal);
  193. set_mal_dcrn(mal, MAL_TXEOBISR, r);
  194. return IRQ_HANDLED;
  195. }
  196. static irqreturn_t mal_rxeob(int irq, void *dev_instance, struct pt_regs *regs)
  197. {
  198. struct ibm_ocp_mal *mal = dev_instance;
  199. u32 r = get_mal_dcrn(mal, MAL_RXEOBISR);
  200. MAL_DBG2("%d: rxeob %08x" NL, mal->def->index, r);
  201. mal_schedule_poll(mal);
  202. set_mal_dcrn(mal, MAL_RXEOBISR, r);
  203. return IRQ_HANDLED;
  204. }
  205. static irqreturn_t mal_txde(int irq, void *dev_instance, struct pt_regs *regs)
  206. {
  207. struct ibm_ocp_mal *mal = dev_instance;
  208. u32 deir = get_mal_dcrn(mal, MAL_TXDEIR);
  209. set_mal_dcrn(mal, MAL_TXDEIR, deir);
  210. MAL_DBG("%d: txde %08x" NL, mal->def->index, deir);
  211. if (net_ratelimit())
  212. printk(KERN_ERR
  213. "mal%d: TX descriptor error (TXDEIR = 0x%08x)\n",
  214. mal->def->index, deir);
  215. return IRQ_HANDLED;
  216. }
  217. static irqreturn_t mal_rxde(int irq, void *dev_instance, struct pt_regs *regs)
  218. {
  219. struct ibm_ocp_mal *mal = dev_instance;
  220. struct list_head *l;
  221. u32 deir = get_mal_dcrn(mal, MAL_RXDEIR);
  222. MAL_DBG("%d: rxde %08x" NL, mal->def->index, deir);
  223. list_for_each(l, &mal->list) {
  224. struct mal_commac *mc = list_entry(l, struct mal_commac, list);
  225. if (deir & mc->rx_chan_mask) {
  226. mc->rx_stopped = 1;
  227. mc->ops->rxde(mc->dev);
  228. }
  229. }
  230. mal_schedule_poll(mal);
  231. set_mal_dcrn(mal, MAL_RXDEIR, deir);
  232. return IRQ_HANDLED;
  233. }
  234. static int mal_poll(struct net_device *ndev, int *budget)
  235. {
  236. struct ibm_ocp_mal *mal = ndev->priv;
  237. struct list_head *l;
  238. int rx_work_limit = min(ndev->quota, *budget), received = 0, done;
  239. MAL_DBG2("%d: poll(%d) %d ->" NL, mal->def->index, *budget,
  240. rx_work_limit);
  241. again:
  242. /* Process TX skbs */
  243. list_for_each(l, &mal->poll_list) {
  244. struct mal_commac *mc =
  245. list_entry(l, struct mal_commac, poll_list);
  246. mc->ops->poll_tx(mc->dev);
  247. }
  248. /* Process RX skbs.
  249. * We _might_ need something more smart here to enforce polling fairness.
  250. */
  251. list_for_each(l, &mal->poll_list) {
  252. struct mal_commac *mc =
  253. list_entry(l, struct mal_commac, poll_list);
  254. int n = mc->ops->poll_rx(mc->dev, rx_work_limit);
  255. if (n) {
  256. received += n;
  257. rx_work_limit -= n;
  258. if (rx_work_limit <= 0) {
  259. done = 0;
  260. goto more_work; // XXX What if this is the last one ?
  261. }
  262. }
  263. }
  264. /* We need to disable IRQs to protect from RXDE IRQ here */
  265. local_irq_disable();
  266. __netif_rx_complete(ndev);
  267. mal_enable_eob_irq(mal);
  268. local_irq_enable();
  269. done = 1;
  270. /* Check for "rotting" packet(s) */
  271. list_for_each(l, &mal->poll_list) {
  272. struct mal_commac *mc =
  273. list_entry(l, struct mal_commac, poll_list);
  274. if (unlikely(mc->ops->peek_rx(mc->dev) || mc->rx_stopped)) {
  275. MAL_DBG2("%d: rotting packet" NL, mal->def->index);
  276. if (netif_rx_reschedule(ndev, received))
  277. mal_disable_eob_irq(mal);
  278. else
  279. MAL_DBG2("%d: already in poll list" NL,
  280. mal->def->index);
  281. if (rx_work_limit > 0)
  282. goto again;
  283. else
  284. goto more_work;
  285. }
  286. mc->ops->poll_tx(mc->dev);
  287. }
  288. more_work:
  289. ndev->quota -= received;
  290. *budget -= received;
  291. MAL_DBG2("%d: poll() %d <- %d" NL, mal->def->index, *budget,
  292. done ? 0 : 1);
  293. return done ? 0 : 1;
  294. }
  295. static void mal_reset(struct ibm_ocp_mal *mal)
  296. {
  297. int n = 10;
  298. MAL_DBG("%d: reset" NL, mal->def->index);
  299. set_mal_dcrn(mal, MAL_CFG, MAL_CFG_SR);
  300. /* Wait for reset to complete (1 system clock) */
  301. while ((get_mal_dcrn(mal, MAL_CFG) & MAL_CFG_SR) && n)
  302. --n;
  303. if (unlikely(!n))
  304. printk(KERN_ERR "mal%d: reset timeout\n", mal->def->index);
  305. }
  306. int mal_get_regs_len(struct ibm_ocp_mal *mal)
  307. {
  308. return sizeof(struct emac_ethtool_regs_subhdr) +
  309. sizeof(struct ibm_mal_regs);
  310. }
  311. void *mal_dump_regs(struct ibm_ocp_mal *mal, void *buf)
  312. {
  313. struct emac_ethtool_regs_subhdr *hdr = buf;
  314. struct ibm_mal_regs *regs = (struct ibm_mal_regs *)(hdr + 1);
  315. struct ocp_func_mal_data *maldata = mal->def->additions;
  316. int i;
  317. hdr->version = MAL_VERSION;
  318. hdr->index = mal->def->index;
  319. regs->tx_count = maldata->num_tx_chans;
  320. regs->rx_count = maldata->num_rx_chans;
  321. regs->cfg = get_mal_dcrn(mal, MAL_CFG);
  322. regs->esr = get_mal_dcrn(mal, MAL_ESR);
  323. regs->ier = get_mal_dcrn(mal, MAL_IER);
  324. regs->tx_casr = get_mal_dcrn(mal, MAL_TXCASR);
  325. regs->tx_carr = get_mal_dcrn(mal, MAL_TXCARR);
  326. regs->tx_eobisr = get_mal_dcrn(mal, MAL_TXEOBISR);
  327. regs->tx_deir = get_mal_dcrn(mal, MAL_TXDEIR);
  328. regs->rx_casr = get_mal_dcrn(mal, MAL_RXCASR);
  329. regs->rx_carr = get_mal_dcrn(mal, MAL_RXCARR);
  330. regs->rx_eobisr = get_mal_dcrn(mal, MAL_RXEOBISR);
  331. regs->rx_deir = get_mal_dcrn(mal, MAL_RXDEIR);
  332. for (i = 0; i < regs->tx_count; ++i)
  333. regs->tx_ctpr[i] = get_mal_dcrn(mal, MAL_TXCTPR(i));
  334. for (i = 0; i < regs->rx_count; ++i) {
  335. regs->rx_ctpr[i] = get_mal_dcrn(mal, MAL_RXCTPR(i));
  336. regs->rcbs[i] = get_mal_dcrn(mal, MAL_RCBS(i));
  337. }
  338. return regs + 1;
  339. }
  340. static int __init mal_probe(struct ocp_device *ocpdev)
  341. {
  342. struct ibm_ocp_mal *mal;
  343. struct ocp_func_mal_data *maldata;
  344. int err = 0, i, bd_size;
  345. MAL_DBG("%d: probe" NL, ocpdev->def->index);
  346. maldata = ocpdev->def->additions;
  347. if (maldata == NULL) {
  348. printk(KERN_ERR "mal%d: missing additional data!\n",
  349. ocpdev->def->index);
  350. return -ENODEV;
  351. }
  352. mal = kzalloc(sizeof(struct ibm_ocp_mal), GFP_KERNEL);
  353. if (!mal) {
  354. printk(KERN_ERR
  355. "mal%d: out of memory allocating MAL structure!\n",
  356. ocpdev->def->index);
  357. return -ENOMEM;
  358. }
  359. mal->dcrbase = maldata->dcr_base;
  360. mal->def = ocpdev->def;
  361. INIT_LIST_HEAD(&mal->poll_list);
  362. set_bit(__LINK_STATE_START, &mal->poll_dev.state);
  363. mal->poll_dev.weight = CONFIG_IBM_EMAC_POLL_WEIGHT;
  364. mal->poll_dev.poll = mal_poll;
  365. mal->poll_dev.priv = mal;
  366. atomic_set(&mal->poll_dev.refcnt, 1);
  367. INIT_LIST_HEAD(&mal->list);
  368. /* Load power-on reset defaults */
  369. mal_reset(mal);
  370. /* Set the MAL configuration register */
  371. set_mal_dcrn(mal, MAL_CFG, MAL_CFG_DEFAULT | MAL_CFG_PLBB |
  372. MAL_CFG_OPBBL | MAL_CFG_LEA);
  373. mal_enable_eob_irq(mal);
  374. /* Allocate space for BD rings */
  375. BUG_ON(maldata->num_tx_chans <= 0 || maldata->num_tx_chans > 32);
  376. BUG_ON(maldata->num_rx_chans <= 0 || maldata->num_rx_chans > 32);
  377. bd_size = sizeof(struct mal_descriptor) *
  378. (NUM_TX_BUFF * maldata->num_tx_chans +
  379. NUM_RX_BUFF * maldata->num_rx_chans);
  380. mal->bd_virt =
  381. dma_alloc_coherent(&ocpdev->dev, bd_size, &mal->bd_dma, GFP_KERNEL);
  382. if (!mal->bd_virt) {
  383. printk(KERN_ERR
  384. "mal%d: out of memory allocating RX/TX descriptors!\n",
  385. mal->def->index);
  386. err = -ENOMEM;
  387. goto fail;
  388. }
  389. memset(mal->bd_virt, 0, bd_size);
  390. for (i = 0; i < maldata->num_tx_chans; ++i)
  391. set_mal_dcrn(mal, MAL_TXCTPR(i), mal->bd_dma +
  392. sizeof(struct mal_descriptor) *
  393. mal_tx_bd_offset(mal, i));
  394. for (i = 0; i < maldata->num_rx_chans; ++i)
  395. set_mal_dcrn(mal, MAL_RXCTPR(i), mal->bd_dma +
  396. sizeof(struct mal_descriptor) *
  397. mal_rx_bd_offset(mal, i));
  398. err = request_irq(maldata->serr_irq, mal_serr, 0, "MAL SERR", mal);
  399. if (err)
  400. goto fail2;
  401. err = request_irq(maldata->txde_irq, mal_txde, 0, "MAL TX DE", mal);
  402. if (err)
  403. goto fail3;
  404. err = request_irq(maldata->txeob_irq, mal_txeob, 0, "MAL TX EOB", mal);
  405. if (err)
  406. goto fail4;
  407. err = request_irq(maldata->rxde_irq, mal_rxde, 0, "MAL RX DE", mal);
  408. if (err)
  409. goto fail5;
  410. err = request_irq(maldata->rxeob_irq, mal_rxeob, 0, "MAL RX EOB", mal);
  411. if (err)
  412. goto fail6;
  413. /* Enable all MAL SERR interrupt sources */
  414. set_mal_dcrn(mal, MAL_IER, MAL_IER_EVENTS);
  415. /* Advertise this instance to the rest of the world */
  416. ocp_set_drvdata(ocpdev, mal);
  417. mal_dbg_register(mal->def->index, mal);
  418. printk(KERN_INFO "mal%d: initialized, %d TX channels, %d RX channels\n",
  419. mal->def->index, maldata->num_tx_chans, maldata->num_rx_chans);
  420. return 0;
  421. fail6:
  422. free_irq(maldata->rxde_irq, mal);
  423. fail5:
  424. free_irq(maldata->txeob_irq, mal);
  425. fail4:
  426. free_irq(maldata->txde_irq, mal);
  427. fail3:
  428. free_irq(maldata->serr_irq, mal);
  429. fail2:
  430. dma_free_coherent(&ocpdev->dev, bd_size, mal->bd_virt, mal->bd_dma);
  431. fail:
  432. kfree(mal);
  433. return err;
  434. }
  435. static void __exit mal_remove(struct ocp_device *ocpdev)
  436. {
  437. struct ibm_ocp_mal *mal = ocp_get_drvdata(ocpdev);
  438. struct ocp_func_mal_data *maldata = mal->def->additions;
  439. MAL_DBG("%d: remove" NL, mal->def->index);
  440. /* Syncronize with scheduled polling,
  441. stolen from net/core/dev.c:dev_close()
  442. */
  443. clear_bit(__LINK_STATE_START, &mal->poll_dev.state);
  444. netif_poll_disable(&mal->poll_dev);
  445. if (!list_empty(&mal->list)) {
  446. /* This is *very* bad */
  447. printk(KERN_EMERG
  448. "mal%d: commac list is not empty on remove!\n",
  449. mal->def->index);
  450. }
  451. ocp_set_drvdata(ocpdev, NULL);
  452. free_irq(maldata->serr_irq, mal);
  453. free_irq(maldata->txde_irq, mal);
  454. free_irq(maldata->txeob_irq, mal);
  455. free_irq(maldata->rxde_irq, mal);
  456. free_irq(maldata->rxeob_irq, mal);
  457. mal_reset(mal);
  458. mal_dbg_register(mal->def->index, NULL);
  459. dma_free_coherent(&ocpdev->dev,
  460. sizeof(struct mal_descriptor) *
  461. (NUM_TX_BUFF * maldata->num_tx_chans +
  462. NUM_RX_BUFF * maldata->num_rx_chans), mal->bd_virt,
  463. mal->bd_dma);
  464. kfree(mal);
  465. }
  466. /* Structure for a device driver */
  467. static struct ocp_device_id mal_ids[] = {
  468. { .vendor = OCP_VENDOR_IBM, .function = OCP_FUNC_MAL },
  469. { .vendor = OCP_VENDOR_INVALID}
  470. };
  471. static struct ocp_driver mal_driver = {
  472. .name = "mal",
  473. .id_table = mal_ids,
  474. .probe = mal_probe,
  475. .remove = mal_remove,
  476. };
  477. int __init mal_init(void)
  478. {
  479. MAL_DBG(": init" NL);
  480. return ocp_register_driver(&mal_driver);
  481. }
  482. void __exit mal_exit(void)
  483. {
  484. MAL_DBG(": exit" NL);
  485. ocp_unregister_driver(&mal_driver);
  486. }