From 25dada32d3122e8369618035e0434d644292d079 Mon Sep 17 00:00:00 2001 From: Weiming Liu Date: Thu, 21 Dec 2017 18:16:25 +0800 Subject: [PATCH] lcd_extern: add st7701 driver PD#157223: lcd_extern: add st7701 driver for CES Change-Id: I49d6930c4a4358a8a97a73cbe0194a77f39f55e3 Signed-off-by: Weiming Liu --- MAINTAINERS | 4 + .../boot/dts/amlogic/mesonaxg_s400-panel.dtsi | 98 +++++++++---- arch/arm64/configs/meson64_defconfig | 1 + .../amlogic/media/vout/lcd/lcd_extern/Kconfig | 10 ++ .../media/vout/lcd/lcd_extern/Makefile | 2 +- .../media/vout/lcd/lcd_extern/lcd_extern.c | 4 + .../media/vout/lcd/lcd_extern/lcd_extern.h | 4 + .../media/vout/lcd/lcd_extern/mipi_ST7701.c | 134 ++++++++++++++++++ 8 files changed, 229 insertions(+), 28 deletions(-) create mode 100644 drivers/amlogic/media/vout/lcd/lcd_extern/mipi_ST7701.c diff --git a/MAINTAINERS b/MAINTAINERS index 58d7b37e64d0..22f58b6f47b5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14207,3 +14207,7 @@ AMLOGIC TXLX[R311] ADD LCD DRIVER SUPPORT M: Weiming Liu F: arch/arm64/boot/dts/amlogic/mesontxlx_r311-panel.dtsi F: drivers/amlogic/media/vout/backlight/aml_ldim/* + +AMLOGIC ADD LCD_EXTERN ST7701 DRIVER +M: Weiming Liu +F: drivers/amlogic/media/vout/lcd/lcd_extern/mipi_ST7701.c \ No newline at end of file diff --git a/arch/arm64/boot/dts/amlogic/mesonaxg_s400-panel.dtsi b/arch/arm64/boot/dts/amlogic/mesonaxg_s400-panel.dtsi index 4a5a78be1e9e..e2668f75d1b7 100644 --- a/arch/arm64/boot/dts/amlogic/mesonaxg_s400-panel.dtsi +++ b/arch/arm64/boot/dts/amlogic/mesonaxg_s400-panel.dtsi @@ -99,32 +99,27 @@ model_name = "TV070WSM"; /*interface(ttl,lvds,mipi)*/ interface = "mipi"; - /* basic_setting: - * h_active,v_active,h_period,v_period, - * lcd_bits,screen_widht,screen_height - */ - basic_setting = <600 1024 680 1040 8 95 163>; - /* lcd_timing: - * hs_width,hs_bp,hs_pol,vs_width,vs_bp,vs_pol - */ - lcd_timing = <24 36 0 2 8 0>; - /* clk_attr: - * fr_adj_type(0=clock,1=htotal,2=vtotal), - * clk_ss_level,clk_auto_generate, - * pixel_clk(unit in Hz) - */ - clk_attr = <0 0 1 42400000>; - /* mipi_attr: - * lane_num, bit_rate_max(MHz), - * factor(*100, default 0 for auto), - * operation_mode_init(0=video, 1=command), - * operation_mode_display(0=video, 1=command), - * video_mode_type - * (0=sync_pulse,1=sync_event,2=burst), - * clk_lp_continuous(0=stop,1=continue), - * phy_stop_wait(0=auto,1=standard,2=slow) - */ - mipi_attr = <4 350 0 1 0 2 1 0>; + basic_setting = <600 1024 /*h_active, v_active*/ + 680 1040 /*h_period, v_period*/ + 8 /*lcd_bits*/ + 95 163>; /*screen_widht, screen_height*/ + lcd_timing = <24 36 0 /*hs_width,hs_bp,hs_pol*/ + 2 8 0>; /*vs_width,vs_bp,vs_pol*/ + clk_attr = <0 /*fr_adj_type(0=clock,1=htotal,2=vtotal)*/ + 0 /*clk_ss_level*/ + 1 /*clk_auto_generate*/ + 42400000>; /*pixel_clk(unit in Hz)*/ + mipi_attr = <4 /*lane_num*/ + 350 /*bit_rate_max(MHz)*/ + 0 /*factor(*100, default 0 for auto)*/ + 1 /*operation_mode_init(0=video, 1=command)*/ + 0 /*operation_mode_display(0=video, 1=command)*/ + 2 /* + *video_mode_type + *(0=sync_pulse,1=sync_event,2=burst) + */ + 1 /*clk_lp_continuous(0=stop,1=continue)*/ + 0>; /*phy_stop_wait(0=auto,1=standard,2=slow)*/ /* dsi_init: data_type, num, data... */ dsi_init_on = <0xff 0xff>; /* ending flag */ dsi_init_off = <0xff 0xff>; /* ending flag */ @@ -139,6 +134,48 @@ 0xff 0 0 0>; backlight_index = <0>; }; + + lcd_2{ + model_name = "ST7701"; + /*interface(ttl,lvds,mipi)*/ + interface = "mipi"; + basic_setting = <480 854 /*h_active, v_active*/ + 570 929 /*h_period, v_period*/ + 8 /*lcd_bits*/ + 8 15>; /*screen_widht, screen_height*/ + lcd_timing = <30 30 0 /*hs_width,hs_bp,hs_pol*/ + 5 40 0>; /*vs_width,vs_bp,vs_pol*/ + clk_attr = <0 /*fr_adj_type(0=clock,1=htotal,2=vtotal)*/ + 0 /*clk_ss_level*/ + 1 /*clk_auto_generate*/ + 31771800>; /*pixel_clk(unit in Hz)*/ + mipi_attr = <2 /*lane_num*/ + 400 /*bit_rate_max(MHz)*/ + 0 /*factor(*100, default 0 for auto)*/ + 1 /*operation_mode_init(0=video, 1=command)*/ + 0 /*operation_mode_display(0=video, 1=command)*/ + 2 /* + *video_mode_type + *(0=sync_pulse,1=sync_event,2=burst) + */ + 1 /*clk_lp_continuous(0=stop,1=continue)*/ + 0>; /*phy_stop_wait(0=auto,1=standard,2=slow)*/ + /* dsi_init: data_type, num, data... */ + dsi_init_on = <0xff 0xff>; /* ending flag */ + dsi_init_off = <0xff 0xff>; /* ending flag */ + /* extern_init: 0xff for invalid */ + extern_init = <3>; + /* power step: type,index,value,delay(ms) */ + power_on_step = <0 0 1 20 + 0 0 0 10 + 0 0 1 20 + 2 0 0 0 + 0xff 0 0 0>; + power_off_step = <2 0 0 50 + 0 0 0 100 + 0xff 0 0 0>; + backlight_index = <0>; + }; }; lcd_extern{ @@ -160,7 +197,7 @@ /* init on/off: (type, value..., delay), * must match cmd_size for every group * type: 0x00=cmd(bit[3:0]=1 for second_addr), - * 0x10=gpio, 0xff=ending + * 0xf0=gpio, 0xff=ending * value: i2c or spi cmd, or gpio index & level, * fill 0x0 for no use * delay: unit ms @@ -231,6 +268,13 @@ status = "okay"; type = <2>; /* 0=i2c, 1=spi, 2=mipi */ }; + + extern_3{ + index = <3>; + extern_name = "mipi_ST7701"; + status = "okay"; + type = <2>; /* 0=i2c, 1=spi, 2=mipi */ + }; }; backlight{ diff --git a/arch/arm64/configs/meson64_defconfig b/arch/arm64/configs/meson64_defconfig index fdd2c1c28ff2..75ebf5b1013d 100644 --- a/arch/arm64/configs/meson64_defconfig +++ b/arch/arm64/configs/meson64_defconfig @@ -263,6 +263,7 @@ CONFIG_AMLOGIC_LCD_TABLET=y CONFIG_AMLOGIC_LCD_EXTERN=y CONFIG_AMLOGIC_LCD_EXTERN_MIPI_KD080D13=y CONFIG_AMLOGIC_LCD_EXTERN_MIPI_TV070WSM=y +CONFIG_AMLOGIC_LCD_EXTERN_MIPI_ST7701=y CONFIG_AMLOGIC_BACKLIGHT=y CONFIG_AMLOGIC_BL_EXTERN=y CONFIG_AMLOGIC_BL_EXTERN_I2C_LP8556=y diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/Kconfig b/drivers/amlogic/media/vout/lcd/lcd_extern/Kconfig index 1725652bf0a0..f11d1747990d 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/Kconfig +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/Kconfig @@ -84,3 +84,13 @@ config AMLOGIC_LCD_EXTERN_MIPI_TV070WSM Once the power on, according to the timing requirements, through the mipi interface to write data to the LCD, make its initialization + +config AMLOGIC_LCD_EXTERN_MIPI_ST7701 + bool "lcd external mipi ST7701 init driver" + default n + depends on AMLOGIC_LCD_EXTERN + help + Amlogic LCD external mipi_ST7701 init driver support + Once the power on, according to the timing requirements, + through the mipi interface to write data to the LCD, + make its initialization \ No newline at end of file diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/Makefile b/drivers/amlogic/media/vout/lcd/lcd_extern/Makefile index d3ca0b0f728d..fbbda0421cef 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/Makefile +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/Makefile @@ -4,4 +4,4 @@ obj-$(CONFIG_AMLOGIC_LCD_EXTERN_SPI_LD070WS2) += spi_LD070WS2.o obj-$(CONFIG_AMLOGIC_LCD_EXTERN_I2C_DLPC3439) += i2c_DLPC3439.o obj-$(CONFIG_AMLOGIC_LCD_EXTERN_MIPI_KD080D13) += mipi_KD080D13.o obj-$(CONFIG_AMLOGIC_LCD_EXTERN_MIPI_TV070WSM) += mipi_TV070WSM.o - +obj-$(CONFIG_AMLOGIC_LCD_EXTERN_MIPI_ST7701) += mipi_ST7701.o diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c b/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c index 487b00d647ee..2404802bc115 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c @@ -1071,6 +1071,10 @@ static int lcd_extern_add_mipi(struct aml_lcd_extern_driver_s *ext_drv) } else if (strcmp(ext_drv->config.name, "mipi_TV070WSM") == 0) { #ifdef CONFIG_AMLOGIC_LCD_EXTERN_MIPI_TV070WSM ret = aml_lcd_extern_mipi_TV070WSM_probe(ext_drv); +#endif + } else if (strcmp(ext_drv->config.name, "mipi_ST7701") == 0) { +#ifdef CONFIG_AMLOGIC_LCD_EXTERN_MIPI_ST7701 + ret = aml_lcd_extern_mipi_st7701_probe(ext_drv); #endif } else { EXTERR("invalid driver name: %s\n", ext_drv->config.name); diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.h b/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.h index 7e4ccbb6c397..a6b827940b08 100644 --- a/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.h +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.h @@ -73,6 +73,10 @@ extern int aml_lcd_extern_mipi_KD080D13_probe( extern int aml_lcd_extern_mipi_TV070WSM_probe( struct aml_lcd_extern_driver_s *ext_drv); #endif +#ifdef CONFIG_AMLOGIC_LCD_EXTERN_MIPI_ST7701 +extern int aml_lcd_extern_mipi_st7701_probe( + struct aml_lcd_extern_driver_s *ext_drv); +#endif #endif diff --git a/drivers/amlogic/media/vout/lcd/lcd_extern/mipi_ST7701.c b/drivers/amlogic/media/vout/lcd/lcd_extern/mipi_ST7701.c new file mode 100644 index 000000000000..e1597d721193 --- /dev/null +++ b/drivers/amlogic/media/vout/lcd/lcd_extern/mipi_ST7701.c @@ -0,0 +1,134 @@ +/* + * drivers/amlogic/media/vout/lcd/lcd_extern/mipi_ST7701.c + * + * Copyright (C) 2017 Amlogic, Inc. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "lcd_extern.h" + +#define LCD_EXTERN_NAME "mipi_ST7701" + +/* ******************** mipi command ******************** + * format: data_type, num, data.... + * special: data_type=0xff, num<0xff means delay ms, num=0xff means ending. + */ +static unsigned char mipi_init_on_table[] = { + 0x13, 1, 0x11, + //0x13, 1, 0x21, + //0x23, 2, 0x36, 0x00, + 0xff, 200, /* delay(ms) */ + 0x29, 6, 0xff, 0x77, 0x01, 0x00, 0x00, 0x10, + 0x29, 3, 0xc0, 0xe9, 0x03, + 0x29, 3, 0xc1, 0x11, 0x02, + 0x29, 3, 0xc2, 0x31, 0x08, + 0x29, 17, 0xb0, 0x00, 0x06, 0x11, 0x12, 0x18, + 0x0a, 0x0a, 0x09, 0x09, 0x1d, 0x09, 0x14, + 0x10, 0x0e, 0x11, 0x19, + 0x29, 17, 0xb1, 0x00, 0x06, 0x11, 0x11, 0x15, + 0x09, 0x0b, 0x09, 0x09, 0x23, 0x09, 0x17, + 0x14, 0x18, 0x1e, 0x19, + 0x29, 6, 0xff, 0x77, 0x01, 0x00, 0x00, 0x11, + 0x23, 2, 0xb0, 0x4d, + + //---------Vcom Setting---------------- + 0x23, 2, 0xb1, 0x3a, + + //---------End Vcom Setting-------------- + 0x23, 2, 0xb2, 0x07, + 0x23, 2, 0xb3, 0x80, + 0x23, 2, 0xb5, 0x47, + 0x23, 2, 0xb7, 0x8a, + 0x23, 2, 0xb8, 0x21, + 0x23, 2, 0xc1, 0x78, + 0x23, 2, 0xc2, 0x78, + 0x23, 2, 0xd0, 0x88, + + //-------End Power Control Registers Initial -- + 0xff, 100, /* delay(ms) */ + + //-----------GIP Setting--------------- + 0x29, 4, 0xe0, 0x00, 0x00, 0x02, + 0x29, 12, 0xe1, 0x08, 0x00, 0x0a, 0x00, 0x07, + 0x00, 0x09, 0x00, 0x00, 0x33, 0x33, + 0x29, 14, 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x29, 5, 0xe3, 0x00, 0x00, 0x33, 0x33, + 0x29, 3, 0xe4, 0x44, 0x44, + 0x29, 17, 0xe5, 0x0e, 0x60, 0xaf, 0xaf, 0x10, 0x60, + 0xaf, 0xaf, 0x0a, 0x60, 0xaf, 0xaf, 0x0c, 0x60, + 0xaf, 0xaf, + 0x29, 5, 0xe6, 0x00, 0x00, 0x33, 0x33, + 0x29, 3, 0xe7, 0x44, 0x44, + 0x29, 17, 0xe8, 0x0d, 0x60, 0xa0, 0xa0, 0x0f, 0x60, + 0xaf, 0xaf, 0x09, 0x60, 0xaf, 0xaf, 0x0b, 0x60, + 0xaf, 0xaf, + 0x29, 8, 0xeb, 0x02, 0x01, 0xe4, 0xe4, 0x44, 0x00, 0x40, + 0x29, 3, 0xec, 0x02, 0x01, + 0x29, 17, 0xed, 0xab, 0x89, 0x76, 0x54, 0x01, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x10, 0x45, 0x67, 0x98, 0xba, + + //------- Power Control Registers Initial End----- + 0xff, 10, /* delay(ms) */ + 0x29, 6, 0xff, 0x77, 0x01, 0x00, 0x00, 0x00, + 0x13, 1, 0x29, + //0x13, 1, 0x2c, + 0xff, 200, /* delay(ms) */ + 0xff, 0xff, /* ending flag */ +}; + +static unsigned char mipi_init_off_table[] = { + 0x05, 1, 0x28, /* display off */ + 0xff, 10, /* delay 10ms */ + 0x05, 1, 0x10, /* sleep in */ + 0xff, 150, /* delay 150ms */ + 0xff, 0xff, /* ending flag */ +}; + +static int lcd_extern_driver_update(struct aml_lcd_extern_driver_s *ext_drv) +{ + int ret = 0; + + if (ext_drv) { + ext_drv->config.table_init_on = &mipi_init_on_table[0]; + ext_drv->config.table_init_off = &mipi_init_off_table[0]; + } else { + EXTERR("%s driver is null\n", LCD_EXTERN_NAME); + ret = -1; + } + + return ret; +} + +int aml_lcd_extern_mipi_st7701_probe(struct aml_lcd_extern_driver_s *ext_drv) +{ + int ret = 0; + + ret = lcd_extern_driver_update(ext_drv); + + if (lcd_debug_print_flag) + EXTPR("%s: %d\n", __func__, ret); + return ret; +} +