xref: /linux/include/video/sh_mobile_lcdc.h (revision ce1c0b0873bf4e970970a49612105cf6c36d81e3)
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 
7*ce1c0b08SLaurent Pinchart /* Register definitions */
8*ce1c0b08SLaurent Pinchart #define _LDDCKR			0x410
9*ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_BUS	(0 << 16)
10*ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_MIPI	(1 << 16)
11*ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_HDMI	(2 << 16)
12*ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_EXT	(3 << 16)
13*ce1c0b08SLaurent Pinchart #define LDDCKR_ICKSEL_MASK	(7 << 16)
14*ce1c0b08SLaurent Pinchart #define LDDCKR_MOSEL		(1 << 6)
15*ce1c0b08SLaurent Pinchart #define _LDDCKSTPR		0x414
16*ce1c0b08SLaurent Pinchart #define _LDINTR			0x468
17*ce1c0b08SLaurent Pinchart #define LDINTR_FE		(1 << 10)
18*ce1c0b08SLaurent Pinchart #define LDINTR_VSE		(1 << 9)
19*ce1c0b08SLaurent Pinchart #define LDINTR_VEE		(1 << 8)
20*ce1c0b08SLaurent Pinchart #define LDINTR_FS		(1 << 2)
21*ce1c0b08SLaurent Pinchart #define LDINTR_VSS		(1 << 1)
22*ce1c0b08SLaurent Pinchart #define LDINTR_VES		(1 << 0)
23*ce1c0b08SLaurent Pinchart #define LDINTR_STATUS_MASK	(0xff << 0)
24*ce1c0b08SLaurent Pinchart #define _LDSR			0x46c
25*ce1c0b08SLaurent Pinchart #define LDSR_MSS		(1 << 10)
26*ce1c0b08SLaurent Pinchart #define LDSR_MRS		(1 << 8)
27*ce1c0b08SLaurent Pinchart #define LDSR_AS			(1 << 1)
28*ce1c0b08SLaurent Pinchart #define _LDCNT1R		0x470
29*ce1c0b08SLaurent Pinchart #define LDCNT1R_DE		(1 << 0)
30*ce1c0b08SLaurent Pinchart #define _LDCNT2R		0x474
31*ce1c0b08SLaurent Pinchart #define LDCNT2R_BR		(1 << 8)
32*ce1c0b08SLaurent Pinchart #define LDCNT2R_MD		(1 << 3)
33*ce1c0b08SLaurent Pinchart #define LDCNT2R_SE		(1 << 2)
34*ce1c0b08SLaurent Pinchart #define LDCNT2R_ME		(1 << 1)
35*ce1c0b08SLaurent Pinchart #define LDCNT2R_DO		(1 << 0)
36*ce1c0b08SLaurent Pinchart #define _LDRCNTR		0x478
37*ce1c0b08SLaurent Pinchart #define LDRCNTR_SRS		(1 << 17)
38*ce1c0b08SLaurent Pinchart #define LDRCNTR_SRC		(1 << 16)
39*ce1c0b08SLaurent Pinchart #define LDRCNTR_MRS		(1 << 1)
40*ce1c0b08SLaurent Pinchart #define LDRCNTR_MRC		(1 << 0)
41*ce1c0b08SLaurent Pinchart #define _LDDDSR			0x47c
42*ce1c0b08SLaurent Pinchart #define LDDDSR_LS		(1 << 2)
43*ce1c0b08SLaurent Pinchart #define LDDDSR_WS		(1 << 1)
44*ce1c0b08SLaurent Pinchart #define LDDDSR_BS		(1 << 0)
45*ce1c0b08SLaurent Pinchart 
46*ce1c0b08SLaurent Pinchart #define LDMT1R_VPOL		(1 << 28)
47*ce1c0b08SLaurent Pinchart #define LDMT1R_HPOL		(1 << 27)
48*ce1c0b08SLaurent Pinchart #define LDMT1R_DWPOL		(1 << 26)
49*ce1c0b08SLaurent Pinchart #define LDMT1R_DIPOL		(1 << 25)
50*ce1c0b08SLaurent Pinchart #define LDMT1R_DAPOL		(1 << 24)
51*ce1c0b08SLaurent Pinchart #define LDMT1R_HSCNT		(1 << 17)
52*ce1c0b08SLaurent Pinchart #define LDMT1R_DWCNT		(1 << 16)
53*ce1c0b08SLaurent Pinchart #define LDMT1R_IFM		(1 << 12)
54*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB8	(0x0 << 0)
55*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB9	(0x4 << 0)
56*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB12A	(0x5 << 0)
57*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB12B	(0x6 << 0)
58*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB16	(0x7 << 0)
59*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB18	(0xa << 0)
60*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_RGB24	(0xb << 0)
61*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_YCBCR	(0xf << 0)
62*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8A	(0x0 << 0)
63*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8B	(0x1 << 0)
64*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8C	(0x2 << 0)
65*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS8D	(0x3 << 0)
66*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS9	(0x4 << 0)
67*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS12	(0x5 << 0)
68*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS16A	(0x7 << 0)
69*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS16B	(0x8 << 0)
70*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS16C	(0x9 << 0)
71*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS18	(0xa << 0)
72*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_SYS24	(0xb << 0)
73*ce1c0b08SLaurent Pinchart #define LDMT1R_MIFTYP_MASK	(0xf << 0)
74*ce1c0b08SLaurent Pinchart 
75*ce1c0b08SLaurent Pinchart #define LDDFR_CF1		(1 << 18)
76*ce1c0b08SLaurent Pinchart #define LDDFR_CF0		(1 << 17)
77*ce1c0b08SLaurent Pinchart #define LDDFR_CC		(1 << 16)
78*ce1c0b08SLaurent Pinchart #define LDDFR_YF_420		(0 << 8)
79*ce1c0b08SLaurent Pinchart #define LDDFR_YF_422		(1 << 8)
80*ce1c0b08SLaurent Pinchart #define LDDFR_YF_444		(2 << 8)
81*ce1c0b08SLaurent Pinchart #define LDDFR_YF_MASK		(3 << 8)
82*ce1c0b08SLaurent Pinchart #define LDDFR_PKF_ARGB32	(0x00 << 0)
83*ce1c0b08SLaurent Pinchart #define LDDFR_PKF_RGB16		(0x03 << 0)
84*ce1c0b08SLaurent Pinchart #define LDDFR_PKF_RGB24		(0x0b << 0)
85*ce1c0b08SLaurent Pinchart #define LDDFR_PKF_MASK		(0x1f << 0)
86*ce1c0b08SLaurent Pinchart 
87*ce1c0b08SLaurent Pinchart #define LDSM1R_OS		(1 << 0)
88*ce1c0b08SLaurent Pinchart 
89*ce1c0b08SLaurent Pinchart #define LDSM2R_OSTRG		(1 << 0)
90*ce1c0b08SLaurent Pinchart 
91*ce1c0b08SLaurent Pinchart #define LDPMR_LPS		(3 << 0)
92*ce1c0b08SLaurent Pinchart 
93*ce1c0b08SLaurent Pinchart #define _LDDWD0R		0x800
94*ce1c0b08SLaurent Pinchart #define LDDWDxR_WDACT		(1 << 28)
95*ce1c0b08SLaurent Pinchart #define LDDWDxR_RSW		(1 << 24)
96*ce1c0b08SLaurent Pinchart #define _LDDRDR			0x840
97*ce1c0b08SLaurent Pinchart #define LDDRDR_RSR		(1 << 24)
98*ce1c0b08SLaurent Pinchart #define LDDRDR_DRD_MASK		(0x3ffff << 0)
99*ce1c0b08SLaurent Pinchart #define _LDDWAR			0x900
100*ce1c0b08SLaurent Pinchart #define LDDWAR_WA		(1 << 0)
101*ce1c0b08SLaurent Pinchart #define _LDDRAR			0x904
102*ce1c0b08SLaurent Pinchart #define LDDRAR_RA		(1 << 0)
103*ce1c0b08SLaurent Pinchart 
1041430e006SGuennadi Liakhovetski enum {
105*ce1c0b08SLaurent Pinchart 	RGB8	= LDMT1R_MIFTYP_RGB8,	/* 24bpp, 8:8:8 */
106*ce1c0b08SLaurent Pinchart 	RGB9	= LDMT1R_MIFTYP_RGB9,	/* 18bpp, 9:9 */
107*ce1c0b08SLaurent Pinchart 	RGB12A	= LDMT1R_MIFTYP_RGB12A,	/* 24bpp, 12:12 */
108*ce1c0b08SLaurent Pinchart 	RGB12B	= LDMT1R_MIFTYP_RGB12B,	/* 12bpp */
109*ce1c0b08SLaurent Pinchart 	RGB16	= LDMT1R_MIFTYP_RGB16,	/* 16bpp */
110*ce1c0b08SLaurent Pinchart 	RGB18	= LDMT1R_MIFTYP_RGB18,	/* 18bpp */
111*ce1c0b08SLaurent Pinchart 	RGB24	= LDMT1R_MIFTYP_RGB24,	/* 24bpp */
112*ce1c0b08SLaurent Pinchart 	YUV422	= LDMT1R_MIFTYP_YCBCR,	/* 16bpp */
113*ce1c0b08SLaurent Pinchart 	SYS8A	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8A,	/* 24bpp, 8:8:8 */
114*ce1c0b08SLaurent Pinchart 	SYS8B	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8B,	/* 18bpp, 8:8:2 */
115*ce1c0b08SLaurent Pinchart 	SYS8C	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8C,	/* 18bpp, 2:8:8 */
116*ce1c0b08SLaurent Pinchart 	SYS8D	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS8D,	/* 16bpp, 8:8 */
117*ce1c0b08SLaurent Pinchart 	SYS9	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS9,	/* 18bpp, 9:9 */
118*ce1c0b08SLaurent Pinchart 	SYS12	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS12,	/* 24bpp, 12:12 */
119*ce1c0b08SLaurent Pinchart 	SYS16A	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS16A,	/* 16bpp */
120*ce1c0b08SLaurent Pinchart 	SYS16B	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS16B,	/* 18bpp, 16:2 */
121*ce1c0b08SLaurent Pinchart 	SYS16C	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS16C,	/* 18bpp, 2:16 */
122*ce1c0b08SLaurent Pinchart 	SYS18	= LDMT1R_IFM | LDMT1R_MIFTYP_SYS18,	/* 18bpp */
123*ce1c0b08SLaurent 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 
1506de9edd5SGuennadi Liakhovetski struct module;
151225c9a8dSPaul Mundt struct sh_mobile_lcdc_board_cfg {
1526de9edd5SGuennadi Liakhovetski 	struct module *owner;
153225c9a8dSPaul Mundt 	void *board_data;
154225c9a8dSPaul Mundt 	int (*setup_sys)(void *board_data, void *sys_ops_handle,
155225c9a8dSPaul Mundt 			 struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
156ef61aae4SMagnus Damm 	void (*start_transfer)(void *board_data, void *sys_ops_handle,
157ef61aae4SMagnus Damm 			       struct sh_mobile_lcdc_sys_bus_ops *sys_ops);
158c2439398SGuennadi Liakhovetski 	void (*display_on)(void *board_data, struct fb_info *info);
159225c9a8dSPaul Mundt 	void (*display_off)(void *board_data);
1603b0fd9d7SAlexandre Courbot 	int (*set_brightness)(void *board_data, int brightness);
1613b0fd9d7SAlexandre Courbot 	int (*get_brightness)(void *board_data);
162225c9a8dSPaul Mundt };
163225c9a8dSPaul Mundt 
164225c9a8dSPaul Mundt struct sh_mobile_lcdc_lcd_size_cfg { /* width and height of panel in mm */
165225c9a8dSPaul Mundt 	unsigned long width;
166225c9a8dSPaul Mundt 	unsigned long height;
167225c9a8dSPaul Mundt };
168225c9a8dSPaul Mundt 
1693b0fd9d7SAlexandre Courbot /* backlight info */
1703b0fd9d7SAlexandre Courbot struct sh_mobile_lcdc_bl_info {
1713b0fd9d7SAlexandre Courbot 	const char *name;
1723b0fd9d7SAlexandre Courbot 	int max_brightness;
1733b0fd9d7SAlexandre Courbot };
1743b0fd9d7SAlexandre Courbot 
175225c9a8dSPaul Mundt struct sh_mobile_lcdc_chan_cfg {
176225c9a8dSPaul Mundt 	int chan;
177225c9a8dSPaul Mundt 	int bpp;
178225c9a8dSPaul Mundt 	int interface_type; /* selects RGBn or SYSn I/F, see above */
179225c9a8dSPaul Mundt 	int clock_divider;
180f400f510SMagnus Damm 	unsigned long flags; /* LCDC_FLAGS_... */
18144432407SGuennadi Liakhovetski 	const struct fb_videomode *lcd_cfg;
18244432407SGuennadi Liakhovetski 	int num_cfg;
183225c9a8dSPaul Mundt 	struct sh_mobile_lcdc_lcd_size_cfg lcd_size_cfg;
184225c9a8dSPaul Mundt 	struct sh_mobile_lcdc_board_cfg board_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 */
18753b50314SDamian Hobson-Garcia 	int nonstd;
1887caa4342SDamian 	struct sh_mobile_meram_cfg *meram_cfg;
189225c9a8dSPaul Mundt };
190225c9a8dSPaul Mundt 
191225c9a8dSPaul Mundt struct sh_mobile_lcdc_info {
192225c9a8dSPaul Mundt 	int clock_source;
193225c9a8dSPaul Mundt 	struct sh_mobile_lcdc_chan_cfg ch[2];
1947caa4342SDamian 	struct sh_mobile_meram_info *meram_dev;
195225c9a8dSPaul Mundt };
196225c9a8dSPaul Mundt 
197225c9a8dSPaul Mundt #endif /* __ASM_SH_MOBILE_LCDC_H__ */
198