coh901318.c 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840
  1. /*
  2. * driver/dma/coh901318.c
  3. *
  4. * Copyright (C) 2007-2009 ST-Ericsson
  5. * License terms: GNU General Public License (GPL) version 2
  6. * DMA driver for COH 901 318
  7. * Author: Per Friden <per.friden@stericsson.com>
  8. */
  9. #include <linux/init.h>
  10. #include <linux/module.h>
  11. #include <linux/kernel.h> /* printk() */
  12. #include <linux/fs.h> /* everything... */
  13. #include <linux/scatterlist.h>
  14. #include <linux/slab.h> /* kmalloc() */
  15. #include <linux/dmaengine.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/device.h>
  18. #include <linux/irqreturn.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/io.h>
  21. #include <linux/uaccess.h>
  22. #include <linux/debugfs.h>
  23. #include <linux/platform_data/dma-coh901318.h>
  24. #include "coh901318.h"
  25. #include "dmaengine.h"
  26. #define COH901318_MOD32_MASK (0x1F)
  27. #define COH901318_WORD_MASK (0xFFFFFFFF)
  28. /* INT_STATUS - Interrupt Status Registers 32bit (R/-) */
  29. #define COH901318_INT_STATUS1 (0x0000)
  30. #define COH901318_INT_STATUS2 (0x0004)
  31. /* TC_INT_STATUS - Terminal Count Interrupt Status Registers 32bit (R/-) */
  32. #define COH901318_TC_INT_STATUS1 (0x0008)
  33. #define COH901318_TC_INT_STATUS2 (0x000C)
  34. /* TC_INT_CLEAR - Terminal Count Interrupt Clear Registers 32bit (-/W) */
  35. #define COH901318_TC_INT_CLEAR1 (0x0010)
  36. #define COH901318_TC_INT_CLEAR2 (0x0014)
  37. /* RAW_TC_INT_STATUS - Raw Term Count Interrupt Status Registers 32bit (R/-) */
  38. #define COH901318_RAW_TC_INT_STATUS1 (0x0018)
  39. #define COH901318_RAW_TC_INT_STATUS2 (0x001C)
  40. /* BE_INT_STATUS - Bus Error Interrupt Status Registers 32bit (R/-) */
  41. #define COH901318_BE_INT_STATUS1 (0x0020)
  42. #define COH901318_BE_INT_STATUS2 (0x0024)
  43. /* BE_INT_CLEAR - Bus Error Interrupt Clear Registers 32bit (-/W) */
  44. #define COH901318_BE_INT_CLEAR1 (0x0028)
  45. #define COH901318_BE_INT_CLEAR2 (0x002C)
  46. /* RAW_BE_INT_STATUS - Raw Term Count Interrupt Status Registers 32bit (R/-) */
  47. #define COH901318_RAW_BE_INT_STATUS1 (0x0030)
  48. #define COH901318_RAW_BE_INT_STATUS2 (0x0034)
  49. /*
  50. * CX_CFG - Channel Configuration Registers 32bit (R/W)
  51. */
  52. #define COH901318_CX_CFG (0x0100)
  53. #define COH901318_CX_CFG_SPACING (0x04)
  54. /* Channel enable activates tha dma job */
  55. #define COH901318_CX_CFG_CH_ENABLE (0x00000001)
  56. #define COH901318_CX_CFG_CH_DISABLE (0x00000000)
  57. /* Request Mode */
  58. #define COH901318_CX_CFG_RM_MASK (0x00000006)
  59. #define COH901318_CX_CFG_RM_MEMORY_TO_MEMORY (0x0 << 1)
  60. #define COH901318_CX_CFG_RM_PRIMARY_TO_MEMORY (0x1 << 1)
  61. #define COH901318_CX_CFG_RM_MEMORY_TO_PRIMARY (0x1 << 1)
  62. #define COH901318_CX_CFG_RM_PRIMARY_TO_SECONDARY (0x3 << 1)
  63. #define COH901318_CX_CFG_RM_SECONDARY_TO_PRIMARY (0x3 << 1)
  64. /* Linked channel request field. RM must == 11 */
  65. #define COH901318_CX_CFG_LCRF_SHIFT 3
  66. #define COH901318_CX_CFG_LCRF_MASK (0x000001F8)
  67. #define COH901318_CX_CFG_LCR_DISABLE (0x00000000)
  68. /* Terminal Counter Interrupt Request Mask */
  69. #define COH901318_CX_CFG_TC_IRQ_ENABLE (0x00000200)
  70. #define COH901318_CX_CFG_TC_IRQ_DISABLE (0x00000000)
  71. /* Bus Error interrupt Mask */
  72. #define COH901318_CX_CFG_BE_IRQ_ENABLE (0x00000400)
  73. #define COH901318_CX_CFG_BE_IRQ_DISABLE (0x00000000)
  74. /*
  75. * CX_STAT - Channel Status Registers 32bit (R/-)
  76. */
  77. #define COH901318_CX_STAT (0x0200)
  78. #define COH901318_CX_STAT_SPACING (0x04)
  79. #define COH901318_CX_STAT_RBE_IRQ_IND (0x00000008)
  80. #define COH901318_CX_STAT_RTC_IRQ_IND (0x00000004)
  81. #define COH901318_CX_STAT_ACTIVE (0x00000002)
  82. #define COH901318_CX_STAT_ENABLED (0x00000001)
  83. /*
  84. * CX_CTRL - Channel Control Registers 32bit (R/W)
  85. */
  86. #define COH901318_CX_CTRL (0x0400)
  87. #define COH901318_CX_CTRL_SPACING (0x10)
  88. /* Transfer Count Enable */
  89. #define COH901318_CX_CTRL_TC_ENABLE (0x00001000)
  90. #define COH901318_CX_CTRL_TC_DISABLE (0x00000000)
  91. /* Transfer Count Value 0 - 4095 */
  92. #define COH901318_CX_CTRL_TC_VALUE_MASK (0x00000FFF)
  93. /* Burst count */
  94. #define COH901318_CX_CTRL_BURST_COUNT_MASK (0x0000E000)
  95. #define COH901318_CX_CTRL_BURST_COUNT_64_BYTES (0x7 << 13)
  96. #define COH901318_CX_CTRL_BURST_COUNT_48_BYTES (0x6 << 13)
  97. #define COH901318_CX_CTRL_BURST_COUNT_32_BYTES (0x5 << 13)
  98. #define COH901318_CX_CTRL_BURST_COUNT_16_BYTES (0x4 << 13)
  99. #define COH901318_CX_CTRL_BURST_COUNT_8_BYTES (0x3 << 13)
  100. #define COH901318_CX_CTRL_BURST_COUNT_4_BYTES (0x2 << 13)
  101. #define COH901318_CX_CTRL_BURST_COUNT_2_BYTES (0x1 << 13)
  102. #define COH901318_CX_CTRL_BURST_COUNT_1_BYTE (0x0 << 13)
  103. /* Source bus size */
  104. #define COH901318_CX_CTRL_SRC_BUS_SIZE_MASK (0x00030000)
  105. #define COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS (0x2 << 16)
  106. #define COH901318_CX_CTRL_SRC_BUS_SIZE_16_BITS (0x1 << 16)
  107. #define COH901318_CX_CTRL_SRC_BUS_SIZE_8_BITS (0x0 << 16)
  108. /* Source address increment */
  109. #define COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE (0x00040000)
  110. #define COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE (0x00000000)
  111. /* Destination Bus Size */
  112. #define COH901318_CX_CTRL_DST_BUS_SIZE_MASK (0x00180000)
  113. #define COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS (0x2 << 19)
  114. #define COH901318_CX_CTRL_DST_BUS_SIZE_16_BITS (0x1 << 19)
  115. #define COH901318_CX_CTRL_DST_BUS_SIZE_8_BITS (0x0 << 19)
  116. /* Destination address increment */
  117. #define COH901318_CX_CTRL_DST_ADDR_INC_ENABLE (0x00200000)
  118. #define COH901318_CX_CTRL_DST_ADDR_INC_DISABLE (0x00000000)
  119. /* Master Mode (Master2 is only connected to MSL) */
  120. #define COH901318_CX_CTRL_MASTER_MODE_MASK (0x00C00000)
  121. #define COH901318_CX_CTRL_MASTER_MODE_M2R_M1W (0x3 << 22)
  122. #define COH901318_CX_CTRL_MASTER_MODE_M1R_M2W (0x2 << 22)
  123. #define COH901318_CX_CTRL_MASTER_MODE_M2RW (0x1 << 22)
  124. #define COH901318_CX_CTRL_MASTER_MODE_M1RW (0x0 << 22)
  125. /* Terminal Count flag to PER enable */
  126. #define COH901318_CX_CTRL_TCP_ENABLE (0x01000000)
  127. #define COH901318_CX_CTRL_TCP_DISABLE (0x00000000)
  128. /* Terminal Count flags to CPU enable */
  129. #define COH901318_CX_CTRL_TC_IRQ_ENABLE (0x02000000)
  130. #define COH901318_CX_CTRL_TC_IRQ_DISABLE (0x00000000)
  131. /* Hand shake to peripheral */
  132. #define COH901318_CX_CTRL_HSP_ENABLE (0x04000000)
  133. #define COH901318_CX_CTRL_HSP_DISABLE (0x00000000)
  134. #define COH901318_CX_CTRL_HSS_ENABLE (0x08000000)
  135. #define COH901318_CX_CTRL_HSS_DISABLE (0x00000000)
  136. /* DMA mode */
  137. #define COH901318_CX_CTRL_DDMA_MASK (0x30000000)
  138. #define COH901318_CX_CTRL_DDMA_LEGACY (0x0 << 28)
  139. #define COH901318_CX_CTRL_DDMA_DEMAND_DMA1 (0x1 << 28)
  140. #define COH901318_CX_CTRL_DDMA_DEMAND_DMA2 (0x2 << 28)
  141. /* Primary Request Data Destination */
  142. #define COH901318_CX_CTRL_PRDD_MASK (0x40000000)
  143. #define COH901318_CX_CTRL_PRDD_DEST (0x1 << 30)
  144. #define COH901318_CX_CTRL_PRDD_SOURCE (0x0 << 30)
  145. /*
  146. * CX_SRC_ADDR - Channel Source Address Registers 32bit (R/W)
  147. */
  148. #define COH901318_CX_SRC_ADDR (0x0404)
  149. #define COH901318_CX_SRC_ADDR_SPACING (0x10)
  150. /*
  151. * CX_DST_ADDR - Channel Destination Address Registers 32bit R/W
  152. */
  153. #define COH901318_CX_DST_ADDR (0x0408)
  154. #define COH901318_CX_DST_ADDR_SPACING (0x10)
  155. /*
  156. * CX_LNK_ADDR - Channel Link Address Registers 32bit (R/W)
  157. */
  158. #define COH901318_CX_LNK_ADDR (0x040C)
  159. #define COH901318_CX_LNK_ADDR_SPACING (0x10)
  160. #define COH901318_CX_LNK_LINK_IMMEDIATE (0x00000001)
  161. /**
  162. * struct coh901318_params - parameters for DMAC configuration
  163. * @config: DMA config register
  164. * @ctrl_lli_last: DMA control register for the last lli in the list
  165. * @ctrl_lli: DMA control register for an lli
  166. * @ctrl_lli_chained: DMA control register for a chained lli
  167. */
  168. struct coh901318_params {
  169. u32 config;
  170. u32 ctrl_lli_last;
  171. u32 ctrl_lli;
  172. u32 ctrl_lli_chained;
  173. };
  174. /**
  175. * struct coh_dma_channel - dma channel base
  176. * @name: ascii name of dma channel
  177. * @number: channel id number
  178. * @desc_nbr_max: number of preallocated descriptors
  179. * @priority_high: prio of channel, 0 low otherwise high.
  180. * @param: configuration parameters
  181. */
  182. struct coh_dma_channel {
  183. const char name[32];
  184. const int number;
  185. const int desc_nbr_max;
  186. const int priority_high;
  187. const struct coh901318_params param;
  188. };
  189. /**
  190. * dma_access_memory_state_t - register dma for memory access
  191. *
  192. * @dev: The dma device
  193. * @active: 1 means dma intends to access memory
  194. * 0 means dma wont access memory
  195. */
  196. typedef void (*dma_access_memory_state_t)(struct device *dev,
  197. bool active);
  198. /**
  199. * struct powersave - DMA power save structure
  200. * @lock: lock protecting data in this struct
  201. * @started_channels: bit mask indicating active dma channels
  202. */
  203. struct powersave {
  204. spinlock_t lock;
  205. u64 started_channels;
  206. };
  207. /**
  208. * struct coh901318_platform - platform arch structure
  209. * @chans_slave: specifying dma slave channels
  210. * @chans_memcpy: specifying dma memcpy channels
  211. * @access_memory_state: requesting DMA memory access (on / off)
  212. * @chan_conf: dma channel configurations
  213. * @max_channels: max number of dma chanenls
  214. */
  215. struct coh901318_platform {
  216. const int *chans_slave;
  217. const int *chans_memcpy;
  218. const dma_access_memory_state_t access_memory_state;
  219. const struct coh_dma_channel *chan_conf;
  220. const int max_channels;
  221. };
  222. /* points out all dma slave channels.
  223. * Syntax is [A1, B1, A2, B2, .... ,-1,-1]
  224. * Select all channels from A to B, end of list is marked with -1,-1
  225. */
  226. static int dma_slave_channels[] = {
  227. U300_DMA_MSL_TX_0, U300_DMA_SPI_RX,
  228. U300_DMA_UART1_TX, U300_DMA_UART1_RX, -1, -1};
  229. /* points out all dma memcpy channels. */
  230. static int dma_memcpy_channels[] = {
  231. U300_DMA_GENERAL_PURPOSE_0, U300_DMA_GENERAL_PURPOSE_8, -1, -1};
  232. /** register dma for memory access
  233. *
  234. * active 1 means dma intends to access memory
  235. * 0 means dma wont access memory
  236. */
  237. static void coh901318_access_memory_state(struct device *dev, bool active)
  238. {
  239. }
  240. #define flags_memcpy_config (COH901318_CX_CFG_CH_DISABLE | \
  241. COH901318_CX_CFG_RM_MEMORY_TO_MEMORY | \
  242. COH901318_CX_CFG_LCR_DISABLE | \
  243. COH901318_CX_CFG_TC_IRQ_ENABLE | \
  244. COH901318_CX_CFG_BE_IRQ_ENABLE)
  245. #define flags_memcpy_lli_chained (COH901318_CX_CTRL_TC_ENABLE | \
  246. COH901318_CX_CTRL_BURST_COUNT_32_BYTES | \
  247. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS | \
  248. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE | \
  249. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS | \
  250. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE | \
  251. COH901318_CX_CTRL_MASTER_MODE_M1RW | \
  252. COH901318_CX_CTRL_TCP_DISABLE | \
  253. COH901318_CX_CTRL_TC_IRQ_DISABLE | \
  254. COH901318_CX_CTRL_HSP_DISABLE | \
  255. COH901318_CX_CTRL_HSS_DISABLE | \
  256. COH901318_CX_CTRL_DDMA_LEGACY | \
  257. COH901318_CX_CTRL_PRDD_SOURCE)
  258. #define flags_memcpy_lli (COH901318_CX_CTRL_TC_ENABLE | \
  259. COH901318_CX_CTRL_BURST_COUNT_32_BYTES | \
  260. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS | \
  261. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE | \
  262. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS | \
  263. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE | \
  264. COH901318_CX_CTRL_MASTER_MODE_M1RW | \
  265. COH901318_CX_CTRL_TCP_DISABLE | \
  266. COH901318_CX_CTRL_TC_IRQ_DISABLE | \
  267. COH901318_CX_CTRL_HSP_DISABLE | \
  268. COH901318_CX_CTRL_HSS_DISABLE | \
  269. COH901318_CX_CTRL_DDMA_LEGACY | \
  270. COH901318_CX_CTRL_PRDD_SOURCE)
  271. #define flags_memcpy_lli_last (COH901318_CX_CTRL_TC_ENABLE | \
  272. COH901318_CX_CTRL_BURST_COUNT_32_BYTES | \
  273. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS | \
  274. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE | \
  275. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS | \
  276. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE | \
  277. COH901318_CX_CTRL_MASTER_MODE_M1RW | \
  278. COH901318_CX_CTRL_TCP_DISABLE | \
  279. COH901318_CX_CTRL_TC_IRQ_ENABLE | \
  280. COH901318_CX_CTRL_HSP_DISABLE | \
  281. COH901318_CX_CTRL_HSS_DISABLE | \
  282. COH901318_CX_CTRL_DDMA_LEGACY | \
  283. COH901318_CX_CTRL_PRDD_SOURCE)
  284. const struct coh_dma_channel chan_config[U300_DMA_CHANNELS] = {
  285. {
  286. .number = U300_DMA_MSL_TX_0,
  287. .name = "MSL TX 0",
  288. .priority_high = 0,
  289. },
  290. {
  291. .number = U300_DMA_MSL_TX_1,
  292. .name = "MSL TX 1",
  293. .priority_high = 0,
  294. .param.config = COH901318_CX_CFG_CH_DISABLE |
  295. COH901318_CX_CFG_LCR_DISABLE |
  296. COH901318_CX_CFG_TC_IRQ_ENABLE |
  297. COH901318_CX_CFG_BE_IRQ_ENABLE,
  298. .param.ctrl_lli_chained = 0 |
  299. COH901318_CX_CTRL_TC_ENABLE |
  300. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  301. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  302. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  303. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  304. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  305. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  306. COH901318_CX_CTRL_TCP_DISABLE |
  307. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  308. COH901318_CX_CTRL_HSP_ENABLE |
  309. COH901318_CX_CTRL_HSS_DISABLE |
  310. COH901318_CX_CTRL_DDMA_LEGACY |
  311. COH901318_CX_CTRL_PRDD_SOURCE,
  312. .param.ctrl_lli = 0 |
  313. COH901318_CX_CTRL_TC_ENABLE |
  314. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  315. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  316. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  317. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  318. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  319. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  320. COH901318_CX_CTRL_TCP_ENABLE |
  321. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  322. COH901318_CX_CTRL_HSP_ENABLE |
  323. COH901318_CX_CTRL_HSS_DISABLE |
  324. COH901318_CX_CTRL_DDMA_LEGACY |
  325. COH901318_CX_CTRL_PRDD_SOURCE,
  326. .param.ctrl_lli_last = 0 |
  327. COH901318_CX_CTRL_TC_ENABLE |
  328. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  329. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  330. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  331. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  332. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  333. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  334. COH901318_CX_CTRL_TCP_ENABLE |
  335. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  336. COH901318_CX_CTRL_HSP_ENABLE |
  337. COH901318_CX_CTRL_HSS_DISABLE |
  338. COH901318_CX_CTRL_DDMA_LEGACY |
  339. COH901318_CX_CTRL_PRDD_SOURCE,
  340. },
  341. {
  342. .number = U300_DMA_MSL_TX_2,
  343. .name = "MSL TX 2",
  344. .priority_high = 0,
  345. .param.config = COH901318_CX_CFG_CH_DISABLE |
  346. COH901318_CX_CFG_LCR_DISABLE |
  347. COH901318_CX_CFG_TC_IRQ_ENABLE |
  348. COH901318_CX_CFG_BE_IRQ_ENABLE,
  349. .param.ctrl_lli_chained = 0 |
  350. COH901318_CX_CTRL_TC_ENABLE |
  351. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  352. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  353. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  354. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  355. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  356. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  357. COH901318_CX_CTRL_TCP_DISABLE |
  358. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  359. COH901318_CX_CTRL_HSP_ENABLE |
  360. COH901318_CX_CTRL_HSS_DISABLE |
  361. COH901318_CX_CTRL_DDMA_LEGACY |
  362. COH901318_CX_CTRL_PRDD_SOURCE,
  363. .param.ctrl_lli = 0 |
  364. COH901318_CX_CTRL_TC_ENABLE |
  365. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  366. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  367. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  368. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  369. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  370. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  371. COH901318_CX_CTRL_TCP_ENABLE |
  372. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  373. COH901318_CX_CTRL_HSP_ENABLE |
  374. COH901318_CX_CTRL_HSS_DISABLE |
  375. COH901318_CX_CTRL_DDMA_LEGACY |
  376. COH901318_CX_CTRL_PRDD_SOURCE,
  377. .param.ctrl_lli_last = 0 |
  378. COH901318_CX_CTRL_TC_ENABLE |
  379. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  380. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  381. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  382. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  383. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  384. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  385. COH901318_CX_CTRL_TCP_ENABLE |
  386. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  387. COH901318_CX_CTRL_HSP_ENABLE |
  388. COH901318_CX_CTRL_HSS_DISABLE |
  389. COH901318_CX_CTRL_DDMA_LEGACY |
  390. COH901318_CX_CTRL_PRDD_SOURCE,
  391. .desc_nbr_max = 10,
  392. },
  393. {
  394. .number = U300_DMA_MSL_TX_3,
  395. .name = "MSL TX 3",
  396. .priority_high = 0,
  397. .param.config = COH901318_CX_CFG_CH_DISABLE |
  398. COH901318_CX_CFG_LCR_DISABLE |
  399. COH901318_CX_CFG_TC_IRQ_ENABLE |
  400. COH901318_CX_CFG_BE_IRQ_ENABLE,
  401. .param.ctrl_lli_chained = 0 |
  402. COH901318_CX_CTRL_TC_ENABLE |
  403. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  404. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  405. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  406. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  407. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  408. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  409. COH901318_CX_CTRL_TCP_DISABLE |
  410. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  411. COH901318_CX_CTRL_HSP_ENABLE |
  412. COH901318_CX_CTRL_HSS_DISABLE |
  413. COH901318_CX_CTRL_DDMA_LEGACY |
  414. COH901318_CX_CTRL_PRDD_SOURCE,
  415. .param.ctrl_lli = 0 |
  416. COH901318_CX_CTRL_TC_ENABLE |
  417. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  418. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  419. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  420. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  421. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  422. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  423. COH901318_CX_CTRL_TCP_ENABLE |
  424. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  425. COH901318_CX_CTRL_HSP_ENABLE |
  426. COH901318_CX_CTRL_HSS_DISABLE |
  427. COH901318_CX_CTRL_DDMA_LEGACY |
  428. COH901318_CX_CTRL_PRDD_SOURCE,
  429. .param.ctrl_lli_last = 0 |
  430. COH901318_CX_CTRL_TC_ENABLE |
  431. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  432. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  433. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  434. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  435. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  436. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  437. COH901318_CX_CTRL_TCP_ENABLE |
  438. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  439. COH901318_CX_CTRL_HSP_ENABLE |
  440. COH901318_CX_CTRL_HSS_DISABLE |
  441. COH901318_CX_CTRL_DDMA_LEGACY |
  442. COH901318_CX_CTRL_PRDD_SOURCE,
  443. },
  444. {
  445. .number = U300_DMA_MSL_TX_4,
  446. .name = "MSL TX 4",
  447. .priority_high = 0,
  448. .param.config = COH901318_CX_CFG_CH_DISABLE |
  449. COH901318_CX_CFG_LCR_DISABLE |
  450. COH901318_CX_CFG_TC_IRQ_ENABLE |
  451. COH901318_CX_CFG_BE_IRQ_ENABLE,
  452. .param.ctrl_lli_chained = 0 |
  453. COH901318_CX_CTRL_TC_ENABLE |
  454. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  455. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  456. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  457. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  458. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  459. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  460. COH901318_CX_CTRL_TCP_DISABLE |
  461. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  462. COH901318_CX_CTRL_HSP_ENABLE |
  463. COH901318_CX_CTRL_HSS_DISABLE |
  464. COH901318_CX_CTRL_DDMA_LEGACY |
  465. COH901318_CX_CTRL_PRDD_SOURCE,
  466. .param.ctrl_lli = 0 |
  467. COH901318_CX_CTRL_TC_ENABLE |
  468. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  469. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  470. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  471. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  472. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  473. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  474. COH901318_CX_CTRL_TCP_ENABLE |
  475. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  476. COH901318_CX_CTRL_HSP_ENABLE |
  477. COH901318_CX_CTRL_HSS_DISABLE |
  478. COH901318_CX_CTRL_DDMA_LEGACY |
  479. COH901318_CX_CTRL_PRDD_SOURCE,
  480. .param.ctrl_lli_last = 0 |
  481. COH901318_CX_CTRL_TC_ENABLE |
  482. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  483. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  484. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  485. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  486. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  487. COH901318_CX_CTRL_MASTER_MODE_M1R_M2W |
  488. COH901318_CX_CTRL_TCP_ENABLE |
  489. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  490. COH901318_CX_CTRL_HSP_ENABLE |
  491. COH901318_CX_CTRL_HSS_DISABLE |
  492. COH901318_CX_CTRL_DDMA_LEGACY |
  493. COH901318_CX_CTRL_PRDD_SOURCE,
  494. },
  495. {
  496. .number = U300_DMA_MSL_TX_5,
  497. .name = "MSL TX 5",
  498. .priority_high = 0,
  499. },
  500. {
  501. .number = U300_DMA_MSL_TX_6,
  502. .name = "MSL TX 6",
  503. .priority_high = 0,
  504. },
  505. {
  506. .number = U300_DMA_MSL_RX_0,
  507. .name = "MSL RX 0",
  508. .priority_high = 0,
  509. },
  510. {
  511. .number = U300_DMA_MSL_RX_1,
  512. .name = "MSL RX 1",
  513. .priority_high = 0,
  514. .param.config = COH901318_CX_CFG_CH_DISABLE |
  515. COH901318_CX_CFG_LCR_DISABLE |
  516. COH901318_CX_CFG_TC_IRQ_ENABLE |
  517. COH901318_CX_CFG_BE_IRQ_ENABLE,
  518. .param.ctrl_lli_chained = 0 |
  519. COH901318_CX_CTRL_TC_ENABLE |
  520. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  521. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  522. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  523. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  524. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  525. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  526. COH901318_CX_CTRL_TCP_DISABLE |
  527. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  528. COH901318_CX_CTRL_HSP_ENABLE |
  529. COH901318_CX_CTRL_HSS_DISABLE |
  530. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  531. COH901318_CX_CTRL_PRDD_DEST,
  532. .param.ctrl_lli = 0,
  533. .param.ctrl_lli_last = 0 |
  534. COH901318_CX_CTRL_TC_ENABLE |
  535. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  536. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  537. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  538. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  539. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  540. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  541. COH901318_CX_CTRL_TCP_DISABLE |
  542. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  543. COH901318_CX_CTRL_HSP_ENABLE |
  544. COH901318_CX_CTRL_HSS_DISABLE |
  545. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  546. COH901318_CX_CTRL_PRDD_DEST,
  547. },
  548. {
  549. .number = U300_DMA_MSL_RX_2,
  550. .name = "MSL RX 2",
  551. .priority_high = 0,
  552. .param.config = COH901318_CX_CFG_CH_DISABLE |
  553. COH901318_CX_CFG_LCR_DISABLE |
  554. COH901318_CX_CFG_TC_IRQ_ENABLE |
  555. COH901318_CX_CFG_BE_IRQ_ENABLE,
  556. .param.ctrl_lli_chained = 0 |
  557. COH901318_CX_CTRL_TC_ENABLE |
  558. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  559. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  560. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  561. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  562. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  563. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  564. COH901318_CX_CTRL_TCP_DISABLE |
  565. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  566. COH901318_CX_CTRL_HSP_ENABLE |
  567. COH901318_CX_CTRL_HSS_DISABLE |
  568. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  569. COH901318_CX_CTRL_PRDD_DEST,
  570. .param.ctrl_lli = 0 |
  571. COH901318_CX_CTRL_TC_ENABLE |
  572. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  573. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  574. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  575. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  576. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  577. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  578. COH901318_CX_CTRL_TCP_DISABLE |
  579. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  580. COH901318_CX_CTRL_HSP_ENABLE |
  581. COH901318_CX_CTRL_HSS_DISABLE |
  582. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  583. COH901318_CX_CTRL_PRDD_DEST,
  584. .param.ctrl_lli_last = 0 |
  585. COH901318_CX_CTRL_TC_ENABLE |
  586. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  587. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  588. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  589. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  590. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  591. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  592. COH901318_CX_CTRL_TCP_DISABLE |
  593. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  594. COH901318_CX_CTRL_HSP_ENABLE |
  595. COH901318_CX_CTRL_HSS_DISABLE |
  596. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  597. COH901318_CX_CTRL_PRDD_DEST,
  598. },
  599. {
  600. .number = U300_DMA_MSL_RX_3,
  601. .name = "MSL RX 3",
  602. .priority_high = 0,
  603. .param.config = COH901318_CX_CFG_CH_DISABLE |
  604. COH901318_CX_CFG_LCR_DISABLE |
  605. COH901318_CX_CFG_TC_IRQ_ENABLE |
  606. COH901318_CX_CFG_BE_IRQ_ENABLE,
  607. .param.ctrl_lli_chained = 0 |
  608. COH901318_CX_CTRL_TC_ENABLE |
  609. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  610. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  611. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  612. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  613. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  614. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  615. COH901318_CX_CTRL_TCP_DISABLE |
  616. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  617. COH901318_CX_CTRL_HSP_ENABLE |
  618. COH901318_CX_CTRL_HSS_DISABLE |
  619. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  620. COH901318_CX_CTRL_PRDD_DEST,
  621. .param.ctrl_lli = 0 |
  622. COH901318_CX_CTRL_TC_ENABLE |
  623. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  624. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  625. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  626. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  627. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  628. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  629. COH901318_CX_CTRL_TCP_DISABLE |
  630. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  631. COH901318_CX_CTRL_HSP_ENABLE |
  632. COH901318_CX_CTRL_HSS_DISABLE |
  633. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  634. COH901318_CX_CTRL_PRDD_DEST,
  635. .param.ctrl_lli_last = 0 |
  636. COH901318_CX_CTRL_TC_ENABLE |
  637. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  638. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  639. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  640. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  641. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  642. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  643. COH901318_CX_CTRL_TCP_DISABLE |
  644. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  645. COH901318_CX_CTRL_HSP_ENABLE |
  646. COH901318_CX_CTRL_HSS_DISABLE |
  647. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  648. COH901318_CX_CTRL_PRDD_DEST,
  649. },
  650. {
  651. .number = U300_DMA_MSL_RX_4,
  652. .name = "MSL RX 4",
  653. .priority_high = 0,
  654. .param.config = COH901318_CX_CFG_CH_DISABLE |
  655. COH901318_CX_CFG_LCR_DISABLE |
  656. COH901318_CX_CFG_TC_IRQ_ENABLE |
  657. COH901318_CX_CFG_BE_IRQ_ENABLE,
  658. .param.ctrl_lli_chained = 0 |
  659. COH901318_CX_CTRL_TC_ENABLE |
  660. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  661. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  662. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  663. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  664. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  665. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  666. COH901318_CX_CTRL_TCP_DISABLE |
  667. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  668. COH901318_CX_CTRL_HSP_ENABLE |
  669. COH901318_CX_CTRL_HSS_DISABLE |
  670. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  671. COH901318_CX_CTRL_PRDD_DEST,
  672. .param.ctrl_lli = 0 |
  673. COH901318_CX_CTRL_TC_ENABLE |
  674. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  675. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  676. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  677. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  678. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  679. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  680. COH901318_CX_CTRL_TCP_DISABLE |
  681. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  682. COH901318_CX_CTRL_HSP_ENABLE |
  683. COH901318_CX_CTRL_HSS_DISABLE |
  684. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  685. COH901318_CX_CTRL_PRDD_DEST,
  686. .param.ctrl_lli_last = 0 |
  687. COH901318_CX_CTRL_TC_ENABLE |
  688. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  689. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  690. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  691. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  692. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  693. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  694. COH901318_CX_CTRL_TCP_DISABLE |
  695. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  696. COH901318_CX_CTRL_HSP_ENABLE |
  697. COH901318_CX_CTRL_HSS_DISABLE |
  698. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  699. COH901318_CX_CTRL_PRDD_DEST,
  700. },
  701. {
  702. .number = U300_DMA_MSL_RX_5,
  703. .name = "MSL RX 5",
  704. .priority_high = 0,
  705. .param.config = COH901318_CX_CFG_CH_DISABLE |
  706. COH901318_CX_CFG_LCR_DISABLE |
  707. COH901318_CX_CFG_TC_IRQ_ENABLE |
  708. COH901318_CX_CFG_BE_IRQ_ENABLE,
  709. .param.ctrl_lli_chained = 0 |
  710. COH901318_CX_CTRL_TC_ENABLE |
  711. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  712. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  713. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  714. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  715. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  716. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  717. COH901318_CX_CTRL_TCP_DISABLE |
  718. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  719. COH901318_CX_CTRL_HSP_ENABLE |
  720. COH901318_CX_CTRL_HSS_DISABLE |
  721. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  722. COH901318_CX_CTRL_PRDD_DEST,
  723. .param.ctrl_lli = 0 |
  724. COH901318_CX_CTRL_TC_ENABLE |
  725. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  726. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  727. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  728. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  729. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  730. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  731. COH901318_CX_CTRL_TCP_DISABLE |
  732. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  733. COH901318_CX_CTRL_HSP_ENABLE |
  734. COH901318_CX_CTRL_HSS_DISABLE |
  735. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  736. COH901318_CX_CTRL_PRDD_DEST,
  737. .param.ctrl_lli_last = 0 |
  738. COH901318_CX_CTRL_TC_ENABLE |
  739. COH901318_CX_CTRL_BURST_COUNT_32_BYTES |
  740. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  741. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  742. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  743. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  744. COH901318_CX_CTRL_MASTER_MODE_M2R_M1W |
  745. COH901318_CX_CTRL_TCP_DISABLE |
  746. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  747. COH901318_CX_CTRL_HSP_ENABLE |
  748. COH901318_CX_CTRL_HSS_DISABLE |
  749. COH901318_CX_CTRL_DDMA_DEMAND_DMA1 |
  750. COH901318_CX_CTRL_PRDD_DEST,
  751. },
  752. {
  753. .number = U300_DMA_MSL_RX_6,
  754. .name = "MSL RX 6",
  755. .priority_high = 0,
  756. },
  757. /*
  758. * Don't set up device address, burst count or size of src
  759. * or dst bus for this peripheral - handled by PrimeCell
  760. * DMA extension.
  761. */
  762. {
  763. .number = U300_DMA_MMCSD_RX_TX,
  764. .name = "MMCSD RX TX",
  765. .priority_high = 0,
  766. .param.config = COH901318_CX_CFG_CH_DISABLE |
  767. COH901318_CX_CFG_LCR_DISABLE |
  768. COH901318_CX_CFG_TC_IRQ_ENABLE |
  769. COH901318_CX_CFG_BE_IRQ_ENABLE,
  770. .param.ctrl_lli_chained = 0 |
  771. COH901318_CX_CTRL_TC_ENABLE |
  772. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  773. COH901318_CX_CTRL_TCP_ENABLE |
  774. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  775. COH901318_CX_CTRL_HSP_ENABLE |
  776. COH901318_CX_CTRL_HSS_DISABLE |
  777. COH901318_CX_CTRL_DDMA_LEGACY,
  778. .param.ctrl_lli = 0 |
  779. COH901318_CX_CTRL_TC_ENABLE |
  780. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  781. COH901318_CX_CTRL_TCP_ENABLE |
  782. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  783. COH901318_CX_CTRL_HSP_ENABLE |
  784. COH901318_CX_CTRL_HSS_DISABLE |
  785. COH901318_CX_CTRL_DDMA_LEGACY,
  786. .param.ctrl_lli_last = 0 |
  787. COH901318_CX_CTRL_TC_ENABLE |
  788. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  789. COH901318_CX_CTRL_TCP_DISABLE |
  790. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  791. COH901318_CX_CTRL_HSP_ENABLE |
  792. COH901318_CX_CTRL_HSS_DISABLE |
  793. COH901318_CX_CTRL_DDMA_LEGACY,
  794. },
  795. {
  796. .number = U300_DMA_MSPRO_TX,
  797. .name = "MSPRO TX",
  798. .priority_high = 0,
  799. },
  800. {
  801. .number = U300_DMA_MSPRO_RX,
  802. .name = "MSPRO RX",
  803. .priority_high = 0,
  804. },
  805. /*
  806. * Don't set up device address, burst count or size of src
  807. * or dst bus for this peripheral - handled by PrimeCell
  808. * DMA extension.
  809. */
  810. {
  811. .number = U300_DMA_UART0_TX,
  812. .name = "UART0 TX",
  813. .priority_high = 0,
  814. .param.config = COH901318_CX_CFG_CH_DISABLE |
  815. COH901318_CX_CFG_LCR_DISABLE |
  816. COH901318_CX_CFG_TC_IRQ_ENABLE |
  817. COH901318_CX_CFG_BE_IRQ_ENABLE,
  818. .param.ctrl_lli_chained = 0 |
  819. COH901318_CX_CTRL_TC_ENABLE |
  820. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  821. COH901318_CX_CTRL_TCP_ENABLE |
  822. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  823. COH901318_CX_CTRL_HSP_ENABLE |
  824. COH901318_CX_CTRL_HSS_DISABLE |
  825. COH901318_CX_CTRL_DDMA_LEGACY,
  826. .param.ctrl_lli = 0 |
  827. COH901318_CX_CTRL_TC_ENABLE |
  828. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  829. COH901318_CX_CTRL_TCP_ENABLE |
  830. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  831. COH901318_CX_CTRL_HSP_ENABLE |
  832. COH901318_CX_CTRL_HSS_DISABLE |
  833. COH901318_CX_CTRL_DDMA_LEGACY,
  834. .param.ctrl_lli_last = 0 |
  835. COH901318_CX_CTRL_TC_ENABLE |
  836. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  837. COH901318_CX_CTRL_TCP_ENABLE |
  838. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  839. COH901318_CX_CTRL_HSP_ENABLE |
  840. COH901318_CX_CTRL_HSS_DISABLE |
  841. COH901318_CX_CTRL_DDMA_LEGACY,
  842. },
  843. {
  844. .number = U300_DMA_UART0_RX,
  845. .name = "UART0 RX",
  846. .priority_high = 0,
  847. .param.config = COH901318_CX_CFG_CH_DISABLE |
  848. COH901318_CX_CFG_LCR_DISABLE |
  849. COH901318_CX_CFG_TC_IRQ_ENABLE |
  850. COH901318_CX_CFG_BE_IRQ_ENABLE,
  851. .param.ctrl_lli_chained = 0 |
  852. COH901318_CX_CTRL_TC_ENABLE |
  853. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  854. COH901318_CX_CTRL_TCP_ENABLE |
  855. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  856. COH901318_CX_CTRL_HSP_ENABLE |
  857. COH901318_CX_CTRL_HSS_DISABLE |
  858. COH901318_CX_CTRL_DDMA_LEGACY,
  859. .param.ctrl_lli = 0 |
  860. COH901318_CX_CTRL_TC_ENABLE |
  861. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  862. COH901318_CX_CTRL_TCP_ENABLE |
  863. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  864. COH901318_CX_CTRL_HSP_ENABLE |
  865. COH901318_CX_CTRL_HSS_DISABLE |
  866. COH901318_CX_CTRL_DDMA_LEGACY,
  867. .param.ctrl_lli_last = 0 |
  868. COH901318_CX_CTRL_TC_ENABLE |
  869. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  870. COH901318_CX_CTRL_TCP_ENABLE |
  871. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  872. COH901318_CX_CTRL_HSP_ENABLE |
  873. COH901318_CX_CTRL_HSS_DISABLE |
  874. COH901318_CX_CTRL_DDMA_LEGACY,
  875. },
  876. {
  877. .number = U300_DMA_APEX_TX,
  878. .name = "APEX TX",
  879. .priority_high = 0,
  880. },
  881. {
  882. .number = U300_DMA_APEX_RX,
  883. .name = "APEX RX",
  884. .priority_high = 0,
  885. },
  886. {
  887. .number = U300_DMA_PCM_I2S0_TX,
  888. .name = "PCM I2S0 TX",
  889. .priority_high = 1,
  890. .param.config = COH901318_CX_CFG_CH_DISABLE |
  891. COH901318_CX_CFG_LCR_DISABLE |
  892. COH901318_CX_CFG_TC_IRQ_ENABLE |
  893. COH901318_CX_CFG_BE_IRQ_ENABLE,
  894. .param.ctrl_lli_chained = 0 |
  895. COH901318_CX_CTRL_TC_ENABLE |
  896. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  897. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  898. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  899. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  900. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  901. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  902. COH901318_CX_CTRL_TCP_DISABLE |
  903. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  904. COH901318_CX_CTRL_HSP_ENABLE |
  905. COH901318_CX_CTRL_HSS_DISABLE |
  906. COH901318_CX_CTRL_DDMA_LEGACY |
  907. COH901318_CX_CTRL_PRDD_SOURCE,
  908. .param.ctrl_lli = 0 |
  909. COH901318_CX_CTRL_TC_ENABLE |
  910. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  911. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  912. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  913. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  914. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  915. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  916. COH901318_CX_CTRL_TCP_ENABLE |
  917. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  918. COH901318_CX_CTRL_HSP_ENABLE |
  919. COH901318_CX_CTRL_HSS_DISABLE |
  920. COH901318_CX_CTRL_DDMA_LEGACY |
  921. COH901318_CX_CTRL_PRDD_SOURCE,
  922. .param.ctrl_lli_last = 0 |
  923. COH901318_CX_CTRL_TC_ENABLE |
  924. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  925. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  926. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  927. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  928. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  929. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  930. COH901318_CX_CTRL_TCP_ENABLE |
  931. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  932. COH901318_CX_CTRL_HSP_ENABLE |
  933. COH901318_CX_CTRL_HSS_DISABLE |
  934. COH901318_CX_CTRL_DDMA_LEGACY |
  935. COH901318_CX_CTRL_PRDD_SOURCE,
  936. },
  937. {
  938. .number = U300_DMA_PCM_I2S0_RX,
  939. .name = "PCM I2S0 RX",
  940. .priority_high = 1,
  941. .param.config = COH901318_CX_CFG_CH_DISABLE |
  942. COH901318_CX_CFG_LCR_DISABLE |
  943. COH901318_CX_CFG_TC_IRQ_ENABLE |
  944. COH901318_CX_CFG_BE_IRQ_ENABLE,
  945. .param.ctrl_lli_chained = 0 |
  946. COH901318_CX_CTRL_TC_ENABLE |
  947. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  948. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  949. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  950. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  951. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  952. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  953. COH901318_CX_CTRL_TCP_DISABLE |
  954. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  955. COH901318_CX_CTRL_HSP_ENABLE |
  956. COH901318_CX_CTRL_HSS_DISABLE |
  957. COH901318_CX_CTRL_DDMA_LEGACY |
  958. COH901318_CX_CTRL_PRDD_DEST,
  959. .param.ctrl_lli = 0 |
  960. COH901318_CX_CTRL_TC_ENABLE |
  961. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  962. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  963. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  964. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  965. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  966. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  967. COH901318_CX_CTRL_TCP_ENABLE |
  968. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  969. COH901318_CX_CTRL_HSP_ENABLE |
  970. COH901318_CX_CTRL_HSS_DISABLE |
  971. COH901318_CX_CTRL_DDMA_LEGACY |
  972. COH901318_CX_CTRL_PRDD_DEST,
  973. .param.ctrl_lli_last = 0 |
  974. COH901318_CX_CTRL_TC_ENABLE |
  975. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  976. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  977. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  978. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  979. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  980. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  981. COH901318_CX_CTRL_TCP_ENABLE |
  982. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  983. COH901318_CX_CTRL_HSP_ENABLE |
  984. COH901318_CX_CTRL_HSS_DISABLE |
  985. COH901318_CX_CTRL_DDMA_LEGACY |
  986. COH901318_CX_CTRL_PRDD_DEST,
  987. },
  988. {
  989. .number = U300_DMA_PCM_I2S1_TX,
  990. .name = "PCM I2S1 TX",
  991. .priority_high = 1,
  992. .param.config = COH901318_CX_CFG_CH_DISABLE |
  993. COH901318_CX_CFG_LCR_DISABLE |
  994. COH901318_CX_CFG_TC_IRQ_ENABLE |
  995. COH901318_CX_CFG_BE_IRQ_ENABLE,
  996. .param.ctrl_lli_chained = 0 |
  997. COH901318_CX_CTRL_TC_ENABLE |
  998. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  999. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  1000. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  1001. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  1002. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  1003. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1004. COH901318_CX_CTRL_TCP_DISABLE |
  1005. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  1006. COH901318_CX_CTRL_HSP_ENABLE |
  1007. COH901318_CX_CTRL_HSS_DISABLE |
  1008. COH901318_CX_CTRL_DDMA_LEGACY |
  1009. COH901318_CX_CTRL_PRDD_SOURCE,
  1010. .param.ctrl_lli = 0 |
  1011. COH901318_CX_CTRL_TC_ENABLE |
  1012. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  1013. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  1014. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  1015. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  1016. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  1017. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1018. COH901318_CX_CTRL_TCP_ENABLE |
  1019. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  1020. COH901318_CX_CTRL_HSP_ENABLE |
  1021. COH901318_CX_CTRL_HSS_DISABLE |
  1022. COH901318_CX_CTRL_DDMA_LEGACY |
  1023. COH901318_CX_CTRL_PRDD_SOURCE,
  1024. .param.ctrl_lli_last = 0 |
  1025. COH901318_CX_CTRL_TC_ENABLE |
  1026. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  1027. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  1028. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE |
  1029. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  1030. COH901318_CX_CTRL_DST_ADDR_INC_DISABLE |
  1031. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1032. COH901318_CX_CTRL_TCP_ENABLE |
  1033. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  1034. COH901318_CX_CTRL_HSP_ENABLE |
  1035. COH901318_CX_CTRL_HSS_DISABLE |
  1036. COH901318_CX_CTRL_DDMA_LEGACY |
  1037. COH901318_CX_CTRL_PRDD_SOURCE,
  1038. },
  1039. {
  1040. .number = U300_DMA_PCM_I2S1_RX,
  1041. .name = "PCM I2S1 RX",
  1042. .priority_high = 1,
  1043. .param.config = COH901318_CX_CFG_CH_DISABLE |
  1044. COH901318_CX_CFG_LCR_DISABLE |
  1045. COH901318_CX_CFG_TC_IRQ_ENABLE |
  1046. COH901318_CX_CFG_BE_IRQ_ENABLE,
  1047. .param.ctrl_lli_chained = 0 |
  1048. COH901318_CX_CTRL_TC_ENABLE |
  1049. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  1050. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  1051. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  1052. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  1053. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  1054. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1055. COH901318_CX_CTRL_TCP_DISABLE |
  1056. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  1057. COH901318_CX_CTRL_HSP_ENABLE |
  1058. COH901318_CX_CTRL_HSS_DISABLE |
  1059. COH901318_CX_CTRL_DDMA_LEGACY |
  1060. COH901318_CX_CTRL_PRDD_DEST,
  1061. .param.ctrl_lli = 0 |
  1062. COH901318_CX_CTRL_TC_ENABLE |
  1063. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  1064. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  1065. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  1066. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  1067. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  1068. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1069. COH901318_CX_CTRL_TCP_ENABLE |
  1070. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  1071. COH901318_CX_CTRL_HSP_ENABLE |
  1072. COH901318_CX_CTRL_HSS_DISABLE |
  1073. COH901318_CX_CTRL_DDMA_LEGACY |
  1074. COH901318_CX_CTRL_PRDD_DEST,
  1075. .param.ctrl_lli_last = 0 |
  1076. COH901318_CX_CTRL_TC_ENABLE |
  1077. COH901318_CX_CTRL_BURST_COUNT_16_BYTES |
  1078. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  1079. COH901318_CX_CTRL_SRC_ADDR_INC_DISABLE |
  1080. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS |
  1081. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE |
  1082. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1083. COH901318_CX_CTRL_TCP_ENABLE |
  1084. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  1085. COH901318_CX_CTRL_HSP_ENABLE |
  1086. COH901318_CX_CTRL_HSS_DISABLE |
  1087. COH901318_CX_CTRL_DDMA_LEGACY |
  1088. COH901318_CX_CTRL_PRDD_DEST,
  1089. },
  1090. {
  1091. .number = U300_DMA_XGAM_CDI,
  1092. .name = "XGAM CDI",
  1093. .priority_high = 0,
  1094. },
  1095. {
  1096. .number = U300_DMA_XGAM_PDI,
  1097. .name = "XGAM PDI",
  1098. .priority_high = 0,
  1099. },
  1100. /*
  1101. * Don't set up device address, burst count or size of src
  1102. * or dst bus for this peripheral - handled by PrimeCell
  1103. * DMA extension.
  1104. */
  1105. {
  1106. .number = U300_DMA_SPI_TX,
  1107. .name = "SPI TX",
  1108. .priority_high = 0,
  1109. .param.config = COH901318_CX_CFG_CH_DISABLE |
  1110. COH901318_CX_CFG_LCR_DISABLE |
  1111. COH901318_CX_CFG_TC_IRQ_ENABLE |
  1112. COH901318_CX_CFG_BE_IRQ_ENABLE,
  1113. .param.ctrl_lli_chained = 0 |
  1114. COH901318_CX_CTRL_TC_ENABLE |
  1115. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1116. COH901318_CX_CTRL_TCP_DISABLE |
  1117. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  1118. COH901318_CX_CTRL_HSP_ENABLE |
  1119. COH901318_CX_CTRL_HSS_DISABLE |
  1120. COH901318_CX_CTRL_DDMA_LEGACY,
  1121. .param.ctrl_lli = 0 |
  1122. COH901318_CX_CTRL_TC_ENABLE |
  1123. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1124. COH901318_CX_CTRL_TCP_DISABLE |
  1125. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  1126. COH901318_CX_CTRL_HSP_ENABLE |
  1127. COH901318_CX_CTRL_HSS_DISABLE |
  1128. COH901318_CX_CTRL_DDMA_LEGACY,
  1129. .param.ctrl_lli_last = 0 |
  1130. COH901318_CX_CTRL_TC_ENABLE |
  1131. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1132. COH901318_CX_CTRL_TCP_DISABLE |
  1133. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  1134. COH901318_CX_CTRL_HSP_ENABLE |
  1135. COH901318_CX_CTRL_HSS_DISABLE |
  1136. COH901318_CX_CTRL_DDMA_LEGACY,
  1137. },
  1138. {
  1139. .number = U300_DMA_SPI_RX,
  1140. .name = "SPI RX",
  1141. .priority_high = 0,
  1142. .param.config = COH901318_CX_CFG_CH_DISABLE |
  1143. COH901318_CX_CFG_LCR_DISABLE |
  1144. COH901318_CX_CFG_TC_IRQ_ENABLE |
  1145. COH901318_CX_CFG_BE_IRQ_ENABLE,
  1146. .param.ctrl_lli_chained = 0 |
  1147. COH901318_CX_CTRL_TC_ENABLE |
  1148. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1149. COH901318_CX_CTRL_TCP_DISABLE |
  1150. COH901318_CX_CTRL_TC_IRQ_DISABLE |
  1151. COH901318_CX_CTRL_HSP_ENABLE |
  1152. COH901318_CX_CTRL_HSS_DISABLE |
  1153. COH901318_CX_CTRL_DDMA_LEGACY,
  1154. .param.ctrl_lli = 0 |
  1155. COH901318_CX_CTRL_TC_ENABLE |
  1156. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1157. COH901318_CX_CTRL_TCP_DISABLE |
  1158. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  1159. COH901318_CX_CTRL_HSP_ENABLE |
  1160. COH901318_CX_CTRL_HSS_DISABLE |
  1161. COH901318_CX_CTRL_DDMA_LEGACY,
  1162. .param.ctrl_lli_last = 0 |
  1163. COH901318_CX_CTRL_TC_ENABLE |
  1164. COH901318_CX_CTRL_MASTER_MODE_M1RW |
  1165. COH901318_CX_CTRL_TCP_DISABLE |
  1166. COH901318_CX_CTRL_TC_IRQ_ENABLE |
  1167. COH901318_CX_CTRL_HSP_ENABLE |
  1168. COH901318_CX_CTRL_HSS_DISABLE |
  1169. COH901318_CX_CTRL_DDMA_LEGACY,
  1170. },
  1171. {
  1172. .number = U300_DMA_GENERAL_PURPOSE_0,
  1173. .name = "GENERAL 00",
  1174. .priority_high = 0,
  1175. .param.config = flags_memcpy_config,
  1176. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1177. .param.ctrl_lli = flags_memcpy_lli,
  1178. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1179. },
  1180. {
  1181. .number = U300_DMA_GENERAL_PURPOSE_1,
  1182. .name = "GENERAL 01",
  1183. .priority_high = 0,
  1184. .param.config = flags_memcpy_config,
  1185. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1186. .param.ctrl_lli = flags_memcpy_lli,
  1187. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1188. },
  1189. {
  1190. .number = U300_DMA_GENERAL_PURPOSE_2,
  1191. .name = "GENERAL 02",
  1192. .priority_high = 0,
  1193. .param.config = flags_memcpy_config,
  1194. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1195. .param.ctrl_lli = flags_memcpy_lli,
  1196. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1197. },
  1198. {
  1199. .number = U300_DMA_GENERAL_PURPOSE_3,
  1200. .name = "GENERAL 03",
  1201. .priority_high = 0,
  1202. .param.config = flags_memcpy_config,
  1203. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1204. .param.ctrl_lli = flags_memcpy_lli,
  1205. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1206. },
  1207. {
  1208. .number = U300_DMA_GENERAL_PURPOSE_4,
  1209. .name = "GENERAL 04",
  1210. .priority_high = 0,
  1211. .param.config = flags_memcpy_config,
  1212. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1213. .param.ctrl_lli = flags_memcpy_lli,
  1214. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1215. },
  1216. {
  1217. .number = U300_DMA_GENERAL_PURPOSE_5,
  1218. .name = "GENERAL 05",
  1219. .priority_high = 0,
  1220. .param.config = flags_memcpy_config,
  1221. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1222. .param.ctrl_lli = flags_memcpy_lli,
  1223. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1224. },
  1225. {
  1226. .number = U300_DMA_GENERAL_PURPOSE_6,
  1227. .name = "GENERAL 06",
  1228. .priority_high = 0,
  1229. .param.config = flags_memcpy_config,
  1230. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1231. .param.ctrl_lli = flags_memcpy_lli,
  1232. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1233. },
  1234. {
  1235. .number = U300_DMA_GENERAL_PURPOSE_7,
  1236. .name = "GENERAL 07",
  1237. .priority_high = 0,
  1238. .param.config = flags_memcpy_config,
  1239. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1240. .param.ctrl_lli = flags_memcpy_lli,
  1241. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1242. },
  1243. {
  1244. .number = U300_DMA_GENERAL_PURPOSE_8,
  1245. .name = "GENERAL 08",
  1246. .priority_high = 0,
  1247. .param.config = flags_memcpy_config,
  1248. .param.ctrl_lli_chained = flags_memcpy_lli_chained,
  1249. .param.ctrl_lli = flags_memcpy_lli,
  1250. .param.ctrl_lli_last = flags_memcpy_lli_last,
  1251. },
  1252. {
  1253. .number = U300_DMA_UART1_TX,
  1254. .name = "UART1 TX",
  1255. .priority_high = 0,
  1256. },
  1257. {
  1258. .number = U300_DMA_UART1_RX,
  1259. .name = "UART1 RX",
  1260. .priority_high = 0,
  1261. }
  1262. };
  1263. static struct coh901318_platform coh901318_platform = {
  1264. .chans_slave = dma_slave_channels,
  1265. .chans_memcpy = dma_memcpy_channels,
  1266. .access_memory_state = coh901318_access_memory_state,
  1267. .chan_conf = chan_config,
  1268. .max_channels = U300_DMA_CHANNELS,
  1269. };
  1270. #define COHC_2_DEV(cohc) (&cohc->chan.dev->device)
  1271. #ifdef VERBOSE_DEBUG
  1272. #define COH_DBG(x) ({ if (1) x; 0; })
  1273. #else
  1274. #define COH_DBG(x) ({ if (0) x; 0; })
  1275. #endif
  1276. struct coh901318_desc {
  1277. struct dma_async_tx_descriptor desc;
  1278. struct list_head node;
  1279. struct scatterlist *sg;
  1280. unsigned int sg_len;
  1281. struct coh901318_lli *lli;
  1282. enum dma_transfer_direction dir;
  1283. unsigned long flags;
  1284. u32 head_config;
  1285. u32 head_ctrl;
  1286. };
  1287. struct coh901318_base {
  1288. struct device *dev;
  1289. void __iomem *virtbase;
  1290. struct coh901318_pool pool;
  1291. struct powersave pm;
  1292. struct dma_device dma_slave;
  1293. struct dma_device dma_memcpy;
  1294. struct coh901318_chan *chans;
  1295. struct coh901318_platform *platform;
  1296. };
  1297. struct coh901318_chan {
  1298. spinlock_t lock;
  1299. int allocated;
  1300. int id;
  1301. int stopped;
  1302. struct work_struct free_work;
  1303. struct dma_chan chan;
  1304. struct tasklet_struct tasklet;
  1305. struct list_head active;
  1306. struct list_head queue;
  1307. struct list_head free;
  1308. unsigned long nbr_active_done;
  1309. unsigned long busy;
  1310. u32 addr;
  1311. u32 ctrl;
  1312. struct coh901318_base *base;
  1313. };
  1314. static void coh901318_list_print(struct coh901318_chan *cohc,
  1315. struct coh901318_lli *lli)
  1316. {
  1317. struct coh901318_lli *l = lli;
  1318. int i = 0;
  1319. while (l) {
  1320. dev_vdbg(COHC_2_DEV(cohc), "i %d, lli %p, ctrl 0x%x, src 0x%x"
  1321. ", dst 0x%x, link 0x%x virt_link_addr 0x%p\n",
  1322. i, l, l->control, l->src_addr, l->dst_addr,
  1323. l->link_addr, l->virt_link_addr);
  1324. i++;
  1325. l = l->virt_link_addr;
  1326. }
  1327. }
  1328. #ifdef CONFIG_DEBUG_FS
  1329. #define COH901318_DEBUGFS_ASSIGN(x, y) (x = y)
  1330. static struct coh901318_base *debugfs_dma_base;
  1331. static struct dentry *dma_dentry;
  1332. static int coh901318_debugfs_read(struct file *file, char __user *buf,
  1333. size_t count, loff_t *f_pos)
  1334. {
  1335. u64 started_channels = debugfs_dma_base->pm.started_channels;
  1336. int pool_count = debugfs_dma_base->pool.debugfs_pool_counter;
  1337. int i;
  1338. int ret = 0;
  1339. char *dev_buf;
  1340. char *tmp;
  1341. int dev_size;
  1342. dev_buf = kmalloc(4*1024, GFP_KERNEL);
  1343. if (dev_buf == NULL)
  1344. goto err_kmalloc;
  1345. tmp = dev_buf;
  1346. tmp += sprintf(tmp, "DMA -- enabled dma channels\n");
  1347. for (i = 0; i < debugfs_dma_base->platform->max_channels; i++)
  1348. if (started_channels & (1 << i))
  1349. tmp += sprintf(tmp, "channel %d\n", i);
  1350. tmp += sprintf(tmp, "Pool alloc nbr %d\n", pool_count);
  1351. dev_size = tmp - dev_buf;
  1352. /* No more to read if offset != 0 */
  1353. if (*f_pos > dev_size)
  1354. goto out;
  1355. if (count > dev_size - *f_pos)
  1356. count = dev_size - *f_pos;
  1357. if (copy_to_user(buf, dev_buf + *f_pos, count))
  1358. ret = -EINVAL;
  1359. ret = count;
  1360. *f_pos += count;
  1361. out:
  1362. kfree(dev_buf);
  1363. return ret;
  1364. err_kmalloc:
  1365. return 0;
  1366. }
  1367. static const struct file_operations coh901318_debugfs_status_operations = {
  1368. .owner = THIS_MODULE,
  1369. .open = simple_open,
  1370. .read = coh901318_debugfs_read,
  1371. .llseek = default_llseek,
  1372. };
  1373. static int __init init_coh901318_debugfs(void)
  1374. {
  1375. dma_dentry = debugfs_create_dir("dma", NULL);
  1376. (void) debugfs_create_file("status",
  1377. S_IFREG | S_IRUGO,
  1378. dma_dentry, NULL,
  1379. &coh901318_debugfs_status_operations);
  1380. return 0;
  1381. }
  1382. static void __exit exit_coh901318_debugfs(void)
  1383. {
  1384. debugfs_remove_recursive(dma_dentry);
  1385. }
  1386. module_init(init_coh901318_debugfs);
  1387. module_exit(exit_coh901318_debugfs);
  1388. #else
  1389. #define COH901318_DEBUGFS_ASSIGN(x, y)
  1390. #endif /* CONFIG_DEBUG_FS */
  1391. static inline struct coh901318_chan *to_coh901318_chan(struct dma_chan *chan)
  1392. {
  1393. return container_of(chan, struct coh901318_chan, chan);
  1394. }
  1395. static inline const struct coh901318_params *
  1396. cohc_chan_param(struct coh901318_chan *cohc)
  1397. {
  1398. return &cohc->base->platform->chan_conf[cohc->id].param;
  1399. }
  1400. static inline const struct coh_dma_channel *
  1401. cohc_chan_conf(struct coh901318_chan *cohc)
  1402. {
  1403. return &cohc->base->platform->chan_conf[cohc->id];
  1404. }
  1405. static void enable_powersave(struct coh901318_chan *cohc)
  1406. {
  1407. unsigned long flags;
  1408. struct powersave *pm = &cohc->base->pm;
  1409. spin_lock_irqsave(&pm->lock, flags);
  1410. pm->started_channels &= ~(1ULL << cohc->id);
  1411. if (!pm->started_channels) {
  1412. /* DMA no longer intends to access memory */
  1413. cohc->base->platform->access_memory_state(cohc->base->dev,
  1414. false);
  1415. }
  1416. spin_unlock_irqrestore(&pm->lock, flags);
  1417. }
  1418. static void disable_powersave(struct coh901318_chan *cohc)
  1419. {
  1420. unsigned long flags;
  1421. struct powersave *pm = &cohc->base->pm;
  1422. spin_lock_irqsave(&pm->lock, flags);
  1423. if (!pm->started_channels) {
  1424. /* DMA intends to access memory */
  1425. cohc->base->platform->access_memory_state(cohc->base->dev,
  1426. true);
  1427. }
  1428. pm->started_channels |= (1ULL << cohc->id);
  1429. spin_unlock_irqrestore(&pm->lock, flags);
  1430. }
  1431. static inline int coh901318_set_ctrl(struct coh901318_chan *cohc, u32 control)
  1432. {
  1433. int channel = cohc->id;
  1434. void __iomem *virtbase = cohc->base->virtbase;
  1435. writel(control,
  1436. virtbase + COH901318_CX_CTRL +
  1437. COH901318_CX_CTRL_SPACING * channel);
  1438. return 0;
  1439. }
  1440. static inline int coh901318_set_conf(struct coh901318_chan *cohc, u32 conf)
  1441. {
  1442. int channel = cohc->id;
  1443. void __iomem *virtbase = cohc->base->virtbase;
  1444. writel(conf,
  1445. virtbase + COH901318_CX_CFG +
  1446. COH901318_CX_CFG_SPACING*channel);
  1447. return 0;
  1448. }
  1449. static int coh901318_start(struct coh901318_chan *cohc)
  1450. {
  1451. u32 val;
  1452. int channel = cohc->id;
  1453. void __iomem *virtbase = cohc->base->virtbase;
  1454. disable_powersave(cohc);
  1455. val = readl(virtbase + COH901318_CX_CFG +
  1456. COH901318_CX_CFG_SPACING * channel);
  1457. /* Enable channel */
  1458. val |= COH901318_CX_CFG_CH_ENABLE;
  1459. writel(val, virtbase + COH901318_CX_CFG +
  1460. COH901318_CX_CFG_SPACING * channel);
  1461. return 0;
  1462. }
  1463. static int coh901318_prep_linked_list(struct coh901318_chan *cohc,
  1464. struct coh901318_lli *lli)
  1465. {
  1466. int channel = cohc->id;
  1467. void __iomem *virtbase = cohc->base->virtbase;
  1468. BUG_ON(readl(virtbase + COH901318_CX_STAT +
  1469. COH901318_CX_STAT_SPACING*channel) &
  1470. COH901318_CX_STAT_ACTIVE);
  1471. writel(lli->src_addr,
  1472. virtbase + COH901318_CX_SRC_ADDR +
  1473. COH901318_CX_SRC_ADDR_SPACING * channel);
  1474. writel(lli->dst_addr, virtbase +
  1475. COH901318_CX_DST_ADDR +
  1476. COH901318_CX_DST_ADDR_SPACING * channel);
  1477. writel(lli->link_addr, virtbase + COH901318_CX_LNK_ADDR +
  1478. COH901318_CX_LNK_ADDR_SPACING * channel);
  1479. writel(lli->control, virtbase + COH901318_CX_CTRL +
  1480. COH901318_CX_CTRL_SPACING * channel);
  1481. return 0;
  1482. }
  1483. static struct coh901318_desc *
  1484. coh901318_desc_get(struct coh901318_chan *cohc)
  1485. {
  1486. struct coh901318_desc *desc;
  1487. if (list_empty(&cohc->free)) {
  1488. /* alloc new desc because we're out of used ones
  1489. * TODO: alloc a pile of descs instead of just one,
  1490. * avoid many small allocations.
  1491. */
  1492. desc = kzalloc(sizeof(struct coh901318_desc), GFP_NOWAIT);
  1493. if (desc == NULL)
  1494. goto out;
  1495. INIT_LIST_HEAD(&desc->node);
  1496. dma_async_tx_descriptor_init(&desc->desc, &cohc->chan);
  1497. } else {
  1498. /* Reuse an old desc. */
  1499. desc = list_first_entry(&cohc->free,
  1500. struct coh901318_desc,
  1501. node);
  1502. list_del(&desc->node);
  1503. /* Initialize it a bit so it's not insane */
  1504. desc->sg = NULL;
  1505. desc->sg_len = 0;
  1506. desc->desc.callback = NULL;
  1507. desc->desc.callback_param = NULL;
  1508. }
  1509. out:
  1510. return desc;
  1511. }
  1512. static void
  1513. coh901318_desc_free(struct coh901318_chan *cohc, struct coh901318_desc *cohd)
  1514. {
  1515. list_add_tail(&cohd->node, &cohc->free);
  1516. }
  1517. /* call with irq lock held */
  1518. static void
  1519. coh901318_desc_submit(struct coh901318_chan *cohc, struct coh901318_desc *desc)
  1520. {
  1521. list_add_tail(&desc->node, &cohc->active);
  1522. }
  1523. static struct coh901318_desc *
  1524. coh901318_first_active_get(struct coh901318_chan *cohc)
  1525. {
  1526. struct coh901318_desc *d;
  1527. if (list_empty(&cohc->active))
  1528. return NULL;
  1529. d = list_first_entry(&cohc->active,
  1530. struct coh901318_desc,
  1531. node);
  1532. return d;
  1533. }
  1534. static void
  1535. coh901318_desc_remove(struct coh901318_desc *cohd)
  1536. {
  1537. list_del(&cohd->node);
  1538. }
  1539. static void
  1540. coh901318_desc_queue(struct coh901318_chan *cohc, struct coh901318_desc *desc)
  1541. {
  1542. list_add_tail(&desc->node, &cohc->queue);
  1543. }
  1544. static struct coh901318_desc *
  1545. coh901318_first_queued(struct coh901318_chan *cohc)
  1546. {
  1547. struct coh901318_desc *d;
  1548. if (list_empty(&cohc->queue))
  1549. return NULL;
  1550. d = list_first_entry(&cohc->queue,
  1551. struct coh901318_desc,
  1552. node);
  1553. return d;
  1554. }
  1555. static inline u32 coh901318_get_bytes_in_lli(struct coh901318_lli *in_lli)
  1556. {
  1557. struct coh901318_lli *lli = in_lli;
  1558. u32 bytes = 0;
  1559. while (lli) {
  1560. bytes += lli->control & COH901318_CX_CTRL_TC_VALUE_MASK;
  1561. lli = lli->virt_link_addr;
  1562. }
  1563. return bytes;
  1564. }
  1565. /*
  1566. * Get the number of bytes left to transfer on this channel,
  1567. * it is unwise to call this before stopping the channel for
  1568. * absolute measures, but for a rough guess you can still call
  1569. * it.
  1570. */
  1571. static u32 coh901318_get_bytes_left(struct dma_chan *chan)
  1572. {
  1573. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  1574. struct coh901318_desc *cohd;
  1575. struct list_head *pos;
  1576. unsigned long flags;
  1577. u32 left = 0;
  1578. int i = 0;
  1579. spin_lock_irqsave(&cohc->lock, flags);
  1580. /*
  1581. * If there are many queued jobs, we iterate and add the
  1582. * size of them all. We take a special look on the first
  1583. * job though, since it is probably active.
  1584. */
  1585. list_for_each(pos, &cohc->active) {
  1586. /*
  1587. * The first job in the list will be working on the
  1588. * hardware. The job can be stopped but still active,
  1589. * so that the transfer counter is somewhere inside
  1590. * the buffer.
  1591. */
  1592. cohd = list_entry(pos, struct coh901318_desc, node);
  1593. if (i == 0) {
  1594. struct coh901318_lli *lli;
  1595. dma_addr_t ladd;
  1596. /* Read current transfer count value */
  1597. left = readl(cohc->base->virtbase +
  1598. COH901318_CX_CTRL +
  1599. COH901318_CX_CTRL_SPACING * cohc->id) &
  1600. COH901318_CX_CTRL_TC_VALUE_MASK;
  1601. /* See if the transfer is linked... */
  1602. ladd = readl(cohc->base->virtbase +
  1603. COH901318_CX_LNK_ADDR +
  1604. COH901318_CX_LNK_ADDR_SPACING *
  1605. cohc->id) &
  1606. ~COH901318_CX_LNK_LINK_IMMEDIATE;
  1607. /* Single transaction */
  1608. if (!ladd)
  1609. continue;
  1610. /*
  1611. * Linked transaction, follow the lli, find the
  1612. * currently processing lli, and proceed to the next
  1613. */
  1614. lli = cohd->lli;
  1615. while (lli && lli->link_addr != ladd)
  1616. lli = lli->virt_link_addr;
  1617. if (lli)
  1618. lli = lli->virt_link_addr;
  1619. /*
  1620. * Follow remaining lli links around to count the total
  1621. * number of bytes left
  1622. */
  1623. left += coh901318_get_bytes_in_lli(lli);
  1624. } else {
  1625. left += coh901318_get_bytes_in_lli(cohd->lli);
  1626. }
  1627. i++;
  1628. }
  1629. /* Also count bytes in the queued jobs */
  1630. list_for_each(pos, &cohc->queue) {
  1631. cohd = list_entry(pos, struct coh901318_desc, node);
  1632. left += coh901318_get_bytes_in_lli(cohd->lli);
  1633. }
  1634. spin_unlock_irqrestore(&cohc->lock, flags);
  1635. return left;
  1636. }
  1637. /*
  1638. * Pauses a transfer without losing data. Enables power save.
  1639. * Use this function in conjunction with coh901318_resume.
  1640. */
  1641. static void coh901318_pause(struct dma_chan *chan)
  1642. {
  1643. u32 val;
  1644. unsigned long flags;
  1645. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  1646. int channel = cohc->id;
  1647. void __iomem *virtbase = cohc->base->virtbase;
  1648. spin_lock_irqsave(&cohc->lock, flags);
  1649. /* Disable channel in HW */
  1650. val = readl(virtbase + COH901318_CX_CFG +
  1651. COH901318_CX_CFG_SPACING * channel);
  1652. /* Stopping infinite transfer */
  1653. if ((val & COH901318_CX_CTRL_TC_ENABLE) == 0 &&
  1654. (val & COH901318_CX_CFG_CH_ENABLE))
  1655. cohc->stopped = 1;
  1656. val &= ~COH901318_CX_CFG_CH_ENABLE;
  1657. /* Enable twice, HW bug work around */
  1658. writel(val, virtbase + COH901318_CX_CFG +
  1659. COH901318_CX_CFG_SPACING * channel);
  1660. writel(val, virtbase + COH901318_CX_CFG +
  1661. COH901318_CX_CFG_SPACING * channel);
  1662. /* Spin-wait for it to actually go inactive */
  1663. while (readl(virtbase + COH901318_CX_STAT+COH901318_CX_STAT_SPACING *
  1664. channel) & COH901318_CX_STAT_ACTIVE)
  1665. cpu_relax();
  1666. /* Check if we stopped an active job */
  1667. if ((readl(virtbase + COH901318_CX_CTRL+COH901318_CX_CTRL_SPACING *
  1668. channel) & COH901318_CX_CTRL_TC_VALUE_MASK) > 0)
  1669. cohc->stopped = 1;
  1670. enable_powersave(cohc);
  1671. spin_unlock_irqrestore(&cohc->lock, flags);
  1672. }
  1673. /* Resumes a transfer that has been stopped via 300_dma_stop(..).
  1674. Power save is handled.
  1675. */
  1676. static void coh901318_resume(struct dma_chan *chan)
  1677. {
  1678. u32 val;
  1679. unsigned long flags;
  1680. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  1681. int channel = cohc->id;
  1682. spin_lock_irqsave(&cohc->lock, flags);
  1683. disable_powersave(cohc);
  1684. if (cohc->stopped) {
  1685. /* Enable channel in HW */
  1686. val = readl(cohc->base->virtbase + COH901318_CX_CFG +
  1687. COH901318_CX_CFG_SPACING * channel);
  1688. val |= COH901318_CX_CFG_CH_ENABLE;
  1689. writel(val, cohc->base->virtbase + COH901318_CX_CFG +
  1690. COH901318_CX_CFG_SPACING*channel);
  1691. cohc->stopped = 0;
  1692. }
  1693. spin_unlock_irqrestore(&cohc->lock, flags);
  1694. }
  1695. bool coh901318_filter_id(struct dma_chan *chan, void *chan_id)
  1696. {
  1697. unsigned int ch_nr = (unsigned int) chan_id;
  1698. if (ch_nr == to_coh901318_chan(chan)->id)
  1699. return true;
  1700. return false;
  1701. }
  1702. EXPORT_SYMBOL(coh901318_filter_id);
  1703. /*
  1704. * DMA channel allocation
  1705. */
  1706. static int coh901318_config(struct coh901318_chan *cohc,
  1707. struct coh901318_params *param)
  1708. {
  1709. unsigned long flags;
  1710. const struct coh901318_params *p;
  1711. int channel = cohc->id;
  1712. void __iomem *virtbase = cohc->base->virtbase;
  1713. spin_lock_irqsave(&cohc->lock, flags);
  1714. if (param)
  1715. p = param;
  1716. else
  1717. p = &cohc->base->platform->chan_conf[channel].param;
  1718. /* Clear any pending BE or TC interrupt */
  1719. if (channel < 32) {
  1720. writel(1 << channel, virtbase + COH901318_BE_INT_CLEAR1);
  1721. writel(1 << channel, virtbase + COH901318_TC_INT_CLEAR1);
  1722. } else {
  1723. writel(1 << (channel - 32), virtbase +
  1724. COH901318_BE_INT_CLEAR2);
  1725. writel(1 << (channel - 32), virtbase +
  1726. COH901318_TC_INT_CLEAR2);
  1727. }
  1728. coh901318_set_conf(cohc, p->config);
  1729. coh901318_set_ctrl(cohc, p->ctrl_lli_last);
  1730. spin_unlock_irqrestore(&cohc->lock, flags);
  1731. return 0;
  1732. }
  1733. /* must lock when calling this function
  1734. * start queued jobs, if any
  1735. * TODO: start all queued jobs in one go
  1736. *
  1737. * Returns descriptor if queued job is started otherwise NULL.
  1738. * If the queue is empty NULL is returned.
  1739. */
  1740. static struct coh901318_desc *coh901318_queue_start(struct coh901318_chan *cohc)
  1741. {
  1742. struct coh901318_desc *cohd;
  1743. /*
  1744. * start queued jobs, if any
  1745. * TODO: transmit all queued jobs in one go
  1746. */
  1747. cohd = coh901318_first_queued(cohc);
  1748. if (cohd != NULL) {
  1749. /* Remove from queue */
  1750. coh901318_desc_remove(cohd);
  1751. /* initiate DMA job */
  1752. cohc->busy = 1;
  1753. coh901318_desc_submit(cohc, cohd);
  1754. /* Program the transaction head */
  1755. coh901318_set_conf(cohc, cohd->head_config);
  1756. coh901318_set_ctrl(cohc, cohd->head_ctrl);
  1757. coh901318_prep_linked_list(cohc, cohd->lli);
  1758. /* start dma job on this channel */
  1759. coh901318_start(cohc);
  1760. }
  1761. return cohd;
  1762. }
  1763. /*
  1764. * This tasklet is called from the interrupt handler to
  1765. * handle each descriptor (DMA job) that is sent to a channel.
  1766. */
  1767. static void dma_tasklet(unsigned long data)
  1768. {
  1769. struct coh901318_chan *cohc = (struct coh901318_chan *) data;
  1770. struct coh901318_desc *cohd_fin;
  1771. unsigned long flags;
  1772. dma_async_tx_callback callback;
  1773. void *callback_param;
  1774. dev_vdbg(COHC_2_DEV(cohc), "[%s] chan_id %d"
  1775. " nbr_active_done %ld\n", __func__,
  1776. cohc->id, cohc->nbr_active_done);
  1777. spin_lock_irqsave(&cohc->lock, flags);
  1778. /* get first active descriptor entry from list */
  1779. cohd_fin = coh901318_first_active_get(cohc);
  1780. if (cohd_fin == NULL)
  1781. goto err;
  1782. /* locate callback to client */
  1783. callback = cohd_fin->desc.callback;
  1784. callback_param = cohd_fin->desc.callback_param;
  1785. /* sign this job as completed on the channel */
  1786. dma_cookie_complete(&cohd_fin->desc);
  1787. /* release the lli allocation and remove the descriptor */
  1788. coh901318_lli_free(&cohc->base->pool, &cohd_fin->lli);
  1789. /* return desc to free-list */
  1790. coh901318_desc_remove(cohd_fin);
  1791. coh901318_desc_free(cohc, cohd_fin);
  1792. spin_unlock_irqrestore(&cohc->lock, flags);
  1793. /* Call the callback when we're done */
  1794. if (callback)
  1795. callback(callback_param);
  1796. spin_lock_irqsave(&cohc->lock, flags);
  1797. /*
  1798. * If another interrupt fired while the tasklet was scheduling,
  1799. * we don't get called twice, so we have this number of active
  1800. * counter that keep track of the number of IRQs expected to
  1801. * be handled for this channel. If there happen to be more than
  1802. * one IRQ to be ack:ed, we simply schedule this tasklet again.
  1803. */
  1804. cohc->nbr_active_done--;
  1805. if (cohc->nbr_active_done) {
  1806. dev_dbg(COHC_2_DEV(cohc), "scheduling tasklet again, new IRQs "
  1807. "came in while we were scheduling this tasklet\n");
  1808. if (cohc_chan_conf(cohc)->priority_high)
  1809. tasklet_hi_schedule(&cohc->tasklet);
  1810. else
  1811. tasklet_schedule(&cohc->tasklet);
  1812. }
  1813. spin_unlock_irqrestore(&cohc->lock, flags);
  1814. return;
  1815. err:
  1816. spin_unlock_irqrestore(&cohc->lock, flags);
  1817. dev_err(COHC_2_DEV(cohc), "[%s] No active dma desc\n", __func__);
  1818. }
  1819. /* called from interrupt context */
  1820. static void dma_tc_handle(struct coh901318_chan *cohc)
  1821. {
  1822. /*
  1823. * If the channel is not allocated, then we shouldn't have
  1824. * any TC interrupts on it.
  1825. */
  1826. if (!cohc->allocated) {
  1827. dev_err(COHC_2_DEV(cohc), "spurious interrupt from "
  1828. "unallocated channel\n");
  1829. return;
  1830. }
  1831. spin_lock(&cohc->lock);
  1832. /*
  1833. * When we reach this point, at least one queue item
  1834. * should have been moved over from cohc->queue to
  1835. * cohc->active and run to completion, that is why we're
  1836. * getting a terminal count interrupt is it not?
  1837. * If you get this BUG() the most probable cause is that
  1838. * the individual nodes in the lli chain have IRQ enabled,
  1839. * so check your platform config for lli chain ctrl.
  1840. */
  1841. BUG_ON(list_empty(&cohc->active));
  1842. cohc->nbr_active_done++;
  1843. /*
  1844. * This attempt to take a job from cohc->queue, put it
  1845. * into cohc->active and start it.
  1846. */
  1847. if (coh901318_queue_start(cohc) == NULL)
  1848. cohc->busy = 0;
  1849. spin_unlock(&cohc->lock);
  1850. /*
  1851. * This tasklet will remove items from cohc->active
  1852. * and thus terminates them.
  1853. */
  1854. if (cohc_chan_conf(cohc)->priority_high)
  1855. tasklet_hi_schedule(&cohc->tasklet);
  1856. else
  1857. tasklet_schedule(&cohc->tasklet);
  1858. }
  1859. static irqreturn_t dma_irq_handler(int irq, void *dev_id)
  1860. {
  1861. u32 status1;
  1862. u32 status2;
  1863. int i;
  1864. int ch;
  1865. struct coh901318_base *base = dev_id;
  1866. struct coh901318_chan *cohc;
  1867. void __iomem *virtbase = base->virtbase;
  1868. status1 = readl(virtbase + COH901318_INT_STATUS1);
  1869. status2 = readl(virtbase + COH901318_INT_STATUS2);
  1870. if (unlikely(status1 == 0 && status2 == 0)) {
  1871. dev_warn(base->dev, "spurious DMA IRQ from no channel!\n");
  1872. return IRQ_HANDLED;
  1873. }
  1874. /* TODO: consider handle IRQ in tasklet here to
  1875. * minimize interrupt latency */
  1876. /* Check the first 32 DMA channels for IRQ */
  1877. while (status1) {
  1878. /* Find first bit set, return as a number. */
  1879. i = ffs(status1) - 1;
  1880. ch = i;
  1881. cohc = &base->chans[ch];
  1882. spin_lock(&cohc->lock);
  1883. /* Mask off this bit */
  1884. status1 &= ~(1 << i);
  1885. /* Check the individual channel bits */
  1886. if (test_bit(i, virtbase + COH901318_BE_INT_STATUS1)) {
  1887. dev_crit(COHC_2_DEV(cohc),
  1888. "DMA bus error on channel %d!\n", ch);
  1889. BUG_ON(1);
  1890. /* Clear BE interrupt */
  1891. __set_bit(i, virtbase + COH901318_BE_INT_CLEAR1);
  1892. } else {
  1893. /* Caused by TC, really? */
  1894. if (unlikely(!test_bit(i, virtbase +
  1895. COH901318_TC_INT_STATUS1))) {
  1896. dev_warn(COHC_2_DEV(cohc),
  1897. "ignoring interrupt not caused by terminal count on channel %d\n", ch);
  1898. /* Clear TC interrupt */
  1899. BUG_ON(1);
  1900. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR1);
  1901. } else {
  1902. /* Enable powersave if transfer has finished */
  1903. if (!(readl(virtbase + COH901318_CX_STAT +
  1904. COH901318_CX_STAT_SPACING*ch) &
  1905. COH901318_CX_STAT_ENABLED)) {
  1906. enable_powersave(cohc);
  1907. }
  1908. /* Must clear TC interrupt before calling
  1909. * dma_tc_handle
  1910. * in case tc_handle initiate a new dma job
  1911. */
  1912. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR1);
  1913. dma_tc_handle(cohc);
  1914. }
  1915. }
  1916. spin_unlock(&cohc->lock);
  1917. }
  1918. /* Check the remaining 32 DMA channels for IRQ */
  1919. while (status2) {
  1920. /* Find first bit set, return as a number. */
  1921. i = ffs(status2) - 1;
  1922. ch = i + 32;
  1923. cohc = &base->chans[ch];
  1924. spin_lock(&cohc->lock);
  1925. /* Mask off this bit */
  1926. status2 &= ~(1 << i);
  1927. /* Check the individual channel bits */
  1928. if (test_bit(i, virtbase + COH901318_BE_INT_STATUS2)) {
  1929. dev_crit(COHC_2_DEV(cohc),
  1930. "DMA bus error on channel %d!\n", ch);
  1931. /* Clear BE interrupt */
  1932. BUG_ON(1);
  1933. __set_bit(i, virtbase + COH901318_BE_INT_CLEAR2);
  1934. } else {
  1935. /* Caused by TC, really? */
  1936. if (unlikely(!test_bit(i, virtbase +
  1937. COH901318_TC_INT_STATUS2))) {
  1938. dev_warn(COHC_2_DEV(cohc),
  1939. "ignoring interrupt not caused by terminal count on channel %d\n", ch);
  1940. /* Clear TC interrupt */
  1941. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR2);
  1942. BUG_ON(1);
  1943. } else {
  1944. /* Enable powersave if transfer has finished */
  1945. if (!(readl(virtbase + COH901318_CX_STAT +
  1946. COH901318_CX_STAT_SPACING*ch) &
  1947. COH901318_CX_STAT_ENABLED)) {
  1948. enable_powersave(cohc);
  1949. }
  1950. /* Must clear TC interrupt before calling
  1951. * dma_tc_handle
  1952. * in case tc_handle initiate a new dma job
  1953. */
  1954. __set_bit(i, virtbase + COH901318_TC_INT_CLEAR2);
  1955. dma_tc_handle(cohc);
  1956. }
  1957. }
  1958. spin_unlock(&cohc->lock);
  1959. }
  1960. return IRQ_HANDLED;
  1961. }
  1962. static int coh901318_alloc_chan_resources(struct dma_chan *chan)
  1963. {
  1964. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  1965. unsigned long flags;
  1966. dev_vdbg(COHC_2_DEV(cohc), "[%s] DMA channel %d\n",
  1967. __func__, cohc->id);
  1968. if (chan->client_count > 1)
  1969. return -EBUSY;
  1970. spin_lock_irqsave(&cohc->lock, flags);
  1971. coh901318_config(cohc, NULL);
  1972. cohc->allocated = 1;
  1973. dma_cookie_init(chan);
  1974. spin_unlock_irqrestore(&cohc->lock, flags);
  1975. return 1;
  1976. }
  1977. static void
  1978. coh901318_free_chan_resources(struct dma_chan *chan)
  1979. {
  1980. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  1981. int channel = cohc->id;
  1982. unsigned long flags;
  1983. spin_lock_irqsave(&cohc->lock, flags);
  1984. /* Disable HW */
  1985. writel(0x00000000U, cohc->base->virtbase + COH901318_CX_CFG +
  1986. COH901318_CX_CFG_SPACING*channel);
  1987. writel(0x00000000U, cohc->base->virtbase + COH901318_CX_CTRL +
  1988. COH901318_CX_CTRL_SPACING*channel);
  1989. cohc->allocated = 0;
  1990. spin_unlock_irqrestore(&cohc->lock, flags);
  1991. chan->device->device_control(chan, DMA_TERMINATE_ALL, 0);
  1992. }
  1993. static dma_cookie_t
  1994. coh901318_tx_submit(struct dma_async_tx_descriptor *tx)
  1995. {
  1996. struct coh901318_desc *cohd = container_of(tx, struct coh901318_desc,
  1997. desc);
  1998. struct coh901318_chan *cohc = to_coh901318_chan(tx->chan);
  1999. unsigned long flags;
  2000. dma_cookie_t cookie;
  2001. spin_lock_irqsave(&cohc->lock, flags);
  2002. cookie = dma_cookie_assign(tx);
  2003. coh901318_desc_queue(cohc, cohd);
  2004. spin_unlock_irqrestore(&cohc->lock, flags);
  2005. return cookie;
  2006. }
  2007. static struct dma_async_tx_descriptor *
  2008. coh901318_prep_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
  2009. size_t size, unsigned long flags)
  2010. {
  2011. struct coh901318_lli *lli;
  2012. struct coh901318_desc *cohd;
  2013. unsigned long flg;
  2014. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  2015. int lli_len;
  2016. u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
  2017. int ret;
  2018. spin_lock_irqsave(&cohc->lock, flg);
  2019. dev_vdbg(COHC_2_DEV(cohc),
  2020. "[%s] channel %d src 0x%x dest 0x%x size %d\n",
  2021. __func__, cohc->id, src, dest, size);
  2022. if (flags & DMA_PREP_INTERRUPT)
  2023. /* Trigger interrupt after last lli */
  2024. ctrl_last |= COH901318_CX_CTRL_TC_IRQ_ENABLE;
  2025. lli_len = size >> MAX_DMA_PACKET_SIZE_SHIFT;
  2026. if ((lli_len << MAX_DMA_PACKET_SIZE_SHIFT) < size)
  2027. lli_len++;
  2028. lli = coh901318_lli_alloc(&cohc->base->pool, lli_len);
  2029. if (lli == NULL)
  2030. goto err;
  2031. ret = coh901318_lli_fill_memcpy(
  2032. &cohc->base->pool, lli, src, size, dest,
  2033. cohc_chan_param(cohc)->ctrl_lli_chained,
  2034. ctrl_last);
  2035. if (ret)
  2036. goto err;
  2037. COH_DBG(coh901318_list_print(cohc, lli));
  2038. /* Pick a descriptor to handle this transfer */
  2039. cohd = coh901318_desc_get(cohc);
  2040. cohd->lli = lli;
  2041. cohd->flags = flags;
  2042. cohd->desc.tx_submit = coh901318_tx_submit;
  2043. spin_unlock_irqrestore(&cohc->lock, flg);
  2044. return &cohd->desc;
  2045. err:
  2046. spin_unlock_irqrestore(&cohc->lock, flg);
  2047. return NULL;
  2048. }
  2049. static struct dma_async_tx_descriptor *
  2050. coh901318_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
  2051. unsigned int sg_len, enum dma_transfer_direction direction,
  2052. unsigned long flags, void *context)
  2053. {
  2054. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  2055. struct coh901318_lli *lli;
  2056. struct coh901318_desc *cohd;
  2057. const struct coh901318_params *params;
  2058. struct scatterlist *sg;
  2059. int len = 0;
  2060. int size;
  2061. int i;
  2062. u32 ctrl_chained = cohc_chan_param(cohc)->ctrl_lli_chained;
  2063. u32 ctrl = cohc_chan_param(cohc)->ctrl_lli;
  2064. u32 ctrl_last = cohc_chan_param(cohc)->ctrl_lli_last;
  2065. u32 config;
  2066. unsigned long flg;
  2067. int ret;
  2068. if (!sgl)
  2069. goto out;
  2070. if (sg_dma_len(sgl) == 0)
  2071. goto out;
  2072. spin_lock_irqsave(&cohc->lock, flg);
  2073. dev_vdbg(COHC_2_DEV(cohc), "[%s] sg_len %d dir %d\n",
  2074. __func__, sg_len, direction);
  2075. if (flags & DMA_PREP_INTERRUPT)
  2076. /* Trigger interrupt after last lli */
  2077. ctrl_last |= COH901318_CX_CTRL_TC_IRQ_ENABLE;
  2078. params = cohc_chan_param(cohc);
  2079. config = params->config;
  2080. /*
  2081. * Add runtime-specific control on top, make
  2082. * sure the bits you set per peripheral channel are
  2083. * cleared in the default config from the platform.
  2084. */
  2085. ctrl_chained |= cohc->ctrl;
  2086. ctrl_last |= cohc->ctrl;
  2087. ctrl |= cohc->ctrl;
  2088. if (direction == DMA_MEM_TO_DEV) {
  2089. u32 tx_flags = COH901318_CX_CTRL_PRDD_SOURCE |
  2090. COH901318_CX_CTRL_SRC_ADDR_INC_ENABLE;
  2091. config |= COH901318_CX_CFG_RM_MEMORY_TO_PRIMARY;
  2092. ctrl_chained |= tx_flags;
  2093. ctrl_last |= tx_flags;
  2094. ctrl |= tx_flags;
  2095. } else if (direction == DMA_DEV_TO_MEM) {
  2096. u32 rx_flags = COH901318_CX_CTRL_PRDD_DEST |
  2097. COH901318_CX_CTRL_DST_ADDR_INC_ENABLE;
  2098. config |= COH901318_CX_CFG_RM_PRIMARY_TO_MEMORY;
  2099. ctrl_chained |= rx_flags;
  2100. ctrl_last |= rx_flags;
  2101. ctrl |= rx_flags;
  2102. } else
  2103. goto err_direction;
  2104. /* The dma only supports transmitting packages up to
  2105. * MAX_DMA_PACKET_SIZE. Calculate to total number of
  2106. * dma elemts required to send the entire sg list
  2107. */
  2108. for_each_sg(sgl, sg, sg_len, i) {
  2109. unsigned int factor;
  2110. size = sg_dma_len(sg);
  2111. if (size <= MAX_DMA_PACKET_SIZE) {
  2112. len++;
  2113. continue;
  2114. }
  2115. factor = size >> MAX_DMA_PACKET_SIZE_SHIFT;
  2116. if ((factor << MAX_DMA_PACKET_SIZE_SHIFT) < size)
  2117. factor++;
  2118. len += factor;
  2119. }
  2120. pr_debug("Allocate %d lli:s for this transfer\n", len);
  2121. lli = coh901318_lli_alloc(&cohc->base->pool, len);
  2122. if (lli == NULL)
  2123. goto err_dma_alloc;
  2124. /* initiate allocated lli list */
  2125. ret = coh901318_lli_fill_sg(&cohc->base->pool, lli, sgl, sg_len,
  2126. cohc->addr,
  2127. ctrl_chained,
  2128. ctrl,
  2129. ctrl_last,
  2130. direction, COH901318_CX_CTRL_TC_IRQ_ENABLE);
  2131. if (ret)
  2132. goto err_lli_fill;
  2133. COH_DBG(coh901318_list_print(cohc, lli));
  2134. /* Pick a descriptor to handle this transfer */
  2135. cohd = coh901318_desc_get(cohc);
  2136. cohd->head_config = config;
  2137. /*
  2138. * Set the default head ctrl for the channel to the one from the
  2139. * lli, things may have changed due to odd buffer alignment
  2140. * etc.
  2141. */
  2142. cohd->head_ctrl = lli->control;
  2143. cohd->dir = direction;
  2144. cohd->flags = flags;
  2145. cohd->desc.tx_submit = coh901318_tx_submit;
  2146. cohd->lli = lli;
  2147. spin_unlock_irqrestore(&cohc->lock, flg);
  2148. return &cohd->desc;
  2149. err_lli_fill:
  2150. err_dma_alloc:
  2151. err_direction:
  2152. spin_unlock_irqrestore(&cohc->lock, flg);
  2153. out:
  2154. return NULL;
  2155. }
  2156. static enum dma_status
  2157. coh901318_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
  2158. struct dma_tx_state *txstate)
  2159. {
  2160. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  2161. enum dma_status ret;
  2162. ret = dma_cookie_status(chan, cookie, txstate);
  2163. /* FIXME: should be conditional on ret != DMA_SUCCESS? */
  2164. dma_set_residue(txstate, coh901318_get_bytes_left(chan));
  2165. if (ret == DMA_IN_PROGRESS && cohc->stopped)
  2166. ret = DMA_PAUSED;
  2167. return ret;
  2168. }
  2169. static void
  2170. coh901318_issue_pending(struct dma_chan *chan)
  2171. {
  2172. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  2173. unsigned long flags;
  2174. spin_lock_irqsave(&cohc->lock, flags);
  2175. /*
  2176. * Busy means that pending jobs are already being processed,
  2177. * and then there is no point in starting the queue: the
  2178. * terminal count interrupt on the channel will take the next
  2179. * job on the queue and execute it anyway.
  2180. */
  2181. if (!cohc->busy)
  2182. coh901318_queue_start(cohc);
  2183. spin_unlock_irqrestore(&cohc->lock, flags);
  2184. }
  2185. /*
  2186. * Here we wrap in the runtime dma control interface
  2187. */
  2188. struct burst_table {
  2189. int burst_8bit;
  2190. int burst_16bit;
  2191. int burst_32bit;
  2192. u32 reg;
  2193. };
  2194. static const struct burst_table burst_sizes[] = {
  2195. {
  2196. .burst_8bit = 64,
  2197. .burst_16bit = 32,
  2198. .burst_32bit = 16,
  2199. .reg = COH901318_CX_CTRL_BURST_COUNT_64_BYTES,
  2200. },
  2201. {
  2202. .burst_8bit = 48,
  2203. .burst_16bit = 24,
  2204. .burst_32bit = 12,
  2205. .reg = COH901318_CX_CTRL_BURST_COUNT_48_BYTES,
  2206. },
  2207. {
  2208. .burst_8bit = 32,
  2209. .burst_16bit = 16,
  2210. .burst_32bit = 8,
  2211. .reg = COH901318_CX_CTRL_BURST_COUNT_32_BYTES,
  2212. },
  2213. {
  2214. .burst_8bit = 16,
  2215. .burst_16bit = 8,
  2216. .burst_32bit = 4,
  2217. .reg = COH901318_CX_CTRL_BURST_COUNT_16_BYTES,
  2218. },
  2219. {
  2220. .burst_8bit = 8,
  2221. .burst_16bit = 4,
  2222. .burst_32bit = 2,
  2223. .reg = COH901318_CX_CTRL_BURST_COUNT_8_BYTES,
  2224. },
  2225. {
  2226. .burst_8bit = 4,
  2227. .burst_16bit = 2,
  2228. .burst_32bit = 1,
  2229. .reg = COH901318_CX_CTRL_BURST_COUNT_4_BYTES,
  2230. },
  2231. {
  2232. .burst_8bit = 2,
  2233. .burst_16bit = 1,
  2234. .burst_32bit = 0,
  2235. .reg = COH901318_CX_CTRL_BURST_COUNT_2_BYTES,
  2236. },
  2237. {
  2238. .burst_8bit = 1,
  2239. .burst_16bit = 0,
  2240. .burst_32bit = 0,
  2241. .reg = COH901318_CX_CTRL_BURST_COUNT_1_BYTE,
  2242. },
  2243. };
  2244. static void coh901318_dma_set_runtimeconfig(struct dma_chan *chan,
  2245. struct dma_slave_config *config)
  2246. {
  2247. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  2248. dma_addr_t addr;
  2249. enum dma_slave_buswidth addr_width;
  2250. u32 maxburst;
  2251. u32 ctrl = 0;
  2252. int i = 0;
  2253. /* We only support mem to per or per to mem transfers */
  2254. if (config->direction == DMA_DEV_TO_MEM) {
  2255. addr = config->src_addr;
  2256. addr_width = config->src_addr_width;
  2257. maxburst = config->src_maxburst;
  2258. } else if (config->direction == DMA_MEM_TO_DEV) {
  2259. addr = config->dst_addr;
  2260. addr_width = config->dst_addr_width;
  2261. maxburst = config->dst_maxburst;
  2262. } else {
  2263. dev_err(COHC_2_DEV(cohc), "illegal channel mode\n");
  2264. return;
  2265. }
  2266. dev_dbg(COHC_2_DEV(cohc), "configure channel for %d byte transfers\n",
  2267. addr_width);
  2268. switch (addr_width) {
  2269. case DMA_SLAVE_BUSWIDTH_1_BYTE:
  2270. ctrl |=
  2271. COH901318_CX_CTRL_SRC_BUS_SIZE_8_BITS |
  2272. COH901318_CX_CTRL_DST_BUS_SIZE_8_BITS;
  2273. while (i < ARRAY_SIZE(burst_sizes)) {
  2274. if (burst_sizes[i].burst_8bit <= maxburst)
  2275. break;
  2276. i++;
  2277. }
  2278. break;
  2279. case DMA_SLAVE_BUSWIDTH_2_BYTES:
  2280. ctrl |=
  2281. COH901318_CX_CTRL_SRC_BUS_SIZE_16_BITS |
  2282. COH901318_CX_CTRL_DST_BUS_SIZE_16_BITS;
  2283. while (i < ARRAY_SIZE(burst_sizes)) {
  2284. if (burst_sizes[i].burst_16bit <= maxburst)
  2285. break;
  2286. i++;
  2287. }
  2288. break;
  2289. case DMA_SLAVE_BUSWIDTH_4_BYTES:
  2290. /* Direction doesn't matter here, it's 32/32 bits */
  2291. ctrl |=
  2292. COH901318_CX_CTRL_SRC_BUS_SIZE_32_BITS |
  2293. COH901318_CX_CTRL_DST_BUS_SIZE_32_BITS;
  2294. while (i < ARRAY_SIZE(burst_sizes)) {
  2295. if (burst_sizes[i].burst_32bit <= maxburst)
  2296. break;
  2297. i++;
  2298. }
  2299. break;
  2300. default:
  2301. dev_err(COHC_2_DEV(cohc),
  2302. "bad runtimeconfig: alien address width\n");
  2303. return;
  2304. }
  2305. ctrl |= burst_sizes[i].reg;
  2306. dev_dbg(COHC_2_DEV(cohc),
  2307. "selected burst size %d bytes for address width %d bytes, maxburst %d\n",
  2308. burst_sizes[i].burst_8bit, addr_width, maxburst);
  2309. cohc->addr = addr;
  2310. cohc->ctrl = ctrl;
  2311. }
  2312. static int
  2313. coh901318_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
  2314. unsigned long arg)
  2315. {
  2316. unsigned long flags;
  2317. struct coh901318_chan *cohc = to_coh901318_chan(chan);
  2318. struct coh901318_desc *cohd;
  2319. void __iomem *virtbase = cohc->base->virtbase;
  2320. if (cmd == DMA_SLAVE_CONFIG) {
  2321. struct dma_slave_config *config =
  2322. (struct dma_slave_config *) arg;
  2323. coh901318_dma_set_runtimeconfig(chan, config);
  2324. return 0;
  2325. }
  2326. if (cmd == DMA_PAUSE) {
  2327. coh901318_pause(chan);
  2328. return 0;
  2329. }
  2330. if (cmd == DMA_RESUME) {
  2331. coh901318_resume(chan);
  2332. return 0;
  2333. }
  2334. if (cmd != DMA_TERMINATE_ALL)
  2335. return -ENXIO;
  2336. /* The remainder of this function terminates the transfer */
  2337. coh901318_pause(chan);
  2338. spin_lock_irqsave(&cohc->lock, flags);
  2339. /* Clear any pending BE or TC interrupt */
  2340. if (cohc->id < 32) {
  2341. writel(1 << cohc->id, virtbase + COH901318_BE_INT_CLEAR1);
  2342. writel(1 << cohc->id, virtbase + COH901318_TC_INT_CLEAR1);
  2343. } else {
  2344. writel(1 << (cohc->id - 32), virtbase +
  2345. COH901318_BE_INT_CLEAR2);
  2346. writel(1 << (cohc->id - 32), virtbase +
  2347. COH901318_TC_INT_CLEAR2);
  2348. }
  2349. enable_powersave(cohc);
  2350. while ((cohd = coh901318_first_active_get(cohc))) {
  2351. /* release the lli allocation*/
  2352. coh901318_lli_free(&cohc->base->pool, &cohd->lli);
  2353. /* return desc to free-list */
  2354. coh901318_desc_remove(cohd);
  2355. coh901318_desc_free(cohc, cohd);
  2356. }
  2357. while ((cohd = coh901318_first_queued(cohc))) {
  2358. /* release the lli allocation*/
  2359. coh901318_lli_free(&cohc->base->pool, &cohd->lli);
  2360. /* return desc to free-list */
  2361. coh901318_desc_remove(cohd);
  2362. coh901318_desc_free(cohc, cohd);
  2363. }
  2364. cohc->nbr_active_done = 0;
  2365. cohc->busy = 0;
  2366. spin_unlock_irqrestore(&cohc->lock, flags);
  2367. return 0;
  2368. }
  2369. void coh901318_base_init(struct dma_device *dma, const int *pick_chans,
  2370. struct coh901318_base *base)
  2371. {
  2372. int chans_i;
  2373. int i = 0;
  2374. struct coh901318_chan *cohc;
  2375. INIT_LIST_HEAD(&dma->channels);
  2376. for (chans_i = 0; pick_chans[chans_i] != -1; chans_i += 2) {
  2377. for (i = pick_chans[chans_i]; i <= pick_chans[chans_i+1]; i++) {
  2378. cohc = &base->chans[i];
  2379. cohc->base = base;
  2380. cohc->chan.device = dma;
  2381. cohc->id = i;
  2382. /* TODO: do we really need this lock if only one
  2383. * client is connected to each channel?
  2384. */
  2385. spin_lock_init(&cohc->lock);
  2386. cohc->nbr_active_done = 0;
  2387. cohc->busy = 0;
  2388. INIT_LIST_HEAD(&cohc->free);
  2389. INIT_LIST_HEAD(&cohc->active);
  2390. INIT_LIST_HEAD(&cohc->queue);
  2391. tasklet_init(&cohc->tasklet, dma_tasklet,
  2392. (unsigned long) cohc);
  2393. list_add_tail(&cohc->chan.device_node,
  2394. &dma->channels);
  2395. }
  2396. }
  2397. }
  2398. static int __init coh901318_probe(struct platform_device *pdev)
  2399. {
  2400. int err = 0;
  2401. struct coh901318_platform *pdata;
  2402. struct coh901318_base *base;
  2403. int irq;
  2404. struct resource *io;
  2405. io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  2406. if (!io)
  2407. return -ENODEV;
  2408. /* Map DMA controller registers to virtual memory */
  2409. if (devm_request_mem_region(&pdev->dev,
  2410. io->start,
  2411. resource_size(io),
  2412. pdev->dev.driver->name) == NULL)
  2413. return -ENOMEM;
  2414. pdata = &coh901318_platform,
  2415. base = devm_kzalloc(&pdev->dev,
  2416. ALIGN(sizeof(struct coh901318_base), 4) +
  2417. pdata->max_channels *
  2418. sizeof(struct coh901318_chan),
  2419. GFP_KERNEL);
  2420. if (!base)
  2421. return -ENOMEM;
  2422. base->chans = ((void *)base) + ALIGN(sizeof(struct coh901318_base), 4);
  2423. base->virtbase = devm_ioremap(&pdev->dev, io->start, resource_size(io));
  2424. if (!base->virtbase)
  2425. return -ENOMEM;
  2426. base->dev = &pdev->dev;
  2427. base->platform = pdata;
  2428. spin_lock_init(&base->pm.lock);
  2429. base->pm.started_channels = 0;
  2430. COH901318_DEBUGFS_ASSIGN(debugfs_dma_base, base);
  2431. irq = platform_get_irq(pdev, 0);
  2432. if (irq < 0)
  2433. return irq;
  2434. err = devm_request_irq(&pdev->dev, irq, dma_irq_handler, IRQF_DISABLED,
  2435. "coh901318", base);
  2436. if (err)
  2437. return err;
  2438. err = coh901318_pool_create(&base->pool, &pdev->dev,
  2439. sizeof(struct coh901318_lli),
  2440. 32);
  2441. if (err)
  2442. return err;
  2443. /* init channels for device transfers */
  2444. coh901318_base_init(&base->dma_slave, base->platform->chans_slave,
  2445. base);
  2446. dma_cap_zero(base->dma_slave.cap_mask);
  2447. dma_cap_set(DMA_SLAVE, base->dma_slave.cap_mask);
  2448. base->dma_slave.device_alloc_chan_resources = coh901318_alloc_chan_resources;
  2449. base->dma_slave.device_free_chan_resources = coh901318_free_chan_resources;
  2450. base->dma_slave.device_prep_slave_sg = coh901318_prep_slave_sg;
  2451. base->dma_slave.device_tx_status = coh901318_tx_status;
  2452. base->dma_slave.device_issue_pending = coh901318_issue_pending;
  2453. base->dma_slave.device_control = coh901318_control;
  2454. base->dma_slave.dev = &pdev->dev;
  2455. err = dma_async_device_register(&base->dma_slave);
  2456. if (err)
  2457. goto err_register_slave;
  2458. /* init channels for memcpy */
  2459. coh901318_base_init(&base->dma_memcpy, base->platform->chans_memcpy,
  2460. base);
  2461. dma_cap_zero(base->dma_memcpy.cap_mask);
  2462. dma_cap_set(DMA_MEMCPY, base->dma_memcpy.cap_mask);
  2463. base->dma_memcpy.device_alloc_chan_resources = coh901318_alloc_chan_resources;
  2464. base->dma_memcpy.device_free_chan_resources = coh901318_free_chan_resources;
  2465. base->dma_memcpy.device_prep_dma_memcpy = coh901318_prep_memcpy;
  2466. base->dma_memcpy.device_tx_status = coh901318_tx_status;
  2467. base->dma_memcpy.device_issue_pending = coh901318_issue_pending;
  2468. base->dma_memcpy.device_control = coh901318_control;
  2469. base->dma_memcpy.dev = &pdev->dev;
  2470. /*
  2471. * This controller can only access address at even 32bit boundaries,
  2472. * i.e. 2^2
  2473. */
  2474. base->dma_memcpy.copy_align = 2;
  2475. err = dma_async_device_register(&base->dma_memcpy);
  2476. if (err)
  2477. goto err_register_memcpy;
  2478. platform_set_drvdata(pdev, base);
  2479. dev_info(&pdev->dev, "Initialized COH901318 DMA on virtual base 0x%08x\n",
  2480. (u32) base->virtbase);
  2481. return err;
  2482. err_register_memcpy:
  2483. dma_async_device_unregister(&base->dma_slave);
  2484. err_register_slave:
  2485. coh901318_pool_destroy(&base->pool);
  2486. return err;
  2487. }
  2488. static int __exit coh901318_remove(struct platform_device *pdev)
  2489. {
  2490. struct coh901318_base *base = platform_get_drvdata(pdev);
  2491. dma_async_device_unregister(&base->dma_memcpy);
  2492. dma_async_device_unregister(&base->dma_slave);
  2493. coh901318_pool_destroy(&base->pool);
  2494. return 0;
  2495. }
  2496. static struct platform_driver coh901318_driver = {
  2497. .remove = __exit_p(coh901318_remove),
  2498. .driver = {
  2499. .name = "coh901318",
  2500. },
  2501. };
  2502. int __init coh901318_init(void)
  2503. {
  2504. return platform_driver_probe(&coh901318_driver, coh901318_probe);
  2505. }
  2506. subsys_initcall(coh901318_init);
  2507. void __exit coh901318_exit(void)
  2508. {
  2509. platform_driver_unregister(&coh901318_driver);
  2510. }
  2511. module_exit(coh901318_exit);
  2512. MODULE_LICENSE("GPL");
  2513. MODULE_AUTHOR("Per Friden");