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