2 * Copyright (C) 2012 Spreadtrum Communications Inc.
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include <linux/kernel.h>
15 #include <linux/delay.h>
16 #include "../sprdfb_panel.h"
19 static int32_t hx8363_init(struct panel_spec *self)
21 send_data_t send_cmd = self->info.mcu->ops->send_cmd;
22 send_data_t send_data = self->info.mcu->ops->send_data;
24 printk("hx8363_init\n");
26 send_cmd(0xB9); // SET password
31 send_cmd(0xB0);//Enable internal oscillator
56 send_cmd(0xB2); // SET DISP
61 send_data(0x00);//Column inversion
69 send_cmd(0xB6);//Set_VCOM
72 send_cmd(0xCC);// SET Panel
77 send_cmd(0xE0); // SET Gamma
113 send_cmd(0xC1); //COLMOD
245 send_cmd(0x3A); //COLMOD
248 send_cmd(0x11);//Sleep Out
251 send_cmd(0xC2);// SET DISPIF
252 send_data(0x04); //24bit
253 send_cmd(0x35); //Tearing Effect
264 static int32_t hx8363_enter_sleep(struct panel_spec *self, uint8_t is_sleep)
266 send_data_t send_cmd = self->info.mcu->ops->send_cmd;
267 send_data_t send_data = self->info.mcu->ops->send_data;
289 static int32_t hx8363_set_window(struct panel_spec *self,
290 uint16_t left, uint16_t top, uint16_t right, uint16_t bottom)
292 send_data_t send_cmd = self->info.mcu->ops->send_cmd;
293 send_data_t send_data = self->info.mcu->ops->send_data;
295 pr_debug("hx8363_set_window: %d, %d, %d, %d\n",left, top, right, bottom);
297 send_cmd(0x2A); // col
298 send_data((left >> 8));
299 send_data((left & 0xFF));
300 send_data((right >> 8));
301 send_data((right & 0xFF));
303 send_cmd(0x2B); // row
304 send_data((top >> 8));
305 send_data((top & 0xFF));
306 send_data((bottom >> 8));
307 send_data((bottom & 0xFF));
309 send_cmd(0x2C); //Write data
313 static int32_t hx8363_invalidate(struct panel_spec *self)
315 pr_debug("hx8363_invalidate\n");
317 return self->ops->panel_set_window(self, 0, 0,
318 self->width - 1, self->height - 1);
323 static int32_t hx8363_invalidate_rect(struct panel_spec *self,
324 uint16_t left, uint16_t top,
325 uint16_t right, uint16_t bottom)
327 pr_debug("hx8363_invalidate_rect \n");
329 return self->ops->panel_set_window(self, left, top,
333 static int32_t hx8363_read_id(struct panel_spec *self)
336 send_data_t send_cmd = self->info.mcu->ops->send_cmd;
337 read_data_t read_data = self->info.mcu->ops->read_data;
338 send_data_t send_data = self->info.mcu->ops->send_data;
346 static struct panel_operations lcd_hx8363_mcu_operations = {
347 .panel_init = hx8363_init,
348 .panel_set_window = hx8363_set_window,
349 .panel_invalidate_rect= hx8363_invalidate_rect,
350 .panel_invalidate = hx8363_invalidate,
351 .panel_enter_sleep = hx8363_enter_sleep,
352 .panel_readid = hx8363_read_id
355 static struct timing_mcu lcd_hx8363_mcu_timing[] = {
356 [MCU_LCD_REGISTER_TIMING] = { // read/write register timing
364 [MCU_LCD_GRAM_TIMING] = { // read/write gram timing
374 static struct info_mcu lcd_hx8363_mcu_info = {
375 .bus_mode = LCD_BUS_8080,
378 .timing =lcd_hx8363_mcu_timing,
382 struct panel_spec lcd_hx8363_mcu_spec = {
385 .type = LCD_MODE_MCU,
386 .direction = LCD_DIRECT_NORMAL,
388 .mcu = &lcd_hx8363_mcu_info
390 .ops = &lcd_hx8363_mcu_operations,
393 struct panel_cfg lcd_hx8363_mcu = {
394 /* this panel may on both CS0/1 */
395 .dev_id = SPRDFB_UNDEFINELCD_ID,
397 .lcd_name = "lcd_hx8363_mcu",
398 .panel = &lcd_hx8363_mcu_spec,
401 static int __init lcd_hx8363_mcu_init(void)
403 return sprdfb_panel_register(&lcd_hx8363_mcu);
406 subsys_initcall(lcd_hx8363_mcu_init);