dss.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. /*
  2. * linux/drivers/video/omap2/dss/dss.h
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  6. *
  7. * Some code and ideas taken from drivers/video/omap/ driver
  8. * by Imre Deak.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #ifndef __OMAP2_DSS_H
  23. #define __OMAP2_DSS_H
  24. #include <linux/interrupt.h>
  25. #ifdef pr_fmt
  26. #undef pr_fmt
  27. #endif
  28. #ifdef DSS_SUBSYS_NAME
  29. #define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
  30. #else
  31. #define pr_fmt(fmt) fmt
  32. #endif
  33. #define DSSDBG(format, ...) \
  34. pr_debug(format, ## __VA_ARGS__)
  35. #ifdef DSS_SUBSYS_NAME
  36. #define DSSERR(format, ...) \
  37. printk(KERN_ERR "omapdss " DSS_SUBSYS_NAME " error: " format, \
  38. ## __VA_ARGS__)
  39. #else
  40. #define DSSERR(format, ...) \
  41. printk(KERN_ERR "omapdss error: " format, ## __VA_ARGS__)
  42. #endif
  43. #ifdef DSS_SUBSYS_NAME
  44. #define DSSINFO(format, ...) \
  45. printk(KERN_INFO "omapdss " DSS_SUBSYS_NAME ": " format, \
  46. ## __VA_ARGS__)
  47. #else
  48. #define DSSINFO(format, ...) \
  49. printk(KERN_INFO "omapdss: " format, ## __VA_ARGS__)
  50. #endif
  51. #ifdef DSS_SUBSYS_NAME
  52. #define DSSWARN(format, ...) \
  53. printk(KERN_WARNING "omapdss " DSS_SUBSYS_NAME ": " format, \
  54. ## __VA_ARGS__)
  55. #else
  56. #define DSSWARN(format, ...) \
  57. printk(KERN_WARNING "omapdss: " format, ## __VA_ARGS__)
  58. #endif
  59. /* OMAP TRM gives bitfields as start:end, where start is the higher bit
  60. number. For example 7:0 */
  61. #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end))
  62. #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
  63. #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
  64. #define FLD_MOD(orig, val, start, end) \
  65. (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
  66. enum dss_io_pad_mode {
  67. DSS_IO_PAD_MODE_RESET,
  68. DSS_IO_PAD_MODE_RFBI,
  69. DSS_IO_PAD_MODE_BYPASS,
  70. };
  71. enum dss_hdmi_venc_clk_source_select {
  72. DSS_VENC_TV_CLK = 0,
  73. DSS_HDMI_M_PCLK = 1,
  74. };
  75. enum dss_dsi_content_type {
  76. DSS_DSI_CONTENT_DCS,
  77. DSS_DSI_CONTENT_GENERIC,
  78. };
  79. enum dss_writeback_channel {
  80. DSS_WB_LCD1_MGR = 0,
  81. DSS_WB_LCD2_MGR = 1,
  82. DSS_WB_TV_MGR = 2,
  83. DSS_WB_OVL0 = 3,
  84. DSS_WB_OVL1 = 4,
  85. DSS_WB_OVL2 = 5,
  86. DSS_WB_OVL3 = 6,
  87. DSS_WB_LCD3_MGR = 7,
  88. };
  89. struct dispc_clock_info {
  90. /* rates that we get with dividers below */
  91. unsigned long lck;
  92. unsigned long pck;
  93. /* dividers */
  94. u16 lck_div;
  95. u16 pck_div;
  96. };
  97. struct dsi_clock_info {
  98. /* rates that we get with dividers below */
  99. unsigned long fint;
  100. unsigned long clkin4ddr;
  101. unsigned long clkin;
  102. unsigned long dsi_pll_hsdiv_dispc_clk; /* OMAP3: DSI1_PLL_CLK
  103. * OMAP4: PLLx_CLK1 */
  104. unsigned long dsi_pll_hsdiv_dsi_clk; /* OMAP3: DSI2_PLL_CLK
  105. * OMAP4: PLLx_CLK2 */
  106. unsigned long lp_clk;
  107. /* dividers */
  108. u16 regn;
  109. u16 regm;
  110. u16 regm_dispc; /* OMAP3: REGM3
  111. * OMAP4: REGM4 */
  112. u16 regm_dsi; /* OMAP3: REGM4
  113. * OMAP4: REGM5 */
  114. u16 lp_clk_div;
  115. };
  116. struct dss_lcd_mgr_config {
  117. enum dss_io_pad_mode io_pad_mode;
  118. bool stallmode;
  119. bool fifohandcheck;
  120. struct dispc_clock_info clock_info;
  121. int video_port_width;
  122. int lcden_sig_polarity;
  123. };
  124. struct seq_file;
  125. struct platform_device;
  126. /* core */
  127. struct platform_device *dss_get_core_pdev(void);
  128. int dss_dsi_enable_pads(int dsi_id, unsigned lane_mask);
  129. void dss_dsi_disable_pads(int dsi_id, unsigned lane_mask);
  130. int dss_set_min_bus_tput(struct device *dev, unsigned long tput);
  131. int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
  132. /* display */
  133. int dss_suspend_all_devices(void);
  134. int dss_resume_all_devices(void);
  135. void dss_disable_all_devices(void);
  136. int display_init_sysfs(struct platform_device *pdev);
  137. void display_uninit_sysfs(struct platform_device *pdev);
  138. /* manager */
  139. int dss_init_overlay_managers(void);
  140. void dss_uninit_overlay_managers(void);
  141. int dss_init_overlay_managers_sysfs(struct platform_device *pdev);
  142. void dss_uninit_overlay_managers_sysfs(struct platform_device *pdev);
  143. int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
  144. const struct omap_overlay_manager_info *info);
  145. int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
  146. const struct omap_video_timings *timings);
  147. int dss_mgr_check(struct omap_overlay_manager *mgr,
  148. struct omap_overlay_manager_info *info,
  149. const struct omap_video_timings *mgr_timings,
  150. const struct dss_lcd_mgr_config *config,
  151. struct omap_overlay_info **overlay_infos);
  152. static inline bool dss_mgr_is_lcd(enum omap_channel id)
  153. {
  154. if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
  155. id == OMAP_DSS_CHANNEL_LCD3)
  156. return true;
  157. else
  158. return false;
  159. }
  160. int dss_manager_kobj_init(struct omap_overlay_manager *mgr,
  161. struct platform_device *pdev);
  162. void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr);
  163. /* overlay */
  164. void dss_init_overlays(struct platform_device *pdev);
  165. void dss_uninit_overlays(struct platform_device *pdev);
  166. void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr);
  167. int dss_ovl_simple_check(struct omap_overlay *ovl,
  168. const struct omap_overlay_info *info);
  169. int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info,
  170. const struct omap_video_timings *mgr_timings);
  171. bool dss_ovl_use_replication(struct dss_lcd_mgr_config config,
  172. enum omap_color_mode mode);
  173. int dss_overlay_kobj_init(struct omap_overlay *ovl,
  174. struct platform_device *pdev);
  175. void dss_overlay_kobj_uninit(struct omap_overlay *ovl);
  176. /* DSS */
  177. int dss_init_platform_driver(void) __init;
  178. void dss_uninit_platform_driver(void);
  179. unsigned long dss_get_dispc_clk_rate(void);
  180. int dss_dpi_select_source(enum omap_channel channel);
  181. void dss_select_hdmi_venc_clk_source(enum dss_hdmi_venc_clk_source_select);
  182. enum dss_hdmi_venc_clk_source_select dss_get_hdmi_venc_clk_source(void);
  183. const char *dss_get_generic_clk_source_name(enum omap_dss_clk_source clk_src);
  184. void dss_dump_clocks(struct seq_file *s);
  185. #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
  186. void dss_debug_dump_clocks(struct seq_file *s);
  187. #endif
  188. void dss_sdi_init(int datapairs);
  189. int dss_sdi_enable(void);
  190. void dss_sdi_disable(void);
  191. void dss_select_dsi_clk_source(int dsi_module,
  192. enum omap_dss_clk_source clk_src);
  193. void dss_select_lcd_clk_source(enum omap_channel channel,
  194. enum omap_dss_clk_source clk_src);
  195. enum omap_dss_clk_source dss_get_dispc_clk_source(void);
  196. enum omap_dss_clk_source dss_get_dsi_clk_source(int dsi_module);
  197. enum omap_dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
  198. void dss_set_venc_output(enum omap_dss_venc_type type);
  199. void dss_set_dac_pwrdn_bgz(bool enable);
  200. int dss_set_fck_rate(unsigned long rate);
  201. typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
  202. bool dss_div_calc(unsigned long pck, unsigned long fck_min,
  203. dss_div_calc_func func, void *data);
  204. /* SDI */
  205. int sdi_init_platform_driver(void) __init;
  206. void sdi_uninit_platform_driver(void) __exit;
  207. int sdi_init_port(struct platform_device *pdev, struct device_node *port) __init;
  208. void sdi_uninit_port(void) __exit;
  209. /* DSI */
  210. typedef bool (*dsi_pll_calc_func)(int regn, int regm, unsigned long fint,
  211. unsigned long pll, void *data);
  212. typedef bool (*dsi_hsdiv_calc_func)(int regm_dispc, unsigned long dispc,
  213. void *data);
  214. #ifdef CONFIG_OMAP2_DSS_DSI
  215. struct dentry;
  216. struct file_operations;
  217. int dsi_init_platform_driver(void) __init;
  218. void dsi_uninit_platform_driver(void) __exit;
  219. int dsi_runtime_get(struct platform_device *dsidev);
  220. void dsi_runtime_put(struct platform_device *dsidev);
  221. void dsi_dump_clocks(struct seq_file *s);
  222. void dsi_irq_handler(void);
  223. u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt);
  224. unsigned long dsi_get_pll_clkin(struct platform_device *dsidev);
  225. bool dsi_hsdiv_calc(struct platform_device *dsidev, unsigned long pll,
  226. unsigned long out_min, dsi_hsdiv_calc_func func, void *data);
  227. bool dsi_pll_calc(struct platform_device *dsidev, unsigned long clkin,
  228. unsigned long pll_min, unsigned long pll_max,
  229. dsi_pll_calc_func func, void *data);
  230. unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev);
  231. int dsi_pll_set_clock_div(struct platform_device *dsidev,
  232. struct dsi_clock_info *cinfo);
  233. int dsi_pll_init(struct platform_device *dsidev, bool enable_hsclk,
  234. bool enable_hsdiv);
  235. void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes);
  236. void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev);
  237. void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev);
  238. struct platform_device *dsi_get_dsidev_from_id(int module);
  239. #else
  240. static inline int dsi_runtime_get(struct platform_device *dsidev)
  241. {
  242. return 0;
  243. }
  244. static inline void dsi_runtime_put(struct platform_device *dsidev)
  245. {
  246. }
  247. static inline u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt)
  248. {
  249. WARN("%s: DSI not compiled in, returning pixel_size as 0\n", __func__);
  250. return 0;
  251. }
  252. static inline unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev)
  253. {
  254. WARN("%s: DSI not compiled in, returning rate as 0\n", __func__);
  255. return 0;
  256. }
  257. static inline int dsi_pll_set_clock_div(struct platform_device *dsidev,
  258. struct dsi_clock_info *cinfo)
  259. {
  260. WARN("%s: DSI not compiled in\n", __func__);
  261. return -ENODEV;
  262. }
  263. static inline int dsi_pll_init(struct platform_device *dsidev,
  264. bool enable_hsclk, bool enable_hsdiv)
  265. {
  266. WARN("%s: DSI not compiled in\n", __func__);
  267. return -ENODEV;
  268. }
  269. static inline void dsi_pll_uninit(struct platform_device *dsidev,
  270. bool disconnect_lanes)
  271. {
  272. }
  273. static inline void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev)
  274. {
  275. }
  276. static inline void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev)
  277. {
  278. }
  279. static inline struct platform_device *dsi_get_dsidev_from_id(int module)
  280. {
  281. return NULL;
  282. }
  283. static inline unsigned long dsi_get_pll_clkin(struct platform_device *dsidev)
  284. {
  285. return 0;
  286. }
  287. static inline bool dsi_hsdiv_calc(struct platform_device *dsidev,
  288. unsigned long pll, unsigned long out_min,
  289. dsi_hsdiv_calc_func func, void *data)
  290. {
  291. return false;
  292. }
  293. static inline bool dsi_pll_calc(struct platform_device *dsidev,
  294. unsigned long clkin,
  295. unsigned long pll_min, unsigned long pll_max,
  296. dsi_pll_calc_func func, void *data)
  297. {
  298. return false;
  299. }
  300. #endif
  301. /* DPI */
  302. int dpi_init_platform_driver(void) __init;
  303. void dpi_uninit_platform_driver(void) __exit;
  304. int dpi_init_port(struct platform_device *pdev, struct device_node *port) __init;
  305. void dpi_uninit_port(void) __exit;
  306. /* DISPC */
  307. int dispc_init_platform_driver(void) __init;
  308. void dispc_uninit_platform_driver(void) __exit;
  309. void dispc_dump_clocks(struct seq_file *s);
  310. void dispc_enable_sidle(void);
  311. void dispc_disable_sidle(void);
  312. void dispc_lcd_enable_signal(bool enable);
  313. void dispc_pck_free_enable(bool enable);
  314. void dispc_enable_fifomerge(bool enable);
  315. void dispc_enable_gamma_table(bool enable);
  316. void dispc_set_loadmode(enum omap_dss_load_mode mode);
  317. typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
  318. unsigned long pck, void *data);
  319. bool dispc_div_calc(unsigned long dispc,
  320. unsigned long pck_min, unsigned long pck_max,
  321. dispc_div_calc_func func, void *data);
  322. bool dispc_mgr_timings_ok(enum omap_channel channel,
  323. const struct omap_video_timings *timings);
  324. unsigned long dispc_fclk_rate(void);
  325. int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
  326. struct dispc_clock_info *cinfo);
  327. void dispc_ovl_set_fifo_threshold(enum omap_plane plane, u32 low, u32 high);
  328. void dispc_ovl_compute_fifo_thresholds(enum omap_plane plane,
  329. u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
  330. bool manual_update);
  331. unsigned long dispc_mgr_lclk_rate(enum omap_channel channel);
  332. unsigned long dispc_mgr_pclk_rate(enum omap_channel channel);
  333. unsigned long dispc_core_clk_rate(void);
  334. void dispc_mgr_set_clock_div(enum omap_channel channel,
  335. const struct dispc_clock_info *cinfo);
  336. int dispc_mgr_get_clock_div(enum omap_channel channel,
  337. struct dispc_clock_info *cinfo);
  338. void dispc_set_tv_pclk(unsigned long pclk);
  339. u32 dispc_wb_get_framedone_irq(void);
  340. bool dispc_wb_go_busy(void);
  341. void dispc_wb_go(void);
  342. void dispc_wb_enable(bool enable);
  343. bool dispc_wb_is_enabled(void);
  344. void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
  345. int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
  346. bool mem_to_mem, const struct omap_video_timings *timings);
  347. /* VENC */
  348. int venc_init_platform_driver(void) __init;
  349. void venc_uninit_platform_driver(void) __exit;
  350. /* HDMI */
  351. int hdmi4_init_platform_driver(void) __init;
  352. void hdmi4_uninit_platform_driver(void) __exit;
  353. int hdmi5_init_platform_driver(void) __init;
  354. void hdmi5_uninit_platform_driver(void) __exit;
  355. /* RFBI */
  356. int rfbi_init_platform_driver(void) __init;
  357. void rfbi_uninit_platform_driver(void) __exit;
  358. #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
  359. static inline void dss_collect_irq_stats(u32 irqstatus, unsigned *irq_arr)
  360. {
  361. int b;
  362. for (b = 0; b < 32; ++b) {
  363. if (irqstatus & (1 << b))
  364. irq_arr[b]++;
  365. }
  366. }
  367. #endif
  368. #endif