tegra20-apb-dma.c 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615
  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) && !dma_desc->cb_count) {
  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. /* if we dma for long enough the transfer count will wrap */
  539. dma_desc->bytes_transferred =
  540. (dma_desc->bytes_transferred + sgreq->req_len) %
  541. dma_desc->bytes_requested;
  542. /* Callback need to be call */
  543. if (!dma_desc->cb_count)
  544. list_add_tail(&dma_desc->cb_node, &tdc->cb_desc);
  545. dma_desc->cb_count++;
  546. /* If not last req then put at end of pending list */
  547. if (!list_is_last(&sgreq->node, &tdc->pending_sg_req)) {
  548. list_move_tail(&sgreq->node, &tdc->pending_sg_req);
  549. sgreq->configured = false;
  550. st = handle_continuous_head_request(tdc, sgreq, to_terminate);
  551. if (!st)
  552. dma_desc->dma_status = DMA_ERROR;
  553. }
  554. }
  555. static void tegra_dma_tasklet(unsigned long data)
  556. {
  557. struct tegra_dma_channel *tdc = (struct tegra_dma_channel *)data;
  558. struct dmaengine_desc_callback cb;
  559. struct tegra_dma_desc *dma_desc;
  560. unsigned long flags;
  561. int cb_count;
  562. spin_lock_irqsave(&tdc->lock, flags);
  563. while (!list_empty(&tdc->cb_desc)) {
  564. dma_desc = list_first_entry(&tdc->cb_desc,
  565. typeof(*dma_desc), cb_node);
  566. list_del(&dma_desc->cb_node);
  567. dmaengine_desc_get_callback(&dma_desc->txd, &cb);
  568. cb_count = dma_desc->cb_count;
  569. dma_desc->cb_count = 0;
  570. spin_unlock_irqrestore(&tdc->lock, flags);
  571. while (cb_count--)
  572. dmaengine_desc_callback_invoke(&cb, NULL);
  573. spin_lock_irqsave(&tdc->lock, flags);
  574. }
  575. spin_unlock_irqrestore(&tdc->lock, flags);
  576. }
  577. static irqreturn_t tegra_dma_isr(int irq, void *dev_id)
  578. {
  579. struct tegra_dma_channel *tdc = dev_id;
  580. unsigned long status;
  581. unsigned long flags;
  582. spin_lock_irqsave(&tdc->lock, flags);
  583. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  584. if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
  585. tdc_write(tdc, TEGRA_APBDMA_CHAN_STATUS, status);
  586. tdc->isr_handler(tdc, false);
  587. tasklet_schedule(&tdc->tasklet);
  588. spin_unlock_irqrestore(&tdc->lock, flags);
  589. return IRQ_HANDLED;
  590. }
  591. spin_unlock_irqrestore(&tdc->lock, flags);
  592. dev_info(tdc2dev(tdc),
  593. "Interrupt already served status 0x%08lx\n", status);
  594. return IRQ_NONE;
  595. }
  596. static dma_cookie_t tegra_dma_tx_submit(struct dma_async_tx_descriptor *txd)
  597. {
  598. struct tegra_dma_desc *dma_desc = txd_to_tegra_dma_desc(txd);
  599. struct tegra_dma_channel *tdc = to_tegra_dma_chan(txd->chan);
  600. unsigned long flags;
  601. dma_cookie_t cookie;
  602. spin_lock_irqsave(&tdc->lock, flags);
  603. dma_desc->dma_status = DMA_IN_PROGRESS;
  604. cookie = dma_cookie_assign(&dma_desc->txd);
  605. list_splice_tail_init(&dma_desc->tx_list, &tdc->pending_sg_req);
  606. spin_unlock_irqrestore(&tdc->lock, flags);
  607. return cookie;
  608. }
  609. static void tegra_dma_issue_pending(struct dma_chan *dc)
  610. {
  611. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  612. unsigned long flags;
  613. spin_lock_irqsave(&tdc->lock, flags);
  614. if (list_empty(&tdc->pending_sg_req)) {
  615. dev_err(tdc2dev(tdc), "No DMA request\n");
  616. goto end;
  617. }
  618. if (!tdc->busy) {
  619. tdc_start_head_req(tdc);
  620. /* Continuous single mode: Configure next req */
  621. if (tdc->cyclic) {
  622. /*
  623. * Wait for 1 burst time for configure DMA for
  624. * next transfer.
  625. */
  626. udelay(TEGRA_APBDMA_BURST_COMPLETE_TIME);
  627. tdc_configure_next_head_desc(tdc);
  628. }
  629. }
  630. end:
  631. spin_unlock_irqrestore(&tdc->lock, flags);
  632. }
  633. static int tegra_dma_terminate_all(struct dma_chan *dc)
  634. {
  635. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  636. struct tegra_dma_sg_req *sgreq;
  637. struct tegra_dma_desc *dma_desc;
  638. unsigned long flags;
  639. unsigned long status;
  640. unsigned long wcount;
  641. bool was_busy;
  642. spin_lock_irqsave(&tdc->lock, flags);
  643. if (!tdc->busy)
  644. goto skip_dma_stop;
  645. /* Pause DMA before checking the queue status */
  646. tegra_dma_pause(tdc, true);
  647. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  648. if (status & TEGRA_APBDMA_STATUS_ISE_EOC) {
  649. dev_dbg(tdc2dev(tdc), "%s():handling isr\n", __func__);
  650. tdc->isr_handler(tdc, true);
  651. status = tdc_read(tdc, TEGRA_APBDMA_CHAN_STATUS);
  652. }
  653. if (tdc->tdma->chip_data->support_separate_wcount_reg)
  654. wcount = tdc_read(tdc, TEGRA_APBDMA_CHAN_WORD_TRANSFER);
  655. else
  656. wcount = status;
  657. was_busy = tdc->busy;
  658. tegra_dma_stop(tdc);
  659. if (!list_empty(&tdc->pending_sg_req) && was_busy) {
  660. sgreq = list_first_entry(&tdc->pending_sg_req,
  661. typeof(*sgreq), node);
  662. sgreq->dma_desc->bytes_transferred +=
  663. get_current_xferred_count(tdc, sgreq, wcount);
  664. }
  665. tegra_dma_resume(tdc);
  666. skip_dma_stop:
  667. tegra_dma_abort_all(tdc);
  668. while (!list_empty(&tdc->cb_desc)) {
  669. dma_desc = list_first_entry(&tdc->cb_desc,
  670. typeof(*dma_desc), cb_node);
  671. list_del(&dma_desc->cb_node);
  672. dma_desc->cb_count = 0;
  673. }
  674. spin_unlock_irqrestore(&tdc->lock, flags);
  675. return 0;
  676. }
  677. static enum dma_status tegra_dma_tx_status(struct dma_chan *dc,
  678. dma_cookie_t cookie, struct dma_tx_state *txstate)
  679. {
  680. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  681. struct tegra_dma_desc *dma_desc;
  682. struct tegra_dma_sg_req *sg_req;
  683. enum dma_status ret;
  684. unsigned long flags;
  685. unsigned int residual;
  686. ret = dma_cookie_status(dc, cookie, txstate);
  687. if (ret == DMA_COMPLETE)
  688. return ret;
  689. spin_lock_irqsave(&tdc->lock, flags);
  690. /* Check on wait_ack desc status */
  691. list_for_each_entry(dma_desc, &tdc->free_dma_desc, node) {
  692. if (dma_desc->txd.cookie == cookie) {
  693. ret = dma_desc->dma_status;
  694. goto found;
  695. }
  696. }
  697. /* Check in pending list */
  698. list_for_each_entry(sg_req, &tdc->pending_sg_req, node) {
  699. dma_desc = sg_req->dma_desc;
  700. if (dma_desc->txd.cookie == cookie) {
  701. ret = dma_desc->dma_status;
  702. goto found;
  703. }
  704. }
  705. dev_dbg(tdc2dev(tdc), "cookie %d not found\n", cookie);
  706. dma_desc = NULL;
  707. found:
  708. if (dma_desc && txstate) {
  709. residual = dma_desc->bytes_requested -
  710. (dma_desc->bytes_transferred %
  711. dma_desc->bytes_requested);
  712. dma_set_residue(txstate, residual);
  713. }
  714. spin_unlock_irqrestore(&tdc->lock, flags);
  715. return ret;
  716. }
  717. static inline int get_bus_width(struct tegra_dma_channel *tdc,
  718. enum dma_slave_buswidth slave_bw)
  719. {
  720. switch (slave_bw) {
  721. case DMA_SLAVE_BUSWIDTH_1_BYTE:
  722. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_8;
  723. case DMA_SLAVE_BUSWIDTH_2_BYTES:
  724. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_16;
  725. case DMA_SLAVE_BUSWIDTH_4_BYTES:
  726. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32;
  727. case DMA_SLAVE_BUSWIDTH_8_BYTES:
  728. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_64;
  729. default:
  730. dev_warn(tdc2dev(tdc),
  731. "slave bw is not supported, using 32bits\n");
  732. return TEGRA_APBDMA_APBSEQ_BUS_WIDTH_32;
  733. }
  734. }
  735. static inline int get_burst_size(struct tegra_dma_channel *tdc,
  736. u32 burst_size, enum dma_slave_buswidth slave_bw, int len)
  737. {
  738. int burst_byte;
  739. int burst_ahb_width;
  740. /*
  741. * burst_size from client is in terms of the bus_width.
  742. * convert them into AHB memory width which is 4 byte.
  743. */
  744. burst_byte = burst_size * slave_bw;
  745. burst_ahb_width = burst_byte / 4;
  746. /* If burst size is 0 then calculate the burst size based on length */
  747. if (!burst_ahb_width) {
  748. if (len & 0xF)
  749. return TEGRA_APBDMA_AHBSEQ_BURST_1;
  750. else if ((len >> 4) & 0x1)
  751. return TEGRA_APBDMA_AHBSEQ_BURST_4;
  752. else
  753. return TEGRA_APBDMA_AHBSEQ_BURST_8;
  754. }
  755. if (burst_ahb_width < 4)
  756. return TEGRA_APBDMA_AHBSEQ_BURST_1;
  757. else if (burst_ahb_width < 8)
  758. return TEGRA_APBDMA_AHBSEQ_BURST_4;
  759. else
  760. return TEGRA_APBDMA_AHBSEQ_BURST_8;
  761. }
  762. static int get_transfer_param(struct tegra_dma_channel *tdc,
  763. enum dma_transfer_direction direction, unsigned long *apb_addr,
  764. unsigned long *apb_seq, unsigned long *csr, unsigned int *burst_size,
  765. enum dma_slave_buswidth *slave_bw)
  766. {
  767. switch (direction) {
  768. case DMA_MEM_TO_DEV:
  769. *apb_addr = tdc->dma_sconfig.dst_addr;
  770. *apb_seq = get_bus_width(tdc, tdc->dma_sconfig.dst_addr_width);
  771. *burst_size = tdc->dma_sconfig.dst_maxburst;
  772. *slave_bw = tdc->dma_sconfig.dst_addr_width;
  773. *csr = TEGRA_APBDMA_CSR_DIR;
  774. return 0;
  775. case DMA_DEV_TO_MEM:
  776. *apb_addr = tdc->dma_sconfig.src_addr;
  777. *apb_seq = get_bus_width(tdc, tdc->dma_sconfig.src_addr_width);
  778. *burst_size = tdc->dma_sconfig.src_maxburst;
  779. *slave_bw = tdc->dma_sconfig.src_addr_width;
  780. *csr = 0;
  781. return 0;
  782. default:
  783. dev_err(tdc2dev(tdc), "Dma direction is not supported\n");
  784. return -EINVAL;
  785. }
  786. return -EINVAL;
  787. }
  788. static void tegra_dma_prep_wcount(struct tegra_dma_channel *tdc,
  789. struct tegra_dma_channel_regs *ch_regs, u32 len)
  790. {
  791. u32 len_field = (len - 4) & 0xFFFC;
  792. if (tdc->tdma->chip_data->support_separate_wcount_reg)
  793. ch_regs->wcount = len_field;
  794. else
  795. ch_regs->csr |= len_field;
  796. }
  797. static struct dma_async_tx_descriptor *tegra_dma_prep_slave_sg(
  798. struct dma_chan *dc, struct scatterlist *sgl, unsigned int sg_len,
  799. enum dma_transfer_direction direction, unsigned long flags,
  800. void *context)
  801. {
  802. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  803. struct tegra_dma_desc *dma_desc;
  804. unsigned int i;
  805. struct scatterlist *sg;
  806. unsigned long csr, ahb_seq, apb_ptr, apb_seq;
  807. struct list_head req_list;
  808. struct tegra_dma_sg_req *sg_req = NULL;
  809. u32 burst_size;
  810. enum dma_slave_buswidth slave_bw;
  811. if (!tdc->config_init) {
  812. dev_err(tdc2dev(tdc), "dma channel is not configured\n");
  813. return NULL;
  814. }
  815. if (sg_len < 1) {
  816. dev_err(tdc2dev(tdc), "Invalid segment length %d\n", sg_len);
  817. return NULL;
  818. }
  819. if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr,
  820. &burst_size, &slave_bw) < 0)
  821. return NULL;
  822. INIT_LIST_HEAD(&req_list);
  823. ahb_seq = TEGRA_APBDMA_AHBSEQ_INTR_ENB;
  824. ahb_seq |= TEGRA_APBDMA_AHBSEQ_WRAP_NONE <<
  825. TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT;
  826. ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32;
  827. csr |= TEGRA_APBDMA_CSR_ONCE;
  828. if (tdc->slave_id != TEGRA_APBDMA_SLAVE_ID_INVALID) {
  829. csr |= TEGRA_APBDMA_CSR_FLOW;
  830. csr |= tdc->slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
  831. }
  832. if (flags & DMA_PREP_INTERRUPT) {
  833. csr |= TEGRA_APBDMA_CSR_IE_EOC;
  834. } else {
  835. WARN_ON_ONCE(1);
  836. return NULL;
  837. }
  838. apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1;
  839. dma_desc = tegra_dma_desc_get(tdc);
  840. if (!dma_desc) {
  841. dev_err(tdc2dev(tdc), "Dma descriptors not available\n");
  842. return NULL;
  843. }
  844. INIT_LIST_HEAD(&dma_desc->tx_list);
  845. INIT_LIST_HEAD(&dma_desc->cb_node);
  846. dma_desc->cb_count = 0;
  847. dma_desc->bytes_requested = 0;
  848. dma_desc->bytes_transferred = 0;
  849. dma_desc->dma_status = DMA_IN_PROGRESS;
  850. /* Make transfer requests */
  851. for_each_sg(sgl, sg, sg_len, i) {
  852. u32 len, mem;
  853. mem = sg_dma_address(sg);
  854. len = sg_dma_len(sg);
  855. if ((len & 3) || (mem & 3) ||
  856. (len > tdc->tdma->chip_data->max_dma_count)) {
  857. dev_err(tdc2dev(tdc),
  858. "Dma length/memory address is not supported\n");
  859. tegra_dma_desc_put(tdc, dma_desc);
  860. return NULL;
  861. }
  862. sg_req = tegra_dma_sg_req_get(tdc);
  863. if (!sg_req) {
  864. dev_err(tdc2dev(tdc), "Dma sg-req not available\n");
  865. tegra_dma_desc_put(tdc, dma_desc);
  866. return NULL;
  867. }
  868. ahb_seq |= get_burst_size(tdc, burst_size, slave_bw, len);
  869. dma_desc->bytes_requested += len;
  870. sg_req->ch_regs.apb_ptr = apb_ptr;
  871. sg_req->ch_regs.ahb_ptr = mem;
  872. sg_req->ch_regs.csr = csr;
  873. tegra_dma_prep_wcount(tdc, &sg_req->ch_regs, len);
  874. sg_req->ch_regs.apb_seq = apb_seq;
  875. sg_req->ch_regs.ahb_seq = ahb_seq;
  876. sg_req->configured = false;
  877. sg_req->last_sg = false;
  878. sg_req->dma_desc = dma_desc;
  879. sg_req->req_len = len;
  880. list_add_tail(&sg_req->node, &dma_desc->tx_list);
  881. }
  882. sg_req->last_sg = true;
  883. if (flags & DMA_CTRL_ACK)
  884. dma_desc->txd.flags = DMA_CTRL_ACK;
  885. /*
  886. * Make sure that mode should not be conflicting with currently
  887. * configured mode.
  888. */
  889. if (!tdc->isr_handler) {
  890. tdc->isr_handler = handle_once_dma_done;
  891. tdc->cyclic = false;
  892. } else {
  893. if (tdc->cyclic) {
  894. dev_err(tdc2dev(tdc), "DMA configured in cyclic mode\n");
  895. tegra_dma_desc_put(tdc, dma_desc);
  896. return NULL;
  897. }
  898. }
  899. return &dma_desc->txd;
  900. }
  901. static struct dma_async_tx_descriptor *tegra_dma_prep_dma_cyclic(
  902. struct dma_chan *dc, dma_addr_t buf_addr, size_t buf_len,
  903. size_t period_len, enum dma_transfer_direction direction,
  904. unsigned long flags)
  905. {
  906. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  907. struct tegra_dma_desc *dma_desc = NULL;
  908. struct tegra_dma_sg_req *sg_req = NULL;
  909. unsigned long csr, ahb_seq, apb_ptr, apb_seq;
  910. int len;
  911. size_t remain_len;
  912. dma_addr_t mem = buf_addr;
  913. u32 burst_size;
  914. enum dma_slave_buswidth slave_bw;
  915. if (!buf_len || !period_len) {
  916. dev_err(tdc2dev(tdc), "Invalid buffer/period len\n");
  917. return NULL;
  918. }
  919. if (!tdc->config_init) {
  920. dev_err(tdc2dev(tdc), "DMA slave is not configured\n");
  921. return NULL;
  922. }
  923. /*
  924. * We allow to take more number of requests till DMA is
  925. * not started. The driver will loop over all requests.
  926. * Once DMA is started then new requests can be queued only after
  927. * terminating the DMA.
  928. */
  929. if (tdc->busy) {
  930. dev_err(tdc2dev(tdc), "Request not allowed when dma running\n");
  931. return NULL;
  932. }
  933. /*
  934. * We only support cycle transfer when buf_len is multiple of
  935. * period_len.
  936. */
  937. if (buf_len % period_len) {
  938. dev_err(tdc2dev(tdc), "buf_len is not multiple of period_len\n");
  939. return NULL;
  940. }
  941. len = period_len;
  942. if ((len & 3) || (buf_addr & 3) ||
  943. (len > tdc->tdma->chip_data->max_dma_count)) {
  944. dev_err(tdc2dev(tdc), "Req len/mem address is not correct\n");
  945. return NULL;
  946. }
  947. if (get_transfer_param(tdc, direction, &apb_ptr, &apb_seq, &csr,
  948. &burst_size, &slave_bw) < 0)
  949. return NULL;
  950. ahb_seq = TEGRA_APBDMA_AHBSEQ_INTR_ENB;
  951. ahb_seq |= TEGRA_APBDMA_AHBSEQ_WRAP_NONE <<
  952. TEGRA_APBDMA_AHBSEQ_WRAP_SHIFT;
  953. ahb_seq |= TEGRA_APBDMA_AHBSEQ_BUS_WIDTH_32;
  954. if (tdc->slave_id != TEGRA_APBDMA_SLAVE_ID_INVALID) {
  955. csr |= TEGRA_APBDMA_CSR_FLOW;
  956. csr |= tdc->slave_id << TEGRA_APBDMA_CSR_REQ_SEL_SHIFT;
  957. }
  958. if (flags & DMA_PREP_INTERRUPT) {
  959. csr |= TEGRA_APBDMA_CSR_IE_EOC;
  960. } else {
  961. WARN_ON_ONCE(1);
  962. return NULL;
  963. }
  964. apb_seq |= TEGRA_APBDMA_APBSEQ_WRAP_WORD_1;
  965. dma_desc = tegra_dma_desc_get(tdc);
  966. if (!dma_desc) {
  967. dev_err(tdc2dev(tdc), "not enough descriptors available\n");
  968. return NULL;
  969. }
  970. INIT_LIST_HEAD(&dma_desc->tx_list);
  971. INIT_LIST_HEAD(&dma_desc->cb_node);
  972. dma_desc->cb_count = 0;
  973. dma_desc->bytes_transferred = 0;
  974. dma_desc->bytes_requested = buf_len;
  975. remain_len = buf_len;
  976. /* Split transfer equal to period size */
  977. while (remain_len) {
  978. sg_req = tegra_dma_sg_req_get(tdc);
  979. if (!sg_req) {
  980. dev_err(tdc2dev(tdc), "Dma sg-req not available\n");
  981. tegra_dma_desc_put(tdc, dma_desc);
  982. return NULL;
  983. }
  984. ahb_seq |= get_burst_size(tdc, burst_size, slave_bw, len);
  985. sg_req->ch_regs.apb_ptr = apb_ptr;
  986. sg_req->ch_regs.ahb_ptr = mem;
  987. sg_req->ch_regs.csr = csr;
  988. tegra_dma_prep_wcount(tdc, &sg_req->ch_regs, len);
  989. sg_req->ch_regs.apb_seq = apb_seq;
  990. sg_req->ch_regs.ahb_seq = ahb_seq;
  991. sg_req->configured = false;
  992. sg_req->last_sg = false;
  993. sg_req->dma_desc = dma_desc;
  994. sg_req->req_len = len;
  995. list_add_tail(&sg_req->node, &dma_desc->tx_list);
  996. remain_len -= len;
  997. mem += len;
  998. }
  999. sg_req->last_sg = true;
  1000. if (flags & DMA_CTRL_ACK)
  1001. dma_desc->txd.flags = DMA_CTRL_ACK;
  1002. /*
  1003. * Make sure that mode should not be conflicting with currently
  1004. * configured mode.
  1005. */
  1006. if (!tdc->isr_handler) {
  1007. tdc->isr_handler = handle_cont_sngl_cycle_dma_done;
  1008. tdc->cyclic = true;
  1009. } else {
  1010. if (!tdc->cyclic) {
  1011. dev_err(tdc2dev(tdc), "DMA configuration conflict\n");
  1012. tegra_dma_desc_put(tdc, dma_desc);
  1013. return NULL;
  1014. }
  1015. }
  1016. return &dma_desc->txd;
  1017. }
  1018. static int tegra_dma_alloc_chan_resources(struct dma_chan *dc)
  1019. {
  1020. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  1021. struct tegra_dma *tdma = tdc->tdma;
  1022. int ret;
  1023. dma_cookie_init(&tdc->dma_chan);
  1024. tdc->config_init = false;
  1025. ret = pm_runtime_get_sync(tdma->dev);
  1026. if (ret < 0)
  1027. return ret;
  1028. return 0;
  1029. }
  1030. static void tegra_dma_free_chan_resources(struct dma_chan *dc)
  1031. {
  1032. struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
  1033. struct tegra_dma *tdma = tdc->tdma;
  1034. struct tegra_dma_desc *dma_desc;
  1035. struct tegra_dma_sg_req *sg_req;
  1036. struct list_head dma_desc_list;
  1037. struct list_head sg_req_list;
  1038. unsigned long flags;
  1039. INIT_LIST_HEAD(&dma_desc_list);
  1040. INIT_LIST_HEAD(&sg_req_list);
  1041. dev_dbg(tdc2dev(tdc), "Freeing channel %d\n", tdc->id);
  1042. tegra_dma_terminate_all(dc);
  1043. spin_lock_irqsave(&tdc->lock, flags);
  1044. list_splice_init(&tdc->pending_sg_req, &sg_req_list);
  1045. list_splice_init(&tdc->free_sg_req, &sg_req_list);
  1046. list_splice_init(&tdc->free_dma_desc, &dma_desc_list);
  1047. INIT_LIST_HEAD(&tdc->cb_desc);
  1048. tdc->config_init = false;
  1049. tdc->isr_handler = NULL;
  1050. spin_unlock_irqrestore(&tdc->lock, flags);
  1051. while (!list_empty(&dma_desc_list)) {
  1052. dma_desc = list_first_entry(&dma_desc_list,
  1053. typeof(*dma_desc), node);
  1054. list_del(&dma_desc->node);
  1055. kfree(dma_desc);
  1056. }
  1057. while (!list_empty(&sg_req_list)) {
  1058. sg_req = list_first_entry(&sg_req_list, typeof(*sg_req), node);
  1059. list_del(&sg_req->node);
  1060. kfree(sg_req);
  1061. }
  1062. pm_runtime_put(tdma->dev);
  1063. tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID;
  1064. }
  1065. static struct dma_chan *tegra_dma_of_xlate(struct of_phandle_args *dma_spec,
  1066. struct of_dma *ofdma)
  1067. {
  1068. struct tegra_dma *tdma = ofdma->of_dma_data;
  1069. struct dma_chan *chan;
  1070. struct tegra_dma_channel *tdc;
  1071. if (dma_spec->args[0] > TEGRA_APBDMA_CSR_REQ_SEL_MASK) {
  1072. dev_err(tdma->dev, "Invalid slave id: %d\n", dma_spec->args[0]);
  1073. return NULL;
  1074. }
  1075. chan = dma_get_any_slave_channel(&tdma->dma_dev);
  1076. if (!chan)
  1077. return NULL;
  1078. tdc = to_tegra_dma_chan(chan);
  1079. tdc->slave_id = dma_spec->args[0];
  1080. return chan;
  1081. }
  1082. /* Tegra20 specific DMA controller information */
  1083. static const struct tegra_dma_chip_data tegra20_dma_chip_data = {
  1084. .nr_channels = 16,
  1085. .channel_reg_size = 0x20,
  1086. .max_dma_count = 1024UL * 64,
  1087. .support_channel_pause = false,
  1088. .support_separate_wcount_reg = false,
  1089. };
  1090. /* Tegra30 specific DMA controller information */
  1091. static const struct tegra_dma_chip_data tegra30_dma_chip_data = {
  1092. .nr_channels = 32,
  1093. .channel_reg_size = 0x20,
  1094. .max_dma_count = 1024UL * 64,
  1095. .support_channel_pause = false,
  1096. .support_separate_wcount_reg = false,
  1097. };
  1098. /* Tegra114 specific DMA controller information */
  1099. static const struct tegra_dma_chip_data tegra114_dma_chip_data = {
  1100. .nr_channels = 32,
  1101. .channel_reg_size = 0x20,
  1102. .max_dma_count = 1024UL * 64,
  1103. .support_channel_pause = true,
  1104. .support_separate_wcount_reg = false,
  1105. };
  1106. /* Tegra148 specific DMA controller information */
  1107. static const struct tegra_dma_chip_data tegra148_dma_chip_data = {
  1108. .nr_channels = 32,
  1109. .channel_reg_size = 0x40,
  1110. .max_dma_count = 1024UL * 64,
  1111. .support_channel_pause = true,
  1112. .support_separate_wcount_reg = true,
  1113. };
  1114. static int tegra_dma_probe(struct platform_device *pdev)
  1115. {
  1116. struct resource *res;
  1117. struct tegra_dma *tdma;
  1118. int ret;
  1119. int i;
  1120. const struct tegra_dma_chip_data *cdata;
  1121. cdata = of_device_get_match_data(&pdev->dev);
  1122. if (!cdata) {
  1123. dev_err(&pdev->dev, "Error: No device match data found\n");
  1124. return -ENODEV;
  1125. }
  1126. tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
  1127. sizeof(struct tegra_dma_channel), GFP_KERNEL);
  1128. if (!tdma)
  1129. return -ENOMEM;
  1130. tdma->dev = &pdev->dev;
  1131. tdma->chip_data = cdata;
  1132. platform_set_drvdata(pdev, tdma);
  1133. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1134. tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
  1135. if (IS_ERR(tdma->base_addr))
  1136. return PTR_ERR(tdma->base_addr);
  1137. tdma->dma_clk = devm_clk_get(&pdev->dev, NULL);
  1138. if (IS_ERR(tdma->dma_clk)) {
  1139. dev_err(&pdev->dev, "Error: Missing controller clock\n");
  1140. return PTR_ERR(tdma->dma_clk);
  1141. }
  1142. tdma->rst = devm_reset_control_get(&pdev->dev, "dma");
  1143. if (IS_ERR(tdma->rst)) {
  1144. dev_err(&pdev->dev, "Error: Missing reset\n");
  1145. return PTR_ERR(tdma->rst);
  1146. }
  1147. spin_lock_init(&tdma->global_lock);
  1148. pm_runtime_enable(&pdev->dev);
  1149. if (!pm_runtime_enabled(&pdev->dev))
  1150. ret = tegra_dma_runtime_resume(&pdev->dev);
  1151. else
  1152. ret = pm_runtime_get_sync(&pdev->dev);
  1153. if (ret < 0) {
  1154. pm_runtime_disable(&pdev->dev);
  1155. return ret;
  1156. }
  1157. /* Reset DMA controller */
  1158. reset_control_assert(tdma->rst);
  1159. udelay(2);
  1160. reset_control_deassert(tdma->rst);
  1161. /* Enable global DMA registers */
  1162. tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE);
  1163. tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0);
  1164. tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul);
  1165. pm_runtime_put(&pdev->dev);
  1166. INIT_LIST_HEAD(&tdma->dma_dev.channels);
  1167. for (i = 0; i < cdata->nr_channels; i++) {
  1168. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1169. tdc->chan_addr = tdma->base_addr +
  1170. TEGRA_APBDMA_CHANNEL_BASE_ADD_OFFSET +
  1171. (i * cdata->channel_reg_size);
  1172. res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
  1173. if (!res) {
  1174. ret = -EINVAL;
  1175. dev_err(&pdev->dev, "No irq resource for chan %d\n", i);
  1176. goto err_irq;
  1177. }
  1178. tdc->irq = res->start;
  1179. snprintf(tdc->name, sizeof(tdc->name), "apbdma.%d", i);
  1180. ret = request_irq(tdc->irq, tegra_dma_isr, 0, tdc->name, tdc);
  1181. if (ret) {
  1182. dev_err(&pdev->dev,
  1183. "request_irq failed with err %d channel %d\n",
  1184. ret, i);
  1185. goto err_irq;
  1186. }
  1187. tdc->dma_chan.device = &tdma->dma_dev;
  1188. dma_cookie_init(&tdc->dma_chan);
  1189. list_add_tail(&tdc->dma_chan.device_node,
  1190. &tdma->dma_dev.channels);
  1191. tdc->tdma = tdma;
  1192. tdc->id = i;
  1193. tdc->slave_id = TEGRA_APBDMA_SLAVE_ID_INVALID;
  1194. tasklet_init(&tdc->tasklet, tegra_dma_tasklet,
  1195. (unsigned long)tdc);
  1196. spin_lock_init(&tdc->lock);
  1197. INIT_LIST_HEAD(&tdc->pending_sg_req);
  1198. INIT_LIST_HEAD(&tdc->free_sg_req);
  1199. INIT_LIST_HEAD(&tdc->free_dma_desc);
  1200. INIT_LIST_HEAD(&tdc->cb_desc);
  1201. }
  1202. dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
  1203. dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
  1204. dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);
  1205. tdma->global_pause_count = 0;
  1206. tdma->dma_dev.dev = &pdev->dev;
  1207. tdma->dma_dev.device_alloc_chan_resources =
  1208. tegra_dma_alloc_chan_resources;
  1209. tdma->dma_dev.device_free_chan_resources =
  1210. tegra_dma_free_chan_resources;
  1211. tdma->dma_dev.device_prep_slave_sg = tegra_dma_prep_slave_sg;
  1212. tdma->dma_dev.device_prep_dma_cyclic = tegra_dma_prep_dma_cyclic;
  1213. tdma->dma_dev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  1214. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  1215. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
  1216. BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);
  1217. tdma->dma_dev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  1218. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  1219. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
  1220. BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);
  1221. tdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
  1222. /*
  1223. * XXX The hardware appears to support
  1224. * DMA_RESIDUE_GRANULARITY_BURST-level reporting, but it's
  1225. * only used by this driver during tegra_dma_terminate_all()
  1226. */
  1227. tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
  1228. tdma->dma_dev.device_config = tegra_dma_slave_config;
  1229. tdma->dma_dev.device_terminate_all = tegra_dma_terminate_all;
  1230. tdma->dma_dev.device_tx_status = tegra_dma_tx_status;
  1231. tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending;
  1232. ret = dma_async_device_register(&tdma->dma_dev);
  1233. if (ret < 0) {
  1234. dev_err(&pdev->dev,
  1235. "Tegra20 APB DMA driver registration failed %d\n", ret);
  1236. goto err_irq;
  1237. }
  1238. ret = of_dma_controller_register(pdev->dev.of_node,
  1239. tegra_dma_of_xlate, tdma);
  1240. if (ret < 0) {
  1241. dev_err(&pdev->dev,
  1242. "Tegra20 APB DMA OF registration failed %d\n", ret);
  1243. goto err_unregister_dma_dev;
  1244. }
  1245. dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n",
  1246. cdata->nr_channels);
  1247. return 0;
  1248. err_unregister_dma_dev:
  1249. dma_async_device_unregister(&tdma->dma_dev);
  1250. err_irq:
  1251. while (--i >= 0) {
  1252. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1253. free_irq(tdc->irq, tdc);
  1254. tasklet_kill(&tdc->tasklet);
  1255. }
  1256. pm_runtime_disable(&pdev->dev);
  1257. if (!pm_runtime_status_suspended(&pdev->dev))
  1258. tegra_dma_runtime_suspend(&pdev->dev);
  1259. return ret;
  1260. }
  1261. static int tegra_dma_remove(struct platform_device *pdev)
  1262. {
  1263. struct tegra_dma *tdma = platform_get_drvdata(pdev);
  1264. int i;
  1265. struct tegra_dma_channel *tdc;
  1266. dma_async_device_unregister(&tdma->dma_dev);
  1267. for (i = 0; i < tdma->chip_data->nr_channels; ++i) {
  1268. tdc = &tdma->channels[i];
  1269. free_irq(tdc->irq, tdc);
  1270. tasklet_kill(&tdc->tasklet);
  1271. }
  1272. pm_runtime_disable(&pdev->dev);
  1273. if (!pm_runtime_status_suspended(&pdev->dev))
  1274. tegra_dma_runtime_suspend(&pdev->dev);
  1275. return 0;
  1276. }
  1277. static int tegra_dma_runtime_suspend(struct device *dev)
  1278. {
  1279. struct tegra_dma *tdma = dev_get_drvdata(dev);
  1280. int i;
  1281. tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL);
  1282. for (i = 0; i < tdma->chip_data->nr_channels; i++) {
  1283. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1284. struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg;
  1285. /* Only save the state of DMA channels that are in use */
  1286. if (!tdc->config_init)
  1287. continue;
  1288. ch_reg->csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR);
  1289. ch_reg->ahb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBPTR);
  1290. ch_reg->apb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBPTR);
  1291. ch_reg->ahb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBSEQ);
  1292. ch_reg->apb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBSEQ);
  1293. if (tdma->chip_data->support_separate_wcount_reg)
  1294. ch_reg->wcount = tdc_read(tdc,
  1295. TEGRA_APBDMA_CHAN_WCOUNT);
  1296. }
  1297. clk_disable_unprepare(tdma->dma_clk);
  1298. return 0;
  1299. }
  1300. static int tegra_dma_runtime_resume(struct device *dev)
  1301. {
  1302. struct tegra_dma *tdma = dev_get_drvdata(dev);
  1303. int i, ret;
  1304. ret = clk_prepare_enable(tdma->dma_clk);
  1305. if (ret < 0) {
  1306. dev_err(dev, "clk_enable failed: %d\n", ret);
  1307. return ret;
  1308. }
  1309. tdma_write(tdma, TEGRA_APBDMA_GENERAL, tdma->reg_gen);
  1310. tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0);
  1311. tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul);
  1312. for (i = 0; i < tdma->chip_data->nr_channels; i++) {
  1313. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1314. struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg;
  1315. /* Only restore the state of DMA channels that are in use */
  1316. if (!tdc->config_init)
  1317. continue;
  1318. if (tdma->chip_data->support_separate_wcount_reg)
  1319. tdc_write(tdc, TEGRA_APBDMA_CHAN_WCOUNT,
  1320. ch_reg->wcount);
  1321. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBSEQ, ch_reg->apb_seq);
  1322. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, ch_reg->apb_ptr);
  1323. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq);
  1324. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr);
  1325. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR,
  1326. (ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB));
  1327. }
  1328. return 0;
  1329. }
  1330. static const struct dev_pm_ops tegra_dma_dev_pm_ops = {
  1331. SET_RUNTIME_PM_OPS(tegra_dma_runtime_suspend, tegra_dma_runtime_resume,
  1332. NULL)
  1333. SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
  1334. pm_runtime_force_resume)
  1335. };
  1336. static const struct of_device_id tegra_dma_of_match[] = {
  1337. {
  1338. .compatible = "nvidia,tegra148-apbdma",
  1339. .data = &tegra148_dma_chip_data,
  1340. }, {
  1341. .compatible = "nvidia,tegra114-apbdma",
  1342. .data = &tegra114_dma_chip_data,
  1343. }, {
  1344. .compatible = "nvidia,tegra30-apbdma",
  1345. .data = &tegra30_dma_chip_data,
  1346. }, {
  1347. .compatible = "nvidia,tegra20-apbdma",
  1348. .data = &tegra20_dma_chip_data,
  1349. }, {
  1350. },
  1351. };
  1352. MODULE_DEVICE_TABLE(of, tegra_dma_of_match);
  1353. static struct platform_driver tegra_dmac_driver = {
  1354. .driver = {
  1355. .name = "tegra-apbdma",
  1356. .pm = &tegra_dma_dev_pm_ops,
  1357. .of_match_table = tegra_dma_of_match,
  1358. },
  1359. .probe = tegra_dma_probe,
  1360. .remove = tegra_dma_remove,
  1361. };
  1362. module_platform_driver(tegra_dmac_driver);
  1363. MODULE_ALIAS("platform:tegra20-apbdma");
  1364. MODULE_DESCRIPTION("NVIDIA Tegra APB DMA Controller driver");
  1365. MODULE_AUTHOR("Laxman Dewangan <ldewangan@nvidia.com>");
  1366. MODULE_LICENSE("GPL v2");