xref: /openbmc/linux/drivers/gpu/drm/omapdrm/dss/dss.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1caab277bSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
29960aa7cSTomi Valkeinen /*
39960aa7cSTomi Valkeinen  * Copyright (C) 2009 Nokia Corporation
46505d75cSTomi Valkeinen  * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
59960aa7cSTomi Valkeinen  *
69960aa7cSTomi Valkeinen  * Some code and ideas taken from drivers/video/omap/ driver
79960aa7cSTomi Valkeinen  * by Imre Deak.
89960aa7cSTomi Valkeinen  */
99960aa7cSTomi Valkeinen 
109960aa7cSTomi Valkeinen #ifndef __OMAP2_DSS_H
119960aa7cSTomi Valkeinen #define __OMAP2_DSS_H
129960aa7cSTomi Valkeinen 
139960aa7cSTomi Valkeinen #include <linux/interrupt.h>
149960aa7cSTomi Valkeinen 
1535a339acSTomi Valkeinen #include "omapdss.h"
1635a339acSTomi Valkeinen 
1750638ae5SLaurent Pinchart struct dispc_device;
18f33656e1SLaurent Pinchart struct dss_debugfs_entry;
19f33656e1SLaurent Pinchart struct platform_device;
20f33656e1SLaurent Pinchart struct seq_file;
21f33656e1SLaurent Pinchart 
22d874b3a7SLaurent Pinchart #define MAX_DSS_LCD_MANAGERS	3
23d874b3a7SLaurent Pinchart #define MAX_NUM_DSI		2
24d874b3a7SLaurent Pinchart 
259960aa7cSTomi Valkeinen #ifdef pr_fmt
269960aa7cSTomi Valkeinen #undef pr_fmt
279960aa7cSTomi Valkeinen #endif
289960aa7cSTomi Valkeinen 
299960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
309960aa7cSTomi Valkeinen #define pr_fmt(fmt) DSS_SUBSYS_NAME ": " fmt
319960aa7cSTomi Valkeinen #else
329960aa7cSTomi Valkeinen #define pr_fmt(fmt) fmt
339960aa7cSTomi Valkeinen #endif
349960aa7cSTomi Valkeinen 
359960aa7cSTomi Valkeinen #define DSSDBG(format, ...) \
369960aa7cSTomi Valkeinen 	pr_debug(format, ## __VA_ARGS__)
379960aa7cSTomi Valkeinen 
389960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
399960aa7cSTomi Valkeinen #define DSSERR(format, ...) \
408dfe162aSJoe Perches 	pr_err("omapdss " DSS_SUBSYS_NAME " error: " format, ##__VA_ARGS__)
419960aa7cSTomi Valkeinen #else
429960aa7cSTomi Valkeinen #define DSSERR(format, ...) \
438dfe162aSJoe Perches 	pr_err("omapdss error: " format, ##__VA_ARGS__)
449960aa7cSTomi Valkeinen #endif
459960aa7cSTomi Valkeinen 
469960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
479960aa7cSTomi Valkeinen #define DSSINFO(format, ...) \
488dfe162aSJoe Perches 	pr_info("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
499960aa7cSTomi Valkeinen #else
509960aa7cSTomi Valkeinen #define DSSINFO(format, ...) \
518dfe162aSJoe Perches 	pr_info("omapdss: " format, ## __VA_ARGS__)
529960aa7cSTomi Valkeinen #endif
539960aa7cSTomi Valkeinen 
549960aa7cSTomi Valkeinen #ifdef DSS_SUBSYS_NAME
559960aa7cSTomi Valkeinen #define DSSWARN(format, ...) \
568dfe162aSJoe Perches 	pr_warn("omapdss " DSS_SUBSYS_NAME ": " format, ##__VA_ARGS__)
579960aa7cSTomi Valkeinen #else
589960aa7cSTomi Valkeinen #define DSSWARN(format, ...) \
598dfe162aSJoe Perches 	pr_warn("omapdss: " format, ##__VA_ARGS__)
609960aa7cSTomi Valkeinen #endif
619960aa7cSTomi Valkeinen 
629960aa7cSTomi Valkeinen /* OMAP TRM gives bitfields as start:end, where start is the higher bit
639960aa7cSTomi Valkeinen    number. For example 7:0 */
649960aa7cSTomi Valkeinen #define FLD_MASK(start, end)	(((1 << ((start) - (end) + 1)) - 1) << (end))
659960aa7cSTomi Valkeinen #define FLD_VAL(val, start, end) (((val) << (end)) & FLD_MASK(start, end))
669960aa7cSTomi Valkeinen #define FLD_GET(val, start, end) (((val) & FLD_MASK(start, end)) >> (end))
679960aa7cSTomi Valkeinen #define FLD_MOD(orig, val, start, end) \
689960aa7cSTomi Valkeinen 	(((orig) & ~FLD_MASK(start, end)) | FLD_VAL(val, start, end))
699960aa7cSTomi Valkeinen 
70b8dab2bdSLaurent Pinchart enum dss_model {
71b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP2,
72b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP3,
73b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP4,
74b8dab2bdSLaurent Pinchart 	DSS_MODEL_OMAP5,
75b8dab2bdSLaurent Pinchart 	DSS_MODEL_DRA7,
76b8dab2bdSLaurent Pinchart };
77b8dab2bdSLaurent Pinchart 
789960aa7cSTomi Valkeinen enum dss_io_pad_mode {
799960aa7cSTomi Valkeinen 	DSS_IO_PAD_MODE_RESET,
809960aa7cSTomi Valkeinen 	DSS_IO_PAD_MODE_RFBI,
819960aa7cSTomi Valkeinen 	DSS_IO_PAD_MODE_BYPASS,
829960aa7cSTomi Valkeinen };
839960aa7cSTomi Valkeinen 
849960aa7cSTomi Valkeinen enum dss_hdmi_venc_clk_source_select {
859960aa7cSTomi Valkeinen 	DSS_VENC_TV_CLK = 0,
869960aa7cSTomi Valkeinen 	DSS_HDMI_M_PCLK = 1,
879960aa7cSTomi Valkeinen };
889960aa7cSTomi Valkeinen 
899960aa7cSTomi Valkeinen enum dss_dsi_content_type {
909960aa7cSTomi Valkeinen 	DSS_DSI_CONTENT_DCS,
919960aa7cSTomi Valkeinen 	DSS_DSI_CONTENT_GENERIC,
929960aa7cSTomi Valkeinen };
939960aa7cSTomi Valkeinen 
94dc0352d1STomi Valkeinen enum dss_clk_source {
953b63ca75STomi Valkeinen 	DSS_CLK_SRC_FCK = 0,
963b63ca75STomi Valkeinen 
973b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL1_1,
983b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL1_2,
99b5d8c757STomi Valkeinen 	DSS_CLK_SRC_PLL1_3,
1003b63ca75STomi Valkeinen 
1013b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL2_1,
1023b63ca75STomi Valkeinen 	DSS_CLK_SRC_PLL2_2,
103b5d8c757STomi Valkeinen 	DSS_CLK_SRC_PLL2_3,
104b5d8c757STomi Valkeinen 
105b5d8c757STomi Valkeinen 	DSS_CLK_SRC_HDMI_PLL,
106be5d7319STomi Valkeinen };
107be5d7319STomi Valkeinen 
1089960aa7cSTomi Valkeinen enum dss_pll_id {
1099960aa7cSTomi Valkeinen 	DSS_PLL_DSI1,
1109960aa7cSTomi Valkeinen 	DSS_PLL_DSI2,
1119960aa7cSTomi Valkeinen 	DSS_PLL_HDMI,
1129960aa7cSTomi Valkeinen 	DSS_PLL_VIDEO1,
1139960aa7cSTomi Valkeinen 	DSS_PLL_VIDEO2,
1149960aa7cSTomi Valkeinen };
1159960aa7cSTomi Valkeinen 
1169960aa7cSTomi Valkeinen struct dss_pll;
1179960aa7cSTomi Valkeinen 
1189960aa7cSTomi Valkeinen #define DSS_PLL_MAX_HSDIVS 4
1199960aa7cSTomi Valkeinen 
12006ede3ddSTomi Valkeinen enum dss_pll_type {
12106ede3ddSTomi Valkeinen 	DSS_PLL_TYPE_A,
12206ede3ddSTomi Valkeinen 	DSS_PLL_TYPE_B,
12306ede3ddSTomi Valkeinen };
12406ede3ddSTomi Valkeinen 
1259960aa7cSTomi Valkeinen /*
1269960aa7cSTomi Valkeinen  * Type-A PLLs: clkout[]/mX[] refer to hsdiv outputs m4, m5, m6, m7.
1279960aa7cSTomi Valkeinen  * Type-B PLLs: clkout[0] refers to m2.
1289960aa7cSTomi Valkeinen  */
1299960aa7cSTomi Valkeinen struct dss_pll_clock_info {
1309960aa7cSTomi Valkeinen 	/* rates that we get with dividers below */
1319960aa7cSTomi Valkeinen 	unsigned long fint;
1329960aa7cSTomi Valkeinen 	unsigned long clkdco;
1339960aa7cSTomi Valkeinen 	unsigned long clkout[DSS_PLL_MAX_HSDIVS];
1349960aa7cSTomi Valkeinen 
1359960aa7cSTomi Valkeinen 	/* dividers */
1369960aa7cSTomi Valkeinen 	u16 n;
1379960aa7cSTomi Valkeinen 	u16 m;
1389960aa7cSTomi Valkeinen 	u32 mf;
1399960aa7cSTomi Valkeinen 	u16 mX[DSS_PLL_MAX_HSDIVS];
1409960aa7cSTomi Valkeinen 	u16 sd;
1419960aa7cSTomi Valkeinen };
1429960aa7cSTomi Valkeinen 
1439960aa7cSTomi Valkeinen struct dss_pll_ops {
1449960aa7cSTomi Valkeinen 	int (*enable)(struct dss_pll *pll);
1459960aa7cSTomi Valkeinen 	void (*disable)(struct dss_pll *pll);
1469960aa7cSTomi Valkeinen 	int (*set_config)(struct dss_pll *pll,
1479960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
1489960aa7cSTomi Valkeinen };
1499960aa7cSTomi Valkeinen 
1509960aa7cSTomi Valkeinen struct dss_pll_hw {
15106ede3ddSTomi Valkeinen 	enum dss_pll_type type;
15206ede3ddSTomi Valkeinen 
153d11e5c82SLaurent Pinchart 	unsigned int n_max;
154d11e5c82SLaurent Pinchart 	unsigned int m_min;
155d11e5c82SLaurent Pinchart 	unsigned int m_max;
156d11e5c82SLaurent Pinchart 	unsigned int mX_max;
1579960aa7cSTomi Valkeinen 
1589960aa7cSTomi Valkeinen 	unsigned long fint_min, fint_max;
1599960aa7cSTomi Valkeinen 	unsigned long clkdco_min, clkdco_low, clkdco_max;
1609960aa7cSTomi Valkeinen 
1619960aa7cSTomi Valkeinen 	u8 n_msb, n_lsb;
1629960aa7cSTomi Valkeinen 	u8 m_msb, m_lsb;
1639960aa7cSTomi Valkeinen 	u8 mX_msb[DSS_PLL_MAX_HSDIVS], mX_lsb[DSS_PLL_MAX_HSDIVS];
1649960aa7cSTomi Valkeinen 
1659960aa7cSTomi Valkeinen 	bool has_stopmode;
1669960aa7cSTomi Valkeinen 	bool has_freqsel;
1679960aa7cSTomi Valkeinen 	bool has_selfreqdco;
1689960aa7cSTomi Valkeinen 	bool has_refsel;
1690c43f1e0STomi Valkeinen 
1700c43f1e0STomi Valkeinen 	/* DRA7 errata i886: use high N & M to avoid jitter */
1710c43f1e0STomi Valkeinen 	bool errata_i886;
172c618a3a9SVenkateswara Rao Mandela 
173c618a3a9SVenkateswara Rao Mandela 	/* DRA7 errata i932: retry pll lock on failure */
174c618a3a9SVenkateswara Rao Mandela 	bool errata_i932;
1759960aa7cSTomi Valkeinen };
1769960aa7cSTomi Valkeinen 
1779960aa7cSTomi Valkeinen struct dss_pll {
1789960aa7cSTomi Valkeinen 	const char *name;
1799960aa7cSTomi Valkeinen 	enum dss_pll_id id;
1807b295257SLaurent Pinchart 	struct dss_device *dss;
1819960aa7cSTomi Valkeinen 
1829960aa7cSTomi Valkeinen 	struct clk *clkin;
1839960aa7cSTomi Valkeinen 	struct regulator *regulator;
1849960aa7cSTomi Valkeinen 
1859960aa7cSTomi Valkeinen 	void __iomem *base;
1869960aa7cSTomi Valkeinen 
1879960aa7cSTomi Valkeinen 	const struct dss_pll_hw *hw;
1889960aa7cSTomi Valkeinen 
1899960aa7cSTomi Valkeinen 	const struct dss_pll_ops *ops;
1909960aa7cSTomi Valkeinen 
1919960aa7cSTomi Valkeinen 	struct dss_pll_clock_info cinfo;
1929960aa7cSTomi Valkeinen };
1939960aa7cSTomi Valkeinen 
1946d85d4adSLaurent Pinchart /* Defines a generic omap register field */
1956d85d4adSLaurent Pinchart struct dss_reg_field {
1966d85d4adSLaurent Pinchart 	u8 start, end;
1976d85d4adSLaurent Pinchart };
1986d85d4adSLaurent Pinchart 
1999960aa7cSTomi Valkeinen struct dispc_clock_info {
2009960aa7cSTomi Valkeinen 	/* rates that we get with dividers below */
2019960aa7cSTomi Valkeinen 	unsigned long lck;
2029960aa7cSTomi Valkeinen 	unsigned long pck;
2039960aa7cSTomi Valkeinen 
2049960aa7cSTomi Valkeinen 	/* dividers */
2059960aa7cSTomi Valkeinen 	u16 lck_div;
2069960aa7cSTomi Valkeinen 	u16 pck_div;
2079960aa7cSTomi Valkeinen };
2089960aa7cSTomi Valkeinen 
2099960aa7cSTomi Valkeinen struct dss_lcd_mgr_config {
2109960aa7cSTomi Valkeinen 	enum dss_io_pad_mode io_pad_mode;
2119960aa7cSTomi Valkeinen 
2129960aa7cSTomi Valkeinen 	bool stallmode;
2139960aa7cSTomi Valkeinen 	bool fifohandcheck;
2149960aa7cSTomi Valkeinen 
2159960aa7cSTomi Valkeinen 	struct dispc_clock_info clock_info;
2169960aa7cSTomi Valkeinen 
2179960aa7cSTomi Valkeinen 	int video_port_width;
2189960aa7cSTomi Valkeinen 
2199960aa7cSTomi Valkeinen 	int lcden_sig_polarity;
2209960aa7cSTomi Valkeinen };
2219960aa7cSTomi Valkeinen 
2220e546dfdSLaurent Pinchart #define DSS_SZ_REGS			SZ_512
2230e546dfdSLaurent Pinchart 
2240e546dfdSLaurent Pinchart struct dss_device {
2250e546dfdSLaurent Pinchart 	struct platform_device *pdev;
2260e546dfdSLaurent Pinchart 	void __iomem    *base;
2270e546dfdSLaurent Pinchart 	struct regmap	*syscon_pll_ctrl;
2280e546dfdSLaurent Pinchart 	u32		syscon_pll_ctrl_offset;
2290e546dfdSLaurent Pinchart 
230cc1876ceSJyri Sarha 	struct platform_device *drm_pdev;
231cc1876ceSJyri Sarha 
2320e546dfdSLaurent Pinchart 	struct clk	*parent_clk;
2330e546dfdSLaurent Pinchart 	struct clk	*dss_clk;
2340e546dfdSLaurent Pinchart 	unsigned long	dss_clk_rate;
2350e546dfdSLaurent Pinchart 
2360e546dfdSLaurent Pinchart 	unsigned long	cache_req_pck;
2370e546dfdSLaurent Pinchart 	unsigned long	cache_prate;
2380e546dfdSLaurent Pinchart 	struct dispc_clock_info cache_dispc_cinfo;
2390e546dfdSLaurent Pinchart 
2400e546dfdSLaurent Pinchart 	enum dss_clk_source dsi_clk_source[MAX_NUM_DSI];
2410e546dfdSLaurent Pinchart 	enum dss_clk_source dispc_clk_source;
2420e546dfdSLaurent Pinchart 	enum dss_clk_source lcd_clk_source[MAX_DSS_LCD_MANAGERS];
2430e546dfdSLaurent Pinchart 
2440e546dfdSLaurent Pinchart 	bool		ctx_valid;
2450e546dfdSLaurent Pinchart 	u32		ctx[DSS_SZ_REGS / sizeof(u32)];
2460e546dfdSLaurent Pinchart 
2470e546dfdSLaurent Pinchart 	const struct dss_features *feat;
2480e546dfdSLaurent Pinchart 
249f33656e1SLaurent Pinchart 	struct {
2501c4b92eeSLaurent Pinchart 		struct dentry *root;
251f33656e1SLaurent Pinchart 		struct dss_debugfs_entry *clk;
252f33656e1SLaurent Pinchart 		struct dss_debugfs_entry *dss;
253f33656e1SLaurent Pinchart 	} debugfs;
254f33656e1SLaurent Pinchart 
255798957aeSLaurent Pinchart 	struct dss_pll *plls[4];
2560e546dfdSLaurent Pinchart 	struct dss_pll	*video1_pll;
2570e546dfdSLaurent Pinchart 	struct dss_pll	*video2_pll;
258d3541ca8SLaurent Pinchart 
25950638ae5SLaurent Pinchart 	struct dispc_device *dispc;
260845417b3SLaurent Pinchart 	struct omap_drm_private *mgr_ops_priv;
2610e546dfdSLaurent Pinchart };
2620e546dfdSLaurent Pinchart 
2639960aa7cSTomi Valkeinen /* core */
dss_set_min_bus_tput(struct device * dev,unsigned long tput)264493b683bSLaurent Pinchart static inline int dss_set_min_bus_tput(struct device *dev, unsigned long tput)
265493b683bSLaurent Pinchart {
266493b683bSLaurent Pinchart 	/* To be implemented when the OMAP platform will provide this feature */
267493b683bSLaurent Pinchart 	return 0;
268493b683bSLaurent Pinchart }
269493b683bSLaurent Pinchart 
dss_mgr_is_lcd(enum omap_channel id)2709960aa7cSTomi Valkeinen static inline bool dss_mgr_is_lcd(enum omap_channel id)
2719960aa7cSTomi Valkeinen {
2729960aa7cSTomi Valkeinen 	if (id == OMAP_DSS_CHANNEL_LCD || id == OMAP_DSS_CHANNEL_LCD2 ||
2739960aa7cSTomi Valkeinen 			id == OMAP_DSS_CHANNEL_LCD3)
2749960aa7cSTomi Valkeinen 		return true;
2759960aa7cSTomi Valkeinen 	else
2769960aa7cSTomi Valkeinen 		return false;
2779960aa7cSTomi Valkeinen }
2789960aa7cSTomi Valkeinen 
2799960aa7cSTomi Valkeinen /* DSS */
28011765d16SLaurent Pinchart #if defined(CONFIG_OMAP2_DSS_DEBUGFS)
2811c4b92eeSLaurent Pinchart struct dss_debugfs_entry *
2821c4b92eeSLaurent Pinchart dss_debugfs_create_file(struct dss_device *dss, const char *name,
2831c4b92eeSLaurent Pinchart 			int (*show_fn)(struct seq_file *s, void *data),
2841c4b92eeSLaurent Pinchart 			void *data);
285f33656e1SLaurent Pinchart void dss_debugfs_remove_file(struct dss_debugfs_entry *entry);
28611765d16SLaurent Pinchart #else
287f33656e1SLaurent Pinchart static inline struct dss_debugfs_entry *
dss_debugfs_create_file(struct dss_device * dss,const char * name,int (* show_fn)(struct seq_file * s,void * data),void * data)2881c4b92eeSLaurent Pinchart dss_debugfs_create_file(struct dss_device *dss, const char *name,
289f33656e1SLaurent Pinchart 			int (*show_fn)(struct seq_file *s, void *data),
290f33656e1SLaurent Pinchart 			void *data)
29111765d16SLaurent Pinchart {
292f33656e1SLaurent Pinchart 	return NULL;
293f33656e1SLaurent Pinchart }
294f33656e1SLaurent Pinchart 
dss_debugfs_remove_file(struct dss_debugfs_entry * entry)295f33656e1SLaurent Pinchart static inline void dss_debugfs_remove_file(struct dss_debugfs_entry *entry)
296f33656e1SLaurent Pinchart {
29711765d16SLaurent Pinchart }
29811765d16SLaurent Pinchart #endif /* CONFIG_OMAP2_DSS_DEBUGFS */
29911765d16SLaurent Pinchart 
3007b295257SLaurent Pinchart struct dss_device *dss_get_device(struct device *dev);
3017b295257SLaurent Pinchart 
3027b295257SLaurent Pinchart int dss_runtime_get(struct dss_device *dss);
3037b295257SLaurent Pinchart void dss_runtime_put(struct dss_device *dss);
3049960aa7cSTomi Valkeinen 
30560f9c59fSLaurent Pinchart unsigned long dss_get_dispc_clk_rate(struct dss_device *dss);
30660f9c59fSLaurent Pinchart unsigned long dss_get_max_fck_rate(struct dss_device *dss);
3078aea8e6aSLaurent Pinchart int dss_dpi_select_source(struct dss_device *dss, int port,
3088aea8e6aSLaurent Pinchart 			  enum omap_channel channel);
3098aea8e6aSLaurent Pinchart void dss_select_hdmi_venc_clk_source(struct dss_device *dss,
3108aea8e6aSLaurent Pinchart 				     enum dss_hdmi_venc_clk_source_select src);
311407bd564STomi Valkeinen const char *dss_get_clk_source_name(enum dss_clk_source clk_src);
3129960aa7cSTomi Valkeinen 
3139960aa7cSTomi Valkeinen /* DSS VIDEO PLL */
3147b295257SLaurent Pinchart struct dss_pll *dss_video_pll_init(struct dss_device *dss,
3157b295257SLaurent Pinchart 				   struct platform_device *pdev, int id,
3169960aa7cSTomi Valkeinen 				   struct regulator *regulator);
3179960aa7cSTomi Valkeinen void dss_video_pll_uninit(struct dss_pll *pll);
3189960aa7cSTomi Valkeinen 
31927260999SLaurent Pinchart void dss_ctrl_pll_enable(struct dss_pll *pll, bool enable);
3209960aa7cSTomi Valkeinen 
321d7157dfeSLaurent Pinchart void dss_sdi_init(struct dss_device *dss, int datapairs);
322d7157dfeSLaurent Pinchart int dss_sdi_enable(struct dss_device *dss);
323d7157dfeSLaurent Pinchart void dss_sdi_disable(struct dss_device *dss);
3249960aa7cSTomi Valkeinen 
3258aea8e6aSLaurent Pinchart void dss_select_dsi_clk_source(struct dss_device *dss, int dsi_module,
326dc0352d1STomi Valkeinen 			       enum dss_clk_source clk_src);
3278aea8e6aSLaurent Pinchart void dss_select_lcd_clk_source(struct dss_device *dss,
3288aea8e6aSLaurent Pinchart 			       enum omap_channel channel,
329dc0352d1STomi Valkeinen 			       enum dss_clk_source clk_src);
3303cc62aadSLaurent Pinchart enum dss_clk_source dss_get_dispc_clk_source(struct dss_device *dss);
3313cc62aadSLaurent Pinchart enum dss_clk_source dss_get_dsi_clk_source(struct dss_device *dss,
3323cc62aadSLaurent Pinchart 					   int dsi_module);
3333cc62aadSLaurent Pinchart enum dss_clk_source dss_get_lcd_clk_source(struct dss_device *dss,
3343cc62aadSLaurent Pinchart 					   enum omap_channel channel);
3359960aa7cSTomi Valkeinen 
3361ef904e1SLaurent Pinchart void dss_set_venc_output(struct dss_device *dss, enum omap_dss_venc_type type);
3371ef904e1SLaurent Pinchart void dss_set_dac_pwrdn_bgz(struct dss_device *dss, bool enable);
3389960aa7cSTomi Valkeinen 
33960f9c59fSLaurent Pinchart int dss_set_fck_rate(struct dss_device *dss, unsigned long rate);
3409960aa7cSTomi Valkeinen 
3419960aa7cSTomi Valkeinen typedef bool (*dss_div_calc_func)(unsigned long fck, void *data);
34260f9c59fSLaurent Pinchart bool dss_div_calc(struct dss_device *dss, unsigned long pck,
34360f9c59fSLaurent Pinchart 		  unsigned long fck_min, dss_div_calc_func func, void *data);
3449960aa7cSTomi Valkeinen 
3459960aa7cSTomi Valkeinen /* SDI */
3469960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_SDI
347d7157dfeSLaurent Pinchart int sdi_init_port(struct dss_device *dss, struct platform_device *pdev,
348d7157dfeSLaurent Pinchart 		  struct device_node *port);
3499960aa7cSTomi Valkeinen void sdi_uninit_port(struct device_node *port);
3509960aa7cSTomi Valkeinen #else
sdi_init_port(struct dss_device * dss,struct platform_device * pdev,struct device_node * port)351d7157dfeSLaurent Pinchart static inline int sdi_init_port(struct dss_device *dss,
352d7157dfeSLaurent Pinchart 				struct platform_device *pdev,
3539960aa7cSTomi Valkeinen 				struct device_node *port)
3549960aa7cSTomi Valkeinen {
3559960aa7cSTomi Valkeinen 	return 0;
3569960aa7cSTomi Valkeinen }
sdi_uninit_port(struct device_node * port)3579960aa7cSTomi Valkeinen static inline void sdi_uninit_port(struct device_node *port)
3589960aa7cSTomi Valkeinen {
3599960aa7cSTomi Valkeinen }
3609960aa7cSTomi Valkeinen #endif
3619960aa7cSTomi Valkeinen 
3629960aa7cSTomi Valkeinen /* DSI */
3639960aa7cSTomi Valkeinen 
3649960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_DSI
3659960aa7cSTomi Valkeinen 
3669960aa7cSTomi Valkeinen void dsi_irq_handler(void);
3679960aa7cSTomi Valkeinen 
3689960aa7cSTomi Valkeinen #endif
3699960aa7cSTomi Valkeinen 
3709960aa7cSTomi Valkeinen /* DPI */
3719960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_DPI
3728aea8e6aSLaurent Pinchart int dpi_init_port(struct dss_device *dss, struct platform_device *pdev,
3738aea8e6aSLaurent Pinchart 		  struct device_node *port, enum dss_model dss_model);
3749960aa7cSTomi Valkeinen void dpi_uninit_port(struct device_node *port);
3759960aa7cSTomi Valkeinen #else
dpi_init_port(struct dss_device * dss,struct platform_device * pdev,struct device_node * port,enum dss_model dss_model)376037f0315STomi Valkeinen static inline int dpi_init_port(struct dss_device *dss,
3778aea8e6aSLaurent Pinchart 				struct platform_device *pdev,
3788aea8e6aSLaurent Pinchart 				struct device_node *port,
3798aea8e6aSLaurent Pinchart 				enum dss_model dss_model)
3809960aa7cSTomi Valkeinen {
3819960aa7cSTomi Valkeinen 	return 0;
3829960aa7cSTomi Valkeinen }
dpi_uninit_port(struct device_node * port)3839960aa7cSTomi Valkeinen static inline void dpi_uninit_port(struct device_node *port)
3849960aa7cSTomi Valkeinen {
3859960aa7cSTomi Valkeinen }
3869960aa7cSTomi Valkeinen #endif
3879960aa7cSTomi Valkeinen 
3889960aa7cSTomi Valkeinen /* DISPC */
3898a7eda76SLaurent Pinchart void dispc_dump_clocks(struct dispc_device *dispc, struct seq_file *s);
3909960aa7cSTomi Valkeinen 
39150638ae5SLaurent Pinchart int dispc_runtime_get(struct dispc_device *dispc);
39250638ae5SLaurent Pinchart void dispc_runtime_put(struct dispc_device *dispc);
3935034b1faSTomi Valkeinen 
394dac62bcaSTomi Valkeinen int dispc_get_num_ovls(struct dispc_device *dispc);
395dac62bcaSTomi Valkeinen int dispc_get_num_mgrs(struct dispc_device *dispc);
396dac62bcaSTomi Valkeinen 
397dac62bcaSTomi Valkeinen const u32 *dispc_ovl_get_color_modes(struct dispc_device *dispc,
398dac62bcaSTomi Valkeinen 					    enum omap_plane_id plane);
399dac62bcaSTomi Valkeinen 
400d484c20dSBenoit Parrot void dispc_ovl_get_max_size(struct dispc_device *dispc, u16 *width, u16 *height);
401*0b0f7282SBenoit Parrot bool dispc_ovl_color_mode_supported(struct dispc_device *dispc,
402*0b0f7282SBenoit Parrot 				    enum omap_plane_id plane, u32 fourcc);
403*0b0f7282SBenoit Parrot enum omap_overlay_caps dispc_ovl_get_caps(struct dispc_device *dispc, enum omap_plane_id plane);
404d484c20dSBenoit Parrot 
405dac62bcaSTomi Valkeinen u32 dispc_read_irqstatus(struct dispc_device *dispc);
406dac62bcaSTomi Valkeinen void dispc_clear_irqstatus(struct dispc_device *dispc, u32 mask);
407dac62bcaSTomi Valkeinen void dispc_write_irqenable(struct dispc_device *dispc, u32 mask);
408dac62bcaSTomi Valkeinen 
409dac62bcaSTomi Valkeinen int dispc_request_irq(struct dispc_device *dispc, irq_handler_t handler,
410dac62bcaSTomi Valkeinen 			     void *dev_id);
411dac62bcaSTomi Valkeinen void dispc_free_irq(struct dispc_device *dispc, void *dev_id);
412dac62bcaSTomi Valkeinen 
413dac62bcaSTomi Valkeinen u32 dispc_mgr_get_vsync_irq(struct dispc_device *dispc,
414dac62bcaSTomi Valkeinen 				   enum omap_channel channel);
415dac62bcaSTomi Valkeinen u32 dispc_mgr_get_framedone_irq(struct dispc_device *dispc,
416dac62bcaSTomi Valkeinen 				       enum omap_channel channel);
417dac62bcaSTomi Valkeinen u32 dispc_mgr_get_sync_lost_irq(struct dispc_device *dispc,
418dac62bcaSTomi Valkeinen 				       enum omap_channel channel);
419dac62bcaSTomi Valkeinen u32 dispc_wb_get_framedone_irq(struct dispc_device *dispc);
420dac62bcaSTomi Valkeinen 
421dac62bcaSTomi Valkeinen u32 dispc_get_memory_bandwidth_limit(struct dispc_device *dispc);
422dac62bcaSTomi Valkeinen 
423dac62bcaSTomi Valkeinen void dispc_mgr_enable(struct dispc_device *dispc,
424dac62bcaSTomi Valkeinen 			     enum omap_channel channel, bool enable);
425dac62bcaSTomi Valkeinen 
426dac62bcaSTomi Valkeinen bool dispc_mgr_go_busy(struct dispc_device *dispc,
427dac62bcaSTomi Valkeinen 			      enum omap_channel channel);
428dac62bcaSTomi Valkeinen 
429dac62bcaSTomi Valkeinen void dispc_mgr_go(struct dispc_device *dispc, enum omap_channel channel);
430dac62bcaSTomi Valkeinen 
431dac62bcaSTomi Valkeinen void dispc_mgr_set_lcd_config(struct dispc_device *dispc,
432dac62bcaSTomi Valkeinen 				     enum omap_channel channel,
433dac62bcaSTomi Valkeinen 				     const struct dss_lcd_mgr_config *config);
434dac62bcaSTomi Valkeinen void dispc_mgr_set_timings(struct dispc_device *dispc,
435dac62bcaSTomi Valkeinen 				  enum omap_channel channel,
436dac62bcaSTomi Valkeinen 				  const struct videomode *vm);
437dac62bcaSTomi Valkeinen void dispc_mgr_setup(struct dispc_device *dispc,
438dac62bcaSTomi Valkeinen 			    enum omap_channel channel,
439dac62bcaSTomi Valkeinen 			    const struct omap_overlay_manager_info *info);
440dac62bcaSTomi Valkeinen 
441dac62bcaSTomi Valkeinen int dispc_mgr_check_timings(struct dispc_device *dispc,
442dac62bcaSTomi Valkeinen 				   enum omap_channel channel,
443dac62bcaSTomi Valkeinen 				   const struct videomode *vm);
444dac62bcaSTomi Valkeinen 
445dac62bcaSTomi Valkeinen u32 dispc_mgr_gamma_size(struct dispc_device *dispc,
446dac62bcaSTomi Valkeinen 				enum omap_channel channel);
447dac62bcaSTomi Valkeinen void dispc_mgr_set_gamma(struct dispc_device *dispc,
448dac62bcaSTomi Valkeinen 				enum omap_channel channel,
449dac62bcaSTomi Valkeinen 				const struct drm_color_lut *lut,
450dac62bcaSTomi Valkeinen 				unsigned int length);
451dac62bcaSTomi Valkeinen 
452dac62bcaSTomi Valkeinen int dispc_ovl_setup(struct dispc_device *dispc,
453dac62bcaSTomi Valkeinen 			   enum omap_plane_id plane,
454dac62bcaSTomi Valkeinen 			   const struct omap_overlay_info *oi,
455dac62bcaSTomi Valkeinen 			   const struct videomode *vm, bool mem_to_mem,
456dac62bcaSTomi Valkeinen 			   enum omap_channel channel);
457dac62bcaSTomi Valkeinen 
458dac62bcaSTomi Valkeinen int dispc_ovl_enable(struct dispc_device *dispc,
459dac62bcaSTomi Valkeinen 			    enum omap_plane_id plane, bool enable);
460dac62bcaSTomi Valkeinen 
461dac62bcaSTomi Valkeinen bool dispc_has_writeback(struct dispc_device *dispc);
462dac62bcaSTomi Valkeinen int dispc_wb_setup(struct dispc_device *dispc,
463dac62bcaSTomi Valkeinen 		   const struct omap_dss_writeback_info *wi,
464dac62bcaSTomi Valkeinen 		   bool mem_to_mem, const struct videomode *vm,
465dac62bcaSTomi Valkeinen 		   enum dss_writeback_channel channel_in);
466dac62bcaSTomi Valkeinen bool dispc_wb_go_busy(struct dispc_device *dispc);
467dac62bcaSTomi Valkeinen void dispc_wb_go(struct dispc_device *dispc);
468dac62bcaSTomi Valkeinen 
4698a7eda76SLaurent Pinchart void dispc_enable_sidle(struct dispc_device *dispc);
4708a7eda76SLaurent Pinchart void dispc_disable_sidle(struct dispc_device *dispc);
4719960aa7cSTomi Valkeinen 
4728a7eda76SLaurent Pinchart void dispc_lcd_enable_signal(struct dispc_device *dispc, bool enable);
4738a7eda76SLaurent Pinchart void dispc_pck_free_enable(struct dispc_device *dispc, bool enable);
4748a7eda76SLaurent Pinchart void dispc_enable_fifomerge(struct dispc_device *dispc, bool enable);
4759960aa7cSTomi Valkeinen 
4769960aa7cSTomi Valkeinen typedef bool (*dispc_div_calc_func)(int lckd, int pckd, unsigned long lck,
4779960aa7cSTomi Valkeinen 		unsigned long pck, void *data);
4788a7eda76SLaurent Pinchart bool dispc_div_calc(struct dispc_device *dispc, unsigned long dispc_freq,
4799960aa7cSTomi Valkeinen 		    unsigned long pck_min, unsigned long pck_max,
4809960aa7cSTomi Valkeinen 		    dispc_div_calc_func func, void *data);
4819960aa7cSTomi Valkeinen 
4828a7eda76SLaurent Pinchart int dispc_calc_clock_rates(struct dispc_device *dispc,
4838a7eda76SLaurent Pinchart 			   unsigned long dispc_fclk_rate,
4849960aa7cSTomi Valkeinen 			   struct dispc_clock_info *cinfo);
4859960aa7cSTomi Valkeinen 
4869960aa7cSTomi Valkeinen 
4878a7eda76SLaurent Pinchart void dispc_ovl_set_fifo_threshold(struct dispc_device *dispc,
4888a7eda76SLaurent Pinchart 				  enum omap_plane_id plane, u32 low, u32 high);
4898a7eda76SLaurent Pinchart void dispc_ovl_compute_fifo_thresholds(struct dispc_device *dispc,
4908a7eda76SLaurent Pinchart 				       enum omap_plane_id plane,
4918a7eda76SLaurent Pinchart 				       u32 *fifo_low, u32 *fifo_high,
4928a7eda76SLaurent Pinchart 				       bool use_fifomerge, bool manual_update);
4939960aa7cSTomi Valkeinen 
4948a7eda76SLaurent Pinchart void dispc_mgr_set_clock_div(struct dispc_device *dispc,
4958a7eda76SLaurent Pinchart 			     enum omap_channel channel,
4969960aa7cSTomi Valkeinen 			     const struct dispc_clock_info *cinfo);
4978a7eda76SLaurent Pinchart int dispc_mgr_get_clock_div(struct dispc_device *dispc,
4988a7eda76SLaurent Pinchart 			    enum omap_channel channel,
4999960aa7cSTomi Valkeinen 			    struct dispc_clock_info *cinfo);
5008a7eda76SLaurent Pinchart void dispc_set_tv_pclk(struct dispc_device *dispc, unsigned long pclk);
5019960aa7cSTomi Valkeinen 
5029960aa7cSTomi Valkeinen #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS
dss_collect_irq_stats(u32 irqstatus,unsigned int * irq_arr)503d11e5c82SLaurent Pinchart static inline void dss_collect_irq_stats(u32 irqstatus, unsigned int *irq_arr)
5049960aa7cSTomi Valkeinen {
5059960aa7cSTomi Valkeinen 	int b;
5069960aa7cSTomi Valkeinen 	for (b = 0; b < 32; ++b) {
5079960aa7cSTomi Valkeinen 		if (irqstatus & (1 << b))
5089960aa7cSTomi Valkeinen 			irq_arr[b]++;
5099960aa7cSTomi Valkeinen 	}
5109960aa7cSTomi Valkeinen }
5119960aa7cSTomi Valkeinen #endif
5129960aa7cSTomi Valkeinen 
5139960aa7cSTomi Valkeinen /* PLL */
5149960aa7cSTomi Valkeinen typedef bool (*dss_pll_calc_func)(int n, int m, unsigned long fint,
5159960aa7cSTomi Valkeinen 		unsigned long clkdco, void *data);
5169960aa7cSTomi Valkeinen typedef bool (*dss_hsdiv_calc_func)(int m_dispc, unsigned long dispc,
5179960aa7cSTomi Valkeinen 		void *data);
5189960aa7cSTomi Valkeinen 
519798957aeSLaurent Pinchart int dss_pll_register(struct dss_device *dss, struct dss_pll *pll);
5209960aa7cSTomi Valkeinen void dss_pll_unregister(struct dss_pll *pll);
521798957aeSLaurent Pinchart struct dss_pll *dss_pll_find(struct dss_device *dss, const char *name);
522798957aeSLaurent Pinchart struct dss_pll *dss_pll_find_by_src(struct dss_device *dss,
523798957aeSLaurent Pinchart 				    enum dss_clk_source src);
524d11e5c82SLaurent Pinchart unsigned int dss_pll_get_clkout_idx_for_src(enum dss_clk_source src);
5259960aa7cSTomi Valkeinen int dss_pll_enable(struct dss_pll *pll);
5269960aa7cSTomi Valkeinen void dss_pll_disable(struct dss_pll *pll);
5279960aa7cSTomi Valkeinen int dss_pll_set_config(struct dss_pll *pll,
5289960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
5299960aa7cSTomi Valkeinen 
530cd0715ffSTomi Valkeinen bool dss_pll_hsdiv_calc_a(const struct dss_pll *pll, unsigned long clkdco,
5319960aa7cSTomi Valkeinen 		unsigned long out_min, unsigned long out_max,
5329960aa7cSTomi Valkeinen 		dss_hsdiv_calc_func func, void *data);
533cd0715ffSTomi Valkeinen bool dss_pll_calc_a(const struct dss_pll *pll, unsigned long clkin,
5349960aa7cSTomi Valkeinen 		unsigned long pll_min, unsigned long pll_max,
5359960aa7cSTomi Valkeinen 		dss_pll_calc_func func, void *data);
536c17dc0e3STomi Valkeinen 
537c17dc0e3STomi Valkeinen bool dss_pll_calc_b(const struct dss_pll *pll, unsigned long clkin,
538c107751dSTomi Valkeinen 	unsigned long target_clkout, struct dss_pll_clock_info *cinfo);
539c17dc0e3STomi Valkeinen 
5409960aa7cSTomi Valkeinen int dss_pll_write_config_type_a(struct dss_pll *pll,
5419960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
5429960aa7cSTomi Valkeinen int dss_pll_write_config_type_b(struct dss_pll *pll,
5439960aa7cSTomi Valkeinen 		const struct dss_pll_clock_info *cinfo);
5449960aa7cSTomi Valkeinen int dss_pll_wait_reset_done(struct dss_pll *pll);
5459960aa7cSTomi Valkeinen 
546d66c36a3SAndrew F. Davis extern struct platform_driver omap_dsshw_driver;
547d66c36a3SAndrew F. Davis extern struct platform_driver omap_dispchw_driver;
548d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP2_DSS_DSI
549d66c36a3SAndrew F. Davis extern struct platform_driver omap_dsihw_driver;
550d66c36a3SAndrew F. Davis #endif
551d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP2_DSS_VENC
552d66c36a3SAndrew F. Davis extern struct platform_driver omap_venchw_driver;
553d66c36a3SAndrew F. Davis #endif
554d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP4_DSS_HDMI
555d66c36a3SAndrew F. Davis extern struct platform_driver omapdss_hdmi4hw_driver;
556d66c36a3SAndrew F. Davis #endif
557d66c36a3SAndrew F. Davis #ifdef CONFIG_OMAP5_DSS_HDMI
558d66c36a3SAndrew F. Davis extern struct platform_driver omapdss_hdmi5hw_driver;
559d66c36a3SAndrew F. Davis #endif
560d66c36a3SAndrew F. Davis 
5619960aa7cSTomi Valkeinen #endif
562