ppc4xx_dma.h 19 KB

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