blob: e3122e6ea043b86fc1eda4141ea3e6140d40887e [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 Pinchartd874b3a2017-08-05 01:44:19 +030028#define MAX_DSS_LCD_MANAGERS 3
29#define MAX_NUM_DSI 2
30
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053031#ifdef pr_fmt
32#undef pr_fmt
Tomi Valkeinen559d6702009-11-03 11:23:50 +020033#endif
34
35#ifdef DSS_SUBSYS_NAME
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053036#define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
Tomi Valkeinen559d6702009-11-03 11:23:50 +020037#else
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053038#define pr_fmt(fmt) fmt
Tomi Valkeinen559d6702009-11-03 11:23:50 +020039#endif
40
Chandrabhanu Mahapatra702d2672012-09-24 17:12:58 +053041#define DSSDBG(format, ...) \
42 pr_debug(format, ## __VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020043
44#ifdef DSS_SUBSYS_NAME
45#define DSSERR(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080046 pr_err("omapdss " DSS_SUBSYS_NAME " error: " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020047#else
48#define DSSERR(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080049 pr_err("omapdss error: " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020050#endif
51
52#ifdef DSS_SUBSYS_NAME
53#define DSSINFO(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080054 pr_info("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020055#else
56#define DSSINFO(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080057 pr_info("omapdss: " format, ## __VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020058#endif
59
60#ifdef DSS_SUBSYS_NAME
61#define DSSWARN(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080062 pr_warn("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020063#else
64#define DSSWARN(format, ...) \
Joe Perches8dfe1622017-02-28 04:55:54 -080065 pr_warn("omapdss: " format, ##__VA_ARGS__)
Tomi Valkeinen559d6702009-11-03 11:23:50 +020066#endif
67
68/* OMAP TRM gives bitfields as start:end, where start is the higher bit
69 number. For example 7:0 */
70#define FLD_MASK(start, end) (((1 << ((start) - (end) + 1)) - 1) << (end))
71#define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
72#define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
73#define FLD_MOD(orig, val, start, end) \
74 (((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
75
Laurent Pinchartb8dab2b2017-08-05 01:43:56 +030076enum dss_model {
77 DSS_MODEL_OMAP2,
78 DSS_MODEL_OMAP3,
79 DSS_MODEL_OMAP4,
80 DSS_MODEL_OMAP5,
81 DSS_MODEL_DRA7,
82};
83
Archit Taneja569969d2011-08-22 17:41:57 +053084enum dss_io_pad_mode {
85 DSS_IO_PAD_MODE_RESET,
86 DSS_IO_PAD_MODE_RFBI,
87 DSS_IO_PAD_MODE_BYPASS,
Tomi Valkeinen559d6702009-11-03 11:23:50 +020088};
89
Mythri P K7ed024a2011-03-09 16:31:38 +053090enum dss_hdmi_venc_clk_source_select {
91 DSS_VENC_TV_CLK = 0,
92 DSS_HDMI_M_PCLK = 1,
93};
94
Archit Taneja6ff8aa32011-08-25 18:35:58 +053095enum dss_dsi_content_type {
96 DSS_DSI_CONTENT_DCS,
97 DSS_DSI_CONTENT_GENERIC,
98};
99
Archit Tanejad9ac7732012-09-22 12:38:19 +0530100enum dss_writeback_channel {
101 DSS_WB_LCD1_MGR = 0,
102 DSS_WB_LCD2_MGR = 1,
103 DSS_WB_TV_MGR = 2,
104 DSS_WB_OVL0 = 3,
105 DSS_WB_OVL1 = 4,
106 DSS_WB_OVL2 = 5,
107 DSS_WB_OVL3 = 6,
108 DSS_WB_LCD3_MGR = 7,
109};
110
Tomi Valkeinendc0352d2016-05-17 13:45:09 +0300111enum dss_clk_source {
Tomi Valkeinen3b63ca72016-05-17 14:01:10 +0300112 DSS_CLK_SRC_FCK = 0,
113
114 DSS_CLK_SRC_PLL1_1,
115 DSS_CLK_SRC_PLL1_2,
Tomi Valkeinenb5d8c752016-05-17 14:12:35 +0300116 DSS_CLK_SRC_PLL1_3,
Tomi Valkeinen3b63ca72016-05-17 14:01:10 +0300117
118 DSS_CLK_SRC_PLL2_1,
119 DSS_CLK_SRC_PLL2_2,
Tomi Valkeinenb5d8c752016-05-17 14:12:35 +0300120 DSS_CLK_SRC_PLL2_3,
121
122 DSS_CLK_SRC_HDMI_PLL,
Tomi Valkeinenbe5d7312016-05-17 13:31:14 +0300123};
124
Tomi Valkeinen64e22ff2015-01-02 10:05:33 +0200125enum dss_pll_id {
126 DSS_PLL_DSI1,
127 DSS_PLL_DSI2,
128 DSS_PLL_HDMI,
Tomi Valkeinen6d817882014-12-31 11:23:31 +0200129 DSS_PLL_VIDEO1,
130 DSS_PLL_VIDEO2,
Tomi Valkeinen64e22ff2015-01-02 10:05:33 +0200131};
132
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300133struct dss_pll;
134
135#define DSS_PLL_MAX_HSDIVS 4
136
Tomi Valkeinen06ede3d2016-05-18 10:48:44 +0300137enum dss_pll_type {
138 DSS_PLL_TYPE_A,
139 DSS_PLL_TYPE_B,
140};
141
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300142/*
143 * Type-A PLLs: clkout[]/mX[] refer to hsdiv outputs m4, m5, m6, m7.
144 * Type-B PLLs: clkout[0] refers to m2.
145 */
146struct dss_pll_clock_info {
147 /* rates that we get with dividers below */
148 unsigned long fint;
149 unsigned long clkdco;
150 unsigned long clkout[DSS_PLL_MAX_HSDIVS];
151
152 /* dividers */
153 u16 n;
154 u16 m;
155 u32 mf;
156 u16 mX[DSS_PLL_MAX_HSDIVS];
157 u16 sd;
158};
159
160struct dss_pll_ops {
161 int (*enable)(struct dss_pll *pll);
162 void (*disable)(struct dss_pll *pll);
163 int (*set_config)(struct dss_pll *pll,
164 const struct dss_pll_clock_info *cinfo);
165};
166
167struct dss_pll_hw {
Tomi Valkeinen06ede3d2016-05-18 10:48:44 +0300168 enum dss_pll_type type;
169
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200170 unsigned int n_max;
171 unsigned int m_min;
172 unsigned int m_max;
173 unsigned int mX_max;
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300174
175 unsigned long fint_min, fint_max;
176 unsigned long clkdco_min, clkdco_low, clkdco_max;
177
178 u8 n_msb, n_lsb;
179 u8 m_msb, m_lsb;
180 u8 mX_msb[DSS_PLL_MAX_HSDIVS], mX_lsb[DSS_PLL_MAX_HSDIVS];
181
182 bool has_stopmode;
183 bool has_freqsel;
184 bool has_selfreqdco;
185 bool has_refsel;
Tomi Valkeinen0c43f1e02017-06-13 12:02:10 +0300186
187 /* DRA7 errata i886: use high N & M to avoid jitter */
188 bool errata_i886;
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300189};
190
191struct dss_pll {
192 const char *name;
Tomi Valkeinen64e22ff2015-01-02 10:05:33 +0200193 enum dss_pll_id id;
Laurent Pinchart7b295252018-02-13 14:00:21 +0200194 struct dss_device *dss;
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300195
196 struct clk *clkin;
197 struct regulator *regulator;
198
199 void __iomem *base;
200
201 const struct dss_pll_hw *hw;
202
203 const struct dss_pll_ops *ops;
204
205 struct dss_pll_clock_info cinfo;
206};
207
Laurent Pinchart6d85d4a2017-08-05 01:44:07 +0300208/* Defines a generic omap register field */
209struct dss_reg_field {
210 u8 start, end;
211};
212
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200213struct dispc_clock_info {
214 /* rates that we get with dividers below */
215 unsigned long lck;
216 unsigned long pck;
217
218 /* dividers */
219 u16 lck_div;
220 u16 pck_div;
221};
222
Archit Tanejac56fb3e2012-06-29 14:03:48 +0530223struct dss_lcd_mgr_config {
224 enum dss_io_pad_mode io_pad_mode;
225
226 bool stallmode;
227 bool fifohandcheck;
228
229 struct dispc_clock_info clock_info;
230
231 int video_port_width;
232
233 int lcden_sig_polarity;
234};
235
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200236struct seq_file;
237struct platform_device;
238
Laurent Pinchart0e546df2018-02-13 14:00:20 +0200239#define DSS_SZ_REGS SZ_512
240
241struct dss_device {
242 struct platform_device *pdev;
243 void __iomem *base;
244 struct regmap *syscon_pll_ctrl;
245 u32 syscon_pll_ctrl_offset;
246
247 struct clk *parent_clk;
248 struct clk *dss_clk;
249 unsigned long dss_clk_rate;
250
251 unsigned long cache_req_pck;
252 unsigned long cache_prate;
253 struct dispc_clock_info cache_dispc_cinfo;
254
255 enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
256 enum dss_clk_source dispc_clk_source;
257 enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
258
259 bool ctx_valid;
260 u32 ctx[DSS_SZ_REGS / sizeof(u32)];
261
262 const struct dss_features *feat;
263
264 struct dss_pll *video1_pll;
265 struct dss_pll *video2_pll;
266};
267
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200268/* core */
Laurent Pinchart493b6832017-08-05 01:43:54 +0300269static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
270{
271 /* To be implemented when the OMAP platform will provide this feature */
272 return 0;
273}
274
Archit Tanejaf476ae92012-06-29 14:37:03 +0530275static inline bool dss_mgr_is_lcd(enum omap_channel id)
276{
277 if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
278 id == OMAP_DSS_CHANNEL_LCD3)
279 return true;
280 else
281 return false;
282}
283
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200284/* DSS */
Laurent Pinchart11765d12017-08-05 01:44:01 +0300285#if defined(CONFIG_OMAP2_DSS_DEBUGFS)
286int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *));
287#else
288static inline int dss_debugfs_create_file(const char *name,
289 void (*write)(struct seq_file *))
290{
291 return 0;
292}
293#endif /* CONFIG_OMAP2_DSS_DEBUGFS */
294
Laurent Pinchart7b295252018-02-13 14:00:21 +0200295struct dss_device *dss_get_device(struct device *dev);
296
297int dss_runtime_get(struct dss_device *dss);
298void dss_runtime_put(struct dss_device *dss);
Tomi Valkeinen99767542014-07-04 13:38:27 +0530299
Tomi Valkeinen5aaee692012-12-12 10:37:03 +0200300unsigned long dss_get_dispc_clk_rate(void);
Laurent Pinchart9f0fbae2017-08-05 01:44:17 +0300301unsigned long dss_get_max_fck_rate(void);
Laurent Pinchart51919572017-08-05 01:44:18 +0300302enum omap_dss_output_id dss_get_supported_outputs(enum omap_channel channel);
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200303int dss_dpi_select_source(struct dss_device *dss, int port,
304 enum omap_channel channel);
305void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
306 enum dss_hdmi_venc_clk_source_select src);
Tomi Valkeinen407bd562016-05-17 13:50:55 +0300307const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200308
Tomi Valkeinen99767542014-07-04 13:38:27 +0530309/* DSS VIDEO PLL */
Laurent Pinchart7b295252018-02-13 14:00:21 +0200310struct dss_pll *dss_video_pll_init(struct dss_device *dss,
311 struct platform_device *pdev, int id,
312 struct regulator *regulator);
Tomi Valkeinen99767542014-07-04 13:38:27 +0530313void dss_video_pll_uninit(struct dss_pll *pll);
314
Laurent Pinchart27260992018-02-13 14:00:22 +0200315void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
Tomi Valkeinenbe40eec2014-07-04 13:37:15 +0530316
Laurent Pinchartd7157df2018-02-13 14:00:23 +0200317void dss_sdi_init(struct dss_device *dss, int datapairs);
318int dss_sdi_enable(struct dss_device *dss);
319void dss_sdi_disable(struct dss_device *dss);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200320
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200321void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
322 enum dss_clk_source clk_src);
323void dss_select_lcd_clk_source(struct dss_device *dss,
324 enum omap_channel channel,
325 enum dss_clk_source clk_src);
Tomi Valkeinendc0352d2016-05-17 13:45:09 +0300326enum dss_clk_source dss_get_dispc_clk_source(void);
327enum dss_clk_source dss_get_dsi_clk_source(int dsi_module);
328enum dss_clk_source dss_get_lcd_clk_source(enum omap_channel channel);
Tomi Valkeinen2f18c4d2010-01-08 18:00:36 +0200329
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200330void dss_set_venc_output(enum omap_dss_venc_type type);
331void dss_set_dac_pwrdn_bgz(bool enable);
332
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +0200333int dss_set_fck_rate(unsigned long rate);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200334
Tomi Valkeinend0f58bd2013-10-31 14:44:23 +0200335typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
Tomi Valkeinen688af022013-10-31 16:41:57 +0200336bool dss_div_calc(unsigned long pck, unsigned long fck_min,
337 dss_div_calc_func func, void *data);
Tomi Valkeinen43417822013-03-05 16:34:05 +0200338
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200339/* SDI */
Archit Taneja387ce9f2014-05-22 17:01:57 +0530340#ifdef CONFIG_OMAP2_DSS_SDI
Laurent Pinchartd7157df2018-02-13 14:00:23 +0200341int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
342 struct device_node *port);
Tomi Valkeinenede92692015-06-04 14:12:16 +0300343void sdi_uninit_port(struct device_node *port);
Archit Taneja387ce9f2014-05-22 17:01:57 +0530344#else
Laurent Pinchartd7157df2018-02-13 14:00:23 +0200345static inline int sdi_init_port(struct dss_device *dss,
346 struct platform_device *pdev,
347 struct device_node *port)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530348{
349 return 0;
350}
Tomi Valkeinenede92692015-06-04 14:12:16 +0300351static inline void sdi_uninit_port(struct device_node *port)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530352{
353}
354#endif
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200355
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200356/* DSI */
Tomi Valkeinen989c79a2013-04-18 12:16:39 +0300357
Jani Nikula368a1482010-05-07 11:58:41 +0200358#ifdef CONFIG_OMAP2_DSS_DSI
Archit Taneja5a8b5722011-05-12 17:26:29 +0530359
360struct dentry;
361struct file_operations;
362
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200363void dsi_dump_clocks(struct seq_file *s);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200364
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200365void dsi_irq_handler(void);
Archit Tanejaa3b3cc22011-09-08 18:42:16 +0530366
Jani Nikula368a1482010-05-07 11:58:41 +0200367#endif
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200368
369/* DPI */
Archit Taneja387ce9f2014-05-22 17:01:57 +0530370#ifdef CONFIG_OMAP2_DSS_DPI
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200371int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
372 struct device_node *port, enum dss_model dss_model);
Tomi Valkeinenede92692015-06-04 14:12:16 +0300373void dpi_uninit_port(struct device_node *port);
Archit Taneja387ce9f2014-05-22 17:01:57 +0530374#else
Laurent Pinchart8aea8e62018-02-13 14:00:24 +0200375static inline int dpi_init_port(struct dss_device *port,
376 struct platform_device *pdev,
377 struct device_node *port,
378 enum dss_model dss_model)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530379{
380 return 0;
381}
Tomi Valkeinenede92692015-06-04 14:12:16 +0300382static inline void dpi_uninit_port(struct device_node *port)
Archit Taneja387ce9f2014-05-22 17:01:57 +0530383{
384}
385#endif
Tomi Valkeinen2ecef242013-12-16 15:13:24 +0200386
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200387/* DISPC */
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200388void dispc_dump_clocks(struct seq_file *s);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200389
Tomi Valkeinen5034b1f2015-11-05 20:06:06 +0200390int dispc_runtime_get(void);
391void dispc_runtime_put(void);
392
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200393void dispc_enable_sidle(void);
394void dispc_disable_sidle(void);
395
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200396void dispc_lcd_enable_signal(bool enable);
397void dispc_pck_free_enable(bool enable);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300398void dispc_enable_fifomerge(bool enable);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300399
Tomi Valkeinen7c284e62013-03-05 16:32:08 +0200400typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
401 unsigned long pck, void *data);
402bool dispc_div_calc(unsigned long dispc,
403 unsigned long pck_min, unsigned long pck_max,
404 dispc_div_calc_func func, void *data);
405
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300406bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300407int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
408 struct dispc_clock_info *cinfo);
409
410
Jyri Sarha864050c2017-03-24 16:47:52 +0200411void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
412 u32 high);
413void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
Tomi Valkeinen3568f2a2012-05-15 15:31:01 +0300414 u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
415 bool manual_update);
Tomi Valkeinencd295ae2011-08-16 13:49:15 +0300416
Archit Tanejaf0d08f82012-06-29 14:00:54 +0530417void dispc_mgr_set_clock_div(enum omap_channel channel,
Tomi Valkeinena8f3fcd2012-10-03 09:09:11 +0200418 const struct dispc_clock_info *cinfo);
Tomi Valkeinen26d9dd02011-08-16 13:45:15 +0300419int dispc_mgr_get_clock_div(enum omap_channel channel,
Sumit Semwalff1b2cd2010-12-02 11:27:11 +0000420 struct dispc_clock_info *cinfo);
Tomi Valkeinen5391e872013-05-16 10:44:13 +0300421void dispc_set_tv_pclk(unsigned long pclk);
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200422
Archit Taneja0b23e5b2012-09-22 12:39:33 +0530423u32 dispc_wb_get_framedone_irq(void);
424bool dispc_wb_go_busy(void);
425void dispc_wb_go(void);
Archit Tanejad9ac7732012-09-22 12:38:19 +0530426void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
Archit Taneja749feff2012-08-31 12:32:52 +0530427int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
Peter Ujfalusida11bbbb2016-09-22 14:07:04 +0300428 bool mem_to_mem, const struct videomode *vm);
Archit Tanejad9ac7732012-09-22 12:38:19 +0530429
Tomi Valkeinendfc0fd82009-12-17 14:35:21 +0200430#ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200431static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr)
Tomi Valkeinendfc0fd82009-12-17 14:35:21 +0200432{
433 int b;
434 for (b = 0; b < 32; ++b) {
435 if (irqstatus & (1 << b))
436 irq_arr[b]++;
437 }
438}
439#endif
440
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300441/* PLL */
442typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
443 unsigned long clkdco, void *data);
444typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
445 void *data);
446
447int dss_pll_register(struct dss_pll *pll);
448void dss_pll_unregister(struct dss_pll *pll);
449struct dss_pll *dss_pll_find(const char *name);
Tomi Valkeinen5670bd72016-05-18 12:42:09 +0300450struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
Laurent Pinchartd11e5c82018-02-11 15:07:34 +0200451unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300452int dss_pll_enable(struct dss_pll *pll);
453void dss_pll_disable(struct dss_pll *pll);
454int dss_pll_set_config(struct dss_pll *pll,
455 const struct dss_pll_clock_info *cinfo);
456
Tomi Valkeinencd0715f2016-05-17 21:23:37 +0300457bool dss_pll_hsdiv_calc_a(const struct dss_pll *pll, unsigned long clkdco,
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300458 unsigned long out_min, unsigned long out_max,
459 dss_hsdiv_calc_func func, void *data);
Tomi Valkeinencd0715f2016-05-17 21:23:37 +0300460bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300461 unsigned long pll_min, unsigned long pll_max,
462 dss_pll_calc_func func, void *data);
Tomi Valkeinenc17dc0e2016-05-18 10:45:20 +0300463
464bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin,
Tomi Valkeinenc1077512016-05-18 11:15:21 +0300465 unsigned long target_clkout, struct dss_pll_clock_info *cinfo);
Tomi Valkeinenc17dc0e2016-05-18 10:45:20 +0300466
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300467int dss_pll_write_config_type_a(struct dss_pll *pll,
468 const struct dss_pll_clock_info *cinfo);
469int dss_pll_write_config_type_b(struct dss_pll *pll,
470 const struct dss_pll_clock_info *cinfo);
Tomi Valkeineneb301992014-12-31 14:22:42 +0200471int dss_pll_wait_reset_done(struct dss_pll *pll);
Tomi Valkeinen0a201702014-10-22 14:21:59 +0300472
Andrew F. Davisd66c36a2017-12-05 14:29:32 -0600473extern struct platform_driver omap_dsshw_driver;
474extern struct platform_driver omap_dispchw_driver;
475#ifdef CONFIG_OMAP2_DSS_DSI
476extern struct platform_driver omap_dsihw_driver;
477#endif
478#ifdef CONFIG_OMAP2_DSS_VENC
479extern struct platform_driver omap_venchw_driver;
480#endif
481#ifdef CONFIG_OMAP4_DSS_HDMI
482extern struct platform_driver omapdss_hdmi4hw_driver;
483#endif
484#ifdef CONFIG_OMAP5_DSS_HDMI
485extern struct platform_driver omapdss_hdmi5hw_driver;
486#endif
487
Tomi Valkeinen559d6702009-11-03 11:23:50 +0200488#endif