PageRenderTime 27ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/include/video/exynos_mipi_dsim.h

https://github.com/mturquette/linux
C Header | 358 lines | 129 code | 30 blank | 199 comment | 0 complexity | f09676723cf6ee80d4ffeecb07417e98 MD5 | raw file
  1. /* include/video/exynos_mipi_dsim.h
  2. *
  3. * Platform data header for Samsung SoC MIPI-DSIM.
  4. *
  5. * Copyright (c) 2012 Samsung Electronics Co., Ltd
  6. *
  7. * InKi Dae <inki.dae@samsung.com>
  8. * Donghwa Lee <dh09.lee@samsung.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef _EXYNOS_MIPI_DSIM_H
  15. #define _EXYNOS_MIPI_DSIM_H
  16. #include <linux/device.h>
  17. #include <linux/fb.h>
  18. #define PANEL_NAME_SIZE (32)
  19. /*
  20. * Enumerate display interface type.
  21. *
  22. * DSIM_COMMAND means cpu interface and rgb interface for DSIM_VIDEO.
  23. *
  24. * P.S. MIPI DSI Master has two display controller intefaces, RGB Interface
  25. * for main display and CPU Interface(same as I80 Interface) for main
  26. * and sub display.
  27. */
  28. enum mipi_dsim_interface_type {
  29. DSIM_COMMAND,
  30. DSIM_VIDEO
  31. };
  32. enum mipi_dsim_virtual_ch_no {
  33. DSIM_VIRTUAL_CH_0,
  34. DSIM_VIRTUAL_CH_1,
  35. DSIM_VIRTUAL_CH_2,
  36. DSIM_VIRTUAL_CH_3
  37. };
  38. enum mipi_dsim_burst_mode_type {
  39. DSIM_NON_BURST_SYNC_EVENT,
  40. DSIM_BURST_SYNC_EVENT,
  41. DSIM_NON_BURST_SYNC_PULSE,
  42. DSIM_BURST,
  43. DSIM_NON_VIDEO_MODE
  44. };
  45. enum mipi_dsim_no_of_data_lane {
  46. DSIM_DATA_LANE_1,
  47. DSIM_DATA_LANE_2,
  48. DSIM_DATA_LANE_3,
  49. DSIM_DATA_LANE_4
  50. };
  51. enum mipi_dsim_byte_clk_src {
  52. DSIM_PLL_OUT_DIV8,
  53. DSIM_EXT_CLK_DIV8,
  54. DSIM_EXT_CLK_BYPASS
  55. };
  56. enum mipi_dsim_pixel_format {
  57. DSIM_CMD_3BPP,
  58. DSIM_CMD_8BPP,
  59. DSIM_CMD_12BPP,
  60. DSIM_CMD_16BPP,
  61. DSIM_VID_16BPP_565,
  62. DSIM_VID_18BPP_666PACKED,
  63. DSIM_18BPP_666LOOSELYPACKED,
  64. DSIM_24BPP_888
  65. };
  66. /*
  67. * struct mipi_dsim_config - interface for configuring mipi-dsi controller.
  68. *
  69. * @auto_flush: enable or disable Auto flush of MD FIFO using VSYNC pulse.
  70. * @eot_disable: enable or disable EoT packet in HS mode.
  71. * @auto_vertical_cnt: specifies auto vertical count mode.
  72. * in Video mode, the vertical line transition uses line counter
  73. * configured by VSA, VBP, and Vertical resolution.
  74. * If this bit is set to '1', the line counter does not use VSA and VBP
  75. * registers.(in command mode, this variable is ignored)
  76. * @hse: set horizontal sync event mode.
  77. * In VSYNC pulse and Vporch area, MIPI DSI master transfers only HSYNC
  78. * start packet to MIPI DSI slave at MIPI DSI spec1.1r02.
  79. * this bit transfers HSYNC end packet in VSYNC pulse and Vporch area
  80. * (in mommand mode, this variable is ignored)
  81. * @hfp: specifies HFP disable mode.
  82. * if this variable is set, DSI master ignores HFP area in VIDEO mode.
  83. * (in command mode, this variable is ignored)
  84. * @hbp: specifies HBP disable mode.
  85. * if this variable is set, DSI master ignores HBP area in VIDEO mode.
  86. * (in command mode, this variable is ignored)
  87. * @hsa: specifies HSA disable mode.
  88. * if this variable is set, DSI master ignores HSA area in VIDEO mode.
  89. * (in command mode, this variable is ignored)
  90. * @cma_allow: specifies the number of horizontal lines, where command packet
  91. * transmission is allowed after Stable VFP period.
  92. * @e_interface: specifies interface to be used.(CPU or RGB interface)
  93. * @e_virtual_ch: specifies virtual channel number that main or
  94. * sub diaplsy uses.
  95. * @e_pixel_format: specifies pixel stream format for main or sub display.
  96. * @e_burst_mode: selects Burst mode in Video mode.
  97. * in Non-burst mode, RGB data area is filled with RGB data and NULL
  98. * packets, according to input bandwidth of RGB interface.
  99. * In Burst mode, RGB data area is filled with RGB data only.
  100. * @e_no_data_lane: specifies data lane count to be used by Master.
  101. * @e_byte_clk: select byte clock source. (it must be DSIM_PLL_OUT_DIV8)
  102. * DSIM_EXT_CLK_DIV8 and DSIM_EXT_CLK_BYPASSS are not supported.
  103. * @pll_stable_time: specifies the PLL Timer for stability of the ganerated
  104. * clock(System clock cycle base)
  105. * if the timer value goes to 0x00000000, the clock stable bit of status
  106. * and interrupt register is set.
  107. * @esc_clk: specifies escape clock frequency for getting the escape clock
  108. * prescaler value.
  109. * @stop_holding_cnt: specifies the interval value between transmitting
  110. * read packet(or write "set_tear_on" command) and BTA request.
  111. * after transmitting read packet or write "set_tear_on" command,
  112. * BTA requests to D-PHY automatically. this counter value specifies
  113. * the interval between them.
  114. * @bta_timeout: specifies the timer for BTA.
  115. * this register specifies time out from BTA request to change
  116. * the direction with respect to Tx escape clock.
  117. * @rx_timeout: specifies the timer for LP Rx mode timeout.
  118. * this register specifies time out on how long RxValid deasserts,
  119. * after RxLpdt asserts with respect to Tx escape clock.
  120. * - RxValid specifies Rx data valid indicator.
  121. * - RxLpdt specifies an indicator that D-PHY is under RxLpdt mode.
  122. * - RxValid and RxLpdt specifies signal from D-PHY.
  123. */
  124. struct mipi_dsim_config {
  125. unsigned char auto_flush;
  126. unsigned char eot_disable;
  127. unsigned char auto_vertical_cnt;
  128. unsigned char hse;
  129. unsigned char hfp;
  130. unsigned char hbp;
  131. unsigned char hsa;
  132. unsigned char cmd_allow;
  133. enum mipi_dsim_interface_type e_interface;
  134. enum mipi_dsim_virtual_ch_no e_virtual_ch;
  135. enum mipi_dsim_pixel_format e_pixel_format;
  136. enum mipi_dsim_burst_mode_type e_burst_mode;
  137. enum mipi_dsim_no_of_data_lane e_no_data_lane;
  138. enum mipi_dsim_byte_clk_src e_byte_clk;
  139. /*
  140. * ===========================================
  141. * | P | M | S | MHz |
  142. * -------------------------------------------
  143. * | 3 | 100 | 3 | 100 |
  144. * | 3 | 100 | 2 | 200 |
  145. * | 3 | 63 | 1 | 252 |
  146. * | 4 | 100 | 1 | 300 |
  147. * | 4 | 110 | 1 | 330 |
  148. * | 12 | 350 | 1 | 350 |
  149. * | 3 | 100 | 1 | 400 |
  150. * | 4 | 150 | 1 | 450 |
  151. * | 6 | 118 | 1 | 472 |
  152. * | 3 | 120 | 1 | 480 |
  153. * | 12 | 250 | 0 | 500 |
  154. * | 4 | 100 | 0 | 600 |
  155. * | 3 | 81 | 0 | 648 |
  156. * | 3 | 88 | 0 | 704 |
  157. * | 3 | 90 | 0 | 720 |
  158. * | 3 | 100 | 0 | 800 |
  159. * | 12 | 425 | 0 | 850 |
  160. * | 4 | 150 | 0 | 900 |
  161. * | 12 | 475 | 0 | 950 |
  162. * | 6 | 250 | 0 | 1000 |
  163. * -------------------------------------------
  164. */
  165. /*
  166. * pms could be calculated as the following.
  167. * M * 24 / P * 2 ^ S = MHz
  168. */
  169. unsigned char p;
  170. unsigned short m;
  171. unsigned char s;
  172. unsigned int pll_stable_time;
  173. unsigned long esc_clk;
  174. unsigned short stop_holding_cnt;
  175. unsigned char bta_timeout;
  176. unsigned short rx_timeout;
  177. };
  178. /*
  179. * struct mipi_dsim_device - global interface for mipi-dsi driver.
  180. *
  181. * @dev: driver model representation of the device.
  182. * @id: unique device id.
  183. * @clock: pointer to MIPI-DSI clock of clock framework.
  184. * @irq: interrupt number to MIPI-DSI controller.
  185. * @reg_base: base address to memory mapped SRF of MIPI-DSI controller.
  186. * (virtual address)
  187. * @lock: the mutex protecting this data structure.
  188. * @dsim_info: infomation for configuring mipi-dsi controller.
  189. * @master_ops: callbacks to mipi-dsi operations.
  190. * @dsim_lcd_dev: pointer to activated ddi device.
  191. * (it would be registered by mipi-dsi driver.)
  192. * @dsim_lcd_drv: pointer to activated_ddi driver.
  193. * (it would be registered by mipi-dsi driver.)
  194. * @lcd_info: pointer to mipi_lcd_info structure.
  195. * @state: specifies status of MIPI-DSI controller.
  196. * the status could be RESET, INIT, STOP, HSCLKEN and ULPS.
  197. * @data_lane: specifiec enabled data lane number.
  198. * this variable would be set by driver according to e_no_data_lane
  199. * automatically.
  200. * @e_clk_src: select byte clock source.
  201. * @pd: pointer to MIPI-DSI driver platform data.
  202. * @phy: pointer to the MIPI-DSI PHY
  203. */
  204. struct mipi_dsim_device {
  205. struct device *dev;
  206. int id;
  207. struct clk *clock;
  208. unsigned int irq;
  209. void __iomem *reg_base;
  210. struct mutex lock;
  211. struct mipi_dsim_config *dsim_config;
  212. struct mipi_dsim_master_ops *master_ops;
  213. struct mipi_dsim_lcd_device *dsim_lcd_dev;
  214. struct mipi_dsim_lcd_driver *dsim_lcd_drv;
  215. unsigned int state;
  216. unsigned int data_lane;
  217. unsigned int e_clk_src;
  218. bool suspended;
  219. struct mipi_dsim_platform_data *pd;
  220. struct phy *phy;
  221. };
  222. /*
  223. * struct mipi_dsim_platform_data - interface to platform data
  224. * for mipi-dsi driver.
  225. *
  226. * @lcd_panel_name: specifies lcd panel name registered to mipi-dsi driver.
  227. * lcd panel driver searched would be actived.
  228. * @dsim_config: pointer of structure for configuring mipi-dsi controller.
  229. * @enabled: indicate whether mipi controller got enabled or not.
  230. * @lcd_panel_info: pointer for lcd panel specific structure.
  231. * this structure specifies width, height, timing and polarity and so on.
  232. */
  233. struct mipi_dsim_platform_data {
  234. char lcd_panel_name[PANEL_NAME_SIZE];
  235. struct mipi_dsim_config *dsim_config;
  236. unsigned int enabled;
  237. void *lcd_panel_info;
  238. };
  239. /*
  240. * struct mipi_dsim_master_ops - callbacks to mipi-dsi operations.
  241. *
  242. * @cmd_write: transfer command to lcd panel at LP mode.
  243. * @cmd_read: read command from rx register.
  244. * @get_dsim_frame_done: get the status that all screen data have been
  245. * transferred to mipi-dsi.
  246. * @clear_dsim_frame_done: clear frame done status.
  247. * @get_fb_frame_done: get frame done status of display controller.
  248. * @trigger: trigger display controller.
  249. * - this one would be used only in case of CPU mode.
  250. * @set_early_blank_mode: set framebuffer blank mode.
  251. * - this callback should be called prior to fb_blank() by a client driver
  252. * only if needing.
  253. * @set_blank_mode: set framebuffer blank mode.
  254. * - this callback should be called after fb_blank() by a client driver
  255. * only if needing.
  256. */
  257. struct mipi_dsim_master_ops {
  258. int (*cmd_write)(struct mipi_dsim_device *dsim, unsigned int data_id,
  259. const unsigned char *data0, unsigned int data1);
  260. int (*cmd_read)(struct mipi_dsim_device *dsim, unsigned int data_id,
  261. unsigned int data0, unsigned int req_size, u8 *rx_buf);
  262. int (*get_dsim_frame_done)(struct mipi_dsim_device *dsim);
  263. int (*clear_dsim_frame_done)(struct mipi_dsim_device *dsim);
  264. int (*get_fb_frame_done)(struct fb_info *info);
  265. void (*trigger)(struct fb_info *info);
  266. int (*set_early_blank_mode)(struct mipi_dsim_device *dsim, int power);
  267. int (*set_blank_mode)(struct mipi_dsim_device *dsim, int power);
  268. };
  269. /*
  270. * device structure for mipi-dsi based lcd panel.
  271. *
  272. * @name: name of the device to use with this device, or an
  273. * alias for that name.
  274. * @dev: driver model representation of the device.
  275. * @id: id of device to be registered.
  276. * @bus_id: bus id for identifing connected bus
  277. * and this bus id should be same as id of mipi_dsim_device.
  278. * @irq: irq number for signaling when framebuffer transfer of
  279. * lcd panel module is completed.
  280. * this irq would be used only for MIPI-DSI based CPU mode lcd panel.
  281. * @master: pointer to mipi-dsi master device object.
  282. * @platform_data: lcd panel specific platform data.
  283. */
  284. struct mipi_dsim_lcd_device {
  285. char *name;
  286. struct device dev;
  287. int id;
  288. int bus_id;
  289. int irq;
  290. int panel_reverse;
  291. struct mipi_dsim_device *master;
  292. void *platform_data;
  293. };
  294. /*
  295. * driver structure for mipi-dsi based lcd panel.
  296. *
  297. * this structure should be registered by lcd panel driver.
  298. * mipi-dsi driver seeks lcd panel registered through name field
  299. * and calls these callback functions in appropriate time.
  300. *
  301. * @name: name of the driver to use with this device, or an
  302. * alias for that name.
  303. * @id: id of driver to be registered.
  304. * this id would be used for finding device object registered.
  305. */
  306. struct mipi_dsim_lcd_driver {
  307. char *name;
  308. int id;
  309. void (*power_on)(struct mipi_dsim_lcd_device *dsim_dev, int enable);
  310. void (*set_sequence)(struct mipi_dsim_lcd_device *dsim_dev);
  311. int (*probe)(struct mipi_dsim_lcd_device *dsim_dev);
  312. int (*remove)(struct mipi_dsim_lcd_device *dsim_dev);
  313. void (*shutdown)(struct mipi_dsim_lcd_device *dsim_dev);
  314. int (*suspend)(struct mipi_dsim_lcd_device *dsim_dev);
  315. int (*resume)(struct mipi_dsim_lcd_device *dsim_dev);
  316. };
  317. /*
  318. * register mipi_dsim_lcd_device to mipi-dsi master.
  319. */
  320. int exynos_mipi_dsi_register_lcd_device(struct mipi_dsim_lcd_device
  321. *lcd_dev);
  322. /**
  323. * register mipi_dsim_lcd_driver object defined by lcd panel driver
  324. * to mipi-dsi driver.
  325. */
  326. int exynos_mipi_dsi_register_lcd_driver(struct mipi_dsim_lcd_driver
  327. *lcd_drv);
  328. #endif /* _EXYNOS_MIPI_DSIM_H */