tegra20-apb-dma.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609
  1. /*
  2. * DMA driver for Nvidia's Tegra20 APB DMA controller.
  3. *
  4. * Copyright (c) 2012-2013, NVIDIA CORPORATION. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <linux/bitops.h>
  19. #include <linux/clk.h>
  20. #include <linux/delay.h>
  21. #include <linux/dmaengine.h>
  22. #include <linux/dma-mapping.h>
  23. #include <linux/err.h>
  24. #include <linux/init.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/io.h>
  27. #include <linux/mm.h>
  28. #include <linux/module.h>
  29. #include <linux/of.h>
  30. #include <linux/of_device.h>
  31. #include <linux/of_dma.h>
  32. #include <linux/platform_device.h>
  33. #include <linux/pm.h>
  34. #include <linux/pm_runtime.h>
  35. #include <linux/reset.h>
  36. #include <linux/slab.h>
  37. #include "dmaengine.h"
  38. #define TEGRA_APBDMA_GENERAL 0x0
  39. #define TEGRA_APBDMA_GENERAL_ENABLE BIT(31)
  40. #define TEGRA_APBDMA_CONTROL 0x010
  41. #define TEGRA_APBDMA_IRQ_MASK 0x01c
  42. #define TEGRA_APBDMA_IRQ_MASK_SET 0x020
  43. /* CSR register */
  44. #define TEGRA_APBDMA_CHAN_CSR 0x00
  45. #define TEGRA_APBDMA_CSR_ENB BIT(31)
  46. #define TEGRA_APBDMA_CSR_IE_EOC BIT(30)
  47. #define TEGRA_APBDMA_CSR_HOLD BIT(29)
  48. #define TEGRA_APBDMA_CSR_DIR BIT(28)
  49. #define TEGRA_APBDMA_CSR_ONCE BIT(27)
  50. #define TEGRA_APBDMA_CSR_FLOW BIT(21)
  51. #define TEGRA_APBDMA_CSR_REQ_SEL_SHIFT 16
  52. #define TEGRA_APBDMA_CSR_REQ_SEL_MASK 0x1F
  53. #define TEGRA_APBDMA_CSR_WCOUNT_MASK 0xFFFC
  54. /* STATUS register */
  55. #define TEGRA_APBDMA_CHAN_STATUS 0x004
  56. #define TEGRA_APBDMA_STATUS_BUSY BIT(31)
  57. #define TEGRA_APBDMA_STATUS_ISE_EOC BIT(30)
  58. #define TEGRA_APBDMA_STATUS_HALT BIT(29)
  59. #define TEGRA_APBDMA_STATUS_PING_PONG BIT(28)
  60. #define TEGRA_APBDMA_STATUS_COUNT_SHIFT 2
  61. #define TEGRA_APBDMA_STATUS_COUNT_MASK 0xFFFC
  62. #define TEGRA_APBDMA_CHAN_CSRE 0x00C
  63. #define TEGRA_APBDMA_CHAN_CSRE_PAUSE (1 << 31)
  64. /* AHB memory address */
  65. #define TEGRA_APBDMA_CHAN_AHBPTR 0x010
  66. /* AHB sequence register */
  67. #define TEGRA_APBDMA_CHAN_AHBSEQ 0x14
  68. #define TEGRA_APBDMA_AHBSEQ_INTR_ENB BIT(31)
  69. #define TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_8 (0 << 28)
  70. #define TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_16 (1 << 28)
  71. #define TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32 (2 << 28)
  72. #define TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_64 (3 << 28)
  73. #define TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_128 (4 << 28)
  74. #define TEGRA_APBDMA_AHBSEQ_DATA_SWAP BIT(27)
  75. #define TEGRA_APBDMA_AHBSEQ_BURST_1 (4 << 24)
  76. #define TEGRA_APBDMA_AHBSEQ_BURST_4 (5 << 24)
  77. #define TEGRA_APBDMA_AHBSEQ_BURST_8 (6 << 24)
  78. #define TEGRA_APBDMA_AHBSEQ_DBL_BUF BIT(19)
  79. #define TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT 16
  80. #define TEGRA_APBDMA_AHBSEQ_WRAP_NONE 0
  81. /* APB address */
  82. #define TEGRA_APBDMA_CHAN_APBPTR 0x018
  83. /* APB sequence register */
  84. #define TEGRA_APBDMA_CHAN_APBSEQ 0x01c
  85. #define TEGRA_APBDMA_APBSEQ_BUS_WIDTH_8 (0 << 28)
  86. #define TEGRA_APBDMA_APBSEQ_BUS_WIDTH_16 (1 << 28)
  87. #define TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32 (2 << 28)
  88. #define TEGRA_APBDMA_APBSEQ_BUS_WIDTH_64 (3 << 28)
  89. #define TEGRA_APBDMA_APBSEQ_BUS_WIDTH_128 (4 << 28)
  90. #define TEGRA_APBDMA_APBSEQ_DATA_SWAP BIT(27)
  91. #define TEGRA_APBDMA_APBSEQ_WRAP_WORD_1 (1 << 16)
  92. /* Tegra148 specific registers */
  93. #define TEGRA_APBDMA_CHAN_WCOUNT 0x20
  94. #define TEGRA_APBDMA_CHAN_WORD_TRANSFER 0x24
  95. /*
  96. * If any burst is in flight and DMA paused then this is the time to complete
  97. * on-flight burst and update DMA status register.
  98. */
  99. #define TEGRA_APBDMA_BURST_COMPLETE_TIME 20
  100. /* Channel base address offset from APBDMA base address */
  101. #define TEGRA_APBDMA_CHANNEL_BASE_ADD_OFFSET 0x1000
  102. #define TEGRA_APBDMA_SLAVE_ID_INVALID (TEGRA_APBDMA_CSR_REQ_SEL_MASK + 1)
  103. struct tegra_dma;
  104. /*
  105. * tegra_dma_chip_data Tegra chip specific DMA data
  106. * @nr_channels: Number of channels available in the controller.
  107. * @channel_reg_size: Channel register size/stride.
  108. * @max_dma_count: Maximum DMA transfer count supported by DMA controller.
  109. * @support_channel_pause: Support channel wise pause of dma.
  110. * @support_separate_wcount_reg: Support separate word count register.
  111. */
  112. struct tegra_dma_chip_data {
  113. int nr_channels;
  114. int channel_reg_size;
  115. int max_dma_count;
  116. bool support_channel_pause;
  117. bool support_separate_wcount_reg;
  118. };
  119. /* DMA channel registers */
  120. struct tegra_dma_channel_regs {
  121. unsigned long csr;
  122. unsigned long ahb_ptr;
  123. unsigned long apb_ptr;
  124. unsigned long ahb_seq;
  125. unsigned long apb_seq;
  126. unsigned long wcount;
  127. };
  128. /*
  129. * tegra_dma_sg_req: Dma request details to configure hardware. This
  130. * contains the details for one transfer to configure DMA hw.
  131. * The client's request for data transfer can be broken into multiple
  132. * sub-transfer as per requester details and hw support.
  133. * This sub transfer get added in the list of transfer and point to Tegra
  134. * DMA descriptor which manages the transfer details.
  135. */
  136. struct tegra_dma_sg_req {
  137. struct tegra_dma_channel_regs ch_regs;
  138. int req_len;
  139. bool configured;
  140. bool last_sg;
  141. struct list_head node;
  142. struct tegra_dma_desc *dma_desc;
  143. };
  144. /*
  145. * tegra_dma_desc: Tegra DMA descriptors which manages the client requests.
  146. * This descriptor keep track of transfer status, callbacks and request
  147. * counts etc.
  148. */
  149. struct tegra_dma_desc {
  150. struct dma_async_tx_descriptor txd;
  151. int bytes_requested;
  152. int bytes_transferred;
  153. enum dma_status dma_status;
  154. struct list_head node;
  155. struct list_head tx_list;
  156. struct list_head cb_node;
  157. int cb_count;
  158. };
  159. struct tegra_dma_channel;
  160. typedef void (*dma_isr_handler)(struct tegra_dma_channel *tdc,
  161. bool to_terminate);
  162. /* tegra_dma_channel: Channel specific information */
  163. struct tegra_dma_channel {
  164. struct dma_chan dma_chan;
  165. char name[30];
  166. bool config_init;
  167. int id;
  168. int irq;
  169. void __iomem *chan_addr;
  170. spinlock_t lock;
  171. bool busy;
  172. struct tegra_dma *tdma;
  173. bool cyclic;
  174. /* Different lists for managing the requests */
  175. struct list_head free_sg_req;
  176. struct list_head pending_sg_req;
  177. struct list_head free_dma_desc;
  178. struct list_head cb_desc;
  179. /* ISR handler and tasklet for bottom half of isr handling */
  180. dma_isr_handler isr_handler;
  181. struct tasklet_struct tasklet;
  182. /* Channel-slave specific configuration */
  183. unsigned int slave_id;
  184. struct dma_slave_config dma_sconfig;
  185. struct tegra_dma_channel_regs channel_reg;
  186. };
  187. /* tegra_dma: Tegra DMA specific information */
  188. struct tegra_dma {
  189. struct dma_device dma_dev;
  190. struct device *dev;
  191. struct clk *dma_clk;
  192. struct reset_control *rst;
  193. spinlock_t global_lock;
  194. void __iomem *base_addr;
  195. const struct tegra_dma_chip_data *chip_data;
  196. /*
  197. * Counter for managing global pausing of the DMA controller.
  198. * Only applicable for devices that don't support individual
  199. * channel pausing.
  200. */
  201. u32 global_pause_count;
  202. /* Some register need to be cache before suspend */
  203. u32 reg_gen;
  204. /* Last member of the structure */
  205. struct tegra_dma_channel channels[0];
  206. };
  207. static inline void tdma_write(struct tegra_dma *tdma, u32 reg, u32 val)
  208. {
  209. writel(val, tdma->base_addr + reg);
  210. }
  211. static inline u32 tdma_read(struct tegra_dma *tdma, u32 reg)
  212. {
  213. return readl(tdma->base_addr + reg);
  214. }
  215. static inline void tdc_write(struct tegra_dma_channel *tdc,
  216. u32 reg, u32 val)
  217. {
  218. writel(val, tdc->chan_addr + reg);
  219. }
  220. static inline u32 tdc_read(struct tegra_dma_channel *tdc, u32 reg)
  221. {
  222. return readl(tdc->chan_addr + reg);
  223. }
  224. static inline struct tegra_dma_channel *to_tegra_dma_chan(struct dma_chan *dc)
  225. {
  226. return container_of(dc, struct tegra_dma_channel, dma_chan);
  227. }
  228. static inline struct tegra_dma_desc *txd_to_tegra_dma_desc(
  229. struct dma_async_tx_descriptor *td)
  230. {
  231. return container_of(td, struct tegra_dma_desc, txd);
  232. }
  233. static inline struct device *tdc2dev(struct tegra_dma_channel *tdc)
  234. {
  235. return &tdc->dma_chan.dev->device;
  236. }
  237. static dma_cookie_t tegra_dma_tx_submit(struct dma_async_tx_descriptor *tx);
  238. static int tegra_dma_runtime_suspend(struct device *dev);
  239. static int tegra_dma_runtime_resume(struct device *dev);
  240. /* Get DMA desc from free list, if not there then allocate it. */
  241. static struct tegra_dma_desc *tegra_dma_desc_get(
  242. struct tegra_dma_channel *tdc)
  243. {
  244. struct tegra_dma_desc *dma_desc;
  245. unsigned long flags;
  246. spin_lock_irqsave(&tdc->lock, flags);
  247. /* Do not allocate if desc are waiting for ack */
  248. list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {
  249. if (async_tx_test_ack(&dma_desc->txd)) {
  250. list_del(&dma_desc->node);
  251. spin_unlock_irqrestore(&tdc->lock, flags);
  252. dma_desc->txd.flags = 0;
  253. return dma_desc;
  254. }
  255. }
  256. spin_unlock_irqrestore(&tdc->lock, flags);
  257. /* Allocate DMA desc */
  258. dma_desc = kzalloc(sizeof(*dma_desc), GFP_NOWAIT);
  259. if (!dma_desc)
  260. return NULL;
  261. dma_async_tx_descriptor_init(&dma_desc->txd, &tdc->dma_chan);
  262. dma_desc->txd.tx_submit = tegra_dma_tx_submit;
  263. dma_desc->txd.flags = 0;
  264. return dma_desc;
  265. }
  266. static void tegra_dma_desc_put(struct tegra_dma_channel *tdc,
  267. struct tegra_dma_desc *dma_desc)
  268. {
  269. unsigned long flags;
  270. spin_lock_irqsave(&tdc->lock, flags);
  271. if (!list_empty(&dma_desc->tx_list))
  272. list_splice_init(&dma_desc->tx_list, &tdc->free_sg_req);
  273. list_add_tail(&dma_desc->node, &tdc->free_dma_desc);
  274. spin_unlock_irqrestore(&tdc->lock, flags);
  275. }
  276. static struct tegra_dma_sg_req *tegra_dma_sg_req_get(
  277. struct tegra_dma_channel *tdc)
  278. {
  279. struct tegra_dma_sg_req *sg_req = NULL;
  280. unsigned long flags;
  281. spin_lock_irqsave(&tdc->lock, flags);
  282. if (!list_empty(&tdc->free_sg_req)) {
  283. sg_req = list_first_entry(&tdc->free_sg_req,
  284. typeof(*sg_req), node);
  285. list_del(&sg_req->node);
  286. spin_unlock_irqrestore(&tdc->lock, flags);
  287. return sg_req;
  288. }
  289. spin_unlock_irqrestore(&tdc->lock, flags);
  290. sg_req = kzalloc(sizeof(struct tegra_dma_sg_req), GFP_NOWAIT);
  291. return sg_req;
  292. }
  293. static int tegra_dma_slave_config(struct dma_chan *dc,
  294. struct dma_slave_config *sconfig)
  295. {
  296. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  297. if (!list_empty(&tdc->pending_sg_req)) {
  298. dev_err(tdc2dev(tdc), "Configuration not allowed\n");
  299. return -EBUSY;
  300. }
  301. memcpy(&tdc->dma_sconfig, sconfig, sizeof(*sconfig));
  302. if (tdc->slave_id == TEGRA_APBDMA_SLAVE_ID_INVALID &&
  303. sconfig->device_fc) {
  304. if (sconfig->slave_id > TEGRA_APBDMA_CSR_REQ_SEL_MASK)
  305. return -EINVAL;
  306. tdc->slave_id = sconfig->slave_id;
  307. }
  308. tdc->config_init = true;
  309. return 0;
  310. }
  311. static void tegra_dma_global_pause(struct tegra_dma_channel *tdc,
  312. bool wait_for_burst_complete)
  313. {
  314. struct tegra_dma *tdma = tdc->tdma;
  315. spin_lock(&tdma->global_lock);
  316. if (tdc->tdma->global_pause_count == 0) {
  317. tdma_write(tdma, TEGRA_APBDMA_GENERAL, 0);
  318. if (wait_for_burst_complete)
  319. udelay(TEGRA_APBDMA_BURST_COMPLETE_TIME);
  320. }
  321. tdc->tdma->global_pause_count++;
  322. spin_unlock(&tdma->global_lock);
  323. }
  324. static void tegra_dma_global_resume(struct tegra_dma_channel *tdc)
  325. {
  326. struct tegra_dma *tdma = tdc->tdma;
  327. spin_lock(&tdma->global_lock);
  328. if (WARN_ON(tdc->tdma->global_pause_count == 0))
  329. goto out;
  330. if (--tdc->tdma->global_pause_count == 0)
  331. tdma_write(tdma, TEGRA_APBDMA_GENERAL,
  332. TEGRA_APBDMA_GENERAL_ENABLE);
  333. out:
  334. spin_unlock(&tdma->global_lock);
  335. }
  336. static void tegra_dma_pause(struct tegra_dma_channel *tdc,
  337. bool wait_for_burst_complete)
  338. {
  339. struct tegra_dma *tdma = tdc->tdma;
  340. if (tdma->chip_data->support_channel_pause) {
  341. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSRE,
  342. TEGRA_APBDMA_CHAN_CSRE_PAUSE);
  343. if (wait_for_burst_complete)
  344. udelay(TEGRA_APBDMA_BURST_COMPLETE_TIME);
  345. } else {
  346. tegra_dma_global_pause(tdc, wait_for_burst_complete);
  347. }
  348. }
  349. static void tegra_dma_resume(struct tegra_dma_channel *tdc)
  350. {
  351. struct tegra_dma *tdma = tdc->tdma;
  352. if (tdma->chip_data->support_channel_pause) {
  353. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSRE, 0);
  354. } else {
  355. tegra_dma_global_resume(tdc);
  356. }
  357. }
  358. static void tegra_dma_stop(struct tegra_dma_channel *tdc)
  359. {
  360. u32 csr;
  361. u32 status;
  362. /* Disable interrupts */
  363. csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR);
  364. csr &= ~TEGRA_APBDMA_CSR_IE_EOC;
  365. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, csr);
  366. /* Disable DMA */
  367. csr &= ~TEGRA_APBDMA_CSR_ENB;
  368. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, csr);
  369. /* Clear interrupt status if it is there */
  370. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  371. if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
  372. dev_dbg(tdc2dev(tdc), "%s():clearing interrupt\n", __func__);
  373. tdc_write(tdc, TEGRA_APBDMA_CHAN_STATUS, status);
  374. }
  375. tdc->busy = false;
  376. }
  377. static void tegra_dma_start(struct tegra_dma_channel *tdc,
  378. struct tegra_dma_sg_req *sg_req)
  379. {
  380. struct tegra_dma_channel_regs *ch_regs = &sg_req->ch_regs;
  381. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR, ch_regs->csr);
  382. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBSEQ, ch_regs->apb_seq);
  383. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, ch_regs->apb_ptr);
  384. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_regs->ahb_seq);
  385. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_regs->ahb_ptr);
  386. if (tdc->tdma->chip_data->support_separate_wcount_reg)
  387. tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT, ch_regs->wcount);
  388. /* Start DMA */
  389. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR,
  390. ch_regs->csr | TEGRA_APBDMA_CSR_ENB);
  391. }
  392. static void tegra_dma_configure_for_next(struct tegra_dma_channel *tdc,
  393. struct tegra_dma_sg_req *nsg_req)
  394. {
  395. unsigned long status;
  396. /*
  397. * The DMA controller reloads the new configuration for next transfer
  398. * after last burst of current transfer completes.
  399. * If there is no IEC status then this makes sure that last burst
  400. * has not be completed. There may be case that last burst is on
  401. * flight and so it can complete but because DMA is paused, it
  402. * will not generates interrupt as well as not reload the new
  403. * configuration.
  404. * If there is already IEC status then interrupt handler need to
  405. * load new configuration.
  406. */
  407. tegra_dma_pause(tdc, false);
  408. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  409. /*
  410. * If interrupt is pending then do nothing as the ISR will handle
  411. * the programing for new request.
  412. */
  413. if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
  414. dev_err(tdc2dev(tdc),
  415. "Skipping new configuration as interrupt is pending\n");
  416. tegra_dma_resume(tdc);
  417. return;
  418. }
  419. /* Safe to program new configuration */
  420. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, nsg_req->ch_regs.apb_ptr);
  421. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, nsg_req->ch_regs.ahb_ptr);
  422. if (tdc->tdma->chip_data->support_separate_wcount_reg)
  423. tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT,
  424. nsg_req->ch_regs.wcount);
  425. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR,
  426. nsg_req->ch_regs.csr | TEGRA_APBDMA_CSR_ENB);
  427. nsg_req->configured = true;
  428. tegra_dma_resume(tdc);
  429. }
  430. static void tdc_start_head_req(struct tegra_dma_channel *tdc)
  431. {
  432. struct tegra_dma_sg_req *sg_req;
  433. if (list_empty(&tdc->pending_sg_req))
  434. return;
  435. sg_req = list_first_entry(&tdc->pending_sg_req,
  436. typeof(*sg_req), node);
  437. tegra_dma_start(tdc, sg_req);
  438. sg_req->configured = true;
  439. tdc->busy = true;
  440. }
  441. static void tdc_configure_next_head_desc(struct tegra_dma_channel *tdc)
  442. {
  443. struct tegra_dma_sg_req *hsgreq;
  444. struct tegra_dma_sg_req *hnsgreq;
  445. if (list_empty(&tdc->pending_sg_req))
  446. return;
  447. hsgreq = list_first_entry(&tdc->pending_sg_req, typeof(*hsgreq), node);
  448. if (!list_is_last(&hsgreq->node, &tdc->pending_sg_req)) {
  449. hnsgreq = list_first_entry(&hsgreq->node,
  450. typeof(*hnsgreq), node);
  451. tegra_dma_configure_for_next(tdc, hnsgreq);
  452. }
  453. }
  454. static inline int get_current_xferred_count(struct tegra_dma_channel *tdc,
  455. struct tegra_dma_sg_req *sg_req, unsigned long status)
  456. {
  457. return sg_req->req_len - (status & TEGRA_APBDMA_STATUS_COUNT_MASK) - 4;
  458. }
  459. static void tegra_dma_abort_all(struct tegra_dma_channel *tdc)
  460. {
  461. struct tegra_dma_sg_req *sgreq;
  462. struct tegra_dma_desc *dma_desc;
  463. while (!list_empty(&tdc->pending_sg_req)) {
  464. sgreq = list_first_entry(&tdc->pending_sg_req,
  465. typeof(*sgreq), node);
  466. list_move_tail(&sgreq->node, &tdc->free_sg_req);
  467. if (sgreq->last_sg) {
  468. dma_desc = sgreq->dma_desc;
  469. dma_desc->dma_status = DMA_ERROR;
  470. list_add_tail(&dma_desc->node, &tdc->free_dma_desc);
  471. /* Add in cb list if it is not there. */
  472. if (!dma_desc->cb_count)
  473. list_add_tail(&dma_desc->cb_node,
  474. &tdc->cb_desc);
  475. dma_desc->cb_count++;
  476. }
  477. }
  478. tdc->isr_handler = NULL;
  479. }
  480. static bool handle_continuous_head_request(struct tegra_dma_channel *tdc,
  481. struct tegra_dma_sg_req *last_sg_req, bool to_terminate)
  482. {
  483. struct tegra_dma_sg_req *hsgreq = NULL;
  484. if (list_empty(&tdc->pending_sg_req)) {
  485. dev_err(tdc2dev(tdc), "Dma is running without req\n");
  486. tegra_dma_stop(tdc);
  487. return false;
  488. }
  489. /*
  490. * Check that head req on list should be in flight.
  491. * If it is not in flight then abort transfer as
  492. * looping of transfer can not continue.
  493. */
  494. hsgreq = list_first_entry(&tdc->pending_sg_req, typeof(*hsgreq), node);
  495. if (!hsgreq->configured) {
  496. tegra_dma_stop(tdc);
  497. dev_err(tdc2dev(tdc), "Error in dma transfer, aborting dma\n");
  498. tegra_dma_abort_all(tdc);
  499. return false;
  500. }
  501. /* Configure next request */
  502. if (!to_terminate)
  503. tdc_configure_next_head_desc(tdc);
  504. return true;
  505. }
  506. static void handle_once_dma_done(struct tegra_dma_channel *tdc,
  507. bool to_terminate)
  508. {
  509. struct tegra_dma_sg_req *sgreq;
  510. struct tegra_dma_desc *dma_desc;
  511. tdc->busy = false;
  512. sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node);
  513. dma_desc = sgreq->dma_desc;
  514. dma_desc->bytes_transferred += sgreq->req_len;
  515. list_del(&sgreq->node);
  516. if (sgreq->last_sg) {
  517. dma_desc->dma_status = DMA_COMPLETE;
  518. dma_cookie_complete(&dma_desc->txd);
  519. if (!dma_desc->cb_count)
  520. list_add_tail(&dma_desc->cb_node, &tdc->cb_desc);
  521. dma_desc->cb_count++;
  522. list_add_tail(&dma_desc->node, &tdc->free_dma_desc);
  523. }
  524. list_add_tail(&sgreq->node, &tdc->free_sg_req);
  525. /* Do not start DMA if it is going to be terminate */
  526. if (to_terminate || list_empty(&tdc->pending_sg_req))
  527. return;
  528. tdc_start_head_req(tdc);
  529. }
  530. static void handle_cont_sngl_cycle_dma_done(struct tegra_dma_channel *tdc,
  531. bool to_terminate)
  532. {
  533. struct tegra_dma_sg_req *sgreq;
  534. struct tegra_dma_desc *dma_desc;
  535. bool st;
  536. sgreq = list_first_entry(&tdc->pending_sg_req, typeof(*sgreq), node);
  537. dma_desc = sgreq->dma_desc;
  538. dma_desc->bytes_transferred += sgreq->req_len;
  539. /* Callback need to be call */
  540. if (!dma_desc->cb_count)
  541. list_add_tail(&dma_desc->cb_node, &tdc->cb_desc);
  542. dma_desc->cb_count++;
  543. /* If not last req then put at end of pending list */
  544. if (!list_is_last(&sgreq->node, &tdc->pending_sg_req)) {
  545. list_move_tail(&sgreq->node, &tdc->pending_sg_req);
  546. sgreq->configured = false;
  547. st = handle_continuous_head_request(tdc, sgreq, to_terminate);
  548. if (!st)
  549. dma_desc->dma_status = DMA_ERROR;
  550. }
  551. }
  552. static void tegra_dma_tasklet(unsigned long data)
  553. {
  554. struct tegra_dma_channel *tdc = (struct tegra_dma_channel *)data;
  555. struct dmaengine_desc_callback cb;
  556. struct tegra_dma_desc *dma_desc;
  557. unsigned long flags;
  558. int cb_count;
  559. spin_lock_irqsave(&tdc->lock, flags);
  560. while (!list_empty(&tdc->cb_desc)) {
  561. dma_desc = list_first_entry(&tdc->cb_desc,
  562. typeof(*dma_desc), cb_node);
  563. list_del(&dma_desc->cb_node);
  564. dmaengine_desc_get_callback(&dma_desc->txd, &cb);
  565. cb_count = dma_desc->cb_count;
  566. dma_desc->cb_count = 0;
  567. spin_unlock_irqrestore(&tdc->lock, flags);
  568. while (cb_count--)
  569. dmaengine_desc_callback_invoke(&cb, NULL);
  570. spin_lock_irqsave(&tdc->lock, flags);
  571. }
  572. spin_unlock_irqrestore(&tdc->lock, flags);
  573. }
  574. static irqreturn_t tegra_dma_isr(int irq, void *dev_id)
  575. {
  576. struct tegra_dma_channel *tdc = dev_id;
  577. unsigned long status;
  578. unsigned long flags;
  579. spin_lock_irqsave(&tdc->lock, flags);
  580. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  581. if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
  582. tdc_write(tdc, TEGRA_APBDMA_CHAN_STATUS, status);
  583. tdc->isr_handler(tdc, false);
  584. tasklet_schedule(&tdc->tasklet);
  585. spin_unlock_irqrestore(&tdc->lock, flags);
  586. return IRQ_HANDLED;
  587. }
  588. spin_unlock_irqrestore(&tdc->lock, flags);
  589. dev_info(tdc2dev(tdc),
  590. "Interrupt already served status 0x%08lx\n", status);
  591. return IRQ_NONE;
  592. }
  593. static dma_cookie_t tegra_dma_tx_submit(struct dma_async_tx_descriptor *txd)
  594. {
  595. struct tegra_dma_desc *dma_desc = txd_to_tegra_dma_desc(txd);
  596. struct tegra_dma_channel *tdc = to_tegra_dma_chan(txd->chan);
  597. unsigned long flags;
  598. dma_cookie_t cookie;
  599. spin_lock_irqsave(&tdc->lock, flags);
  600. dma_desc->dma_status = DMA_IN_PROGRESS;
  601. cookie = dma_cookie_assign(&dma_desc->txd);
  602. list_splice_tail_init(&dma_desc->tx_list, &tdc->pending_sg_req);
  603. spin_unlock_irqrestore(&tdc->lock, flags);
  604. return cookie;
  605. }
  606. static void tegra_dma_issue_pending(struct dma_chan *dc)
  607. {
  608. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  609. unsigned long flags;
  610. spin_lock_irqsave(&tdc->lock, flags);
  611. if (list_empty(&tdc->pending_sg_req)) {
  612. dev_err(tdc2dev(tdc), "No DMA request\n");
  613. goto end;
  614. }
  615. if (!tdc->busy) {
  616. tdc_start_head_req(tdc);
  617. /* Continuous single mode: Configure next req */
  618. if (tdc->cyclic) {
  619. /*
  620. * Wait for 1 burst time for configure DMA for
  621. * next transfer.
  622. */
  623. udelay(TEGRA_APBDMA_BURST_COMPLETE_TIME);
  624. tdc_configure_next_head_desc(tdc);
  625. }
  626. }
  627. end:
  628. spin_unlock_irqrestore(&tdc->lock, flags);
  629. }
  630. static int tegra_dma_terminate_all(struct dma_chan *dc)
  631. {
  632. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  633. struct tegra_dma_sg_req *sgreq;
  634. struct tegra_dma_desc *dma_desc;
  635. unsigned long flags;
  636. unsigned long status;
  637. unsigned long wcount;
  638. bool was_busy;
  639. spin_lock_irqsave(&tdc->lock, flags);
  640. if (list_empty(&tdc->pending_sg_req)) {
  641. spin_unlock_irqrestore(&tdc->lock, flags);
  642. return 0;
  643. }
  644. if (!tdc->busy)
  645. goto skip_dma_stop;
  646. /* Pause DMA before checking the queue status */
  647. tegra_dma_pause(tdc, true);
  648. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  649. if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
  650. dev_dbg(tdc2dev(tdc), "%s():handling isr\n", __func__);
  651. tdc->isr_handler(tdc, true);
  652. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  653. }
  654. if (tdc->tdma->chip_data->support_separate_wcount_reg)
  655. wcount = tdc_read(tdc, TEGRA_APBDMA_CHAN_WORD_TRANSFER);
  656. else
  657. wcount = status;
  658. was_busy = tdc->busy;
  659. tegra_dma_stop(tdc);
  660. if (!list_empty(&tdc->pending_sg_req) && was_busy) {
  661. sgreq = list_first_entry(&tdc->pending_sg_req,
  662. typeof(*sgreq), node);
  663. sgreq->dma_desc->bytes_transferred +=
  664. get_current_xferred_count(tdc, sgreq, wcount);
  665. }
  666. tegra_dma_resume(tdc);
  667. skip_dma_stop:
  668. tegra_dma_abort_all(tdc);
  669. while (!list_empty(&tdc->cb_desc)) {
  670. dma_desc = list_first_entry(&tdc->cb_desc,
  671. typeof(*dma_desc), cb_node);
  672. list_del(&dma_desc->cb_node);
  673. dma_desc->cb_count = 0;
  674. }
  675. spin_unlock_irqrestore(&tdc->lock, flags);
  676. return 0;
  677. }
  678. static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
  679. dma_cookie_t cookie, struct dma_tx_state *txstate)
  680. {
  681. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  682. struct tegra_dma_desc *dma_desc;
  683. struct tegra_dma_sg_req *sg_req;
  684. enum dma_status ret;
  685. unsigned long flags;
  686. unsigned int residual;
  687. ret = dma_cookie_status(dc, cookie, txstate);
  688. if (ret == DMA_COMPLETE)
  689. return ret;
  690. spin_lock_irqsave(&tdc->lock, flags);
  691. /* Check on wait_ack desc status */
  692. list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {
  693. if (dma_desc->txd.cookie == cookie) {
  694. ret = dma_desc->dma_status;
  695. goto found;
  696. }
  697. }
  698. /* Check in pending list */
  699. list_for_each_entry(sg_req, &tdc->pending_sg_req, node) {
  700. dma_desc = sg_req->dma_desc;
  701. if (dma_desc->txd.cookie == cookie) {
  702. ret = dma_desc->dma_status;
  703. goto found;
  704. }
  705. }
  706. dev_dbg(tdc2dev(tdc), "cookie %d not found\n", cookie);
  707. dma_desc = NULL;
  708. found:
  709. if (dma_desc && txstate) {
  710. residual = dma_desc->bytes_requested -
  711. (dma_desc->bytes_transferred %
  712. dma_desc->bytes_requested);
  713. dma_set_residue(txstate, residual);
  714. }
  715. spin_unlock_irqrestore(&tdc->lock, flags);
  716. return ret;
  717. }
  718. static inline int get_bus_width(struct tegra_dma_channel *tdc,
  719. enum dma_slave_buswidth slave_bw)
  720. {
  721. switch (slave_bw) {
  722. case DMA_SLAVE_BUSWIDTH_1_BYTE:
  723. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_8;
  724. case DMA_SLAVE_BUSWIDTH_2_BYTES:
  725. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_16;
  726. case DMA_SLAVE_BUSWIDTH_4_BYTES:
  727. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32;
  728. case DMA_SLAVE_BUSWIDTH_8_BYTES:
  729. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_64;
  730. default:
  731. dev_warn(tdc2dev(tdc),
  732. "slave bw is not supported, using 32bits\n");
  733. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32;
  734. }
  735. }
  736. static inline int get_burst_size(struct tegra_dma_channel *tdc,
  737. u32 burst_size, enum dma_slave_buswidth slave_bw, int len)
  738. {
  739. int burst_byte;
  740. int burst_ahb_width;
  741. /*
  742. * burst_size from client is in terms of the bus_width.
  743. * convert them into AHB memory width which is 4 byte.
  744. */
  745. burst_byte = burst_size * slave_bw;
  746. burst_ahb_width = burst_byte / 4;
  747. /* If burst size is 0 then calculate the burst size based on length */
  748. if (!burst_ahb_width) {
  749. if (len & 0xF)
  750. return TEGRA_APBDMA_AHBSEQ_BURST_1;
  751. else if ((len >> 4) & 0x1)
  752. return TEGRA_APBDMA_AHBSEQ_BURST_4;
  753. else
  754. return TEGRA_APBDMA_AHBSEQ_BURST_8;
  755. }
  756. if (burst_ahb_width < 4)
  757. return TEGRA_APBDMA_AHBSEQ_BURST_1;
  758. else if (burst_ahb_width < 8)
  759. return TEGRA_APBDMA_AHBSEQ_BURST_4;
  760. else
  761. return TEGRA_APBDMA_AHBSEQ_BURST_8;
  762. }
  763. static int get_transfer_param(struct tegra_dma_channel *tdc,
  764. enum dma_transfer_direction direction, unsigned long *apb_addr,
  765. unsigned long *apb_seq, unsigned long *csr, unsigned int *burst_size,
  766. enum dma_slave_buswidth *slave_bw)
  767. {
  768. switch (direction) {
  769. case DMA_MEM_TO_DEV:
  770. *apb_addr = tdc->dma_sconfig.dst_addr;
  771. *apb_seq = get_bus_width(tdc, tdc->dma_sconfig.dst_addr_width);
  772. *burst_size = tdc->dma_sconfig.dst_maxburst;
  773. *slave_bw = tdc->dma_sconfig.dst_addr_width;
  774. *csr = TEGRA_APBDMA_CSR_DIR;
  775. return 0;
  776. case DMA_DEV_TO_MEM:
  777. *apb_addr = tdc->dma_sconfig.src_addr;
  778. *apb_seq = get_bus_width(tdc, tdc->dma_sconfig.src_addr_width);
  779. *burst_size = tdc->dma_sconfig.src_maxburst;
  780. *slave_bw = tdc->dma_sconfig.src_addr_width;
  781. *csr = 0;
  782. return 0;
  783. default:
  784. dev_err(tdc2dev(tdc), "Dma direction is not supported\n");
  785. return -EINVAL;
  786. }
  787. return -EINVAL;
  788. }
  789. static void tegra_dma_prep_wcount(struct tegra_dma_channel *tdc,
  790. struct tegra_dma_channel_regs *ch_regs, u32 len)
  791. {
  792. u32 len_field = (len - 4) & 0xFFFC;
  793. if (tdc->tdma->chip_data->support_separate_wcount_reg)
  794. ch_regs->wcount = len_field;
  795. else
  796. ch_regs->csr |= len_field;
  797. }
  798. static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
  799. struct dma_chan *dc, struct scatterlist *sgl, unsigned int sg_len,
  800. enum dma_transfer_direction direction, unsigned long flags,
  801. void *context)
  802. {
  803. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  804. struct tegra_dma_desc *dma_desc;
  805. unsigned int i;
  806. struct scatterlist *sg;
  807. unsigned long csr, ahb_seq, apb_ptr, apb_seq;
  808. struct list_head req_list;
  809. struct tegra_dma_sg_req *sg_req = NULL;
  810. u32 burst_size;
  811. enum dma_slave_buswidth slave_bw;
  812. if (!tdc->config_init) {
  813. dev_err(tdc2dev(tdc), "dma channel is not configured\n");
  814. return NULL;
  815. }
  816. if (sg_len < 1) {
  817. dev_err(tdc2dev(tdc), "Invalid segment length %d\n", sg_len);
  818. return NULL;
  819. }
  820. if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr,
  821. &burst_size, &slave_bw) < 0)
  822. return NULL;
  823. INIT_LIST_HEAD(&req_list);
  824. ahb_seq = TEGRA_APBDMA_AHBSEQ_INTR_ENB;
  825. ahb_seq |= TEGRA_APBDMA_AHBSEQ_WRAP_NONE <<
  826. TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT;
  827. ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32;
  828. csr |= TEGRA_APBDMA_CSR_ONCE;
  829. if (tdc->slave_id != TEGRA_APBDMA_SLAVE_ID_INVALID) {
  830. csr |= TEGRA_APBDMA_CSR_FLOW;
  831. csr |= tdc->slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
  832. }
  833. if (flags & DMA_PREP_INTERRUPT)
  834. csr |= TEGRA_APBDMA_CSR_IE_EOC;
  835. apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1;
  836. dma_desc = tegra_dma_desc_get(tdc);
  837. if (!dma_desc) {
  838. dev_err(tdc2dev(tdc), "Dma descriptors not available\n");
  839. return NULL;
  840. }
  841. INIT_LIST_HEAD(&dma_desc->tx_list);
  842. INIT_LIST_HEAD(&dma_desc->cb_node);
  843. dma_desc->cb_count = 0;
  844. dma_desc->bytes_requested = 0;
  845. dma_desc->bytes_transferred = 0;
  846. dma_desc->dma_status = DMA_IN_PROGRESS;
  847. /* Make transfer requests */
  848. for_each_sg(sgl, sg, sg_len, i) {
  849. u32 len, mem;
  850. mem = sg_dma_address(sg);
  851. len = sg_dma_len(sg);
  852. if ((len & 3) || (mem & 3) ||
  853. (len > tdc->tdma->chip_data->max_dma_count)) {
  854. dev_err(tdc2dev(tdc),
  855. "Dma length/memory address is not supported\n");
  856. tegra_dma_desc_put(tdc, dma_desc);
  857. return NULL;
  858. }
  859. sg_req = tegra_dma_sg_req_get(tdc);
  860. if (!sg_req) {
  861. dev_err(tdc2dev(tdc), "Dma sg-req not available\n");
  862. tegra_dma_desc_put(tdc, dma_desc);
  863. return NULL;
  864. }
  865. ahb_seq |= get_burst_size(tdc, burst_size, slave_bw, len);
  866. dma_desc->bytes_requested += len;
  867. sg_req->ch_regs.apb_ptr = apb_ptr;
  868. sg_req->ch_regs.ahb_ptr = mem;
  869. sg_req->ch_regs.csr = csr;
  870. tegra_dma_prep_wcount(tdc, &sg_req->ch_regs, len);
  871. sg_req->ch_regs.apb_seq = apb_seq;
  872. sg_req->ch_regs.ahb_seq = ahb_seq;
  873. sg_req->configured = false;
  874. sg_req->last_sg = false;
  875. sg_req->dma_desc = dma_desc;
  876. sg_req->req_len = len;
  877. list_add_tail(&sg_req->node, &dma_desc->tx_list);
  878. }
  879. sg_req->last_sg = true;
  880. if (flags & DMA_CTRL_ACK)
  881. dma_desc->txd.flags = DMA_CTRL_ACK;
  882. /*
  883. * Make sure that mode should not be conflicting with currently
  884. * configured mode.
  885. */
  886. if (!tdc->isr_handler) {
  887. tdc->isr_handler = handle_once_dma_done;
  888. tdc->cyclic = false;
  889. } else {
  890. if (tdc->cyclic) {
  891. dev_err(tdc2dev(tdc), "DMA configured in cyclic mode\n");
  892. tegra_dma_desc_put(tdc, dma_desc);
  893. return NULL;
  894. }
  895. }
  896. return &dma_desc->txd;
  897. }
  898. static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
  899. struct dma_chan *dc, dma_addr_t buf_addr, size_t buf_len,
  900. size_t period_len, enum dma_transfer_direction direction,
  901. unsigned long flags)
  902. {
  903. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  904. struct tegra_dma_desc *dma_desc = NULL;
  905. struct tegra_dma_sg_req *sg_req = NULL;
  906. unsigned long csr, ahb_seq, apb_ptr, apb_seq;
  907. int len;
  908. size_t remain_len;
  909. dma_addr_t mem = buf_addr;
  910. u32 burst_size;
  911. enum dma_slave_buswidth slave_bw;
  912. if (!buf_len || !period_len) {
  913. dev_err(tdc2dev(tdc), "Invalid buffer/period len\n");
  914. return NULL;
  915. }
  916. if (!tdc->config_init) {
  917. dev_err(tdc2dev(tdc), "DMA slave is not configured\n");
  918. return NULL;
  919. }
  920. /*
  921. * We allow to take more number of requests till DMA is
  922. * not started. The driver will loop over all requests.
  923. * Once DMA is started then new requests can be queued only after
  924. * terminating the DMA.
  925. */
  926. if (tdc->busy) {
  927. dev_err(tdc2dev(tdc), "Request not allowed when dma running\n");
  928. return NULL;
  929. }
  930. /*
  931. * We only support cycle transfer when buf_len is multiple of
  932. * period_len.
  933. */
  934. if (buf_len % period_len) {
  935. dev_err(tdc2dev(tdc), "buf_len is not multiple of period_len\n");
  936. return NULL;
  937. }
  938. len = period_len;
  939. if ((len & 3) || (buf_addr & 3) ||
  940. (len > tdc->tdma->chip_data->max_dma_count)) {
  941. dev_err(tdc2dev(tdc), "Req len/mem address is not correct\n");
  942. return NULL;
  943. }
  944. if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr,
  945. &burst_size, &slave_bw) < 0)
  946. return NULL;
  947. ahb_seq = TEGRA_APBDMA_AHBSEQ_INTR_ENB;
  948. ahb_seq |= TEGRA_APBDMA_AHBSEQ_WRAP_NONE <<
  949. TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT;
  950. ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32;
  951. if (tdc->slave_id != TEGRA_APBDMA_SLAVE_ID_INVALID) {
  952. csr |= TEGRA_APBDMA_CSR_FLOW;
  953. csr |= tdc->slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
  954. }
  955. if (flags & DMA_PREP_INTERRUPT)
  956. csr |= TEGRA_APBDMA_CSR_IE_EOC;
  957. apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1;
  958. dma_desc = tegra_dma_desc_get(tdc);
  959. if (!dma_desc) {
  960. dev_err(tdc2dev(tdc), "not enough descriptors available\n");
  961. return NULL;
  962. }
  963. INIT_LIST_HEAD(&dma_desc->tx_list);
  964. INIT_LIST_HEAD(&dma_desc->cb_node);
  965. dma_desc->cb_count = 0;
  966. dma_desc->bytes_transferred = 0;
  967. dma_desc->bytes_requested = buf_len;
  968. remain_len = buf_len;
  969. /* Split transfer equal to period size */
  970. while (remain_len) {
  971. sg_req = tegra_dma_sg_req_get(tdc);
  972. if (!sg_req) {
  973. dev_err(tdc2dev(tdc), "Dma sg-req not available\n");
  974. tegra_dma_desc_put(tdc, dma_desc);
  975. return NULL;
  976. }
  977. ahb_seq |= get_burst_size(tdc, burst_size, slave_bw, len);
  978. sg_req->ch_regs.apb_ptr = apb_ptr;
  979. sg_req->ch_regs.ahb_ptr = mem;
  980. sg_req->ch_regs.csr = csr;
  981. tegra_dma_prep_wcount(tdc, &sg_req->ch_regs, len);
  982. sg_req->ch_regs.apb_seq = apb_seq;
  983. sg_req->ch_regs.ahb_seq = ahb_seq;
  984. sg_req->configured = false;
  985. sg_req->last_sg = false;
  986. sg_req->dma_desc = dma_desc;
  987. sg_req->req_len = len;
  988. list_add_tail(&sg_req->node, &dma_desc->tx_list);
  989. remain_len -= len;
  990. mem += len;
  991. }
  992. sg_req->last_sg = true;
  993. if (flags & DMA_CTRL_ACK)
  994. dma_desc->txd.flags = DMA_CTRL_ACK;
  995. /*
  996. * Make sure that mode should not be conflicting with currently
  997. * configured mode.
  998. */
  999. if (!tdc->isr_handler) {
  1000. tdc->isr_handler = handle_cont_sngl_cycle_dma_done;
  1001. tdc->cyclic = true;
  1002. } else {
  1003. if (!tdc->cyclic) {
  1004. dev_err(tdc2dev(tdc), "DMA configuration conflict\n");
  1005. tegra_dma_desc_put(tdc, dma_desc);
  1006. return NULL;
  1007. }
  1008. }
  1009. return &dma_desc->txd;
  1010. }
  1011. static int tegra_dma_alloc_chan_resources(struct dma_chan *dc)
  1012. {
  1013. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  1014. struct tegra_dma *tdma = tdc->tdma;
  1015. int ret;
  1016. dma_cookie_init(&tdc->dma_chan);
  1017. tdc->config_init = false;
  1018. ret = pm_runtime_get_sync(tdma->dev);
  1019. if (ret < 0)
  1020. return ret;
  1021. return 0;
  1022. }
  1023. static void tegra_dma_free_chan_resources(struct dma_chan *dc)
  1024. {
  1025. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  1026. struct tegra_dma *tdma = tdc->tdma;
  1027. struct tegra_dma_desc *dma_desc;
  1028. struct tegra_dma_sg_req *sg_req;
  1029. struct list_head dma_desc_list;
  1030. struct list_head sg_req_list;
  1031. unsigned long flags;
  1032. INIT_LIST_HEAD(&dma_desc_list);
  1033. INIT_LIST_HEAD(&sg_req_list);
  1034. dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id);
  1035. if (tdc->busy)
  1036. tegra_dma_terminate_all(dc);
  1037. spin_lock_irqsave(&tdc->lock, flags);
  1038. list_splice_init(&tdc->pending_sg_req, &sg_req_list);
  1039. list_splice_init(&tdc->free_sg_req, &sg_req_list);
  1040. list_splice_init(&tdc->free_dma_desc, &dma_desc_list);
  1041. INIT_LIST_HEAD(&tdc->cb_desc);
  1042. tdc->config_init = false;
  1043. tdc->isr_handler = NULL;
  1044. spin_unlock_irqrestore(&tdc->lock, flags);
  1045. while (!list_empty(&dma_desc_list)) {
  1046. dma_desc = list_first_entry(&dma_desc_list,
  1047. typeof(*dma_desc), node);
  1048. list_del(&dma_desc->node);
  1049. kfree(dma_desc);
  1050. }
  1051. while (!list_empty(&sg_req_list)) {
  1052. sg_req = list_first_entry(&sg_req_list, typeof(*sg_req), node);
  1053. list_del(&sg_req->node);
  1054. kfree(sg_req);
  1055. }
  1056. pm_runtime_put(tdma->dev);
  1057. tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID;
  1058. }
  1059. static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec,
  1060. struct of_dma *ofdma)
  1061. {
  1062. struct tegra_dma *tdma = ofdma->of_dma_data;
  1063. struct dma_chan *chan;
  1064. struct tegra_dma_channel *tdc;
  1065. if (dma_spec->args[0] > TEGRA_APBDMA_CSR_REQ_SEL_MASK) {
  1066. dev_err(tdma->dev, "Invalid slave id: %d\n", dma_spec->args[0]);
  1067. return NULL;
  1068. }
  1069. chan = dma_get_any_slave_channel(&tdma->dma_dev);
  1070. if (!chan)
  1071. return NULL;
  1072. tdc = to_tegra_dma_chan(chan);
  1073. tdc->slave_id = dma_spec->args[0];
  1074. return chan;
  1075. }
  1076. /* Tegra20 specific DMA controller information */
  1077. static const struct tegra_dma_chip_data tegra20_dma_chip_data = {
  1078. .nr_channels = 16,
  1079. .channel_reg_size = 0x20,
  1080. .max_dma_count = 1024UL * 64,
  1081. .support_channel_pause = false,
  1082. .support_separate_wcount_reg = false,
  1083. };
  1084. /* Tegra30 specific DMA controller information */
  1085. static const struct tegra_dma_chip_data tegra30_dma_chip_data = {
  1086. .nr_channels = 32,
  1087. .channel_reg_size = 0x20,
  1088. .max_dma_count = 1024UL * 64,
  1089. .support_channel_pause = false,
  1090. .support_separate_wcount_reg = false,
  1091. };
  1092. /* Tegra114 specific DMA controller information */
  1093. static const struct tegra_dma_chip_data tegra114_dma_chip_data = {
  1094. .nr_channels = 32,
  1095. .channel_reg_size = 0x20,
  1096. .max_dma_count = 1024UL * 64,
  1097. .support_channel_pause = true,
  1098. .support_separate_wcount_reg = false,
  1099. };
  1100. /* Tegra148 specific DMA controller information */
  1101. static const struct tegra_dma_chip_data tegra148_dma_chip_data = {
  1102. .nr_channels = 32,
  1103. .channel_reg_size = 0x40,
  1104. .max_dma_count = 1024UL * 64,
  1105. .support_channel_pause = true,
  1106. .support_separate_wcount_reg = true,
  1107. };
  1108. static int tegra_dma_probe(struct platform_device *pdev)
  1109. {
  1110. struct resource *res;
  1111. struct tegra_dma *tdma;
  1112. int ret;
  1113. int i;
  1114. const struct tegra_dma_chip_data *cdata;
  1115. cdata = of_device_get_match_data(&pdev->dev);
  1116. if (!cdata) {
  1117. dev_err(&pdev->dev, "Error: No device match data found\n");
  1118. return -ENODEV;
  1119. }
  1120. tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
  1121. sizeof(struct tegra_dma_channel), GFP_KERNEL);
  1122. if (!tdma)
  1123. return -ENOMEM;
  1124. tdma->dev = &pdev->dev;
  1125. tdma->chip_data = cdata;
  1126. platform_set_drvdata(pdev, tdma);
  1127. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1128. tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
  1129. if (IS_ERR(tdma->base_addr))
  1130. return PTR_ERR(tdma->base_addr);
  1131. tdma->dma_clk = devm_clk_get(&pdev->dev, NULL);
  1132. if (IS_ERR(tdma->dma_clk)) {
  1133. dev_err(&pdev->dev, "Error: Missing controller clock\n");
  1134. return PTR_ERR(tdma->dma_clk);
  1135. }
  1136. tdma->rst = devm_reset_control_get(&pdev->dev, "dma");
  1137. if (IS_ERR(tdma->rst)) {
  1138. dev_err(&pdev->dev, "Error: Missing reset\n");
  1139. return PTR_ERR(tdma->rst);
  1140. }
  1141. spin_lock_init(&tdma->global_lock);
  1142. pm_runtime_enable(&pdev->dev);
  1143. if (!pm_runtime_enabled(&pdev->dev))
  1144. ret = tegra_dma_runtime_resume(&pdev->dev);
  1145. else
  1146. ret = pm_runtime_get_sync(&pdev->dev);
  1147. if (ret < 0) {
  1148. pm_runtime_disable(&pdev->dev);
  1149. return ret;
  1150. }
  1151. /* Reset DMA controller */
  1152. reset_control_assert(tdma->rst);
  1153. udelay(2);
  1154. reset_control_deassert(tdma->rst);
  1155. /* Enable global DMA registers */
  1156. tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE);
  1157. tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0);
  1158. tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul);
  1159. pm_runtime_put(&pdev->dev);
  1160. INIT_LIST_HEAD(&tdma->dma_dev.channels);
  1161. for (i = 0; i < cdata->nr_channels; i++) {
  1162. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1163. tdc->chan_addr = tdma->base_addr +
  1164. TEGRA_APBDMA_CHANNEL_BASE_ADD_OFFSET +
  1165. (i * cdata->channel_reg_size);
  1166. res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
  1167. if (!res) {
  1168. ret = -EINVAL;
  1169. dev_err(&pdev->dev, "No irq resource for chan %d\n", i);
  1170. goto err_irq;
  1171. }
  1172. tdc->irq = res->start;
  1173. snprintf(tdc->name, sizeof(tdc->name), "apbdma.%d", i);
  1174. ret = request_irq(tdc->irq, tegra_dma_isr, 0, tdc->name, tdc);
  1175. if (ret) {
  1176. dev_err(&pdev->dev,
  1177. "request_irq failed with err %d channel %d\n",
  1178. ret, i);
  1179. goto err_irq;
  1180. }
  1181. tdc->dma_chan.device = &tdma->dma_dev;
  1182. dma_cookie_init(&tdc->dma_chan);
  1183. list_add_tail(&tdc->dma_chan.device_node,
  1184. &tdma->dma_dev.channels);
  1185. tdc->tdma = tdma;
  1186. tdc->id = i;
  1187. tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID;
  1188. tasklet_init(&tdc->tasklet, tegra_dma_tasklet,
  1189. (unsigned long)tdc);
  1190. spin_lock_init(&tdc->lock);
  1191. INIT_LIST_HEAD(&tdc->pending_sg_req);
  1192. INIT_LIST_HEAD(&tdc->free_sg_req);
  1193. INIT_LIST_HEAD(&tdc->free_dma_desc);
  1194. INIT_LIST_HEAD(&tdc->cb_desc);
  1195. }
  1196. dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
  1197. dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
  1198. dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);
  1199. tdma->global_pause_count = 0;
  1200. tdma->dma_dev.dev = &pdev->dev;
  1201. tdma->dma_dev.device_alloc_chan_resources =
  1202. tegra_dma_alloc_chan_resources;
  1203. tdma->dma_dev.device_free_chan_resources =
  1204. tegra_dma_free_chan_resources;
  1205. tdma->dma_dev.device_prep_slave_sg = tegra_dma_prep_slave_sg;
  1206. tdma->dma_dev.device_prep_dma_cyclic = tegra_dma_prep_dma_cyclic;
  1207. tdma->dma_dev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  1208. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  1209. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
  1210. BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);
  1211. tdma->dma_dev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  1212. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  1213. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
  1214. BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);
  1215. tdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
  1216. /*
  1217. * XXX The hardware appears to support
  1218. * DMA_RESIDUE_GRANULARITY_BURST-level reporting, but it's
  1219. * only used by this driver during tegra_dma_terminate_all()
  1220. */
  1221. tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
  1222. tdma->dma_dev.device_config = tegra_dma_slave_config;
  1223. tdma->dma_dev.device_terminate_all = tegra_dma_terminate_all;
  1224. tdma->dma_dev.device_tx_status = tegra_dma_tx_status;
  1225. tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending;
  1226. ret = dma_async_device_register(&tdma->dma_dev);
  1227. if (ret < 0) {
  1228. dev_err(&pdev->dev,
  1229. "Tegra20 APB DMA driver registration failed %d\n", ret);
  1230. goto err_irq;
  1231. }
  1232. ret = of_dma_controller_register(pdev->dev.of_node,
  1233. tegra_dma_of_xlate, tdma);
  1234. if (ret < 0) {
  1235. dev_err(&pdev->dev,
  1236. "Tegra20 APB DMA OF registration failed %d\n", ret);
  1237. goto err_unregister_dma_dev;
  1238. }
  1239. dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n",
  1240. cdata->nr_channels);
  1241. return 0;
  1242. err_unregister_dma_dev:
  1243. dma_async_device_unregister(&tdma->dma_dev);
  1244. err_irq:
  1245. while (--i >= 0) {
  1246. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1247. free_irq(tdc->irq, tdc);
  1248. tasklet_kill(&tdc->tasklet);
  1249. }
  1250. pm_runtime_disable(&pdev->dev);
  1251. if (!pm_runtime_status_suspended(&pdev->dev))
  1252. tegra_dma_runtime_suspend(&pdev->dev);
  1253. return ret;
  1254. }
  1255. static int tegra_dma_remove(struct platform_device *pdev)
  1256. {
  1257. struct tegra_dma *tdma = platform_get_drvdata(pdev);
  1258. int i;
  1259. struct tegra_dma_channel *tdc;
  1260. dma_async_device_unregister(&tdma->dma_dev);
  1261. for (i = 0; i < tdma->chip_data->nr_channels; ++i) {
  1262. tdc = &tdma->channels[i];
  1263. free_irq(tdc->irq, tdc);
  1264. tasklet_kill(&tdc->tasklet);
  1265. }
  1266. pm_runtime_disable(&pdev->dev);
  1267. if (!pm_runtime_status_suspended(&pdev->dev))
  1268. tegra_dma_runtime_suspend(&pdev->dev);
  1269. return 0;
  1270. }
  1271. static int tegra_dma_runtime_suspend(struct device *dev)
  1272. {
  1273. struct tegra_dma *tdma = dev_get_drvdata(dev);
  1274. int i;
  1275. tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL);
  1276. for (i = 0; i < tdma->chip_data->nr_channels; i++) {
  1277. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1278. struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg;
  1279. /* Only save the state of DMA channels that are in use */
  1280. if (!tdc->config_init)
  1281. continue;
  1282. ch_reg->csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR);
  1283. ch_reg->ahb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBPTR);
  1284. ch_reg->apb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBPTR);
  1285. ch_reg->ahb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBSEQ);
  1286. ch_reg->apb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBSEQ);
  1287. if (tdma->chip_data->support_separate_wcount_reg)
  1288. ch_reg->wcount = tdc_read(tdc,
  1289. TEGRA_APBDMA_CHAN_WCOUNT);
  1290. }
  1291. clk_disable_unprepare(tdma->dma_clk);
  1292. return 0;
  1293. }
  1294. static int tegra_dma_runtime_resume(struct device *dev)
  1295. {
  1296. struct tegra_dma *tdma = dev_get_drvdata(dev);
  1297. int i, ret;
  1298. ret = clk_prepare_enable(tdma->dma_clk);
  1299. if (ret < 0) {
  1300. dev_err(dev, "clk_enable failed: %d\n", ret);
  1301. return ret;
  1302. }
  1303. tdma_write(tdma, TEGRA_APBDMA_GENERAL, tdma->reg_gen);
  1304. tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0);
  1305. tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul);
  1306. for (i = 0; i < tdma->chip_data->nr_channels; i++) {
  1307. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1308. struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg;
  1309. /* Only restore the state of DMA channels that are in use */
  1310. if (!tdc->config_init)
  1311. continue;
  1312. if (tdma->chip_data->support_separate_wcount_reg)
  1313. tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT,
  1314. ch_reg->wcount);
  1315. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBSEQ, ch_reg->apb_seq);
  1316. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, ch_reg->apb_ptr);
  1317. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq);
  1318. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr);
  1319. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR,
  1320. (ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB));
  1321. }
  1322. return 0;
  1323. }
  1324. static const struct dev_pm_ops tegra_dma_dev_pm_ops = {
  1325. SET_RUNTIME_PM_OPS(tegra_dma_runtime_suspend, tegra_dma_runtime_resume,
  1326. NULL)
  1327. SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
  1328. pm_runtime_force_resume)
  1329. };
  1330. static const struct of_device_id tegra_dma_of_match[] = {
  1331. {
  1332. .compatible = "nvidia,tegra148-apbdma",
  1333. .data = &tegra148_dma_chip_data,
  1334. }, {
  1335. .compatible = "nvidia,tegra114-apbdma",
  1336. .data = &tegra114_dma_chip_data,
  1337. }, {
  1338. .compatible = "nvidia,tegra30-apbdma",
  1339. .data = &tegra30_dma_chip_data,
  1340. }, {
  1341. .compatible = "nvidia,tegra20-apbdma",
  1342. .data = &tegra20_dma_chip_data,
  1343. }, {
  1344. },
  1345. };
  1346. MODULE_DEVICE_TABLE(of, tegra_dma_of_match);
  1347. static struct platform_driver tegra_dmac_driver = {
  1348. .driver = {
  1349. .name = "tegra-apbdma",
  1350. .pm = &tegra_dma_dev_pm_ops,
  1351. .of_match_table = tegra_dma_of_match,
  1352. },
  1353. .probe = tegra_dma_probe,
  1354. .remove = tegra_dma_remove,
  1355. };
  1356. module_platform_driver(tegra_dmac_driver);
  1357. MODULE_ALIAS("platform:tegra20-apbdma");
  1358. MODULE_DESCRIPTION("NVIDIA Tegra APB DMA Controller driver");
  1359. MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
  1360. MODULE_LICENSE("GPL v2");