Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 1 | /* |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 2 | * Copyright (C) 2009 Nokia Corporation |
| 3 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> |
| 4 | * |
| 5 | * Some code and ideas taken from drivers/video/omap/ driver |
| 6 | * by Imre Deak. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 2 as published by |
| 10 | * the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | * more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #ifndef __OMAP2_DSS_H |
| 22 | #define __OMAP2_DSS_H |
| 23 | |
Tomi Valkeinen | 96e2e63 | 2012-10-10 15:55:19 +0300 | [diff] [blame] | 24 | #include <linux/interrupt.h> |
| 25 | |
Tomi Valkeinen | 35a339a | 2016-02-19 16:54:36 +0200 | [diff] [blame] | 26 | #include "omapdss.h" |
| 27 | |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 28 | struct dss_debugfs_entry; |
| 29 | struct platform_device; |
| 30 | struct seq_file; |
| 31 | |
Laurent Pinchart | d874b3a | 2017-08-05 01:44:19 +0300 | [diff] [blame] | 32 | #define MAX_DSS_LCD_MANAGERS 3 |
| 33 | #define MAX_NUM_DSI 2 |
| 34 | |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 35 | #ifdef pr_fmt |
| 36 | #undef pr_fmt |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 37 | #endif |
| 38 | |
| 39 | #ifdef DSS_SUBSYS_NAME |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 40 | #define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 41 | #else |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 42 | #define pr_fmt(fmt) fmt |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 43 | #endif |
| 44 | |
Chandrabhanu Mahapatra | 702d267 | 2012-09-24 17:12:58 +0530 | [diff] [blame] | 45 | #define DSSDBG(format, ...) \ |
| 46 | pr_debug(format, ## __VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 47 | |
| 48 | #ifdef DSS_SUBSYS_NAME |
| 49 | #define DSSERR(format, ...) \ |
Joe Perches | 8dfe162 | 2017-02-28 04:55:54 -0800 | [diff] [blame] | 50 | pr_err("omapdss " DSS_SUBSYS_NAME " error: " format, ##__VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 51 | #else |
| 52 | #define DSSERR(format, ...) \ |
Joe Perches | 8dfe162 | 2017-02-28 04:55:54 -0800 | [diff] [blame] | 53 | pr_err("omapdss error: " format, ##__VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 54 | #endif |
| 55 | |
| 56 | #ifdef DSS_SUBSYS_NAME |
| 57 | #define DSSINFO(format, ...) \ |
Joe Perches | 8dfe162 | 2017-02-28 04:55:54 -0800 | [diff] [blame] | 58 | pr_info("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 59 | #else |
| 60 | #define DSSINFO(format, ...) \ |
Joe Perches | 8dfe162 | 2017-02-28 04:55:54 -0800 | [diff] [blame] | 61 | pr_info("omapdss: " format, ## __VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 62 | #endif |
| 63 | |
| 64 | #ifdef DSS_SUBSYS_NAME |
| 65 | #define DSSWARN(format, ...) \ |
Joe Perches | 8dfe162 | 2017-02-28 04:55:54 -0800 | [diff] [blame] | 66 | pr_warn("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 67 | #else |
| 68 | #define DSSWARN(format, ...) \ |
Joe Perches | 8dfe162 | 2017-02-28 04:55:54 -0800 | [diff] [blame] | 69 | pr_warn("omapdss: " format, ##__VA_ARGS__) |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 70 | #endif |
| 71 | |
| 72 | /* OMAP TRM gives bitfields as start:end, where start is the higher bit |
| 73 | number. For example 7:0 */ |
| 74 | #define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end)) |
| 75 | #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end)) |
| 76 | #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end)) |
| 77 | #define FLD_MOD(orig, val, start, end) \ |
| 78 | (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end)) |
| 79 | |
Laurent Pinchart | b8dab2b | 2017-08-05 01:43:56 +0300 | [diff] [blame] | 80 | enum dss_model { |
| 81 | DSS_MODEL_OMAP2, |
| 82 | DSS_MODEL_OMAP3, |
| 83 | DSS_MODEL_OMAP4, |
| 84 | DSS_MODEL_OMAP5, |
| 85 | DSS_MODEL_DRA7, |
| 86 | }; |
| 87 | |
Archit Taneja | 569969d | 2011-08-22 17:41:57 +0530 | [diff] [blame] | 88 | enum dss_io_pad_mode { |
| 89 | DSS_IO_PAD_MODE_RESET, |
| 90 | DSS_IO_PAD_MODE_RFBI, |
| 91 | DSS_IO_PAD_MODE_BYPASS, |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 92 | }; |
| 93 | |
Mythri P K | 7ed024a | 2011-03-09 16:31:38 +0530 | [diff] [blame] | 94 | enum dss_hdmi_venc_clk_source_select { |
| 95 | DSS_VENC_TV_CLK = 0, |
| 96 | DSS_HDMI_M_PCLK = 1, |
| 97 | }; |
| 98 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 99 | enum dss_dsi_content_type { |
| 100 | DSS_DSI_CONTENT_DCS, |
| 101 | DSS_DSI_CONTENT_GENERIC, |
| 102 | }; |
| 103 | |
Archit Taneja | d9ac773 | 2012-09-22 12:38:19 +0530 | [diff] [blame] | 104 | enum dss_writeback_channel { |
| 105 | DSS_WB_LCD1_MGR = 0, |
| 106 | DSS_WB_LCD2_MGR = 1, |
| 107 | DSS_WB_TV_MGR = 2, |
| 108 | DSS_WB_OVL0 = 3, |
| 109 | DSS_WB_OVL1 = 4, |
| 110 | DSS_WB_OVL2 = 5, |
| 111 | DSS_WB_OVL3 = 6, |
| 112 | DSS_WB_LCD3_MGR = 7, |
| 113 | }; |
| 114 | |
Tomi Valkeinen | dc0352d | 2016-05-17 13:45:09 +0300 | [diff] [blame] | 115 | enum dss_clk_source { |
Tomi Valkeinen | 3b63ca7 | 2016-05-17 14:01:10 +0300 | [diff] [blame] | 116 | DSS_CLK_SRC_FCK = 0, |
| 117 | |
| 118 | DSS_CLK_SRC_PLL1_1, |
| 119 | DSS_CLK_SRC_PLL1_2, |
Tomi Valkeinen | b5d8c75 | 2016-05-17 14:12:35 +0300 | [diff] [blame] | 120 | DSS_CLK_SRC_PLL1_3, |
Tomi Valkeinen | 3b63ca7 | 2016-05-17 14:01:10 +0300 | [diff] [blame] | 121 | |
| 122 | DSS_CLK_SRC_PLL2_1, |
| 123 | DSS_CLK_SRC_PLL2_2, |
Tomi Valkeinen | b5d8c75 | 2016-05-17 14:12:35 +0300 | [diff] [blame] | 124 | DSS_CLK_SRC_PLL2_3, |
| 125 | |
| 126 | DSS_CLK_SRC_HDMI_PLL, |
Tomi Valkeinen | be5d731 | 2016-05-17 13:31:14 +0300 | [diff] [blame] | 127 | }; |
| 128 | |
Tomi Valkeinen | 64e22ff | 2015-01-02 10:05:33 +0200 | [diff] [blame] | 129 | enum dss_pll_id { |
| 130 | DSS_PLL_DSI1, |
| 131 | DSS_PLL_DSI2, |
| 132 | DSS_PLL_HDMI, |
Tomi Valkeinen | 6d81788 | 2014-12-31 11:23:31 +0200 | [diff] [blame] | 133 | DSS_PLL_VIDEO1, |
| 134 | DSS_PLL_VIDEO2, |
Tomi Valkeinen | 64e22ff | 2015-01-02 10:05:33 +0200 | [diff] [blame] | 135 | }; |
| 136 | |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 137 | struct dss_pll; |
| 138 | |
| 139 | #define DSS_PLL_MAX_HSDIVS 4 |
| 140 | |
Tomi Valkeinen | 06ede3d | 2016-05-18 10:48:44 +0300 | [diff] [blame] | 141 | enum dss_pll_type { |
| 142 | DSS_PLL_TYPE_A, |
| 143 | DSS_PLL_TYPE_B, |
| 144 | }; |
| 145 | |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 146 | /* |
| 147 | * Type-A PLLs: clkout[]/mX[] refer to hsdiv outputs m4, m5, m6, m7. |
| 148 | * Type-B PLLs: clkout[0] refers to m2. |
| 149 | */ |
| 150 | struct dss_pll_clock_info { |
| 151 | /* rates that we get with dividers below */ |
| 152 | unsigned long fint; |
| 153 | unsigned long clkdco; |
| 154 | unsigned long clkout[DSS_PLL_MAX_HSDIVS]; |
| 155 | |
| 156 | /* dividers */ |
| 157 | u16 n; |
| 158 | u16 m; |
| 159 | u32 mf; |
| 160 | u16 mX[DSS_PLL_MAX_HSDIVS]; |
| 161 | u16 sd; |
| 162 | }; |
| 163 | |
| 164 | struct dss_pll_ops { |
| 165 | int (*enable)(struct dss_pll *pll); |
| 166 | void (*disable)(struct dss_pll *pll); |
| 167 | int (*set_config)(struct dss_pll *pll, |
| 168 | const struct dss_pll_clock_info *cinfo); |
| 169 | }; |
| 170 | |
| 171 | struct dss_pll_hw { |
Tomi Valkeinen | 06ede3d | 2016-05-18 10:48:44 +0300 | [diff] [blame] | 172 | enum dss_pll_type type; |
| 173 | |
Laurent Pinchart | d11e5c8 | 2018-02-11 15:07:34 +0200 | [diff] [blame] | 174 | unsigned int n_max; |
| 175 | unsigned int m_min; |
| 176 | unsigned int m_max; |
| 177 | unsigned int mX_max; |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 178 | |
| 179 | unsigned long fint_min, fint_max; |
| 180 | unsigned long clkdco_min, clkdco_low, clkdco_max; |
| 181 | |
| 182 | u8 n_msb, n_lsb; |
| 183 | u8 m_msb, m_lsb; |
| 184 | u8 mX_msb[DSS_PLL_MAX_HSDIVS], mX_lsb[DSS_PLL_MAX_HSDIVS]; |
| 185 | |
| 186 | bool has_stopmode; |
| 187 | bool has_freqsel; |
| 188 | bool has_selfreqdco; |
| 189 | bool has_refsel; |
Tomi Valkeinen | 0c43f1e0 | 2017-06-13 12:02:10 +0300 | [diff] [blame] | 190 | |
| 191 | /* DRA7 errata i886: use high N & M to avoid jitter */ |
| 192 | bool errata_i886; |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 193 | }; |
| 194 | |
| 195 | struct dss_pll { |
| 196 | const char *name; |
Tomi Valkeinen | 64e22ff | 2015-01-02 10:05:33 +0200 | [diff] [blame] | 197 | enum dss_pll_id id; |
Laurent Pinchart | 7b29525 | 2018-02-13 14:00:21 +0200 | [diff] [blame] | 198 | struct dss_device *dss; |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 199 | |
| 200 | struct clk *clkin; |
| 201 | struct regulator *regulator; |
| 202 | |
| 203 | void __iomem *base; |
| 204 | |
| 205 | const struct dss_pll_hw *hw; |
| 206 | |
| 207 | const struct dss_pll_ops *ops; |
| 208 | |
| 209 | struct dss_pll_clock_info cinfo; |
| 210 | }; |
| 211 | |
Laurent Pinchart | 6d85d4a | 2017-08-05 01:44:07 +0300 | [diff] [blame] | 212 | /* Defines a generic omap register field */ |
| 213 | struct dss_reg_field { |
| 214 | u8 start, end; |
| 215 | }; |
| 216 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 217 | struct dispc_clock_info { |
| 218 | /* rates that we get with dividers below */ |
| 219 | unsigned long lck; |
| 220 | unsigned long pck; |
| 221 | |
| 222 | /* dividers */ |
| 223 | u16 lck_div; |
| 224 | u16 pck_div; |
| 225 | }; |
| 226 | |
Archit Taneja | c56fb3e | 2012-06-29 14:03:48 +0530 | [diff] [blame] | 227 | struct dss_lcd_mgr_config { |
| 228 | enum dss_io_pad_mode io_pad_mode; |
| 229 | |
| 230 | bool stallmode; |
| 231 | bool fifohandcheck; |
| 232 | |
| 233 | struct dispc_clock_info clock_info; |
| 234 | |
| 235 | int video_port_width; |
| 236 | |
| 237 | int lcden_sig_polarity; |
| 238 | }; |
| 239 | |
Laurent Pinchart | 0e546df | 2018-02-13 14:00:20 +0200 | [diff] [blame] | 240 | #define DSS_SZ_REGS SZ_512 |
| 241 | |
| 242 | struct dss_device { |
| 243 | struct platform_device *pdev; |
| 244 | void __iomem *base; |
| 245 | struct regmap *syscon_pll_ctrl; |
| 246 | u32 syscon_pll_ctrl_offset; |
| 247 | |
| 248 | struct clk *parent_clk; |
| 249 | struct clk *dss_clk; |
| 250 | unsigned long dss_clk_rate; |
| 251 | |
| 252 | unsigned long cache_req_pck; |
| 253 | unsigned long cache_prate; |
| 254 | struct dispc_clock_info cache_dispc_cinfo; |
| 255 | |
| 256 | enum dss_clk_source dsi_clk_source[MAX_NUM_DSI]; |
| 257 | enum dss_clk_source dispc_clk_source; |
| 258 | enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS]; |
| 259 | |
| 260 | bool ctx_valid; |
| 261 | u32 ctx[DSS_SZ_REGS / sizeof(u32)]; |
| 262 | |
| 263 | const struct dss_features *feat; |
| 264 | |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 265 | struct { |
Laurent Pinchart | 1c4b92e | 2018-02-13 14:00:31 +0200 | [diff] [blame] | 266 | struct dentry *root; |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 267 | struct dss_debugfs_entry *clk; |
| 268 | struct dss_debugfs_entry *dss; |
| 269 | } debugfs; |
| 270 | |
Laurent Pinchart | 798957a | 2018-02-13 14:00:30 +0200 | [diff] [blame] | 271 | struct dss_pll *plls[4]; |
Laurent Pinchart | 0e546df | 2018-02-13 14:00:20 +0200 | [diff] [blame] | 272 | struct dss_pll *video1_pll; |
| 273 | struct dss_pll *video2_pll; |
Laurent Pinchart | d3541ca | 2018-02-13 14:00:41 +0200 | [diff] [blame^] | 274 | |
| 275 | const struct dispc_ops *dispc_ops; |
Laurent Pinchart | 0e546df | 2018-02-13 14:00:20 +0200 | [diff] [blame] | 276 | }; |
| 277 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 278 | /* core */ |
Laurent Pinchart | 493b683 | 2017-08-05 01:43:54 +0300 | [diff] [blame] | 279 | static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput) |
| 280 | { |
| 281 | /* To be implemented when the OMAP platform will provide this feature */ |
| 282 | return 0; |
| 283 | } |
| 284 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 285 | static inline bool dss_mgr_is_lcd(enum omap_channel id) |
| 286 | { |
| 287 | if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 || |
| 288 | id == OMAP_DSS_CHANNEL_LCD3) |
| 289 | return true; |
| 290 | else |
| 291 | return false; |
| 292 | } |
| 293 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 294 | /* DSS */ |
Laurent Pinchart | 11765d1 | 2017-08-05 01:44:01 +0300 | [diff] [blame] | 295 | #if defined(CONFIG_OMAP2_DSS_DEBUGFS) |
Laurent Pinchart | 1c4b92e | 2018-02-13 14:00:31 +0200 | [diff] [blame] | 296 | struct dss_debugfs_entry * |
| 297 | dss_debugfs_create_file(struct dss_device *dss, const char *name, |
| 298 | int (*show_fn)(struct seq_file *s, void *data), |
| 299 | void *data); |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 300 | void dss_debugfs_remove_file(struct dss_debugfs_entry *entry); |
Laurent Pinchart | 11765d1 | 2017-08-05 01:44:01 +0300 | [diff] [blame] | 301 | #else |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 302 | static inline struct dss_debugfs_entry * |
Laurent Pinchart | 1c4b92e | 2018-02-13 14:00:31 +0200 | [diff] [blame] | 303 | dss_debugfs_create_file(struct dss_device *dss, const char *name, |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 304 | int (*show_fn)(struct seq_file *s, void *data), |
| 305 | void *data) |
Laurent Pinchart | 11765d1 | 2017-08-05 01:44:01 +0300 | [diff] [blame] | 306 | { |
Laurent Pinchart | f33656e | 2018-02-13 14:00:29 +0200 | [diff] [blame] | 307 | return NULL; |
| 308 | } |
| 309 | |
| 310 | static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry) |
| 311 | { |
Laurent Pinchart | 11765d1 | 2017-08-05 01:44:01 +0300 | [diff] [blame] | 312 | } |
| 313 | #endif /* CONFIG_OMAP2_DSS_DEBUGFS */ |
| 314 | |
Laurent Pinchart | 7b29525 | 2018-02-13 14:00:21 +0200 | [diff] [blame] | 315 | struct dss_device *dss_get_device(struct device *dev); |
| 316 | |
| 317 | int dss_runtime_get(struct dss_device *dss); |
| 318 | void dss_runtime_put(struct dss_device *dss); |
Tomi Valkeinen | 9976754 | 2014-07-04 13:38:27 +0530 | [diff] [blame] | 319 | |
Laurent Pinchart | 60f9c59 | 2018-02-13 14:00:26 +0200 | [diff] [blame] | 320 | unsigned long dss_get_dispc_clk_rate(struct dss_device *dss); |
| 321 | unsigned long dss_get_max_fck_rate(struct dss_device *dss); |
Laurent Pinchart | 1ef904e | 2018-02-13 14:00:27 +0200 | [diff] [blame] | 322 | enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss, |
| 323 | enum omap_channel channel); |
Laurent Pinchart | 8aea8e6 | 2018-02-13 14:00:24 +0200 | [diff] [blame] | 324 | int dss_dpi_select_source(struct dss_device *dss, int port, |
| 325 | enum omap_channel channel); |
| 326 | void dss_select_hdmi_venc_clk_source(struct dss_device *dss, |
| 327 | enum dss_hdmi_venc_clk_source_select src); |
Tomi Valkeinen | 407bd56 | 2016-05-17 13:50:55 +0300 | [diff] [blame] | 328 | const char *dss_get_clk_source_name(enum dss_clk_source clk_src); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 329 | |
Tomi Valkeinen | 9976754 | 2014-07-04 13:38:27 +0530 | [diff] [blame] | 330 | /* DSS VIDEO PLL */ |
Laurent Pinchart | 7b29525 | 2018-02-13 14:00:21 +0200 | [diff] [blame] | 331 | struct dss_pll *dss_video_pll_init(struct dss_device *dss, |
| 332 | struct platform_device *pdev, int id, |
| 333 | struct regulator *regulator); |
Tomi Valkeinen | 9976754 | 2014-07-04 13:38:27 +0530 | [diff] [blame] | 334 | void dss_video_pll_uninit(struct dss_pll *pll); |
| 335 | |
Laurent Pinchart | 2726099 | 2018-02-13 14:00:22 +0200 | [diff] [blame] | 336 | void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable); |
Tomi Valkeinen | be40eec | 2014-07-04 13:37:15 +0530 | [diff] [blame] | 337 | |
Laurent Pinchart | d7157df | 2018-02-13 14:00:23 +0200 | [diff] [blame] | 338 | void dss_sdi_init(struct dss_device *dss, int datapairs); |
| 339 | int dss_sdi_enable(struct dss_device *dss); |
| 340 | void dss_sdi_disable(struct dss_device *dss); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 341 | |
Laurent Pinchart | 8aea8e6 | 2018-02-13 14:00:24 +0200 | [diff] [blame] | 342 | void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module, |
| 343 | enum dss_clk_source clk_src); |
| 344 | void dss_select_lcd_clk_source(struct dss_device *dss, |
| 345 | enum omap_channel channel, |
| 346 | enum dss_clk_source clk_src); |
Laurent Pinchart | 3cc62aa | 2018-02-13 14:00:25 +0200 | [diff] [blame] | 347 | enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss); |
| 348 | enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss, |
| 349 | int dsi_module); |
| 350 | enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss, |
| 351 | enum omap_channel channel); |
Tomi Valkeinen | 2f18c4d | 2010-01-08 18:00:36 +0200 | [diff] [blame] | 352 | |
Laurent Pinchart | 1ef904e | 2018-02-13 14:00:27 +0200 | [diff] [blame] | 353 | void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type); |
| 354 | void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 355 | |
Laurent Pinchart | 60f9c59 | 2018-02-13 14:00:26 +0200 | [diff] [blame] | 356 | int dss_set_fck_rate(struct dss_device *dss, unsigned long rate); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 357 | |
Tomi Valkeinen | d0f58bd | 2013-10-31 14:44:23 +0200 | [diff] [blame] | 358 | typedef bool (*dss_div_calc_func)(unsigned long fck, void *data); |
Laurent Pinchart | 60f9c59 | 2018-02-13 14:00:26 +0200 | [diff] [blame] | 359 | bool dss_div_calc(struct dss_device *dss, unsigned long pck, |
| 360 | unsigned long fck_min, dss_div_calc_func func, void *data); |
Tomi Valkeinen | 4341782 | 2013-03-05 16:34:05 +0200 | [diff] [blame] | 361 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 362 | /* SDI */ |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 363 | #ifdef CONFIG_OMAP2_DSS_SDI |
Laurent Pinchart | d7157df | 2018-02-13 14:00:23 +0200 | [diff] [blame] | 364 | int sdi_init_port(struct dss_device *dss, struct platform_device *pdev, |
| 365 | struct device_node *port); |
Tomi Valkeinen | ede9269 | 2015-06-04 14:12:16 +0300 | [diff] [blame] | 366 | void sdi_uninit_port(struct device_node *port); |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 367 | #else |
Laurent Pinchart | d7157df | 2018-02-13 14:00:23 +0200 | [diff] [blame] | 368 | static inline int sdi_init_port(struct dss_device *dss, |
| 369 | struct platform_device *pdev, |
| 370 | struct device_node *port) |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 371 | { |
| 372 | return 0; |
| 373 | } |
Tomi Valkeinen | ede9269 | 2015-06-04 14:12:16 +0300 | [diff] [blame] | 374 | static inline void sdi_uninit_port(struct device_node *port) |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 375 | { |
| 376 | } |
| 377 | #endif |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 378 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 379 | /* DSI */ |
Tomi Valkeinen | 989c79a | 2013-04-18 12:16:39 +0300 | [diff] [blame] | 380 | |
Jani Nikula | 368a148 | 2010-05-07 11:58:41 +0200 | [diff] [blame] | 381 | #ifdef CONFIG_OMAP2_DSS_DSI |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 382 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 383 | void dsi_dump_clocks(struct seq_file *s); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 384 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 385 | void dsi_irq_handler(void); |
Archit Taneja | a3b3cc2 | 2011-09-08 18:42:16 +0530 | [diff] [blame] | 386 | |
Jani Nikula | 368a148 | 2010-05-07 11:58:41 +0200 | [diff] [blame] | 387 | #endif |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 388 | |
| 389 | /* DPI */ |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 390 | #ifdef CONFIG_OMAP2_DSS_DPI |
Laurent Pinchart | 8aea8e6 | 2018-02-13 14:00:24 +0200 | [diff] [blame] | 391 | int dpi_init_port(struct dss_device *dss, struct platform_device *pdev, |
| 392 | struct device_node *port, enum dss_model dss_model); |
Tomi Valkeinen | ede9269 | 2015-06-04 14:12:16 +0300 | [diff] [blame] | 393 | void dpi_uninit_port(struct device_node *port); |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 394 | #else |
Laurent Pinchart | 8aea8e6 | 2018-02-13 14:00:24 +0200 | [diff] [blame] | 395 | static inline int dpi_init_port(struct dss_device *port, |
| 396 | struct platform_device *pdev, |
| 397 | struct device_node *port, |
| 398 | enum dss_model dss_model) |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 399 | { |
| 400 | return 0; |
| 401 | } |
Tomi Valkeinen | ede9269 | 2015-06-04 14:12:16 +0300 | [diff] [blame] | 402 | static inline void dpi_uninit_port(struct device_node *port) |
Archit Taneja | 387ce9f | 2014-05-22 17:01:57 +0530 | [diff] [blame] | 403 | { |
| 404 | } |
| 405 | #endif |
Tomi Valkeinen | 2ecef24 | 2013-12-16 15:13:24 +0200 | [diff] [blame] | 406 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 407 | /* DISPC */ |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 408 | void dispc_dump_clocks(struct seq_file *s); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 409 | |
Tomi Valkeinen | 5034b1f | 2015-11-05 20:06:06 +0200 | [diff] [blame] | 410 | int dispc_runtime_get(void); |
| 411 | void dispc_runtime_put(void); |
| 412 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 413 | void dispc_enable_sidle(void); |
| 414 | void dispc_disable_sidle(void); |
| 415 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 416 | void dispc_lcd_enable_signal(bool enable); |
| 417 | void dispc_pck_free_enable(bool enable); |
Tomi Valkeinen | cd295ae | 2011-08-16 13:49:15 +0300 | [diff] [blame] | 418 | void dispc_enable_fifomerge(bool enable); |
Tomi Valkeinen | cd295ae | 2011-08-16 13:49:15 +0300 | [diff] [blame] | 419 | |
Tomi Valkeinen | 7c284e6 | 2013-03-05 16:32:08 +0200 | [diff] [blame] | 420 | typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck, |
| 421 | unsigned long pck, void *data); |
| 422 | bool dispc_div_calc(unsigned long dispc, |
| 423 | unsigned long pck_min, unsigned long pck_max, |
| 424 | dispc_div_calc_func func, void *data); |
| 425 | |
Peter Ujfalusi | da11bbbb | 2016-09-22 14:07:04 +0300 | [diff] [blame] | 426 | bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm); |
Tomi Valkeinen | cd295ae | 2011-08-16 13:49:15 +0300 | [diff] [blame] | 427 | int dispc_calc_clock_rates(unsigned long dispc_fclk_rate, |
| 428 | struct dispc_clock_info *cinfo); |
| 429 | |
| 430 | |
Jyri Sarha | 864050c | 2017-03-24 16:47:52 +0200 | [diff] [blame] | 431 | void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low, |
| 432 | u32 high); |
| 433 | void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane, |
Tomi Valkeinen | 3568f2a | 2012-05-15 15:31:01 +0300 | [diff] [blame] | 434 | u32 *fifo_low, u32 *fifo_high, bool use_fifomerge, |
| 435 | bool manual_update); |
Tomi Valkeinen | cd295ae | 2011-08-16 13:49:15 +0300 | [diff] [blame] | 436 | |
Archit Taneja | f0d08f8 | 2012-06-29 14:00:54 +0530 | [diff] [blame] | 437 | void dispc_mgr_set_clock_div(enum omap_channel channel, |
Tomi Valkeinen | a8f3fcd | 2012-10-03 09:09:11 +0200 | [diff] [blame] | 438 | const struct dispc_clock_info *cinfo); |
Tomi Valkeinen | 26d9dd0 | 2011-08-16 13:45:15 +0300 | [diff] [blame] | 439 | int dispc_mgr_get_clock_div(enum omap_channel channel, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 440 | struct dispc_clock_info *cinfo); |
Tomi Valkeinen | 5391e87 | 2013-05-16 10:44:13 +0300 | [diff] [blame] | 441 | void dispc_set_tv_pclk(unsigned long pclk); |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 442 | |
Archit Taneja | 0b23e5b | 2012-09-22 12:39:33 +0530 | [diff] [blame] | 443 | u32 dispc_wb_get_framedone_irq(void); |
| 444 | bool dispc_wb_go_busy(void); |
| 445 | void dispc_wb_go(void); |
Archit Taneja | d9ac773 | 2012-09-22 12:38:19 +0530 | [diff] [blame] | 446 | void dispc_wb_set_channel_in(enum dss_writeback_channel channel); |
Archit Taneja | 749feff | 2012-08-31 12:32:52 +0530 | [diff] [blame] | 447 | int dispc_wb_setup(const struct omap_dss_writeback_info *wi, |
Peter Ujfalusi | da11bbbb | 2016-09-22 14:07:04 +0300 | [diff] [blame] | 448 | bool mem_to_mem, const struct videomode *vm); |
Archit Taneja | d9ac773 | 2012-09-22 12:38:19 +0530 | [diff] [blame] | 449 | |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 450 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
Laurent Pinchart | d11e5c8 | 2018-02-11 15:07:34 +0200 | [diff] [blame] | 451 | static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr) |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 452 | { |
| 453 | int b; |
| 454 | for (b = 0; b < 32; ++b) { |
| 455 | if (irqstatus & (1 << b)) |
| 456 | irq_arr[b]++; |
| 457 | } |
| 458 | } |
| 459 | #endif |
| 460 | |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 461 | /* PLL */ |
| 462 | typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint, |
| 463 | unsigned long clkdco, void *data); |
| 464 | typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc, |
| 465 | void *data); |
| 466 | |
Laurent Pinchart | 798957a | 2018-02-13 14:00:30 +0200 | [diff] [blame] | 467 | int dss_pll_register(struct dss_device *dss, struct dss_pll *pll); |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 468 | void dss_pll_unregister(struct dss_pll *pll); |
Laurent Pinchart | 798957a | 2018-02-13 14:00:30 +0200 | [diff] [blame] | 469 | struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name); |
| 470 | struct dss_pll *dss_pll_find_by_src(struct dss_device *dss, |
| 471 | enum dss_clk_source src); |
Laurent Pinchart | d11e5c8 | 2018-02-11 15:07:34 +0200 | [diff] [blame] | 472 | unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src); |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 473 | int dss_pll_enable(struct dss_pll *pll); |
| 474 | void dss_pll_disable(struct dss_pll *pll); |
| 475 | int dss_pll_set_config(struct dss_pll *pll, |
| 476 | const struct dss_pll_clock_info *cinfo); |
| 477 | |
Tomi Valkeinen | cd0715f | 2016-05-17 21:23:37 +0300 | [diff] [blame] | 478 | bool dss_pll_hsdiv_calc_a(const struct dss_pll *pll, unsigned long clkdco, |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 479 | unsigned long out_min, unsigned long out_max, |
| 480 | dss_hsdiv_calc_func func, void *data); |
Tomi Valkeinen | cd0715f | 2016-05-17 21:23:37 +0300 | [diff] [blame] | 481 | bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin, |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 482 | unsigned long pll_min, unsigned long pll_max, |
| 483 | dss_pll_calc_func func, void *data); |
Tomi Valkeinen | c17dc0e | 2016-05-18 10:45:20 +0300 | [diff] [blame] | 484 | |
| 485 | bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin, |
Tomi Valkeinen | c107751 | 2016-05-18 11:15:21 +0300 | [diff] [blame] | 486 | unsigned long target_clkout, struct dss_pll_clock_info *cinfo); |
Tomi Valkeinen | c17dc0e | 2016-05-18 10:45:20 +0300 | [diff] [blame] | 487 | |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 488 | int dss_pll_write_config_type_a(struct dss_pll *pll, |
| 489 | const struct dss_pll_clock_info *cinfo); |
| 490 | int dss_pll_write_config_type_b(struct dss_pll *pll, |
| 491 | const struct dss_pll_clock_info *cinfo); |
Tomi Valkeinen | eb30199 | 2014-12-31 14:22:42 +0200 | [diff] [blame] | 492 | int dss_pll_wait_reset_done(struct dss_pll *pll); |
Tomi Valkeinen | 0a20170 | 2014-10-22 14:21:59 +0300 | [diff] [blame] | 493 | |
Andrew F. Davis | d66c36a | 2017-12-05 14:29:32 -0600 | [diff] [blame] | 494 | extern struct platform_driver omap_dsshw_driver; |
| 495 | extern struct platform_driver omap_dispchw_driver; |
| 496 | #ifdef CONFIG_OMAP2_DSS_DSI |
| 497 | extern struct platform_driver omap_dsihw_driver; |
| 498 | #endif |
| 499 | #ifdef CONFIG_OMAP2_DSS_VENC |
| 500 | extern struct platform_driver omap_venchw_driver; |
| 501 | #endif |
| 502 | #ifdef CONFIG_OMAP4_DSS_HDMI |
| 503 | extern struct platform_driver omapdss_hdmi4hw_driver; |
| 504 | #endif |
| 505 | #ifdef CONFIG_OMAP5_DSS_HDMI |
| 506 | extern struct platform_driver omapdss_hdmi5hw_driver; |
| 507 | #endif |
| 508 | |
Tomi Valkeinen | 559d670 | 2009-11-03 11:23:50 +0200 | [diff] [blame] | 509 | #endif |