287 lines
8.4 KiB
Diff
287 lines
8.4 KiB
Diff
|
diff --git a/drivers/video/sprdfb/Kconfig b/drivers/video/sprdfb/Kconfig
|
||
|
index 5c929a5..7f0678c 100755
|
||
|
--- a/drivers/video/sprdfb/Kconfig
|
||
|
+++ b/drivers/video/sprdfb/Kconfig
|
||
|
@@ -305,6 +305,11 @@ config FB_LCD_ST7789V_MCU
|
||
|
depends on FB_SC8825 || FB_SCX35 || FB_SCX15
|
||
|
default n
|
||
|
|
||
|
+config FB_LCD_ST7796S_MIPI
|
||
|
+ boolean "support ST7796S mipi panel"
|
||
|
+ depends on FB_SC8825 || FB_SCX35 || FB_SCX30G
|
||
|
+ default n
|
||
|
+
|
||
|
config FB_LCD_NT51017_MIPI_LVDS
|
||
|
boolean "support nt51017 lvds panel"
|
||
|
depends on FB_SC8825 || FB_SCX35
|
||
|
diff --git a/drivers/video/sprdfb/lcd/Makefile b/drivers/video/sprdfb/lcd/Makefile
|
||
|
index c1b385b..df28587 100755
|
||
|
--- a/drivers/video/sprdfb/lcd/Makefile
|
||
|
+++ b/drivers/video/sprdfb/lcd/Makefile
|
||
|
@@ -27,6 +27,7 @@ obj-$(CONFIG_FB_LCD_S6D77ALA_MIPI_PIKEBJ1MINI) += lcd_s6d77a1a01_mipi_pikebj1min
|
||
|
obj-$(CONFIG_FB_LCD_SC7798D_MIPI_PIKEBJ1MINI) += lcd_sc7798d_mipi_pikebj1mini.o
|
||
|
obj-$(CONFIG_FB_LCD_ILI9341) += lcd_ili9341.o
|
||
|
obj-$(CONFIG_FB_LCD_ST7789V_MCU) += lcd_st7789v_mcu.o
|
||
|
+obj-$(CONFIG_FB_LCD_ST7796S_MIPI) += lcd_st7796s_mipi.o
|
||
|
obj-$(CONFIG_FB_LCD_OTM1283A_MIPI) += lcd_otm1283a_mipi.o
|
||
|
obj-$(CONFIG_FB_LCD_NT35502_MIPI) += lcd_nt35502_mipi.o
|
||
|
obj-$(CONFIG_FB_LCD_VIVA_RGB_SPI) += lcd_hx8363_rgb_spi_viva.o
|
||
|
diff --git a/drivers/video/sprdfb/lcd/lcd_st7796s_mipi.c b/drivers/video/sprdfb/lcd/lcd_st7796s_mipi.c
|
||
|
new file mode 100644
|
||
|
index 0000000..2096e01
|
||
|
--- /dev/null
|
||
|
+++ b/drivers/video/sprdfb/lcd/lcd_st7796s_mipi.c
|
||
|
@@ -0,0 +1,252 @@
|
||
|
+/* drivers/video/sprdfb/lcd/lcd_st7796s_mipi.c
|
||
|
+ *
|
||
|
+ * Support for ST7796S 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/bug.h>
|
||
|
+#include <linux/delay.h>
|
||
|
+#include "../sprdfb_panel.h"
|
||
|
+
|
||
|
+#define MAX_DATA 100
|
||
|
+
|
||
|
+typedef struct LCM_Init_Code_tag {
|
||
|
+ unsigned int tag;
|
||
|
+ unsigned char data[MAX_DATA];
|
||
|
+}LCM_Init_Code;
|
||
|
+
|
||
|
+typedef struct LCM_force_cmd_code_tag{
|
||
|
+ unsigned int datatype;
|
||
|
+ LCM_Init_Code real_cmd_code;
|
||
|
+}LCM_Force_Cmd_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 LCM_TAG_SEND (1<< 0)
|
||
|
+#define LCM_TAG_SLEEP (1 << 1)
|
||
|
+
|
||
|
+static LCM_Init_Code init_data[] = {
|
||
|
+ /*{0xF0, 1, {0xC3}}, COMMAND SET CONTROL: ENABLE COMMAND 2 part I
|
||
|
+ {0xF0, 1, {0x96}}, COMMAND SET CONTROL: ENABLE COMMAND 2 part II
|
||
|
+ {0x36, 1, {0x86}}, MADCTL (memory data access control): mirror framebuffer,
|
||
|
+ {0xB4, 1, {0x01}}, DIC (display inversion control) : 1-dot inversion
|
||
|
+ {0x3A, 1, {0x55}}, Interface pixel format: 18-bit//0x55
|
||
|
+ {0xB7, 1, {0x06}}, Entry Mode Set: normal display
|
||
|
+ {0xB9, 2, {0x02,0XC0}},
|
||
|
+ {0x35, 1, {0x00}}, Tearing effect line: disabled
|
||
|
+ {0x44, 2, {0x00,0x00}}, Set tear scanline: 0
|
||
|
+
|
||
|
+ {0xE8, 8, {0x40,0x8a,0x00,0x00,0x29,0x19,0xa5,0x33}}, Display output ctrl adjust
|
||
|
+ {0xC5, 1, {0x25}}, VCOM control: 1.225
|
||
|
+ {0xC2, 1, {0xA5}}, PWR3 Power control: low
|
||
|
+ GAMMA CONTROL
|
||
|
+ {0xE0, 14, {0xF0,0x00,0x03,0x0b,0x0c,0x29,0x2e,0x44,0x41,0x17,0x11,0x13,0x16,0x1b}},
|
||
|
+ {0xE1, 14, {0xF0,0x00,0x02,0x06,0x06,0x24,0x2a,0x43,0x3e,0x2d,0x1a,0x16,0x13,0x17}},
|
||
|
+ {0xEC, 3, {0x00,0x00,0x01}},
|
||
|
+
|
||
|
+ {0xF0, 1, {0x3C}}, COMMAND SET CONTROL
|
||
|
+ {0xF0, 1, {0x69}}, COMMAND SET CONTROL
|
||
|
+
|
||
|
+ {0x29, 1, {0x00}},
|
||
|
+ {REGFLAG_DELAY, 20, {}},*/
|
||
|
+ {LCM_SEND(1), {0xC3}},
|
||
|
+ {LCM_SEND(1), {0x96}},
|
||
|
+ {LCM_SEND(1), {0x86}},
|
||
|
+ {LCM_SEND(1), {0x01}},
|
||
|
+ {LCM_SEND(1), {0x55}},//0x55
|
||
|
+ {LCM_SEND(1), {0x06}},
|
||
|
+ {LCM_SEND(2), {0x02,0XC0}},
|
||
|
+ {LCM_SEND(1), {0x00}},
|
||
|
+ {LCM_SEND(2), {0x00,0x00}},
|
||
|
+
|
||
|
+ {LCM_SEND(8), {0x40,0x8a,0x00,0x00,0x29,0x19,0xa5,0x33}},
|
||
|
+ {LCM_SEND(1), {0x25}},
|
||
|
+ {LCM_SEND(1), {0xA5}},
|
||
|
+
|
||
|
+ {LCM_SEND(14), {0xF0,0x00,0x03,0x0b,0x0c,0x29,0x2e,0x44,0x41,0x17,0x11,0x13,0x16,0x1b}},
|
||
|
+ {LCM_SEND(14), {0xF0,0x00,0x02,0x06,0x06,0x24,0x2a,0x43,0x3e,0x2d,0x1a,0x16,0x13,0x17}},
|
||
|
+ {LCM_SEND(3), {0x00,0x00,0x01}},
|
||
|
+
|
||
|
+ {LCM_SEND(1), {0x3C}},
|
||
|
+ {LCM_SEND(1), {0x69}},
|
||
|
+
|
||
|
+ {LCM_SEND(1), 1, {0x00}},
|
||
|
+ {LCM_SLEEP(20)},
|
||
|
+};
|
||
|
+
|
||
|
+static LCM_Init_Code sleep_in[] = {
|
||
|
+ {LCM_SEND(1), {0x28}},
|
||
|
+ {LCM_SLEEP(50)}, //>150ms
|
||
|
+ {LCM_SEND(1), {0x10}},
|
||
|
+ {LCM_SLEEP(120)}, //>150ms
|
||
|
+};
|
||
|
+
|
||
|
+static LCM_Init_Code sleep_out[] = {
|
||
|
+ {LCM_SEND(1), {0x11}},
|
||
|
+ {LCM_SLEEP(120)},//>120ms
|
||
|
+ {LCM_SEND(1), {0x29}},
|
||
|
+ {LCM_SLEEP(50)}, //>20ms
|
||
|
+};
|
||
|
+
|
||
|
+static int32_t st7796s_mipi_init(struct panel_spec *self)
|
||
|
+{
|
||
|
+ int32_t i;
|
||
|
+ 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_dcs_write_t mipi_dcs_write = self->info.mipi->ops->mipi_dcs_write;
|
||
|
+ mipi_eotp_set_t mipi_eotp_set = self->info.mipi->ops->mipi_eotp_set;
|
||
|
+
|
||
|
+ printk("kernel ili9486s1_mipi_init\n");
|
||
|
+
|
||
|
+ mipi_set_cmd_mode();
|
||
|
+ mipi_eotp_set(0,0);
|
||
|
+
|
||
|
+ for(i = 0; i < ARRAY_SIZE(init_data); i++){
|
||
|
+ tag = (init->tag >>24);
|
||
|
+ if(tag & LCM_TAG_SEND){
|
||
|
+ mipi_dcs_write(init->data, (init->tag & LCM_TAG_MASK));
|
||
|
+ udelay(20);
|
||
|
+ }else if(tag & LCM_TAG_SLEEP){
|
||
|
+ msleep(init->tag & LCM_TAG_MASK);
|
||
|
+ }
|
||
|
+ init++;
|
||
|
+ }
|
||
|
+ mipi_eotp_set(0,0);
|
||
|
+
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
+static uint32_t st7796s_readid(struct panel_spec *self)
|
||
|
+{
|
||
|
+ printk("lcd_dummy read id!\n");
|
||
|
+ printk("lcd_dummy read id success!\n");
|
||
|
+ return 0x7796;
|
||
|
+}
|
||
|
+
|
||
|
+
|
||
|
+static int32_t st7796s_enter_sleep(struct panel_spec *self, uint8_t is_sleep)
|
||
|
+{
|
||
|
+ int32_t i;
|
||
|
+ LCM_Init_Code *sleep_in_out = NULL;
|
||
|
+ unsigned int tag;
|
||
|
+ int32_t size = 0;
|
||
|
+
|
||
|
+ mipi_set_cmd_mode_t mipi_set_cmd_mode = self->info.mipi->ops->mipi_set_cmd_mode;
|
||
|
+ mipi_dcs_write_t mipi_dcs_write = self->info.mipi->ops->mipi_dcs_write;
|
||
|
+ mipi_eotp_set_t mipi_eotp_set = self->info.mipi->ops->mipi_eotp_set;
|
||
|
+
|
||
|
+ printk("kernel nt35502_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);
|
||
|
+ }
|
||
|
+
|
||
|
+ mipi_set_cmd_mode();
|
||
|
+ mipi_eotp_set(0,0);
|
||
|
+
|
||
|
+ for(i = 0; i <size ; i++){
|
||
|
+ tag = (sleep_in_out->tag >>24);
|
||
|
+ if(tag & LCM_TAG_SEND){
|
||
|
+ mipi_dcs_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++;
|
||
|
+ }
|
||
|
+ mipi_eotp_set(0,0);
|
||
|
+
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+/* esd check disabled
|
||
|
+static int32_t st7796s_check_esd(struct panel_spec *self)
|
||
|
+{
|
||
|
+ pr_debug("dummy_check_esd!\n");
|
||
|
+ pr_debug("dummy_check_esd OK!\n");
|
||
|
+ return 1;
|
||
|
+} */
|
||
|
+
|
||
|
+
|
||
|
+static struct panel_operations lcd_st7796s_mipi_operations = {
|
||
|
+ .panel_init = st7796s_mipi_init,
|
||
|
+ .panel_readid = st7796s_readid,
|
||
|
+ .panel_enter_sleep = st7796s_enter_sleep,
|
||
|
+ //.panel_esd_check = dummy_check_esd,
|
||
|
+};
|
||
|
+
|
||
|
+
|
||
|
+static struct timing_rgb lcd_st7796s_mipi_timing = {
|
||
|
+ /* unit: pixel */
|
||
|
+ .hfp = 65, //Horizontal front porch
|
||
|
+ .hbp = 10, //Horizontal back porch
|
||
|
+ .hsync = 10,//6,
|
||
|
+ /*unit: line*/
|
||
|
+ .vfp = 8, //Vertical front porch
|
||
|
+ .vbp = 10, //Vertical back porch
|
||
|
+ .vsync = 3,
|
||
|
+};
|
||
|
+
|
||
|
+static struct info_mipi lcd_st7796s_mipi_info = {
|
||
|
+ .work_mode = SPRDFB_MIPI_MODE_VIDEO,
|
||
|
+ .video_bus_width = 18, /*18,16*/
|
||
|
+ .lan_number = 1,
|
||
|
+ .phy_feq = 340*1000,
|
||
|
+ .h_sync_pol = SPRDFB_POLARITY_NEG,
|
||
|
+ .v_sync_pol = SPRDFB_POLARITY_NEG,
|
||
|
+ .de_pol = SPRDFB_POLARITY_POS,
|
||
|
+ .te_pol = SPRDFB_POLARITY_POS,
|
||
|
+ .color_mode_pol = SPRDFB_POLARITY_POS,
|
||
|
+ .shut_down_pol = SPRDFB_POLARITY_NEG,
|
||
|
+ .timing = &lcd_st7796s_mipi_timing,
|
||
|
+ .ops = NULL,
|
||
|
+};
|
||
|
+
|
||
|
+// DONE
|
||
|
+
|
||
|
+struct panel_spec lcd_st7796s_mipi_spec = {
|
||
|
+ .width = 320,
|
||
|
+ .height = 480,
|
||
|
+ .fps = 60,
|
||
|
+ .type = LCD_MODE_DSI,
|
||
|
+ .direction = LCD_DIRECT_NORMAL,
|
||
|
+ //.is_clean_lcd = true,
|
||
|
+ .info = {
|
||
|
+ .mipi = &lcd_st7796s_mipi_info
|
||
|
+ },
|
||
|
+ .ops = &lcd_st7796s_mipi_operations,
|
||
|
+};
|
||
|
+
|
||
|
+struct panel_cfg lcd_st7796s_mipi = {
|
||
|
+ .dev_id = SPRDFB_MAINLCD_ID,
|
||
|
+ .lcd_id = 0x7796,
|
||
|
+ .lcd_name = "lcd_st7796s_mipi",
|
||
|
+ .panel = &lcd_st7796s_mipi_spec,
|
||
|
+};
|
||
|
+
|
||
|
+static int __init lcd_st7796s_mipi_init(void)
|
||
|
+{
|
||
|
+ return sprdfb_panel_register(&lcd_st7796s_mipi);
|
||
|
+}
|
||
|
+
|
||
|
+subsys_initcall(lcd_st7796s_mipi_init);
|