gfx: drv: move macro to check pipe validity to psb_intel_reg.h
[platform/kernel/kernel-mfld-blackbay.git] / drivers / staging / mrst / drv / psb_intel_reg.h
1 /*
2  * Copyright (c) 2009, Intel Corporation.
3  * 
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * You should have received a copy of the GNU General Public License along with
14  * this program; if not, write to the Free Software Foundation, Inc., 
15  * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
16  */
17 #ifndef __PSB_INTEL_REG_H__
18 #define __PSB_INTEL_REG_H__
19
20 #ifdef DEBUG
21 #define PSB_CHECK_PIPE(pipe, valid_pipes) ({            \
22         const typeof(pipe) __pipe = (pipe);             \
23         BUG_ON(!((1 << __pipe) & (valid_pipes)));       \
24         __pipe; })
25 #else
26 #define PSB_CHECK_PIPE(pipe, valid_pipes) (pipe)
27 #endif
28
29 #define BLC_PWM_CTL             0x61254
30 #define BLC_PWM_CTL2            0x61250
31 #define BLC_PWM_CTL_C           0x62254
32 #define BLC_PWM_CTL2_C          0x62250
33 #define BACKLIGHT_MODULATION_FREQ_SHIFT         (17)
34 /**
35  * This is the most significant 15 bits of the number of backlight cycles in a
36  * complete cycle of the modulated backlight control.
37  *
38  * The actual value is this field multiplied by two.
39  */
40 #define BACKLIGHT_MODULATION_FREQ_MASK          (0x7fff << 17)
41 #define BLM_LEGACY_MODE                         (1 << 16)
42 /**
43  * This is the number of cycles out of the backlight modulation cycle for which
44  * the backlight is on.
45  *
46  * This field must be no greater than the number of cycles in the complete
47  * backlight modulation cycle.
48  */
49 #define BACKLIGHT_DUTY_CYCLE_SHIFT              (0)
50 #define BACKLIGHT_DUTY_CYCLE_MASK               (0xffff)
51
52 #define I915_GCFGC                      0xf0
53 #define I915_LOW_FREQUENCY_ENABLE               (1 << 7)
54 #define I915_DISPLAY_CLOCK_190_200_MHZ          (0 << 4)
55 #define I915_DISPLAY_CLOCK_333_MHZ              (4 << 4)
56 #define I915_DISPLAY_CLOCK_MASK                 (7 << 4)
57
58 #define I855_HPLLCC                     0xc0
59 #define I855_CLOCK_CONTROL_MASK                 (3 << 0)
60 #define I855_CLOCK_133_200                      (0 << 0)
61 #define I855_CLOCK_100_200                      (1 << 0)
62 #define I855_CLOCK_100_133                      (2 << 0)
63 #define I855_CLOCK_166_250                      (3 << 0)
64
65 /* I830 CRTC registers */
66 #define HTOTAL_A        0x60000
67 #define HBLANK_A        0x60004
68 #define HSYNC_A         0x60008
69 #define VTOTAL_A        0x6000c
70 #define VBLANK_A        0x60010
71 #define VSYNC_A         0x60014
72 #define PIPEASRC        0x6001c
73 #define BCLRPAT_A       0x60020
74 #define VSYNCSHIFT_A    0x60028
75
76 #define HTOTAL_B        0x61000
77 #define HBLANK_B        0x61004
78 #define HSYNC_B         0x61008
79 #define VTOTAL_B        0x6100c
80 #define VBLANK_B        0x61010
81 #define VSYNC_B         0x61014
82 #define PIPEBSRC        0x6101c
83 #define BCLRPAT_B       0x61020
84 #define VSYNCSHIFT_B    0x61028
85
86 #define HTOTAL_C        0x62000
87 #define HBLANK_C        0x62004
88 #define HSYNC_C         0x62008
89 #define VTOTAL_C        0x6200c
90 #define VBLANK_C        0x62010
91 #define VSYNC_C         0x62014
92 #define PIPECSRC        0x6201c
93 #define BCLRPAT_C       0x62020
94 #define VSYNCSHIFT_C    0x62028
95
96 #define PP_STATUS       0x61200
97 # define PP_ON                                  (1 << 31)
98 /**
99  * Indicates that all dependencies of the panel are on:
100  *
101  * - PLL enabled
102  * - pipe enabled
103  * - LVDS/DVOB/DVOC on
104  */
105 # define PP_READY                               (1 << 30)
106 # define PP_SEQUENCE_NONE                       (0 << 28)
107 # define PP_SEQUENCE_ON                         (1 << 28)
108 # define PP_SEQUENCE_OFF                        (2 << 28)
109 # define PP_SEQUENCE_MASK                       0x30000000
110 #define PP_CONTROL      0x61204
111 # define POWER_TARGET_ON                        (1 << 0)
112
113 #define LVDSPP_ON       0x61208
114 #define LVDSPP_OFF      0x6120c
115 #define PP_CYCLE        0x61210
116
117 #define PFIT_CONTROL    0x61230
118 # define PFIT_ENABLE                            (1 << 31)
119 # define PFIT_PIPE_MASK                         (3 << 29)
120 # define PFIT_PIPE_SHIFT                        29
121 # define PFIT_PIPE_SELECT_A                     (0 << PFIT_PIPE_SHIFT)
122 # define PFIT_PIPE_SELECT_B                     (1 << PFIT_PIPE_SHIFT)
123 # define PFIT_PIPE_SELECT_C                     (2 << PFIT_PIPE_SHIFT)
124 # define PFIT_PIPE_SELECT_D                     (3 << PFIT_PIPE_SHIFT)
125 # define PFIT_SCALING_MODE_PILLARBOX            (1 << 27)
126 # define PFIT_SCALING_MODE_LETTERBOX            (3 << 26)
127 # define VERT_INTERP_DISABLE                    (0 << 10)
128 # define VERT_INTERP_BILINEAR                   (1 << 10)
129 # define VERT_INTERP_MASK                       (3 << 10)
130 # define VERT_AUTO_SCALE                        (1 << 9)
131 # define HORIZ_INTERP_DISABLE                   (0 << 6)
132 # define HORIZ_INTERP_BILINEAR                  (1 << 6)
133 # define HORIZ_INTERP_MASK                      (3 << 6)
134 # define HORIZ_AUTO_SCALE                       (1 << 5)
135 # define PANEL_8TO6_DITHER_ENABLE               (1 << 3)
136
137 #define PFIT_PGM_RATIOS 0x61234
138 # define PFIT_VERT_SCALE_MASK                   0xfff00000
139 # define PFIT_HORIZ_SCALE_MASK                  0x0000fff0
140
141 #define PFIT_AUTO_RATIOS        0x61238
142
143
144 #define DPLL_A          0x06014
145 #define DPLL_B          0x06018
146 # define DPLL_VCO_ENABLE                        (1 << 31)
147 # define DPLL_DVO_HIGH_SPEED                    (1 << 30)
148 # define DPLL_SYNCLOCK_ENABLE                   (1 << 29)
149 # define DPLL_VGA_MODE_DIS                      (1 << 28)
150 # define DPLLB_MODE_DAC_SERIAL                  (1 << 26)       /* i915 */
151 # define DPLLB_MODE_LVDS                        (2 << 26)       /* i915 */
152 # define DPLL_MODE_MASK                         (3 << 26)
153 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_10        (0 << 24)       /* i915 */
154 # define DPLL_DAC_SERIAL_P2_CLOCK_DIV_5         (1 << 24)       /* i915 */
155 # define DPLLB_LVDS_P2_CLOCK_DIV_14             (0 << 24)       /* i915 */
156 # define DPLLB_LVDS_P2_CLOCK_DIV_7              (1 << 24)       /* i915 */
157 # define DPLL_P2_CLOCK_DIV_MASK                 0x03000000      /* i915 */
158 # define DPLL_FPA01_P1_POST_DIV_MASK            0x00ff0000      /* i915 */
159 /**
160  *  The i830 generation, in DAC/serial mode, defines p1 as two plus this
161  * bitfield, or just 2 if PLL_P1_DIVIDE_BY_TWO is set.
162  */
163 # define DPLL_FPA01_P1_POST_DIV_MASK_I830       0x001f0000
164 /**
165  * The i830 generation, in LVDS mode, defines P1 as the bit number set within
166  * this field (only one bit may be set).
167  */
168 # define DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS  0x003f0000
169 # define DPLL_FPA01_P1_POST_DIV_SHIFT           16
170 # define PLL_P2_DIVIDE_BY_4             (1 << 23)       /* i830, required
171                                                          * in DVO non-gang */
172 # define PLL_P1_DIVIDE_BY_TWO                   (1 << 21)       /* i830 */
173 # define PLL_REF_INPUT_DREFCLK                  (0 << 13)
174 # define PLL_REF_INPUT_TVCLKINA                 (1 << 13)       /* i830 */
175 # define PLL_REF_INPUT_TVCLKINBC                (2 << 13)       /* SDVO
176                                                                  * TVCLKIN */
177 # define PLLB_REF_INPUT_SPREADSPECTRUMIN        (3 << 13)
178 # define PLL_REF_INPUT_MASK                     (3 << 13)
179 # define PLL_LOAD_PULSE_PHASE_SHIFT             9
180 /*
181  * Parallel to Serial Load Pulse phase selection.
182  * Selects the phase for the 10X DPLL clock for the PCIe
183  * digital display port. The range is 4 to 13; 10 or more
184  * is just a flip delay. The default is 6
185  */
186 # define PLL_LOAD_PULSE_PHASE_MASK      (0xf << PLL_LOAD_PULSE_PHASE_SHIFT)
187 # define DISPLAY_RATE_SELECT_FPA1       (1 << 8)
188
189 /**
190  * SDVO multiplier for 945G/GM. Not used on 965.
191  *
192  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
193  */
194 # define SDVO_MULTIPLIER_MASK                   0x000000ff
195 # define SDVO_MULTIPLIER_SHIFT_HIRES            4
196 # define SDVO_MULTIPLIER_SHIFT_VGA              0
197
198 /** @defgroup DPLL_MD
199  * @{
200  */
201 /** Pipe A SDVO/UDI clock multiplier/divider register for G965. */
202 #define DPLL_A_MD               0x0601c
203 /** Pipe B SDVO/UDI clock multiplier/divider register for G965. */
204 #define DPLL_B_MD               0x06020
205 /**
206  * UDI pixel divider, controlling how many pixels are stuffed into a packet.
207  *
208  * Value is pixels minus 1.  Must be set to 1 pixel for SDVO.
209  */
210 # define DPLL_MD_UDI_DIVIDER_MASK               0x3f000000
211 # define DPLL_MD_UDI_DIVIDER_SHIFT              24
212 /** UDI pixel divider for VGA, same as DPLL_MD_UDI_DIVIDER_MASK. */
213 # define DPLL_MD_VGA_UDI_DIVIDER_MASK           0x003f0000
214 # define DPLL_MD_VGA_UDI_DIVIDER_SHIFT          16
215 /**
216  * SDVO/UDI pixel multiplier.
217  *
218  * SDVO requires that the bus clock rate be between 1 and 2 Ghz, and the bus
219  * clock rate is 10 times the DPLL clock.  At low resolution/refresh rate
220  * modes, the bus rate would be below the limits, so SDVO allows for stuffing
221  * dummy bytes in the datastream at an increased clock rate, with both sides of
222  * the link knowing how many bytes are fill.
223  *
224  * So, for a mode with a dotclock of 65Mhz, we would want to double the clock
225  * rate to 130Mhz to get a bus rate of 1.30Ghz.  The DPLL clock rate would be
226  * set to 130Mhz, and the SDVO multiplier set to 2x in this register and
227  * through an SDVO command.
228  *
229  * This register field has values of multiplication factor minus 1, with
230  * a maximum multiplier of 5 for SDVO.
231  */
232 # define DPLL_MD_UDI_MULTIPLIER_MASK            0x00003f00
233 # define DPLL_MD_UDI_MULTIPLIER_SHIFT           8
234 /** SDVO/UDI pixel multiplier for VGA, same as DPLL_MD_UDI_MULTIPLIER_MASK.
235  * This best be set to the default value (3) or the CRT won't work. No,
236  * I don't entirely understand what this does...
237  */
238 # define DPLL_MD_VGA_UDI_MULTIPLIER_MASK        0x0000003f
239 # define DPLL_MD_VGA_UDI_MULTIPLIER_SHIFT       0
240 /** @} */
241
242 #define DPLL_TEST               0x606c
243 # define DPLLB_TEST_SDVO_DIV_1                  (0 << 22)
244 # define DPLLB_TEST_SDVO_DIV_2                  (1 << 22)
245 # define DPLLB_TEST_SDVO_DIV_4                  (2 << 22)
246 # define DPLLB_TEST_SDVO_DIV_MASK               (3 << 22)
247 # define DPLLB_TEST_N_BYPASS                    (1 << 19)
248 # define DPLLB_TEST_M_BYPASS                    (1 << 18)
249 # define DPLLB_INPUT_BUFFER_ENABLE              (1 << 16)
250 # define DPLLA_TEST_N_BYPASS                    (1 << 3)
251 # define DPLLA_TEST_M_BYPASS                    (1 << 2)
252 # define DPLLA_INPUT_BUFFER_ENABLE              (1 << 0)
253
254 #define ADPA                    0x61100
255 #define ADPA_DAC_ENABLE         (1<<31)
256 #define ADPA_DAC_DISABLE        0
257 #define ADPA_PIPE_SELECT_MASK   (1<<30)
258 #define ADPA_PIPE_A_SELECT      0
259 #define ADPA_PIPE_B_SELECT      (1<<30)
260 #define ADPA_USE_VGA_HVPOLARITY (1<<15)
261 #define ADPA_SETS_HVPOLARITY    0
262 #define ADPA_VSYNC_CNTL_DISABLE (1<<11)
263 #define ADPA_VSYNC_CNTL_ENABLE  0
264 #define ADPA_HSYNC_CNTL_DISABLE (1<<10)
265 #define ADPA_HSYNC_CNTL_ENABLE  0
266 #define ADPA_VSYNC_ACTIVE_HIGH  (1<<4)
267 #define ADPA_VSYNC_ACTIVE_LOW   0
268 #define ADPA_HSYNC_ACTIVE_HIGH  (1<<3)
269 #define ADPA_HSYNC_ACTIVE_LOW   0
270
271 #define FPA0            0x06040
272 #define FPA1            0x06044
273 #define FPB0            0x06048
274 #define FPB1            0x0604c
275 # define FP_N_DIV_MASK                          0x003f0000
276 # define FP_N_DIV_SHIFT                         16
277 # define FP_M1_DIV_MASK                         0x00003f00
278 # define FP_M1_DIV_SHIFT                        8
279 # define FP_M2_DIV_MASK                         0x0000003f
280 # define FP_M2_DIV_SHIFT                        0
281
282
283 #define PORT_HOTPLUG_EN         0x61110
284 # define SDVOB_HOTPLUG_INT_EN                   (1 << 26)
285 # define SDVOC_HOTPLUG_INT_EN                   (1 << 25)
286 # define TV_HOTPLUG_INT_EN                      (1 << 18)
287 # define CRT_HOTPLUG_INT_EN                     (1 << 9)
288 # define CRT_HOTPLUG_FORCE_DETECT               (1 << 3)
289
290 #define PORT_HOTPLUG_STAT       0x61114
291 # define CRT_HOTPLUG_INT_STATUS                 (1 << 11)
292 # define TV_HOTPLUG_INT_STATUS                  (1 << 10)
293 # define CRT_HOTPLUG_MONITOR_MASK               (3 << 8)
294 # define CRT_HOTPLUG_MONITOR_COLOR              (3 << 8)
295 # define CRT_HOTPLUG_MONITOR_MONO               (2 << 8)
296 # define CRT_HOTPLUG_MONITOR_NONE               (0 << 8)
297 # define SDVOC_HOTPLUG_INT_STATUS               (1 << 7)
298 # define SDVOB_HOTPLUG_INT_STATUS               (1 << 6)
299
300 #define SDVOB                   0x61140
301 #define SDVOC                   0x61160
302 #define SDVO_ENABLE                             (1 << 31)
303 #define SDVO_PIPE_B_SELECT                      (1 << 30)
304 #define SDVO_STALL_SELECT                       (1 << 29)
305 #define SDVO_INTERRUPT_ENABLE                   (1 << 26)
306 /**
307  * 915G/GM SDVO pixel multiplier.
308  *
309  * Programmed value is multiplier - 1, up to 5x.
310  *
311  * \sa DPLL_MD_UDI_MULTIPLIER_MASK
312  */
313 #define SDVO_PORT_MULTIPLY_MASK                 (7 << 23)
314 #define SDVO_PORT_MULTIPLY_SHIFT                23
315 #define SDVO_PHASE_SELECT_MASK                  (15 << 19)
316 #define SDVO_PHASE_SELECT_DEFAULT               (6 << 19)
317 #define SDVO_CLOCK_OUTPUT_INVERT                (1 << 18)
318 #define SDVOC_GANG_MODE                         (1 << 16)
319 #define SDVO_BORDER_ENABLE                      (1 << 7)
320 #define SDVOB_PCIE_CONCURRENCY                  (1 << 3)
321 #define SDVO_DETECTED                           (1 << 2)
322 /* Bits to be preserved when writing */
323 #define SDVOB_PRESERVE_MASK             ((1 << 17) | (1 << 16) | (1 << 14))
324 #define SDVOC_PRESERVE_MASK                     (1 << 17)
325
326 /** @defgroup LVDS
327  * @{
328  */
329 /**
330  * This register controls the LVDS output enable, pipe selection, and data
331  * format selection.
332  *
333  * All of the clock/data pairs are force powered down by power sequencing.
334  */
335 #define LVDS                    0x61180
336 /**
337  * Enables the LVDS port.  This bit must be set before DPLLs are enabled, as
338  * the DPLL semantics change when the LVDS is assigned to that pipe.
339  */
340 # define LVDS_PORT_EN                   (1 << 31)
341 /** Selects pipe B for LVDS data.  Must be set on pre-965. */
342 # define LVDS_PIPEB_SELECT              (1 << 30)
343
344 /** Turns on border drawing to allow centered display. */
345 # define LVDS_BORDER_EN                 (1 << 15)
346
347 /**
348  * Enables the A0-A2 data pairs and CLKA, containing 18 bits of color data per
349  * pixel.
350  */
351 # define LVDS_A0A2_CLKA_POWER_MASK      (3 << 8)
352 # define LVDS_A0A2_CLKA_POWER_DOWN      (0 << 8)
353 # define LVDS_A0A2_CLKA_POWER_UP        (3 << 8)
354 /**
355  * Controls the A3 data pair, which contains the additional LSBs for 24 bit
356  * mode.  Only enabled if LVDS_A0A2_CLKA_POWER_UP also indicates it should be
357  * on.
358  */
359 # define LVDS_A3_POWER_MASK             (3 << 6)
360 # define LVDS_A3_POWER_DOWN             (0 << 6)
361 # define LVDS_A3_POWER_UP               (3 << 6)
362 /**
363  * Controls the CLKB pair.  This should only be set when LVDS_B0B3_POWER_UP
364  * is set.
365  */
366 # define LVDS_CLKB_POWER_MASK           (3 << 4)
367 # define LVDS_CLKB_POWER_DOWN           (0 << 4)
368 # define LVDS_CLKB_POWER_UP             (3 << 4)
369
370 /**
371  * Controls the B0-B3 data pairs.  This must be set to match the DPLL p2
372  * setting for whether we are in dual-channel mode.  The B3 pair will
373  * additionally only be powered up when LVDS_A3_POWER_UP is set.
374  */
375 # define LVDS_B0B3_POWER_MASK           (3 << 2)
376 # define LVDS_B0B3_POWER_DOWN           (0 << 2)
377 # define LVDS_B0B3_POWER_UP             (3 << 2)
378
379 #define PIPEA_DSL               0x70000
380 #define PIPEB_DSL               0x71000
381 #define PIPEC_DSL               0x72000
382
383 #define PIPEACONF 0x70008
384 #define PIPEACONF_ENABLE        (1<<31)
385 #define PIPEACONF_DISABLE       0
386 #define PIPEACONF_DOUBLE_WIDE   (1<<30)
387 #define PIPECONF_ACTIVE         (1<<30)
388 #define I965_PIPECONF_ACTIVE    (1<<30)
389 #define PIPECONF_DSIPLL_LOCK    (1<<29)
390 #define PIPEACONF_SINGLE_WIDE   0
391 #define PIPEACONF_PIPE_UNLOCKED 0
392 #define PIPEACONF_DSR           (1<<26)
393 #define PIPEACONF_PIPE_LOCKED   (1<<25)
394 #define PIPEACONF_PALETTE       0
395 #define PIPECONF_FORCE_BORDER   (1<<25)
396 #define PIPEACONF_GAMMA         (1<<24)
397 #define PIPECONF_PROGRESSIVE    (0 << 21)
398 #define PIPECONF_INTERLACE_W_FIELD_INDICATION   (6 << 21)
399 #define PIPECONF_INTERLACE_FIELD_0_ONLY         (7 << 21)
400 #define PIPECONF_PLANE_OFF      (1<<19)
401 #define PIPECONF_CURSOR_OFF     (1<<18)
402
403
404 #define PIPEBCONF 0x71008
405 #define PIPEBCONF_ENABLE        (1<<31)
406 #define PIPEBCONF_DISABLE       0
407 #define PIPEBCONF_DOUBLE_WIDE   (1<<30)
408 #define PIPEBCONF_DISABLE       0
409 #define PIPEBCONF_GAMMA         (1<<24)
410 #define PIPEBCONF_PALETTE       0
411
412 #define PIPECCONF 0x72008
413
414 #define PIPEBGCMAXRED           0x71010
415 #define PIPEBGCMAXGREEN         0x71014
416 #define PIPEBGCMAXBLUE          0x71018
417
418 #define PIPEASTAT               0x70024
419 #define PIPEBSTAT               0x71024
420 #define PIPECSTAT               0x72024
421 #define PIPE_VBLANK_INTERRUPT_STATUS         (1UL<<1)
422 #define PIPE_START_VBLANK_INTERRUPT_STATUS   (1UL<<2)
423 #define PIPE_VBLANK_CLEAR                    (1 << 1)
424 #define PIPE_VBLANK_STATUS                   (1 << 1)
425 #define PIPE_TE_STATUS                       (1UL<<6)
426 #define PIPE_DPST_EVENT_STATUS               (1UL<<7)
427 #define PIPE_VSYNC_CLEAR                     (1UL<<9)
428 #define PIPE_VSYNC_STATUS                    (1UL<<9)
429 #define PIPE_HDMI_AUDIO_UNDERRUN_STATUS      (1UL<<10)
430 #define PIPE_HDMI_AUDIO_BUFFER_DONE_STATUS   (1UL<<11)
431 #define PIPE_VBLANK_INTERRUPT_ENABLE         (1UL<<17)
432 #define PIPE_START_VBLANK_INTERRUPT_ENABLE   (1UL<<18)
433 #define PIPE_TE_ENABLE                       (1UL<<22)
434 #define PIPE_DPST_EVENT_ENABLE               (1UL<<23)
435 #define PIPE_VSYNC_ENABL                     (1UL<<25)
436 #define PIPE_HDMI_AUDIO_UNDERRUN             (1UL<<26)
437 #define PIPE_HDMI_AUDIO_BUFFER_DONE          (1UL<<27)
438 #define PIPE_HDMI_AUDIO_INT_MASK (PIPE_HDMI_AUDIO_UNDERRUN | PIPE_HDMI_AUDIO_BUFFER_DONE)
439 #define PIPE_EVENT_MASK (BIT(29)|BIT(28)|BIT(27)|BIT(26)|BIT(24)|BIT(23)|BIT(22)|BIT(21)|BIT(20)|BIT(16))
440 #define PIPE_VBLANK_MASK (BIT(25)|BIT(24)|BIT(18)|BIT(17))
441 #define HISTOGRAM_INT_CONTROL           0x61268
442 #define HISTOGRAM_BIN_DATA              0X61264
443 #define HISTOGRAM_LOGIC_CONTROL         0x61260
444 #define PWM_CONTROL_LOGIC               0x61250
445 #define PIPE_HOTPLUG_INTERRUPT_STATUS   (1UL<<10)
446 #define HISTOGRAM_INTERRUPT_ENABLE      (1UL<<31)
447 #define HISTOGRAM_LOGIC_ENABLE          (1UL<<31)
448 #define PWM_LOGIC_ENABLE                (1UL<<31)
449 #define PWM_PHASEIN_ENABLE              (1UL<<25)
450 #define PWM_PHASEIN_INT_ENABLE          (1UL<<24)
451 #define PWM_PHASEIN_VB_COUNT            0x00001f00
452 #define PWM_PHASEIN_INC                 0x0000001f
453 #define HISTOGRAM_INT_CTRL_CLEAR        (1UL<<30)
454 #define DPST_YUV_LUMA_MODE              0
455
456 struct dpst_ie_histogram_control {
457         union {
458                 uint32_t data;
459                 struct {
460                         uint32_t bin_reg_index:7;
461                         uint32_t reserved:4;
462                         uint32_t bin_reg_func_select:1;
463                         uint32_t sync_to_phase_in:1;
464                         uint32_t alt_enhancement_mode:2;
465                         uint32_t reserved1:1;
466                         uint32_t sync_to_phase_in_count:8;
467                         uint32_t histogram_mode_select:1;
468                         uint32_t reserved2:4;
469                         uint32_t ie_pipe_assignment:1;
470                         uint32_t ie_mode_table_enabled:1;
471                         uint32_t ie_histogram_enable:1;
472                 };
473         };
474 };
475
476 struct dpst_guardband {
477         union {
478                 uint32_t data;
479                 struct {
480                         uint32_t guardband:22;
481                         uint32_t guardband_interrupt_delay:8;
482                         uint32_t interrupt_status:1;
483                         uint32_t interrupt_enable:1;
484                 };
485         };
486 };
487
488 #define PIPEAFRAMEHIGH          0x70040
489 #define PIPEAFRAMEPIXEL         0x70044
490 #define PIPEBFRAMEHIGH          0x71040
491 #define PIPEBFRAMEPIXEL         0x71044
492 #define PIPECFRAMEHIGH          0x72040
493 #define PIPECFRAMEPIXEL         0x72044
494 #define PIPE_FRAME_HIGH_MASK    0x0000ffff
495 #define PIPE_FRAME_HIGH_SHIFT   0
496 #define PIPE_FRAME_LOW_MASK     0xff000000
497 #define PIPE_FRAME_LOW_SHIFT    24
498 #define PIPE_PIXEL_MASK         0x00ffffff
499 #define PIPE_PIXEL_SHIFT        0
500
501 #define DSPARB                  0x70030
502 #define DSPFW1                  0x70034
503 #define DSPFW2                  0x70038
504 #define DSPFW3                  0x7003c
505 #define DSPFW4                  0x70050
506 #define DSPFW5                  0x70054
507 #define DSPFW6                  0x70058
508 #define DSPCHICKENBIT           0x70400
509 #define DSPACNTR                0x70180
510 #define DSPBCNTR                0x71180
511 #define DSPCCNTR                0x72180
512 #define DISPLAY_PLANE_ENABLE                    (1<<31)
513 #define DISPLAY_PLANE_DISABLE                   0
514 #define DISPPLANE_GAMMA_ENABLE                  (1<<30)
515 #define DISPPLANE_GAMMA_DISABLE                 0
516 #define DISPPLANE_PIXFORMAT_MASK                (0xf<<26)
517 #define DISPPLANE_8BPP                          (0x2<<26)
518 #define DISPPLANE_15_16BPP                      (0x4<<26)
519 #define DISPPLANE_16BPP                         (0x5<<26)
520 #define DISPPLANE_32BPP_NO_ALPHA                (0x6<<26)
521 #define DISPPLANE_32BPP                         (0x7<<26)
522 #define DISPPLANE_STEREO_ENABLE                 (1<<25)
523 #define DISPPLANE_STEREO_DISABLE                0
524 #define DISPPLANE_SEL_PIPE_MASK                 (1<<24)
525 #define DISPPLANE_SEL_PIPE_POS                  24
526 #define DISPPLANE_SEL_PIPE_A                    0
527 #define DISPPLANE_SEL_PIPE_B                    (1<<24)
528 #define DISPPLANE_SRC_KEY_ENABLE                (1<<22)
529 #define DISPPLANE_SRC_KEY_DISABLE               0
530 #define DISPPLANE_LINE_DOUBLE                   (1<<20)
531 #define DISPPLANE_NO_LINE_DOUBLE                0
532 #define DISPPLANE_STEREO_POLARITY_FIRST         0
533 #define DISPPLANE_STEREO_POLARITY_SECOND        (1<<18)
534 /* plane B only */
535 #define DISPPLANE_ALPHA_TRANS_ENABLE            (1<<15)
536 #define DISPPLANE_ALPHA_TRANS_DISABLE           0
537 #define DISPPLANE_SPRITE_ABOVE_DISPLAYA         0
538 #define DISPPLANE_SPRITE_ABOVE_OVERLAY          (1)
539 #define DISPPLANE_BOTTOM                        (4)
540
541 #define DSPABASE                0x70184
542 #define DSPALINOFF              0x70184
543 #define DSPASTRIDE              0x70188
544
545 #define DSPBBASE                0x71184
546 #define DSPBLINOFF              0X71184
547 #define DSPBADDR                DSPBBASE
548 #define DSPBSTRIDE              0x71188
549
550 #define DSPCBASE                0x72184
551 #define DSPCLINOFF              0x72184
552 #define DSPCSTRIDE              0x72188
553
554 #define DSPAKEYVAL              0x70194
555 #define DSPAKEYMASK             0x70198
556
557 #define DSPAPOS                 0x7018C /* reserved */
558 #define DSPASIZE                0x70190
559 #define DSPBPOS                 0x7118C
560 #define DSPBSIZE                0x71190
561 #define DSPCPOS                 0x7218C
562 #define DSPCSIZE                0x72190
563
564 #define DSPASURF                0x7019C
565 #define DSPATILEOFF             0x701A4
566
567 #define DSPBSURF                0x7119C
568 #define DSPBTILEOFF             0x711A4
569
570 #define DSPCSURF                0x7219C
571 #define DSPCTILEOFF             0x721A4
572 #define DSPCKEYMAXVAL           0x721A0
573 #define DSPCKEYMINVAL           0x72194
574 #define DSPCKEYMSK              0x72198
575
576 #define VGACNTRL                0x71400
577 # define VGA_DISP_DISABLE                       (1 << 31)
578 # define VGA_2X_MODE                            (1 << 30)
579 # define VGA_PIPE_B_SELECT                      (1 << 29)
580
581 /*
582  * Overlay registers
583  */
584 #define OV_C_OFFSET             0x08000
585 #define OV_OVADD                0x30000
586 #define OV_DOVASTA              0x30008
587 # define OV_PIPE_SELECT                         (BIT(6)|BIT(7))
588 # define OV_PIPE_SELECT_POS                     6
589 # define OV_PIPE_A                              0
590 # define OV_PIPE_C                              1
591 #define OV_OGAMC5               0x30010
592 #define OV_OGAMC4               0x30014
593 #define OV_OGAMC3               0x30018
594 #define OV_OGAMC2               0x3001C
595 #define OV_OGAMC1               0x30020
596 #define OV_OGAMC0               0x30024
597 #define OVC_OVADD               0x38000
598 #define OVC_DOVCSTA             0x38008
599 #define OVC_OGAMC5              0x38010
600 #define OVC_OGAMC4              0x38014
601 #define OVC_OGAMC3              0x38018
602 #define OVC_OGAMC2              0x3801C
603 #define OVC_OGAMC1              0x38020
604 #define OVC_OGAMC0              0x38024
605
606 /*
607  * Some BIOS scratch area registers.  The 845 (and 830?) store the amount
608  * of video memory available to the BIOS in SWF1.
609  */ 
610 #define SWF0                    0x71410
611 #define SWF1                    0x71414
612 #define SWF2                    0x71418
613 #define SWF3                    0x7141c
614 #define SWF4                    0x71420
615 #define SWF5                    0x71424
616 #define SWF6                    0x71428
617
618 /*
619  * 855 scratch registers.
620  */
621 #define SWF00                   0x70410
622 #define SWF01                   0x70414
623 #define SWF02                   0x70418
624 #define SWF03                   0x7041c
625 #define SWF04                   0x70420
626 #define SWF05                   0x70424
627 #define SWF06                   0x70428
628
629 #define SWF10                   SWF0
630 #define SWF11                   SWF1
631 #define SWF12                   SWF2
632 #define SWF13                   SWF3
633 #define SWF14                   SWF4
634 #define SWF15                   SWF5
635 #define SWF16                   SWF6
636
637 #define SWF30                   0x72414
638 #define SWF31                   0x72418
639 #define SWF32                   0x7241c
640
641
642 /*
643  * Palette registers
644  */
645 #define PALETTE_A               0x0a000
646 #define PALETTE_B               0x0a800
647 #define PALETTE_C               0x0ac00
648
649 #define IS_I830(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82830_CGC)
650 #define IS_845G(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82845G_IG)
651 #define IS_I85X(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82855GM_IG)
652 #define IS_I855(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82855GM_IG)
653 #define IS_I865G(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82865_IG)
654
655
656 /* || dev->pci_device == PCI_DEVICE_ID_INTELPCI_CHIP_E7221_G) */
657 #define IS_I915G(dev) (dev->pci_device == PCI_DEVICE_ID_INTEL_82915G_IG)
658 #define IS_I915GM(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82915GM_IG)
659 #define IS_I945G(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82945G_IG)
660 #define IS_I945GM(dev) ((dev)->pci_device == PCI_DEVICE_ID_INTEL_82945GM_IG)
661
662 #define IS_I965G(dev) ((dev)->pci_device == 0x2972 || \
663                        (dev)->pci_device == 0x2982 || \
664                        (dev)->pci_device == 0x2992 || \
665                        (dev)->pci_device == 0x29A2 || \
666                        (dev)->pci_device == 0x2A02 || \
667                        (dev)->pci_device == 0x2A12)
668
669 #define IS_I965GM(dev) ((dev)->pci_device == 0x2A02)
670
671 #define IS_G33(dev)    ((dev)->pci_device == 0x29C2 ||  \
672                         (dev)->pci_device == 0x29B2 ||  \
673                         (dev)->pci_device == 0x29D2)
674
675 #define IS_I9XX(dev) (IS_I915G(dev) || IS_I915GM(dev) || IS_I945G(dev) || \
676                         IS_I945GM(dev) || IS_I965G(dev))
677
678 #define IS_MOBILE(dev) (IS_I830(dev) || IS_I85X(dev) || IS_I915GM(dev) || \
679                                 IS_I945GM(dev) || IS_I965GM(dev))
680
681 /* Cursor A & B regs */
682 #define CURACNTR                0x70080
683 #define   CURSOR_MODE_DISABLE   0x00
684 #define   CURSOR_MODE_64_32B_AX 0x07
685 #define   CURSOR_MODE_64_ARGB_AX ((1 << 5) | CURSOR_MODE_64_32B_AX)
686 #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
687 #define CURABASE                0x70084
688 #define CURAPOS                 0x70088
689 #define   CURSOR_POS_MASK       0x007FF
690 #define   CURSOR_POS_SIGN       0x8000
691 #define   CURSOR_X_SHIFT        0
692 #define   CURSOR_Y_SHIFT        16
693 #define CURBCNTR                0x700c0
694 #define CURBBASE                0x700c4
695 #define CURBPOS                 0x700c8
696 #define CURCCNTR                0x700e0
697 #define CURCBASE                0x700e4
698 #define CURCPOS                 0x700e8
699
700 /*
701  * Interrupt Registers
702  */
703 #define IER 0x020a0
704 #define IIR 0x020a4
705 #define IMR 0x020a8
706 #define ISR 0x020ac
707
708 /*
709  * MOORESTOWN delta registers
710  */
711 #define MRST_DPLL_A             0x0f014
712 #define MDFLD_DPLL_B            0x0f018
713 #define MDFLD_INPUT_REF_SEL     (1 << 14) 
714 #define MDFLD_VCO_SEL           (1 << 16) 
715 #define DPLLA_MODE_LVDS         (2 << 26)       /* mrst */
716 #define MDFLD_PLL_LATCHEN       (1 << 28) 
717 #define MDFLD_PWR_GATE_EN       (1 << 30) 
718 #define MDFLD_P1_MASK           (0x1FF << 17) 
719 #define MRST_FPA0               0x0f040
720 #define MRST_FPA1               0x0f044
721 #define MDFLD_DPLL_DIV0         0x0f048
722 #define MDFLD_DPLL_DIV1         0x0f04c
723 #define MRST_PERF_MODE          0x020f4
724
725 /* MEDFIELD HDMI registers */
726 #define HDMIPHYMISCCTL          0x61134
727 # define HDMI_PHY_POWER_DOWN    0x7f
728 #define HDMIB_CONTROL           0x61140
729 # define HDMIB_PORT_EN                  (1 << 31)
730 # define HDMIB_PIPE_B_SELECT            (1 << 30)
731 # define HDMIB_NULL_PACKET              (1 << 9)
732 #define HDMIB_HDCP_PORT (1 << 5)
733 #define AUDIO_DIP_CTL           0x69060
734 #define VIDEO_DIP_CTL           0x61170
735
736 /* #define LVDS                 0x61180 */
737 # define MRST_PANEL_8TO6_DITHER_ENABLE          (1 << 25)
738 # define MRST_PANEL_24_DOT_1_FORMAT             (1 << 24)
739 # define LVDS_A3_POWER_UP_0_OUTPUT              (1 << 6)
740
741 #define MIPI                    0x61190
742 #define MIPI_C                  0x62190
743 # define MIPI_PORT_EN                   (1 << 31)
744 /** Turns on border drawing to allow centered display. */
745 # define SEL_FLOPPED_HSTX               (1 << 23)
746 # define PASS_FROM_SPHY_TO_AFE          (1 << 16)
747 # define MIPI_BORDER_EN                 (1 << 15)
748 # define MIPIA_3LANE_MIPIC_1LANE        0x1
749 # define MIPIA_2LANE_MIPIC_2LANE        0x2
750 # define TE_TRIGGER_DSI_PROTOCOL        (1 << 2)
751 # define TE_TRIGGER_GPIO_PIN            (1 << 3)
752 #define MIPI_TE_COUNT                   0x61194
753
754 /* #define PP_CONTROL   0x61204 */
755 # define POWER_DOWN_ON_RESET            (1 << 1)
756
757 /* #define PFIT_CONTROL 0x61230 */
758 # define PFIT_PIPE_SELECT                               (3 << 29)
759 # define PFIT_PIPE_SELECT_SHIFT                 (29)
760
761 /* #define BLC_PWM_CTL          0x61254 */
762 #define MRST_BACKLIGHT_MODULATION_FREQ_SHIFT            (16)
763 #define MRST_BACKLIGHT_MODULATION_FREQ_MASK             (0xffff << 16)
764
765 /* #define PIPEACONF 0x70008 */
766 #define PIPEACONF_PIPE_STATE    (1<<30)
767 /* #define DSPACNTR             0x70180 */
768 #if 0                           /*FIXME JLIU7 need to define the following */
769 1000 = 32 - bit RGBX(10 : 10 : 10 : 2)
770 pixel format.Ignore alpha.1010 = BGRX 10 : 10 : 10 : 2 1100 = 64 - bit RGBX
771 (16 : 16 : 16 : 16) 16 bit floating point pixel format.
772 Ignore alpha.1110 = 32 - bit RGBX(8 : 8 : 8 : 8) pixel format.
773     Ignore
774     alpha.
775 #endif                          /*FIXME JLIU7 need to define the following */
776
777 #define MRST_DSPABASE           0x7019c
778 #define MRST_DSPBBASE           0x7119c
779 #define MDFLD_DSPCBASE          0x7219c
780
781 /*
782  * MOORESTOWN reserved registers
783  */
784 #if 0
785 #define DSPAPOS                 0x7018C /* reserved */
786 #define DSPASIZE                0x70190
787 #endif
788 /*
789  * Moorestown registers.
790  */
791 /*===========================================================================
792 ; MIPI IP registers
793 ;--------------------------------------------------------------------------*/
794 #define MIPIC_REG_OFFSET             0x800
795 #define DEVICE_READY_REG             0xb000
796 #define LP_OUTPUT_HOLD               BIT(16)
797 #define EXIT_ULPS_DEV_READY          0x3
798 #define LP_OUTPUT_HOLD_RELEASE       0x810000
799 # define ENTERING_ULPS          (2 << 1)
800 # define EXITING_ULPS           (1 << 1)
801 # define ULPS_MASK              (3 << 1)
802 # define BUS_POSSESSION         (1 << 3)
803 #define INTR_STAT_REG                0xb004
804 #define RX_SOT_ERROR BIT(0)
805 #define RX_SOT_SYNC_ERROR BIT(1)
806 #define RX_ESCAPE_MODE_ENTRY_ERROR BIT(3)
807 #define RX_LP_TX_SYNC_ERROR BIT(4)
808 #define RX_HS_RECEIVE_TIMEOUT_ERROR BIT(5)
809 #define RX_FALSE_CONTROL_ERROR BIT(6)
810 #define RX_ECC_SINGLE_BIT_ERROR BIT(7)
811 #define RX_ECC_MULTI_BIT_ERROR BIT(8)
812 #define RX_CHECKSUM_ERROR BIT(9)
813 #define RX_DSI_DATA_TYPE_NOT_RECOGNIZED BIT(10)
814 #define RX_DSI_VC_ID_INVALID BIT(11)
815 #define TX_FALSE_CONTROL_ERROR BIT(12)
816 #define TX_ECC_SINGLE_BIT_ERROR BIT(13)
817 #define TX_ECC_MULTI_BIT_ERROR BIT(14)
818 #define TX_CHECKSUM_ERROR BIT(15)
819 #define TX_DSI_DATA_TYPE_NOT_RECOGNIZED BIT(16)
820 #define TX_DSI_VC_ID_INVALID BIT(17)
821 #define HIGH_CONTENTION BIT(18)
822 #define LOW_CONTENTION BIT(19)
823 #define DPI_FIFO_UNDER_RUN BIT(20)
824 #define HS_TX_TIMEOUT BIT(21)
825 #define LP_RX_TIMEOUT BIT(22)
826 #define TURN_AROUND_ACK_TIMEOUT BIT(23)
827 #define ACK_WITH_NO_ERROR BIT(24)
828 #define HS_GENERIC_WR_FIFO_FULL BIT(27)
829 #define LP_GENERIC_WR_FIFO_FULL BIT(28)
830 #define SPL_PKT_SENT                    BIT(30)
831 #define INTR_EN_REG                  0xb008
832 #define DSI_FUNC_PRG_REG             0xb00c
833 #define DPI_CHANNEL_NUMBER_POS   0x03
834 #define DBI_CHANNEL_NUMBER_POS   0x05
835 #define FMT_DPI_POS              0x07
836 #define FMT_DBI_POS              0x0A
837 #define DBI_DATA_WIDTH_POS       0x0D
838 /* DPI PIXEL FORMATS */
839 #define RGB_565_FMT                  0x01       /* RGB 565 FORMAT */
840 #define RGB_666_FMT                  0x02       /* RGB 666 FORMAT */
841 #define LRGB_666_FMT                 0x03       /* RGB LOOSELY PACKED
842                                                  * 666 FORMAT
843                                                  */
844 #define RGB_888_FMT                  0x04       /* RGB 888 FORMAT */
845 #define VIRTUAL_CHANNEL_NUMBER_0        0x00    /* Virtual channel 0 */
846 #define VIRTUAL_CHANNEL_NUMBER_1        0x01    /* Virtual channel 1 */
847 #define VIRTUAL_CHANNEL_NUMBER_2        0x02    /* Virtual channel 2 */
848 #define VIRTUAL_CHANNEL_NUMBER_3        0x03    /* Virtual channel 3 */
849 #define DBI_NOT_SUPPORTED               0x00    /* command mode
850                                                  * is not supported
851                                                  */
852 #define DBI_DATA_WIDTH_16BIT            0x01    /* 16 bit data */
853 #define DBI_DATA_WIDTH_9BIT                     0x02    /* 9 bit data */
854 #define DBI_DATA_WIDTH_8BIT                     0x03    /* 8 bit data */
855 #define DBI_DATA_WIDTH_OPT1             0x04    /* option 1 */
856 #define DBI_DATA_WIDTH_OPT2             0x05    /* option 2 */
857 #define HS_TX_TIMEOUT_REG            0xb010
858 #define LP_RX_TIMEOUT_REG            0xb014
859 #define TURN_AROUND_TIMEOUT_REG      0xb018
860 #define DEVICE_RESET_REG             0xb01C
861 #define DPI_RESOLUTION_REG           0xb020
862 #define RES_V_POS                0x10
863 #define DBI_RESOLUTION_REG           0xb024 /* Reserved for MDFLD */
864 #define HORIZ_SYNC_PAD_COUNT_REG     0xb028
865 #define HORIZ_BACK_PORCH_COUNT_REG   0xb02C
866 #define HORIZ_FRONT_PORCH_COUNT_REG  0xb030
867 #define HORIZ_ACTIVE_AREA_COUNT_REG  0xb034
868 #define VERT_SYNC_PAD_COUNT_REG      0xb038
869 #define VERT_BACK_PORCH_COUNT_REG    0xb03c
870 #define VERT_FRONT_PORCH_COUNT_REG   0xb040
871 #define HIGH_LOW_SWITCH_COUNT_REG    0xb044
872 #define DPI_CONTROL_REG              0xb048
873 #define DPI_SHUT_DOWN            BIT(0)
874 #define DPI_TURN_ON              BIT(1)
875 #define DPI_COLOR_MODE_ON        BIT(2)
876 #define DPI_COLOR_MODE_OFF       BIT(3)
877 #define DPI_BACK_LIGHT_ON        BIT(4)
878 #define DPI_BACK_LIGHT_OFF       BIT(5)
879 #define DPI_LP                   BIT(6)
880 #define DPI_DATA_REG                 0xb04c
881 #define DPI_BACK_LIGHT_ON_DATA   0x07
882 #define DPI_BACK_LIGHT_OFF_DATA  0x17
883 #define INIT_COUNT_REG               0xb050
884 #define MAX_RET_PAK_REG              0xb054
885 #define VIDEO_FMT_REG                0xb058
886 #define COMPLETE_LAST_PCKT       BIT(2)
887 #define EOT_DISABLE_REG              0xb05c
888 #define ENABLE_CLOCK_STOPPING    BIT(1)
889 #define LP_BYTECLK_REG               0xb060
890 #define LP_GEN_DATA_REG              0xb064
891 #define HS_GEN_DATA_REG              0xb068
892 #define LP_GEN_CTRL_REG              0xb06C
893 #define HS_GEN_CTRL_REG              0xb070
894 #define DCS_CHANNEL_NUMBER_POS   0x06
895 #define MCS_COMMANDS_POS        0x8
896 #define WORD_COUNTS_POS         0x8
897 #define MCS_PARAMETER_POS       0x10
898 #define GEN_FIFO_STAT_REG            0xb074
899 #define HS_DATA_FIFO_FULL        BIT(0)
900 #define HS_DATA_FIFO_HALF_EMPTY  BIT(1)
901 #define HS_DATA_FIFO_EMPTY       BIT(2)
902 #define LP_DATA_FIFO_FULL        BIT(8)
903 #define LP_DATA_FIFO_HALF_EMPTY  BIT(9)
904 #define LP_DATA_FIFO_EMPTY       BIT(10)
905 #define HS_CTRL_FIFO_FULL        BIT(16)
906 #define HS_CTRL_FIFO_HALF_EMPTY  BIT(17)
907 #define HS_CTRL_FIFO_EMPTY       BIT(18)
908 #define LP_CTRL_FIFO_FULL        BIT(24)
909 #define LP_CTRL_FIFO_HALF_EMPTY  BIT(25)
910 #define LP_CTRL_FIFO_EMPTY       BIT(26)
911 #define DBI_FIFO_EMPTY           BIT(27)
912 #define DPI_FIFO_EMPTY           BIT(28)
913 #define HS_LS_DBI_ENABLE_REG         0xb078
914 #define TXCLKESC_REG                 0xb07c
915 #define DPHY_PARAM_REG               0xb080
916 #define DBI_BW_CTRL_REG              0xb084
917 #define CLK_LANE_SWT_REG             0xb088
918 /*===========================================================================
919 ; MIPI Adapter registers
920 ;--------------------------------------------------------------------------*/
921 #define MIPI_CONTROL_REG             0xb104
922 #define MIPI_2X_CLOCK_BITS       (BIT(0) | BIT(1))
923 #define MIPI_DATA_ADDRESS_REG        0xb108
924 #define MIPI_DATA_LENGTH_REG         0xb10C
925 #define MIPI_COMMAND_ADDRESS_REG     0xb110
926 #define MIPI_COMMAND_LENGTH_REG      0xb114
927 #define MIPI_READ_DATA_RETURN_REG0   0xb118
928 #define MIPI_READ_DATA_RETURN_REG1   0xb11C
929 #define MIPI_READ_DATA_RETURN_REG2   0xb120
930 #define MIPI_READ_DATA_RETURN_REG3   0xb124
931 #define MIPI_READ_DATA_RETURN_REG4   0xb128
932 #define MIPI_READ_DATA_RETURN_REG5   0xb12C
933 #define MIPI_READ_DATA_RETURN_REG6   0xb130
934 #define MIPI_READ_DATA_RETURN_REG7   0xb134
935 #define MIPI_READ_DATA_VALID_REG     0xb138
936 /* DBI COMMANDS */
937 #define soft_reset                   0x01
938 /* ************************************************************************* *\
939 The display module performs a software reset.
940 Registers are written with their SW Reset default values.
941 \* ************************************************************************* */
942 #define get_power_mode               0x0a
943 /* ************************************************************************* *\
944 The display module returns the current power mode
945 \* ************************************************************************* */
946 #define get_address_mode             0x0b
947 /* ************************************************************************* *\
948 The display module returns the current status.
949 \* ************************************************************************* */
950 #define get_pixel_format             0x0c
951 /* ************************************************************************* *\
952 This command gets the pixel format for the RGB image data
953 used by the interface.
954 \* ************************************************************************* */
955 #define get_display_mode             0x0d
956 /* ************************************************************************* *\
957 The display module returns the Display Image Mode status.
958 \* ************************************************************************* */
959 #define get_signal_mode              0x0e
960 /* ************************************************************************* *\
961 The display module returns the Display Signal Mode.
962 \* ************************************************************************* */
963 #define get_diagnostic_result        0x0f
964 /* ************************************************************************* *\
965 The display module returns the self-diagnostic results following
966 a Sleep Out command.
967 \* ************************************************************************* */
968 #define enter_sleep_mode             0x10
969 /* ************************************************************************* *\
970 This command causes the display module to enter the Sleep mode.
971 In this mode, all unnecessary blocks inside the display module are disabled
972 except interface communication. This is the lowest power mode
973 the display module supports.
974 \* ************************************************************************* */
975 #define exit_sleep_mode              0x11
976 /* ************************************************************************* *\
977 This command causes the display module to exit Sleep mode.
978 All blocks inside the display module are enabled.
979 \* ************************************************************************* */
980 #define enter_partial_mode           0x12
981 /* ************************************************************************* *\
982 This command causes the display module to enter the Partial Display Mode.
983 The Partial Display Mode window is described by the set_partial_area command.
984 \* ************************************************************************* */
985 #define enter_normal_mode            0x13
986 /* ************************************************************************* *\
987 This command causes the display module to enter the Normal mode.
988 Normal Mode is defined as Partial Display mode and Scroll mode are off
989 \* ************************************************************************* */
990 #define exit_invert_mode             0x20
991 /* ************************************************************************* *\
992 This command causes the display module to stop inverting the image data on
993 the display device. The frame memory contents remain unchanged.
994 No status bits are changed.
995 \* ************************************************************************* */
996 #define enter_invert_mode            0x21
997 /* ************************************************************************* *\
998 This command causes the display module to invert the image data only on
999 the display device. The frame memory contents remain unchanged.
1000 No status bits are changed.
1001 \* ************************************************************************* */
1002 #define set_gamma_curve              0x26
1003 /* ************************************************************************* *\
1004 This command selects the desired gamma curve for the display device.
1005 Four fixed gamma curves are defined in section DCS spec.
1006 \* ************************************************************************* */
1007 #define set_display_off              0x28
1008 /* ************************************************************************* *\
1009 This command causes the display module to stop displaying the image data
1010 on the display device. The frame memory contents remain unchanged.
1011 No status bits are changed.
1012 \* ************************************************************************* */
1013 #define set_display_on               0x29
1014 /* ************************************************************************* *\
1015 This command causes the display module to start displaying the image data
1016 on the display device. The frame memory contents remain unchanged.
1017 No status bits are changed.
1018 \* ************************************************************************* */
1019 #define set_column_address           0x2a
1020 /* ************************************************************************* *\
1021 This command defines the column extent of the frame memory accessed by the
1022 hostprocessor with the read_memory_continue and write_memory_continue commands.
1023 No status bits are changed.
1024 \* ************************************************************************* */
1025 #define set_page_addr             0x2b
1026 /* ************************************************************************* *\
1027 This command defines the page extent of the frame memory accessed by the host
1028 processor with the write_memory_continue and read_memory_continue command.
1029 No status bits are changed.
1030 \* ************************************************************************* */
1031 #define write_mem_start              0x2c
1032 /* ************************************************************************* *\
1033 This command transfers image data from the host processor to the display
1034 module s frame memory starting at the pixel location specified by
1035 preceding set_column_address and set_page_address commands.
1036 \* ************************************************************************* */
1037 #define set_partial_area             0x30
1038 /* ************************************************************************* *\
1039 This command defines the Partial Display mode s display area.
1040 There are two parameters associated with
1041 this command, the first defines the Start Row (SR) and the second the End Row
1042 (ER). SR and ER refer to the Frame Memory Line Pointer.
1043 \* ************************************************************************* */
1044 #define set_scroll_area              0x33
1045 /* ************************************************************************* *\
1046 This command defines the display modules Vertical Scrolling Area.
1047 \* ************************************************************************* */
1048 #define set_tear_off                 0x34
1049 /* ************************************************************************* *\
1050 This command turns off the display modules Tearing Effect output signal on
1051 the TE signal line.
1052 \* ************************************************************************* */
1053 #define set_tear_on                  0x35
1054 /* ************************************************************************* *\
1055 This command turns on the display modules Tearing Effect output signal
1056 on the TE signal line.
1057 \* ************************************************************************* */
1058 #define set_address_mode             0x36
1059 /* ************************************************************************* *\
1060 This command sets the data order for transfers from the host processor to
1061 display modules frame memory,bits B[7:5] and B3, and from the display
1062 modules frame memory to the display device, bits B[2:0] and B4.
1063 \* ************************************************************************* */
1064 #define set_scroll_start             0x37
1065 /* ************************************************************************* *\
1066 This command sets the start of the vertical scrolling area in the frame memory.
1067 The vertical scrolling area is fully defined when this command is used with
1068 the set_scroll_area command The set_scroll_start command has one parameter,
1069 the Vertical Scroll Pointer. The VSP defines the line in the frame memory
1070 that is written to the display device as the first line of the vertical
1071 scroll area.
1072 \* ************************************************************************* */
1073 #define exit_idle_mode               0x38
1074 /* ************************************************************************* *\
1075 This command causes the display module to exit Idle mode.
1076 \* ************************************************************************* */
1077 #define enter_idle_mode              0x39
1078 /* ************************************************************************* *\
1079 This command causes the display module to enter Idle Mode.
1080 In Idle Mode, color expression is reduced. Colors are shown on the display
1081 device using the MSB of each of the R, G and B color components in the frame
1082 memory
1083 \* ************************************************************************* */
1084 #define set_pixel_format             0x3a
1085 /* ************************************************************************* *\
1086 This command sets the pixel format for the RGB image data used by the interface.
1087 Bits D[6:4]  DPI Pixel Format Definition
1088 Bits D[2:0]  DBI Pixel Format Definition
1089 Bits D7 and D3 are not used.
1090 \* ************************************************************************* */
1091   #define DCS_PIXEL_FORMAT_3bbp         0x1
1092   #define DCS_PIXEL_FORMAT_8bbp         0x2
1093   #define DCS_PIXEL_FORMAT_12bbp        0x3
1094   #define DCS_PIXEL_FORMAT_16bbp        0x5 
1095   #define DCS_PIXEL_FORMAT_18bbp        0x6 
1096   #define DCS_PIXEL_FORMAT_24bbp        0x7
1097 #define write_mem_cont               0x3c
1098 /* ************************************************************************* *\
1099 This command transfers image data from the host processor to the display
1100 module's frame memory continuing from the pixel location following the
1101 previous write_memory_continue or write_memory_start command.
1102 \* ************************************************************************* */
1103 #define set_tear_scanline            0x44
1104 /* ************************************************************************* *\
1105 This command turns on the display modules Tearing Effect output signal on the
1106 TE signal line when the display module reaches line N.
1107 \* ************************************************************************* */
1108 #define get_scanline                 0x45
1109 /* ************************************************************************* *\
1110 The display module returns the current scanline, N, used to update the
1111 display device. The total number of scanlines on a display device is
1112 defined as VSYNC + VBP + VACT + VFP.The first scanline is defined as
1113 the first line of V Sync and is denoted as Line 0.
1114 When in Sleep Mode, the value returned by get_scanline is undefined.
1115 \* ************************************************************************* */
1116
1117 /* MCS or Generic COMMANDS */
1118 /* MCS/generic data type */
1119 #define GEN_SHORT_WRITE_0       0x03  /* generic short write, no parameters */
1120 #define GEN_SHORT_WRITE_1       0x13  /* generic short write, 1 parameters */
1121 #define GEN_SHORT_WRITE_2       0x23  /* generic short write, 2 parameters */
1122 #define GEN_READ_0              0x04  /* generic read, no parameters */
1123 #define GEN_READ_1              0x14  /* generic read, 1 parameters */
1124 #define GEN_READ_2              0x24  /* generic read, 2 parameters */
1125 #define GEN_LONG_WRITE          0x29  /* generic long write */
1126 #define MCS_SHORT_WRITE_0       0x05  /* MCS short write, no parameters */
1127 #define MCS_SHORT_WRITE_1       0x15  /* MCS short write, 1 parameters */
1128 #define MCS_READ                0x06  /* MCS read, no parameters */
1129 #define MCS_LONG_WRITE          0x39  /* MCS long write */
1130 /* MCS/generic commands */
1131 /*****TPO MCS**********/
1132 #define write_display_profile           0x50
1133 #define write_display_brightness        0x51
1134 #define write_ctrl_display              0x53
1135 #define write_ctrl_cabc                 0x55
1136   #define UI_IMAGE              0x01
1137   #define STILL_IMAGE           0x02
1138   #define MOVING_IMAGE          0x03
1139 #define write_hysteresis                0x57
1140 #define write_gamma_setting             0x58
1141 #define write_cabc_min_bright           0x5e
1142 #define write_kbbc_profile              0x60
1143 /*****TMD MCS**************/
1144 #define tmd_write_display_brightness 0x8c
1145
1146 /* ************************************************************************* *\
1147 This command is used to control ambient light, panel backlight brightness and
1148 gamma settings.
1149 \* ************************************************************************* */
1150 #define BRIGHT_CNTL_BLOCK_ON    BIT(5)
1151 #define AMBIENT_LIGHT_SENSE_ON  BIT(4)
1152 #define DISPLAY_DIMMING_ON      BIT(3)
1153 #define BACKLIGHT_ON            BIT(2)
1154 #define DISPLAY_BRIGHTNESS_AUTO BIT(1)
1155 #define GAMMA_AUTO              BIT(0)
1156
1157 /* DCS Interface Pixel Formats */
1158 #define DCS_PIXEL_FORMAT_3BPP         0x1
1159 #define DCS_PIXEL_FORMAT_8BPP         0x2
1160 #define DCS_PIXEL_FORMAT_12BPP        0x3
1161 #define DCS_PIXEL_FORMAT_16BPP        0x5
1162 #define DCS_PIXEL_FORMAT_18BPP        0x6
1163 #define DCS_PIXEL_FORMAT_24BPP        0x7
1164 /* ONE PARAMETER READ DATA */
1165 #define addr_mode_data           0xfc
1166 #define diag_res_data            0x00
1167 #define disp_mode_data           0x23
1168 #define pxl_fmt_data             0x77
1169 #define pwr_mode_data            0x74
1170 #define sig_mode_data            0x00
1171 /* TWO PARAMETERS READ DATA */
1172 #define scanline_data1           0xff
1173 #define scanline_data2           0xff
1174 #define NON_BURST_MODE_SYNC_PULSE       0x01    /* Non Burst Mode
1175                                                  * with Sync Pulse
1176                                                  */
1177 #define NON_BURST_MODE_SYNC_EVENTS      0x02    /* Non Burst Mode
1178                                                  * with Sync events
1179                                                  */
1180 #define BURST_MODE                      0x03    /* Burst Mode */
1181 #define DBI_COMMAND_BUFFER_SIZE         0x240  /* 0x32 */    /* 0x120 */        /* Allocate at least
1182                                                  * 0x100 Byte with 32
1183                                                  * byte alignment
1184                                                  */
1185 #define DBI_DATA_BUFFER_SIZE            0x120   /* Allocate at least
1186                                                  * 0x100 Byte with 32
1187                                                  * byte alignment
1188                                                  */
1189 #define DBI_CB_TIME_OUT 0xFFFF
1190 #define GEN_FB_TIME_OUT 2000 
1191 #define ALIGNMENT_32BYTE_MASK           (~(BIT(0)|BIT(1)|BIT(2)|BIT(3)|BIT(4)))
1192 #define SKU_83                                          0x01
1193 #define SKU_100                                         0x02
1194 #define SKU_100L                                        0x04
1195 #define SKU_BYPASS                                      0x08
1196 #if 0
1197 /* ************************************************************************* *\
1198 DSI command data structure
1199 \* ************************************************************************* */
1200 union DSI_LONG_PACKET_HEADER {
1201         u32 DSI_longPacketHeader;
1202         struct {
1203                 u8 dataID;
1204                 u16 wordCount;
1205                 u8 ECC;
1206         };
1207 #if 0                           /*FIXME JLIU7 */
1208         struct {
1209                 u8 DT:6;
1210                 u8 VC:2;
1211         };
1212 #endif                          /*FIXME JLIU7 */
1213 };
1214
1215 union MIPI_ADPT_CMD_LNG_REG {
1216         u32 commnadLengthReg;
1217         struct {
1218                 u8 command0;
1219                 u8 command1;
1220                 u8 command2;
1221                 u8 command3;
1222         };
1223 };
1224
1225 struct SET_COLUMN_ADDRESS_DATA {
1226         u8 command;
1227         u16 SC;                 /* Start Column */
1228         u16 EC;                 /* End Column */
1229 };
1230
1231 struct SET_PAGE_ADDRESS_DATA {
1232         u8 command;
1233         u16 SP;                 /* Start Page */
1234         u16 EP;                 /* End Page */
1235 };
1236 #endif
1237
1238 #endif