rk610 : lvds bias power ctl
[firefly-linux-kernel-4.4.55.git] / drivers / video / display / lcd / rk610_lcd.h
1 #ifndef _RK610_LCD_H\r
2 #define _RK610_LCD_H\r
3 #include "../screen/screen.h"\r
4 #define ENABLE      1\r
5 #define DISABLE     0\r
6 /*      LVDS config         */\r
7 /*                  LVDS ÍⲿÁ¬Ïß½Ó·¨                       */\r
8 /*          LVDS_8BIT_1    LVDS_8BIT_2     LVDS_8BIT_3     LVDS_6BIT\r
9 ----------------------------------------------------------------------\r
10     TX0     R0              R2              R2              R0\r
11     TX1     R1              R3              R3              R1\r
12     TX2     R2              R4              R4              R2\r
13 Y   TX3     R3              R5              R5              R3\r
14 0   TX4     R4              R6              R6              R4\r
15     TX6     R5              R7              R7              R5\r
16     TX7     G0              G2              G2              G0\r
17 ----------------------------------------------------------------------\r
18     TX8     G1              G3              G3              G1\r
19     TX9     G2              G4              G4              G2\r
20 Y   TX12    G3              G5              G5              G3\r
21 1   TX13    G4              G6              G6              G4\r
22     TX14    G5              G7              G7              G5\r
23     TX15    B0              B2              B2              B0\r
24     TX18    B1              B3              B3              B1\r
25 ----------------------------------------------------------------------\r
26     TX19    B2              B4              B4              B2\r
27     TX20    B3              B5              B5              B3\r
28     TX21    B4              B6              B6              B4\r
29 Y   TX22    B5              B7              B7              B5\r
30 2   TX24    HSYNC           HSYNC           HSYNC           HSYNC\r
31     TX25    VSYNC           VSYNC           VSYNC           VSYNC\r
32     TX26    ENABLE          ENABLE          ENABLE          ENABLE\r
33 ----------------------------------------------------------------------    \r
34     TX27    R6              R0              GND             GND\r
35     TX5     R7              R1              GND             GND\r
36     TX10    G6              G0              GND             GND\r
37 Y   TX11    G7              G1              GND             GND\r
38 3   TX16    B6              B0              GND             GND\r
39     TX17    B7              B1              GND             GND\r
40     TX23    RSVD            RSVD            RSVD            RSVD\r
41 ----------------------------------------------------------------------        \r
42 */\r
43 #define LVDS_8BIT_1     0x00\r
44 #define LVDS_8BIT_2     0x01\r
45 #define LVDS_8BIT_3     0x10\r
46 #define LVDS_6BIT       0x11\r
47 //LVDS lane input format\r
48 #define DATA_D0_MSB         0\r
49 #define DATA_D7_MSB         1\r
50 //LVDS input source\r
51 #define FROM_LCD1           0\r
52 #define FROM_LCD0_OR_SCL    1\r
53 \r
54 /*      LCD1 config         */\r
55 #define LCD1_AS_IN      0\r
56 #define LCD1_AS_OUT     1\r
57 \r
58 //LCD1 output source\r
59 #define LCD1_FROM_LCD0  0\r
60 #define LCD1_FROM_SCL   1\r
61 \r
62 /*      clock config        */\r
63 #define S_PLL_FROM_DIV      0\r
64 #define S_PLL_FROM_CLKIN    1\r
65 #define S_PLL_DIV(x)        ((x)&0x7)\r
66 /*********S_PLL_CON************/\r
67 //S_PLL_CON0\r
68 #define S_DIV_N(x)              (((x)&0xf)<<4)\r
69 #define S_DIV_OD(x)             (((x)&3)<<0)\r
70 //S_PLL_CON1\r
71 #define S_DIV_M(x)              ((x)&0xff)\r
72 //S_PLL_CON2\r
73 #define S_PLL_UNLOCK            (0<<7)    //0:unlock 1:pll_lock\r
74 #define S_PLL_LOCK              (1<<7)    //0:unlock 1:pll_lock\r
75 #define S_PLL_PWR(x)            (((x)&1)<<2)    //0:POWER UP 1:POWER DOWN\r
76 #define S_PLL_RESET(x)          (((x)&1)<<1)    //0:normal  1:reset M/N dividers\r
77 #define S_PLL_BYPASS(x)          (((x)&1)<<0)    //0:normal  1:bypass\r
78 //LVDS_CON0\r
79 #define LVDS_OUT_CLK_PIN(x)     (((x)&1)<<7)    //clk enable pin, 0: enable\r
80 #define LVDS_OUT_CLK_PWR_PIN(x) (((x)&1)<<6)    //clk pwr enable pin, 1: enable \r
81 #define LVDS_PLL_PWR_PIN(x)     (((x)&1)<<5)    //pll pwr enable pin, 0:enable \r
82 #define LVDS_BIASE_PWR(x)       (((x)&1)<<4)    //0: power down     1: normal work\r
83 #define LVDS_LANE_IN_FORMAT(x)  (((x)&1)<<3)    //0: msb on D0  1:msb on D7\r
84 #define LVDS_INPUT_SOURCE(x)    (((x)&1)<<2)    //0: from lcd1  1:from lcd0 or scaler\r
85 #define LVDS_OUTPUT_FORMAT(x)   (((x)&3)<<0)    //00:8bit format-1  01:8bit format-2  10:8bit format-3   11:6bit format  \r
86 //LVDS_CON1\r
87 #define LVDS_OUT_ENABLE(x)      (((x)&0xf)<<4)  //0:output enable 1:output disable\r
88 #define LVDS_TX_PWR_ENABLE(x)   (((x)&0xf)<<0)  //0:working mode  1:power down\r
89 //LCD1_CON\r
90 #define LCD1_OUT_ENABLE(x)      (((x)&1)<<1)    //0:lcd1 as input 1:lcd1 as output\r
91 #define LCD1_OUT_SRC(x)         (((x)&1)<<0)    //0:from lcd0   1:from scaler\r
92 //SCL_CON0\r
93 #define SCL_BYPASS(x)           (((x)&1)<<4)    //0:not bypass  1:bypass\r
94 #define SCL_DEN_INV(x)          (((x)&1)<<3)    //scl_den_inv\r
95 #define SCL_H_V_SYNC_INV(x)     (((x)&1)<<2)    //scl_sync_inv\r
96 #define SCL_OUT_CLK_INV(x)      (((x)&1)<<1)    //scl_dclk_inv\r
97 #define SCL_ENABLE(x)           (((x)&1)<<0)    //scaler enable\r
98 //SCL_CON1\r
99 #define SCL_H_FACTOR_LSB(x)     ((x)&0xff)      //scl_h_factor[7:0]\r
100 //SCL_CON2\r
101 #define SCL_H_FACTOR_MSB(x)     (((x)>>8)&0x3f)      //scl_h_factor[13:8]\r
102 //SCL_CON3\r
103 #define SCL_V_FACTOR_LSB(x)     ((x)&0xff)      //scl_v_factor[7:0]\r
104 //SCL_CON4\r
105 #define SCL_V_FACTOR_MSB(x)     (((x)>>8)&0x3f)      //scl_v_factor[13:8]\r
106 //SCL_CON5\r
107 #define SCL_DSP_HST_LSB(x)      ((x)&0xff)      //dsp_frame_hst[7:0]\r
108 //SCL_CON6\r
109 #define SCL_DSP_HST_MSB(x)      (((x)>>8)&0xf)       //dsp_frame_hst[11:8]\r
110 //SCL_CON7\r
111 #define SCL_DSP_VST_LSB(x)      ((x)&0xff)      //dsp_frame_vst[7:0]\r
112 //SCL_CON8\r
113 #define SCL_DSP_VST_MSB(x)      (((x)>>8)&0xf)       //dsp_frame_vst[11:8]\r
114 //SCL_CON9\r
115 #define SCL_DSP_HTOTAL_LSB(x)   ((x)&0xff)      //dsp_frame_htotal[7:0]\r
116 //SCL_CON10\r
117 #define SCL_DSP_HTOTAL_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_htotal[11:8]\r
118 //SCL_CON11\r
119 #define SCL_DSP_HS_END(x)       ((x)&0xff)      //dsp_hs_end\r
120 //SCL_CON12\r
121 #define SCL_DSP_HACT_ST_LSB(x)      ((x)&0xff)      //dsp_hact_st[7:0]\r
122 //SCL_CON13\r
123 #define SCL_DSP_HACT_ST_MSB(x)      (((x)>>8)&0x3)      //dsp_hact_st[9:8]\r
124 //SCL_CON14\r
125 #define SCL_DSP_HACT_END_LSB(x)   ((x)&0xff)      //dsp_hact_end[7:0]\r
126 //SCL_CON15\r
127 #define SCL_DSP_HACT_END_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_htotal[11:8]\r
128 //SCL_CON16\r
129 #define SCL_DSP_VTOTAL_LSB(x)   ((x)&0xff)      //dsp_frame_vtotal[7:0]\r
130 //SCL_CON17\r
131 #define SCL_DSP_VTOTAL_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_vtotal[11:8]\r
132 //SCL_CON18\r
133 #define SCL_DSP_VS_END(x)       ((x)&0xff)      //dsp_vs_end\r
134 //SCL_CON19\r
135 #define SCL_DSP_VACT_ST(x)      ((x)&0xff)      //dsp_vact_st[7:0]\r
136 //SCL_CON20\r
137 #define SCL_DSP_VACT_END_LSB(x)   ((x)&0xff)      //dsp_vact_end[7:0]\r
138 //SCL_CON21\r
139 #define SCL_DSP_VACT_END_MSB(x)   (((x)>>8)&0xf)       //dsp_frame_vtotal[11:8]\r
140 //SCL_CON22\r
141 #define SCL_H_BORD_ST_LSB(x)        ((x)&0xff)      //dsp_hbord_st[7:0]\r
142 //SCL_CON23\r
143 #define SCL_H_BORD_ST_MSB(x)        (((x)>>8)&0x3)      //dsp_hbord_st[9:8]\r
144 //SCL_CON24\r
145 #define SCL_H_BORD_END_LSB(x)        ((x)&0xff)      //dsp_hbord_end[7:0]\r
146 //SCL_CON25\r
147 #define SCL_H_BORD_END_MSB(x)        (((x)>>8)&0xf)      //dsp_hbord_end[11:8]\r
148 //SCL_CON26\r
149 #define SCL_V_BORD_ST(x)            ((x)&0xff)      //dsp_vbord_st[7:0]\r
150 //SCL_CON27\r
151 #define SCL_V_BORD_END_LSB(x)              ((x)&0xff)      //dsp_vbord_end[7:0]\r
152 //SCL_CON25\r
153 #define SCL_V_BORD_END_MSB(x)        (((x)>>8)&0xf)      //dsp_vbord_end[11:8]\r
154 #if 0\r
155 /****************LCD STRUCT********/\r
156 #define PLL_CLKOD(i)    ((i) & 0x03)\r
157 #define PLL_NO_1        PLL_CLKOD(0)
158 #define PLL_NO_2        PLL_CLKOD(1)
159 #define PLL_NO_4        PLL_CLKOD(2)
160 #define PLL_NO_8        PLL_CLKOD(3)\r
161 #define SCALE_PLL(_parent_rate , _rate, _m, _n, _od) \\r
162 { \
163         .parent_rate    = _parent_rate, \\r
164         .rate           = _rate,          \\r
165         .m                  = _m,            \\r
166         .n                  = _n,            \\r
167         .od             = _od,         \\r
168 }\r
169 #endif\r
170 struct rk610_pll_info{\r
171     u32 parent_rate;\r
172     u32 rate;\r
173     int m;\r
174     int n;\r
175     int od;\r
176 };\r
177 struct lcd_mode_inf{\r
178         int h_pw;\r
179         int h_bp;\r
180         int h_vd;\r
181         int h_fp;\r
182         int v_pw;\r
183         int v_bp;\r
184         int v_vd;\r
185         int v_fp;\r
186         int f_hst;\r
187         int f_vst;\r
188     struct rk610_pll_info pllclk;\r
189 };\r
190 struct scl_hv_info{\r
191     int scl_h ;\r
192     int scl_v;\r
193     };\r
194 struct rk610_lcd_info{\r
195     int enable;\r
196     struct scl_hv_info scl;\r
197     struct lcd_mode_inf *lcd_mode;\r
198 };\r
199 extern int rk610_lcd_init(struct i2c_client *client);\r
200 extern int rk610_lcd_scaler_set_param(struct rk29fb_screen *screen,bool enable );\r
201 #endif\r