tegra20-apb-dma.c 44 KB

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