2 #include <linux/string.h>
5 #include <platform/mt_gpio.h>
6 #include <platform/mt_pmic.h>
8 #include <platform/upmu_common.h>
10 #elif (defined BUILD_UBOOT)
11 #include <asm/arch/mt6577_gpio.h>
13 #include <mach/mt_gpio.h>
14 #include <linux/xlog.h>
15 #include <mach/mt_pm_ldo.h>
18 #include "mt8193_lvds.h"
20 // ---------------------------------------------------------------------------
22 // ---------------------------------------------------------------------------
24 #if defined(MTK_ALPS_BOX_SUPPORT)
25 /*for 8127 box hdmi main path */
26 #define FRAME_WIDTH (1920)
27 #define FRAME_HEIGHT (1080)
29 #define FRAME_WIDTH (800)
30 #define FRAME_HEIGHT (1280)
33 //#define GPIO_LCD_RST_EN GPIO90
34 //#define GPIO_LCD_STB_EN GPIO89
38 #define GPIO_LCD_PWR GPIO_LCM_PWR
40 #define GPIO_LCD_PWR 0xFFFFFFFF
43 #ifdef GPIO_LCM_PWR_EN
44 #define GPIO_LCD_PWR_EN GPIO_LCM_PWR_EN
46 #define GPIO_LCD_PWR_EN 0xFFFFFFFF
49 #ifdef GPIO_LCM_PWR2_EN
50 #define GPIO_LCD_PWR2_EN GPIO_LCM_PWR2_EN
52 #define GPIO_LCD_PWR2_EN 0xFFFFFFFF
57 #define GPIO_LCD_RST_EN GPIO_LCM_RST
59 #define GPIO_LCD_RST_EN 0xFFFFFFFF
63 #define GPIO_LCD_STB_EN GPIO_LCM_STB
65 #define GPIO_LCD_STB_EN 0xFFFFFFFF
69 #ifdef GPIO_LCM_LVL_SHIFT_EN
70 #define GPIO_SHIFT_EN GPIO_LCM_LVL_SHIFT_EN
72 #define GPIO_SHIFT_EN 0xFFFFFFFF
76 #define GPIO_LCD_BL_EN GPIO_LCM_BL_EN
78 #define GPIO_LCD_BL_EN 0xFFFFFFFF
82 #ifdef GPIO_LCM_BRIDGE_EN
83 #define GPIO_LCD_BRIDGE_EN GPIO_LCM_BRIDGE_EN
85 #define GPIO_LCD_BRIDGE_EN 0xFFFFFFFF
90 #define HSYNC_PULSE_WIDTH 16
91 #define HSYNC_BACK_PORCH 16
92 #define HSYNC_FRONT_PORCH 32
93 #define VSYNC_PULSE_WIDTH 2
94 #define VSYNC_BACK_PORCH 2
95 #define VSYNC_FRONT_PORCH 4
98 // ---------------------------------------------------------------------------
100 // ---------------------------------------------------------------------------
102 static LCM_UTIL_FUNCS lcm_util
= {0};
104 #define SET_RESET_PIN(v) (mt_set_reset_pin((v)))
110 // ---------------------------------------------------------------------------
112 // ---------------------------------------------------------------------------
114 static __inline
void send_ctrl_cmd(unsigned int cmd
)
119 static __inline
void send_data_cmd(unsigned int data
)
124 static __inline
void set_lcm_register(unsigned int regIndex
,
125 unsigned int regData
)
131 static void lcm_set_gpio_output(unsigned int GPIO
, unsigned int output
)
134 if(GPIO
== 0xFFFFFFFF)
137 printf("[LK/LCM] GPIO_LCD_PWR = 0x%x \n",GPIO_LCD_PWR
);
138 printf("[LK/LCM] GPIO_LCD_PWR_EN = 0x%x\n",GPIO_LCD_PWR_EN
);
139 printf("[LK/LCM] GPIO_LCD_PWR2_EN = 0x%x \n",GPIO_LCD_PWR2_EN
);
140 printf("[LK/LCM] GPIO_LCD_RST_EN = 0x%x \n",GPIO_LCD_RST_EN
);
141 printf("[LK/LCM] GPIO_LCD_STB_EN = 0x%x\n",GPIO_LCD_STB_EN
);
142 printf("[LK/LCM] GPIO_SHIFT_EN = 0x%x\n",GPIO_SHIFT_EN
);
143 printf("[LK/LCM] GPIO_LCD_BL_EN = 0x%x\n",GPIO_LCD_BL_EN
);
144 printf("[LK/LCM] GPIO_LCD_BRIDGE_EN = 0x%x \n",GPIO_LCD_BRIDGE_EN
);
146 #elif (defined BUILD_UBOOT)
147 // do nothing in uboot
149 //printf("kernel] lcm_set gpio() \n");
154 mt_set_gpio_mode(GPIO
, GPIO_MODE_00
);
155 mt_set_gpio_dir(GPIO
, GPIO_DIR_OUT
);
156 mt_set_gpio_out(GPIO
, (output
>0)? GPIO_OUT_ONE
: GPIO_OUT_ZERO
);
160 // ---------------------------------------------------------------------------
161 // LCM Driver Implementations
162 // ---------------------------------------------------------------------------
164 static void lcm_set_util_funcs(const LCM_UTIL_FUNCS
*util
)
166 memcpy(&lcm_util
, util
, sizeof(LCM_UTIL_FUNCS
));
169 static void lcm_get_params(LCM_PARAMS
*params
)
171 memset(params
, 0, sizeof(LCM_PARAMS
));
173 params
->type
= LCM_TYPE_DPI
;
174 params
->ctrl
= LCM_CTRL_SERIAL_DBI
;
175 params
->width
= FRAME_WIDTH
;
176 params
->height
= FRAME_HEIGHT
;
177 params
->io_select_mode
= 0;
179 params
->dpi
.PLL_CLOCK
= 67; //67MHz
182 /* RGB interface configurations */
183 params
->dpi
.mipi_pll_clk_ref
= 0;
184 params
->dpi
.mipi_pll_clk_div1
= 0x80000101; //lvds pll 65M
185 params
->dpi
.mipi_pll_clk_div2
= 0x800a0000;
186 //params->dpi.dpi_clk_div = 2;
187 //params->dpi.dpi_clk_duty = 1;
189 params
->dpi
.clk_pol
= LCM_POLARITY_FALLING
;
190 params
->dpi
.de_pol
= LCM_POLARITY_RISING
;
191 params
->dpi
.vsync_pol
= LCM_POLARITY_FALLING
;
192 params
->dpi
.hsync_pol
= LCM_POLARITY_FALLING
;
194 params
->dpi
.hsync_pulse_width
= HSYNC_PULSE_WIDTH
;
195 params
->dpi
.hsync_back_porch
= HSYNC_BACK_PORCH
;
196 params
->dpi
.hsync_front_porch
= HSYNC_FRONT_PORCH
;
197 params
->dpi
.vsync_pulse_width
= VSYNC_PULSE_WIDTH
;
198 params
->dpi
.vsync_back_porch
= VSYNC_BACK_PORCH
;
199 params
->dpi
.vsync_front_porch
= VSYNC_FRONT_PORCH
;
202 //params->dpi.i2x_en = 1;
203 params
->dpi
.lvds_tx_en
= 1;
204 params
->dpi
.ssc_disable
= 1;
205 params
->dpi
.format
= LCM_DPI_FORMAT_RGB888
; // format is 24 bit
206 params
->dpi
.rgb_order
= LCM_COLOR_ORDER_RGB
;
207 params
->dpi
.is_serial_output
= 0;
209 params
->dpi
.intermediat_buffer_num
= 0;
211 params
->dpi
.io_driving_current
= LCM_DRIVING_CURRENT_2MA
;
215 static void lcm_init(void)
218 printf("[LK/LCM] lcm_init() enter\n");
220 lcm_set_gpio_output(GPIO_LCD_PWR
, 1);
221 lcm_set_gpio_output(GPIO_LCD_PWR_EN
, 0);
222 lcm_set_gpio_output(GPIO_LCD_PWR2_EN
, 1);
225 //pmic_config_interface(0x424, 0x1, 0x1, 15);
226 //pmic_config_interface(0x45a, 0x07, 0x07, 5);
228 #ifdef CONFIG_MTK_PMIC_MT6397
229 upmu_set_rg_vgp6_vosel(0x7);
230 upmu_set_rg_vgp6_sw_en(0x1);
232 upmu_set_rg_vgp1_vosel(0x7);
233 upmu_set_rg_vgp1_en(0x1);
235 //hwPowerOn(MT65XX_POWER_LDO_VGP6, VOL_3300, "LCM");
237 lcm_set_gpio_output(GPIO_LCD_RST_EN
,GPIO_OUT_ONE
);
241 lcm_set_gpio_output(GPIO_LCD_STB_EN
,GPIO_OUT_ONE
);
245 lcm_set_gpio_output(GPIO_LCD_BL_EN
, GPIO_OUT_ONE
);
248 #elif (defined BUILD_UBOOT)
249 // do nothing in uboot
251 printk("[LCM] lcm_init() enter\n");
253 lcm_set_gpio_output(GPIO_LCD_RST_EN
,GPIO_OUT_ONE
);
258 lcm_set_gpio_output(GPIO_LCD_STB_EN
,GPIO_OUT_ONE
);
263 lcm_set_gpio_output(GPIO_LCD_BL_EN
, GPIO_OUT_ONE
);
271 static void lcm_suspend(void)
274 printf("[LK/LCM] lcm_suspend() enter\n");
276 lcm_set_gpio_output(GPIO_LCD_BL_EN
, 0);
281 lcm_set_gpio_output(GPIO_LCD_RST_EN
,GPIO_OUT_ZERO
);
282 lcm_set_gpio_output(GPIO_LCD_STB_EN
,GPIO_OUT_ZERO
);
284 lcm_set_gpio_output(GPIO_LCD_PWR
, 0);
285 lcm_set_gpio_output(GPIO_LCD_PWR_EN
, 0);
286 lcm_set_gpio_output(GPIO_LCD_PWR2_EN
, 0);
291 #elif (defined BUILD_UBOOT)
292 // do nothing in uboot
294 printk("[LCM] lcm_suspend() enter\n");
296 lcm_set_gpio_output(GPIO_LCD_BL_EN
, 0);
300 lcm_set_gpio_output(GPIO_LCD_RST_EN
,GPIO_OUT_ZERO
);
301 lcm_set_gpio_output(GPIO_LCD_STB_EN
,GPIO_OUT_ZERO
);
303 lcm_set_gpio_output(GPIO_LCD_PWR
, 0);
304 lcm_set_gpio_output(GPIO_LCD_PWR_EN
, 0);
305 lcm_set_gpio_output(GPIO_LCD_PWR2_EN
, 0);
308 #ifdef CONFIG_MTK_PMIC_MT6397
309 hwPowerDown(MT65XX_POWER_LDO_VGP6
, "LCM");//
311 hwPowerDown(MT6323_POWER_LDO_VGP1
, "LCM");//
321 static void lcm_resume(void)
324 printf("[LK/LCM] lcm_resume() enter\n");
327 #ifdef CONFIG_MTK_PMIC_MT6397
328 upmu_set_rg_vgp6_vosel(0x7);
329 upmu_set_rg_vgp6_sw_en(0x1);
331 upmu_set_rg_vgp1_vosel(0x7);
332 upmu_set_rg_vgp1_en(0x1);
334 //pmic_config_interface(0x424, 0x1, 0x1, 15);
335 //pmic_config_interface(0x45a, 0x07, 0x07, 5);
337 // hwPowerOn(MT65XX_POWER_LDO_VGP6, VOL_3300, "LCM");
339 lcm_set_gpio_output(GPIO_LCD_STB_EN
,GPIO_OUT_ONE
);
342 lcm_set_gpio_output(GPIO_LCD_PWR
, 1);
343 lcm_set_gpio_output(GPIO_LCD_PWR_EN
, 1);
344 lcm_set_gpio_output(GPIO_LCD_PWR2_EN
, 1);
349 lcm_set_gpio_output(GPIO_LCD_RST_EN
,GPIO_OUT_ONE
);
352 lcm_set_gpio_output(GPIO_LCD_BL_EN
, 1);
354 #elif (defined BUILD_UBOOT)
355 // do nothing in uboot
357 printk("[LCM] lcm_resume() enter\n");
359 #ifdef CONFIG_MTK_PMIC_MT6397
360 hwPowerOn(MT65XX_POWER_LDO_VGP6
, VOL_3300
, "LCM");
362 hwPowerOn(MT6323_POWER_LDO_VGP1
, VOL_3300
, "LCM");
364 lcm_set_gpio_output(GPIO_LCD_PWR
, 1);
365 lcm_set_gpio_output(GPIO_LCD_PWR_EN
, 1);
366 lcm_set_gpio_output(GPIO_LCD_PWR2_EN
, 1);
370 lcm_set_gpio_output(GPIO_LCD_STB_EN
, 1);
372 lcm_set_gpio_output(GPIO_LCD_RST_EN
, 1);
376 lcm_set_gpio_output(GPIO_LCD_BL_EN
, 1);
382 LCM_DRIVER cpt_clap070wp03xg_lvds_lcm_drv
=
384 .name
= "cpt_clap070wp03xg_lvds",
385 .set_util_funcs
= lcm_set_util_funcs
,
386 .get_params
= lcm_get_params
,
388 .suspend
= lcm_suspend
,
389 .resume
= lcm_resume
,