ppc4xx_dma.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*
  2. * include/asm-ppc/ppc4xx_dma.h
  3. *
  4. * IBM PPC4xx DMA engine library
  5. *
  6. * Copyright 2000-2004 MontaVista Software Inc.
  7. *
  8. * Cleaned up a bit more, Matt Porter <mporter@kernel.crashing.org>
  9. *
  10. * Original code by Armin Kuster <akuster@mvista.com>
  11. * and Pete Popov <ppopov@mvista.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify it
  14. * under the terms of the GNU General Public License as published by the
  15. * Free Software Foundation; either version 2 of the License, or (at your
  16. * option) any later version.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program; if not, write to the Free Software Foundation, Inc.,
  20. * 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #ifdef __KERNEL__
  23. #ifndef __ASMPPC_PPC4xx_DMA_H
  24. #define __ASMPPC_PPC4xx_DMA_H
  25. #include <linux/types.h>
  26. #include <asm/mmu.h>
  27. #include <asm/ibm4xx.h>
  28. #undef DEBUG_4xxDMA
  29. #define MAX_PPC4xx_DMA_CHANNELS 4
  30. /*
  31. * Function return status codes
  32. * These values are used to indicate whether or not the function
  33. * call was successful, or a bad/invalid parameter was passed.
  34. */
  35. #define DMA_STATUS_GOOD 0
  36. #define DMA_STATUS_BAD_CHANNEL 1
  37. #define DMA_STATUS_BAD_HANDLE 2
  38. #define DMA_STATUS_BAD_MODE 3
  39. #define DMA_STATUS_NULL_POINTER 4
  40. #define DMA_STATUS_OUT_OF_MEMORY 5
  41. #define DMA_STATUS_SGL_LIST_EMPTY 6
  42. #define DMA_STATUS_GENERAL_ERROR 7
  43. #define DMA_STATUS_CHANNEL_NOTFREE 8
  44. #define DMA_CHANNEL_BUSY 0x80000000
  45. /*
  46. * These indicate status as returned from the DMA Status Register.
  47. */
  48. #define DMA_STATUS_NO_ERROR 0
  49. #define DMA_STATUS_CS 1 /* Count Status */
  50. #define DMA_STATUS_TS 2 /* Transfer Status */
  51. #define DMA_STATUS_DMA_ERROR 3 /* DMA Error Occurred */
  52. #define DMA_STATUS_DMA_BUSY 4 /* The channel is busy */
  53. /*
  54. * DMA Channel Control Registers
  55. */
  56. #ifdef CONFIG_44x
  57. #define PPC4xx_DMA_64BIT
  58. #define DMA_CR_OFFSET 1
  59. #else
  60. #define DMA_CR_OFFSET 0
  61. #endif
  62. #define DMA_CE_ENABLE (1<<31) /* DMA Channel Enable */
  63. #define SET_DMA_CE_ENABLE(x) (((x)&0x1)<<31)
  64. #define GET_DMA_CE_ENABLE(x) (((x)&DMA_CE_ENABLE)>>31)
  65. #define DMA_CIE_ENABLE (1<<30) /* DMA Channel Interrupt Enable */
  66. #define SET_DMA_CIE_ENABLE(x) (((x)&0x1)<<30)
  67. #define GET_DMA_CIE_ENABLE(x) (((x)&DMA_CIE_ENABLE)>>30)
  68. #define DMA_TD (1<<29)
  69. #define SET_DMA_TD(x) (((x)&0x1)<<29)
  70. #define GET_DMA_TD(x) (((x)&DMA_TD)>>29)
  71. #define DMA_PL (1<<28) /* Peripheral Location */
  72. #define SET_DMA_PL(x) (((x)&0x1)<<28)
  73. #define GET_DMA_PL(x) (((x)&DMA_PL)>>28)
  74. #define EXTERNAL_PERIPHERAL 0
  75. #define INTERNAL_PERIPHERAL 1
  76. #define SET_DMA_PW(x) (((x)&0x3)<<(26-DMA_CR_OFFSET)) /* Peripheral Width */
  77. #define DMA_PW_MASK SET_DMA_PW(3)
  78. #define PW_8 0
  79. #define PW_16 1
  80. #define PW_32 2
  81. #define PW_64 3
  82. /* FIXME: Add PW_128 support for 440GP DMA block */
  83. #define GET_DMA_PW(x) (((x)&DMA_PW_MASK)>>(26-DMA_CR_OFFSET))
  84. #define DMA_DAI (1<<(25-DMA_CR_OFFSET)) /* Destination Address Increment */
  85. #define SET_DMA_DAI(x) (((x)&0x1)<<(25-DMA_CR_OFFSET))
  86. #define DMA_SAI (1<<(24-DMA_CR_OFFSET)) /* Source Address Increment */
  87. #define SET_DMA_SAI(x) (((x)&0x1)<<(24-DMA_CR_OFFSET))
  88. #define DMA_BEN (1<<(23-DMA_CR_OFFSET)) /* Buffer Enable */
  89. #define SET_DMA_BEN(x) (((x)&0x1)<<(23-DMA_CR_OFFSET))
  90. #define SET_DMA_TM(x) (((x)&0x3)<<(21-DMA_CR_OFFSET)) /* Transfer Mode */
  91. #define DMA_TM_MASK SET_DMA_TM(3)
  92. #define TM_PERIPHERAL 0 /* Peripheral */
  93. #define TM_RESERVED 1 /* Reserved */
  94. #define TM_S_MM 2 /* Memory to Memory */
  95. #define TM_D_MM 3 /* Device Paced Memory to Memory */
  96. #define GET_DMA_TM(x) (((x)&DMA_TM_MASK)>>(21-DMA_CR_OFFSET))
  97. #define SET_DMA_PSC(x) (((x)&0x3)<<(19-DMA_CR_OFFSET)) /* Peripheral Setup Cycles */
  98. #define DMA_PSC_MASK SET_DMA_PSC(3)
  99. #define GET_DMA_PSC(x) (((x)&DMA_PSC_MASK)>>(19-DMA_CR_OFFSET))
  100. #define SET_DMA_PWC(x) (((x)&0x3F)<<(13-DMA_CR_OFFSET)) /* Peripheral Wait Cycles */
  101. #define DMA_PWC_MASK SET_DMA_PWC(0x3F)
  102. #define GET_DMA_PWC(x) (((x)&DMA_PWC_MASK)>>(13-DMA_CR_OFFSET))
  103. #define SET_DMA_PHC(x) (((x)&0x7)<<(10-DMA_CR_OFFSET)) /* Peripheral Hold Cycles */
  104. #define DMA_PHC_MASK SET_DMA_PHC(0x7)
  105. #define GET_DMA_PHC(x) (((x)&DMA_PHC_MASK)>>(10-DMA_CR_OFFSET))
  106. #define DMA_ETD_OUTPUT (1<<(9-DMA_CR_OFFSET)) /* EOT pin is a TC output */
  107. #define SET_DMA_ETD(x) (((x)&0x1)<<(9-DMA_CR_OFFSET))
  108. #define DMA_TCE_ENABLE (1<<(8-DMA_CR_OFFSET))
  109. #define SET_DMA_TCE(x) (((x)&0x1)<<(8-DMA_CR_OFFSET))
  110. #define DMA_DEC (1<<(2)) /* Address Decrement */
  111. #define SET_DMA_DEC(x) (((x)&0x1)<<2)
  112. #define GET_DMA_DEC(x) (((x)&DMA_DEC)>>2)
  113. /*
  114. * Transfer Modes
  115. * These modes are defined in a way that makes it possible to
  116. * simply "or" in the value in the control register.
  117. */
  118. #define DMA_MODE_MM (SET_DMA_TM(TM_S_MM)) /* memory to memory */
  119. /* Device-paced memory to memory, */
  120. /* device is at source address */
  121. #define DMA_MODE_MM_DEVATSRC (DMA_TD | SET_DMA_TM(TM_D_MM))
  122. /* Device-paced memory to memory, */
  123. /* device is at destination address */
  124. #define DMA_MODE_MM_DEVATDST (SET_DMA_TM(TM_D_MM))
  125. /* 405gp/440gp */
  126. #define SET_DMA_PREFETCH(x) (((x)&0x3)<<(4-DMA_CR_OFFSET)) /* Memory Read Prefetch */
  127. #define DMA_PREFETCH_MASK SET_DMA_PREFETCH(3)
  128. #define PREFETCH_1 0 /* Prefetch 1 Double Word */
  129. #define PREFETCH_2 1
  130. #define PREFETCH_4 2
  131. #define GET_DMA_PREFETCH(x) (((x)&DMA_PREFETCH_MASK)>>(4-DMA_CR_OFFSET))
  132. #define DMA_PCE (1<<(3-DMA_CR_OFFSET)) /* Parity Check Enable */
  133. #define SET_DMA_PCE(x) (((x)&0x1)<<(3-DMA_CR_OFFSET))
  134. #define GET_DMA_PCE(x) (((x)&DMA_PCE)>>(3-DMA_CR_OFFSET))
  135. /* stb3x */
  136. #define DMA_ECE_ENABLE (1<<5)
  137. #define SET_DMA_ECE(x) (((x)&0x1)<<5)
  138. #define GET_DMA_ECE(x) (((x)&DMA_ECE_ENABLE)>>5)
  139. #define DMA_TCD_DISABLE (1<<4)
  140. #define SET_DMA_TCD(x) (((x)&0x1)<<4)
  141. #define GET_DMA_TCD(x) (((x)&DMA_TCD_DISABLE)>>4)
  142. typedef uint32_t sgl_handle_t;
  143. #ifdef CONFIG_PPC4xx_EDMA
  144. #define SGL_LIST_SIZE 4096
  145. #define DMA_PPC4xx_SIZE SGL_LIST_SIZE
  146. #define SET_DMA_PRIORITY(x) (((x)&0x3)<<(6-DMA_CR_OFFSET)) /* DMA Channel Priority */
  147. #define DMA_PRIORITY_MASK SET_DMA_PRIORITY(3)
  148. #define PRIORITY_LOW 0
  149. #define PRIORITY_MID_LOW 1
  150. #define PRIORITY_MID_HIGH 2
  151. #define PRIORITY_HIGH 3
  152. #define GET_DMA_PRIORITY(x) (((x)&DMA_PRIORITY_MASK)>>(6-DMA_CR_OFFSET))
  153. /*
  154. * DMA Polarity Configuration Register
  155. */
  156. #define DMAReq_ActiveLow(chan) (1<<(31-(chan*3)))
  157. #define DMAAck_ActiveLow(chan) (1<<(30-(chan*3)))
  158. #define EOT_ActiveLow(chan) (1<<(29-(chan*3))) /* End of Transfer */
  159. /*
  160. * DMA Sleep Mode Register
  161. */
  162. #define SLEEP_MODE_ENABLE (1<<21)
  163. /*
  164. * DMA Status Register
  165. */
  166. #define DMA_CS0 (1<<31) /* Terminal Count has been reached */
  167. #define DMA_CS1 (1<<30)
  168. #define DMA_CS2 (1<<29)
  169. #define DMA_CS3 (1<<28)
  170. #define DMA_TS0 (1<<27) /* End of Transfer has been requested */
  171. #define DMA_TS1 (1<<26)
  172. #define DMA_TS2 (1<<25)
  173. #define DMA_TS3 (1<<24)
  174. #define DMA_CH0_ERR (1<<23) /* DMA Chanel 0 Error */
  175. #define DMA_CH1_ERR (1<<22)
  176. #define DMA_CH2_ERR (1<<21)
  177. #define DMA_CH3_ERR (1<<20)
  178. #define DMA_IN_DMA_REQ0 (1<<19) /* Internal DMA Request is pending */
  179. #define DMA_IN_DMA_REQ1 (1<<18)
  180. #define DMA_IN_DMA_REQ2 (1<<17)
  181. #define DMA_IN_DMA_REQ3 (1<<16)
  182. #define DMA_EXT_DMA_REQ0 (1<<15) /* External DMA Request is pending */
  183. #define DMA_EXT_DMA_REQ1 (1<<14)
  184. #define DMA_EXT_DMA_REQ2 (1<<13)
  185. #define DMA_EXT_DMA_REQ3 (1<<12)
  186. #define DMA_CH0_BUSY (1<<11) /* DMA Channel 0 Busy */
  187. #define DMA_CH1_BUSY (1<<10)
  188. #define DMA_CH2_BUSY (1<<9)
  189. #define DMA_CH3_BUSY (1<<8)
  190. #define DMA_SG0 (1<<7) /* DMA Channel 0 Scatter/Gather in progress */
  191. #define DMA_SG1 (1<<6)
  192. #define DMA_SG2 (1<<5)
  193. #define DMA_SG3 (1<<4)
  194. /* DMA Channel Count Register */
  195. #define DMA_CTC_BTEN (1<<23) /* Burst Enable/Disable bit */
  196. #define DMA_CTC_BSIZ_MSK (3<<21) /* Mask of the Burst size bits */
  197. #define DMA_CTC_BSIZ_2 (0)
  198. #define DMA_CTC_BSIZ_4 (1<<21)
  199. #define DMA_CTC_BSIZ_8 (2<<21)
  200. #define DMA_CTC_BSIZ_16 (3<<21)
  201. /*
  202. * DMA SG Command Register
  203. */
  204. #define SSG_ENABLE(chan) (1<<(31-chan)) /* Start Scatter Gather */
  205. #define SSG_MASK_ENABLE(chan) (1<<(15-chan)) /* Enable writing to SSG0 bit */
  206. /*
  207. * DMA Scatter/Gather Descriptor Bit fields
  208. */
  209. #define SG_LINK (1<<31) /* Link */
  210. #define SG_TCI_ENABLE (1<<29) /* Enable Terminal Count Interrupt */
  211. #define SG_ETI_ENABLE (1<<28) /* Enable End of Transfer Interrupt */
  212. #define SG_ERI_ENABLE (1<<27) /* Enable Error Interrupt */
  213. #define SG_COUNT_MASK 0xFFFF /* Count Field */
  214. #define SET_DMA_CONTROL \
  215. (SET_DMA_CIE_ENABLE(p_init->int_enable) | /* interrupt enable */ \
  216. SET_DMA_BEN(p_init->buffer_enable) | /* buffer enable */\
  217. SET_DMA_ETD(p_init->etd_output) | /* end of transfer pin */ \
  218. SET_DMA_TCE(p_init->tce_enable) | /* terminal count enable */ \
  219. SET_DMA_PL(p_init->pl) | /* peripheral location */ \
  220. SET_DMA_DAI(p_init->dai) | /* dest addr increment */ \
  221. SET_DMA_SAI(p_init->sai) | /* src addr increment */ \
  222. SET_DMA_PRIORITY(p_init->cp) | /* channel priority */ \
  223. SET_DMA_PW(p_init->pwidth) | /* peripheral/bus width */ \
  224. SET_DMA_PSC(p_init->psc) | /* peripheral setup cycles */ \
  225. SET_DMA_PWC(p_init->pwc) | /* peripheral wait cycles */ \
  226. SET_DMA_PHC(p_init->phc) | /* peripheral hold cycles */ \
  227. SET_DMA_PREFETCH(p_init->pf) /* read prefetch */)
  228. #define GET_DMA_POLARITY(chan) (DMAReq_ActiveLow(chan) | DMAAck_ActiveLow(chan) | EOT_ActiveLow(chan))
  229. #elif defined(CONFIG_STB03xxx) /* stb03xxx */
  230. #define DMA_PPC4xx_SIZE 4096
  231. /*
  232. * DMA Status Register
  233. */
  234. #define SET_DMA_PRIORITY(x) (((x)&0x00800001)) /* DMA Channel Priority */
  235. #define DMA_PRIORITY_MASK 0x00800001
  236. #define PRIORITY_LOW 0x00000000
  237. #define PRIORITY_MID_LOW 0x00000001
  238. #define PRIORITY_MID_HIGH 0x00800000
  239. #define PRIORITY_HIGH 0x00800001
  240. #define GET_DMA_PRIORITY(x) (((((x)&DMA_PRIORITY_MASK) &0x00800000) >> 22 ) | (((x)&DMA_PRIORITY_MASK) &0x00000001))
  241. #define DMA_CS0 (1<<31) /* Terminal Count has been reached */
  242. #define DMA_CS1 (1<<30)
  243. #define DMA_CS2 (1<<29)
  244. #define DMA_CS3 (1<<28)
  245. #define DMA_TS0 (1<<27) /* End of Transfer has been requested */
  246. #define DMA_TS1 (1<<26)
  247. #define DMA_TS2 (1<<25)
  248. #define DMA_TS3 (1<<24)
  249. #define DMA_CH0_ERR (1<<23) /* DMA Chanel 0 Error */
  250. #define DMA_CH1_ERR (1<<22)
  251. #define DMA_CH2_ERR (1<<21)
  252. #define DMA_CH3_ERR (1<<20)
  253. #define DMA_CT0 (1<<19) /* Chained transfere */
  254. #define DMA_IN_DMA_REQ0 (1<<18) /* Internal DMA Request is pending */
  255. #define DMA_IN_DMA_REQ1 (1<<17)
  256. #define DMA_IN_DMA_REQ2 (1<<16)
  257. #define DMA_IN_DMA_REQ3 (1<<15)
  258. #define DMA_EXT_DMA_REQ0 (1<<14) /* External DMA Request is pending */
  259. #define DMA_EXT_DMA_REQ1 (1<<13)
  260. #define DMA_EXT_DMA_REQ2 (1<<12)
  261. #define DMA_EXT_DMA_REQ3 (1<<11)
  262. #define DMA_CH0_BUSY (1<<10) /* DMA Channel 0 Busy */
  263. #define DMA_CH1_BUSY (1<<9)
  264. #define DMA_CH2_BUSY (1<<8)
  265. #define DMA_CH3_BUSY (1<<7)
  266. #define DMA_CT1 (1<<6) /* Chained transfere */
  267. #define DMA_CT2 (1<<5)
  268. #define DMA_CT3 (1<<4)
  269. #define DMA_CH_ENABLE (1<<7)
  270. #define SET_DMA_CH(x) (((x)&0x1)<<7)
  271. #define GET_DMA_CH(x) (((x)&DMA_CH_ENABLE)>>7)
  272. /* STBx25xxx dma unique */
  273. /* enable device port on a dma channel
  274. * example ext 0 on dma 1
  275. */
  276. #define SSP0_RECV 15
  277. #define SSP0_XMIT 14
  278. #define EXT_DMA_0 12
  279. #define SC1_XMIT 11
  280. #define SC1_RECV 10
  281. #define EXT_DMA_2 9
  282. #define EXT_DMA_3 8
  283. #define SERIAL2_XMIT 7
  284. #define SERIAL2_RECV 6
  285. #define SC0_XMIT 5
  286. #define SC0_RECV 4
  287. #define SERIAL1_XMIT 3
  288. #define SERIAL1_RECV 2
  289. #define SERIAL0_XMIT 1
  290. #define SERIAL0_RECV 0
  291. #define DMA_CHAN_0 1
  292. #define DMA_CHAN_1 2
  293. #define DMA_CHAN_2 3
  294. #define DMA_CHAN_3 4
  295. /* end STBx25xx */
  296. /*
  297. * Bit 30 must be one for Redwoods, otherwise transfers may receive errors.
  298. */
  299. #define DMA_CR_MB0 0x2
  300. #define SET_DMA_CONTROL \
  301. (SET_DMA_CIE_ENABLE(p_init->int_enable) | /* interrupt enable */ \
  302. SET_DMA_ETD(p_init->etd_output) | /* end of transfer pin */ \
  303. SET_DMA_TCE(p_init->tce_enable) | /* terminal count enable */ \
  304. SET_DMA_PL(p_init->pl) | /* peripheral location */ \
  305. SET_DMA_DAI(p_init->dai) | /* dest addr increment */ \
  306. SET_DMA_SAI(p_init->sai) | /* src addr increment */ \
  307. SET_DMA_PRIORITY(p_init->cp) | /* channel priority */ \
  308. SET_DMA_PW(p_init->pwidth) | /* peripheral/bus width */ \
  309. SET_DMA_PSC(p_init->psc) | /* peripheral setup cycles */ \
  310. SET_DMA_PWC(p_init->pwc) | /* peripheral wait cycles */ \
  311. SET_DMA_PHC(p_init->phc) | /* peripheral hold cycles */ \
  312. SET_DMA_TCD(p_init->tcd_disable) | /* TC chain mode disable */ \
  313. SET_DMA_ECE(p_init->ece_enable) | /* ECE chanin mode enable */ \
  314. SET_DMA_CH(p_init->ch_enable) | /* Chain enable */ \
  315. DMA_CR_MB0 /* must be one */)
  316. #define GET_DMA_POLARITY(chan) chan
  317. #endif
  318. typedef struct {
  319. unsigned short in_use; /* set when channel is being used, clr when
  320. * available.
  321. */
  322. /*
  323. * Valid polarity settings:
  324. * DMAReq_ActiveLow(n)
  325. * DMAAck_ActiveLow(n)
  326. * EOT_ActiveLow(n)
  327. *
  328. * n is 0 to max dma chans
  329. */
  330. unsigned int polarity;
  331. char buffer_enable; /* Boolean: buffer enable */
  332. char tce_enable; /* Boolean: terminal count enable */
  333. char etd_output; /* Boolean: eot pin is a tc output */
  334. char pce; /* Boolean: parity check enable */
  335. /*
  336. * Peripheral location:
  337. * INTERNAL_PERIPHERAL (UART0 on the 405GP)
  338. * EXTERNAL_PERIPHERAL
  339. */
  340. char pl; /* internal/external peripheral */
  341. /*
  342. * Valid pwidth settings:
  343. * PW_8
  344. * PW_16
  345. * PW_32
  346. * PW_64
  347. */
  348. unsigned int pwidth;
  349. char dai; /* Boolean: dst address increment */
  350. char sai; /* Boolean: src address increment */
  351. /*
  352. * Valid psc settings: 0-3
  353. */
  354. unsigned int psc; /* Peripheral Setup Cycles */
  355. /*
  356. * Valid pwc settings:
  357. * 0-63
  358. */
  359. unsigned int pwc; /* Peripheral Wait Cycles */
  360. /*
  361. * Valid phc settings:
  362. * 0-7
  363. */
  364. unsigned int phc; /* Peripheral Hold Cycles */
  365. /*
  366. * Valid cp (channel priority) settings:
  367. * PRIORITY_LOW
  368. * PRIORITY_MID_LOW
  369. * PRIORITY_MID_HIGH
  370. * PRIORITY_HIGH
  371. */
  372. unsigned int cp; /* channel priority */
  373. /*
  374. * Valid pf (memory read prefetch) settings:
  375. *
  376. * PREFETCH_1
  377. * PREFETCH_2
  378. * PREFETCH_4
  379. */
  380. unsigned int pf; /* memory read prefetch */
  381. /*
  382. * Boolean: channel interrupt enable
  383. * NOTE: for sgl transfers, only the last descriptor will be setup to
  384. * interrupt.
  385. */
  386. char int_enable;
  387. char shift; /* easy access to byte_count shift, based on */
  388. /* the width of the channel */
  389. uint32_t control; /* channel control word */
  390. /* These variabled are used ONLY in single dma transfers */
  391. unsigned int mode; /* transfer mode */
  392. phys_addr_t addr;
  393. char ce; /* channel enable */
  394. #ifdef CONFIG_STB03xxx
  395. char ch_enable;
  396. char tcd_disable;
  397. char ece_enable;
  398. char td; /* transfer direction */
  399. #endif
  400. char int_on_final_sg;/* for scatter/gather - only interrupt on last sg */
  401. } ppc_dma_ch_t;
  402. /*
  403. * PPC44x DMA implementations have a slightly different
  404. * descriptor layout. Probably moved about due to the
  405. * change to 64-bit addresses and link pointer. I don't
  406. * know why they didn't just leave control_count after
  407. * the dst_addr.
  408. */
  409. #ifdef PPC4xx_DMA_64BIT
  410. typedef struct {
  411. uint32_t control;
  412. uint32_t control_count;
  413. phys_addr_t src_addr;
  414. phys_addr_t dst_addr;
  415. phys_addr_t next;
  416. } ppc_sgl_t;
  417. #else
  418. typedef struct {
  419. uint32_t control;
  420. phys_addr_t src_addr;
  421. phys_addr_t dst_addr;
  422. uint32_t control_count;
  423. uint32_t next;
  424. } ppc_sgl_t;
  425. #endif
  426. typedef struct {
  427. unsigned int dmanr;
  428. uint32_t control; /* channel ctrl word; loaded from each descrptr */
  429. uint32_t sgl_control; /* LK, TCI, ETI, and ERI bits in sgl descriptor */
  430. dma_addr_t dma_addr; /* dma (physical) address of this list */
  431. ppc_sgl_t *phead;
  432. dma_addr_t phead_dma;
  433. ppc_sgl_t *ptail;
  434. dma_addr_t ptail_dma;
  435. } sgl_list_info_t;
  436. typedef struct {
  437. phys_addr_t *src_addr;
  438. phys_addr_t *dst_addr;
  439. phys_addr_t dma_src_addr;
  440. phys_addr_t dma_dst_addr;
  441. } pci_alloc_desc_t;
  442. extern ppc_dma_ch_t dma_channels[];
  443. /*
  444. * The DMA API are in ppc4xx_dma.c and ppc4xx_sgdma.c
  445. */
  446. extern int ppc4xx_init_dma_channel(unsigned int, ppc_dma_ch_t *);
  447. extern int ppc4xx_get_channel_config(unsigned int, ppc_dma_ch_t *);
  448. extern int ppc4xx_set_channel_priority(unsigned int, unsigned int);
  449. extern unsigned int ppc4xx_get_peripheral_width(unsigned int);
  450. extern void ppc4xx_set_sg_addr(int, phys_addr_t);
  451. extern int ppc4xx_add_dma_sgl(sgl_handle_t, phys_addr_t, phys_addr_t, unsigned int);
  452. extern void ppc4xx_enable_dma_sgl(sgl_handle_t);
  453. extern void ppc4xx_disable_dma_sgl(sgl_handle_t);
  454. extern int ppc4xx_get_dma_sgl_residue(sgl_handle_t, phys_addr_t *, phys_addr_t *);
  455. extern int ppc4xx_delete_dma_sgl_element(sgl_handle_t, phys_addr_t *, phys_addr_t *);
  456. extern int ppc4xx_alloc_dma_handle(sgl_handle_t *, unsigned int, unsigned int);
  457. extern void ppc4xx_free_dma_handle(sgl_handle_t);
  458. extern int ppc4xx_get_dma_status(void);
  459. extern int ppc4xx_enable_burst(unsigned int);
  460. extern int ppc4xx_disable_burst(unsigned int);
  461. extern int ppc4xx_set_burst_size(unsigned int, unsigned int);
  462. extern void ppc4xx_set_src_addr(int dmanr, phys_addr_t src_addr);
  463. extern void ppc4xx_set_dst_addr(int dmanr, phys_addr_t dst_addr);
  464. extern void ppc4xx_enable_dma(unsigned int dmanr);
  465. extern void ppc4xx_disable_dma(unsigned int dmanr);
  466. extern void ppc4xx_set_dma_count(unsigned int dmanr, unsigned int count);
  467. extern int ppc4xx_get_dma_residue(unsigned int dmanr);
  468. extern void ppc4xx_set_dma_addr2(unsigned int dmanr, phys_addr_t src_dma_addr,
  469. phys_addr_t dst_dma_addr);
  470. extern int ppc4xx_enable_dma_interrupt(unsigned int dmanr);
  471. extern int ppc4xx_disable_dma_interrupt(unsigned int dmanr);
  472. extern int ppc4xx_clr_dma_status(unsigned int dmanr);
  473. extern int ppc4xx_map_dma_port(unsigned int dmanr, unsigned int ocp_dma,short dma_chan);
  474. extern int ppc4xx_disable_dma_port(unsigned int dmanr, unsigned int ocp_dma,short dma_chan);
  475. extern int ppc4xx_set_dma_mode(unsigned int dmanr, unsigned int mode);
  476. /* These are in kernel/dma.c: */
  477. /* reserve a DMA channel */
  478. extern int request_dma(unsigned int dmanr, const char *device_id);
  479. /* release it again */
  480. extern void free_dma(unsigned int dmanr);
  481. #endif
  482. #endif /* __KERNEL__ */