coh901318.c 80 KB

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