xref: /openbmc/linux/drivers/gpu/drm/gma500/oaktrail.h (revision abade675e02e1b73da0c20ffaf08fbe309038298)
1 /**************************************************************************
2  * Copyright (c) 2007-2011, Intel Corporation.
3  * All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms and conditions of the GNU General Public License,
7  * version 2, as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  **************************************************************************/
19 
20 struct psb_intel_mode_device;
21 
22 /* MID device specific descriptors */
23 
24 struct oaktrail_timing_info {
25 	u16 pixel_clock;
26 	u8 hactive_lo;
27 	u8 hblank_lo;
28 	u8 hblank_hi:4;
29 	u8 hactive_hi:4;
30 	u8 vactive_lo;
31 	u8 vblank_lo;
32 	u8 vblank_hi:4;
33 	u8 vactive_hi:4;
34 	u8 hsync_offset_lo;
35 	u8 hsync_pulse_width_lo;
36 	u8 vsync_pulse_width_lo:4;
37 	u8 vsync_offset_lo:4;
38 	u8 vsync_pulse_width_hi:2;
39 	u8 vsync_offset_hi:2;
40 	u8 hsync_pulse_width_hi:2;
41 	u8 hsync_offset_hi:2;
42 	u8 width_mm_lo;
43 	u8 height_mm_lo;
44 	u8 height_mm_hi:4;
45 	u8 width_mm_hi:4;
46 	u8 hborder;
47 	u8 vborder;
48 	u8 unknown0:1;
49 	u8 hsync_positive:1;
50 	u8 vsync_positive:1;
51 	u8 separate_sync:2;
52 	u8 stereo:1;
53 	u8 unknown6:1;
54 	u8 interlaced:1;
55 } __packed;
56 
57 struct gct_r10_timing_info {
58 	u16 pixel_clock;
59 	u32 hactive_lo:8;
60 	u32 hactive_hi:4;
61 	u32 hblank_lo:8;
62 	u32 hblank_hi:4;
63 	u32 hsync_offset_lo:8;
64 	u16 hsync_offset_hi:2;
65 	u16 hsync_pulse_width_lo:8;
66 	u16 hsync_pulse_width_hi:2;
67 	u16 hsync_positive:1;
68 	u16 rsvd_1:3;
69 	u8  vactive_lo:8;
70 	u16 vactive_hi:4;
71 	u16 vblank_lo:8;
72 	u16 vblank_hi:4;
73 	u16 vsync_offset_lo:4;
74 	u16 vsync_offset_hi:2;
75 	u16 vsync_pulse_width_lo:4;
76 	u16 vsync_pulse_width_hi:2;
77 	u16 vsync_positive:1;
78 	u16 rsvd_2:3;
79 } __packed;
80 
81 struct oaktrail_panel_descriptor_v1 {
82 	u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
83 				/* 0x61190 if MIPI */
84 	u32 Panel_Power_On_Sequencing;/*1 dword,Register 0x61208,*/
85 	u32 Panel_Power_Off_Sequencing;/*1 dword,Register 0x6120C,*/
86 	u32 Panel_Power_Cycle_Delay_and_Reference_Divisor;/* 1 dword */
87 						/* Register 0x61210 */
88 	struct oaktrail_timing_info DTD;/*18 bytes, Standard definition */
89 	u16 Panel_Backlight_Inverter_Descriptor;/* 16 bits, as follows */
90 				/* Bit 0, Frequency, 15 bits,0 - 32767Hz */
91 			/* Bit 15, Polarity, 1 bit, 0: Normal, 1: Inverted */
92 	u16 Panel_MIPI_Display_Descriptor;
93 			/*16 bits, Defined as follows: */
94 			/* if MIPI, 0x0000 if LVDS */
95 			/* Bit 0, Type, 2 bits, */
96 			/* 0: Type-1, */
97 			/* 1: Type-2, */
98 			/* 2: Type-3, */
99 			/* 3: Type-4 */
100 			/* Bit 2, Pixel Format, 4 bits */
101 			/* Bit0: 16bpp (not supported in LNC), */
102 			/* Bit1: 18bpp loosely packed, */
103 			/* Bit2: 18bpp packed, */
104 			/* Bit3: 24bpp */
105 			/* Bit 6, Reserved, 2 bits, 00b */
106 			/* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
107 			/* Bit 14, Reserved, 2 bits, 00b */
108 } __packed;
109 
110 struct oaktrail_panel_descriptor_v2 {
111 	u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
112 				/* 0x61190 if MIPI */
113 	u32 Panel_Power_On_Sequencing;/*1 dword,Register 0x61208,*/
114 	u32 Panel_Power_Off_Sequencing;/*1 dword,Register 0x6120C,*/
115 	u8 Panel_Power_Cycle_Delay_and_Reference_Divisor;/* 1 byte */
116 						/* Register 0x61210 */
117 	struct oaktrail_timing_info DTD;/*18 bytes, Standard definition */
118 	u16 Panel_Backlight_Inverter_Descriptor;/*16 bits, as follows*/
119 				/*Bit 0, Frequency, 16 bits, 0 - 32767Hz*/
120 	u8 Panel_Initial_Brightness;/* [7:0] 0 - 100% */
121 			/*Bit 7, Polarity, 1 bit,0: Normal, 1: Inverted*/
122 	u16 Panel_MIPI_Display_Descriptor;
123 			/*16 bits, Defined as follows: */
124 			/* if MIPI, 0x0000 if LVDS */
125 			/* Bit 0, Type, 2 bits, */
126 			/* 0: Type-1, */
127 			/* 1: Type-2, */
128 			/* 2: Type-3, */
129 			/* 3: Type-4 */
130 			/* Bit 2, Pixel Format, 4 bits */
131 			/* Bit0: 16bpp (not supported in LNC), */
132 			/* Bit1: 18bpp loosely packed, */
133 			/* Bit2: 18bpp packed, */
134 			/* Bit3: 24bpp */
135 			/* Bit 6, Reserved, 2 bits, 00b */
136 			/* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
137 			/* Bit 14, Reserved, 2 bits, 00b */
138 } __packed;
139 
140 union oaktrail_panel_rx {
141 	struct {
142 		u16 NumberOfLanes:2; /*Num of Lanes, 2 bits,0 = 1 lane,*/
143 			/* 1 = 2 lanes, 2 = 3 lanes, 3 = 4 lanes. */
144 		u16 MaxLaneFreq:3; /* 0: 100MHz, 1: 200MHz, 2: 300MHz, */
145 		/*3: 400MHz, 4: 500MHz, 5: 600MHz, 6: 700MHz, 7: 800MHz.*/
146 		u16 SupportedVideoTransferMode:2; /*0: Non-burst only */
147 					/* 1: Burst and non-burst */
148 					/* 2/3: Reserved */
149 		u16 HSClkBehavior:1; /*0: Continuous, 1: Non-continuous*/
150 		u16 DuoDisplaySupport:1; /*1 bit,0: No, 1: Yes*/
151 		u16 ECC_ChecksumCapabilities:1;/*1 bit,0: No, 1: Yes*/
152 		u16 BidirectionalCommunication:1;/*1 bit,0: No, 1: Yes */
153 		u16 Rsvd:5;/*5 bits,00000b */
154 	} panelrx;
155 	u16 panel_receiver;
156 } __packed;
157 
158 struct gct_r0 {
159 	union { /*8 bits,Defined as follows: */
160 		struct {
161 			u8 PanelType:4; /*4 bits, Bit field for panels*/
162 					/* 0 - 3: 0 = LVDS, 1 = MIPI*/
163 					/*2 bits,Specifies which of the*/
164 			u8 BootPanelIndex:2;
165 					/* 4 panels to use by default*/
166 			u8 BootMIPI_DSI_RxIndex:2;/*Specifies which of*/
167 					/* the 4 MIPI DSI receivers to use*/
168 		} PD;
169 		u8 PanelDescriptor;
170 	};
171 	struct oaktrail_panel_descriptor_v1 panel[4];/*panel descrs,38 bytes each*/
172 	union oaktrail_panel_rx panelrx[4]; /* panel receivers*/
173 } __packed;
174 
175 struct gct_r1 {
176 	union { /*8 bits,Defined as follows: */
177 		struct {
178 			u8 PanelType:4; /*4 bits, Bit field for panels*/
179 					/* 0 - 3: 0 = LVDS, 1 = MIPI*/
180 					/*2 bits,Specifies which of the*/
181 			u8 BootPanelIndex:2;
182 					/* 4 panels to use by default*/
183 			u8 BootMIPI_DSI_RxIndex:2;/*Specifies which of*/
184 					/* the 4 MIPI DSI receivers to use*/
185 		} PD;
186 		u8 PanelDescriptor;
187 	};
188 	struct oaktrail_panel_descriptor_v2 panel[4];/*panel descrs,38 bytes each*/
189 	union oaktrail_panel_rx panelrx[4]; /* panel receivers*/
190 } __packed;
191 
192 struct gct_r10 {
193 	struct gct_r10_timing_info DTD;
194 	u16 Panel_MIPI_Display_Descriptor;
195 	u16 Panel_MIPI_Receiver_Descriptor;
196 	u16 Panel_Backlight_Inverter_Descriptor;
197 	u8 Panel_Initial_Brightness;
198 	u32 MIPI_Ctlr_Init_ptr;
199 	u32 MIPI_Panel_Init_ptr;
200 } __packed;
201 
202 struct oaktrail_gct_data {
203 	u8 bpi; /* boot panel index, number of panel used during boot */
204 	u8 pt; /* panel type, 4 bit field, 0=lvds, 1=mipi */
205 	struct oaktrail_timing_info DTD; /* timing info for the selected panel */
206 	u32 Panel_Port_Control;
207 	u32 PP_On_Sequencing;/*1 dword,Register 0x61208,*/
208 	u32 PP_Off_Sequencing;/*1 dword,Register 0x6120C,*/
209 	u32 PP_Cycle_Delay;
210 	u16 Panel_Backlight_Inverter_Descriptor;
211 	u16 Panel_MIPI_Display_Descriptor;
212 } __packed;
213 
214 #define MODE_SETTING_IN_CRTC		0x1
215 #define MODE_SETTING_IN_ENCODER		0x2
216 #define MODE_SETTING_ON_GOING		0x3
217 #define MODE_SETTING_IN_DSR		0x4
218 #define MODE_SETTING_ENCODER_DONE	0x8
219 
220 /*
221  *	Moorestown HDMI interfaces
222  */
223 
224 struct oaktrail_hdmi_dev {
225 	struct pci_dev *dev;
226 	void __iomem *regs;
227 	unsigned int mmio, mmio_len;
228 	int dpms_mode;
229 	struct hdmi_i2c_dev *i2c_dev;
230 
231 	/* register state */
232 	u32 saveDPLL_CTRL;
233 	u32 saveDPLL_DIV_CTRL;
234 	u32 saveDPLL_ADJUST;
235 	u32 saveDPLL_UPDATE;
236 	u32 saveDPLL_CLK_ENABLE;
237 	u32 savePCH_HTOTAL_B;
238 	u32 savePCH_HBLANK_B;
239 	u32 savePCH_HSYNC_B;
240 	u32 savePCH_VTOTAL_B;
241 	u32 savePCH_VBLANK_B;
242 	u32 savePCH_VSYNC_B;
243 	u32 savePCH_PIPEBCONF;
244 	u32 savePCH_PIPEBSRC;
245 };
246 
247 extern void oaktrail_hdmi_setup(struct drm_device *dev);
248 extern void oaktrail_hdmi_teardown(struct drm_device *dev);
249 extern int  oaktrail_hdmi_i2c_init(struct pci_dev *dev);
250 extern void oaktrail_hdmi_i2c_exit(struct pci_dev *dev);
251 extern void oaktrail_hdmi_save(struct drm_device *dev);
252 extern void oaktrail_hdmi_restore(struct drm_device *dev);
253 extern void oaktrail_hdmi_init(struct drm_device *dev, struct psb_intel_mode_device *mode_dev);
254 extern int oaktrail_crtc_hdmi_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
255 						struct drm_display_mode *adjusted_mode, int x, int y,
256 						struct drm_framebuffer *old_fb);
257 extern void oaktrail_crtc_hdmi_dpms(struct drm_crtc *crtc, int mode);
258 
259 
260