epi.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. //*****************************************************************************
  2. //
  3. // epi.h - Prototypes and macros for the EPI module.
  4. //
  5. // Copyright (c) 2008-2017 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its contributors may be used to endorse or promote products derived
  22. // from this software without specific prior written permission.
  23. //
  24. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //*****************************************************************************
  37. #ifndef __DRIVERLIB_EPI_H__
  38. #define __DRIVERLIB_EPI_H__
  39. #include <stdint.h>
  40. #include <stdbool.h>
  41. //*****************************************************************************
  42. //
  43. // If building with a C++ compiler, make all of the definitions in this header
  44. // have a C binding.
  45. //
  46. //*****************************************************************************
  47. #ifdef __cplusplus
  48. extern "C"
  49. {
  50. #endif
  51. //*****************************************************************************
  52. //
  53. // Values that can be passed to EPIModeSet()
  54. //
  55. //*****************************************************************************
  56. #define EPI_MODE_GENERAL 0x00000010
  57. #define EPI_MODE_SDRAM 0x00000011
  58. #define EPI_MODE_HB8 0x00000012
  59. #define EPI_MODE_HB16 0x00000013
  60. #define EPI_MODE_DISABLE 0x00000000
  61. //*****************************************************************************
  62. //
  63. // Values that can be passed to EPIConfigSDRAMSet()
  64. //
  65. //*****************************************************************************
  66. #define EPI_SDRAM_CORE_FREQ_0_15 \
  67. 0x00000000
  68. #define EPI_SDRAM_CORE_FREQ_15_30 \
  69. 0x40000000
  70. #define EPI_SDRAM_CORE_FREQ_30_50 \
  71. 0x80000000
  72. #define EPI_SDRAM_CORE_FREQ_50_100 \
  73. 0xC0000000
  74. #define EPI_SDRAM_LOW_POWER 0x00000200
  75. #define EPI_SDRAM_FULL_POWER 0x00000000
  76. #define EPI_SDRAM_SIZE_64MBIT 0x00000000
  77. #define EPI_SDRAM_SIZE_128MBIT 0x00000001
  78. #define EPI_SDRAM_SIZE_256MBIT 0x00000002
  79. #define EPI_SDRAM_SIZE_512MBIT 0x00000003
  80. //*****************************************************************************
  81. //
  82. // Values that can be passed to EPIConfigGPModeSet()
  83. //
  84. //*****************************************************************************
  85. #define EPI_GPMODE_CLKPIN 0x80000000
  86. #define EPI_GPMODE_CLKGATE 0x40000000
  87. #define EPI_GPMODE_FRAME50 0x04000000
  88. #define EPI_GPMODE_WRITE2CYCLE 0x00080000
  89. #define EPI_GPMODE_ASIZE_NONE 0x00000000
  90. #define EPI_GPMODE_ASIZE_4 0x00000010
  91. #define EPI_GPMODE_ASIZE_12 0x00000020
  92. #define EPI_GPMODE_ASIZE_20 0x00000030
  93. #define EPI_GPMODE_DSIZE_8 0x00000000
  94. #define EPI_GPMODE_DSIZE_16 0x00000001
  95. #define EPI_GPMODE_DSIZE_24 0x00000002
  96. #define EPI_GPMODE_DSIZE_32 0x00000003
  97. //*****************************************************************************
  98. //
  99. // Values that can be passed to EPIConfigHB8ModeSet()
  100. //
  101. //*****************************************************************************
  102. #define EPI_HB8_USE_TXEMPTY 0x00800000
  103. #define EPI_HB8_USE_RXFULL 0x00400000
  104. #define EPI_HB8_WRHIGH 0x00200000
  105. #define EPI_HB8_RDHIGH 0x00100000
  106. #define EPI_HB8_ALE_HIGH 0x00080000
  107. #define EPI_HB8_ALE_LOW 0x00000000
  108. #define EPI_HB8_WRWAIT_0 0x00000000
  109. #define EPI_HB8_WRWAIT_1 0x00000040
  110. #define EPI_HB8_WRWAIT_2 0x00000080
  111. #define EPI_HB8_WRWAIT_3 0x000000C0
  112. #define EPI_HB8_RDWAIT_0 0x00000000
  113. #define EPI_HB8_RDWAIT_1 0x00000010
  114. #define EPI_HB8_RDWAIT_2 0x00000020
  115. #define EPI_HB8_RDWAIT_3 0x00000030
  116. #define EPI_HB8_MODE_ADMUX 0x00000000
  117. #define EPI_HB8_MODE_ADDEMUX 0x00000001
  118. #define EPI_HB8_MODE_SRAM 0x00000002
  119. #define EPI_HB8_MODE_FIFO 0x00000003
  120. #define EPI_HB8_CSCFG_ALE 0x00000000
  121. #define EPI_HB8_CSCFG_CS 0x00000200
  122. #define EPI_HB8_CSCFG_DUAL_CS 0x00000400
  123. #define EPI_HB8_CSCFG_ALE_DUAL_CS \
  124. 0x00000600
  125. #define EPI_HB8_CSCFG_ALE_SINGLE_CS \
  126. 0x00001000
  127. #define EPI_HB8_CSCFG_QUAD_CS 0x00001200
  128. #define EPI_HB8_CSCFG_ALE_QUAD_CS \
  129. 0x00001400
  130. #define EPI_HB8_CSBAUD 0x00000800
  131. #define EPI_HB8_CLOCK_GATE 0x80000000
  132. #define EPI_HB8_CLOCK_GATE_IDLE \
  133. 0x40000000
  134. #define EPI_HB8_CLOCK_INVERT 0x20000000
  135. #define EPI_HB8_IN_READY_EN 0x10000000
  136. #define EPI_HB8_IN_READY_EN_INVERT \
  137. 0x18000000
  138. #define EPI_HB8_CSCFG_MASK 0x00001600
  139. //*****************************************************************************
  140. //
  141. // Values that can be passed to EPIConfigHB16ModeSet()
  142. //
  143. //*****************************************************************************
  144. #define EPI_HB16_USE_TXEMPTY 0x00800000
  145. #define EPI_HB16_USE_RXFULL 0x00400000
  146. #define EPI_HB16_WRHIGH 0x00200000
  147. #define EPI_HB16_RDHIGH 0x00100000
  148. #define EPI_HB16_WRWAIT_0 0x00000000
  149. #define EPI_HB16_WRWAIT_1 0x00000040
  150. #define EPI_HB16_WRWAIT_2 0x00000080
  151. #define EPI_HB16_WRWAIT_3 0x000000C0
  152. #define EPI_HB16_RDWAIT_0 0x00000000
  153. #define EPI_HB16_RDWAIT_1 0x00000010
  154. #define EPI_HB16_RDWAIT_2 0x00000020
  155. #define EPI_HB16_RDWAIT_3 0x00000030
  156. #define EPI_HB16_MODE_ADMUX 0x00000000
  157. #define EPI_HB16_MODE_ADDEMUX 0x00000001
  158. #define EPI_HB16_MODE_SRAM 0x00000002
  159. #define EPI_HB16_MODE_FIFO 0x00000003
  160. #define EPI_HB16_BSEL 0x00000004
  161. #define EPI_HB16_CSCFG_ALE 0x00000000
  162. #define EPI_HB16_CSCFG_CS 0x00000200
  163. #define EPI_HB16_CSCFG_DUAL_CS 0x00000400
  164. #define EPI_HB16_CSCFG_ALE_DUAL_CS \
  165. 0x00000600
  166. #define EPI_HB16_CSCFG_ALE_SINGLE_CS \
  167. 0x00001000
  168. #define EPI_HB16_CSCFG_QUAD_CS 0x00001200
  169. #define EPI_HB16_CSCFG_ALE_QUAD_CS \
  170. 0x00001400
  171. #define EPI_HB16_CLOCK_GATE 0x80000000
  172. #define EPI_HB16_CLOCK_GATE_IDLE \
  173. 0x40000000
  174. #define EPI_HB16_CLOCK_INVERT 0x20000000
  175. #define EPI_HB16_IN_READY_EN 0x10000000
  176. #define EPI_HB16_IN_READY_EN_INVERTED \
  177. 0x18000000
  178. #define EPI_HB16_ALE_HIGH 0x00080000
  179. #define EPI_HB16_ALE_LOW 0x00000000
  180. #define EPI_HB16_BURST_TRAFFIC 0x00010000
  181. #define EPI_HB16_CSBAUD 0x00000800
  182. #define EPI_HB16_CSCFG_MASK 0x00001600
  183. //*****************************************************************************
  184. //
  185. // Values that can be passed to EPIConfigHB8TimingSet().
  186. //
  187. //*****************************************************************************
  188. #define EPI_HB8_IN_READY_DELAY_1 \
  189. 0x01000000
  190. #define EPI_HB8_IN_READY_DELAY_2 \
  191. 0x02000000
  192. #define EPI_HB8_IN_READY_DELAY_3 \
  193. 0x03000000
  194. #define EPI_HB8_CAP_WIDTH_1 0x00001000
  195. #define EPI_HB8_CAP_WIDTH_2 0x00002000
  196. #define EPI_HB8_WRWAIT_MINUS_DISABLE \
  197. 0x00000000
  198. #define EPI_HB8_WRWAIT_MINUS_ENABLE \
  199. 0x00000010
  200. #define EPI_HB8_RDWAIT_MINUS_DISABLE \
  201. 0x00000000
  202. #define EPI_HB8_RDWAIT_MINUS_ENABLE \
  203. 0x00000001
  204. //*****************************************************************************
  205. //
  206. // Values that can be passed to EPIConfigHB16TimingSet().
  207. //
  208. //*****************************************************************************
  209. #define EPI_HB16_IN_READY_DELAY_1 \
  210. 0x01000000
  211. #define EPI_HB16_IN_READY_DELAY_2 \
  212. 0x02000000
  213. #define EPI_HB16_IN_READY_DELAY_3 \
  214. 0x03000000
  215. #define EPI_HB16_PSRAM_NO_LIMIT 0x00000000
  216. #define EPI_HB16_PSRAM_128 0x00010000
  217. #define EPI_HB16_PSRAM_256 0x00020000
  218. #define EPI_HB16_PSRAM_512 0x00030000
  219. #define EPI_HB16_PSRAM_1024 0x00040000
  220. #define EPI_HB16_PSRAM_2048 0x00050000
  221. #define EPI_HB16_PSRAM_4096 0x00060000
  222. #define EPI_HB16_PSRAM_8192 0x00070000
  223. #define EPI_HB16_CAP_WIDTH_1 0x00001000
  224. #define EPI_HB16_CAP_WIDTH_2 0x00002000
  225. #define EPI_HB16_WRWAIT_MINUS_DISABLE \
  226. 0x00000000
  227. #define EPI_HB16_WRWAIT_MINUS_ENABLE \
  228. 0x00000008
  229. #define EPI_HB16_RDWAIT_MINUS_DISABLE \
  230. 0x00000000
  231. #define EPI_HB16_RDWAIT_MINUS_ENABLE \
  232. 0x00000001
  233. //*****************************************************************************
  234. //
  235. // Values that can be passed to EPIAddressMapSet().
  236. //
  237. //*****************************************************************************
  238. #define EPI_ADDR_PER_SIZE_256B 0x00000000
  239. #define EPI_ADDR_PER_SIZE_64KB 0x00000040
  240. #define EPI_ADDR_PER_SIZE_16MB 0x00000080
  241. #define EPI_ADDR_PER_SIZE_256MB 0x000000C0
  242. #define EPI_ADDR_PER_BASE_NONE 0x00000000
  243. #define EPI_ADDR_PER_BASE_A 0x00000010
  244. #define EPI_ADDR_PER_BASE_C 0x00000020
  245. #define EPI_ADDR_RAM_SIZE_256B 0x00000000
  246. #define EPI_ADDR_RAM_SIZE_64KB 0x00000004
  247. #define EPI_ADDR_RAM_SIZE_16MB 0x00000008
  248. #define EPI_ADDR_RAM_SIZE_256MB 0x0000000C
  249. #define EPI_ADDR_RAM_BASE_NONE 0x00000000
  250. #define EPI_ADDR_RAM_BASE_6 0x00000001
  251. #define EPI_ADDR_RAM_BASE_8 0x00000002
  252. #define EPI_ADDR_QUAD_MODE 0x00000033
  253. #define EPI_ADDR_CODE_SIZE_256B 0x00000000
  254. #define EPI_ADDR_CODE_SIZE_64KB 0x00000400
  255. #define EPI_ADDR_CODE_SIZE_16MB 0x00000800
  256. #define EPI_ADDR_CODE_SIZE_256MB \
  257. 0x00000C00
  258. #define EPI_ADDR_CODE_BASE_NONE 0x00000000
  259. #define EPI_ADDR_CODE_BASE_1 0x00000100
  260. //*****************************************************************************
  261. //
  262. // Values that can be passed to EPINonBlockingReadConfigure()
  263. //
  264. //*****************************************************************************
  265. #define EPI_NBCONFIG_SIZE_8 1
  266. #define EPI_NBCONFIG_SIZE_16 2
  267. #define EPI_NBCONFIG_SIZE_32 3
  268. //*****************************************************************************
  269. //
  270. // Values that can be passed to EPIFIFOConfig()
  271. //
  272. //*****************************************************************************
  273. #define EPI_FIFO_CONFIG_WTFULLERR \
  274. 0x00020000
  275. #define EPI_FIFO_CONFIG_RSTALLERR \
  276. 0x00010000
  277. #define EPI_FIFO_CONFIG_TX_EMPTY \
  278. 0x00000000
  279. #define EPI_FIFO_CONFIG_TX_1_4 0x00000020
  280. #define EPI_FIFO_CONFIG_TX_1_2 0x00000030
  281. #define EPI_FIFO_CONFIG_TX_3_4 0x00000040
  282. #define EPI_FIFO_CONFIG_RX_1_8 0x00000001
  283. #define EPI_FIFO_CONFIG_RX_1_4 0x00000002
  284. #define EPI_FIFO_CONFIG_RX_1_2 0x00000003
  285. #define EPI_FIFO_CONFIG_RX_3_4 0x00000004
  286. #define EPI_FIFO_CONFIG_RX_7_8 0x00000005
  287. #define EPI_FIFO_CONFIG_RX_FULL 0x00000006
  288. //*****************************************************************************
  289. //
  290. // Values that can be passed to EPIIntEnable(), EPIIntDisable(), or returned
  291. // as flags from EPIIntStatus()
  292. //
  293. //*****************************************************************************
  294. #define EPI_INT_DMA_TX_DONE 0x00000010
  295. #define EPI_INT_DMA_RX_DONE 0x00000008
  296. #define EPI_INT_TXREQ 0x00000004
  297. #define EPI_INT_RXREQ 0x00000002
  298. #define EPI_INT_ERR 0x00000001
  299. //*****************************************************************************
  300. //
  301. // Values that can be passed to EPIIntErrorClear(), or returned as flags from
  302. // EPIIntErrorStatus()
  303. //
  304. //*****************************************************************************
  305. #define EPI_INT_ERR_DMAWRIC 0x00000010
  306. #define EPI_INT_ERR_DMARDIC 0x00000008
  307. #define EPI_INT_ERR_WTFULL 0x00000004
  308. #define EPI_INT_ERR_RSTALL 0x00000002
  309. #define EPI_INT_ERR_TIMEOUT 0x00000001
  310. #ifdef rvmdk
  311. //*****************************************************************************
  312. //
  313. // Keil case.
  314. //
  315. //*****************************************************************************
  316. inline void
  317. EPIWorkaroundWordWrite(uint32_t *pui32Addr, uint32_t ui32Value)
  318. {
  319. uint32_t ui32Scratch;
  320. __asm
  321. {
  322. //
  323. // Add a NOP to ensure we don�t have a flash read immediately before
  324. // the EPI read.
  325. //
  326. NOP
  327. //
  328. // Perform the write we're actually interested in.
  329. //
  330. STR ui32Value, [pui32Addr]
  331. //
  332. // Read from SRAM to ensure that we don't have an EPI write followed by
  333. // a flash read.
  334. //
  335. LDR ui32Scratch, [__current_sp()]
  336. }
  337. }
  338. inline uint32_t
  339. EPIWorkaroundWordRead(uint32_t *pui32Addr)
  340. {
  341. uint32_t ui32Value, ui32Scratch;
  342. __asm
  343. {
  344. //
  345. // Add a NOP to ensure we don�t have a flash read immediately before
  346. // the EPI read.
  347. //
  348. NOP
  349. //
  350. // Perform the read we're actually interested in.
  351. //
  352. LDR ui32Value, [pui32Addr]
  353. //
  354. // Read from SRAM to ensure that we don't have an EPI read followed by
  355. // a flash read.
  356. //
  357. LDR ui32Scratch, [__current_sp()]
  358. }
  359. return (ui32Value);
  360. }
  361. inline void
  362. EPIWorkaroundHWordWrite(uint16_t *pui16Addr, uint16_t ui16Value)
  363. {
  364. uint32_t ui32Scratch;
  365. __asm
  366. {
  367. //
  368. // Add a NOP to ensure we don�t have a flash read immediately before
  369. // the EPI read.
  370. //
  371. NOP
  372. //
  373. // Perform the write we're actually interested in.
  374. //
  375. STRH ui16Value, [pui16Addr]
  376. //
  377. // Read from SRAM to ensure that we don't have an EPI write followed by
  378. // a flash read.
  379. //
  380. LDR ui32Scratch, [__current_sp()]
  381. }
  382. }
  383. inline uint16_t
  384. EPIWorkaroundHWordRead(uint16_t *pui16Addr)
  385. {
  386. uint32_t ui32Scratch;
  387. uint16_t ui16Value;
  388. __asm
  389. {
  390. //
  391. // Add a NOP to ensure we don�t have a flash read immediately before
  392. // the EPI read.
  393. //
  394. NOP
  395. //
  396. // Perform the read we're actually interested in.
  397. //
  398. LDRH ui16Value, [pui16Addr]
  399. //
  400. // Read from SRAM to ensure that we don't have an EPI read followed by
  401. // a flash read.
  402. //
  403. LDR ui32Scratch, [__current_sp()]
  404. }
  405. return (ui16Value);
  406. }
  407. inline void
  408. EPIWorkaroundByteWrite(uint8_t *pui8Addr, uint8_t ui8Value)
  409. {
  410. uint32_t ui32Scratch;
  411. __asm
  412. {
  413. //
  414. // Add a NOP to ensure we don�t have a flash read immediately before
  415. // the EPI read.
  416. //
  417. NOP
  418. //
  419. // Perform the write we're actually interested in.
  420. //
  421. STRB ui8Value, [pui8Addr]
  422. //
  423. // Read from SRAM to ensure that we don't have an EPI write followed by
  424. // a flash read.
  425. //
  426. LDR ui32Scratch, [__current_sp()]
  427. }
  428. }
  429. inline uint8_t
  430. EPIWorkaroundByteRead(uint8_t *pui8Addr)
  431. {
  432. uint32_t ui32Scratch;
  433. uint8_t ui8Value;
  434. __asm
  435. {
  436. //
  437. // Add a NOP to ensure we don�t have a flash read immediately before
  438. // the EPI read.
  439. //
  440. NOP
  441. //
  442. // Perform the read we're actually interested in.
  443. //
  444. LDRB ui8Value, [pui8Addr]
  445. //
  446. // Read from SRAM to ensure that we don't have an EPI read followed by
  447. // a flash read.
  448. //
  449. LDR ui32Scratch, [__current_sp()]
  450. }
  451. return (ui8Value);
  452. }
  453. #endif
  454. #ifdef __TI_ARM__
  455. //*****************************************************************************
  456. //
  457. // Code Composer Studio versions of these functions can be found in separate
  458. // source file epi_workaround_ccs.s.
  459. //
  460. //*****************************************************************************
  461. extern void EPIWorkaroundWordWrite(uint32_t *pui32Addr, uint32_t ui32Value);
  462. extern uint32_t EPIWorkaroundWordRead(uint32_t *pui32Addr);
  463. extern void EPIWorkaroundHWordWrite(uint16_t *pui16Addr, uint16_t ui16Value);
  464. extern uint16_t EPIWorkaroundHWordRead(uint16_t *pui16Addr);
  465. extern void EPIWorkaroundByteWrite(uint8_t *pui8Addr, uint8_t ui8Value);
  466. extern uint8_t EPIWorkaroundByteRead(uint8_t *pui8Addr);
  467. #endif
  468. #if (defined __GNUC__) || (defined __ICCARM__) || (defined sourcerygxx) || \
  469. (defined codered)
  470. //*****************************************************************************
  471. //
  472. // GCC-based toolchain and IAR case.
  473. //
  474. //*****************************************************************************
  475. inline void
  476. EPIWorkaroundWordWrite(uint32_t *pui32Addr, uint32_t ui32Value)
  477. {
  478. volatile register uint32_t ui32Scratch;
  479. __asm volatile(
  480. //
  481. // Add a NOP to ensure we don�t have a flash read immediately before
  482. // the EPI read.
  483. //
  484. " NOP\n"
  485. " STR %[value],[%[addr]]\n"
  486. " LDR %[scratch],[sp]\n"
  487. : [scratch] "=r"(ui32Scratch)
  488. : [addr] "r"(pui32Addr), [value] "r"(ui32Value)
  489. );
  490. //
  491. // Keep the compiler from generating a warning.
  492. //
  493. ui32Scratch = ui32Scratch;
  494. }
  495. inline uint32_t
  496. EPIWorkaroundWordRead(uint32_t *pui32Addr)
  497. {
  498. volatile register uint32_t ui32Data, ui32Scratch;
  499. //
  500. // ui32Scratch is not used other than to add a padding read following the
  501. // "real" read.
  502. //
  503. __asm volatile(
  504. //
  505. // Add a NOP to ensure we don�t have a flash read immediately before
  506. // the EPI read.
  507. //
  508. " NOP\n"
  509. " LDR %[ret],[%[addr]]\n"
  510. " LDR %[scratch],[sp]\n"
  511. : [ret] "=r"(ui32Data),
  512. [scratch] "=r"(ui32Scratch)
  513. : [addr] "r"(pui32Addr)
  514. );
  515. //
  516. // Keep the compiler from generating a warning.
  517. //
  518. ui32Scratch = ui32Scratch;
  519. return (ui32Data);
  520. }
  521. inline void
  522. EPIWorkaroundHWordWrite(uint16_t *pui16Addr, uint16_t ui16Value)
  523. {
  524. volatile register uint32_t ui32Scratch;
  525. __asm volatile(
  526. //
  527. // Add a NOP to ensure we don�t have a flash read immediately before
  528. // the EPI read.
  529. //
  530. " NOP\n"
  531. " STRH %[value],[%[addr]]\n"
  532. " LDR %[scratch],[sp]\n"
  533. : [scratch] "=r"(ui32Scratch)
  534. : [addr] "r"(pui16Addr), [value] "r"(ui16Value)
  535. );
  536. //
  537. // Keep the compiler from generating a warning.
  538. //
  539. ui32Scratch = ui32Scratch;
  540. }
  541. inline uint16_t
  542. EPIWorkaroundHWordRead(uint16_t *pui16Addr)
  543. {
  544. register uint16_t ui16Data;
  545. register uint32_t ui32Scratch;
  546. //
  547. // ui32Scratch is not used other than to add a padding read following the
  548. // "real" read.
  549. //
  550. __asm volatile(
  551. //
  552. // Add a NOP to ensure we don�t have a flash read immediately before
  553. // the EPI read.
  554. //
  555. " NOP\n"
  556. " LDRH %[ret],[%[addr]]\n"
  557. " LDR %[scratch],[sp]\n"
  558. : [ret] "=r"(ui16Data),
  559. [scratch] "=r"(ui32Scratch)
  560. : [addr] "r"(pui16Addr)
  561. );
  562. //
  563. // Keep the compiler from generating a warning.
  564. //
  565. ui32Scratch = ui32Scratch;
  566. return (ui16Data);
  567. }
  568. inline void
  569. EPIWorkaroundByteWrite(uint8_t *pui8Addr, uint8_t ui8Value)
  570. {
  571. volatile register uint32_t ui32Scratch;
  572. __asm volatile(
  573. //
  574. // Add a NOP to ensure we don�t have a flash read immediately before
  575. // the EPI read.
  576. //
  577. " NOP\n"
  578. " STRB %[value],[%[addr]]\n"
  579. " LDR %[scratch],[sp]\n"
  580. : [scratch] "=r"(ui32Scratch)
  581. : [addr] "r"(pui8Addr), [value] "r"(ui8Value)
  582. );
  583. //
  584. // Keep the compiler from generating a warning.
  585. //
  586. ui32Scratch = ui32Scratch;
  587. }
  588. inline uint8_t
  589. EPIWorkaroundByteRead(uint8_t *pui8Addr)
  590. {
  591. register uint8_t ui8Data;
  592. register uint32_t ui32Scratch;
  593. //
  594. // ui32Scratch is not used other than to add a padding read following the
  595. // "real" read.
  596. //
  597. __asm volatile(
  598. //
  599. // Add a NOP to ensure we don�t have a flash read immediately before
  600. // the EPI read.
  601. //
  602. " NOP\n"
  603. " LDRB %[ret],[%[addr]]\n"
  604. " LDR %[scratch],[sp]\n"
  605. : [ret] "=r"(ui8Data),
  606. [scratch] "=r"(ui32Scratch)
  607. : [addr] "r"(pui8Addr)
  608. );
  609. //
  610. // Keep the compiler from generating a warning.
  611. //
  612. ui32Scratch = ui32Scratch;
  613. return (ui8Data);
  614. }
  615. #endif
  616. //*****************************************************************************
  617. //
  618. // API Function prototypes
  619. //
  620. //*****************************************************************************
  621. extern void EPIModeSet(uint32_t ui32Base, uint32_t ui32Mode);
  622. extern void EPIDividerSet(uint32_t ui32Base, uint32_t ui32Divider);
  623. extern void EPIDividerCSSet(uint32_t ui32Base, uint32_t ui32CS,
  624. uint32_t ui32Divider);
  625. extern void EPIDMATxCount(uint32_t ui32Base, uint32_t ui32Count);
  626. extern void EPIConfigGPModeSet(uint32_t ui32Base, uint32_t ui32Config,
  627. uint32_t ui32FrameCount, uint32_t ui32MaxWait);
  628. extern void EPIConfigHB8Set(uint32_t ui32Base, uint32_t ui32Config,
  629. uint32_t ui32MaxWait);
  630. extern void EPIConfigHB16Set(uint32_t ui32Base, uint32_t ui32Config,
  631. uint32_t ui32MaxWait);
  632. extern void EPIConfigHB8CSSet(uint32_t ui32Base, uint32_t ui32CS,
  633. uint32_t ui32Config);
  634. extern void EPIConfigHB16CSSet(uint32_t ui32Base, uint32_t ui32CS,
  635. uint32_t ui32Config);
  636. extern void EPIConfigHB8TimingSet(uint32_t ui32Base, uint32_t ui32CS,
  637. uint32_t ui32Config);
  638. extern void EPIConfigHB16TimingSet(uint32_t ui32Base, uint32_t ui32CS,
  639. uint32_t ui32Config);
  640. extern void EPIPSRAMConfigRegSet(uint32_t ui32Base, uint32_t ui32CS,
  641. uint32_t ui32CR);
  642. extern void EPIPSRAMConfigRegRead(uint32_t ui32Base, uint32_t ui32CS);
  643. extern bool EPIPSRAMConfigRegGetNonBlocking(uint32_t ui32Base,
  644. uint32_t ui32CS,
  645. uint32_t *pui32CR);
  646. extern uint32_t EPIPSRAMConfigRegGet(uint32_t ui32Base, uint32_t ui32CS);
  647. extern void EPIConfigSDRAMSet(uint32_t ui32Base, uint32_t ui32Config,
  648. uint32_t ui32Refresh);
  649. extern void EPIAddressMapSet(uint32_t ui32Base, uint32_t ui32Map);
  650. extern void EPINonBlockingReadConfigure(uint32_t ui32Base,
  651. uint32_t ui32Channel,
  652. uint32_t ui32DataSize,
  653. uint32_t ui32Address);
  654. extern void EPINonBlockingReadStart(uint32_t ui32Base,
  655. uint32_t ui32Channel,
  656. uint32_t ui32Count);
  657. extern void EPINonBlockingReadStop(uint32_t ui32Base,
  658. uint32_t ui32Channel);
  659. extern uint32_t EPINonBlockingReadCount(uint32_t ui32Base,
  660. uint32_t ui32Channel);
  661. extern uint32_t EPINonBlockingReadAvail(uint32_t ui32Base);
  662. extern uint32_t EPINonBlockingReadGet32(uint32_t ui32Base,
  663. uint32_t ui32Count,
  664. uint32_t *pui32Buf);
  665. extern uint32_t EPINonBlockingReadGet16(uint32_t ui32Base,
  666. uint32_t ui32Count,
  667. uint16_t *pui16Buf);
  668. extern uint32_t EPINonBlockingReadGet8(uint32_t ui32Base,
  669. uint32_t ui32Count,
  670. uint8_t *pui8Buf);
  671. extern void EPIFIFOConfig(uint32_t ui32Base, uint32_t ui32Config);
  672. extern uint32_t EPIWriteFIFOCountGet(uint32_t ui32Base);
  673. extern void EPIIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags);
  674. extern void EPIIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags);
  675. extern uint32_t EPIIntStatus(uint32_t ui32Base, bool bMasked);
  676. extern uint32_t EPIIntErrorStatus(uint32_t ui32Base);
  677. extern void EPIIntErrorClear(uint32_t ui32Base, uint32_t ui32ErrFlags);
  678. extern void EPIIntRegister(uint32_t ui32Base, void (*pfnHandler)(void));
  679. extern void EPIIntUnregister(uint32_t ui32Base);
  680. //*****************************************************************************
  681. //
  682. // Mark the end of the C bindings section for C++ compilers.
  683. //
  684. //*****************************************************************************
  685. #ifdef __cplusplus
  686. }
  687. #endif
  688. #endif // __DRIVERLIB_EPI_H__