6 #include <platform/mt_i2c.h>
9 #include <linux/string.h>
13 #include <platform/mt_gpio.h>
14 #include <platform/mt_pmic.h>
16 #include <mach/mt_gpio.h>
17 #include <mach/mt_pm_ldo.h>
18 #include <mach/upmu_common.h>
24 #define TPS_I2C_ID I2C2
25 #define TPS_SLAVE_ADDR 0x74
26 #define TPS_data_size 13 //1024
27 const uint8_t e2prom_data
[TPS_data_size
] = {0xFA,0x3C,0x28,0x09,0x09,0x08,0x23,0x03,0x01,0x06,0x01,0x7D,0x7D};
30 // ---------------------------------------------------------------------------
32 // ---------------------------------------------------------------------------
33 #define FRAME_WIDTH (800)
34 #define FRAME_HEIGHT (1280)
36 #define REGFLAG_DELAY 0XFE
37 #define REGFLAG_END_OF_TABLE 0xFF // END OF REGISTERS MARKER
39 #define LCM_ID 0x01 //KDT+AUO+OTA7291
40 #define LCM_DSI_CMD_MODE 0
42 // ---------------------------------------------------------------------------
44 // ---------------------------------------------------------------------------
45 static LCM_UTIL_FUNCS lcm_util
= {
49 #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
50 #define UDELAY(n) (lcm_util.udelay(n))
51 #define MDELAY(n) (lcm_util.mdelay(n))
53 // ---------------------------------------------------------------------------
55 // ---------------------------------------------------------------------------
56 #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
57 #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
58 #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
59 #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
60 #define read_reg lcm_util.dsi_read_reg()
61 #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
63 struct LCM_setting_table
{
66 unsigned char para_list
[64];
69 static struct LCM_setting_table lcm_initialization_setting
[] = {
71 {0x19,18,{0x00,0x00,0xfc,0x51,0xf2,0x3f,0xff,0xf3,0x3f,0x91,0x00,0x00,0x00,0x1c,0xf8,0x1f,0x01,0xc3}},
72 {0x19,18,{0x60,0x00,0x64,0xa0,0x10,0x0a,0x1e,0x1c,0x36,0x9c,0x10,0x09,0x3a,0x1e,0x80,0x91,0x02,0x3c}},
77 /*----------------------------------------*/
78 /*--------------TPS65640------------------*/
79 static int tps65640_write_data(void)
81 printf("Evan:%s\n",__func__
);
85 i2c
.addr
= TPS_SLAVE_ADDR
;
90 u8 buf1
[TPS_data_size
+1];
93 for(i
=0;i
<TPS_data_size
;i
++)
94 buf1
[i
+1]=e2prom_data
[i
];
95 ret
= i2c_write(&i2c
, buf1
, TPS_data_size
+1);
98 printf("--------Evan:%s step1 error---------\n",__func__
);
105 ret
= i2c_write(&i2c
, buf2
, 2);
108 printf("--------Evan:%s step2 error---------\n",__func__
);
115 static int tps65640_read_data(uint8_t *data
)
117 printf("Evan:%s\n",__func__
);
121 i2c
.addr
= TPS_SLAVE_ADDR
;
129 ret
= i2c_write(&i2c
, buf1
, 2);
132 printf("--------Evan:%s step1 error---------\n",__func__
);
137 ret
= i2c_write(&i2c
, buf2
, 1);
140 printf("--------Evan:%s step2-1 error---------\n",__func__
);
144 ret
=i2c_read(&i2c
, data
, TPS_data_size
);
147 printf("--------Evan:%s step2-2 error---------\n",__func__
);
156 static int tps65640_e2prom_data_check(void)
158 printf("Evan:%s\n",__func__
);
160 uint8_t data
[TPS_data_size
];
162 tps65640_read_data(data
);
164 for(i
=0;i
<TPS_data_size
;i
++)
165 if(data
[i
]!=e2prom_data
[i
])
168 printf("---------Evan:e2prom_data need update--------\n");
172 printf("---------Evan:e2prom_data is OK--------\n");
174 ret
=tps65640_write_data();
178 static int tps65640_enable()
180 printf("Evan:%s\n",__func__
);
184 /*----------------------------------------*/
187 static void lcd_power_en(unsigned char enabled
)
191 upmu_set_rg_vgp1_vosel(0x7);//3.3V
192 upmu_set_rg_vgp1_en(0x1);
193 upmu_set_rg_vgp3_vosel(0x3);//1.8V
194 upmu_set_rg_vgp3_en(0x1);
196 upmu_set_rg_vgp1_vosel(0x7);//3.3V
197 upmu_set_rg_vgp1_en(0x1);
198 upmu_set_rg_vgp3_vosel(0x3);//1.8V
199 upmu_set_rg_vgp3_en(0x1);
203 upmu_set_rg_vgp1_en(0);
204 upmu_set_rg_vgp1_vosel(0);
205 upmu_set_rg_vgp3_en(0);
206 upmu_set_rg_vgp3_vosel(0);
208 upmu_set_rg_vgp1_en(0);
209 upmu_set_rg_vgp1_vosel(0);
210 upmu_set_rg_vgp3_en(0);
211 upmu_set_rg_vgp3_vosel(0);
217 static void lcd_reset(unsigned char enabled
)
220 mt_set_gpio_out(GPIO_LCM_RST
, GPIO_OUT_ONE
);
222 mt_set_gpio_out(GPIO_LCM_RST
, GPIO_OUT_ZERO
);
226 // ---------------------------------------------------------------------------
227 // LCM Driver Implementations
228 // ---------------------------------------------------------------------------
229 static void lcm_set_util_funcs(const LCM_UTIL_FUNCS
*util
)
231 memcpy(&lcm_util
, util
, sizeof(LCM_UTIL_FUNCS
));
235 static void lcm_get_params(LCM_PARAMS
*params
)
237 memset(params
, 0, sizeof(LCM_PARAMS
));
239 params
->type
= LCM_TYPE_DSI
;
240 params
->width
= FRAME_WIDTH
;
241 params
->height
= FRAME_HEIGHT
;
242 params
->dsi
.mode
= SYNC_EVENT_VDO_MODE
; //BURST_VDO_MODE;BURST_VDO_MODE;
245 /* Command mode setting */
246 params
->dsi
.LANE_NUM
= LCM_FOUR_LANE
;
247 //The following defined the fomat for data coming from LCD engine.
248 params
->dsi
.data_format
.format
= LCM_DSI_FORMAT_RGB888
; //LCM_DSI_FORMAT_RGB666;
250 // Video mode setting
251 params
->dsi
.PS
= LCM_PACKED_PS_24BIT_RGB888
; //LCM_PACKED_PS_18BIT_RGB666;
253 params
->dsi
.vertical_sync_active
= 4;//0;
254 params
->dsi
.vertical_backporch
= 8;//23;
255 params
->dsi
.vertical_frontporch
= 8;
256 params
->dsi
.vertical_active_line
= FRAME_HEIGHT
;
258 params
->dsi
.horizontal_sync_active
= 4;//0;
259 params
->dsi
.horizontal_backporch
= 132;//160;
260 params
->dsi
.horizontal_frontporch
= 24; //100;//160;
261 params
->dsi
.horizontal_active_pixel
= FRAME_WIDTH
;
263 params
->dsi
.PLL_CLOCK
= 260;//148;
267 static void push_table(struct LCM_setting_table
*table
, unsigned int count
, unsigned char force_update
)
271 for(i
= 0; i
< count
; i
++) {
277 MDELAY(table
[i
].count
);
280 case REGFLAG_END_OF_TABLE
:
284 dsi_set_cmdq_V2(cmd
, table
[i
].count
, table
[i
].para_list
, force_update
);
290 static void lcm_init(void)
292 unsigned int data_array
[16];
295 printf("%s, LK \n", __func__
);
297 printk("%s, kernel", __func__
);
304 mt_set_gpio_out(GPIO_LCM_PWR_EN
, GPIO_OUT_ONE
);//iml8881 bias
313 push_table(lcm_initialization_setting
, sizeof(lcm_initialization_setting
) / sizeof(struct LCM_setting_table
), 1);
317 static void lcm_suspend(void)
319 unsigned int data_array
[16];
322 printf("%s, LK \n", __func__
);
324 printk("%s, kernel", __func__
);
329 mt_set_gpio_out(GPIO_LCM_PWR_EN
, GPIO_OUT_ZERO
);//iml8881 bias
335 static void lcm_resume(void)
337 unsigned int data_array
[16];
340 printf("%s, LK \n", __func__
);
342 printk("%s, kernel", __func__
);
348 static unsigned int lcm_compare_id(void)
350 unsigned int id1
= 0, id2
= 0, id
= 0;
353 printf("%s, LK \n", __func__
);
365 mt_set_gpio_mode(GPIO_HALL_2_PIN
, GPIO_HALL_2_PIN_M_GPIO
);
366 mt_set_gpio_dir(GPIO_HALL_2_PIN
, GPIO_DIR_IN
);
367 mt_set_gpio_pull_enable(GPIO_HALL_2_PIN
, GPIO_PULL_DISABLE
);
368 mt_set_gpio_mode(GPIO_HALL_1_PIN
, GPIO_HALL_1_PIN_M_GPIO
);
369 mt_set_gpio_dir(GPIO_HALL_1_PIN
, GPIO_DIR_IN
);
370 mt_set_gpio_pull_enable(GPIO_HALL_1_PIN
, GPIO_PULL_DISABLE
);
373 id1
= mt_get_gpio_in(GPIO_HALL_1_PIN
);
374 id2
= mt_get_gpio_in(GPIO_HALL_2_PIN
);
377 printf("KDT+AUO id1=%d,id2=%d,id=0x%x\n",id1
,id2
,id
);
379 printk("KDT+AUO id1=%d,id2=%d,id=0x%x\n",id1
,id2
,id
);
384 return (LCM_ID
== id
)?1:0;
387 LCM_DRIVER ota7291_wxga_dsi_vdo_lcm_drv
=
389 .name
= "ota7291_wxga_dsi_vdo",
390 .set_util_funcs
= lcm_set_util_funcs
,
391 .get_params
= lcm_get_params
,
393 .suspend
= lcm_suspend
,
394 .resume
= lcm_resume
,
395 .compare_id
= lcm_compare_id
,