lcm_drv.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. */
  31. #ifndef __LCM_DRV_H__
  32. #define __LCM_DRV_H__
  33. #include <platform/mt_gpio.h>
  34. #include <platform/mt_i2c.h>
  35. #include <platform/mt_pmic.h>
  36. #include <string.h>
  37. /* --------------------------------------------------------------------------- */
  38. #ifndef ARY_SIZE
  39. #define ARY_SIZE(x) (sizeof((x)) / sizeof((x[0])))
  40. #endif
  41. /* --------------------------------------------------------------------------- */
  42. /* common enumerations */
  43. typedef enum {
  44. LCM_TYPE_DBI = 0,
  45. LCM_TYPE_DPI,
  46. LCM_TYPE_DSI
  47. } LCM_TYPE;
  48. typedef enum {
  49. LCM_CTRL_NONE = 0,
  50. LCM_CTRL_SERIAL_DBI,
  51. LCM_CTRL_PARALLEL_DBI,
  52. LCM_CTRL_GPIO
  53. } LCM_CTRL;
  54. typedef enum {
  55. LCM_POLARITY_RISING = 0,
  56. LCM_POLARITY_FALLING = 1
  57. } LCM_POLARITY;
  58. typedef enum {
  59. LCM_CLOCK_PHASE_0 = 0,
  60. LCM_CLOCK_PHASE_90 = 1
  61. } LCM_CLOCK_PHASE;
  62. typedef enum {
  63. LCM_COLOR_ORDER_RGB = 0,
  64. LCM_COLOR_ORDER_BGR = 1
  65. } LCM_COLOR_ORDER;
  66. typedef enum {
  67. LCM_DRIVING_CURRENT_DEFAULT,
  68. LCM_DRIVING_CURRENT_8MA = (1 << 0),
  69. LCM_DRIVING_CURRENT_4MA = (1 << 1),
  70. LCM_DRIVING_CURRENT_2MA = (1 << 2),
  71. LCM_DRIVING_CURRENT_SLEW_CNTL = (1 << 3),
  72. LCM_DRIVING_CURRENT_6575_4MA = (1 << 4),
  73. LCM_DRIVING_CURRENT_6575_8MA = (3 << 4),
  74. LCM_DRIVING_CURRENT_6575_12MA = (2 << 4),
  75. LCM_DRIVING_CURRENT_6575_16MA = (4 << 4),
  76. LCM_DRIVING_CURRENT_6MA,
  77. LCM_DRIVING_CURRENT_10MA,
  78. LCM_DRIVING_CURRENT_12MA,
  79. LCM_DRIVING_CURRENT_14MA,
  80. LCM_DRIVING_CURRENT_16MA,
  81. LCM_DRIVING_CURRENT_20MA,
  82. LCM_DRIVING_CURRENT_24MA,
  83. LCM_DRIVING_CURRENT_28MA,
  84. LCM_DRIVING_CURRENT_32MA
  85. } LCM_DRIVING_CURRENT;
  86. typedef enum {
  87. LCM_INTERFACE_NOTDEFINED = 0,
  88. LCM_INTERFACE_DSI0,
  89. LCM_INTERFACE_DSI1,
  90. LCM_INTERFACE_DSI_DUAL,
  91. LCM_INTERFACE_DPI0,
  92. LCM_INTERFACE_DPI1,
  93. LCM_INTERFACE_DBI0
  94. } LCM_INTERFACE_ID;
  95. typedef enum {
  96. LCM_IOCTL_NULL = 0,
  97. } LCM_IOCTL;
  98. /* DBI related enumerations */
  99. typedef enum {
  100. LCM_DBI_CLOCK_FREQ_104M = 0,
  101. LCM_DBI_CLOCK_FREQ_52M,
  102. LCM_DBI_CLOCK_FREQ_26M,
  103. LCM_DBI_CLOCK_FREQ_13M,
  104. LCM_DBI_CLOCK_FREQ_7M
  105. } LCM_DBI_CLOCK_FREQ;
  106. typedef enum {
  107. LCM_DBI_DATA_WIDTH_8BITS = 0,
  108. LCM_DBI_DATA_WIDTH_9BITS = 1,
  109. LCM_DBI_DATA_WIDTH_16BITS = 2,
  110. LCM_DBI_DATA_WIDTH_18BITS = 3,
  111. LCM_DBI_DATA_WIDTH_24BITS = 4,
  112. LCM_DBI_DATA_WIDTH_32BITS = 5
  113. } LCM_DBI_DATA_WIDTH;
  114. typedef enum {
  115. LCM_DBI_CPU_WRITE_8_BITS = 8,
  116. LCM_DBI_CPU_WRITE_16_BITS = 16,
  117. LCM_DBI_CPU_WRITE_32_BITS = 32,
  118. } LCM_DBI_CPU_WRITE_BITS;
  119. typedef enum {
  120. LCM_DBI_FORMAT_RGB332 = 0,
  121. LCM_DBI_FORMAT_RGB444 = 1,
  122. LCM_DBI_FORMAT_RGB565 = 2,
  123. LCM_DBI_FORMAT_RGB666 = 3,
  124. LCM_DBI_FORMAT_RGB888 = 4
  125. } LCM_DBI_FORMAT;
  126. typedef enum {
  127. LCM_DBI_TRANS_SEQ_MSB_FIRST = 0,
  128. LCM_DBI_TRANS_SEQ_LSB_FIRST = 1
  129. } LCM_DBI_TRANS_SEQ;
  130. typedef enum {
  131. LCM_DBI_PADDING_ON_LSB = 0,
  132. LCM_DBI_PADDING_ON_MSB = 1
  133. } LCM_DBI_PADDING;
  134. typedef enum {
  135. LCM_DBI_TE_MODE_DISABLED = 0,
  136. LCM_DBI_TE_MODE_VSYNC_ONLY = 1,
  137. LCM_DBI_TE_MODE_VSYNC_OR_HSYNC = 2,
  138. } LCM_DBI_TE_MODE;
  139. typedef enum {
  140. LCM_DBI_TE_VS_WIDTH_CNT_DIV_8 = 0,
  141. LCM_DBI_TE_VS_WIDTH_CNT_DIV_16 = 1,
  142. LCM_DBI_TE_VS_WIDTH_CNT_DIV_32 = 2,
  143. LCM_DBI_TE_VS_WIDTH_CNT_DIV_64 = 3,
  144. } LCM_DBI_TE_VS_WIDTH_CNT_DIV;
  145. /* DPI related enumerations */
  146. typedef enum {
  147. LCM_DPI_FORMAT_RGB565 = 0,
  148. LCM_DPI_FORMAT_RGB666 = 1,
  149. LCM_DPI_FORMAT_RGB888 = 2
  150. } LCM_DPI_FORMAT;
  151. typedef enum {
  152. LCM_SERIAL_CLOCK_FREQ_104M = 0,
  153. LCM_SERIAL_CLOCK_FREQ_26M,
  154. LCM_SERIAL_CLOCK_FREQ_52M
  155. } LCM_SERIAL_CLOCK_FREQ;
  156. typedef enum {
  157. LCM_SERIAL_CLOCK_DIV_2 = 0,
  158. LCM_SERIAL_CLOCK_DIV_4 = 1,
  159. LCM_SERIAL_CLOCK_DIV_8 = 2,
  160. LCM_SERIAL_CLOCK_DIV_16 = 3,
  161. } LCM_SERIAL_CLOCK_DIV;
  162. /* DSI related enumerations */
  163. typedef enum {
  164. CMD_MODE = 0,
  165. SYNC_PULSE_VDO_MODE = 1,
  166. SYNC_EVENT_VDO_MODE = 2,
  167. BURST_VDO_MODE = 3
  168. } LCM_DSI_MODE_CON;
  169. typedef enum {
  170. LCM_ONE_LANE = 1,
  171. LCM_TWO_LANE = 2,
  172. LCM_THREE_LANE = 3,
  173. LCM_FOUR_LANE = 4,
  174. } LCM_LANE_NUM;
  175. typedef enum {
  176. LCM_DSI_FORMAT_RGB565 = 0,
  177. LCM_DSI_FORMAT_RGB666 = 1,
  178. LCM_DSI_FORMAT_RGB888 = 2
  179. } LCM_DSI_FORMAT;
  180. typedef enum {
  181. LCM_DSI_TRANS_SEQ_MSB_FIRST = 0,
  182. LCM_DSI_TRANS_SEQ_LSB_FIRST = 1
  183. } LCM_DSI_TRANS_SEQ;
  184. typedef enum {
  185. LCM_DSI_PADDING_ON_LSB = 0,
  186. LCM_DSI_PADDING_ON_MSB = 1
  187. } LCM_DSI_PADDING;
  188. typedef enum {
  189. LCM_PACKED_PS_16BIT_RGB565 = 0,
  190. LCM_LOOSELY_PS_18BIT_RGB666 = 1,
  191. LCM_PACKED_PS_24BIT_RGB888 = 2,
  192. LCM_PACKED_PS_18BIT_RGB666 = 3
  193. } LCM_PS_TYPE;
  194. typedef enum {
  195. LCM_DSI_6589_PLL_CLOCK_NULL = 0,
  196. LCM_DSI_6589_PLL_CLOCK_201_5 = 1,
  197. LCM_DSI_6589_PLL_CLOCK_208 = 2,
  198. LCM_DSI_6589_PLL_CLOCK_214_5 = 3,
  199. LCM_DSI_6589_PLL_CLOCK_221 = 4,
  200. LCM_DSI_6589_PLL_CLOCK_227_5 = 5,
  201. LCM_DSI_6589_PLL_CLOCK_234 = 6,
  202. LCM_DSI_6589_PLL_CLOCK_240_5 = 7,
  203. LCM_DSI_6589_PLL_CLOCK_247 = 8,
  204. LCM_DSI_6589_PLL_CLOCK_253_5 = 9,
  205. LCM_DSI_6589_PLL_CLOCK_260 = 10,
  206. LCM_DSI_6589_PLL_CLOCK_266_5 = 11,
  207. LCM_DSI_6589_PLL_CLOCK_273 = 12,
  208. LCM_DSI_6589_PLL_CLOCK_279_5 = 13,
  209. LCM_DSI_6589_PLL_CLOCK_286 = 14,
  210. LCM_DSI_6589_PLL_CLOCK_292_5 = 15,
  211. LCM_DSI_6589_PLL_CLOCK_299 = 16,
  212. LCM_DSI_6589_PLL_CLOCK_305_5 = 17,
  213. LCM_DSI_6589_PLL_CLOCK_312 = 18,
  214. LCM_DSI_6589_PLL_CLOCK_318_5 = 19,
  215. LCM_DSI_6589_PLL_CLOCK_325 = 20,
  216. LCM_DSI_6589_PLL_CLOCK_331_5 = 21,
  217. LCM_DSI_6589_PLL_CLOCK_338 = 22,
  218. LCM_DSI_6589_PLL_CLOCK_344_5 = 23,
  219. LCM_DSI_6589_PLL_CLOCK_351 = 24,
  220. LCM_DSI_6589_PLL_CLOCK_357_5 = 25,
  221. LCM_DSI_6589_PLL_CLOCK_364 = 26,
  222. LCM_DSI_6589_PLL_CLOCK_370_5 = 27,
  223. LCM_DSI_6589_PLL_CLOCK_377 = 28,
  224. LCM_DSI_6589_PLL_CLOCK_383_5 = 29,
  225. LCM_DSI_6589_PLL_CLOCK_390 = 30,
  226. LCM_DSI_6589_PLL_CLOCK_396_5 = 31,
  227. LCM_DSI_6589_PLL_CLOCK_403 = 32,
  228. LCM_DSI_6589_PLL_CLOCK_409_5 = 33,
  229. LCM_DSI_6589_PLL_CLOCK_416 = 34,
  230. LCM_DSI_6589_PLL_CLOCK_422_5 = 35,
  231. LCM_DSI_6589_PLL_CLOCK_429 = 36,
  232. LCM_DSI_6589_PLL_CLOCK_435_5 = 37,
  233. LCM_DSI_6589_PLL_CLOCK_442 = 38,
  234. LCM_DSI_6589_PLL_CLOCK_448_5 = 39,
  235. LCM_DSI_6589_PLL_CLOCK_455 = 40,
  236. LCM_DSI_6589_PLL_CLOCK_461_5 = 41,
  237. LCM_DSI_6589_PLL_CLOCK_468 = 42,
  238. LCM_DSI_6589_PLL_CLOCK_474_5 = 43,
  239. LCM_DSI_6589_PLL_CLOCK_481 = 44,
  240. LCM_DSI_6589_PLL_CLOCK_487_5 = 45,
  241. LCM_DSI_6589_PLL_CLOCK_494 = 46,
  242. LCM_DSI_6589_PLL_CLOCK_500_5 = 47,
  243. LCM_DSI_6589_PLL_CLOCK_507 = 48,
  244. LCM_DSI_6589_PLL_CLOCK_513_5 = 49,
  245. LCM_DSI_6589_PLL_CLOCK_520 = 50,
  246. } LCM_DSI_PLL_CLOCK;
  247. /* --------------------------------------------------------------------------- */
  248. typedef struct {
  249. LCM_COLOR_ORDER color_order;
  250. LCM_DBI_TRANS_SEQ trans_seq;
  251. LCM_DBI_PADDING padding;
  252. LCM_DBI_FORMAT format;
  253. LCM_DBI_DATA_WIDTH width;
  254. } LCM_DBI_DATA_FORMAT;
  255. typedef struct {
  256. LCM_POLARITY cs_polarity;
  257. LCM_POLARITY clk_polarity;
  258. LCM_CLOCK_PHASE clk_phase;
  259. unsigned int is_non_dbi_mode;
  260. LCM_SERIAL_CLOCK_FREQ clock_base;
  261. LCM_SERIAL_CLOCK_DIV clock_div;
  262. /* //////////////////////////////////MT6575 added params, and if lcm driver is for 6575, only care these below params */
  263. unsigned int css;
  264. unsigned int csh;
  265. unsigned int rd_1st;
  266. unsigned int rd_2nd;
  267. unsigned int wr_1st;
  268. unsigned int wr_2nd;
  269. unsigned int sif_3wire;
  270. unsigned int sif_sdi;
  271. LCM_POLARITY sif_1st_pol;
  272. LCM_POLARITY sif_sck_def;
  273. unsigned int sif_div2;
  274. unsigned int sif_hw_cs;
  275. /* ////////////////////////////////// */
  276. } LCM_DBI_SERIAL_PARAMS;
  277. typedef struct {
  278. /* timing parameters */
  279. unsigned int write_setup;
  280. unsigned int write_hold;
  281. unsigned int write_wait;
  282. unsigned int read_setup;
  283. unsigned int read_hold;
  284. unsigned int read_latency;
  285. unsigned int wait_period;
  286. /*only for 6575 */
  287. unsigned int cs_high_width;
  288. } LCM_DBI_PARALLEL_PARAMS;
  289. typedef struct {
  290. LCM_COLOR_ORDER color_order;
  291. LCM_DSI_TRANS_SEQ trans_seq;
  292. LCM_DSI_PADDING padding;
  293. LCM_DSI_FORMAT format;
  294. } LCM_DSI_DATA_FORMAT;
  295. typedef struct {
  296. LCM_DSI_MODE_CON mode;
  297. unsigned int cmd_if;
  298. unsigned int addr;
  299. unsigned int val[4];
  300. } LCM_DSI_MODE_SWITCH_CMD;
  301. typedef struct {
  302. unsigned int compress_ratio;
  303. unsigned int lr_mode_en;
  304. unsigned int vlc_disable;
  305. unsigned int vlc_config;
  306. } LCM_UFOE_CONFIG_PARAMS;
  307. /* --------------------------------------------------------------------------- */
  308. typedef struct {
  309. /* common parameters for serial & parallel interface */
  310. unsigned int port;
  311. LCM_DBI_CLOCK_FREQ clock_freq;
  312. LCM_DBI_DATA_WIDTH data_width;
  313. LCM_DBI_DATA_FORMAT data_format;
  314. LCM_DBI_CPU_WRITE_BITS cpu_write_bits;
  315. LCM_DRIVING_CURRENT io_driving_current;
  316. LCM_DRIVING_CURRENT msb_io_driving_current;
  317. LCM_DRIVING_CURRENT ctrl_io_driving_current;
  318. /* tearing control */
  319. LCM_DBI_TE_MODE te_mode;
  320. LCM_POLARITY te_edge_polarity;
  321. unsigned int te_hs_delay_cnt;
  322. unsigned int te_vs_width_cnt;
  323. LCM_DBI_TE_VS_WIDTH_CNT_DIV te_vs_width_cnt_div;
  324. /* particular parameters for serial & parallel interface */
  325. LCM_DBI_SERIAL_PARAMS serial;
  326. LCM_DBI_PARALLEL_PARAMS parallel;
  327. } LCM_DBI_PARAMS;
  328. typedef struct {
  329. /*
  330. Pixel Clock Frequency = 26MHz * mipi_pll_clk_div1
  331. / (mipi_pll_clk_ref + 1)
  332. / (2 * mipi_pll_clk_div2)
  333. / dpi_clk_div
  334. */
  335. unsigned int mipi_pll_clk_ref; /* 0..1 */
  336. unsigned int mipi_pll_clk_div1; /* 0..63 */
  337. unsigned int mipi_pll_clk_div2; /* 0..15 */
  338. unsigned int mipi_pll_clk_fbk_div; /* PCLK=> 8: 26MHz, 10: 35MHz, 12: 40MHz */
  339. unsigned int dpi_clk_div; /* 2..32 */
  340. unsigned int dpi_clk_duty; /* (dpi_clk_div - 1) .. 31 */
  341. unsigned int PLL_CLOCK;
  342. unsigned int dpi_clock;
  343. unsigned int ssc_disable;
  344. unsigned int ssc_range;
  345. unsigned int width;
  346. unsigned int height;
  347. unsigned int bg_width;
  348. unsigned int bg_height;
  349. /* polarity parameters */
  350. LCM_POLARITY clk_pol;
  351. LCM_POLARITY de_pol;
  352. LCM_POLARITY vsync_pol;
  353. LCM_POLARITY hsync_pol;
  354. /* timing parameters */
  355. unsigned int hsync_pulse_width;
  356. unsigned int hsync_back_porch;
  357. unsigned int hsync_front_porch;
  358. unsigned int vsync_pulse_width;
  359. unsigned int vsync_back_porch;
  360. unsigned int vsync_front_porch;
  361. /* output format parameters */
  362. LCM_DPI_FORMAT format;
  363. LCM_COLOR_ORDER rgb_order;
  364. unsigned int is_serial_output;
  365. unsigned int i2x_en;
  366. unsigned int i2x_edge;
  367. unsigned int embsync;
  368. unsigned int lvds_tx_en;
  369. unsigned int bit_swap;
  370. /* intermediate buffers parameters */
  371. unsigned int intermediat_buffer_num; /* 2..3 */
  372. /* iopad parameters */
  373. LCM_DRIVING_CURRENT io_driving_current;
  374. LCM_DRIVING_CURRENT msb_io_driving_current;
  375. LCM_DRIVING_CURRENT lsb_io_driving_current;
  376. LCM_DRIVING_CURRENT ctrl_io_driving_current;
  377. } LCM_DPI_PARAMS;
  378. /* --------------------------------------------------------------------------- */
  379. typedef struct {
  380. unsigned char cmd;
  381. unsigned char count;
  382. unsigned char para_list[2];
  383. } LCM_esd_check_item;
  384. typedef enum {
  385. DUAL_DSI_NONE = 0x0,
  386. DUAL_DSI_CMD = 0x1,
  387. DUAL_DSI_VDO = 0x2,
  388. } DUAL_DSI_TYPE;
  389. typedef enum {
  390. MIPITX_PHY_LANE_0 = 0,
  391. MIPITX_PHY_LANE_1,
  392. MIPITX_PHY_LANE_2,
  393. MIPITX_PHY_LANE_3,
  394. MIPITX_PHY_LANE_CK,
  395. MIPITX_PHY_LANE_RX,
  396. MIPITX_PHY_LANE_NUM
  397. } MIPITX_PHY_LANE_SWAP;
  398. typedef enum {
  399. MIPITX_PHY_PORT_0 = 0,
  400. MIPITX_PHY_PORT_1,
  401. MIPITX_PHY_PORT_NUM
  402. } MIPITX_PHY_PORT;
  403. typedef struct {
  404. unsigned int slice_width;
  405. unsigned int slice_hight;
  406. unsigned int bit_per_pixel;
  407. unsigned int slice_mode;
  408. unsigned int rgb_swap;
  409. unsigned int dsc_cfg;
  410. unsigned int dsc_line_buf_depth;
  411. unsigned int bit_per_channel;
  412. unsigned int rct_on;
  413. unsigned int bp_enable;
  414. unsigned int dec_delay;
  415. unsigned int xmit_delay;
  416. unsigned int scale_value;
  417. unsigned int increment_interval;
  418. unsigned int line_bpg_offset;
  419. unsigned int decrement_interval;
  420. unsigned int nfl_bpg_offset;
  421. unsigned int slice_bpg_offset;
  422. unsigned int initial_offset;
  423. unsigned int final_offset;
  424. unsigned int flatness_minqp;
  425. unsigned int flatness_maxqp;
  426. unsigned int rc_mode1_size;
  427. } LCM_DSC_CONFIG_PARAMS;
  428. typedef struct {
  429. LCM_DSI_MODE_CON mode;
  430. LCM_DSI_MODE_CON switch_mode;
  431. unsigned int DSI_WMEM_CONTI;
  432. unsigned int DSI_RMEM_CONTI;
  433. unsigned int VC_NUM;
  434. LCM_LANE_NUM LANE_NUM;
  435. LCM_DSI_DATA_FORMAT data_format;
  436. /* intermediate buffers parameters */
  437. unsigned int intermediat_buffer_num; /* 2..3 */
  438. LCM_PS_TYPE PS;
  439. unsigned int word_count;
  440. unsigned int packet_size;
  441. unsigned int packet_size_mult;
  442. unsigned int vertical_sync_active;
  443. unsigned int vertical_backporch;
  444. unsigned int vertical_frontporch;
  445. unsigned int vertical_frontporch_for_low_power;
  446. unsigned int vertical_active_line;
  447. unsigned int horizontal_sync_active;
  448. unsigned int horizontal_backporch;
  449. unsigned int horizontal_frontporch;
  450. unsigned int horizontal_blanking_pixel;
  451. unsigned int horizontal_active_pixel;
  452. unsigned int horizontal_bllp;
  453. unsigned int line_byte;
  454. unsigned int horizontal_sync_active_byte;
  455. unsigned int horizontal_backporch_byte;
  456. unsigned int horizontal_frontporch_byte;
  457. unsigned int rgb_byte;
  458. unsigned int horizontal_sync_active_word_count;
  459. unsigned int horizontal_backporch_word_count;
  460. unsigned int horizontal_frontporch_word_count;
  461. unsigned char HS_TRAIL;
  462. unsigned char HS_ZERO;
  463. unsigned char HS_PRPR;
  464. unsigned char LPX;
  465. unsigned char TA_SACK;
  466. unsigned char TA_GET;
  467. unsigned char TA_SURE;
  468. unsigned char TA_GO;
  469. unsigned char CLK_TRAIL;
  470. unsigned char CLK_ZERO;
  471. unsigned char LPX_WAIT;
  472. unsigned char CONT_DET;
  473. unsigned char CLK_HS_PRPR;
  474. unsigned char CLK_HS_POST;
  475. unsigned char DA_HS_EXIT;
  476. unsigned char CLK_HS_EXIT;
  477. unsigned int pll_select;
  478. unsigned int pll_div1;
  479. unsigned int pll_div2;
  480. unsigned int fbk_div;
  481. unsigned int fbk_sel;
  482. unsigned int rg_bir;
  483. unsigned int rg_bic;
  484. unsigned int rg_bp;
  485. unsigned int PLL_CLOCK; /* PLL_CLOCK = (int) PLL_CLOCK */
  486. unsigned int data_rate; /* data_rate = PLL_CLOCK x 2 */
  487. unsigned int dsi_clock;
  488. unsigned int ssc_disable;
  489. unsigned int ssc_range;
  490. unsigned int compatibility_for_nvk;
  491. unsigned int cont_clock;
  492. unsigned int ufoe_enable;
  493. unsigned int dsc_enable;
  494. LCM_UFOE_CONFIG_PARAMS ufoe_params;
  495. LCM_DSC_CONFIG_PARAMS dsc_params;
  496. unsigned int edp_panel;
  497. unsigned int customization_esd_check_enable;
  498. unsigned int esd_check_enable;
  499. unsigned int lcm_int_te_monitor;
  500. unsigned int lcm_int_te_period;
  501. unsigned int lcm_ext_te_monitor;
  502. unsigned int lcm_ext_te_enable;
  503. unsigned int noncont_clock;
  504. unsigned int noncont_clock_period;
  505. unsigned int clk_lp_per_line_enable;
  506. LCM_esd_check_item lcm_esd_check_table[3];
  507. unsigned int switch_mode_enable;
  508. DUAL_DSI_TYPE dual_dsi_type;
  509. unsigned int lane_swap_en;
  510. MIPITX_PHY_LANE_SWAP lane_swap[MIPITX_PHY_PORT_NUM][MIPITX_PHY_LANE_NUM];
  511. unsigned int vertical_vfp_lp;
  512. unsigned int PLL_CLOCK_lp;
  513. unsigned int ulps_sw_enable;
  514. unsigned int null_packet_en;
  515. unsigned int mixmode_enable;
  516. unsigned int mixmode_mipi_clock;
  517. unsigned int pwm_fps;
  518. unsigned int send_frame_enable;
  519. unsigned int lfr_enable;
  520. unsigned int lfr_mode;
  521. unsigned int lfr_type;
  522. unsigned int lfr_skip_num;
  523. unsigned int ext_te_edge;
  524. unsigned int eint_disable;
  525. unsigned int IsCphy;
  526. unsigned int PHY_SEL0;
  527. unsigned int PHY_SEL1;
  528. unsigned int PHY_SEL2;
  529. unsigned int PHY_SEL3;
  530. } LCM_DSI_PARAMS;
  531. /* --------------------------------------------------------------------------- */
  532. typedef struct {
  533. unsigned int round_corner_en;
  534. unsigned int is_notch;
  535. unsigned int full_content;
  536. unsigned int w;
  537. unsigned int h;
  538. unsigned int w_bot;
  539. unsigned int h_bot;
  540. unsigned int tp_size;
  541. unsigned int bt_size;
  542. void *lt_addr;
  543. void *rt_addr;
  544. void *lb_addr;
  545. void *rb_addr;
  546. } LCM_ROUND_CORNER;
  547. typedef struct {
  548. LCM_TYPE type;
  549. LCM_CTRL ctrl; /* ! how to control LCM registers */
  550. LCM_INTERFACE_ID lcm_if;
  551. LCM_INTERFACE_ID lcm_cmd_if;
  552. /* common parameters */
  553. unsigned int lcm_x;
  554. unsigned int lcm_y;
  555. unsigned int width;
  556. unsigned int height;
  557. unsigned int virtual_width;
  558. unsigned int virtual_height;
  559. unsigned int io_select_mode; /* DBI or DPI should select IO mode according to chip spec */
  560. /* particular parameters */
  561. LCM_DBI_PARAMS dbi;
  562. LCM_DPI_PARAMS dpi;
  563. LCM_DSI_PARAMS dsi;
  564. unsigned int physical_width;
  565. unsigned int physical_height;
  566. unsigned int od_table_size;
  567. void *od_table;
  568. #ifdef MTK_ROUND_CORNER_SUPPORT
  569. LCM_ROUND_CORNER round_corner_params;
  570. #endif
  571. } LCM_PARAMS;
  572. #ifndef MAX
  573. #define MAX(x, y) (((x) >= (y)) ? (x) : (y))
  574. #endif /* MAX */
  575. #ifndef MIN
  576. #define MIN(x, y) (((x) <= (y)) ? (x) : (y))
  577. #endif /* MIN */
  578. #define INIT_SIZE (640)
  579. #define COMPARE_ID_SIZE (32)
  580. #define SUSPEND_SIZE (32)
  581. #define BACKLIGHT_SIZE (32)
  582. #define BACKLIGHT_CMDQ_SIZE (32)
  583. #define MAX_SIZE (MAX(MAX(MAX(MAX(INIT_SIZE, COMPARE_ID_SIZE), SUSPEND_SIZE), BACKLIGHT_SIZE), \
  584. BACKLIGHT_CMDQ_SIZE))
  585. typedef struct {
  586. char data;
  587. char padding[131];
  588. } LCM_DATA_T1;
  589. typedef struct {
  590. char cmd;
  591. char data;
  592. char padding[130];
  593. } LCM_DATA_T2;
  594. typedef struct {
  595. char cmd;
  596. char size;
  597. char data[128];
  598. char padding[2];
  599. } LCM_DATA_T3;
  600. typedef struct {
  601. char cmd;
  602. char location;
  603. char data;
  604. char padding[129];
  605. } LCM_DATA_T4;
  606. typedef struct {
  607. char size;
  608. char cmd[128];
  609. char padding[3];
  610. } LCM_DATA_T5;
  611. typedef struct {
  612. char func;
  613. char type;
  614. char size;
  615. char padding;
  616. union {
  617. LCM_DATA_T1 data_t1;
  618. LCM_DATA_T2 data_t2;
  619. LCM_DATA_T3 data_t3;
  620. LCM_DATA_T4 data_t4;
  621. LCM_DATA_T5 data_t5;
  622. };
  623. } LCM_DATA;
  624. typedef struct {
  625. unsigned int parsing;
  626. unsigned int id;
  627. unsigned int init_size;
  628. unsigned int compare_id_size;
  629. unsigned int suspend_size;
  630. unsigned int backlight_size;
  631. unsigned int backlight_cmdq_size;
  632. LCM_PARAMS params;
  633. LCM_DATA init[INIT_SIZE];
  634. LCM_DATA compare_id[COMPARE_ID_SIZE];
  635. LCM_DATA suspend[SUSPEND_SIZE];
  636. LCM_DATA backlight[BACKLIGHT_SIZE];
  637. LCM_DATA backlight_cmdq[BACKLIGHT_CMDQ_SIZE];
  638. } LCM_DTS;
  639. /* --------------------------------------------------------------------------- */
  640. #define REGFLAG_ESCAPE_ID (0x00)
  641. #define REGFLAG_DELAY_MS_V3 (0xFF)
  642. typedef struct {
  643. unsigned char id;
  644. unsigned char cmd;
  645. unsigned char count;
  646. unsigned char para_list[128];
  647. } LCM_setting_table_V3;
  648. /*
  649. * dtype ---- data type
  650. * vc ---- virtual channel
  651. * dlen ---- data length
  652. * link_state ---- HS:0 LP:1
  653. * payload ---- payload
  654. */
  655. struct dsi_cmd_desc {
  656. unsigned int dtype;
  657. unsigned int vc;
  658. unsigned int dlen;
  659. unsigned int link_state;
  660. char *payload;
  661. };
  662. typedef struct {
  663. void (*set_reset_pin) (unsigned int value);
  664. void (*set_chip_select) (unsigned int value);
  665. int (*set_gpio_out) (unsigned int gpio, unsigned int value);
  666. void (*udelay) (unsigned int us);
  667. void (*mdelay) (unsigned int ms);
  668. void (*rar) (unsigned int ms);
  669. void (*send_cmd) (unsigned int cmd);
  670. void (*send_data) (unsigned int data);
  671. unsigned int (*read_data) (void);
  672. void (*dsi_set_cmdq_V3) (LCM_setting_table_V3 *para_list, unsigned int size,
  673. unsigned char force_update);
  674. void (*dsi_set_cmdq_V2) (unsigned cmd, unsigned char count, unsigned char *para_list,
  675. unsigned char force_update);
  676. void (*dsi_set_cmdq) (unsigned int *pdata, unsigned int queue_size,
  677. unsigned char force_update);
  678. void (*dsi_set_null) (unsigned cmd, unsigned char count, unsigned char *para_list,
  679. unsigned char force_update);
  680. void (*dsi_write_cmd) (unsigned int cmd);
  681. void (*dsi_write_regs) (unsigned int addr, unsigned int *para, unsigned int nums);
  682. unsigned int (*dsi_read_reg) (void);
  683. unsigned int (*dsi_dcs_read_lcm_reg) (unsigned char cmd);
  684. unsigned int (*dsi_dcs_read_lcm_reg_v2) (unsigned char cmd, unsigned char *buffer,
  685. unsigned char buffer_size);
  686. void (*wait_transfer_done) (void);
  687. /** FIXME: GPIO mode should not be configured in lcm driver
  688. REMOVE ME after GPIO customization is done
  689. */
  690. int (*set_gpio_mode) (unsigned int pin, unsigned int mode);
  691. int (*set_gpio_dir) (unsigned int pin, unsigned int dir);
  692. int (*set_gpio_pull_enable) (unsigned int pin, unsigned char pull_en);
  693. long (*set_gpio_lcd_enp_bias)(unsigned int value);
  694. void (*dsi_set_cmdq_V11) (void *cmdq, unsigned int *pdata, unsigned int queue_size,
  695. unsigned char force_update);
  696. void (*dsi_set_cmdq_V22) (void *cmdq, unsigned cmd, unsigned char count,
  697. unsigned char *para_list, unsigned char force_update);
  698. void (*dsi_swap_port) (int swap);
  699. void (*dsi_set_cmdq_V23) (void *cmdq, unsigned cmd, unsigned char count, unsigned char *para_list, unsigned char force_update); /* dual */
  700. void (*mipi_dsi_cmds_tx)(void *cmdq, struct dsi_cmd_desc *cmds);
  701. unsigned int (*mipi_dsi_cmds_rx)(char *out,
  702. struct dsi_cmd_desc *cmds, unsigned int len);
  703. } LCM_UTIL_FUNCS;
  704. typedef enum {
  705. LCM_DRV_IOCTL_ENABLE_CMD_MODE = 0x100,
  706. } LCM_DRV_IOCTL_CMD;
  707. typedef struct {
  708. const char *name;
  709. void (*set_util_funcs) (const LCM_UTIL_FUNCS *util);
  710. void (*get_params) (LCM_PARAMS *params);
  711. void (*init) (void);
  712. void (*suspend) (void);
  713. void (*resume) (void);
  714. /* for power-on sequence refinement */
  715. void (*init_power) (void);
  716. void (*suspend_power) (void);
  717. void (*resume_power) (void);
  718. void (*update) (unsigned int x, unsigned int y, unsigned int width, unsigned int height);
  719. unsigned int (*compare_id) (void);
  720. void (*parse_dts)(const LCM_DTS *DTS, unsigned char force_update);
  721. /* /////////////////////////CABC backlight related function */
  722. void (*set_backlight) (unsigned int level);
  723. void (*set_backlight_cmdq) (void *handle, unsigned int level);
  724. void (*set_pwm) (unsigned int divider);
  725. unsigned int (*get_pwm) (unsigned int divider);
  726. void (*set_backlight_mode) (unsigned int mode);
  727. /* ///////////////////////// */
  728. int (*adjust_fps) (void *cmdq, int fps);
  729. /* ///////////ESD_RECOVERY////////////////////// */
  730. unsigned int (*esd_check) (void);
  731. unsigned int (*esd_recover) (void);
  732. unsigned int (*check_status) (void);
  733. unsigned int (*ata_check) (unsigned char *buffer);
  734. void (*read_fb) (unsigned char *buffer);
  735. int (*ioctl) (LCM_DRV_IOCTL_CMD cmd, unsigned int data);
  736. /* /////////////////////////////////////////////// */
  737. void (*enter_idle)(void);
  738. void (*exit_idle)(void);
  739. void (*change_fps)(unsigned int mode);
  740. /* //switch mode */
  741. void *(*switch_mode) (int mode);
  742. void (*set_cmd) (void *handle, int *mode, unsigned int cmd_num);
  743. void (*set_lcm_cmd) (void *handle, unsigned int *lcm_cmd, unsigned int *lcm_count,
  744. unsigned int *lcm_value);
  745. /* /////////////PWM///////////////////////////// */
  746. void (*set_pwm_for_mix) (int enable);
  747. } LCM_DRIVER;
  748. /* --------------------------------------------------------------------------- */
  749. /* LCM Driver Functions */
  750. /* --------------------------------------------------------------------------- */
  751. const LCM_DRIVER *LCM_GetDriver(void);
  752. unsigned char which_lcd_module_triple(void);
  753. #endif /* __LCM_DRV_H__ */