raster.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /**
  2. * \file raster.h
  3. *
  4. * \brief Definitions used for raster LCD
  5. *
  6. * This file contains the driver API prototypes and macro definitions.
  7. */
  8. /*
  9. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  10. */
  11. /*
  12. * Redistribution and use in source and binary forms, with or without
  13. * modification, are permitted provided that the following conditions
  14. * are met:
  15. *
  16. * Redistributions of source code must retain the above copyright
  17. * notice, this list of conditions and the following disclaimer.
  18. *
  19. * Redistributions in binary form must reproduce the above copyright
  20. * notice, this list of conditions and the following disclaimer in the
  21. * documentation and/or other materials provided with the
  22. * distribution.
  23. *
  24. * Neither the name of Texas Instruments Incorporated nor the names of
  25. * its contributors may be used to endorse or promote products derived
  26. * from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  29. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  30. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  31. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  32. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  33. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  34. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  35. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  36. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  38. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. */
  41. #ifndef _RASTER_H_
  42. #define _RASTER_H_
  43. #include "hw_lcdc.h"
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. /*******************************************************************************
  48. * MACRO DEFINITIONS
  49. *******************************************************************************/
  50. /*****************************************************************************/
  51. /*
  52. ** Values that can be passed to RasterModeConfig API as displayType to select
  53. ** type of display
  54. */
  55. /* Configure display type to TFT */
  56. #define RASTER_DISPLAY_MODE_TFT (1 << LCDC_RASTER_CTRL_TFT_STN_SHIFT)
  57. /* Configure display type to STN */
  58. #define RASTER_DISPLAY_MODE_STN 0
  59. /* Configure display type to TFT with 24 bit data packed mode */
  60. #define RASTER_DISPLAY_MODE_TFT_PACKED (1 << LCDC_RASTER_CTRL_TFT_STN_SHIFT)|\
  61. (1 << LCDC_RASTER_CTRL_TFT24_SHIFT)
  62. /* Configure display type to TFT with 24 bit data packed mode */
  63. #define RASTER_DISPLAY_MODE_TFT_UNPACKED (1 << LCDC_RASTER_CTRL_TFT_STN_SHIFT)|\
  64. (1 << LCDC_RASTER_CTRL_TFT24_SHIFT) |\
  65. (1 << LCDC_RASTER_CTRL_TFT24UNPACKED_SHIFT)
  66. /******************************************************************************/
  67. /*
  68. ** Values that can be passed to RasterModeConfig API as paletteMode to select
  69. ** mode of palette loading.
  70. */
  71. /* Both palette and data will be loaded */
  72. #define RASTER_PALETTE_DATA 0
  73. /* Only palette will be loaded */
  74. #define RASTER_PALETTE (1 << LCDC_RASTER_CTRL_PLM_SHIFT)
  75. /* Only data will be loaded */
  76. #define RASTER_DATA (2 << LCDC_RASTER_CTRL_PLM_SHIFT)
  77. /*********************************************************************************/
  78. /*
  79. ** Values that can be passed to RasterModeConfig API as displayMode to select
  80. ** mode of display as either color or monochrome.
  81. */
  82. /* Select displayMode as COLOR */
  83. #define RASTER_COLOR 0
  84. /* Select displayMode as monochrome */
  85. #define RASTER_MONOCHROME (1 << LCDC_RASTER_CTRL_MONO_COLOR_SHIFT)
  86. /*********************************************************************************/
  87. /*
  88. ** Values that can be passed to RasterModeConfig API as flag for signal mappping
  89. ** if out pixel data is of 1,2,4 or 8 bits per pixel
  90. */
  91. /* Out put pixel data will be right aligned */
  92. #define RASTER_RIGHT_ALIGNED 0
  93. /* Out put pixel data will be mapped to 565 format */
  94. #define RASTER_EXTRAPOLATE (1 << LCDC_RASTER_CTRL_TFT_ALT_MAP_SHIFT)
  95. /*******************************************************************************/
  96. /*
  97. ** Values that can be passed to RasterModeConfig API as flag to select how many
  98. ** bits to output each pixel clock when momochrome displayMode is used
  99. */
  100. /* Eight bits are output each pClk */
  101. #define RASTER_MONO8B (1 << LCDC_RASTER_CTRL_MONO8B_SHIFT)
  102. /* Four bits are output each pClk */
  103. #define RASTER_MONO4B 0
  104. /******************************************************************************/
  105. /*
  106. ** Values that can be passed to RasterDMAConfig API as frmMode to select either
  107. ** to signle frame buffer or double frmae buffer(ping pong)
  108. */
  109. /* Selects single frmae buffer */
  110. #define RASTER_SINGLE_FRAME_BUFFER 0
  111. /* Selects double frmae buffer */
  112. #define RASTER_DOUBLE_FRAME_BUFFER LCDC_LCDDMA_CTRL_FRAME_MODE
  113. /*****************************************************************************/
  114. /*
  115. ** Values that can be passed to RasterDMAConfig API as endian to enable or
  116. ** disable bigendian for data reordering
  117. */
  118. /* Enable bigendian for data reordering */
  119. #define RASTER_BIG_ENDIAN_ENABLE (1 << LCDC_LCDDMA_CTRL_BIGENDIAN_SHIFT)
  120. /* Disable bigendian for data reordering */
  121. #define RASTER_BIG_ENDIAN_DISABLE 0
  122. /*****************************************************************************/
  123. /*
  124. ** Values that can be passed to RasterDMAConfig API as bustSz to select burst
  125. ** size for DMA transfer
  126. */
  127. /* Select burst size as one */
  128. #define RASTER_BURST_SIZE_1 0
  129. /* Select burst size as two */
  130. #define RASTER_BURST_SIZE_2 (1 << LCDC_LCDDMA_CTRL_BURST_SIZE_SHIFT)
  131. /* Select burst size as four */
  132. #define RASTER_BURST_SIZE_4 (2 << LCDC_LCDDMA_CTRL_BURST_SIZE_SHIFT)
  133. /* Select burst size as eight*/
  134. #define RASTER_BURST_SIZE_8 (3 << LCDC_LCDDMA_CTRL_BURST_SIZE_SHIFT)
  135. /* Select burst size as sixteen */
  136. #define RASTER_BURST_SIZE_16 (4 << LCDC_LCDDMA_CTRL_BURST_SIZE_SHIFT)
  137. /*****************************************************************************/
  138. /*
  139. ** Values that can be passed to RasterDMAConfig API as fifoTh to select DMA
  140. ** fifo threshold
  141. */
  142. #define RASTER_FIFO_THRESHOLD_8 (0 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  143. #define RASTER_FIFO_THRESHOLD_16 (1 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  144. #define RASTER_FIFO_THRESHOLD_32 (2 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  145. #define RASTER_FIFO_THRESHOLD_64 (3 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  146. #define RASTER_FIFO_THRESHOLD_128 (4 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  147. #define RASTER_FIFO_THRESHOLD_256 (5 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  148. #define RASTER_FIFO_THRESHOLD_512 (6 << LCDC_LCDDMA_CTRL_TH_FIFO_READY_SHIFT)
  149. /*********************************************************************************/
  150. /*
  151. ** Values that can be passed to RasterTiming2Configure API as flag to select the
  152. ** polarity of timing parameters of LCD controller.
  153. */
  154. /* Selects active high frame clock */
  155. #define RASTER_FRAME_CLOCK_HIGH 0
  156. /* Selects active low frame clock */
  157. #define RASTER_FRAME_CLOCK_LOW LCDC_RASTER_TIMING_2_IVS
  158. /* Selects active high line clock */
  159. #define RASTER_LINE_CLOCK_HIGH 0
  160. /* Selects active low line clock */
  161. #define RASTER_LINE_CLOCK_LOW LCDC_RASTER_TIMING_2_IHS
  162. /* Selects active high pixel clock */
  163. #define RASTER_PIXEL_CLOCK_HIGH 0
  164. /* Selects active low pixel clock */
  165. #define RASTER_PIXEL_CLOCK_LOW LCDC_RASTER_TIMING_2_IPC
  166. /* Selects acbias as active high*/
  167. #define RASTER_AC_BIAS_HIGH 0
  168. /* Selects acbias as active low*/
  169. #define RASTER_AC_BIAS_LOW LCDC_RASTER_TIMING_2_BIAS
  170. /* Selects horizontal and vertical sync edge as rising edge*/
  171. #define RASTER_SYNC_EDGE_RISING 0
  172. /* Selects horizontal and vertical sync edge as falling edge*/
  173. #define RASTER_SYNC_EDGE_FALLING LCDC_RASTER_TIMING_2_SYNC_EDGE
  174. /* Selects horizontal and vertical sync control as active */
  175. #define RASTER_SYNC_CTRL_ACTIVE LCDC_RASTER_TIMING_2_SYNC_CTRL
  176. /* Selects horizontal and vertical sync control as active */
  177. #define RASTER_SYNC_CTRL_INACTIVE 0
  178. /**************************************************************************/
  179. /*
  180. ** Values that can be passed to RasterIntEnable or RasterIntDisable API
  181. ** as flag to select the interrupt to be enabled or disabled
  182. */
  183. #ifdef am1808
  184. #define RASTER_ACBIAS_COUNT_INT LCDC_RASTER_CTRL_AC_EN
  185. #define RASTER_FRAME_DONE_INT LCDC_RASTER_CTRL_DONE_EN
  186. #define RASTER_PALETTE_LOADED_INT LCDC_RASTER_CTRL_PL_EN
  187. #define RASTER_SYNC_LOST_INT LCDC_RASTER_CTRL_SL_EN
  188. #define RASTER_FIFO_UNDRFLOW_INT LCDC_RASTER_CTRL_FUF_EN
  189. #endif
  190. #if defined(am335x) || defined(am335x_13x13) || defined(am335x_15x15)
  191. #define RASTER_ACBIAS_COUNT_INT LCDC_IRQENABLE_SET_ACB
  192. #define RASTER_FRAME_DONE_INT LCDC_IRQENABLE_SET_DONE
  193. #define RASTER_PALETTE_LOADED_INT LCDC_IRQENABLE_SET_PL
  194. #define RASTER_SYNC_LOST_INT LCDC_IRQENABLE_SET_SYNC
  195. #define RASTER_FIFO_UNDRFLOW_INT LCDC_IRQENABLE_SET_FUF
  196. #endif
  197. #define RASTER_DONE_INT LCDC_IRQENABLE_SET_RECURRENT_RASTER
  198. #define RASTER_END_OF_FRAME0_INT LCDC_IRQENABLE_SET_EOF0
  199. #define RASTER_END_OF_FRAME1_INT LCDC_IRQENABLE_SET_EOF1
  200. /***************************************************************************/
  201. /*
  202. ** Values that can be passed to RasterIntSatus API as flag
  203. ** to get interrupt status of rquired interrupt.
  204. */
  205. #if defined(am1808) || defined(omapl138) || defined(c6748)
  206. #define RASTER_FRAME_DONE_INT_STAT LCDC_LCD_STAT_DONE
  207. #define RASTER_SYNC_LOST_INT_STAT LCDC_LCD_STAT_SYNC
  208. #define RASTER_ACBIAS_COUNT_INT_STAT LCDC_LCD_STAT_ABC
  209. #define RASTER_FIFO_UNDERFLOW_INT_STAT LCDC_LCD_STAT_FUF
  210. #define RASTER_PALETTE_LOADED_INT_STAT LCDC_LCD_STAT_PL
  211. #define RASTER_END_OF_FRAME0_INT_STAT LCDC_LCD_STAT_EOF0
  212. #define RASTER_END_OF_FRAME1_INT_STAT LCDC_LCD_STAT_EOF1
  213. #endif
  214. #if defined(am335x) || defined(am335x_13x13) || defined(am335x_15x15)
  215. #define RASTER_FRAME_DONE_INT_STAT LCDC_IRQSTATUS_DONE
  216. #define RASTER_SYNC_LOST_INT_STAT LCDC_IRQSTATUS_SYNC
  217. #define RASTER_ACBIAS_COUNT_INT_STAT LCDC_IRQSTATUS_ACB
  218. #define RASTER_FIFO_UNDERFLOW_INT_STAT LCDC_IRQSTATUS_FUF
  219. #define RASTER_PALETTE_LOADED_INT_STAT LCDC_IRQSTATUS_PL
  220. #define RASTER_END_OF_FRAME0_INT_STAT LCDC_IRQSTATUS_EOF0
  221. #define RASTER_END_OF_FRAME1_INT_STAT LCDC_IRQSTATUS_EOF1
  222. #endif
  223. /***************************************************************************/
  224. /*
  225. ** Values that can be passed to RasterSoftawreResetControl API as flag
  226. ** to Reset required module(i.e Raster or DMA or LCD).
  227. */
  228. #define RASTER_CORE_RESET LCDC_CLKC_RESET_CORE
  229. #define RASTER_DMA_RESET LCDC_CLKC_RESET_DMA
  230. #define RASTER_LCD_MODULE_RESET LCDC_CLKC_RESET_MAIN
  231. #define RASTER_REV_AM335X 2u
  232. #define RASTER_REV_AM1808 1u
  233. /***************************************************************************/
  234. typedef struct rasterContext {
  235. unsigned int clkcEnable;
  236. unsigned int lcdCtrl;
  237. unsigned int lcddmaCtrl;
  238. unsigned int rasterTiming0;
  239. unsigned int rasterTiming1;
  240. unsigned int rasterTiming2;
  241. unsigned int rasterCtrl;
  242. unsigned int irqEnableSet;
  243. unsigned int lcddmaFb0Base;
  244. unsigned int lcddmaFb0Ceiling;
  245. unsigned int lcddmaFb1Base;
  246. unsigned int lcddmaFb1Ceiling;
  247. }RASTERCONTEXT;
  248. /*
  249. ** Function Prototypes
  250. */
  251. extern void RasterEnable(unsigned int baseAddr);
  252. extern void RasterDisable(unsigned int baseAddr);
  253. extern void RasterNibbleModeEnable(unsigned int baseAddr);
  254. extern void RasterNibbleModeDisable(unsigned int baseAddr);
  255. extern void RasterMSBDataOrderSelect(unsigned int baseAddr);
  256. extern void RasterLSBDataOrderSelect(unsigned int baseAddr);
  257. extern void RasterEndOfFrameIntEnable(unsigned int baseAddr);
  258. extern void RasterEndOfFrameIntDisable(unsigned int baseAddr);
  259. extern void RasterIntEnable(unsigned int baseAddr, unsigned int flag);
  260. extern void RasterDMAFBConfig(unsigned int baseAddr, unsigned int base,
  261. unsigned int ceiling, unsigned int flag);
  262. extern void RasterDMAConfig(unsigned int baseAddr, unsigned int frmMode,
  263. unsigned int bustSz, unsigned int fifoTh,
  264. unsigned int endian);
  265. extern void RasterIntDisable(unsigned int baseAddr, unsigned int flag);
  266. extern void RasterClkConfig(unsigned int baseAddr, unsigned int pClk,
  267. unsigned int moduleClk);
  268. extern void RasterModeConfig(unsigned int baseAddr, unsigned int displayMode,
  269. unsigned int paletteMode, unsigned int displayType,
  270. unsigned int flag);
  271. extern unsigned int RasterIntStatus(unsigned int baseAddr, unsigned int flag);
  272. extern void RasterVparamConfig(unsigned int baseAddr, unsigned int Lpp,
  273. unsigned int vsw, unsigned int vfp,
  274. unsigned vbp);
  275. extern void RasterHparamConfig(unsigned int baseAddr, unsigned int numOfppl,
  276. unsigned int hsw, unsigned int hfp,
  277. unsigned hbp);
  278. extern void RasterTiming2Configure(unsigned int baseAddr, unsigned int flag,
  279. unsigned int acb_i, unsigned int acb);
  280. extern void RasterFIFODMADelayConfig(unsigned int baseAddr, unsigned int delay);
  281. extern void RasterSubPanelEnable(unsigned int baseAddr);
  282. extern void RasterSubPanelDisable(unsigned int baseAddr);
  283. extern void RasterSubPanelConfig(unsigned int baseAddr, unsigned int hols,
  284. unsigned int lppt, unsigned int dpd);
  285. extern unsigned int RasterClearGetIntStatus(unsigned int baseAddr,
  286. unsigned int flag);
  287. extern void RasterClocksEnable(unsigned int baseAddr);
  288. extern unsigned int LCDVersionGet(void);
  289. extern void RasterContextSave(unsigned int baseAddr, RASTERCONTEXT *contextPtr);
  290. extern void RasterContextRestore(unsigned int baseAddr, RASTERCONTEXT *contextPtr);
  291. extern void RasterStandbyModeConfig(unsigned int baseAddr, unsigned int flag);
  292. extern void RasterIdleModeConfig(unsigned int baseAddr, unsigned int flag);
  293. #ifdef __cplusplus
  294. }
  295. #endif
  296. #endif