coh901318.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. /*
  2. * driver/dma/coh901318.c
  3. *
  4. * Copyright (C) 2007-2009 ST-Ericsson
  5. * License terms: GNU General Public License (GPL) version 2
  6. * DMA driver for COH 901 318
  7. * Author: Per Friden <per.friden@stericsson.com>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/module.h>
  11. #include <linux/kernel.h> /* printk() */
  12. #include <linux/fs.h> /* everything... */
  13. #include <linux/slab.h> /* kmalloc() */
  14. #include <linux/dmaengine.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/device.h>
  17. #include <linux/irqreturn.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/io.h>
  20. #include <linux/uaccess.h>
  21. #include <linux/debugfs.h>
  22. #include <mach/coh901318.h>
  23. #include "coh901318_lli.h"
  24. #define COHC_2_DEV(cohc) (&cohc->chan.dev->device)
  25. #ifdef VERBOSE_DEBUG
  26. #define COH_DBG(x) ({ if (1) x; 0; })
  27. #else
  28. #define COH_DBG(x) ({ if (0) x; 0; })
  29. #endif
  30. struct coh901318_desc {
  31. struct dma_async_tx_descriptor desc;
  32. struct list_head node;
  33. struct scatterlist *sg;
  34. unsigned int sg_len;
  35. struct coh901318_lli *data;
  36. enum dma_data_direction dir;
  37. unsigned long flags;
  38. };
  39. struct coh901318_base {
  40. struct device *dev;
  41. void __iomem *virtbase;
  42. struct coh901318_pool pool;
  43. struct powersave pm;
  44. struct dma_device dma_slave;
  45. struct dma_device dma_memcpy;
  46. struct coh901318_chan *chans;
  47. struct coh901318_platform *platform;
  48. };
  49. struct coh901318_chan {
  50. spinlock_t lock;
  51. int allocated;
  52. int completed;
  53. int id;
  54. int stopped;
  55. struct work_struct free_work;
  56. struct dma_chan chan;
  57. struct tasklet_struct tasklet;
  58. struct list_head active;
  59. struct list_head queue;
  60. struct list_head free;
  61. unsigned long nbr_active_done;
  62. unsigned long busy;
  63. struct coh901318_base *base;
  64. };
  65. static void coh901318_list_print(struct coh901318_chan *cohc,
  66. struct coh901318_lli *lli)
  67. {
  68. struct coh901318_lli *l = lli;
  69. int i = 0;
  70. while (l) {
  71. dev_vdbg(COHC_2_DEV(cohc), "i %d, lli %p, ctrl 0x%x, src 0x%x"
  72. ", dst 0x%x, link 0x%x virt_link_addr 0x%p\n",
  73. i, l, l->control, l->src_addr, l->dst_addr,
  74. l->link_addr, l->virt_link_addr);
  75. i++;
  76. l = l->virt_link_addr;
  77. }
  78. }
  79. #ifdef CONFIG_DEBUG_FS
  80. #define COH901318_DEBUGFS_ASSIGN(x, y) (x = y)
  81. static struct coh901318_base *debugfs_dma_base;
  82. static struct dentry *dma_dentry;
  83. static int coh901318_debugfs_open(struct inode *inode, struct file *file)
  84. {
  85. file->private_data = inode->i_private;
  86. return 0;
  87. }
  88. static int coh901318_debugfs_read(struct file *file, char __user *buf,
  89. size_t count, loff_t *f_pos)
  90. {
  91. u64 started_channels = debugfs_dma_base->pm.started_channels;
  92. int pool_count = debugfs_dma_base->pool.debugfs_pool_counter;
  93. int i;
  94. int ret = 0;
  95. char *dev_buf;
  96. char *tmp;
  97. int dev_size;
  98. dev_buf = kmalloc(4*1024, GFP_KERNEL);
  99. if (dev_buf == NULL)
  100. goto err_kmalloc;
  101. tmp = dev_buf;
  102. tmp += sprintf(tmp, "DMA -- enabled dma channels\n");
  103. for (i = 0; i < debugfs_dma_base->platform->max_channels; i++)
  104. if (started_channels & (1 << i))
  105. tmp += sprintf(tmp, "channel %d\n", i);
  106. tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count);
  107. dev_size = tmp - dev_buf;
  108. /* No more to read if offset != 0 */
  109. if (*f_pos > dev_size)
  110. goto out;
  111. if (count > dev_size - *f_pos)
  112. count = dev_size - *f_pos;
  113. if (copy_to_user(buf, dev_buf + *f_pos, count))
  114. ret = -EINVAL;
  115. ret = count;
  116. *f_pos += count;
  117. out:
  118. kfree(dev_buf);
  119. return ret;
  120. err_kmalloc:
  121. return 0;
  122. }
  123. static const struct file_operations coh901318_debugfs_status_operations = {
  124. .owner = THIS_MODULE,
  125. .open = coh901318_debugfs_open,
  126. .read = coh901318_debugfs_read,
  127. };
  128. static int __init init_coh901318_debugfs(void)
  129. {
  130. dma_dentry = debugfs_create_dir("dma", NULL);
  131. (void) debugfs_create_file("status",
  132. S_IFREG | S_IRUGO,
  133. dma_dentry, NULL,
  134. &coh901318_debugfs_status_operations);
  135. return 0;
  136. }
  137. static void __exit exit_coh901318_debugfs(void)
  138. {
  139. debugfs_remove_recursive(dma_dentry);
  140. }
  141. module_init(init_coh901318_debugfs);
  142. module_exit(exit_coh901318_debugfs);
  143. #else
  144. #define COH901318_DEBUGFS_ASSIGN(x, y)
  145. #endif /* CONFIG_DEBUG_FS */
  146. static inline struct coh901318_chan *to_coh901318_chan(struct dma_chan *chan)
  147. {
  148. return container_of(chan, struct coh901318_chan, chan);
  149. }
  150. static inline dma_addr_t
  151. cohc_dev_addr(struct coh901318_chan *cohc)
  152. {
  153. return cohc->base->platform->chan_conf[cohc->id].dev_addr;
  154. }
  155. static inline const struct coh901318_params *
  156. cohc_chan_param(struct coh901318_chan *cohc)
  157. {
  158. return &cohc->base->platform->chan_conf[cohc->id].param;
  159. }
  160. static inline const struct coh_dma_channel *
  161. cohc_chan_conf(struct coh901318_chan *cohc)
  162. {
  163. return &cohc->base->platform->chan_conf[cohc->id];
  164. }
  165. static void enable_powersave(struct coh901318_chan *cohc)
  166. {
  167. unsigned long flags;
  168. struct powersave *pm = &cohc->base->pm;
  169. spin_lock_irqsave(&pm->lock, flags);
  170. pm->started_channels &= ~(1ULL << cohc->id);
  171. if (!pm->started_channels) {
  172. /* DMA no longer intends to access memory */
  173. cohc->base->platform->access_memory_state(cohc->base->dev,
  174. false);
  175. }
  176. spin_unlock_irqrestore(&pm->lock, flags);
  177. }
  178. static void disable_powersave(struct coh901318_chan *cohc)
  179. {
  180. unsigned long flags;
  181. struct powersave *pm = &cohc->base->pm;
  182. spin_lock_irqsave(&pm->lock, flags);
  183. if (!pm->started_channels) {
  184. /* DMA intends to access memory */
  185. cohc->base->platform->access_memory_state(cohc->base->dev,
  186. true);
  187. }
  188. pm->started_channels |= (1ULL << cohc->id);
  189. spin_unlock_irqrestore(&pm->lock, flags);
  190. }
  191. static inline int coh901318_set_ctrl(struct coh901318_chan *cohc, u32 control)
  192. {
  193. int channel = cohc->id;
  194. void __iomem *virtbase = cohc->base->virtbase;
  195. writel(control,
  196. virtbase + COH901318_CX_CTRL +
  197. COH901318_CX_CTRL_SPACING * channel);
  198. return 0;
  199. }
  200. static inline int coh901318_set_conf(struct coh901318_chan *cohc, u32 conf)
  201. {
  202. int channel = cohc->id;
  203. void __iomem *virtbase = cohc->base->virtbase;
  204. writel(conf,
  205. virtbase + COH901318_CX_CFG +
  206. COH901318_CX_CFG_SPACING*channel);
  207. return 0;
  208. }
  209. static int coh901318_start(struct coh901318_chan *cohc)
  210. {
  211. u32 val;
  212. int channel = cohc->id;
  213. void __iomem *virtbase = cohc->base->virtbase;
  214. disable_powersave(cohc);
  215. val = readl(virtbase + COH901318_CX_CFG +
  216. COH901318_CX_CFG_SPACING * channel);
  217. /* Enable channel */
  218. val |= COH901318_CX_CFG_CH_ENABLE;
  219. writel(val, virtbase + COH901318_CX_CFG +
  220. COH901318_CX_CFG_SPACING * channel);
  221. return 0;
  222. }
  223. static int coh901318_prep_linked_list(struct coh901318_chan *cohc,
  224. struct coh901318_lli *data)
  225. {
  226. int channel = cohc->id;
  227. void __iomem *virtbase = cohc->base->virtbase;
  228. BUG_ON(readl(virtbase + COH901318_CX_STAT +
  229. COH901318_CX_STAT_SPACING*channel) &
  230. COH901318_CX_STAT_ACTIVE);
  231. writel(data->src_addr,
  232. virtbase + COH901318_CX_SRC_ADDR +
  233. COH901318_CX_SRC_ADDR_SPACING * channel);
  234. writel(data->dst_addr, virtbase +
  235. COH901318_CX_DST_ADDR +
  236. COH901318_CX_DST_ADDR_SPACING * channel);
  237. writel(data->link_addr, virtbase + COH901318_CX_LNK_ADDR +
  238. COH901318_CX_LNK_ADDR_SPACING * channel);
  239. writel(data->control, virtbase + COH901318_CX_CTRL +
  240. COH901318_CX_CTRL_SPACING * channel);
  241. return 0;
  242. }
  243. static dma_cookie_t
  244. coh901318_assign_cookie(struct coh901318_chan *cohc,
  245. struct coh901318_desc *cohd)
  246. {
  247. dma_cookie_t cookie = cohc->chan.cookie;
  248. if (++cookie < 0)
  249. cookie = 1;
  250. cohc->chan.cookie = cookie;
  251. cohd->desc.cookie = cookie;
  252. return cookie;
  253. }
  254. static struct coh901318_desc *
  255. coh901318_desc_get(struct coh901318_chan *cohc)
  256. {
  257. struct coh901318_desc *desc;
  258. if (list_empty(&cohc->free)) {
  259. /* alloc new desc because we're out of used ones
  260. * TODO: alloc a pile of descs instead of just one,
  261. * avoid many small allocations.
  262. */
  263. desc = kzalloc(sizeof(struct coh901318_desc), GFP_NOWAIT);
  264. if (desc == NULL)
  265. goto out;
  266. INIT_LIST_HEAD(&desc->node);
  267. dma_async_tx_descriptor_init(&desc->desc, &cohc->chan);
  268. } else {
  269. /* Reuse an old desc. */
  270. desc = list_first_entry(&cohc->free,
  271. struct coh901318_desc,
  272. node);
  273. list_del(&desc->node);
  274. /* Initialize it a bit so it's not insane */
  275. desc->sg = NULL;
  276. desc->sg_len = 0;
  277. desc->desc.callback = NULL;
  278. desc->desc.callback_param = NULL;
  279. }
  280. out:
  281. return desc;
  282. }
  283. static void
  284. coh901318_desc_free(struct coh901318_chan *cohc, struct coh901318_desc *cohd)
  285. {
  286. list_add_tail(&cohd->node, &cohc->free);
  287. }
  288. /* call with irq lock held */
  289. static void
  290. coh901318_desc_submit(struct coh901318_chan *cohc, struct coh901318_desc *desc)
  291. {
  292. list_add_tail(&desc->node, &cohc->active);
  293. }
  294. static struct coh901318_desc *
  295. coh901318_first_active_get(struct coh901318_chan *cohc)
  296. {
  297. struct coh901318_desc *d;
  298. if (list_empty(&cohc->active))
  299. return NULL;
  300. d = list_first_entry(&cohc->active,
  301. struct coh901318_desc,
  302. node);
  303. return d;
  304. }
  305. static void
  306. coh901318_desc_remove(struct coh901318_desc *cohd)
  307. {
  308. list_del(&cohd->node);
  309. }
  310. static void
  311. coh901318_desc_queue(struct coh901318_chan *cohc, struct coh901318_desc *desc)
  312. {
  313. list_add_tail(&desc->node, &cohc->queue);
  314. }
  315. static struct coh901318_desc *
  316. coh901318_first_queued(struct coh901318_chan *cohc)
  317. {
  318. struct coh901318_desc *d;
  319. if (list_empty(&cohc->queue))
  320. return NULL;
  321. d = list_first_entry(&cohc->queue,
  322. struct coh901318_desc,
  323. node);
  324. return d;
  325. }
  326. /*
  327. * DMA start/stop controls
  328. */
  329. u32 coh901318_get_bytes_left(struct dma_chan *chan)
  330. {
  331. unsigned long flags;
  332. u32 ret;
  333. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  334. spin_lock_irqsave(&cohc->lock, flags);
  335. /* Read transfer count value */
  336. ret = readl(cohc->base->virtbase +
  337. COH901318_CX_CTRL+COH901318_CX_CTRL_SPACING *
  338. cohc->id) & COH901318_CX_CTRL_TC_VALUE_MASK;
  339. spin_unlock_irqrestore(&cohc->lock, flags);
  340. return ret;
  341. }
  342. EXPORT_SYMBOL(coh901318_get_bytes_left);
  343. /* Stops a transfer without losing data. Enables power save.
  344. Use this function in conjunction with coh901318_continue(..)
  345. */
  346. void coh901318_stop(struct dma_chan *chan)
  347. {
  348. u32 val;
  349. unsigned long flags;
  350. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  351. int channel = cohc->id;
  352. void __iomem *virtbase = cohc->base->virtbase;
  353. spin_lock_irqsave(&cohc->lock, flags);
  354. /* Disable channel in HW */
  355. val = readl(virtbase + COH901318_CX_CFG +
  356. COH901318_CX_CFG_SPACING * channel);
  357. /* Stopping infinit transfer */
  358. if ((val & COH901318_CX_CTRL_TC_ENABLE) == 0 &&
  359. (val & COH901318_CX_CFG_CH_ENABLE))
  360. cohc->stopped = 1;
  361. val &= ~COH901318_CX_CFG_CH_ENABLE;
  362. /* Enable twice, HW bug work around */
  363. writel(val, virtbase + COH901318_CX_CFG +
  364. COH901318_CX_CFG_SPACING * channel);
  365. writel(val, virtbase + COH901318_CX_CFG +
  366. COH901318_CX_CFG_SPACING * channel);
  367. /* Spin-wait for it to actually go inactive */
  368. while (readl(virtbase + COH901318_CX_STAT+COH901318_CX_STAT_SPACING *
  369. channel) & COH901318_CX_STAT_ACTIVE)
  370. cpu_relax();
  371. /* Check if we stopped an active job */
  372. if ((readl(virtbase + COH901318_CX_CTRL+COH901318_CX_CTRL_SPACING *
  373. channel) & COH901318_CX_CTRL_TC_VALUE_MASK) > 0)
  374. cohc->stopped = 1;
  375. enable_powersave(cohc);
  376. spin_unlock_irqrestore(&cohc->lock, flags);
  377. }
  378. EXPORT_SYMBOL(coh901318_stop);
  379. /* Continues a transfer that has been stopped via 300_dma_stop(..).
  380. Power save is handled.
  381. */
  382. void coh901318_continue(struct dma_chan *chan)
  383. {
  384. u32 val;
  385. unsigned long flags;
  386. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  387. int channel = cohc->id;
  388. spin_lock_irqsave(&cohc->lock, flags);
  389. disable_powersave(cohc);
  390. if (cohc->stopped) {
  391. /* Enable channel in HW */
  392. val = readl(cohc->base->virtbase + COH901318_CX_CFG +
  393. COH901318_CX_CFG_SPACING * channel);
  394. val |= COH901318_CX_CFG_CH_ENABLE;
  395. writel(val, cohc->base->virtbase + COH901318_CX_CFG +
  396. COH901318_CX_CFG_SPACING*channel);
  397. cohc->stopped = 0;
  398. }
  399. spin_unlock_irqrestore(&cohc->lock, flags);
  400. }
  401. EXPORT_SYMBOL(coh901318_continue);
  402. bool coh901318_filter_id(struct dma_chan *chan, void *chan_id)
  403. {
  404. unsigned int ch_nr = (unsigned int) chan_id;
  405. if (ch_nr == to_coh901318_chan(chan)->id)
  406. return true;
  407. return false;
  408. }
  409. EXPORT_SYMBOL(coh901318_filter_id);
  410. /*
  411. * DMA channel allocation
  412. */
  413. static int coh901318_config(struct coh901318_chan *cohc,
  414. struct coh901318_params *param)
  415. {
  416. unsigned long flags;
  417. const struct coh901318_params *p;
  418. int channel = cohc->id;
  419. void __iomem *virtbase = cohc->base->virtbase;
  420. spin_lock_irqsave(&cohc->lock, flags);
  421. if (param)
  422. p = param;
  423. else
  424. p = &cohc->base->platform->chan_conf[channel].param;
  425. /* Clear any pending BE or TC interrupt */
  426. if (channel < 32) {
  427. writel(1 << channel, virtbase + COH901318_BE_INT_CLEAR1);
  428. writel(1 << channel, virtbase + COH901318_TC_INT_CLEAR1);
  429. } else {
  430. writel(1 << (channel - 32), virtbase +
  431. COH901318_BE_INT_CLEAR2);
  432. writel(1 << (channel - 32), virtbase +
  433. COH901318_TC_INT_CLEAR2);
  434. }
  435. coh901318_set_conf(cohc, p->config);
  436. coh901318_set_ctrl(cohc, p->ctrl_lli_last);
  437. spin_unlock_irqrestore(&cohc->lock, flags);
  438. return 0;
  439. }
  440. /* must lock when calling this function
  441. * start queued jobs, if any
  442. * TODO: start all queued jobs in one go
  443. *
  444. * Returns descriptor if queued job is started otherwise NULL.
  445. * If the queue is empty NULL is returned.
  446. */
  447. static struct coh901318_desc *coh901318_queue_start(struct coh901318_chan *cohc)
  448. {
  449. struct coh901318_desc *cohd_que;
  450. /* start queued jobs, if any
  451. * TODO: transmit all queued jobs in one go
  452. */
  453. cohd_que = coh901318_first_queued(cohc);
  454. if (cohd_que != NULL) {
  455. /* Remove from queue */
  456. coh901318_desc_remove(cohd_que);
  457. /* initiate DMA job */
  458. cohc->busy = 1;
  459. coh901318_desc_submit(cohc, cohd_que);
  460. coh901318_prep_linked_list(cohc, cohd_que->data);
  461. /* start dma job */
  462. coh901318_start(cohc);
  463. }
  464. return cohd_que;
  465. }
  466. /*
  467. * This tasklet is called from the interrupt handler to
  468. * handle each descriptor (DMA job) that is sent to a channel.
  469. */
  470. static void dma_tasklet(unsigned long data)
  471. {
  472. struct coh901318_chan *cohc = (struct coh901318_chan *) data;
  473. struct coh901318_desc *cohd_fin;
  474. unsigned long flags;
  475. dma_async_tx_callback callback;
  476. void *callback_param;
  477. dev_vdbg(COHC_2_DEV(cohc), "[%s] chan_id %d"
  478. " nbr_active_done %ld\n", __func__,
  479. cohc->id, cohc->nbr_active_done);
  480. spin_lock_irqsave(&cohc->lock, flags);
  481. /* get first active descriptor entry from list */
  482. cohd_fin = coh901318_first_active_get(cohc);
  483. if (cohd_fin == NULL)
  484. goto err;
  485. /* locate callback to client */
  486. callback = cohd_fin->desc.callback;
  487. callback_param = cohd_fin->desc.callback_param;
  488. /* sign this job as completed on the channel */
  489. cohc->completed = cohd_fin->desc.cookie;
  490. /* release the lli allocation and remove the descriptor */
  491. coh901318_lli_free(&cohc->base->pool, &cohd_fin->data);
  492. /* return desc to free-list */
  493. coh901318_desc_remove(cohd_fin);
  494. coh901318_desc_free(cohc, cohd_fin);
  495. spin_unlock_irqrestore(&cohc->lock, flags);
  496. /* Call the callback when we're done */
  497. if (callback)
  498. callback(callback_param);
  499. spin_lock_irqsave(&cohc->lock, flags);
  500. /*
  501. * If another interrupt fired while the tasklet was scheduling,
  502. * we don't get called twice, so we have this number of active
  503. * counter that keep track of the number of IRQs expected to
  504. * be handled for this channel. If there happen to be more than
  505. * one IRQ to be ack:ed, we simply schedule this tasklet again.
  506. */
  507. cohc->nbr_active_done--;
  508. if (cohc->nbr_active_done) {
  509. dev_dbg(COHC_2_DEV(cohc), "scheduling tasklet again, new IRQs "
  510. "came in while we were scheduling this tasklet\n");
  511. if (cohc_chan_conf(cohc)->priority_high)
  512. tasklet_hi_schedule(&cohc->tasklet);
  513. else
  514. tasklet_schedule(&cohc->tasklet);
  515. }
  516. spin_unlock_irqrestore(&cohc->lock, flags);
  517. return;
  518. err:
  519. spin_unlock_irqrestore(&cohc->lock, flags);
  520. dev_err(COHC_2_DEV(cohc), "[%s] No active dma desc\n", __func__);
  521. }
  522. /* called from interrupt context */
  523. static void dma_tc_handle(struct coh901318_chan *cohc)
  524. {
  525. BUG_ON(!cohc->allocated && (list_empty(&cohc->active) ||
  526. list_empty(&cohc->queue)));
  527. if (!cohc->allocated)
  528. return;
  529. spin_lock(&cohc->lock);
  530. cohc->nbr_active_done++;
  531. if (coh901318_queue_start(cohc) == NULL)
  532. cohc->busy = 0;
  533. BUG_ON(list_empty(&cohc->active));
  534. spin_unlock(&cohc->lock);
  535. if (cohc_chan_conf(cohc)->priority_high)
  536. tasklet_hi_schedule(&cohc->tasklet);
  537. else
  538. tasklet_schedule(&cohc->tasklet);
  539. }
  540. static irqreturn_t dma_irq_handler(int irq, void *dev_id)
  541. {
  542. u32 status1;
  543. u32 status2;
  544. int i;
  545. int ch;
  546. struct coh901318_base *base = dev_id;
  547. struct coh901318_chan *cohc;
  548. void __iomem *virtbase = base->virtbase;
  549. status1 = readl(virtbase + COH901318_INT_STATUS1);
  550. status2 = readl(virtbase + COH901318_INT_STATUS2);
  551. if (unlikely(status1 == 0 && status2 == 0)) {
  552. dev_warn(base->dev, "spurious DMA IRQ from no channel!\n");
  553. return IRQ_HANDLED;
  554. }
  555. /* TODO: consider handle IRQ in tasklet here to
  556. * minimize interrupt latency */
  557. /* Check the first 32 DMA channels for IRQ */
  558. while (status1) {
  559. /* Find first bit set, return as a number. */
  560. i = ffs(status1) - 1;
  561. ch = i;
  562. cohc = &base->chans[ch];
  563. spin_lock(&cohc->lock);
  564. /* Mask off this bit */
  565. status1 &= ~(1 << i);
  566. /* Check the individual channel bits */
  567. if (test_bit(i, virtbase + COH901318_BE_INT_STATUS1)) {
  568. dev_crit(COHC_2_DEV(cohc),
  569. "DMA bus error on channel %d!\n", ch);
  570. BUG_ON(1);
  571. /* Clear BE interrupt */
  572. __set_bit(i, virtbase + COH901318_BE_INT_CLEAR1);
  573. } else {
  574. /* Caused by TC, really? */
  575. if (unlikely(!test_bit(i, virtbase +
  576. COH901318_TC_INT_STATUS1))) {
  577. dev_warn(COHC_2_DEV(cohc),
  578. "ignoring interrupt not caused by terminal count on channel %d\n", ch);
  579. /* Clear TC interrupt */
  580. BUG_ON(1);
  581. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR1);
  582. } else {
  583. /* Enable powersave if transfer has finished */
  584. if (!(readl(virtbase + COH901318_CX_STAT +
  585. COH901318_CX_STAT_SPACING*ch) &
  586. COH901318_CX_STAT_ENABLED)) {
  587. enable_powersave(cohc);
  588. }
  589. /* Must clear TC interrupt before calling
  590. * dma_tc_handle
  591. * in case tc_handle initate a new dma job
  592. */
  593. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR1);
  594. dma_tc_handle(cohc);
  595. }
  596. }
  597. spin_unlock(&cohc->lock);
  598. }
  599. /* Check the remaining 32 DMA channels for IRQ */
  600. while (status2) {
  601. /* Find first bit set, return as a number. */
  602. i = ffs(status2) - 1;
  603. ch = i + 32;
  604. cohc = &base->chans[ch];
  605. spin_lock(&cohc->lock);
  606. /* Mask off this bit */
  607. status2 &= ~(1 << i);
  608. /* Check the individual channel bits */
  609. if (test_bit(i, virtbase + COH901318_BE_INT_STATUS2)) {
  610. dev_crit(COHC_2_DEV(cohc),
  611. "DMA bus error on channel %d!\n", ch);
  612. /* Clear BE interrupt */
  613. BUG_ON(1);
  614. __set_bit(i, virtbase + COH901318_BE_INT_CLEAR2);
  615. } else {
  616. /* Caused by TC, really? */
  617. if (unlikely(!test_bit(i, virtbase +
  618. COH901318_TC_INT_STATUS2))) {
  619. dev_warn(COHC_2_DEV(cohc),
  620. "ignoring interrupt not caused by terminal count on channel %d\n", ch);
  621. /* Clear TC interrupt */
  622. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR2);
  623. BUG_ON(1);
  624. } else {
  625. /* Enable powersave if transfer has finished */
  626. if (!(readl(virtbase + COH901318_CX_STAT +
  627. COH901318_CX_STAT_SPACING*ch) &
  628. COH901318_CX_STAT_ENABLED)) {
  629. enable_powersave(cohc);
  630. }
  631. /* Must clear TC interrupt before calling
  632. * dma_tc_handle
  633. * in case tc_handle initate a new dma job
  634. */
  635. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR2);
  636. dma_tc_handle(cohc);
  637. }
  638. }
  639. spin_unlock(&cohc->lock);
  640. }
  641. return IRQ_HANDLED;
  642. }
  643. static int coh901318_alloc_chan_resources(struct dma_chan *chan)
  644. {
  645. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  646. dev_vdbg(COHC_2_DEV(cohc), "[%s] DMA channel %d\n",
  647. __func__, cohc->id);
  648. if (chan->client_count > 1)
  649. return -EBUSY;
  650. coh901318_config(cohc, NULL);
  651. cohc->allocated = 1;
  652. cohc->completed = chan->cookie = 1;
  653. return 1;
  654. }
  655. static void
  656. coh901318_free_chan_resources(struct dma_chan *chan)
  657. {
  658. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  659. int channel = cohc->id;
  660. unsigned long flags;
  661. spin_lock_irqsave(&cohc->lock, flags);
  662. /* Disable HW */
  663. writel(0x00000000U, cohc->base->virtbase + COH901318_CX_CFG +
  664. COH901318_CX_CFG_SPACING*channel);
  665. writel(0x00000000U, cohc->base->virtbase + COH901318_CX_CTRL +
  666. COH901318_CX_CTRL_SPACING*channel);
  667. cohc->allocated = 0;
  668. spin_unlock_irqrestore(&cohc->lock, flags);
  669. chan->device->device_terminate_all(chan);
  670. }
  671. static dma_cookie_t
  672. coh901318_tx_submit(struct dma_async_tx_descriptor *tx)
  673. {
  674. struct coh901318_desc *cohd = container_of(tx, struct coh901318_desc,
  675. desc);
  676. struct coh901318_chan *cohc = to_coh901318_chan(tx->chan);
  677. unsigned long flags;
  678. spin_lock_irqsave(&cohc->lock, flags);
  679. tx->cookie = coh901318_assign_cookie(cohc, cohd);
  680. coh901318_desc_queue(cohc, cohd);
  681. spin_unlock_irqrestore(&cohc->lock, flags);
  682. return tx->cookie;
  683. }
  684. static struct dma_async_tx_descriptor *
  685. coh901318_prep_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
  686. size_t size, unsigned long flags)
  687. {
  688. struct coh901318_lli *data;
  689. struct coh901318_desc *cohd;
  690. unsigned long flg;
  691. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  692. int lli_len;
  693. u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
  694. int ret;
  695. spin_lock_irqsave(&cohc->lock, flg);
  696. dev_vdbg(COHC_2_DEV(cohc),
  697. "[%s] channel %d src 0x%x dest 0x%x size %d\n",
  698. __func__, cohc->id, src, dest, size);
  699. if (flags & DMA_PREP_INTERRUPT)
  700. /* Trigger interrupt after last lli */
  701. ctrl_last |= COH901318_CX_CTRL_TC_IRQ_ENABLE;
  702. lli_len = size >> MAX_DMA_PACKET_SIZE_SHIFT;
  703. if ((lli_len << MAX_DMA_PACKET_SIZE_SHIFT) < size)
  704. lli_len++;
  705. data = coh901318_lli_alloc(&cohc->base->pool, lli_len);
  706. if (data == NULL)
  707. goto err;
  708. ret = coh901318_lli_fill_memcpy(
  709. &cohc->base->pool, data, src, size, dest,
  710. cohc_chan_param(cohc)->ctrl_lli_chained,
  711. ctrl_last);
  712. if (ret)
  713. goto err;
  714. COH_DBG(coh901318_list_print(cohc, data));
  715. /* Pick a descriptor to handle this transfer */
  716. cohd = coh901318_desc_get(cohc);
  717. cohd->data = data;
  718. cohd->flags = flags;
  719. cohd->desc.tx_submit = coh901318_tx_submit;
  720. spin_unlock_irqrestore(&cohc->lock, flg);
  721. return &cohd->desc;
  722. err:
  723. spin_unlock_irqrestore(&cohc->lock, flg);
  724. return NULL;
  725. }
  726. static struct dma_async_tx_descriptor *
  727. coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
  728. unsigned int sg_len, enum dma_data_direction direction,
  729. unsigned long flags)
  730. {
  731. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  732. struct coh901318_lli *data;
  733. struct coh901318_desc *cohd;
  734. const struct coh901318_params *params;
  735. struct scatterlist *sg;
  736. int len = 0;
  737. int size;
  738. int i;
  739. u32 ctrl_chained = cohc_chan_param(cohc)->ctrl_lli_chained;
  740. u32 ctrl = cohc_chan_param(cohc)->ctrl_lli;
  741. u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
  742. u32 config;
  743. unsigned long flg;
  744. int ret;
  745. if (!sgl)
  746. goto out;
  747. if (sgl->length == 0)
  748. goto out;
  749. spin_lock_irqsave(&cohc->lock, flg);
  750. dev_vdbg(COHC_2_DEV(cohc), "[%s] sg_len %d dir %d\n",
  751. __func__, sg_len, direction);
  752. if (flags & DMA_PREP_INTERRUPT)
  753. /* Trigger interrupt after last lli */
  754. ctrl_last |= COH901318_CX_CTRL_TC_IRQ_ENABLE;
  755. params = cohc_chan_param(cohc);
  756. config = params->config;
  757. if (direction == DMA_TO_DEVICE) {
  758. u32 tx_flags = COH901318_CX_CTRL_PRDD_SOURCE |
  759. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE;
  760. config |= COH901318_CX_CFG_RM_MEMORY_TO_PRIMARY;
  761. ctrl_chained |= tx_flags;
  762. ctrl_last |= tx_flags;
  763. ctrl |= tx_flags;
  764. } else if (direction == DMA_FROM_DEVICE) {
  765. u32 rx_flags = COH901318_CX_CTRL_PRDD_DEST |
  766. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE;
  767. config |= COH901318_CX_CFG_RM_PRIMARY_TO_MEMORY;
  768. ctrl_chained |= rx_flags;
  769. ctrl_last |= rx_flags;
  770. ctrl |= rx_flags;
  771. } else
  772. goto err_direction;
  773. coh901318_set_conf(cohc, config);
  774. /* The dma only supports transmitting packages up to
  775. * MAX_DMA_PACKET_SIZE. Calculate to total number of
  776. * dma elemts required to send the entire sg list
  777. */
  778. for_each_sg(sgl, sg, sg_len, i) {
  779. unsigned int factor;
  780. size = sg_dma_len(sg);
  781. if (size <= MAX_DMA_PACKET_SIZE) {
  782. len++;
  783. continue;
  784. }
  785. factor = size >> MAX_DMA_PACKET_SIZE_SHIFT;
  786. if ((factor << MAX_DMA_PACKET_SIZE_SHIFT) < size)
  787. factor++;
  788. len += factor;
  789. }
  790. pr_debug("Allocate %d lli:s for this transfer\n", len);
  791. data = coh901318_lli_alloc(&cohc->base->pool, len);
  792. if (data == NULL)
  793. goto err_dma_alloc;
  794. /* initiate allocated data list */
  795. ret = coh901318_lli_fill_sg(&cohc->base->pool, data, sgl, sg_len,
  796. cohc_dev_addr(cohc),
  797. ctrl_chained,
  798. ctrl,
  799. ctrl_last,
  800. direction, COH901318_CX_CTRL_TC_IRQ_ENABLE);
  801. if (ret)
  802. goto err_lli_fill;
  803. COH_DBG(coh901318_list_print(cohc, data));
  804. /* Pick a descriptor to handle this transfer */
  805. cohd = coh901318_desc_get(cohc);
  806. cohd->dir = direction;
  807. cohd->flags = flags;
  808. cohd->desc.tx_submit = coh901318_tx_submit;
  809. cohd->data = data;
  810. spin_unlock_irqrestore(&cohc->lock, flg);
  811. return &cohd->desc;
  812. err_lli_fill:
  813. err_dma_alloc:
  814. err_direction:
  815. spin_unlock_irqrestore(&cohc->lock, flg);
  816. out:
  817. return NULL;
  818. }
  819. static enum dma_status
  820. coh901318_is_tx_complete(struct dma_chan *chan,
  821. dma_cookie_t cookie, dma_cookie_t *done,
  822. dma_cookie_t *used)
  823. {
  824. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  825. dma_cookie_t last_used;
  826. dma_cookie_t last_complete;
  827. int ret;
  828. last_complete = cohc->completed;
  829. last_used = chan->cookie;
  830. ret = dma_async_is_complete(cookie, last_complete, last_used);
  831. if (done)
  832. *done = last_complete;
  833. if (used)
  834. *used = last_used;
  835. return ret;
  836. }
  837. static void
  838. coh901318_issue_pending(struct dma_chan *chan)
  839. {
  840. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  841. unsigned long flags;
  842. spin_lock_irqsave(&cohc->lock, flags);
  843. /* Busy means that pending jobs are already being processed */
  844. if (!cohc->busy)
  845. coh901318_queue_start(cohc);
  846. spin_unlock_irqrestore(&cohc->lock, flags);
  847. }
  848. static void
  849. coh901318_terminate_all(struct dma_chan *chan)
  850. {
  851. unsigned long flags;
  852. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  853. struct coh901318_desc *cohd;
  854. void __iomem *virtbase = cohc->base->virtbase;
  855. coh901318_stop(chan);
  856. spin_lock_irqsave(&cohc->lock, flags);
  857. /* Clear any pending BE or TC interrupt */
  858. if (cohc->id < 32) {
  859. writel(1 << cohc->id, virtbase + COH901318_BE_INT_CLEAR1);
  860. writel(1 << cohc->id, virtbase + COH901318_TC_INT_CLEAR1);
  861. } else {
  862. writel(1 << (cohc->id - 32), virtbase +
  863. COH901318_BE_INT_CLEAR2);
  864. writel(1 << (cohc->id - 32), virtbase +
  865. COH901318_TC_INT_CLEAR2);
  866. }
  867. enable_powersave(cohc);
  868. while ((cohd = coh901318_first_active_get(cohc))) {
  869. /* release the lli allocation*/
  870. coh901318_lli_free(&cohc->base->pool, &cohd->data);
  871. /* return desc to free-list */
  872. coh901318_desc_remove(cohd);
  873. coh901318_desc_free(cohc, cohd);
  874. }
  875. while ((cohd = coh901318_first_queued(cohc))) {
  876. /* release the lli allocation*/
  877. coh901318_lli_free(&cohc->base->pool, &cohd->data);
  878. /* return desc to free-list */
  879. coh901318_desc_remove(cohd);
  880. coh901318_desc_free(cohc, cohd);
  881. }
  882. cohc->nbr_active_done = 0;
  883. cohc->busy = 0;
  884. spin_unlock_irqrestore(&cohc->lock, flags);
  885. }
  886. void coh901318_base_init(struct dma_device *dma, const int *pick_chans,
  887. struct coh901318_base *base)
  888. {
  889. int chans_i;
  890. int i = 0;
  891. struct coh901318_chan *cohc;
  892. INIT_LIST_HEAD(&dma->channels);
  893. for (chans_i = 0; pick_chans[chans_i] != -1; chans_i += 2) {
  894. for (i = pick_chans[chans_i]; i <= pick_chans[chans_i+1]; i++) {
  895. cohc = &base->chans[i];
  896. cohc->base = base;
  897. cohc->chan.device = dma;
  898. cohc->id = i;
  899. /* TODO: do we really need this lock if only one
  900. * client is connected to each channel?
  901. */
  902. spin_lock_init(&cohc->lock);
  903. cohc->nbr_active_done = 0;
  904. cohc->busy = 0;
  905. INIT_LIST_HEAD(&cohc->free);
  906. INIT_LIST_HEAD(&cohc->active);
  907. INIT_LIST_HEAD(&cohc->queue);
  908. tasklet_init(&cohc->tasklet, dma_tasklet,
  909. (unsigned long) cohc);
  910. list_add_tail(&cohc->chan.device_node,
  911. &dma->channels);
  912. }
  913. }
  914. }
  915. static int __init coh901318_probe(struct platform_device *pdev)
  916. {
  917. int err = 0;
  918. struct coh901318_platform *pdata;
  919. struct coh901318_base *base;
  920. int irq;
  921. struct resource *io;
  922. io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  923. if (!io)
  924. goto err_get_resource;
  925. /* Map DMA controller registers to virtual memory */
  926. if (request_mem_region(io->start,
  927. resource_size(io),
  928. pdev->dev.driver->name) == NULL) {
  929. err = -EBUSY;
  930. goto err_request_mem;
  931. }
  932. pdata = pdev->dev.platform_data;
  933. if (!pdata)
  934. goto err_no_platformdata;
  935. base = kmalloc(ALIGN(sizeof(struct coh901318_base), 4) +
  936. pdata->max_channels *
  937. sizeof(struct coh901318_chan),
  938. GFP_KERNEL);
  939. if (!base)
  940. goto err_alloc_coh_dma_channels;
  941. base->chans = ((void *)base) + ALIGN(sizeof(struct coh901318_base), 4);
  942. base->virtbase = ioremap(io->start, resource_size(io));
  943. if (!base->virtbase) {
  944. err = -ENOMEM;
  945. goto err_no_ioremap;
  946. }
  947. base->dev = &pdev->dev;
  948. base->platform = pdata;
  949. spin_lock_init(&base->pm.lock);
  950. base->pm.started_channels = 0;
  951. COH901318_DEBUGFS_ASSIGN(debugfs_dma_base, base);
  952. platform_set_drvdata(pdev, base);
  953. irq = platform_get_irq(pdev, 0);
  954. if (irq < 0)
  955. goto err_no_irq;
  956. err = request_irq(irq, dma_irq_handler, IRQF_DISABLED,
  957. "coh901318", base);
  958. if (err) {
  959. dev_crit(&pdev->dev,
  960. "Cannot allocate IRQ for DMA controller!\n");
  961. goto err_request_irq;
  962. }
  963. err = coh901318_pool_create(&base->pool, &pdev->dev,
  964. sizeof(struct coh901318_lli),
  965. 32);
  966. if (err)
  967. goto err_pool_create;
  968. /* init channels for device transfers */
  969. coh901318_base_init(&base->dma_slave, base->platform->chans_slave,
  970. base);
  971. dma_cap_zero(base->dma_slave.cap_mask);
  972. dma_cap_set(DMA_SLAVE, base->dma_slave.cap_mask);
  973. base->dma_slave.device_alloc_chan_resources = coh901318_alloc_chan_resources;
  974. base->dma_slave.device_free_chan_resources = coh901318_free_chan_resources;
  975. base->dma_slave.device_prep_slave_sg = coh901318_prep_slave_sg;
  976. base->dma_slave.device_is_tx_complete = coh901318_is_tx_complete;
  977. base->dma_slave.device_issue_pending = coh901318_issue_pending;
  978. base->dma_slave.device_terminate_all = coh901318_terminate_all;
  979. base->dma_slave.dev = &pdev->dev;
  980. err = dma_async_device_register(&base->dma_slave);
  981. if (err)
  982. goto err_register_slave;
  983. /* init channels for memcpy */
  984. coh901318_base_init(&base->dma_memcpy, base->platform->chans_memcpy,
  985. base);
  986. dma_cap_zero(base->dma_memcpy.cap_mask);
  987. dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask);
  988. base->dma_memcpy.device_alloc_chan_resources = coh901318_alloc_chan_resources;
  989. base->dma_memcpy.device_free_chan_resources = coh901318_free_chan_resources;
  990. base->dma_memcpy.device_prep_dma_memcpy = coh901318_prep_memcpy;
  991. base->dma_memcpy.device_is_tx_complete = coh901318_is_tx_complete;
  992. base->dma_memcpy.device_issue_pending = coh901318_issue_pending;
  993. base->dma_memcpy.device_terminate_all = coh901318_terminate_all;
  994. base->dma_memcpy.dev = &pdev->dev;
  995. /*
  996. * This controller can only access address at even 32bit boundaries,
  997. * i.e. 2^2
  998. */
  999. base->dma_memcpy.copy_align = 2;
  1000. err = dma_async_device_register(&base->dma_memcpy);
  1001. if (err)
  1002. goto err_register_memcpy;
  1003. dev_info(&pdev->dev, "Initialized COH901318 DMA on virtual base 0x%08x\n",
  1004. (u32) base->virtbase);
  1005. return err;
  1006. err_register_memcpy:
  1007. dma_async_device_unregister(&base->dma_slave);
  1008. err_register_slave:
  1009. coh901318_pool_destroy(&base->pool);
  1010. err_pool_create:
  1011. free_irq(platform_get_irq(pdev, 0), base);
  1012. err_request_irq:
  1013. err_no_irq:
  1014. iounmap(base->virtbase);
  1015. err_no_ioremap:
  1016. kfree(base);
  1017. err_alloc_coh_dma_channels:
  1018. err_no_platformdata:
  1019. release_mem_region(pdev->resource->start,
  1020. resource_size(pdev->resource));
  1021. err_request_mem:
  1022. err_get_resource:
  1023. return err;
  1024. }
  1025. static int __exit coh901318_remove(struct platform_device *pdev)
  1026. {
  1027. struct coh901318_base *base = platform_get_drvdata(pdev);
  1028. dma_async_device_unregister(&base->dma_memcpy);
  1029. dma_async_device_unregister(&base->dma_slave);
  1030. coh901318_pool_destroy(&base->pool);
  1031. free_irq(platform_get_irq(pdev, 0), base);
  1032. iounmap(base->virtbase);
  1033. kfree(base);
  1034. release_mem_region(pdev->resource->start,
  1035. resource_size(pdev->resource));
  1036. return 0;
  1037. }
  1038. static struct platform_driver coh901318_driver = {
  1039. .remove = __exit_p(coh901318_remove),
  1040. .driver = {
  1041. .name = "coh901318",
  1042. },
  1043. };
  1044. int __init coh901318_init(void)
  1045. {
  1046. return platform_driver_probe(&coh901318_driver, coh901318_probe);
  1047. }
  1048. subsys_initcall(coh901318_init);
  1049. void __exit coh901318_exit(void)
  1050. {
  1051. platform_driver_unregister(&coh901318_driver);
  1052. }
  1053. module_exit(coh901318_exit);
  1054. MODULE_LICENSE("GPL");
  1055. MODULE_AUTHOR("Per Friden");