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