xref: /linux/include/video/sh_mobile_lcdc.h (revision b24413180f5600bcb3bb70fbed5cf186b60864bd)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2225c9a8dSPaul Mundt #ifndef __ASM_SH_MOBILE_LCDC_H__
3225c9a8dSPaul Mundt #define __ASM_SH_MOBILE_LCDC_H__
4225c9a8dSPaul Mundt 
5225c9a8dSPaul Mundt #include <linux/fb.h>
67caa4342SDamian #include <video/sh_mobile_meram.h>
7225c9a8dSPaul Mundt 
8ce1c0b08SLaurent Pinchart /* Register definitions */
9ce1c0b08SLaurent Pinchart #define _LDDCKR			0x410
10ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_BUS	(0 << 16)
11ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_MIPI	(1 << 16)
12ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_HDMI	(2 << 16)
13ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_EXT	(3 << 16)
14ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_MASK	(7 << 16)
15ce1c0b08SLaurent Pinchart #define LDDCKR_MOSEL		(1 << 6)
16ce1c0b08SLaurent Pinchart #define _LDDCKSTPR		0x414
17ce1c0b08SLaurent Pinchart #define _LDINTR			0x468
18ce1c0b08SLaurent Pinchart #define LDINTR_FE		(1 << 10)
19ce1c0b08SLaurent Pinchart #define LDINTR_VSE		(1 << 9)
20ce1c0b08SLaurent Pinchart #define LDINTR_VEE		(1 << 8)
21ce1c0b08SLaurent Pinchart #define LDINTR_FS		(1 << 2)
22ce1c0b08SLaurent Pinchart #define LDINTR_VSS		(1 << 1)
23ce1c0b08SLaurent Pinchart #define LDINTR_VES		(1 << 0)
24ce1c0b08SLaurent Pinchart #define LDINTR_STATUS_MASK	(0xff << 0)
25ce1c0b08SLaurent Pinchart #define _LDSR			0x46c
26ce1c0b08SLaurent Pinchart #define LDSR_MSS		(1 << 10)
27ce1c0b08SLaurent Pinchart #define LDSR_MRS		(1 << 8)
28ce1c0b08SLaurent Pinchart #define LDSR_AS			(1 << 1)
29ce1c0b08SLaurent Pinchart #define _LDCNT1R		0x470
30ce1c0b08SLaurent Pinchart #define LDCNT1R_DE		(1 << 0)
31ce1c0b08SLaurent Pinchart #define _LDCNT2R		0x474
32ce1c0b08SLaurent Pinchart #define LDCNT2R_BR		(1 << 8)
33ce1c0b08SLaurent Pinchart #define LDCNT2R_MD		(1 << 3)
34ce1c0b08SLaurent Pinchart #define LDCNT2R_SE		(1 << 2)
35ce1c0b08SLaurent Pinchart #define LDCNT2R_ME		(1 << 1)
36ce1c0b08SLaurent Pinchart #define LDCNT2R_DO		(1 << 0)
37ce1c0b08SLaurent Pinchart #define _LDRCNTR		0x478
38ce1c0b08SLaurent Pinchart #define LDRCNTR_SRS		(1 << 17)
39ce1c0b08SLaurent Pinchart #define LDRCNTR_SRC		(1 << 16)
40ce1c0b08SLaurent Pinchart #define LDRCNTR_MRS		(1 << 1)
41ce1c0b08SLaurent Pinchart #define LDRCNTR_MRC		(1 << 0)
42ce1c0b08SLaurent Pinchart #define _LDDDSR			0x47c
43ce1c0b08SLaurent Pinchart #define LDDDSR_LS		(1 << 2)
44ce1c0b08SLaurent Pinchart #define LDDDSR_WS		(1 << 1)
45ce1c0b08SLaurent Pinchart #define LDDDSR_BS		(1 << 0)
46ce1c0b08SLaurent Pinchart 
47ce1c0b08SLaurent Pinchart #define LDMT1R_VPOL		(1 << 28)
48ce1c0b08SLaurent Pinchart #define LDMT1R_HPOL		(1 << 27)
49ce1c0b08SLaurent Pinchart #define LDMT1R_DWPOL		(1 << 26)
50ce1c0b08SLaurent Pinchart #define LDMT1R_DIPOL		(1 << 25)
51ce1c0b08SLaurent Pinchart #define LDMT1R_DAPOL		(1 << 24)
52ce1c0b08SLaurent Pinchart #define LDMT1R_HSCNT		(1 << 17)
53ce1c0b08SLaurent Pinchart #define LDMT1R_DWCNT		(1 << 16)
54ce1c0b08SLaurent Pinchart #define LDMT1R_IFM		(1 << 12)
55ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB8	(0x0 << 0)
56ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB9	(0x4 << 0)
57ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB12A	(0x5 << 0)
58ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB12B	(0x6 << 0)
59ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB16	(0x7 << 0)
60ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB18	(0xa << 0)
61ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB24	(0xb << 0)
62ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_YCBCR	(0xf << 0)
63ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8A	(0x0 << 0)
64ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8B	(0x1 << 0)
65ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8C	(0x2 << 0)
66ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8D	(0x3 << 0)
67ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS9	(0x4 << 0)
68ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS12	(0x5 << 0)
69ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS16A	(0x7 << 0)
70ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS16B	(0x8 << 0)
71ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS16C	(0x9 << 0)
72ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS18	(0xa << 0)
73ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS24	(0xb << 0)
74ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_MASK	(0xf << 0)
75ce1c0b08SLaurent Pinchart 
76ce1c0b08SLaurent Pinchart #define LDDFR_CF1		(1 << 18)
77ce1c0b08SLaurent Pinchart #define LDDFR_CF0		(1 << 17)
78ce1c0b08SLaurent Pinchart #define LDDFR_CC		(1 << 16)
79ce1c0b08SLaurent Pinchart #define LDDFR_YF_420		(0 << 8)
80ce1c0b08SLaurent Pinchart #define LDDFR_YF_422		(1 << 8)
81ce1c0b08SLaurent Pinchart #define LDDFR_YF_444		(2 << 8)
82ce1c0b08SLaurent Pinchart #define LDDFR_YF_MASK		(3 << 8)
83ce1c0b08SLaurent Pinchart #define LDDFR_PKF_ARGB32	(0x00 << 0)
84ce1c0b08SLaurent Pinchart #define LDDFR_PKF_RGB16		(0x03 << 0)
85ce1c0b08SLaurent Pinchart #define LDDFR_PKF_RGB24		(0x0b << 0)
86ce1c0b08SLaurent Pinchart #define LDDFR_PKF_MASK		(0x1f << 0)
87ce1c0b08SLaurent Pinchart 
88ce1c0b08SLaurent Pinchart #define LDSM1R_OS		(1 << 0)
89ce1c0b08SLaurent Pinchart 
90ce1c0b08SLaurent Pinchart #define LDSM2R_OSTRG		(1 << 0)
91ce1c0b08SLaurent Pinchart 
92ce1c0b08SLaurent Pinchart #define LDPMR_LPS		(3 << 0)
93ce1c0b08SLaurent Pinchart 
94ce1c0b08SLaurent Pinchart #define _LDDWD0R		0x800
95ce1c0b08SLaurent Pinchart #define LDDWDxR_WDACT		(1 << 28)
96ce1c0b08SLaurent Pinchart #define LDDWDxR_RSW		(1 << 24)
97ce1c0b08SLaurent Pinchart #define _LDDRDR			0x840
98ce1c0b08SLaurent Pinchart #define LDDRDR_RSR		(1 << 24)
99ce1c0b08SLaurent Pinchart #define LDDRDR_DRD_MASK		(0x3ffff << 0)
100ce1c0b08SLaurent Pinchart #define _LDDWAR			0x900
101ce1c0b08SLaurent Pinchart #define LDDWAR_WA		(1 << 0)
102ce1c0b08SLaurent Pinchart #define _LDDRAR			0x904
103ce1c0b08SLaurent Pinchart #define LDDRAR_RA		(1 << 0)
104ce1c0b08SLaurent Pinchart 
1051430e006SGuennadi Liakhovetski enum {
106ce1c0b08SLaurent Pinchart 	RGB8	= LDMT1R_MIFTYP_RGB8,	/* 24bpp, 8:8:8 */
107ce1c0b08SLaurent Pinchart 	RGB9	= LDMT1R_MIFTYP_RGB9,	/* 18bpp, 9:9 */
108ce1c0b08SLaurent Pinchart 	RGB12A	= LDMT1R_MIFTYP_RGB12A,	/* 24bpp, 12:12 */
109ce1c0b08SLaurent Pinchart 	RGB12B	= LDMT1R_MIFTYP_RGB12B,	/* 12bpp */
110ce1c0b08SLaurent Pinchart 	RGB16	= LDMT1R_MIFTYP_RGB16,	/* 16bpp */
111ce1c0b08SLaurent Pinchart 	RGB18	= LDMT1R_MIFTYP_RGB18,	/* 18bpp */
112ce1c0b08SLaurent Pinchart 	RGB24	= LDMT1R_MIFTYP_RGB24,	/* 24bpp */
113ce1c0b08SLaurent Pinchart 	YUV422	= LDMT1R_MIFTYP_YCBCR,	/* 16bpp */
114ce1c0b08SLaurent Pinchart 	SYS8A	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8A,	/* 24bpp, 8:8:8 */
115ce1c0b08SLaurent Pinchart 	SYS8B	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8B,	/* 18bpp, 8:8:2 */
116ce1c0b08SLaurent Pinchart 	SYS8C	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8C,	/* 18bpp, 2:8:8 */
117ce1c0b08SLaurent Pinchart 	SYS8D	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8D,	/* 16bpp, 8:8 */
118ce1c0b08SLaurent Pinchart 	SYS9	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS9,	/* 18bpp, 9:9 */
119ce1c0b08SLaurent Pinchart 	SYS12	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS12,	/* 24bpp, 12:12 */
120ce1c0b08SLaurent Pinchart 	SYS16A	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS16A,	/* 16bpp */
121ce1c0b08SLaurent Pinchart 	SYS16B	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS16B,	/* 18bpp, 16:2 */
122ce1c0b08SLaurent Pinchart 	SYS16C	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS16C,	/* 18bpp, 2:16 */
123ce1c0b08SLaurent Pinchart 	SYS18	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS18,	/* 18bpp */
124ce1c0b08SLaurent Pinchart 	SYS24	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS24,	/* 24bpp */
1251430e006SGuennadi Liakhovetski };
126225c9a8dSPaul Mundt 
127225c9a8dSPaul Mundt enum { LCDC_CHAN_DISABLED = 0,
128225c9a8dSPaul Mundt        LCDC_CHAN_MAINLCD,
129225c9a8dSPaul Mundt        LCDC_CHAN_SUBLCD };
130225c9a8dSPaul Mundt 
131225c9a8dSPaul Mundt enum { LCDC_CLK_BUS, LCDC_CLK_PERIPHERAL, LCDC_CLK_EXTERNAL };
132225c9a8dSPaul Mundt 
133f400f510SMagnus Damm #define LCDC_FLAGS_DWPOL (1 << 0) /* Rising edge dot clock data latch */
134f400f510SMagnus Damm #define LCDC_FLAGS_DIPOL (1 << 1) /* Active low display enable polarity */
135f400f510SMagnus Damm #define LCDC_FLAGS_DAPOL (1 << 2) /* Active low display data polarity */
136f400f510SMagnus Damm #define LCDC_FLAGS_HSCNT (1 << 3) /* Disable HSYNC during VBLANK */
137f400f510SMagnus Damm #define LCDC_FLAGS_DWCNT (1 << 4) /* Disable dotclock during blanking */
138f400f510SMagnus Damm 
139225c9a8dSPaul Mundt struct sh_mobile_lcdc_sys_bus_cfg {
140225c9a8dSPaul Mundt 	unsigned long ldmt2r;
141225c9a8dSPaul Mundt 	unsigned long ldmt3r;
1428564557aSMagnus Damm 	unsigned long deferred_io_msec;
143225c9a8dSPaul Mundt };
144225c9a8dSPaul Mundt 
145225c9a8dSPaul Mundt struct sh_mobile_lcdc_sys_bus_ops {
146225c9a8dSPaul Mundt 	void (*write_index)(void *handle, unsigned long data);
147225c9a8dSPaul Mundt 	void (*write_data)(void *handle, unsigned long data);
148225c9a8dSPaul Mundt 	unsigned long (*read_data)(void *handle);
149225c9a8dSPaul Mundt };
150225c9a8dSPaul Mundt 
151afaad83bSLaurent Pinchart struct sh_mobile_lcdc_panel_cfg {
152afaad83bSLaurent Pinchart 	unsigned long width;		/* Panel width in mm */
153afaad83bSLaurent Pinchart 	unsigned long height;		/* Panel height in mm */
154018882aaSLaurent Pinchart 	int (*setup_sys)(void *sys_ops_handle,
155225c9a8dSPaul Mundt 			 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
156018882aaSLaurent Pinchart 	void (*start_transfer)(void *sys_ops_handle,
157ef61aae4SMagnus Damm 			       struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
158018882aaSLaurent Pinchart 	void (*display_on)(void);
159018882aaSLaurent Pinchart 	void (*display_off)(void);
160225c9a8dSPaul Mundt };
161225c9a8dSPaul Mundt 
1623b0fd9d7SAlexandre Courbot /* backlight info */
1633b0fd9d7SAlexandre Courbot struct sh_mobile_lcdc_bl_info {
1643b0fd9d7SAlexandre Courbot 	const char *name;
1653b0fd9d7SAlexandre Courbot 	int max_brightness;
16643059b0fSLaurent Pinchart 	int (*set_brightness)(int brightness);
1673b0fd9d7SAlexandre Courbot };
1683b0fd9d7SAlexandre Courbot 
169c5deac3cSLaurent Pinchart struct sh_mobile_lcdc_overlay_cfg {
170c5deac3cSLaurent Pinchart 	int fourcc;
171c5deac3cSLaurent Pinchart 	unsigned int max_xres;
172c5deac3cSLaurent Pinchart 	unsigned int max_yres;
173c5deac3cSLaurent Pinchart };
174c5deac3cSLaurent Pinchart 
175225c9a8dSPaul Mundt struct sh_mobile_lcdc_chan_cfg {
176225c9a8dSPaul Mundt 	int chan;
177edd153a3SLaurent Pinchart 	int fourcc;
178edd153a3SLaurent Pinchart 	int colorspace;
179225c9a8dSPaul Mundt 	int interface_type; /* selects RGBn or SYSn I/F, see above */
180225c9a8dSPaul Mundt 	int clock_divider;
181f400f510SMagnus Damm 	unsigned long flags; /* LCDC_FLAGS_... */
18293ff2598SLaurent Pinchart 	const struct fb_videomode *lcd_modes;
18393ff2598SLaurent Pinchart 	int num_modes;
184afaad83bSLaurent Pinchart 	struct sh_mobile_lcdc_panel_cfg panel_cfg;
1853b0fd9d7SAlexandre Courbot 	struct sh_mobile_lcdc_bl_info bl_info;
186225c9a8dSPaul Mundt 	struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
187b5ef967dSLaurent Pinchart 	const struct sh_mobile_meram_cfg *meram_cfg;
1889a2985e7SLaurent Pinchart 
1899a2985e7SLaurent Pinchart 	struct platform_device *tx_dev;	/* HDMI/DSI transmitter device */
190225c9a8dSPaul Mundt };
191225c9a8dSPaul Mundt 
192225c9a8dSPaul Mundt struct sh_mobile_lcdc_info {
193225c9a8dSPaul Mundt 	int clock_source;
194225c9a8dSPaul Mundt 	struct sh_mobile_lcdc_chan_cfg ch[2];
195c5deac3cSLaurent Pinchart 	struct sh_mobile_lcdc_overlay_cfg overlays[4];
1967caa4342SDamian 	struct sh_mobile_meram_info *meram_dev;
197225c9a8dSPaul Mundt };
198225c9a8dSPaul Mundt 
199225c9a8dSPaul Mundt #endif /* __ASM_SH_MOBILE_LCDC_H__ */
200