3 #include <linux/mfd/rk610_core.h>
4 #include <linux/earlysuspend.h>
8 //LVDS lane input format
13 #define FROM_LCD0_OR_SCL 1
20 #define LCD1_FROM_LCD0 0
21 #define LCD1_FROM_SCL 1
28 #define S_PLL_PWR_ON 0
29 #define S_PLL_PWR_DOWN 1
32 #define S_PLL_FROM_DIV 0
33 #define S_PLL_FROM_CLKIN 1
34 #define S_PLL_DIV(x) ((x)&0x7)
35 /*********S_PLL_CON************/
37 #define S_DIV_N(x) (((x)&0xf)<<4)
38 #define S_DIV_OD(x) (((x)&3)<<0)
40 #define S_DIV_M(x) ((x)&0xff)
42 #define S_PLL_UNLOCK (0<<7) //0:unlock 1:pll_lock
43 #define S_PLL_LOCK (1<<7) //0:unlock 1:pll_lock
44 #define S_PLL_PWR(x) (((x)&1)<<2) //0:POWER UP 1:POWER DOWN
45 #define S_PLL_RESET(x) (((x)&1)<<1) //0:normal 1:reset M/N dividers
46 #define S_PLL_BYPASS(x) (((x)&1)<<0) //0:normal 1:bypass
48 #define LVDS_OUT_CLK_PIN(x) (((x)&1)<<7) //clk enable pin, 0: enable
49 #define LVDS_OUT_CLK_PWR_PIN(x) (((x)&1)<<6) //clk pwr enable pin, 1: enable
50 #define LVDS_PLL_PWR_PIN(x) (((x)&1)<<5) //pll pwr enable pin, 0:enable
51 #define LVDS_BIASE_PWR(x) (((x)&1)<<4) //0: power down 1: normal work
52 #define LVDS_LANE_IN_FORMAT(x) (((x)&1)<<3) //0: msb on D0 1:msb on D7
53 #define LVDS_INPUT_SOURCE(x) (((x)&1)<<2) //0: from lcd1 1:from lcd0 or scaler
54 #define LVDS_OUTPUT_FORMAT(x) (((x)&3)<<0) //00:8bit format-1 01:8bit format-2 10:8bit format-3 11:6bit format
56 #define LVDS_OUT_ENABLE(x) (((x)&0xf)<<4) //0:output enable 1:output disable
57 #define LVDS_TX_PWR_ENABLE(x) (((x)&0xf)<<0) //0:working mode 1:power down
59 #define LCD1_OUT_ENABLE(x) (((x)&1)<<1) //0:lcd1 as input 1:lcd1 as output
60 #define LCD1_OUT_SRC(x) (((x)&1)<<0) //0:from lcd0 1:from scaler
62 #define SCL_BYPASS(x) (((x)&1)<<4) //0:not bypass 1:bypass
63 #define SCL_DEN_INV(x) (((x)&1)<<3) //scl_den_inv
64 #define SCL_H_V_SYNC_INV(x) (((x)&1)<<2) //scl_sync_inv
65 #define SCL_OUT_CLK_INV(x) (((x)&1)<<1) //scl_dclk_inv
66 #define SCL_ENABLE(x) (((x)&1)<<0) //scaler enable
68 #define SCL_H_FACTOR_LSB(x) ((x)&0xff) //scl_h_factor[7:0]
70 #define SCL_H_FACTOR_MSB(x) (((x)>>8)&0x3f) //scl_h_factor[13:8]
72 #define SCL_V_FACTOR_LSB(x) ((x)&0xff) //scl_v_factor[7:0]
74 #define SCL_V_FACTOR_MSB(x) (((x)>>8)&0x3f) //scl_v_factor[13:8]
76 #define SCL_DSP_HST_LSB(x) ((x)&0xff) //dsp_frame_hst[7:0]
78 #define SCL_DSP_HST_MSB(x) (((x)>>8)&0xf) //dsp_frame_hst[11:8]
80 #define SCL_DSP_VST_LSB(x) ((x)&0xff) //dsp_frame_vst[7:0]
82 #define SCL_DSP_VST_MSB(x) (((x)>>8)&0xf) //dsp_frame_vst[11:8]
84 #define SCL_DSP_HTOTAL_LSB(x) ((x)&0xff) //dsp_frame_htotal[7:0]
86 #define SCL_DSP_HTOTAL_MSB(x) (((x)>>8)&0xf) //dsp_frame_htotal[11:8]
88 #define SCL_DSP_HS_END(x) ((x)&0xff) //dsp_hs_end
90 #define SCL_DSP_HACT_ST_LSB(x) ((x)&0xff) //dsp_hact_st[7:0]
92 #define SCL_DSP_HACT_ST_MSB(x) (((x)>>8)&0x3) //dsp_hact_st[9:8]
94 #define SCL_DSP_HACT_END_LSB(x) ((x)&0xff) //dsp_hact_end[7:0]
96 #define SCL_DSP_HACT_END_MSB(x) (((x)>>8)&0xf) //dsp_frame_htotal[11:8]
98 #define SCL_DSP_VTOTAL_LSB(x) ((x)&0xff) //dsp_frame_vtotal[7:0]
100 #define SCL_DSP_VTOTAL_MSB(x) (((x)>>8)&0xf) //dsp_frame_vtotal[11:8]
102 #define SCL_DSP_VS_END(x) ((x)&0xff) //dsp_vs_end
104 #define SCL_DSP_VACT_ST(x) ((x)&0xff) //dsp_vact_st[7:0]
106 #define SCL_DSP_VACT_END_LSB(x) ((x)&0xff) //dsp_vact_end[7:0]
108 #define SCL_DSP_VACT_END_MSB(x) (((x)>>8)&0xf) //dsp_frame_vtotal[11:8]
110 #define SCL_H_BORD_ST_LSB(x) ((x)&0xff) //dsp_hbord_st[7:0]
112 #define SCL_H_BORD_ST_MSB(x) (((x)>>8)&0x3) //dsp_hbord_st[9:8]
114 #define SCL_H_BORD_END_LSB(x) ((x)&0xff) //dsp_hbord_end[7:0]
116 #define SCL_H_BORD_END_MSB(x) (((x)>>8)&0xf) //dsp_hbord_end[11:8]
118 #define SCL_V_BORD_ST(x) ((x)&0xff) //dsp_vbord_st[7:0]
120 #define SCL_V_BORD_END_LSB(x) ((x)&0xff) //dsp_vbord_end[7:0]
122 #define SCL_V_BORD_END_MSB(x) (((x)>>8)&0xf) //dsp_vbord_end[11:8]
124 /* Scaler PLL CONFIG */
129 #define S_PLL_M(x) (((x)&0xff)<<8)
130 #define S_PLL_N(x) (((x)&0xf)<<4)
131 #define S_PLL_NO(x) ((S_PLL_NO_##x)&0x3)
138 /* Scaler clk setting */
139 #define SCALE_PLL(_parent_rate,_rate,_m,_n,_no) \
140 HDMI_RATE_ ## _parent_rate ##_S_RATE_ ## _rate \
141 = S_PLL_M(_m) | S_PLL_N(_n) | S_PLL_NO(_no)
142 #define SCALE_RATE(_parent_rate , _rate) \
143 (HDMI_RATE_ ## _parent_rate ## _S_RATE_ ## _rate)
146 SCALE_PLL(148500000, 66000000, 16, 9, 4),
147 SCALE_PLL(148500000, 57375000, 17, 11, 4),
148 SCALE_PLL(148500000, 54000000, 16, 11, 4),
149 SCALE_PLL(148500000, 33000000, 16, 9, 8),
150 SCALE_PLL(148500000, 30375000, 18, 11, 8),
151 SCALE_PLL(148500000, 29700000, 16, 10, 8),
152 SCALE_PLL(148500000, 25312500, 15, 11, 8),
153 SCALE_PLL(148500000, 74250000, 12, 6, 4),
154 SCALE_PLL(148500000, 50625000, 15, 11, 4),
155 SCALE_PLL(148500000, 79199997, 32, 15, 4),
156 SCALE_PLL(148500000, 45375000, 22, 9, 8),
158 SCALE_PLL(74250000, 66000000, 32, 9, 4),
159 SCALE_PLL(74250000, 57375000, 34, 11, 4),
160 SCALE_PLL(74250000, 54000000, 32, 11, 4),
161 SCALE_PLL(74250000, 33000000, 32, 9, 8),
162 SCALE_PLL(74250000, 30375000, 36, 11, 8),
163 SCALE_PLL(74250000, 25312500, 30, 11, 8),
164 SCALE_PLL(74250000, 74250000, 12, 3, 4),
165 SCALE_PLL(74250000, 67500000, 40, 11, 4),
166 SCALE_PLL(74250000, 50625000, 30, 11, 4),
167 SCALE_PLL(74250000, 79199997, 64,15,4),
168 SCALE_PLL(74250000, 44343750, 43, 9, 8),
170 SCALE_PLL(27000000, 75000000, 100, 9, 4),
171 SCALE_PLL(27000000, 72000000, 32, 3, 4),
172 SCALE_PLL(27000000, 63281250, 75, 4, 8),
173 SCALE_PLL(27000000, 60000000, 80, 9, 4),
174 SCALE_PLL(27000000, 54375000, 145, 9, 8),
175 SCALE_PLL(27000000, 31500000, 28, 3, 8),
176 SCALE_PLL(27000000, 30000000, 80, 9, 8),
177 SCALE_PLL(27000000, 70312500, 125, 6, 8),
178 SCALE_PLL(27000000, 46875000, 125, 9, 8),
179 SCALE_PLL(27000000, 56250000, 25, 3, 4)
187 struct rk610_pll_info{
205 struct rk610_pll_info pllclk;
215 struct scl_hv_info scl_hv;
217 struct rk610_lcd_info{
220 struct rk_screen *screen;
221 struct scl_info scl_inf;
222 struct i2c_client *client;
224 #ifdef CONFIG_HAS_EARLYSUSPEND
225 struct early_suspend early_suspend;
228 extern int rk610_lcd_init(struct rk610_core_info *rk610_core_info);
229 extern int rk610_lcd_scaler_set_param(struct rk_screen *screen,bool enable );