epdc.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /*
  2. * Copyright (c) 2010-2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. #ifndef _EPDC_H_
  31. #define _EPDC_H_
  32. //! @addtogroup diag_epdc
  33. //! @{
  34. ////////////////////////////////////////////////////////////////////////////////
  35. // Definitions
  36. ////////////////////////////////////////////////////////////////////////////////
  37. #define TRUE 1
  38. #define FALSE 0
  39. #define NUM_SCREENS 2
  40. #define EPDC_NUM_LUTS 16
  41. #define EPDC_MAX_NUM_UPDATES 32
  42. #define INVALID_LUT -1
  43. #define TEMP_USE_DEFAULT 8
  44. #define INIT_UPDATE_MARKER 0x12345678
  45. #define PAN_UPDATE_MARKER 0x12345679
  46. #define LUT_UPDATE_NONE 0
  47. #define LUT_UPDATE_NEW 1
  48. #define LUT_UPDATE_COLLISION 2
  49. #define POWER_STATE_OFF 0
  50. #define POWER_STATE_ON 1
  51. // Use waves for B077 panel
  52. #define EPDC_B077_4BIT_WV_DATA
  53. #define WV_SIZE 214136
  54. #define EPDC_HSIZE 800
  55. #define EPDC_VSIZE 600
  56. // We need a 20MHz pixclk to achieve 50Hz display refresh
  57. #define EPDC_PIXCLK_FRAC 27
  58. #define EPDC_PIXCLK_PRE_DIV 2
  59. #define EPDC_PIXCLK_POST_DIV 8
  60. // Set Axi clock to 200MHz
  61. #define EPDC_AXICLK_FRAC 22
  62. #define EPDC_AXICLK_PRE_DIV 2
  63. #define EPDC_AXICLK_POST_DIV 1
  64. #define EPDC_UPD_UPDATE_MODE__PARTIAL 0x0
  65. #define EPDC_UPD_UPDATE_MODE__FULL 0x1
  66. #define EPDC_WV_MODE__INIT 0
  67. #define EPDC_WV_MODE__DU 1 // black and white
  68. #define EPDC_WV_MODE__GC16 2 // 16 level
  69. #define EPDC_WV_MODE__GC4 3 // 4 level, low fidelity
  70. /*EPDC memory map*/
  71. #if defined(CHIP_MX6SDL)
  72. #define WV_DATA_ADDR 0x23000000
  73. #define WB_DATA_ADDR 0x23100000
  74. #define UPD_BUFFER_MODE_0_ADDR 0x23200000
  75. #define IMAGE_STORE_0_ADDR 0x23400000
  76. #elif defined(CHIP_MX6SL)
  77. #define WV_DATA_ADDR 0x93000000
  78. #define WB_DATA_ADDR 0x93100000
  79. #define UPD_BUFFER_MODE_0_ADDR 0x93200000
  80. #define IMAGE_STORE_0_ADDR 0x93400000
  81. #else
  82. #define WV_DATA_ADDR 0x73000000
  83. #define WB_DATA_ADDR 0x73100000
  84. #define UPD_BUFFER_MODE_0_ADDR 0x73200000
  85. #define IMAGE_STORE_0_ADDR 0x73400000
  86. #endif
  87. //! @brief Structure of waveform data header
  88. struct waveform_data_header {
  89. unsigned int wi0;
  90. unsigned int wi1;
  91. unsigned int wi2;
  92. unsigned int wi3;
  93. unsigned int wi4;
  94. unsigned int wi5;
  95. unsigned int wi6;
  96. unsigned int xwia:24;
  97. unsigned int cs1:8;
  98. unsigned int wmta:24;
  99. unsigned int fvsn:8;
  100. unsigned int luts:8;
  101. unsigned int mc:8;
  102. unsigned int trc:8;
  103. unsigned int reserved0_0:8;
  104. unsigned int eb:8;
  105. unsigned int sb:8;
  106. unsigned int reserved0_1:8;
  107. unsigned int reserved0_2:8;
  108. unsigned int reserved0_3:8;
  109. unsigned int reserved0_4:8;
  110. unsigned int reserved0_5:8;
  111. unsigned int cs2:8;
  112. };
  113. //! @brief Structure of waveform data file
  114. struct mxc_waveform_data_file {
  115. struct waveform_data_header wdh;
  116. unsigned int *data; /* Temperature Range Table + Waveform Data */
  117. };
  118. //! @brief Structure for epdc updated area information
  119. typedef struct {
  120. struct {
  121. int x;
  122. int y;
  123. } coordinate;
  124. struct {
  125. int width;
  126. int height;
  127. } size;
  128. } epdc_upd_area_t;
  129. //! @brief Structure for eink panel information
  130. typedef struct eink_panel_info {
  131. char name[32];
  132. unsigned int name_flag;
  133. unsigned int refresh;
  134. unsigned int width;
  135. unsigned int height;
  136. unsigned int pixel_clock;
  137. unsigned int hsync_start_width;
  138. unsigned int hsync_width;
  139. unsigned int hsync_end_width;
  140. unsigned int vsync_start_width;
  141. unsigned int vsync_width;
  142. unsigned int vsync_end_width;
  143. unsigned int delay_h2v;
  144. unsigned int interlaced;
  145. unsigned int data_format;
  146. } eink_panel_info_t;
  147. //! @Enumeration for eink panel that are supported by the driver
  148. enum eink_panel_flag {
  149. EINK_ED060SC4,
  150. };
  151. //! @brief Enumeration for epd lut table
  152. enum epdc_lut {
  153. EPDC_LUT0 = 0,
  154. EPDC_LUT1 = 1,
  155. EPDC_LUT2 = 2,
  156. EPDC_LUT3 = 3,
  157. EPDC_LUT4 = 4,
  158. EPDC_LUT5 = 5,
  159. EPDC_LUT6 = 6,
  160. EPDC_LUT7 = 7,
  161. EPDC_LUT8 = 8,
  162. EPDC_LUT9 = 9,
  163. EPDC_LUT10 = 10,
  164. EPDC_LUT11 = 11,
  165. EPDC_LUT12 = 12,
  166. EPDC_LUT13 = 13,
  167. EPDC_LUT14 = 14,
  168. EPDC_LUT15 = 15,
  169. };
  170. ////////////////////////////////////////////////////////////////////////////////
  171. // API
  172. ////////////////////////////////////////////////////////////////////////////////
  173. /*!
  174. * @brief Dump the EPDC registers for debug purpose
  175. */
  176. void epdc_dump_registers(void);
  177. /*!
  178. * @brief Configure the EPDC iomux
  179. */
  180. void epdc_iomux_config(void);
  181. /*!
  182. * @brief Configure the EPDC clock
  183. *
  184. * @param freq_mhz clock frequency in MHz unit
  185. */
  186. void epdc_clock_setting(int freq_mhz);
  187. /*!
  188. * @brief Load the GC image to EPDC data buffer
  189. */
  190. void epdc_load_image(void);
  191. /*!
  192. * @brief Provide the buffer supply for EPDC. it will use
  193. * external pmic
  194. */
  195. void epdc_power_supply(void);
  196. /*!
  197. * @brief Reset the EPD controller
  198. */
  199. void epdc_reset(void);
  200. /*!
  201. * @brief Intialize the EPDC buffers
  202. */
  203. void epdc_buffer_init(void);
  204. /*!
  205. * @brief Initialize the EPD controller
  206. */
  207. void epdc_init_settings(void);
  208. /*!
  209. * @brief Checi if the EPDC buffer is busy
  210. *
  211. * @return TRUE for busy and FALSE for idle
  212. */
  213. int epdc_is_working_buffer_busy(void);
  214. /*!
  215. * @brief Update the buffer address of EPDC
  216. *
  217. * @param addr buffer address
  218. */
  219. void epdc_set_update_addr(unsigned int addr);
  220. /*!
  221. * @brief Set the coordinate of EPDC update area
  222. *
  223. * @param x x coordinate
  224. * @param y y coordinate
  225. */
  226. void epdc_set_update_coord(unsigned int x, unsigned int y);
  227. /*!
  228. * @brief Set the dimensions of EPDC update area
  229. *
  230. * @param width width of the update area
  231. * @param height height of the update area
  232. */
  233. void epdc_set_update_dimensions(unsigned int width, unsigned int height);
  234. /*!
  235. * @brief Summit the update request to the panel by EPDC
  236. *
  237. * @param lut_num LUT offset
  238. * @param waveform_mode mode of the waveform
  239. * @param update_mode mode of update
  240. * @param use_test_mode test mode selection
  241. * @param np_val fixed NP offset
  242. */
  243. void epdc_submit_update(unsigned int lut_num, unsigned int waveform_mode,
  244. unsigned int update_mode, int use_test_mode, unsigned int np_val);
  245. /*!
  246. * @brief EPDC get the next LUT unit
  247. */
  248. int epdc_get_next_lut(void);
  249. /*!
  250. * @brief Check if the lut is active
  251. */
  252. int epdc_is_lut_active(unsigned int lut_num);
  253. //! @}
  254. #endif /*_EPDC_H_*/
  255. ////////////////////////////////////////////////////////////////////////////////
  256. // EOF
  257. ////////////////////////////////////////////////////////////////////////////////