coh901318.c 32 KB

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