summaryrefslogtreecommitdiff
path: root/drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
committerYuval Adam <_@yuv.al>2017-08-30 08:25:59 +0000
commit8e4bff4cab0ddac6060645b0715210484d02ff40 (patch)
tree3a5c3024371a04692a3a6d9974d001cdff8ebf84 /drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c
Initial file dump from open source releaseHEADmaster
Diffstat (limited to 'drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c')
-rw-r--r--drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c291
1 files changed, 291 insertions, 0 deletions
diff --git a/drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c b/drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c
new file mode 100644
index 00000000..3ef26edb
--- /dev/null
+++ b/drivers/video/sprdfb/lcd/lcd_nt35510_mipi.c
@@ -0,0 +1,291 @@
+/* drivers/video/sc8825/lcd_nt35516_mipi.c
+ *
+ * Support for nt35516 mipi LCD device
+ *
+ * Copyright (C) 2010 Spreadtrum
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include "../sprdfb_panel.h"
+
+//#define LCD_Delay(ms) uDelay(ms*1000)
+
+#define MAX_DATA 56
+
+typedef struct LCM_Init_Code_tag {
+ unsigned int tag;
+ unsigned char data[MAX_DATA];
+}LCM_Init_Code;
+
+#define LCM_TAG_SHIFT 24
+#define LCM_TAG_MASK ((1 << 24) -1)
+#define LCM_SEND(len) ((1 << LCM_TAG_SHIFT)| len)
+#define LCM_SLEEP(ms) ((2 << LCM_TAG_SHIFT)| ms)
+//#define ARRAY_SIZE(array) ( sizeof(array) / sizeof(array[0]))
+
+#define LCM_TAG_SEND (1<< 0)
+#define LCM_TAG_SLEEP (1 << 1)
+
+static LCM_Init_Code init_data[] = {
+
+{LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x01}},
+
+{LCM_SEND(6), {4, 0, 0xB0,0x09,0x09,0x09}},
+{LCM_SEND(6), {4, 0, 0xB6,0x34,0x34,0x34}},
+{LCM_SEND(6), {4, 0, 0xB1,0x09,0x09,0x09}},
+{LCM_SEND(6), {4, 0, 0xB7,0x24,0x24,0x24}},
+{LCM_SEND(6), {4, 0, 0xB3,0x05,0x05,0x05}},
+{LCM_SEND(6), {4, 0, 0xB9,0x24,0x24,0x24}},
+
+{LCM_SEND(2), {0xBF,0x01}},
+
+{LCM_SEND(6), {4, 0, 0xB5,0x0B,0x0B,0x0B}},
+{LCM_SEND(6), {4, 0, 0xBA,0x24,0x24,0x24}},
+{LCM_SEND(6), {4, 0, 0xBC,0x00,0xA3,0x00}},
+{LCM_SEND(6), {4, 0, 0xBD,0x00,0xA3,0x00}},
+
+{LCM_SEND(5), {3, 0, 0xBE,0x00,0x58}},
+
+{LCM_SEND(55), {53, 0, 0xD1,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,
+0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,
+0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,
+0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},
+{LCM_SEND(55), {53, 0, 0xD2,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,
+0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,
+0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,
+0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},
+{LCM_SEND(55), {53, 0, 0xD3,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,
+0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,
+0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,
+0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},
+{LCM_SEND(55), {53, 0, 0xD4,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,
+0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,
+0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,
+0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},
+{LCM_SEND(55), {53, 0, 0xD5,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,
+0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,
+0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,
+0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},
+{LCM_SEND(55), {53, 0, 0xD6,0x00,0x01,0x00,0x43,0x00,0x6B,0x00,0x87,0x00,0xA3,
+0x00,0xCE,0x00,0xF1,0x01,0x27,0x01,0x53,0x01,0x98,0x01,0xCE,0x02,0x22,0x02,
+0x83,0x02,0x78,0x02,0x9E,0x02,0xDD,0x03,0x00,0x03,0x2E,0x03,0x54,0x03,0x7F,
+0x03,0x95,0x03,0xB3,0x03,0xC2,0x03,0xE1,0x03,0xF1,0x03,0xFE}},
+
+{LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x00}},
+
+{LCM_SEND(5), {3, 0, 0xB1,0xFC,0x04}},
+{LCM_SEND(2), {0x36,0x02}},
+{LCM_SEND(2), {0xB6,0x0A}},
+{LCM_SEND(5), {3, 0, 0xB7,0x00,0x00}},
+{LCM_SEND(7), {5, 0, 0xB8,0x01,0x05,0x05,0x05}},
+{LCM_SEND(2), {0xBA,0x01}},
+{LCM_SEND(6), {4, 0, 0xBC,0x00,0x00,0x00}},
+{LCM_SEND(8), {6, 0, 0xBD,0x01,0x84,0x07,0x32,0x00}},
+{LCM_SEND(8), {6, 0, 0xBE,0x01,0x84,0x07,0x31,0x00}},
+{LCM_SEND(8), {6, 0, 0xBF,0x01,0x84,0x07,0x31,0x00}},
+{LCM_SEND(2), {0x35,0x00}},// Tearing Effect On
+{LCM_SEND(6), {4, 0, 0xCC,0x03,0x00,0x00}},
+{LCM_SEND(2), {0x3A, 0x77}},
+
+{LCM_SEND(1), {0x11}}, // sleep out
+{LCM_SLEEP(120),},
+{LCM_SEND(1), {0x29}}, // display on
+{LCM_SLEEP(100),},
+{LCM_SEND(1), {0x2c}}, // normal on
+
+
+};
+
+//static LCM_Init_Code disp_on = {LCM_SEND(1), {0x29}};
+
+static LCM_Init_Code sleep_in[] = {
+{LCM_SEND(1), {0x28}},
+{LCM_SLEEP(10)},
+{LCM_SEND(1), {0x10}},
+{LCM_SLEEP(120)},
+{LCM_SEND(2), {0x4f, 0x01}},
+};
+
+static LCM_Init_Code sleep_out[] = {
+{LCM_SEND(1), {0x11}},
+{LCM_SLEEP(120)},
+{LCM_SEND(1), {0x29}},
+{LCM_SLEEP(20)},
+};
+
+static LCM_Init_Code change_fps_40[] = {
+{LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x00}},
+{LCM_SEND(8), {6, 0, 0xBD,0x02,0x46,0x1C,0x1C,0x00}},
+{LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x00,0x00}},
+};
+
+static LCM_Init_Code change_fps_60[] = {
+{LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x08,0x00}},
+{LCM_SEND(8), {6, 0, 0xBD,0x01,0x84,0x1C,0x1C,0x00}},
+{LCM_SEND(8), {6, 0, 0xF0,0x55,0xAA,0x52,0x00,0x00}},
+};
+
+static int32_t nt35510_mipi_init(struct panel_spec *self)
+{
+ int32_t i = 0;
+ LCM_Init_Code *init = init_data;
+ unsigned int tag;
+
+ mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;
+ mipi_gen_write_t mipi_gen_write = self->info.mipi->ops->mipi_gen_write;
+ mipi_dcs_write_t mipi_dcs_write = self->info.mipi->ops->mipi_dcs_write;
+
+ pr_debug(KERN_DEBUG "nt35510_mipi_init\n");
+
+ mipi_set_cmd_mode();
+
+ for(i = 0; i < ARRAY_SIZE(init_data); i++){
+ tag = (init->tag >>24);
+ if(tag & LCM_TAG_SEND){
+ mipi_gen_write(init->data, (init->tag & LCM_TAG_MASK));
+ udelay(20);
+ }else if(tag & LCM_TAG_SLEEP){
+ msleep((init->tag & LCM_TAG_MASK));
+ }
+ init++;
+ }
+ return 0;
+}
+
+static uint32_t nt35510_readid(struct panel_spec *self)
+{
+ /*Jessica TODO: need read id*/
+ return 0x10;
+}
+
+static int32_t nt35510_enter_sleep(struct panel_spec *self, uint8_t is_sleep)
+{
+ int32_t i = 0;
+ LCM_Init_Code *sleep_in_out = NULL;
+ unsigned int tag;
+ int32_t size = 0;
+
+ mipi_dcs_write_t mipi_dcs_write = self->info.mipi->ops->mipi_dcs_write;
+ mipi_gen_write_t mipi_gen_write = self->info.mipi->ops->mipi_gen_write;
+
+ printk(KERN_DEBUG "nt35516_enter_sleep, is_sleep = %d\n", is_sleep);
+
+ if(is_sleep){
+ sleep_in_out = sleep_in;
+ size = ARRAY_SIZE(sleep_in);
+ }else{
+ sleep_in_out = sleep_out;
+ size = ARRAY_SIZE(sleep_out);
+ }
+
+ for(i = 0; i <size ; i++){
+ tag = (sleep_in_out->tag >>24);
+ if(tag & LCM_TAG_SEND){
+ mipi_gen_write(sleep_in_out->data, (sleep_in_out->tag & LCM_TAG_MASK));
+ }else if(tag & LCM_TAG_SLEEP){
+ msleep((sleep_in_out->tag & LCM_TAG_MASK));
+ }
+ sleep_in_out++;
+ }
+ return 0;
+}
+
+static int32_t nt35510_change_fps(struct panel_spec *self, int fps_level)
+{
+ int32_t i = 0;
+ LCM_Init_Code *change_fps = NULL;
+ unsigned int tag;
+ int32_t size = 0;
+
+ mipi_gen_write_t mipi_gen_write = self->info.mipi->ops->mipi_gen_write;
+
+ printk(KERN_DEBUG "nt35510_change_fps, fps_level = %d\n", fps_level);
+
+ if(fps_level < 50){
+ change_fps = change_fps_40;
+ size = ARRAY_SIZE(change_fps_40);
+ }else{
+ change_fps = change_fps_60;
+ size = ARRAY_SIZE(change_fps_60);
+ }
+
+ for(i = 0; i <size ; i++){
+ tag = (change_fps->tag >>24);
+ if(tag & LCM_TAG_SEND){
+ mipi_gen_write(change_fps->data, (change_fps->tag & LCM_TAG_MASK));
+ }else if(tag & LCM_TAG_SLEEP){
+ msleep((change_fps->tag & LCM_TAG_MASK));
+ }
+ change_fps++;
+ }
+ return 0;
+
+}
+
+static struct panel_operations lcd_nt35510_mipi_operations = {
+ .panel_init = nt35510_mipi_init,
+ .panel_readid = nt35510_readid,
+ .panel_enter_sleep = nt35510_enter_sleep,
+ .panel_change_fps= nt35510_change_fps,
+};
+
+static struct timing_rgb lcd_nt35510_mipi_timing = {
+ .hfp = 20, /* unit: pixel */
+ .hbp = 20,
+ .hsync = 4,
+ .vfp = 10, /*unit: line*/
+ .vbp = 10,
+ .vsync = 6,
+};
+
+static struct info_mipi lcd_nt35510_mipi_info = {
+ .work_mode = SPRDFB_MIPI_MODE_CMD,
+ .video_bus_width = 24, /*18,16*/
+ .lan_number = 2,
+ .phy_feq = 500*1000,
+ .h_sync_pol = SPRDFB_POLARITY_POS,
+ .v_sync_pol = SPRDFB_POLARITY_POS,
+ .de_pol = SPRDFB_POLARITY_POS,
+ .te_pol = SPRDFB_POLARITY_POS,
+ .color_mode_pol = SPRDFB_POLARITY_NEG,
+ .shut_down_pol = SPRDFB_POLARITY_NEG,
+ .timing = &lcd_nt35510_mipi_timing,
+ .ops = NULL,
+};
+
+struct panel_spec lcd_nt35510_mipi_spec = {
+ .width = 480,
+ .height = 800,
+ .type = LCD_MODE_DSI,
+ .direction = LCD_DIRECT_NORMAL,
+ .info = {
+ .mipi = &lcd_nt35510_mipi_info
+ },
+ .ops = &lcd_nt35510_mipi_operations,
+};
+
+
+struct panel_cfg lcd_nt35510_mipi = {
+ /* this panel can only be main lcd */
+ .dev_id = SPRDFB_MAINLCD_ID,
+ .lcd_id = 0x10,
+ .lcd_name = "lcd_nt35510_mipi",
+ .panel = &lcd_nt35510_mipi_spec,
+};
+
+static int __init lcd_nt35510_mipi_init(void)
+{
+ return sprdfb_panel_register(&lcd_nt35510_mipi);
+}
+
+subsys_initcall(lcd_nt35510_mipi_init);