coh901318.c 79 KB

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