tegra20-apb-dma.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623
  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_ATOMIC);
  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_ATOMIC);
  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 = clk_prepare_enable(tdma->dma_clk);
  1016. if (ret < 0)
  1017. dev_err(tdc2dev(tdc), "clk_prepare_enable failed: %d\n", ret);
  1018. return ret;
  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. clk_disable_unprepare(tdma->dma_clk);
  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 const struct of_device_id tegra_dma_of_match[] = {
  1102. {
  1103. .compatible = "nvidia,tegra148-apbdma",
  1104. .data = &tegra148_dma_chip_data,
  1105. }, {
  1106. .compatible = "nvidia,tegra114-apbdma",
  1107. .data = &tegra114_dma_chip_data,
  1108. }, {
  1109. .compatible = "nvidia,tegra30-apbdma",
  1110. .data = &tegra30_dma_chip_data,
  1111. }, {
  1112. .compatible = "nvidia,tegra20-apbdma",
  1113. .data = &tegra20_dma_chip_data,
  1114. }, {
  1115. },
  1116. };
  1117. MODULE_DEVICE_TABLE(of, tegra_dma_of_match);
  1118. static int tegra_dma_probe(struct platform_device *pdev)
  1119. {
  1120. struct resource *res;
  1121. struct tegra_dma *tdma;
  1122. int ret;
  1123. int i;
  1124. const struct tegra_dma_chip_data *cdata = NULL;
  1125. const struct of_device_id *match;
  1126. match = of_match_device(tegra_dma_of_match, &pdev->dev);
  1127. if (!match) {
  1128. dev_err(&pdev->dev, "Error: No device match found\n");
  1129. return -ENODEV;
  1130. }
  1131. cdata = match->data;
  1132. tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
  1133. sizeof(struct tegra_dma_channel), GFP_KERNEL);
  1134. if (!tdma) {
  1135. dev_err(&pdev->dev, "Error: memory allocation failed\n");
  1136. return -ENOMEM;
  1137. }
  1138. tdma->dev = &pdev->dev;
  1139. tdma->chip_data = cdata;
  1140. platform_set_drvdata(pdev, tdma);
  1141. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1142. tdma->base_addr = devm_ioremap_resource(&pdev->dev, res);
  1143. if (IS_ERR(tdma->base_addr))
  1144. return PTR_ERR(tdma->base_addr);
  1145. tdma->dma_clk = devm_clk_get(&pdev->dev, NULL);
  1146. if (IS_ERR(tdma->dma_clk)) {
  1147. dev_err(&pdev->dev, "Error: Missing controller clock\n");
  1148. return PTR_ERR(tdma->dma_clk);
  1149. }
  1150. tdma->rst = devm_reset_control_get(&pdev->dev, "dma");
  1151. if (IS_ERR(tdma->rst)) {
  1152. dev_err(&pdev->dev, "Error: Missing reset\n");
  1153. return PTR_ERR(tdma->rst);
  1154. }
  1155. spin_lock_init(&tdma->global_lock);
  1156. pm_runtime_enable(&pdev->dev);
  1157. if (!pm_runtime_enabled(&pdev->dev)) {
  1158. ret = tegra_dma_runtime_resume(&pdev->dev);
  1159. if (ret) {
  1160. dev_err(&pdev->dev, "dma_runtime_resume failed %d\n",
  1161. ret);
  1162. goto err_pm_disable;
  1163. }
  1164. }
  1165. /* Enable clock before accessing registers */
  1166. ret = clk_prepare_enable(tdma->dma_clk);
  1167. if (ret < 0) {
  1168. dev_err(&pdev->dev, "clk_prepare_enable failed: %d\n", ret);
  1169. goto err_pm_disable;
  1170. }
  1171. /* Reset DMA controller */
  1172. reset_control_assert(tdma->rst);
  1173. udelay(2);
  1174. reset_control_deassert(tdma->rst);
  1175. /* Enable global DMA registers */
  1176. tdma_write(tdma, TEGRA_APBDMA_GENERAL, TEGRA_APBDMA_GENERAL_ENABLE);
  1177. tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0);
  1178. tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul);
  1179. clk_disable_unprepare(tdma->dma_clk);
  1180. INIT_LIST_HEAD(&tdma->dma_dev.channels);
  1181. for (i = 0; i < cdata->nr_channels; i++) {
  1182. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1183. tdc->chan_addr = tdma->base_addr +
  1184. TEGRA_APBDMA_CHANNEL_BASE_ADD_OFFSET +
  1185. (i * cdata->channel_reg_size);
  1186. res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
  1187. if (!res) {
  1188. ret = -EINVAL;
  1189. dev_err(&pdev->dev, "No irq resource for chan %d\n", i);
  1190. goto err_irq;
  1191. }
  1192. tdc->irq = res->start;
  1193. snprintf(tdc->name, sizeof(tdc->name), "apbdma.%d", i);
  1194. ret = devm_request_irq(&pdev->dev, tdc->irq,
  1195. tegra_dma_isr, 0, tdc->name, tdc);
  1196. if (ret) {
  1197. dev_err(&pdev->dev,
  1198. "request_irq failed with err %d channel %d\n",
  1199. ret, i);
  1200. goto err_irq;
  1201. }
  1202. tdc->dma_chan.device = &tdma->dma_dev;
  1203. dma_cookie_init(&tdc->dma_chan);
  1204. list_add_tail(&tdc->dma_chan.device_node,
  1205. &tdma->dma_dev.channels);
  1206. tdc->tdma = tdma;
  1207. tdc->id = i;
  1208. tasklet_init(&tdc->tasklet, tegra_dma_tasklet,
  1209. (unsigned long)tdc);
  1210. spin_lock_init(&tdc->lock);
  1211. INIT_LIST_HEAD(&tdc->pending_sg_req);
  1212. INIT_LIST_HEAD(&tdc->free_sg_req);
  1213. INIT_LIST_HEAD(&tdc->free_dma_desc);
  1214. INIT_LIST_HEAD(&tdc->cb_desc);
  1215. }
  1216. dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
  1217. dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
  1218. dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);
  1219. tdma->global_pause_count = 0;
  1220. tdma->dma_dev.dev = &pdev->dev;
  1221. tdma->dma_dev.device_alloc_chan_resources =
  1222. tegra_dma_alloc_chan_resources;
  1223. tdma->dma_dev.device_free_chan_resources =
  1224. tegra_dma_free_chan_resources;
  1225. tdma->dma_dev.device_prep_slave_sg = tegra_dma_prep_slave_sg;
  1226. tdma->dma_dev.device_prep_dma_cyclic = tegra_dma_prep_dma_cyclic;
  1227. tdma->dma_dev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  1228. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  1229. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
  1230. BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);
  1231. tdma->dma_dev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) |
  1232. BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) |
  1233. BIT(DMA_SLAVE_BUSWIDTH_4_BYTES) |
  1234. BIT(DMA_SLAVE_BUSWIDTH_8_BYTES);
  1235. tdma->dma_dev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
  1236. /*
  1237. * XXX The hardware appears to support
  1238. * DMA_RESIDUE_GRANULARITY_BURST-level reporting, but it's
  1239. * only used by this driver during tegra_dma_terminate_all()
  1240. */
  1241. tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
  1242. tdma->dma_dev.device_config = tegra_dma_slave_config;
  1243. tdma->dma_dev.device_terminate_all = tegra_dma_terminate_all;
  1244. tdma->dma_dev.device_tx_status = tegra_dma_tx_status;
  1245. tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending;
  1246. ret = dma_async_device_register(&tdma->dma_dev);
  1247. if (ret < 0) {
  1248. dev_err(&pdev->dev,
  1249. "Tegra20 APB DMA driver registration failed %d\n", ret);
  1250. goto err_irq;
  1251. }
  1252. ret = of_dma_controller_register(pdev->dev.of_node,
  1253. tegra_dma_of_xlate, tdma);
  1254. if (ret < 0) {
  1255. dev_err(&pdev->dev,
  1256. "Tegra20 APB DMA OF registration failed %d\n", ret);
  1257. goto err_unregister_dma_dev;
  1258. }
  1259. dev_info(&pdev->dev, "Tegra20 APB DMA driver register %d channels\n",
  1260. cdata->nr_channels);
  1261. return 0;
  1262. err_unregister_dma_dev:
  1263. dma_async_device_unregister(&tdma->dma_dev);
  1264. err_irq:
  1265. while (--i >= 0) {
  1266. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1267. tasklet_kill(&tdc->tasklet);
  1268. }
  1269. err_pm_disable:
  1270. pm_runtime_disable(&pdev->dev);
  1271. if (!pm_runtime_status_suspended(&pdev->dev))
  1272. tegra_dma_runtime_suspend(&pdev->dev);
  1273. return ret;
  1274. }
  1275. static int tegra_dma_remove(struct platform_device *pdev)
  1276. {
  1277. struct tegra_dma *tdma = platform_get_drvdata(pdev);
  1278. int i;
  1279. struct tegra_dma_channel *tdc;
  1280. dma_async_device_unregister(&tdma->dma_dev);
  1281. for (i = 0; i < tdma->chip_data->nr_channels; ++i) {
  1282. tdc = &tdma->channels[i];
  1283. tasklet_kill(&tdc->tasklet);
  1284. }
  1285. pm_runtime_disable(&pdev->dev);
  1286. if (!pm_runtime_status_suspended(&pdev->dev))
  1287. tegra_dma_runtime_suspend(&pdev->dev);
  1288. return 0;
  1289. }
  1290. static int tegra_dma_runtime_suspend(struct device *dev)
  1291. {
  1292. struct platform_device *pdev = to_platform_device(dev);
  1293. struct tegra_dma *tdma = platform_get_drvdata(pdev);
  1294. clk_disable_unprepare(tdma->dma_clk);
  1295. return 0;
  1296. }
  1297. static int tegra_dma_runtime_resume(struct device *dev)
  1298. {
  1299. struct platform_device *pdev = to_platform_device(dev);
  1300. struct tegra_dma *tdma = platform_get_drvdata(pdev);
  1301. int ret;
  1302. ret = clk_prepare_enable(tdma->dma_clk);
  1303. if (ret < 0) {
  1304. dev_err(dev, "clk_enable failed: %d\n", ret);
  1305. return ret;
  1306. }
  1307. return 0;
  1308. }
  1309. #ifdef CONFIG_PM_SLEEP
  1310. static int tegra_dma_pm_suspend(struct device *dev)
  1311. {
  1312. struct tegra_dma *tdma = dev_get_drvdata(dev);
  1313. int i;
  1314. int ret;
  1315. /* Enable clock before accessing register */
  1316. ret = tegra_dma_runtime_resume(dev);
  1317. if (ret < 0)
  1318. return ret;
  1319. tdma->reg_gen = tdma_read(tdma, TEGRA_APBDMA_GENERAL);
  1320. for (i = 0; i < tdma->chip_data->nr_channels; i++) {
  1321. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1322. struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg;
  1323. ch_reg->csr = tdc_read(tdc, TEGRA_APBDMA_CHAN_CSR);
  1324. ch_reg->ahb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBPTR);
  1325. ch_reg->apb_ptr = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBPTR);
  1326. ch_reg->ahb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_AHBSEQ);
  1327. ch_reg->apb_seq = tdc_read(tdc, TEGRA_APBDMA_CHAN_APBSEQ);
  1328. }
  1329. /* Disable clock */
  1330. tegra_dma_runtime_suspend(dev);
  1331. return 0;
  1332. }
  1333. static int tegra_dma_pm_resume(struct device *dev)
  1334. {
  1335. struct tegra_dma *tdma = dev_get_drvdata(dev);
  1336. int i;
  1337. int ret;
  1338. /* Enable clock before accessing register */
  1339. ret = tegra_dma_runtime_resume(dev);
  1340. if (ret < 0)
  1341. return ret;
  1342. tdma_write(tdma, TEGRA_APBDMA_GENERAL, tdma->reg_gen);
  1343. tdma_write(tdma, TEGRA_APBDMA_CONTROL, 0);
  1344. tdma_write(tdma, TEGRA_APBDMA_IRQ_MASK_SET, 0xFFFFFFFFul);
  1345. for (i = 0; i < tdma->chip_data->nr_channels; i++) {
  1346. struct tegra_dma_channel *tdc = &tdma->channels[i];
  1347. struct tegra_dma_channel_regs *ch_reg = &tdc->channel_reg;
  1348. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBSEQ, ch_reg->apb_seq);
  1349. tdc_write(tdc, TEGRA_APBDMA_CHAN_APBPTR, ch_reg->apb_ptr);
  1350. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBSEQ, ch_reg->ahb_seq);
  1351. tdc_write(tdc, TEGRA_APBDMA_CHAN_AHBPTR, ch_reg->ahb_ptr);
  1352. tdc_write(tdc, TEGRA_APBDMA_CHAN_CSR,
  1353. (ch_reg->csr & ~TEGRA_APBDMA_CSR_ENB));
  1354. }
  1355. /* Disable clock */
  1356. tegra_dma_runtime_suspend(dev);
  1357. return 0;
  1358. }
  1359. #endif
  1360. static const struct dev_pm_ops tegra_dma_dev_pm_ops = {
  1361. #ifdef CONFIG_PM
  1362. .runtime_suspend = tegra_dma_runtime_suspend,
  1363. .runtime_resume = tegra_dma_runtime_resume,
  1364. #endif
  1365. SET_SYSTEM_SLEEP_PM_OPS(tegra_dma_pm_suspend, tegra_dma_pm_resume)
  1366. };
  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");