tegra20-apb-dma.c 44 KB

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