dma.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /* linux/arch/arm/plat-s3c64xx/dma.c
  2. *
  3. * Copyright 2009 Openmoko, Inc.
  4. * Copyright 2009 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * S3C64XX DMA core
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/dmapool.h>
  18. #include <linux/sysdev.h>
  19. #include <linux/errno.h>
  20. #include <linux/delay.h>
  21. #include <linux/clk.h>
  22. #include <linux/err.h>
  23. #include <linux/io.h>
  24. #include <mach/dma.h>
  25. #include <mach/map.h>
  26. #include <mach/irqs.h>
  27. #include <plat/dma-plat.h>
  28. #include <plat/regs-sys.h>
  29. #include <asm/hardware/pl080.h>
  30. /* dma channel state information */
  31. struct s3c64xx_dmac {
  32. struct sys_device sysdev;
  33. struct clk *clk;
  34. void __iomem *regs;
  35. struct s3c2410_dma_chan *channels;
  36. enum dma_ch chanbase;
  37. };
  38. /* pool to provide LLI buffers */
  39. static struct dma_pool *dma_pool;
  40. /* Debug configuration and code */
  41. static unsigned char debug_show_buffs = 0;
  42. static void dbg_showchan(struct s3c2410_dma_chan *chan)
  43. {
  44. pr_debug("DMA%d: %08x->%08x L %08x C %08x,%08x S %08x\n",
  45. chan->number,
  46. readl(chan->regs + PL080_CH_SRC_ADDR),
  47. readl(chan->regs + PL080_CH_DST_ADDR),
  48. readl(chan->regs + PL080_CH_LLI),
  49. readl(chan->regs + PL080_CH_CONTROL),
  50. readl(chan->regs + PL080S_CH_CONTROL2),
  51. readl(chan->regs + PL080S_CH_CONFIG));
  52. }
  53. static void show_lli(struct pl080s_lli *lli)
  54. {
  55. pr_debug("LLI[%p] %08x->%08x, NL %08x C %08x,%08x\n",
  56. lli, lli->src_addr, lli->dst_addr, lli->next_lli,
  57. lli->control0, lli->control1);
  58. }
  59. static void dbg_showbuffs(struct s3c2410_dma_chan *chan)
  60. {
  61. struct s3c64xx_dma_buff *ptr;
  62. struct s3c64xx_dma_buff *end;
  63. pr_debug("DMA%d: buffs next %p, curr %p, end %p\n",
  64. chan->number, chan->next, chan->curr, chan->end);
  65. ptr = chan->next;
  66. end = chan->end;
  67. if (debug_show_buffs) {
  68. for (; ptr != NULL; ptr = ptr->next) {
  69. pr_debug("DMA%d: %08x ",
  70. chan->number, ptr->lli_dma);
  71. show_lli(ptr->lli);
  72. }
  73. }
  74. }
  75. /* End of Debug */
  76. static struct s3c2410_dma_chan *s3c64xx_dma_map_channel(unsigned int channel)
  77. {
  78. struct s3c2410_dma_chan *chan;
  79. unsigned int start, offs;
  80. start = 0;
  81. if (channel >= DMACH_PCM1_TX)
  82. start = 8;
  83. for (offs = 0; offs < 8; offs++) {
  84. chan = &s3c2410_chans[start + offs];
  85. if (!chan->in_use)
  86. goto found;
  87. }
  88. return NULL;
  89. found:
  90. s3c_dma_chan_map[channel] = chan;
  91. return chan;
  92. }
  93. int s3c2410_dma_config(unsigned int channel, int xferunit)
  94. {
  95. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  96. if (chan == NULL)
  97. return -EINVAL;
  98. switch (xferunit) {
  99. case 1:
  100. chan->hw_width = 0;
  101. break;
  102. case 2:
  103. chan->hw_width = 1;
  104. break;
  105. case 4:
  106. chan->hw_width = 2;
  107. break;
  108. default:
  109. printk(KERN_ERR "%s: illegal width %d\n", __func__, xferunit);
  110. return -EINVAL;
  111. }
  112. return 0;
  113. }
  114. EXPORT_SYMBOL(s3c2410_dma_config);
  115. static void s3c64xx_dma_fill_lli(struct s3c2410_dma_chan *chan,
  116. struct pl080s_lli *lli,
  117. dma_addr_t data, int size)
  118. {
  119. dma_addr_t src, dst;
  120. u32 control0, control1;
  121. switch (chan->source) {
  122. case S3C2410_DMASRC_HW:
  123. src = chan->dev_addr;
  124. dst = data;
  125. control0 = PL080_CONTROL_SRC_AHB2;
  126. control0 |= (u32)chan->hw_width << PL080_CONTROL_SWIDTH_SHIFT;
  127. control0 |= 2 << PL080_CONTROL_DWIDTH_SHIFT;
  128. control0 |= PL080_CONTROL_DST_INCR;
  129. break;
  130. case S3C2410_DMASRC_MEM:
  131. src = data;
  132. dst = chan->dev_addr;
  133. control0 = PL080_CONTROL_DST_AHB2;
  134. control0 |= (u32)chan->hw_width << PL080_CONTROL_DWIDTH_SHIFT;
  135. control0 |= 2 << PL080_CONTROL_SWIDTH_SHIFT;
  136. control0 |= PL080_CONTROL_SRC_INCR;
  137. break;
  138. default:
  139. BUG();
  140. }
  141. /* note, we do not currently setup any of the burst controls */
  142. control1 = size >> chan->hw_width; /* size in no of xfers */
  143. control0 |= PL080_CONTROL_PROT_SYS; /* always in priv. mode */
  144. control0 |= PL080_CONTROL_TC_IRQ_EN; /* always fire IRQ */
  145. lli->src_addr = src;
  146. lli->dst_addr = dst;
  147. lli->next_lli = 0;
  148. lli->control0 = control0;
  149. lli->control1 = control1;
  150. }
  151. static void s3c64xx_lli_to_regs(struct s3c2410_dma_chan *chan,
  152. struct pl080s_lli *lli)
  153. {
  154. void __iomem *regs = chan->regs;
  155. pr_debug("%s: LLI %p => regs\n", __func__, lli);
  156. show_lli(lli);
  157. writel(lli->src_addr, regs + PL080_CH_SRC_ADDR);
  158. writel(lli->dst_addr, regs + PL080_CH_DST_ADDR);
  159. writel(lli->next_lli, regs + PL080_CH_LLI);
  160. writel(lli->control0, regs + PL080_CH_CONTROL);
  161. writel(lli->control1, regs + PL080S_CH_CONTROL2);
  162. }
  163. static int s3c64xx_dma_start(struct s3c2410_dma_chan *chan)
  164. {
  165. struct s3c64xx_dmac *dmac = chan->dmac;
  166. u32 config;
  167. u32 bit = chan->bit;
  168. dbg_showchan(chan);
  169. pr_debug("%s: clearing interrupts\n", __func__);
  170. /* clear interrupts */
  171. writel(bit, dmac->regs + PL080_TC_CLEAR);
  172. writel(bit, dmac->regs + PL080_ERR_CLEAR);
  173. pr_debug("%s: starting channel\n", __func__);
  174. config = readl(chan->regs + PL080S_CH_CONFIG);
  175. config |= PL080_CONFIG_ENABLE;
  176. pr_debug("%s: writing config %08x\n", __func__, config);
  177. writel(config, chan->regs + PL080S_CH_CONFIG);
  178. return 0;
  179. }
  180. static int s3c64xx_dma_stop(struct s3c2410_dma_chan *chan)
  181. {
  182. u32 config;
  183. int timeout;
  184. pr_debug("%s: stopping channel\n", __func__);
  185. dbg_showchan(chan);
  186. config = readl(chan->regs + PL080S_CH_CONFIG);
  187. config |= PL080_CONFIG_HALT;
  188. writel(config, chan->regs + PL080S_CH_CONFIG);
  189. timeout = 1000;
  190. do {
  191. config = readl(chan->regs + PL080S_CH_CONFIG);
  192. pr_debug("%s: %d - config %08x\n", __func__, timeout, config);
  193. if (config & PL080_CONFIG_ACTIVE)
  194. udelay(10);
  195. else
  196. break;
  197. } while (--timeout > 0);
  198. if (config & PL080_CONFIG_ACTIVE) {
  199. printk(KERN_ERR "%s: channel still active\n", __func__);
  200. return -EFAULT;
  201. }
  202. config = readl(chan->regs + PL080S_CH_CONFIG);
  203. config &= ~PL080_CONFIG_ENABLE;
  204. writel(config, chan->regs + PL080S_CH_CONFIG);
  205. return 0;
  206. }
  207. static inline void s3c64xx_dma_bufffdone(struct s3c2410_dma_chan *chan,
  208. struct s3c64xx_dma_buff *buf,
  209. enum s3c2410_dma_buffresult result)
  210. {
  211. if (chan->callback_fn != NULL)
  212. (chan->callback_fn)(chan, buf->pw, 0, result);
  213. }
  214. static void s3c64xx_dma_freebuff(struct s3c64xx_dma_buff *buff)
  215. {
  216. dma_pool_free(dma_pool, buff->lli, buff->lli_dma);
  217. kfree(buff);
  218. }
  219. static int s3c64xx_dma_flush(struct s3c2410_dma_chan *chan)
  220. {
  221. struct s3c64xx_dma_buff *buff, *next;
  222. u32 config;
  223. dbg_showchan(chan);
  224. pr_debug("%s: flushing channel\n", __func__);
  225. config = readl(chan->regs + PL080S_CH_CONFIG);
  226. config &= ~PL080_CONFIG_ENABLE;
  227. writel(config, chan->regs + PL080S_CH_CONFIG);
  228. /* dump all the buffers associated with this channel */
  229. for (buff = chan->curr; buff != NULL; buff = next) {
  230. next = buff->next;
  231. pr_debug("%s: buff %p (next %p)\n", __func__, buff, buff->next);
  232. s3c64xx_dma_bufffdone(chan, buff, S3C2410_RES_ABORT);
  233. s3c64xx_dma_freebuff(buff);
  234. }
  235. chan->curr = chan->next = chan->end = NULL;
  236. return 0;
  237. }
  238. int s3c2410_dma_ctrl(unsigned int channel, enum s3c2410_chan_op op)
  239. {
  240. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  241. WARN_ON(!chan);
  242. if (!chan)
  243. return -EINVAL;
  244. switch (op) {
  245. case S3C2410_DMAOP_START:
  246. return s3c64xx_dma_start(chan);
  247. case S3C2410_DMAOP_STOP:
  248. return s3c64xx_dma_stop(chan);
  249. case S3C2410_DMAOP_FLUSH:
  250. return s3c64xx_dma_flush(chan);
  251. /* belive PAUSE/RESUME are no-ops */
  252. case S3C2410_DMAOP_PAUSE:
  253. case S3C2410_DMAOP_RESUME:
  254. case S3C2410_DMAOP_STARTED:
  255. case S3C2410_DMAOP_TIMEOUT:
  256. return 0;
  257. }
  258. return -ENOENT;
  259. }
  260. EXPORT_SYMBOL(s3c2410_dma_ctrl);
  261. /* s3c2410_dma_enque
  262. *
  263. */
  264. int s3c2410_dma_enqueue(unsigned int channel, void *id,
  265. dma_addr_t data, int size)
  266. {
  267. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  268. struct s3c64xx_dma_buff *next;
  269. struct s3c64xx_dma_buff *buff;
  270. struct pl080s_lli *lli;
  271. unsigned long flags;
  272. int ret;
  273. WARN_ON(!chan);
  274. if (!chan)
  275. return -EINVAL;
  276. buff = kzalloc(sizeof(struct s3c64xx_dma_buff), GFP_ATOMIC);
  277. if (!buff) {
  278. printk(KERN_ERR "%s: no memory for buffer\n", __func__);
  279. return -ENOMEM;
  280. }
  281. lli = dma_pool_alloc(dma_pool, GFP_ATOMIC, &buff->lli_dma);
  282. if (!lli) {
  283. printk(KERN_ERR "%s: no memory for lli\n", __func__);
  284. ret = -ENOMEM;
  285. goto err_buff;
  286. }
  287. pr_debug("%s: buff %p, dp %08x lli (%p, %08x) %d\n",
  288. __func__, buff, data, lli, (u32)buff->lli_dma, size);
  289. buff->lli = lli;
  290. buff->pw = id;
  291. s3c64xx_dma_fill_lli(chan, lli, data, size);
  292. local_irq_save(flags);
  293. if ((next = chan->next) != NULL) {
  294. struct s3c64xx_dma_buff *end = chan->end;
  295. struct pl080s_lli *endlli = end->lli;
  296. pr_debug("enquing onto channel\n");
  297. end->next = buff;
  298. endlli->next_lli = buff->lli_dma;
  299. if (chan->flags & S3C2410_DMAF_CIRCULAR) {
  300. struct s3c64xx_dma_buff *curr = chan->curr;
  301. lli->next_lli = curr->lli_dma;
  302. }
  303. if (next == chan->curr) {
  304. writel(buff->lli_dma, chan->regs + PL080_CH_LLI);
  305. chan->next = buff;
  306. }
  307. show_lli(endlli);
  308. chan->end = buff;
  309. } else {
  310. pr_debug("enquing onto empty channel\n");
  311. chan->curr = buff;
  312. chan->next = buff;
  313. chan->end = buff;
  314. s3c64xx_lli_to_regs(chan, lli);
  315. }
  316. local_irq_restore(flags);
  317. show_lli(lli);
  318. dbg_showchan(chan);
  319. dbg_showbuffs(chan);
  320. return 0;
  321. err_buff:
  322. kfree(buff);
  323. return ret;
  324. }
  325. EXPORT_SYMBOL(s3c2410_dma_enqueue);
  326. int s3c2410_dma_devconfig(int channel,
  327. enum s3c2410_dmasrc source,
  328. unsigned long devaddr)
  329. {
  330. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  331. u32 peripheral;
  332. u32 config = 0;
  333. pr_debug("%s: channel %d, source %d, dev %08lx, chan %p\n",
  334. __func__, channel, source, devaddr, chan);
  335. WARN_ON(!chan);
  336. if (!chan)
  337. return -EINVAL;
  338. peripheral = (chan->peripheral & 0xf);
  339. chan->source = source;
  340. chan->dev_addr = devaddr;
  341. pr_debug("%s: peripheral %d\n", __func__, peripheral);
  342. switch (source) {
  343. case S3C2410_DMASRC_HW:
  344. config = 2 << PL080_CONFIG_FLOW_CONTROL_SHIFT;
  345. config |= peripheral << PL080_CONFIG_SRC_SEL_SHIFT;
  346. break;
  347. case S3C2410_DMASRC_MEM:
  348. config = 1 << PL080_CONFIG_FLOW_CONTROL_SHIFT;
  349. config |= peripheral << PL080_CONFIG_DST_SEL_SHIFT;
  350. break;
  351. default:
  352. printk(KERN_ERR "%s: bad source\n", __func__);
  353. return -EINVAL;
  354. }
  355. /* allow TC and ERR interrupts */
  356. config |= PL080_CONFIG_TC_IRQ_MASK;
  357. config |= PL080_CONFIG_ERR_IRQ_MASK;
  358. pr_debug("%s: config %08x\n", __func__, config);
  359. writel(config, chan->regs + PL080S_CH_CONFIG);
  360. return 0;
  361. }
  362. EXPORT_SYMBOL(s3c2410_dma_devconfig);
  363. int s3c2410_dma_getposition(unsigned int channel,
  364. dma_addr_t *src, dma_addr_t *dst)
  365. {
  366. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  367. WARN_ON(!chan);
  368. if (!chan)
  369. return -EINVAL;
  370. if (src != NULL)
  371. *src = readl(chan->regs + PL080_CH_SRC_ADDR);
  372. if (dst != NULL)
  373. *dst = readl(chan->regs + PL080_CH_DST_ADDR);
  374. return 0;
  375. }
  376. EXPORT_SYMBOL(s3c2410_dma_getposition);
  377. /* s3c2410_request_dma
  378. *
  379. * get control of an dma channel
  380. */
  381. int s3c2410_dma_request(unsigned int channel,
  382. struct s3c2410_dma_client *client,
  383. void *dev)
  384. {
  385. struct s3c2410_dma_chan *chan;
  386. unsigned long flags;
  387. pr_debug("dma%d: s3c2410_request_dma: client=%s, dev=%p\n",
  388. channel, client->name, dev);
  389. local_irq_save(flags);
  390. chan = s3c64xx_dma_map_channel(channel);
  391. if (chan == NULL) {
  392. local_irq_restore(flags);
  393. return -EBUSY;
  394. }
  395. dbg_showchan(chan);
  396. chan->client = client;
  397. chan->in_use = 1;
  398. chan->peripheral = channel;
  399. local_irq_restore(flags);
  400. /* need to setup */
  401. pr_debug("%s: channel initialised, %p\n", __func__, chan);
  402. return chan->number | DMACH_LOW_LEVEL;
  403. }
  404. EXPORT_SYMBOL(s3c2410_dma_request);
  405. /* s3c2410_dma_free
  406. *
  407. * release the given channel back to the system, will stop and flush
  408. * any outstanding transfers, and ensure the channel is ready for the
  409. * next claimant.
  410. *
  411. * Note, although a warning is currently printed if the freeing client
  412. * info is not the same as the registrant's client info, the free is still
  413. * allowed to go through.
  414. */
  415. int s3c2410_dma_free(unsigned int channel, struct s3c2410_dma_client *client)
  416. {
  417. struct s3c2410_dma_chan *chan = s3c_dma_lookup_channel(channel);
  418. unsigned long flags;
  419. if (chan == NULL)
  420. return -EINVAL;
  421. local_irq_save(flags);
  422. if (chan->client != client) {
  423. printk(KERN_WARNING "dma%d: possible free from different client (channel %p, passed %p)\n",
  424. channel, chan->client, client);
  425. }
  426. /* sort out stopping and freeing the channel */
  427. chan->client = NULL;
  428. chan->in_use = 0;
  429. if (!(channel & DMACH_LOW_LEVEL))
  430. s3c_dma_chan_map[channel] = NULL;
  431. local_irq_restore(flags);
  432. return 0;
  433. }
  434. EXPORT_SYMBOL(s3c2410_dma_free);
  435. static void s3c64xx_dma_tcirq(struct s3c64xx_dmac *dmac, int offs)
  436. {
  437. struct s3c2410_dma_chan *chan = dmac->channels + offs;
  438. /* note, we currently do not bother to work out which buffer
  439. * or buffers have been completed since the last tc-irq. */
  440. if (chan->callback_fn)
  441. (chan->callback_fn)(chan, chan->curr->pw, 0, S3C2410_RES_OK);
  442. }
  443. static void s3c64xx_dma_errirq(struct s3c64xx_dmac *dmac, int offs)
  444. {
  445. printk(KERN_DEBUG "%s: offs %d\n", __func__, offs);
  446. }
  447. static irqreturn_t s3c64xx_dma_irq(int irq, void *pw)
  448. {
  449. struct s3c64xx_dmac *dmac = pw;
  450. u32 tcstat, errstat;
  451. u32 bit;
  452. int offs;
  453. tcstat = readl(dmac->regs + PL080_TC_STATUS);
  454. errstat = readl(dmac->regs + PL080_ERR_STATUS);
  455. for (offs = 0, bit = 1; offs < 8; offs++, bit <<= 1) {
  456. if (tcstat & bit) {
  457. writel(bit, dmac->regs + PL080_TC_CLEAR);
  458. s3c64xx_dma_tcirq(dmac, offs);
  459. }
  460. if (errstat & bit) {
  461. s3c64xx_dma_errirq(dmac, offs);
  462. writel(bit, dmac->regs + PL080_ERR_CLEAR);
  463. }
  464. }
  465. return IRQ_HANDLED;
  466. }
  467. static struct sysdev_class dma_sysclass = {
  468. .name = "s3c64xx-dma",
  469. };
  470. static int s3c64xx_dma_init1(int chno, enum dma_ch chbase,
  471. int irq, unsigned int base)
  472. {
  473. struct s3c2410_dma_chan *chptr = &s3c2410_chans[chno];
  474. struct s3c64xx_dmac *dmac;
  475. char clkname[16];
  476. void __iomem *regs;
  477. void __iomem *regptr;
  478. int err, ch;
  479. dmac = kzalloc(sizeof(struct s3c64xx_dmac), GFP_KERNEL);
  480. if (!dmac) {
  481. printk(KERN_ERR "%s: failed to alloc mem\n", __func__);
  482. return -ENOMEM;
  483. }
  484. dmac->sysdev.id = chno / 8;
  485. dmac->sysdev.cls = &dma_sysclass;
  486. err = sysdev_register(&dmac->sysdev);
  487. if (err) {
  488. printk(KERN_ERR "%s: failed to register sysdevice\n", __func__);
  489. goto err_alloc;
  490. }
  491. regs = ioremap(base, 0x200);
  492. if (!regs) {
  493. printk(KERN_ERR "%s: failed to ioremap()\n", __func__);
  494. err = -ENXIO;
  495. goto err_dev;
  496. }
  497. snprintf(clkname, sizeof(clkname), "dma%d", dmac->sysdev.id);
  498. dmac->clk = clk_get(NULL, clkname);
  499. if (IS_ERR(dmac->clk)) {
  500. printk(KERN_ERR "%s: failed to get clock %s\n", __func__, clkname);
  501. err = PTR_ERR(dmac->clk);
  502. goto err_map;
  503. }
  504. clk_enable(dmac->clk);
  505. dmac->regs = regs;
  506. dmac->chanbase = chbase;
  507. dmac->channels = chptr;
  508. err = request_irq(irq, s3c64xx_dma_irq, 0, "DMA", dmac);
  509. if (err < 0) {
  510. printk(KERN_ERR "%s: failed to get irq\n", __func__);
  511. goto err_clk;
  512. }
  513. regptr = regs + PL080_Cx_BASE(0);
  514. for (ch = 0; ch < 8; ch++, chno++, chptr++) {
  515. printk(KERN_INFO "%s: registering DMA %d (%p)\n",
  516. __func__, chno, regptr);
  517. chptr->bit = 1 << ch;
  518. chptr->number = chno;
  519. chptr->dmac = dmac;
  520. chptr->regs = regptr;
  521. regptr += PL008_Cx_STRIDE;
  522. }
  523. /* for the moment, permanently enable the controller */
  524. writel(PL080_CONFIG_ENABLE, regs + PL080_CONFIG);
  525. printk(KERN_INFO "PL080: IRQ %d, at %p\n", irq, regs);
  526. return 0;
  527. err_clk:
  528. clk_disable(dmac->clk);
  529. clk_put(dmac->clk);
  530. err_map:
  531. iounmap(regs);
  532. err_dev:
  533. sysdev_unregister(&dmac->sysdev);
  534. err_alloc:
  535. kfree(dmac);
  536. return err;
  537. }
  538. static int __init s3c64xx_dma_init(void)
  539. {
  540. int ret;
  541. printk(KERN_INFO "%s: Registering DMA channels\n", __func__);
  542. dma_pool = dma_pool_create("DMA-LLI", NULL, sizeof(struct pl080s_lli), 16, 0);
  543. if (!dma_pool) {
  544. printk(KERN_ERR "%s: failed to create pool\n", __func__);
  545. return -ENOMEM;
  546. }
  547. ret = sysdev_class_register(&dma_sysclass);
  548. if (ret) {
  549. printk(KERN_ERR "%s: failed to create sysclass\n", __func__);
  550. return -ENOMEM;
  551. }
  552. /* Set all DMA configuration to be DMA, not SDMA */
  553. writel(0xffffff, S3C_SYSREG(0x110));
  554. /* Register standard DMA controlers */
  555. s3c64xx_dma_init1(0, DMACH_UART0, IRQ_DMA0, 0x75000000);
  556. s3c64xx_dma_init1(8, DMACH_PCM1_TX, IRQ_DMA1, 0x75100000);
  557. return 0;
  558. }
  559. arch_initcall(s3c64xx_dma_init);