xref: /openbmc/linux/drivers/gpu/drm/omapdrm/dss/dss.h (revision f33656e1fe5aba0ac0d35e18d90121dd894611ca)
19960aa7cSTomi Valkeinen /*
29960aa7cSTomi Valkeinen  * Copyright (C) 2009 Nokia Corporation
39960aa7cSTomi Valkeinen  * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
49960aa7cSTomi Valkeinen  *
59960aa7cSTomi Valkeinen  * Some code and ideas taken from drivers/video/omap/ driver
69960aa7cSTomi Valkeinen  * by Imre Deak.
79960aa7cSTomi Valkeinen  *
89960aa7cSTomi Valkeinen  * This program is free software; you can redistribute it and/or modify it
99960aa7cSTomi Valkeinen  * under the terms of the GNU General Public License version 2 as published by
109960aa7cSTomi Valkeinen  * the Free Software Foundation.
119960aa7cSTomi Valkeinen  *
129960aa7cSTomi Valkeinen  * This program is distributed in the hope that it will be useful, but WITHOUT
139960aa7cSTomi Valkeinen  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
149960aa7cSTomi Valkeinen  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
159960aa7cSTomi Valkeinen  * more details.
169960aa7cSTomi Valkeinen  *
179960aa7cSTomi Valkeinen  * You should have received a copy of the GNU General Public License along with
189960aa7cSTomi Valkeinen  * this program.  If not, see <http://www.gnu.org/licenses/>.
199960aa7cSTomi Valkeinen  */
209960aa7cSTomi Valkeinen 
219960aa7cSTomi Valkeinen #ifndef __OMAP2_DSS_H
229960aa7cSTomi Valkeinen #define __OMAP2_DSS_H
239960aa7cSTomi Valkeinen 
249960aa7cSTomi Valkeinen #include <linux/interrupt.h>
259960aa7cSTomi Valkeinen 
2635a339acSTomi Valkeinen #include "omapdss.h"
2735a339acSTomi Valkeinen 
28*f33656e1SLaurent Pinchart struct dss_debugfs_entry;
29*f33656e1SLaurent Pinchart struct platform_device;
30*f33656e1SLaurent Pinchart struct seq_file;
31*f33656e1SLaurent Pinchart 
32d874b3a7SLaurent Pinchart #define MAX_DSS_LCD_MANAGERS	3
33d874b3a7SLaurent Pinchart #define MAX_NUM_DSI		2
34d874b3a7SLaurent Pinchart 
359960aa7cSTomi Valkeinen #ifdef pr_fmt
369960aa7cSTomi Valkeinen #undef pr_fmt
379960aa7cSTomi Valkeinen #endif
389960aa7cSTomi Valkeinen 
399960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
409960aa7cSTomi Valkeinen #define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
419960aa7cSTomi Valkeinen #else
429960aa7cSTomi Valkeinen #define pr_fmt(fmt) fmt
439960aa7cSTomi Valkeinen #endif
449960aa7cSTomi Valkeinen 
459960aa7cSTomi Valkeinen #define DSSDBG(format, ...) \
469960aa7cSTomi Valkeinen 	pr_debug(format, ## __VA_ARGS__)
479960aa7cSTomi Valkeinen 
489960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
499960aa7cSTomi Valkeinen #define DSSERR(format, ...) \
508dfe162aSJoe Perches 	pr_err("omapdss " DSS_SUBSYS_NAME " error: " format, ##__VA_ARGS__)
519960aa7cSTomi Valkeinen #else
529960aa7cSTomi Valkeinen #define DSSERR(format, ...) \
538dfe162aSJoe Perches 	pr_err("omapdss error: " format, ##__VA_ARGS__)
549960aa7cSTomi Valkeinen #endif
559960aa7cSTomi Valkeinen 
569960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
579960aa7cSTomi Valkeinen #define DSSINFO(format, ...) \
588dfe162aSJoe Perches 	pr_info("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
599960aa7cSTomi Valkeinen #else
609960aa7cSTomi Valkeinen #define DSSINFO(format, ...) \
618dfe162aSJoe Perches 	pr_info("omapdss: " format, ## __VA_ARGS__)
629960aa7cSTomi Valkeinen #endif
639960aa7cSTomi Valkeinen 
649960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
659960aa7cSTomi Valkeinen #define DSSWARN(format, ...) \
668dfe162aSJoe Perches 	pr_warn("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
679960aa7cSTomi Valkeinen #else
689960aa7cSTomi Valkeinen #define DSSWARN(format, ...) \
698dfe162aSJoe Perches 	pr_warn("omapdss: " format, ##__VA_ARGS__)
709960aa7cSTomi Valkeinen #endif
719960aa7cSTomi Valkeinen 
729960aa7cSTomi Valkeinen /* OMAP TRM gives bitfields as start:end, where start is the higher bit
739960aa7cSTomi Valkeinen    number. For example 7:0 */
749960aa7cSTomi Valkeinen #define FLD_MASK(start, end)	(((1 << ((start) - (end) + 1)) - 1) << (end))
759960aa7cSTomi Valkeinen #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
769960aa7cSTomi Valkeinen #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
779960aa7cSTomi Valkeinen #define FLD_MOD(orig, val, start, end) \
789960aa7cSTomi Valkeinen 	(((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
799960aa7cSTomi Valkeinen 
80b8dab2bdSLaurent Pinchart enum dss_model {
81b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP2,
82b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP3,
83b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP4,
84b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP5,
85b8dab2bdSLaurent Pinchart 	DSS_MODEL_DRA7,
86b8dab2bdSLaurent Pinchart };
87b8dab2bdSLaurent Pinchart 
889960aa7cSTomi Valkeinen enum dss_io_pad_mode {
899960aa7cSTomi Valkeinen 	DSS_IO_PAD_MODE_RESET,
909960aa7cSTomi Valkeinen 	DSS_IO_PAD_MODE_RFBI,
919960aa7cSTomi Valkeinen 	DSS_IO_PAD_MODE_BYPASS,
929960aa7cSTomi Valkeinen };
939960aa7cSTomi Valkeinen 
949960aa7cSTomi Valkeinen enum dss_hdmi_venc_clk_source_select {
959960aa7cSTomi Valkeinen 	DSS_VENC_TV_CLK = 0,
969960aa7cSTomi Valkeinen 	DSS_HDMI_M_PCLK = 1,
979960aa7cSTomi Valkeinen };
989960aa7cSTomi Valkeinen 
999960aa7cSTomi Valkeinen enum dss_dsi_content_type {
1009960aa7cSTomi Valkeinen 	DSS_DSI_CONTENT_DCS,
1019960aa7cSTomi Valkeinen 	DSS_DSI_CONTENT_GENERIC,
1029960aa7cSTomi Valkeinen };
1039960aa7cSTomi Valkeinen 
1049960aa7cSTomi Valkeinen enum dss_writeback_channel {
1059960aa7cSTomi Valkeinen 	DSS_WB_LCD1_MGR =	0,
1069960aa7cSTomi Valkeinen 	DSS_WB_LCD2_MGR =	1,
1079960aa7cSTomi Valkeinen 	DSS_WB_TV_MGR =		2,
1089960aa7cSTomi Valkeinen 	DSS_WB_OVL0 =		3,
1099960aa7cSTomi Valkeinen 	DSS_WB_OVL1 =		4,
1109960aa7cSTomi Valkeinen 	DSS_WB_OVL2 =		5,
1119960aa7cSTomi Valkeinen 	DSS_WB_OVL3 =		6,
1129960aa7cSTomi Valkeinen 	DSS_WB_LCD3_MGR =	7,
1139960aa7cSTomi Valkeinen };
1149960aa7cSTomi Valkeinen 
115dc0352d1STomi Valkeinen enum dss_clk_source {
1163b63ca75STomi Valkeinen 	DSS_CLK_SRC_FCK = 0,
1173b63ca75STomi Valkeinen 
1183b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL1_1,
1193b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL1_2,
120b5d8c757STomi Valkeinen 	DSS_CLK_SRC_PLL1_3,
1213b63ca75STomi Valkeinen 
1223b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL2_1,
1233b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL2_2,
124b5d8c757STomi Valkeinen 	DSS_CLK_SRC_PLL2_3,
125b5d8c757STomi Valkeinen 
126b5d8c757STomi Valkeinen 	DSS_CLK_SRC_HDMI_PLL,
127be5d7319STomi Valkeinen };
128be5d7319STomi Valkeinen 
1299960aa7cSTomi Valkeinen enum dss_pll_id {
1309960aa7cSTomi Valkeinen 	DSS_PLL_DSI1,
1319960aa7cSTomi Valkeinen 	DSS_PLL_DSI2,
1329960aa7cSTomi Valkeinen 	DSS_PLL_HDMI,
1339960aa7cSTomi Valkeinen 	DSS_PLL_VIDEO1,
1349960aa7cSTomi Valkeinen 	DSS_PLL_VIDEO2,
1359960aa7cSTomi Valkeinen };
1369960aa7cSTomi Valkeinen 
1379960aa7cSTomi Valkeinen struct dss_pll;
1389960aa7cSTomi Valkeinen 
1399960aa7cSTomi Valkeinen #define DSS_PLL_MAX_HSDIVS 4
1409960aa7cSTomi Valkeinen 
14106ede3ddSTomi Valkeinen enum dss_pll_type {
14206ede3ddSTomi Valkeinen 	DSS_PLL_TYPE_A,
14306ede3ddSTomi Valkeinen 	DSS_PLL_TYPE_B,
14406ede3ddSTomi Valkeinen };
14506ede3ddSTomi Valkeinen 
1469960aa7cSTomi Valkeinen /*
1479960aa7cSTomi Valkeinen  * Type-A PLLs: clkout[]/mX[] refer to hsdiv outputs m4, m5, m6, m7.
1489960aa7cSTomi Valkeinen  * Type-B PLLs: clkout[0] refers to m2.
1499960aa7cSTomi Valkeinen  */
1509960aa7cSTomi Valkeinen struct dss_pll_clock_info {
1519960aa7cSTomi Valkeinen 	/* rates that we get with dividers below */
1529960aa7cSTomi Valkeinen 	unsigned long fint;
1539960aa7cSTomi Valkeinen 	unsigned long clkdco;
1549960aa7cSTomi Valkeinen 	unsigned long clkout[DSS_PLL_MAX_HSDIVS];
1559960aa7cSTomi Valkeinen 
1569960aa7cSTomi Valkeinen 	/* dividers */
1579960aa7cSTomi Valkeinen 	u16 n;
1589960aa7cSTomi Valkeinen 	u16 m;
1599960aa7cSTomi Valkeinen 	u32 mf;
1609960aa7cSTomi Valkeinen 	u16 mX[DSS_PLL_MAX_HSDIVS];
1619960aa7cSTomi Valkeinen 	u16 sd;
1629960aa7cSTomi Valkeinen };
1639960aa7cSTomi Valkeinen 
1649960aa7cSTomi Valkeinen struct dss_pll_ops {
1659960aa7cSTomi Valkeinen 	int (*enable)(struct dss_pll *pll);
1669960aa7cSTomi Valkeinen 	void (*disable)(struct dss_pll *pll);
1679960aa7cSTomi Valkeinen 	int (*set_config)(struct dss_pll *pll,
1689960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
1699960aa7cSTomi Valkeinen };
1709960aa7cSTomi Valkeinen 
1719960aa7cSTomi Valkeinen struct dss_pll_hw {
17206ede3ddSTomi Valkeinen 	enum dss_pll_type type;
17306ede3ddSTomi Valkeinen 
174d11e5c82SLaurent Pinchart 	unsigned int n_max;
175d11e5c82SLaurent Pinchart 	unsigned int m_min;
176d11e5c82SLaurent Pinchart 	unsigned int m_max;
177d11e5c82SLaurent Pinchart 	unsigned int mX_max;
1789960aa7cSTomi Valkeinen 
1799960aa7cSTomi Valkeinen 	unsigned long fint_min, fint_max;
1809960aa7cSTomi Valkeinen 	unsigned long clkdco_min, clkdco_low, clkdco_max;
1819960aa7cSTomi Valkeinen 
1829960aa7cSTomi Valkeinen 	u8 n_msb, n_lsb;
1839960aa7cSTomi Valkeinen 	u8 m_msb, m_lsb;
1849960aa7cSTomi Valkeinen 	u8 mX_msb[DSS_PLL_MAX_HSDIVS], mX_lsb[DSS_PLL_MAX_HSDIVS];
1859960aa7cSTomi Valkeinen 
1869960aa7cSTomi Valkeinen 	bool has_stopmode;
1879960aa7cSTomi Valkeinen 	bool has_freqsel;
1889960aa7cSTomi Valkeinen 	bool has_selfreqdco;
1899960aa7cSTomi Valkeinen 	bool has_refsel;
1900c43f1e0STomi Valkeinen 
1910c43f1e0STomi Valkeinen 	/* DRA7 errata i886: use high N & M to avoid jitter */
1920c43f1e0STomi Valkeinen 	bool errata_i886;
1939960aa7cSTomi Valkeinen };
1949960aa7cSTomi Valkeinen 
1959960aa7cSTomi Valkeinen struct dss_pll {
1969960aa7cSTomi Valkeinen 	const char *name;
1979960aa7cSTomi Valkeinen 	enum dss_pll_id id;
1987b295257SLaurent Pinchart 	struct dss_device *dss;
1999960aa7cSTomi Valkeinen 
2009960aa7cSTomi Valkeinen 	struct clk *clkin;
2019960aa7cSTomi Valkeinen 	struct regulator *regulator;
2029960aa7cSTomi Valkeinen 
2039960aa7cSTomi Valkeinen 	void __iomem *base;
2049960aa7cSTomi Valkeinen 
2059960aa7cSTomi Valkeinen 	const struct dss_pll_hw *hw;
2069960aa7cSTomi Valkeinen 
2079960aa7cSTomi Valkeinen 	const struct dss_pll_ops *ops;
2089960aa7cSTomi Valkeinen 
2099960aa7cSTomi Valkeinen 	struct dss_pll_clock_info cinfo;
2109960aa7cSTomi Valkeinen };
2119960aa7cSTomi Valkeinen 
2126d85d4adSLaurent Pinchart /* Defines a generic omap register field */
2136d85d4adSLaurent Pinchart struct dss_reg_field {
2146d85d4adSLaurent Pinchart 	u8 start, end;
2156d85d4adSLaurent Pinchart };
2166d85d4adSLaurent Pinchart 
2179960aa7cSTomi Valkeinen struct dispc_clock_info {
2189960aa7cSTomi Valkeinen 	/* rates that we get with dividers below */
2199960aa7cSTomi Valkeinen 	unsigned long lck;
2209960aa7cSTomi Valkeinen 	unsigned long pck;
2219960aa7cSTomi Valkeinen 
2229960aa7cSTomi Valkeinen 	/* dividers */
2239960aa7cSTomi Valkeinen 	u16 lck_div;
2249960aa7cSTomi Valkeinen 	u16 pck_div;
2259960aa7cSTomi Valkeinen };
2269960aa7cSTomi Valkeinen 
2279960aa7cSTomi Valkeinen struct dss_lcd_mgr_config {
2289960aa7cSTomi Valkeinen 	enum dss_io_pad_mode io_pad_mode;
2299960aa7cSTomi Valkeinen 
2309960aa7cSTomi Valkeinen 	bool stallmode;
2319960aa7cSTomi Valkeinen 	bool fifohandcheck;
2329960aa7cSTomi Valkeinen 
2339960aa7cSTomi Valkeinen 	struct dispc_clock_info clock_info;
2349960aa7cSTomi Valkeinen 
2359960aa7cSTomi Valkeinen 	int video_port_width;
2369960aa7cSTomi Valkeinen 
2379960aa7cSTomi Valkeinen 	int lcden_sig_polarity;
2389960aa7cSTomi Valkeinen };
2399960aa7cSTomi Valkeinen 
2400e546dfdSLaurent Pinchart #define DSS_SZ_REGS			SZ_512
2410e546dfdSLaurent Pinchart 
2420e546dfdSLaurent Pinchart struct dss_device {
2430e546dfdSLaurent Pinchart 	struct platform_device *pdev;
2440e546dfdSLaurent Pinchart 	void __iomem    *base;
2450e546dfdSLaurent Pinchart 	struct regmap	*syscon_pll_ctrl;
2460e546dfdSLaurent Pinchart 	u32		syscon_pll_ctrl_offset;
2470e546dfdSLaurent Pinchart 
2480e546dfdSLaurent Pinchart 	struct clk	*parent_clk;
2490e546dfdSLaurent Pinchart 	struct clk	*dss_clk;
2500e546dfdSLaurent Pinchart 	unsigned long	dss_clk_rate;
2510e546dfdSLaurent Pinchart 
2520e546dfdSLaurent Pinchart 	unsigned long	cache_req_pck;
2530e546dfdSLaurent Pinchart 	unsigned long	cache_prate;
2540e546dfdSLaurent Pinchart 	struct dispc_clock_info cache_dispc_cinfo;
2550e546dfdSLaurent Pinchart 
2560e546dfdSLaurent Pinchart 	enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
2570e546dfdSLaurent Pinchart 	enum dss_clk_source dispc_clk_source;
2580e546dfdSLaurent Pinchart 	enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
2590e546dfdSLaurent Pinchart 
2600e546dfdSLaurent Pinchart 	bool		ctx_valid;
2610e546dfdSLaurent Pinchart 	u32		ctx[DSS_SZ_REGS / sizeof(u32)];
2620e546dfdSLaurent Pinchart 
2630e546dfdSLaurent Pinchart 	const struct dss_features *feat;
2640e546dfdSLaurent Pinchart 
265*f33656e1SLaurent Pinchart 	struct {
266*f33656e1SLaurent Pinchart 		struct dss_debugfs_entry *clk;
267*f33656e1SLaurent Pinchart 		struct dss_debugfs_entry *dss;
268*f33656e1SLaurent Pinchart 	} debugfs;
269*f33656e1SLaurent Pinchart 
2700e546dfdSLaurent Pinchart 	struct dss_pll	*video1_pll;
2710e546dfdSLaurent Pinchart 	struct dss_pll	*video2_pll;
2720e546dfdSLaurent Pinchart };
2730e546dfdSLaurent Pinchart 
2749960aa7cSTomi Valkeinen /* core */
275493b683bSLaurent Pinchart static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
276493b683bSLaurent Pinchart {
277493b683bSLaurent Pinchart 	/* To be implemented when the OMAP platform will provide this feature */
278493b683bSLaurent Pinchart 	return 0;
279493b683bSLaurent Pinchart }
280493b683bSLaurent Pinchart 
2819960aa7cSTomi Valkeinen static inline bool dss_mgr_is_lcd(enum omap_channel id)
2829960aa7cSTomi Valkeinen {
2839960aa7cSTomi Valkeinen 	if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
2849960aa7cSTomi Valkeinen 			id == OMAP_DSS_CHANNEL_LCD3)
2859960aa7cSTomi Valkeinen 		return true;
2869960aa7cSTomi Valkeinen 	else
2879960aa7cSTomi Valkeinen 		return false;
2889960aa7cSTomi Valkeinen }
2899960aa7cSTomi Valkeinen 
2909960aa7cSTomi Valkeinen /* DSS */
29111765d16SLaurent Pinchart #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
292*f33656e1SLaurent Pinchart struct dss_debugfs_entry *dss_debugfs_create_file(const char *name,
293*f33656e1SLaurent Pinchart 		int (*show_fn)(struct seq_file *s, void *data), void *data);
294*f33656e1SLaurent Pinchart void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
29511765d16SLaurent Pinchart #else
296*f33656e1SLaurent Pinchart static inline struct dss_debugfs_entry *
297*f33656e1SLaurent Pinchart dss_debugfs_create_file(const char *name,
298*f33656e1SLaurent Pinchart 			int (*show_fn)(struct seq_file *s, void *data),
299*f33656e1SLaurent Pinchart 			void *data)
30011765d16SLaurent Pinchart {
301*f33656e1SLaurent Pinchart 	return NULL;
302*f33656e1SLaurent Pinchart }
303*f33656e1SLaurent Pinchart 
304*f33656e1SLaurent Pinchart static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
305*f33656e1SLaurent Pinchart {
30611765d16SLaurent Pinchart }
30711765d16SLaurent Pinchart #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
30811765d16SLaurent Pinchart 
3097b295257SLaurent Pinchart struct dss_device *dss_get_device(struct device *dev);
3107b295257SLaurent Pinchart 
3117b295257SLaurent Pinchart int dss_runtime_get(struct dss_device *dss);
3127b295257SLaurent Pinchart void dss_runtime_put(struct dss_device *dss);
3139960aa7cSTomi Valkeinen 
31460f9c59fSLaurent Pinchart unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
31560f9c59fSLaurent Pinchart unsigned long dss_get_max_fck_rate(struct dss_device *dss);
3161ef904e1SLaurent Pinchart enum omap_dss_output_id dss_get_supported_outputs(struct dss_device *dss,
3171ef904e1SLaurent Pinchart 						  enum omap_channel channel);
3188aea8e6aSLaurent Pinchart int dss_dpi_select_source(struct dss_device *dss, int port,
3198aea8e6aSLaurent Pinchart 			  enum omap_channel channel);
3208aea8e6aSLaurent Pinchart void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
3218aea8e6aSLaurent Pinchart 				     enum dss_hdmi_venc_clk_source_select src);
322407bd564STomi Valkeinen const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
3239960aa7cSTomi Valkeinen 
3249960aa7cSTomi Valkeinen /* DSS VIDEO PLL */
3257b295257SLaurent Pinchart struct dss_pll *dss_video_pll_init(struct dss_device *dss,
3267b295257SLaurent Pinchart 				   struct platform_device *pdev, int id,
3279960aa7cSTomi Valkeinen 				   struct regulator *regulator);
3289960aa7cSTomi Valkeinen void dss_video_pll_uninit(struct dss_pll *pll);
3299960aa7cSTomi Valkeinen 
33027260999SLaurent Pinchart void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
3319960aa7cSTomi Valkeinen 
332d7157dfeSLaurent Pinchart void dss_sdi_init(struct dss_device *dss, int datapairs);
333d7157dfeSLaurent Pinchart int dss_sdi_enable(struct dss_device *dss);
334d7157dfeSLaurent Pinchart void dss_sdi_disable(struct dss_device *dss);
3359960aa7cSTomi Valkeinen 
3368aea8e6aSLaurent Pinchart void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
337dc0352d1STomi Valkeinen 			       enum dss_clk_source clk_src);
3388aea8e6aSLaurent Pinchart void dss_select_lcd_clk_source(struct dss_device *dss,
3398aea8e6aSLaurent Pinchart 			       enum omap_channel channel,
340dc0352d1STomi Valkeinen 			       enum dss_clk_source clk_src);
3413cc62aadSLaurent Pinchart enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss);
3423cc62aadSLaurent Pinchart enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
3433cc62aadSLaurent Pinchart 					   int dsi_module);
3443cc62aadSLaurent Pinchart enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
3453cc62aadSLaurent Pinchart 					   enum omap_channel channel);
3469960aa7cSTomi Valkeinen 
3471ef904e1SLaurent Pinchart void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type);
3481ef904e1SLaurent Pinchart void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable);
3499960aa7cSTomi Valkeinen 
35060f9c59fSLaurent Pinchart int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
3519960aa7cSTomi Valkeinen 
3529960aa7cSTomi Valkeinen typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
35360f9c59fSLaurent Pinchart bool dss_div_calc(struct dss_device *dss, unsigned long pck,
35460f9c59fSLaurent Pinchart 		  unsigned long fck_min, dss_div_calc_func func, void *data);
3559960aa7cSTomi Valkeinen 
3569960aa7cSTomi Valkeinen /* SDI */
3579960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_SDI
358d7157dfeSLaurent Pinchart int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
359d7157dfeSLaurent Pinchart 		  struct device_node *port);
3609960aa7cSTomi Valkeinen void sdi_uninit_port(struct device_node *port);
3619960aa7cSTomi Valkeinen #else
362d7157dfeSLaurent Pinchart static inline int sdi_init_port(struct dss_device *dss,
363d7157dfeSLaurent Pinchart 				struct platform_device *pdev,
3649960aa7cSTomi Valkeinen 				struct device_node *port)
3659960aa7cSTomi Valkeinen {
3669960aa7cSTomi Valkeinen 	return 0;
3679960aa7cSTomi Valkeinen }
3689960aa7cSTomi Valkeinen static inline void sdi_uninit_port(struct device_node *port)
3699960aa7cSTomi Valkeinen {
3709960aa7cSTomi Valkeinen }
3719960aa7cSTomi Valkeinen #endif
3729960aa7cSTomi Valkeinen 
3739960aa7cSTomi Valkeinen /* DSI */
3749960aa7cSTomi Valkeinen 
3759960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_DSI
3769960aa7cSTomi Valkeinen 
3779960aa7cSTomi Valkeinen void dsi_dump_clocks(struct seq_file *s);
3789960aa7cSTomi Valkeinen 
3799960aa7cSTomi Valkeinen void dsi_irq_handler(void);
3809960aa7cSTomi Valkeinen 
3819960aa7cSTomi Valkeinen #endif
3829960aa7cSTomi Valkeinen 
3839960aa7cSTomi Valkeinen /* DPI */
3849960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_DPI
3858aea8e6aSLaurent Pinchart int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
3868aea8e6aSLaurent Pinchart 		  struct device_node *port, enum dss_model dss_model);
3879960aa7cSTomi Valkeinen void dpi_uninit_port(struct device_node *port);
3889960aa7cSTomi Valkeinen #else
3898aea8e6aSLaurent Pinchart static inline int dpi_init_port(struct dss_device *port,
3908aea8e6aSLaurent Pinchart 				struct platform_device *pdev,
3918aea8e6aSLaurent Pinchart 				struct device_node *port,
3928aea8e6aSLaurent Pinchart 				enum dss_model dss_model)
3939960aa7cSTomi Valkeinen {
3949960aa7cSTomi Valkeinen 	return 0;
3959960aa7cSTomi Valkeinen }
3969960aa7cSTomi Valkeinen static inline void dpi_uninit_port(struct device_node *port)
3979960aa7cSTomi Valkeinen {
3989960aa7cSTomi Valkeinen }
3999960aa7cSTomi Valkeinen #endif
4009960aa7cSTomi Valkeinen 
4019960aa7cSTomi Valkeinen /* DISPC */
4029960aa7cSTomi Valkeinen void dispc_dump_clocks(struct seq_file *s);
4039960aa7cSTomi Valkeinen 
4045034b1faSTomi Valkeinen int dispc_runtime_get(void);
4055034b1faSTomi Valkeinen void dispc_runtime_put(void);
4065034b1faSTomi Valkeinen 
4079960aa7cSTomi Valkeinen void dispc_enable_sidle(void);
4089960aa7cSTomi Valkeinen void dispc_disable_sidle(void);
4099960aa7cSTomi Valkeinen 
4109960aa7cSTomi Valkeinen void dispc_lcd_enable_signal(bool enable);
4119960aa7cSTomi Valkeinen void dispc_pck_free_enable(bool enable);
4129960aa7cSTomi Valkeinen void dispc_enable_fifomerge(bool enable);
4139960aa7cSTomi Valkeinen 
4149960aa7cSTomi Valkeinen typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
4159960aa7cSTomi Valkeinen 		unsigned long pck, void *data);
4169960aa7cSTomi Valkeinen bool dispc_div_calc(unsigned long dispc,
4179960aa7cSTomi Valkeinen 		unsigned long pck_min, unsigned long pck_max,
4189960aa7cSTomi Valkeinen 		dispc_div_calc_func func, void *data);
4199960aa7cSTomi Valkeinen 
420da11bbbbSPeter Ujfalusi bool dispc_mgr_timings_ok(enum omap_channel channel, const struct videomode *vm);
4219960aa7cSTomi Valkeinen int dispc_calc_clock_rates(unsigned long dispc_fclk_rate,
4229960aa7cSTomi Valkeinen 		struct dispc_clock_info *cinfo);
4239960aa7cSTomi Valkeinen 
4249960aa7cSTomi Valkeinen 
425864050c7SJyri Sarha void dispc_ovl_set_fifo_threshold(enum omap_plane_id plane, u32 low,
426864050c7SJyri Sarha 				  u32 high);
427864050c7SJyri Sarha void dispc_ovl_compute_fifo_thresholds(enum omap_plane_id plane,
4289960aa7cSTomi Valkeinen 		u32 *fifo_low, u32 *fifo_high, bool use_fifomerge,
4299960aa7cSTomi Valkeinen 		bool manual_update);
4309960aa7cSTomi Valkeinen 
4319960aa7cSTomi Valkeinen void dispc_mgr_set_clock_div(enum omap_channel channel,
4329960aa7cSTomi Valkeinen 		const struct dispc_clock_info *cinfo);
4339960aa7cSTomi Valkeinen int dispc_mgr_get_clock_div(enum omap_channel channel,
4349960aa7cSTomi Valkeinen 		struct dispc_clock_info *cinfo);
4359960aa7cSTomi Valkeinen void dispc_set_tv_pclk(unsigned long pclk);
4369960aa7cSTomi Valkeinen 
4379960aa7cSTomi Valkeinen u32 dispc_wb_get_framedone_irq(void);
4389960aa7cSTomi Valkeinen bool dispc_wb_go_busy(void);
4399960aa7cSTomi Valkeinen void dispc_wb_go(void);
4409960aa7cSTomi Valkeinen void dispc_wb_set_channel_in(enum dss_writeback_channel channel);
4419960aa7cSTomi Valkeinen int dispc_wb_setup(const struct omap_dss_writeback_info *wi,
442da11bbbbSPeter Ujfalusi 		bool mem_to_mem, const struct videomode *vm);
4439960aa7cSTomi Valkeinen 
4449960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
445d11e5c82SLaurent Pinchart static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr)
4469960aa7cSTomi Valkeinen {
4479960aa7cSTomi Valkeinen 	int b;
4489960aa7cSTomi Valkeinen 	for (b = 0; b < 32; ++b) {
4499960aa7cSTomi Valkeinen 		if (irqstatus & (1 << b))
4509960aa7cSTomi Valkeinen 			irq_arr[b]++;
4519960aa7cSTomi Valkeinen 	}
4529960aa7cSTomi Valkeinen }
4539960aa7cSTomi Valkeinen #endif
4549960aa7cSTomi Valkeinen 
4559960aa7cSTomi Valkeinen /* PLL */
4569960aa7cSTomi Valkeinen typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
4579960aa7cSTomi Valkeinen 		unsigned long clkdco, void *data);
4589960aa7cSTomi Valkeinen typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
4599960aa7cSTomi Valkeinen 		void *data);
4609960aa7cSTomi Valkeinen 
4619960aa7cSTomi Valkeinen int dss_pll_register(struct dss_pll *pll);
4629960aa7cSTomi Valkeinen void dss_pll_unregister(struct dss_pll *pll);
4639960aa7cSTomi Valkeinen struct dss_pll *dss_pll_find(const char *name);
4645670bd72STomi Valkeinen struct dss_pll *dss_pll_find_by_src(enum dss_clk_source src);
465d11e5c82SLaurent Pinchart unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
4669960aa7cSTomi Valkeinen int dss_pll_enable(struct dss_pll *pll);
4679960aa7cSTomi Valkeinen void dss_pll_disable(struct dss_pll *pll);
4689960aa7cSTomi Valkeinen int dss_pll_set_config(struct dss_pll *pll,
4699960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
4709960aa7cSTomi Valkeinen 
471cd0715ffSTomi Valkeinen bool dss_pll_hsdiv_calc_a(const struct dss_pll *pll, unsigned long clkdco,
4729960aa7cSTomi Valkeinen 		unsigned long out_min, unsigned long out_max,
4739960aa7cSTomi Valkeinen 		dss_hsdiv_calc_func func, void *data);
474cd0715ffSTomi Valkeinen bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
4759960aa7cSTomi Valkeinen 		unsigned long pll_min, unsigned long pll_max,
4769960aa7cSTomi Valkeinen 		dss_pll_calc_func func, void *data);
477c17dc0e3STomi Valkeinen 
478c17dc0e3STomi Valkeinen bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin,
479c107751dSTomi Valkeinen 	unsigned long target_clkout, struct dss_pll_clock_info *cinfo);
480c17dc0e3STomi Valkeinen 
4819960aa7cSTomi Valkeinen int dss_pll_write_config_type_a(struct dss_pll *pll,
4829960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
4839960aa7cSTomi Valkeinen int dss_pll_write_config_type_b(struct dss_pll *pll,
4849960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
4859960aa7cSTomi Valkeinen int dss_pll_wait_reset_done(struct dss_pll *pll);
4869960aa7cSTomi Valkeinen 
487d66c36a3SAndrew F. Davis extern struct platform_driver omap_dsshw_driver;
488d66c36a3SAndrew F. Davis extern struct platform_driver omap_dispchw_driver;
489d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP2_DSS_DSI
490d66c36a3SAndrew F. Davis extern struct platform_driver omap_dsihw_driver;
491d66c36a3SAndrew F. Davis #endif
492d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP2_DSS_VENC
493d66c36a3SAndrew F. Davis extern struct platform_driver omap_venchw_driver;
494d66c36a3SAndrew F. Davis #endif
495d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP4_DSS_HDMI
496d66c36a3SAndrew F. Davis extern struct platform_driver omapdss_hdmi4hw_driver;
497d66c36a3SAndrew F. Davis #endif
498d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP5_DSS_HDMI
499d66c36a3SAndrew F. Davis extern struct platform_driver omapdss_hdmi5hw_driver;
500d66c36a3SAndrew F. Davis #endif
501d66c36a3SAndrew F. Davis 
5029960aa7cSTomi Valkeinen #endif
503