blob: f3acfd62031c26eba4668888079a40cd6c3aeadc [file] [log] [blame]
Tomi Valkeinen559d6702009-11-03 11:23:50 +02001/*
Tomi Valkeinen559d6702009-11-03 11:23:50 +02002 * 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 Valkeinen96e2e632012-10-10 15:55:19 +030024#include <linux/interrupt.h>
25
Tomi Valkeinen35a339a2016-02-19 16:54:36 +020026#include "omapdss.h"
27
Laurent Pinchart50638ae2018-02-13 14:00:42 +020028struct dispc_device;
Laurent Pinchartf33656e2018-02-13 14:00:29 +020029struct dss_debugfs_entry;
30struct platform_device;
31struct seq_file;
32
Laurent Pinchartd874b3a2017-08-05 01:44:19 +030033#define MAX_DSS_LCD_MANAGERS 3
34#define MAX_NUM_DSI 2
35
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053036#ifdef pr_fmt
37#undef pr_fmt
Tomi Valkeinen559d6702009-11-03 11:23:50 +020038#endif
39
40#ifdef DSS_SUBSYS_NAME
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053041#define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
Tomi Valkeinen559d6702009-11-03 11:23:50 +020042#else
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053043#define pr_fmt(fmt) fmt
Tomi Valkeinen559d6702009-11-03 11:23:50 +020044#endif
45
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053046#define DSSDBG(format, ...) \
47 pr_debug(format, ## __VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020048
49#ifdef DSS_SUBSYS_NAME
50#define DSSERR(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080051 pr_err("omapdss " DSS_SUBSYS_NAME " error: " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020052#else
53#define DSSERR(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080054 pr_err("omapdss error: " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020055#endif
56
57#ifdef DSS_SUBSYS_NAME
58#define DSSINFO(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080059 pr_info("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020060#else
61#define DSSINFO(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080062 pr_info("omapdss: " format, ## __VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020063#endif
64
65#ifdef DSS_SUBSYS_NAME
66#define DSSWARN(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080067 pr_warn("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020068#else
69#define DSSWARN(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080070 pr_warn("omapdss: " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020071#endif
72
73/* OMAP TRM gives bitfields as start:end, where start is the higher bit
74 number. For example 7:0 */
75#define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end))
76#define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
77#define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
78#define FLD_MOD(orig, val, start, end) \
79 (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
80
Laurent Pinchartb8dab2b2017-08-05 01:43:56 +030081enum dss_model {
82 DSS_MODEL_OMAP2,
83 DSS_MODEL_OMAP3,
84 DSS_MODEL_OMAP4,
85 DSS_MODEL_OMAP5,
86 DSS_MODEL_DRA7,
87};
88
Archit Taneja569969d2011-08-22 17:41:57 +053089enum dss_io_pad_mode {
90 DSS_IO_PAD_MODE_RESET,
91 DSS_IO_PAD_MODE_RFBI,
92 DSS_IO_PAD_MODE_BYPASS,
Tomi Valkeinen559d6702009-11-03 11:23:50 +020093};
94
Mythri P K7ed024a2011-03-09 16:31:38 +053095enum dss_hdmi_venc_clk_source_select {
96 DSS_VENC_TV_CLK = 0,
97 DSS_HDMI_M_PCLK = 1,
98};
99
Archit Taneja6ff8aa32011-08-25 18:35:58 +0530100enum dss_dsi_content_type {
101 DSS_DSI_CONTENT_DCS,
102 DSS_DSI_CONTENT_GENERIC,
103};
104
Archit Tanejad9ac7732012-09-22 12:38:19 +0530105enum dss_writeback_channel {
106 DSS_WB_LCD1_MGR = 0,
107 DSS_WB_LCD2_MGR = 1,
108 DSS_WB_TV_MGR = 2,
109 DSS_WB_OVL0 = 3,
110 DSS_WB_OVL1 = 4,
111 DSS_WB_OVL2 = 5,
112 DSS_WB_OVL3 = 6,
113 DSS_WB_LCD3_MGR = 7,
114};
115
Tomi Valkeinendc0352d2016-05-17 13:45:09 +0300116enum dss_clk_source {
Tomi Valkeinen3b63ca72016-05-17 14:01:10 +0300117 DSS_CLK_SRC_FCK = 0,
118
119 DSS_CLK_SRC_PLL1_1,
120 DSS_CLK_SRC_PLL1_2,
Tomi Valkeinenb5d8c752016-05-17 14:12:35 +0300121 DSS_CLK_SRC_PLL1_3,
Tomi Valkeinen3b63ca72016-05-17 14:01:10 +0300122
123 DSS_CLK_SRC_PLL2_1,
124 DSS_CLK_SRC_PLL2_2,
Tomi Valkeinenb5d8c752016-05-17 14:12:35 +0300125 DSS_CLK_SRC_PLL2_3,
126
127 DSS_CLK_SRC_HDMI_PLL,
Tomi Valkeinenbe5d7312016-05-17 13:31:14 +0300128};
129
Tomi Valkeinen64e22ff2015-01-02 10:05:33 +0200130enum dss_pll_id {
131 DSS_PLL_DSI1,
132 DSS_PLL_DSI2,
133 DSS_PLL_HDMI,
Tomi Valkeinen6d817882014-12-31 11:23:31 +0200134 DSS_PLL_VIDEO1,
135 DSS_PLL_VIDEO2,
Tomi Valkeinen64e22ff2015-01-02 10:05:33 +0200136};
137
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300138struct dss_pll;
139
140#define DSS_PLL_MAX_HSDIVS 4
141
Tomi Valkeinen06ede3d2016-05-18 10:48:44 +0300142enum dss_pll_type {
143 DSS_PLL_TYPE_A,
144 DSS_PLL_TYPE_B,
145};
146
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300147/*
148 * Type-A PLLs: clkout[]/mX[] refer to hsdiv outputs m4, m5, m6, m7.
149 * Type-B PLLs: clkout[0] refers to m2.
150 */
151struct dss_pll_clock_info {
152 /* rates that we get with dividers below */
153 unsigned long fint;
154 unsigned long clkdco;
155 unsigned long clkout[DSS_PLL_MAX_HSDIVS];
156
157 /* dividers */
158 u16 n;
159 u16 m;
160 u32 mf;
161 u16 mX[DSS_PLL_MAX_HSDIVS];
162 u16 sd;
163};
164
165struct dss_pll_ops {
166 int (*enable)(struct dss_pll *pll);
167 void (*disable)(struct dss_pll *pll);
168 int (*set_config)(struct dss_pll *pll,
169 const struct dss_pll_clock_info *cinfo);
170};
171
172struct dss_pll_hw {
Tomi Valkeinen06ede3d2016-05-18 10:48:44 +0300173 enum dss_pll_type type;
174
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200175 unsigned int n_max;
176 unsigned int m_min;
177 unsigned int m_max;
178 unsigned int mX_max;
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300179
180 unsigned long fint_min, fint_max;
181 unsigned long clkdco_min, clkdco_low, clkdco_max;
182
183 u8 n_msb, n_lsb;
184 u8 m_msb, m_lsb;
185 u8 mX_msb[DSS_PLL_MAX_HSDIVS], mX_lsb[DSS_PLL_MAX_HSDIVS];
186
187 bool has_stopmode;
188 bool has_freqsel;
189 bool has_selfreqdco;
190 bool has_refsel;
Tomi Valkeinen0c43f1e02017-06-13 12:02:10 +0300191
192 /* DRA7 errata i886: use high N & M to avoid jitter */
193 bool errata_i886;
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300194};
195
196struct dss_pll {
197 const char *name;
Tomi Valkeinen64e22ff2015-01-02 10:05:33 +0200198 enum dss_pll_id id;
Laurent Pinchart7b295252018-02-13 14:00:21 +0200199 struct dss_device *dss;
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300200
201 struct clk *clkin;
202 struct regulator *regulator;
203
204 void __iomem *base;
205
206 const struct dss_pll_hw *hw;
207
208 const struct dss_pll_ops *ops;
209
210 struct dss_pll_clock_info cinfo;
211};
212
Laurent Pinchart6d85d4a2017-08-05 01:44:07 +0300213/* Defines a generic omap register field */
214struct dss_reg_field {
215 u8 start, end;
216};
217
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200218struct dispc_clock_info {
219 /* rates that we get with dividers below */
220 unsigned long lck;
221 unsigned long pck;
222
223 /* dividers */
224 u16 lck_div;
225 u16 pck_div;
226};
227
Archit Tanejac56fb3e2012-06-29 14:03:48 +0530228struct dss_lcd_mgr_config {
229 enum dss_io_pad_mode io_pad_mode;
230
231 bool stallmode;
232 bool fifohandcheck;
233
234 struct dispc_clock_info clock_info;
235
236 int video_port_width;
237
238 int lcden_sig_polarity;
239};
240
Laurent Pinchart0e546df2018-02-13 14:00:20 +0200241#define DSS_SZ_REGS SZ_512
242
243struct dss_device {
244 struct platform_device *pdev;
245 void __iomem *base;
246 struct regmap *syscon_pll_ctrl;
247 u32 syscon_pll_ctrl_offset;
248
249 struct clk *parent_clk;
250 struct clk *dss_clk;
251 unsigned long dss_clk_rate;
252
253 unsigned long cache_req_pck;
254 unsigned long cache_prate;
255 struct dispc_clock_info cache_dispc_cinfo;
256
257 enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
258 enum dss_clk_source dispc_clk_source;
259 enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
260
261 bool ctx_valid;
262 u32 ctx[DSS_SZ_REGS / sizeof(u32)];
263
264 const struct dss_features *feat;
265
Laurent Pinchartf33656e2018-02-13 14:00:29 +0200266 struct {
Laurent Pinchart1c4b92e2018-02-13 14:00:31 +0200267 struct dentry *root;
Laurent Pinchartf33656e2018-02-13 14:00:29 +0200268 struct dss_debugfs_entry *clk;
269 struct dss_debugfs_entry *dss;
270 } debugfs;
271
Laurent Pinchart798957a2018-02-13 14:00:30 +0200272 struct dss_pll *plls[4];
Laurent Pinchart0e546df2018-02-13 14:00:20 +0200273 struct dss_pll *video1_pll;
274 struct dss_pll *video2_pll;
Laurent Pinchartd3541ca2018-02-13 14:00:41 +0200275
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200276 struct dispc_device *dispc;
Laurent Pinchartd3541ca2018-02-13 14:00:41 +0200277 const struct dispc_ops *dispc_ops;
Laurent Pinchart0e546df2018-02-13 14:00:20 +0200278};
279
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200280/* core */
Laurent Pinchart493b6832017-08-05 01:43:54 +0300281static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
282{
283 /* To be implemented when the OMAP platform will provide this feature */
284 return 0;
285}
286
Archit Tanejaf476ae92012-06-29 14:37:03 +0530287static inline bool dss_mgr_is_lcd(enum omap_channel id)
288{
289 if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
290 id == OMAP_DSS_CHANNEL_LCD3)
291 return true;
292 else
293 return false;
294}
295
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200296/* DSS */
Laurent Pinchart11765d12017-08-05 01:44:01 +0300297#if defined(CONFIG_OMAP2_DSS_DEBUGFS)
Laurent Pinchart1c4b92e2018-02-13 14:00:31 +0200298struct dss_debugfs_entry *
299dss_debugfs_create_file(struct dss_device *dss, const char *name,
300 int (*show_fn)(struct seq_file *s, void *data),
301 void *data);
Laurent Pinchartf33656e2018-02-13 14:00:29 +0200302void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
Laurent Pinchart11765d12017-08-05 01:44:01 +0300303#else
Laurent Pinchartf33656e2018-02-13 14:00:29 +0200304static inline struct dss_debugfs_entry *
Laurent Pinchart1c4b92e2018-02-13 14:00:31 +0200305dss_debugfs_create_file(struct dss_device *dss, const char *name,
Laurent Pinchartf33656e2018-02-13 14:00:29 +0200306 int (*show_fn)(struct seq_file *s, void *data),
307 void *data)
Laurent Pinchart11765d12017-08-05 01:44:01 +0300308{
Laurent Pinchartf33656e2018-02-13 14:00:29 +0200309 return NULL;
310}
311
312static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
313{
Laurent Pinchart11765d12017-08-05 01:44:01 +0300314}
315#endif /* CONFIG_OMAP2_DSS_DEBUGFS */
316
Laurent Pinchart7b295252018-02-13 14:00:21 +0200317struct dss_device *dss_get_device(struct device *dev);
318
319int dss_runtime_get(struct dss_device *dss);
320void dss_runtime_put(struct dss_device *dss);
Tomi Valkeinen99767542014-07-04 13:38:27 +0530321
Laurent Pinchart60f9c592018-02-13 14:00:26 +0200322unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
323unsigned long dss_get_max_fck_rate(struct dss_device *dss);
Laurent Pinchart1ef904e2018-02-13 14:00:27 +0200324enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
325 enum omap_channel channel);
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200326int dss_dpi_select_source(struct dss_device *dss, int port,
327 enum omap_channel channel);
328void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
329 enum dss_hdmi_venc_clk_source_select src);
Tomi Valkeinen407bd562016-05-17 13:50:55 +0300330const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200331
Tomi Valkeinen99767542014-07-04 13:38:27 +0530332/* DSS VIDEO PLL */
Laurent Pinchart7b295252018-02-13 14:00:21 +0200333struct dss_pll *dss_video_pll_init(struct dss_device *dss,
334 struct platform_device *pdev, int id,
335 struct regulator *regulator);
Tomi Valkeinen99767542014-07-04 13:38:27 +0530336void dss_video_pll_uninit(struct dss_pll *pll);
337
Laurent Pinchart27260992018-02-13 14:00:22 +0200338void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
Tomi Valkeinenbe40eec2014-07-04 13:37:15 +0530339
Laurent Pinchartd7157df2018-02-13 14:00:23 +0200340void dss_sdi_init(struct dss_device *dss, int datapairs);
341int dss_sdi_enable(struct dss_device *dss);
342void dss_sdi_disable(struct dss_device *dss);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200343
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200344void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
345 enum dss_clk_source clk_src);
346void dss_select_lcd_clk_source(struct dss_device *dss,
347 enum omap_channel channel,
348 enum dss_clk_source clk_src);
Laurent Pinchart3cc62aa2018-02-13 14:00:25 +0200349enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss);
350enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
351 int dsi_module);
352enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
353 enum omap_channel channel);
Tomi Valkeinen2f18c4d2010-01-08 18:00:36 +0200354
Laurent Pinchart1ef904e2018-02-13 14:00:27 +0200355void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type);
356void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200357
Laurent Pinchart60f9c592018-02-13 14:00:26 +0200358int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200359
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +0200360typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
Laurent Pinchart60f9c592018-02-13 14:00:26 +0200361bool dss_div_calc(struct dss_device *dss, unsigned long pck,
362 unsigned long fck_min, dss_div_calc_func func, void *data);
Tomi Valkeinen43417822013-03-05 16:34:05 +0200363
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200364/* SDI */
Archit Taneja387ce9f2014-05-22 17:01:57 +0530365#ifdef CONFIG_OMAP2_DSS_SDI
Laurent Pinchartd7157df2018-02-13 14:00:23 +0200366int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
367 struct device_node *port);
Tomi Valkeinenede92692015-06-04 14:12:16 +0300368void sdi_uninit_port(struct device_node *port);
Archit Taneja387ce9f2014-05-22 17:01:57 +0530369#else
Laurent Pinchartd7157df2018-02-13 14:00:23 +0200370static inline int sdi_init_port(struct dss_device *dss,
371 struct platform_device *pdev,
372 struct device_node *port)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530373{
374 return 0;
375}
Tomi Valkeinenede92692015-06-04 14:12:16 +0300376static inline void sdi_uninit_port(struct device_node *port)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530377{
378}
379#endif
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200380
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200381/* DSI */
Tomi Valkeinen989c79a2013-04-18 12:16:39 +0300382
Jani Nikula368a1482010-05-07 11:58:41 +0200383#ifdef CONFIG_OMAP2_DSS_DSI
Archit Taneja5a8b5722011-05-12 17:26:29 +0530384
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200385void dsi_dump_clocks(struct seq_file *s);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200386
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200387void dsi_irq_handler(void);
Archit Tanejaa3b3cc22011-09-08 18:42:16 +0530388
Jani Nikula368a1482010-05-07 11:58:41 +0200389#endif
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200390
391/* DPI */
Archit Taneja387ce9f2014-05-22 17:01:57 +0530392#ifdef CONFIG_OMAP2_DSS_DPI
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200393int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
394 struct device_node *port, enum dss_model dss_model);
Tomi Valkeinenede92692015-06-04 14:12:16 +0300395void dpi_uninit_port(struct device_node *port);
Archit Taneja387ce9f2014-05-22 17:01:57 +0530396#else
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200397static inline int dpi_init_port(struct dss_device *port,
398 struct platform_device *pdev,
399 struct device_node *port,
400 enum dss_model dss_model)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530401{
402 return 0;
403}
Tomi Valkeinenede92692015-06-04 14:12:16 +0300404static inline void dpi_uninit_port(struct device_node *port)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530405{
406}
407#endif
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200408
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200409/* DISPC */
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200410void dispc_dump_clocks(struct seq_file *s);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200411
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200412int dispc_runtime_get(struct dispc_device *dispc);
413void dispc_runtime_put(struct dispc_device *dispc);
Tomi Valkeinen5034b1f2015-11-05 20:06:06 +0200414
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200415void dispc_enable_sidle(void);
416void dispc_disable_sidle(void);
417
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200418void dispc_lcd_enable_signal(bool enable);
419void dispc_pck_free_enable(bool enable);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300420void dispc_enable_fifomerge(bool enable);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300421
Tomi Valkeinen7c284e62013-03-05 16:32:08 +0200422typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
423 unsigned long pck, void *data);
424bool dispc_div_calc(unsigned long dispc,
425 unsigned long pck_min, unsigned long pck_max,
426 dispc_div_calc_func func, void *data);
427
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300428bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300429int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
430 struct dispc_clock_info *cinfo);
431
432
Jyri Sarha864050c2017-03-24 16:47:52 +0200433void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
434 u32 high);
435void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
Tomi Valkeinen3568f2a2012-05-15 15:31:01 +0300436 u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
437 bool manual_update);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300438
Archit Tanejaf0d08f82012-06-29 14:00:54 +0530439void dispc_mgr_set_clock_div(enum omap_channel channel,
Tomi Valkeinena8f3fcd2012-10-03 09:09:11 +0200440 const struct dispc_clock_info *cinfo);
Tomi Valkeinen26d9dd02011-08-16 13:45:15 +0300441int dispc_mgr_get_clock_div(enum omap_channel channel,
Sumit Semwalff1b2cd2010-12-02 11:27:11 +0000442 struct dispc_clock_info *cinfo);
Tomi Valkeinen5391e872013-05-16 10:44:13 +0300443void dispc_set_tv_pclk(unsigned long pclk);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200444
Archit Taneja0b23e5b2012-09-22 12:39:33 +0530445u32 dispc_wb_get_framedone_irq(void);
446bool dispc_wb_go_busy(void);
447void dispc_wb_go(void);
Archit Tanejad9ac7732012-09-22 12:38:19 +0530448void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
Archit Taneja749feff2012-08-31 12:32:52 +0530449int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300450 bool mem_to_mem, const struct videomode *vm);
Archit Tanejad9ac7732012-09-22 12:38:19 +0530451
Tomi Valkeinendfc0fd82009-12-17 14:35:21 +0200452#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200453static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr)
Tomi Valkeinendfc0fd82009-12-17 14:35:21 +0200454{
455 int b;
456 for (b = 0; b < 32; ++b) {
457 if (irqstatus & (1 << b))
458 irq_arr[b]++;
459 }
460}
461#endif
462
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300463/* PLL */
464typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
465 unsigned long clkdco, void *data);
466typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
467 void *data);
468
Laurent Pinchart798957a2018-02-13 14:00:30 +0200469int dss_pll_register(struct dss_device *dss, struct dss_pll *pll);
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300470void dss_pll_unregister(struct dss_pll *pll);
Laurent Pinchart798957a2018-02-13 14:00:30 +0200471struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name);
472struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
473 enum dss_clk_source src);
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200474unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300475int dss_pll_enable(struct dss_pll *pll);
476void dss_pll_disable(struct dss_pll *pll);
477int dss_pll_set_config(struct dss_pll *pll,
478 const struct dss_pll_clock_info *cinfo);
479
Tomi Valkeinencd0715f2016-05-17 21:23:37 +0300480bool dss_pll_hsdiv_calc_a(const struct dss_pll *pll, unsigned long clkdco,
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300481 unsigned long out_min, unsigned long out_max,
482 dss_hsdiv_calc_func func, void *data);
Tomi Valkeinencd0715f2016-05-17 21:23:37 +0300483bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300484 unsigned long pll_min, unsigned long pll_max,
485 dss_pll_calc_func func, void *data);
Tomi Valkeinenc17dc0e2016-05-18 10:45:20 +0300486
487bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin,
Tomi Valkeinenc1077512016-05-18 11:15:21 +0300488 unsigned long target_clkout, struct dss_pll_clock_info *cinfo);
Tomi Valkeinenc17dc0e2016-05-18 10:45:20 +0300489
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300490int dss_pll_write_config_type_a(struct dss_pll *pll,
491 const struct dss_pll_clock_info *cinfo);
492int dss_pll_write_config_type_b(struct dss_pll *pll,
493 const struct dss_pll_clock_info *cinfo);
Tomi Valkeineneb301992014-12-31 14:22:42 +0200494int dss_pll_wait_reset_done(struct dss_pll *pll);
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300495
Andrew F. Davisd66c36a2017-12-05 14:29:32 -0600496extern struct platform_driver omap_dsshw_driver;
497extern struct platform_driver omap_dispchw_driver;
498#ifdef CONFIG_OMAP2_DSS_DSI
499extern struct platform_driver omap_dsihw_driver;
500#endif
501#ifdef CONFIG_OMAP2_DSS_VENC
502extern struct platform_driver omap_venchw_driver;
503#endif
504#ifdef CONFIG_OMAP4_DSS_HDMI
505extern struct platform_driver omapdss_hdmi4hw_driver;
506#endif
507#ifdef CONFIG_OMAP5_DSS_HDMI
508extern struct platform_driver omapdss_hdmi5hw_driver;
509#endif
510
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200511#endif