tegra20-apb-dma.c 44 KB

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