lcd: add gpio pinctrl for pinmux off
authorEvoke Zhang <evoke.zhang@amlogic.com>
Thu, 23 Aug 2018 12:21:46 +0000 (20:21 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Thu, 6 Sep 2018 02:08:09 +0000 (19:08 -0700)
PD#172438: lcd: add gpio pinctrl for pinmux off

include below drivers:
1.lcd
2.lcd_extern
3.backlight
4.bl_ldim
5.bl_extern

Change-Id: I7b5449fa9581d0290135c615b63a7557eb9c915a
Signed-off-by: Evoke Zhang <evoke.zhang@amlogic.com>
60 files changed:
arch/arm64/boot/dts/amlogic/axg_s400.dts
arch/arm64/boot/dts/amlogic/axg_s400_v03.dts
arch/arm64/boot/dts/amlogic/axg_s400emmc.dts
arch/arm64/boot/dts/amlogic/axg_s400emmc_512m.dts
arch/arm64/boot/dts/amlogic/axg_s400emmc_v03.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_skt.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_skt_buildroot.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_1g.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_buildroot.dts
arch/arm64/boot/dts/amlogic/g12a_s905d2_u200_drm_buildroot.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u211.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_1g.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_512m.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u211_buildroot.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u212.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u212_1g.dts
arch/arm64/boot/dts/amlogic/g12a_s905x2_u212_buildroot.dts
arch/arm64/boot/dts/amlogic/g12a_s905y2_u220.dts
arch/arm64/boot/dts/amlogic/g12a_s905y2_u221.dts
arch/arm64/boot/dts/amlogic/g12b_a311d_skt.dts
arch/arm64/boot/dts/amlogic/g12b_a311d_w400.dts
arch/arm64/boot/dts/amlogic/g12b_a311d_w400_buildroot.dts
arch/arm64/boot/dts/amlogic/mesonaxg_s400-panel.dtsi
arch/arm64/boot/dts/amlogic/mesong12a_skt-panel.dtsi
arch/arm64/boot/dts/amlogic/mesong12b_skt-panel.dtsi
arch/arm64/boot/dts/amlogic/mesongxl.dtsi
arch/arm64/boot/dts/amlogic/mesongxl_p212-panel.dtsi
arch/arm64/boot/dts/amlogic/mesongxm.dtsi
arch/arm64/boot/dts/amlogic/mesongxm_q200-panel.dtsi
arch/arm64/boot/dts/amlogic/mesontxl_p321-panel.dtsi
arch/arm64/boot/dts/amlogic/mesontxlx.dtsi
arch/arm64/boot/dts/amlogic/mesontxlx_r311-panel.dtsi
arch/arm64/boot/dts/amlogic/txl_t950_p341.dts
arch/arm64/boot/dts/amlogic/txl_t960_p346.dts
arch/arm64/boot/dts/amlogic/txl_t962_p320.dts
arch/arm64/boot/dts/amlogic/txl_t962_p321.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts
drivers/amlogic/media/vout/backlight/aml_bl.c
drivers/amlogic/media/vout/backlight/aml_ldim/global_bl.c
drivers/amlogic/media/vout/backlight/aml_ldim/iw7027_bl.c
drivers/amlogic/media/vout/backlight/aml_ldim/ldim_dev_drv.c
drivers/amlogic/media/vout/backlight/aml_ldim/ldim_drv.c
drivers/amlogic/media/vout/backlight/aml_ldim/ob3350_bl.c
drivers/amlogic/media/vout/backlight/bl_extern/bl_extern.c
drivers/amlogic/media/vout/backlight/bl_extern/bl_extern.h
drivers/amlogic/media/vout/backlight/bl_extern/bl_extern_i2c.c
drivers/amlogic/media/vout/backlight/bl_extern/i2c_lp8556.c
drivers/amlogic/media/vout/backlight/bl_extern/mipi_lt070me05.c
drivers/amlogic/media/vout/lcd/lcd_common.c
drivers/amlogic/media/vout/lcd/lcd_common.h
drivers/amlogic/media/vout/lcd/lcd_debug.c
drivers/amlogic/media/vout/lcd/lcd_extern/ext_default.c
drivers/amlogic/media/vout/lcd/lcd_extern/lcd_extern.c
drivers/amlogic/media/vout/lcd/lcd_vout.c
include/linux/amlogic/media/vout/lcd/aml_bl_extern.h
include/linux/amlogic/media/vout/lcd/aml_ldim.h
include/linux/amlogic/media/vout/lcd/lcd_extern.h

index 46053de..9a6d915 100644 (file)
                        function = "pwm_b";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_4";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 }; /* end of pinctrl_periphs */
 /* Audio Related End */
 
index 9bc25d7..b743d4e 100644 (file)
                        function = "pwm_b";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_4";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 }; /* end of pinctrl_periphs */
 /* Audio Related End */
 
index bf2ecf4..bd22966 100644 (file)
                        function = "pwm_b";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_4";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 }; /* end of pinctrl_periphs */
 /* Audio Related End */
 
index bb46254..ad4ab32 100644 (file)
                        function = "pwm_b";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_4";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 }; /* end of pinctrl_periphs */
 /* Audio Related End */
 
index 52d182f..05861e2 100644 (file)
                        function = "pwm_b";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_4";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 }; /* end of pinctrl_periphs */
 /* Audio Related End */
 
index 7c4e6a1..8cc224a 100644 (file)
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 
 }; /* end of pinctrl_periphs */
 &pinctrl_aobus {
index 56bc1a0..278335a 100644 (file)
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
 
 }; /* end of pinctrl_periphs */
 &pinctrl_aobus {
index 6754cd8..fe7f5f5 100644 (file)
        };
 
        bl_extern_i2c {
-               compatible = "amlogic, bl_extern_i2c";
-               status = "disabled";
-               reg = <0x2c>; /*reg_address for lp8556*/
+               compatible = "bl_extern, i2c";
                dev_name = "lp8556";
-       };
-       lcd_extern_i2c {
-               compatible = "amlogic, lcd_i2c_T5800Q";
+               reg = <0x2c>;
                status = "disabled";
-               reg = <0x1c>; /*reg_address for i2c_T5800Q*/
-               dev_name = "i2c_T5800Q";
        };
 };
 
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 
 }; /* end of pinctrl_periphs */
 &pinctrl_aobus {
index 33d6ab6..3fd298a 100644 (file)
        };
 
        bl_extern_i2c {
-               compatible = "amlogic, bl_extern_i2c";
-               status = "disabled";
-               reg = <0x2c>; /*reg_address for lp8556*/
+               compatible = "bl_extern, i2c";
                dev_name = "lp8556";
-       };
-       lcd_extern_i2c {
-               compatible = "amlogic, lcd_i2c_T5800Q";
+               reg = <0x2c>;
                status = "disabled";
-               reg = <0x1c>; /*reg_address for i2c_T5800Q*/
-               dev_name = "i2c_T5800Q";
        };
 };
 
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 
 }; /* end of pinctrl_periphs */
 &pinctrl_aobus {
index f5332c7..846b79b 100644 (file)
        };
 
        bl_extern_i2c {
-               compatible = "amlogic, bl_extern_i2c";
-               status = "disabled";
-               reg = <0x2c>; /*reg_address for lp8556*/
+               compatible = "bl_extern, i2c";
                dev_name = "lp8556";
-       };
-       lcd_extern_i2c {
-               compatible = "amlogic, lcd_i2c_T5800Q";
+               reg = <0x2c>;
                status = "disabled";
-               reg = <0x1c>; /*reg_address for i2c_T5800Q*/
-               dev_name = "i2c_T5800Q";
        };
 };
 
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 
 }; /* end of pinctrl_periphs */
 &pinctrl_aobus {
index 220a87e..8d8f965 100644 (file)
        };
 
        bl_extern_i2c {
-               compatible = "amlogic, bl_extern_i2c";
-               status = "disabled";
-               reg = <0x2c>; /*reg_address for lp8556*/
+               compatible = "bl_extern, i2c";
                dev_name = "lp8556";
+               reg = <0x2c>;
+               status = "disabled";
        };
 };
 
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 
 }; /* end of pinctrl_periphs */
 &pinctrl_aobus {
index 3ab206f..237ac12 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 9b3cfed..3e8523f 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index a0bb8a6..8b6f603 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 230dc78..7c15662 100644 (file)
@@ -18,7 +18,6 @@
 /dts-v1/;
 
 #include "mesong12a.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 3295b3d..07b7a63 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index f1705db..4e5f86d 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal_P_32.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 9a4d117..f4e0632 100644 (file)
@@ -18,7 +18,6 @@
 /dts-v1/;
 
 #include "mesong12a.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 5b1bfae..e22bf1b 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 5fa634c..b63fef2 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "mesong12a.dtsi"
 #include "partition_mbox_normal.dtsi"
-#include "mesong12a_skt-panel.dtsi"
 
 / {
        model = "Amlogic";
index 6e7c566..3f0df3b 100644 (file)
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 }; /* end of pinctrl_periphs */
 
 &pinctrl_aobus {
index f321af3..e0eadaf 100644 (file)
                differential_pair = <1>;
                status = "disabled";
        };
+
+       bl_extern_i2c {
+               compatible = "bl_extern, i2c";
+               dev_name = "lp8556";
+               reg = <0x2c>;
+               status = "disabled";
+       };
 };
 
 &audiobus {
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 }; /* end of pinctrl_periphs */
 
 &pinctrl_aobus {
index dab736a..200965d 100644 (file)
                differential_pair = <1>;
                status = "disabled";
        };
+
+       bl_extern_i2c {
+               compatible = "bl_extern, i2c";
+               dev_name = "lp8556";
+               reg = <0x2c>;
+               status = "disabled";
+       };
 };
 
 &audiobus {
                };
        };
 
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOH_5";
+                       function = "gpio_periphs";
+                       output-high;
+               };
+       };
+
 }; /* end of pinctrl_periphs */
 
 &pinctrl_aobus {
index ae856c7..67d0c0a 100644 (file)
                dev_name = "backlight";
                status = "okay";
                key_valid = <0>;
-               pinctrl-names = "pwm_on";
+               pinctrl-names = "pwm_on","pwm_off";
                pinctrl-0 = <&bl_pwm_on_pins>;
+               pinctrl-1 = <&bl_pwm_off_pins>;
                pinctrl_version = <1>; /* for uboot */
+               bl_pwm_config = <&bl_pwm_conf>;
+               bl-gpios = <&gpio GPIOZ_4 GPIO_ACTIVE_HIGH
+                       &gpio GPIOZ_5 GPIO_ACTIVE_HIGH>;
+               bl_gpio_names = "GPIOZ_4","GPIOZ_5";
 
                /* pwm port: PWM_A, PWM_B, PWM_C, PWM_D, PWM_VS*/
                /* power index:(point gpios_index, 0xff=invalid)
                 * power value:(0=output low, 1=output high, 2=input)
                 * power delay:(unit in ms)
                 */
-               bl-gpios = <&gpio GPIOZ_4 GPIO_ACTIVE_HIGH
-                       &gpio GPIOZ_5 GPIO_ACTIVE_HIGH>;
-               bl_gpio_names = "GPIOZ_4","GPIOZ_5";
-               bl_pwm_config = <&bl_pwm_conf>;
 
                backlight_0{
                        index = <0>;
                        bl_pwm_attr = <0 /*pwm_method*/
                                180 /*pwm_freq(pwm:Hz, pwm_vs:multiple of vs)*/
                                100 25>; /*duty_max(%), duty_min(%)*/
-                       bl_pwm_power = <0 0 /*pwm_gpio_index, pwm_gpio_off*/
+                       bl_pwm_power = <0 1 /*pwm_gpio_index, pwm_gpio_off*/
                                10 10>; /*pwm_on_delay(ms), pwm_off_delay(ms)*/
                        bl_pwm_en_sequence_reverse = <0>; /* 1 for reverse */
                };
                compatible = "amlogic, bl_extern";
                dev_name = "bl_extern";
                status = "disabled";
+               i2c_bus = "i2c_bus_3";
 
                extern_0{
                        index = <0>;
                        extern_name = "i2c_lp8556";
-
                        type = <0>; /*0=i2c, 1=spi, 2=mipi*/
                        i2c_address = <0x2c>; /*7bit i2c address*/
-                       i2c_bus = "i2c_bus_c";
                        dim_max_min = <255 10>;
                };
 
                extern_1{
                        index = <1>;
                        extern_name = "mipi_lt070me05";
-
                        type = <2>; /*0=i2c, 1=spi, 2=mipi*/
                        dim_max_min = <255 10>;
                };
        };
-
-
 };/* end of panel */
 
index 622f5c3..dfb3346 100644 (file)
                dev_name = "backlight";
                status = "okay";
                key_valid = <0>;
-               pinctrl-names = "pwm_on";
+               pinctrl-names = "pwm_on","pwm_off";
                pinctrl-0 = <&pwm_f_pins2>;
+               pinctrl-1 = <&bl_pwm_off_pins>;
                pinctrl_version = <2>; /* for uboot */
                bl_pwm_config = <&bl_pwm_conf>;
                bl-gpios = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH
                        pwms = <&pwm_ef MESON_PWM_1 30040 0>;
                };
        };
+
        bl_extern{
                compatible = "amlogic, bl_extern";
                dev_name = "bl_extern";
                status = "disabled";
+               i2c_bus = "i2c_bus_3";
+
                extern_0{
                        index = <0>;
                        extern_name = "i2c_lp8556";
                        type = <0>; /*0=i2c, 1=spi, 2=mipi*/
                        i2c_address = <0x2c>; /*7bit i2c address*/
-                       i2c_bus = "i2c_bus_c";
                        dim_max_min = <255 10>;
                };
+
                extern_1{
                        index = <1>;
                        extern_name = "mipi_lt070me05";
index 0ca4d8a..e29ab4e 100644 (file)
                dev_name = "backlight";
                status = "okay";
                key_valid = <0>;
-               pinctrl-names = "pwm_on";
+               pinctrl-names = "pwm_on","pwm_off";
                pinctrl-0 = <&pwm_f_pins2>;
+               pinctrl-1 = <&bl_pwm_off_pins>;
                pinctrl_version = <2>; /* for uboot */
                bl_pwm_config = <&bl_pwm_conf>;
                bl-gpios = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH
                        pwms = <&pwm_ef MESON_PWM_1 30040 0>;
                };
        };
+
        bl_extern{
                compatible = "amlogic, bl_extern";
                dev_name = "bl_extern";
                status = "disabled";
+               i2c_bus = "i2c_bus_3";
+
                extern_0{
                        index = <0>;
                        extern_name = "i2c_lp8556";
                        type = <0>; /*0=i2c, 1=spi, 2=mipi*/
                        i2c_address = <0x2c>; /*7bit i2c address*/
-                       i2c_bus = "i2c_bus_c";
                        dim_max_min = <255 10>;
                };
+
                extern_1{
                        index = <1>;
                        extern_name = "mipi_lt070me05";
index f40d05e..5cd5dad 100644 (file)
                        };
                };
 
+       lcd_ttl_rgb_6bit_on_pins:lcd_ttl_rgb_6bit_on{
+               mux {
+                       groups = "lcd_r2_7",
+                               "lcd_g2_7",
+                               "lcd_b2_7";
+                       function = "lcd_ttl";
+               };
+       };
+       lcd_ttl_rgb_6bit_off_pins:lcd_ttl_rgb_6bit_off{
+               mux {
+                       groups = "GPIODV_2","GPIODV_3","GPIODV_4",
+                               "GPIODV_5","GPIODV_6","GPIODV_7",
+                               "GPIODV_10","GPIODV_11","GPIODV_12",
+                               "GPIODV_13","GPIODV_14","GPIODV_15",
+                               "GPIODV_18","GPIODV_19","GPIODV_20",
+                               "GPIODV_21","GPIODV_22","GPIODV_23";
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
+
+       lcd_ttl_rgb_8bit_on_pins:lcd_ttl_rgb_8bit_on{
+               mux {
+                       groups = "lcd_r0_1", "lcd_r2_7",
+                               "lcd_g0_1", "lcd_g2_7",
+                               "lcd_b0_1", "lcd_b2_7";
+                       function = "lcd_ttl";
+               };
+       };
+       lcd_ttl_rgb_8bit_off_pins:lcd_ttl_rgb_8bit_off{
+               mux {
+                       groups = "GPIODV_0","GPIODV_1","GPIODV_2","GPIODV_3",
+                               "GPIODV_4","GPIODV_5","GPIODV_6","GPIODV_7",
+                               "GPIODV_8","GPIODV_9","GPIODV_10","GPIODV_11",
+                               "GPIODV_12","GPIODV_13","GPIODV_14","GPIODV_15",
+                               "GPIODV_16","GPIODV_17","GPIODV_18","GPIODV_19",
+                               "GPIODV_20","GPIODV_21","GPIODV_22","GPIODV_23";
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
+                /* DE + clk */
+       lcd_ttl_de_on_pins:lcd_ttl_de_on_pin{
+               mux {
+                       groups = "tcon_cph", /* clk */
+                               "tcon_oeh";  /* DE */
+                       function = "lcd_ttl";
+               };
+       };
+                /* hvsync + clk */
+       lcd_ttl_hvsync_on_pins:lcd_ttl_hvsync_on_pin{
+               mux {
+                       groups = "tcon_cph", /* clk */
+                               "tcon_stv1", /* vs */
+                               "tcon_sth1"; /* hs */
+                       function = "lcd_ttl";
+               };
+       };
+                /* DE + hvsync + clk */
+       lcd_ttl_de_hvsync_on_pins:lcd_ttl_de_hvsync_on_pin{
+               mux {
+                       groups = "tcon_cph", /* clk */
+                               "tcon_oeh",  /* DE */
+                               "tcon_stv1", /* vs */
+                               "tcon_sth1"; /* hs */
+                       function = "lcd_ttl";
+               };
+       };
+       lcd_ttl_de_hvsync_off_pins:lcd_ttl_de_hvsync_off_pin{
+               mux {
+                       groups = "GPIODV_26", /* clk */
+                               "GPIODV_27",  /* DE */
+                               "GPIODV_24", /* vs */
+                               "GPIODV_25"; /* hs */
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
 }; /* end of pinctrl_periphs */
 
 &periphs {
index 1eae48a..5df7e23 100644 (file)
                interrupts = <0 3 1>;
                interrupt-names = "vsync";
                pinctrl_version = <1>; /* for uboot */
+               pinctrl-names = "ttl_6bit_hvsync_de_on",
+                       "ttl_6bit_hvsync_on",
+                       "ttl_6bit_de_on",
+                       "ttl_6bit_hvsync_de_off",
+                       "ttl_8bit_hvsync_de_on",
+                       "ttl_8bit_hvsync_on",
+                       "ttl_8bit_de_on",
+                       "ttl_8bit_hvsync_de_off";
+               pinctrl-0 = <&lcd_ttl_rgb_6bit_on_pins
+                       &lcd_ttl_de_hvsync_on_pins>;
+               pinctrl-1 = <&lcd_ttl_rgb_6bit_on_pins
+                       &lcd_ttl_hvsync_on_pins>;
+               pinctrl-2 = <&lcd_ttl_rgb_6bit_on_pins
+                       &lcd_ttl_de_on_pins>;
+               pinctrl-3 = <&lcd_ttl_rgb_6bit_off_pins
+                       &lcd_ttl_de_hvsync_off_pins>;
+               pinctrl-4 = <&lcd_ttl_rgb_8bit_on_pins
+                       &lcd_ttl_de_hvsync_on_pins>;
+               pinctrl-5 = <&lcd_ttl_rgb_8bit_on_pins
+                       &lcd_ttl_hvsync_on_pins>;
+               pinctrl-6 = <&lcd_ttl_rgb_8bit_on_pins
+                       &lcd_ttl_de_on_pins>;
+               pinctrl-7 = <&lcd_ttl_rgb_8bit_off_pins
+                       &lcd_ttl_de_hvsync_off_pins>;
 
                /* power type:
                 *    (0=cpu_gpio, 1=pmu_gpio, 2=signal,3=extern, 0xff=ending)
@@ -39,7 +63,7 @@
                 * power value:(0=output low, 1=output high, 2=input)
                 * power delay:(unit in ms)
                 */
-               /*lcd_cpu-gpios = <&gpio GPIOX_3 1>;*/
+               /*lcd_cpu-gpios = <&gpio GPIOX_3 GPIO_ACTIVE_HIGH>;*/
                /*lcd_cpu_gpio_names = "GPIOX_3";*/
 
                lcd_0{
                        backlight_index = <0xff>;
                };
        };
+
+       lcd_extern{
+               compatible = "amlogic, lcd_extern";
+               dev_name = "lcd_extern";
+               status = "disabled";
+               i2c_bus = "i2c_bus_d";
+               key_valid = <0>;
+
+               extern_0{
+                       index = <0>;
+                       extern_name = "ext_default";
+                       status = "disabled";
+                       type = <0>; /* 0=i2c, 1=spi, 2=mipi */
+                       i2c_address = <0x1c>; /* 7bit i2c address */
+                       i2c_second_address = <0xff>; /* 0xff for none */
+                       cmd_size = <0xff>; /*0xff for dynamic cmd_size*/
+
+                       /* init on/off:
+                        *  fixed cmd_size: (type, value..., delay);
+                        *                  cmd_size include all data.
+                        *  dynamic cmd_size: (type, cmd_size, value..., delay);
+                        *                    cmd_size include value+delay.
+                        */
+                       /* type: 0x00=cmd(bit[3:0]=1 for second_addr),
+                        *       0xf0=gpio, 0xff=ending
+                        */
+                       /* value: i2c or spi cmd, or gpio index & level,
+                        * fill 0x0 for no use
+                        */
+                       /* delay: unit ms */
+                       init_on = <0x00 8 0x20 0x01 0x02 0x00 0x40 0xFF 0x00 0
+                               0x00 8 0x80 0x02 0x00 0x40 0x62 0x51 0x73 0
+                               0x00 8 0x61 0x06 0x00 0x00 0x00 0x00 0x00 0
+                               0x00 8 0xC1 0x05 0x0F 0x00 0x08 0x70 0x00 0
+                               0x00 8 0x13 0x01 0x00 0x00 0x00 0x00 0x00 0
+                               0x00 8 0x3D 0x02 0x01 0x00 0x00 0x00 0x00 0
+                               0x00 8 0xED 0x0D 0x01 0x00 0x00 0x00 0x00 0
+                               0x00 8 0x23 0x02 0x00 0x00 0x00 0x00 0x00 10
+                               0xff 0>; /*ending*/
+                       init_off = <0xff 0>; /*ending*/
+               };
+
+               extern_1{
+                       index = <1>;
+                       extern_name = "i2c_DLPC3439";
+                       status = "disabled";
+                       type = <0>; /* 0=i2c, 1=spi, 2=mipi */
+                       i2c_address = <0x1b>; /* 7bit i2c address */
+                       cmd_size = <0xff>; /*0xff for dynamic cmd_size*/
+               };
+       };
 };/* end of panel */
 
index 9c92322..d127e64 100644 (file)
                };
        };
 
-       lcd_ttl_rgb_6bit_pins_on:lcd_ttl_rgb_6bit_on{
+       lcd_ttl_rgb_6bit_on_pins:lcd_ttl_rgb_6bit_on{
                mux {
                        groups = "lcd_r2_7",
                                "lcd_g2_7",
                        function = "lcd_ttl";
                };
        };
+       lcd_ttl_rgb_6bit_off_pins:lcd_ttl_rgb_6bit_off{
+               mux {
+                       groups = "GPIODV_2","GPIODV_3","GPIODV_4",
+                               "GPIODV_5","GPIODV_6","GPIODV_7",
+                               "GPIODV_10","GPIODV_11","GPIODV_12",
+                               "GPIODV_13","GPIODV_14","GPIODV_15",
+                               "GPIODV_18","GPIODV_19","GPIODV_20",
+                               "GPIODV_21","GPIODV_22","GPIODV_23";
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
 
-       lcd_ttl_rgb_8bit_pins_on:lcd_ttl_rgb_8bit_on{
+       lcd_ttl_rgb_8bit_on_pins:lcd_ttl_rgb_8bit_on{
                mux {
                        groups = "lcd_r0_1", "lcd_r2_7",
                                "lcd_g0_1", "lcd_g2_7",
                        function = "lcd_ttl";
                };
        };
+       lcd_ttl_rgb_8bit_off_pins:lcd_ttl_rgb_8bit_off{
+               mux {
+                       groups = "GPIODV_0","GPIODV_1","GPIODV_2","GPIODV_3",
+                               "GPIODV_4","GPIODV_5","GPIODV_6","GPIODV_7",
+                               "GPIODV_8","GPIODV_9","GPIODV_10","GPIODV_11",
+                               "GPIODV_12","GPIODV_13","GPIODV_14","GPIODV_15",
+                               "GPIODV_16","GPIODV_17","GPIODV_18","GPIODV_19",
+                               "GPIODV_20","GPIODV_21","GPIODV_22","GPIODV_23";
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
                 /* DE + clk */
        lcd_ttl_de_on_pins:lcd_ttl_de_on_pin{
                mux {
                        function = "lcd_ttl";
                };
        };
+       lcd_ttl_de_hvsync_off_pins:lcd_ttl_de_hvsync_off_pin{
+               mux {
+                       groups = "GPIODV_26", /* clk */
+                               "GPIODV_27",  /* DE */
+                               "GPIODV_24", /* vs */
+                               "GPIODV_25"; /* hs */
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
 }; /* end of pinctrl_periphs */
 
 &periphs {
index 0251205..6627036 100644 (file)
                interrupts = <0 3 1>;
                interrupt-names = "vsync";
                pinctrl_version = <1>; /* for uboot */
-               pinctrl-names = "ttl_6bit_hvsync_de_on","ttl_6bit_hvsync_on",
-                       "ttl_6bit_de_on","ttl_8bit_hvsync_de_on",
-                       "ttl_8bit_hvsync_on","ttl_8bit_de_on";
-               pinctrl-0 = <&lcd_ttl_rgb_6bit_pins_on
+               pinctrl-names = "ttl_6bit_hvsync_de_on",
+                       "ttl_6bit_hvsync_on",
+                       "ttl_6bit_de_on",
+                       "ttl_6bit_hvsync_de_off",
+                       "ttl_8bit_hvsync_de_on",
+                       "ttl_8bit_hvsync_on",
+                       "ttl_8bit_de_on",
+                       "ttl_8bit_hvsync_de_off";
+               pinctrl-0 = <&lcd_ttl_rgb_6bit_on_pins
                        &lcd_ttl_de_hvsync_on_pins>;
-               pinctrl-1 = <&lcd_ttl_rgb_6bit_pins_on
+               pinctrl-1 = <&lcd_ttl_rgb_6bit_on_pins
                        &lcd_ttl_hvsync_on_pins>;
-               pinctrl-2 = <&lcd_ttl_rgb_6bit_pins_on
+               pinctrl-2 = <&lcd_ttl_rgb_6bit_on_pins
                        &lcd_ttl_de_on_pins>;
-               pinctrl-3 = <&lcd_ttl_rgb_8bit_pins_on
+               pinctrl-3 = <&lcd_ttl_rgb_6bit_off_pins
+                       &lcd_ttl_de_hvsync_off_pins>;
+               pinctrl-4 = <&lcd_ttl_rgb_8bit_on_pins
                        &lcd_ttl_de_hvsync_on_pins>;
-               pinctrl-4 = <&lcd_ttl_rgb_8bit_pins_on
+               pinctrl-5 = <&lcd_ttl_rgb_8bit_on_pins
                        &lcd_ttl_hvsync_on_pins>;
-               pinctrl-5 = <&lcd_ttl_rgb_8bit_pins_on
+               pinctrl-6 = <&lcd_ttl_rgb_8bit_on_pins
                        &lcd_ttl_de_on_pins>;
+               pinctrl-7 = <&lcd_ttl_rgb_8bit_off_pins
+                       &lcd_ttl_de_hvsync_off_pins>;
 
                /* power type:
                 *    (0=cpu_gpio, 1=pmu_gpio, 2=signal,3=extern, 0xff=ending)
@@ -54,7 +63,7 @@
                 * power value:(0=output low, 1=output high, 2=input)
                 * power delay:(unit in ms)
                 */
-               /*lcd_cpu-gpios = <&gpio GPIOX_3 1>;*/
+               /*lcd_cpu-gpios = <&gpio GPIOX_3 GPIO_ACTIVE_HIGH>;*/
                /*lcd_cpu_gpio_names = "GPIOX_3";*/
 
                lcd_0{
                };
 
                extern_1{
-                       index = <2>;
+                       index = <1>;
                        extern_name = "i2c_DLPC3439";
                        status = "disabled";
                        type = <0>; /* 0=i2c, 1=spi, 2=mipi */
                        i2c_address = <0x1b>; /* 7bit i2c address */
-                       i2c_bus = "i2c_bus_d";
+                       cmd_size = <0xff>; /*0xff for dynamic cmd_size*/
                };
        };
 };/* end of panel */
index 722f865..274f3e5 100644 (file)
                status = "okay";
                key_valid = <1>;
                i2c_bus = "i2c_bus_c";
-               /*pinctrl-names="extern_pins";*/
-               /*pinctrl_names_uboot = "i2c_c";*/ /* i2c_a, i2c_b, i2c_c */
-               /*pinctrl-0=<&i2c_c_master>;*/
-               /*extern-gpios = <&gpio GPIOH_2 1*/
-                               /*&gpio GPIOH_3 1>;*/
+               /*pinctrl-names="extern_on",    */
+               /*      "extern_off";           */
+               /*pinctrl-0=<&i2c2_h_pins       */
+               /*      &lcd_extern_off_pins>;  */
+               /*pinctrl_gpio_off = <0>;       */
+               /*extern-gpios = <&gpio GPIOH_2 GPIO_ACTIVE_HIGH*/
+               /*      &gpio GPIOH_3 GPIO_ACTIVE_HIGH>;*/
                /*extern_gpio_names = "GPIOH_2","GPIOH_3";*/
-               /*i2c_gpio_off = <0 0 1 0>; */
-               /* I2C_SCK_gpio_index, I2C_SCK_gpio_off,
-                * I2C_SDA_gpio_index, I2C_SCK_gpio_off
-                */
+               /*i2c_gpio = <0 1>;  //i2c_sck, i2c_sda gpio_index */
 
                extern_0{
                        index = <0>;
                pinctrl-names = "pwm_on","pwm_vs_on",
                                "pwm_combo_0_1_on",
                                "pwm_combo_0_vs_1_on",
-                               "pwm_combo_0_1_vs_on";
+                               "pwm_combo_0_1_vs_on",
+                               "pwm_off",
+                               "pwm_combo_off";
                pinctrl-0 = <&pwm_b_z6_pins>;
                pinctrl-1 = <&pwm_vs_z6_pins>;
                pinctrl-2 = <&pwm_b_z6_pins &pwm_c_z7_pins>;
                pinctrl-3 = <&pwm_vs_z6_pins &pwm_c_z7_pins>;
                pinctrl-4 = <&pwm_b_z6_pins &pwm_vs_z7_pins>;
+               pinctrl-5 = <&bl_pwm_off_pins>;
+               pinctrl-6 = <&bl_pwm_combo_off_pins>;
                pinctrl_version = <2>; /* for uboot */
                bl_pwm_config = <&bl_pwm_conf>;
 
index 220efeb..c2c9eb7 100644 (file)
                        function = "vbyone";
                };
        };
+       lcd_vbyone_off_pins: lcd_vbyone_off_pin {
+               mux {
+                       groups = "GPIOH_0","GPIOH_1";
+                       function = "gpio_periphs";
+                       input-enable;
+               };
+       };
 
-       lcd_ttl_rgb_6bit_pins_on:lcd_ttl_rgb_6bit_on{
+       lcd_ttl_rgb_6bit_on_pins:lcd_ttl_rgb_6bit_on{
                mux {
                        groups = "lcd_r2_7","lcd_g2_7","lcd_b2_7";
                        function = "lcd";
                };
        };
-       lcd_ttl_rgb_6bit_pins_off:lcd_ttl_rgb_6bit_off{
+       lcd_ttl_rgb_6bit_off_pins:lcd_ttl_rgb_6bit_off{
                mux {
                        groups = "GPIOY_2","GPIOY_3","GPIOY_4","GPIOY_5",
                                "GPIOY_6","GPIOY_7", /*r2~7*/
                        input-enable;
                };
        };
-       lcd_ttl_rgb_8bit_pins_on:lcd_ttl_rgb_8bit_on{
+       lcd_ttl_rgb_8bit_on_pins:lcd_ttl_rgb_8bit_on{
                mux {
                        groups = "lcd_r0_1","lcd_r2_7",
                                "lcd_g0_1","lcd_g2_7",
                        function = "lcd";
                };
        };
-       lcd_ttl_rgb_8bit_pins_off:lcd_ttl_rgb_8bit_off{
+       lcd_ttl_rgb_8bit_off_pins:lcd_ttl_rgb_8bit_off{
                mux {
                        groups = "GPIOY_0","GPIOY_1","GPIOY_2","GPIOY_3",
                                "GPIOY_4","GPIOY_5", "GPIOY_6","GPIOY_7",
index ca4ef2c..e37e864 100644 (file)
@@ -31,8 +31,9 @@
                interrupts = <0 3 1
                        0 78 1>;
                interrupt-names = "vsync","vbyone";
-               pinctrl-names = "vbyone";
+               pinctrl-names = "vbyone","vbyone_off";
                pinctrl-0 = <&lcd_vbyone_pins>;
+               pinctrl-1 = <&lcd_vbyone_off_pins>;
                pinctrl_version = <2>; /* for uboot */
 
                /* power type:(0=cpu_gpio, 2=signal, 3=extern, 0xff=ending) */
                status = "okay";
                key_valid = <1>;
                i2c_bus = "i2c_bus_c";
-               /*pinctrl-names="extern_pins";*/
-               /*pinctrl_names_uboot = "i2c_c";*/ /* i2c_a, i2c_b, i2c_c */
-               /*pinctrl-0=<&i2c_c_master>;*/
-               /*extern-gpios = <&gpio GPIOH_2 1*/
-                               /*&gpio GPIOH_3 1>;*/
+               /*pinctrl-names="extern_on",    */
+               /*      "extern_off";           */
+               /*pinctrl-0=<&i2c2_h_pins       */
+               /*      &lcd_extern_off_pins>;  */
+               /*pinctrl_gpio_off = <0>;       */
+               /*extern-gpios = <&gpio GPIOH_2 GPIO_ACTIVE_HIGH*/
+               /*      &gpio GPIOH_3 GPIO_ACTIVE_HIGH>;*/
                /*extern_gpio_names = "GPIOH_2","GPIOH_3";*/
-               /*i2c_gpio_off = <0 0 1 0>; */
-               /* I2C_SCK_gpio_index, I2C_SCK_gpio_off,
-                * I2C_SDA_gpio_index, I2C_SCK_gpio_off
-                */
+               /*i2c_gpio = <0 1>;  //i2c_sck, i2c_sda gpio_index */
 
                extern_0{
                        index = <0>;
                pinctrl-names = "pwm_on","pwm_vs_on",
                                "pwm_combo_0_1_on",
                                "pwm_combo_0_vs_1_on",
-                               "pwm_combo_0_1_vs_on";
+                               "pwm_combo_0_1_vs_on",
+                               "pwm_off",
+                               "pwm_combo_off";
                pinctrl-0 = <&bl_pwm_on_pins>;
                pinctrl-1 = <&bl_pwm_vs_on_pins>;
                pinctrl-2 = <&bl_pwm_combo_0_on_pins
                        &bl_pwm_combo_1_on_pins>;
                pinctrl-4 = <&bl_pwm_combo_0_on_pins
                        &bl_pwm_combo_1_vs_on_pins>;
+               pinctrl-5 = <&bl_pwm_off_pins>;
+               pinctrl-6 = <&bl_pwm_combo_off_pins>;
                pinctrl_version = <2>; /* for uboot */
                interrupts = <0 3 1>;
                interrupt-names = "ldim_vsync";
                compatible = "amlogic, ldim_dev";
                dev_name = "ldim_dev";
                status = "okay";
-               pinctrl-names = "ldim_pwm","ldim_pwm_vs";
-               pinctrl-0 = <&ldim_pwm_pins>;
-               pinctrl-1 = <&ldim_pwm_vs_pins>;
+               pinctrl-names = "ldim_pwm",
+                       "ldim_pwm_vs",
+                       "ldim_pwm_off";
+               pinctrl-0 = <&bl_pwm_on_pins>;
+               pinctrl-1 = <&bl_pwm_vs_on_pins>;
+               pinctrl-2 = <&bl_pwm_off_pins>;
                pinctrl_version = <1>; /* for uboot */
 
                /* pwm port: PWM_A, PWM_B, PWM_C, PWM_D, PWM_E, PWM_F, PWM_VS*/
index 983efb4..2008afd 100644 (file)
                };
        };
        /* end AUDIO_RELATED */
+
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
+       /*backlight*/
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
+               mux {
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
 };
 
 &i2c1 {
        pinctrl-0=<&i2c1_dv_pins>;
 };
 
+&i2c2 {
+       status = "disabled";
+       pinctrl-names="default";
+       pinctrl-0=<&i2c2_h_pins>;
+
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
+               dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "disabled";
+       };
+};
+
 &dwc3 {
        status = "okay";
 };
index cd62b53..9efde02 100644 (file)
                };
        };
        /* end AUDIO_RELATED */
+
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
+       /*backlight*/
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
+               mux {
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
 };
 
 &i2c1 {
        pinctrl-0=<&i2c1_dv_pins>;
 };
 
+&i2c2 {
+       status = "disabled";
+       pinctrl-names="default";
+       pinctrl-0=<&i2c2_h_pins>;
+
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
+               dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "disabled";
+       };
+};
+
 &dwc3 {
        status = "okay";
 };
index 040adc1..b8f61f1 100644 (file)
                };
        };
        /* end AUDIO_RELATED */
+
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
+       /*backlight*/
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
+               mux {
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
 };
 
 &i2c0 {
        pinctrl-0=<&i2c1_dv_pins>;
 };
 
+&i2c2 {
+       status = "okay";
+       pinctrl-names="default";
+       pinctrl-0=<&i2c2_h_pins>;
+
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
+               dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "okay";
+       };
+};
+
 &dwc3 {
        status = "okay";
 };
index ee8d10b..b25f050 100644 (file)
                };
        };
        /* end AUDIO_RELATED */
+
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
+       /*backlight*/
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
+               mux {
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
 };
 
 &i2c0 {
        pinctrl-0=<&i2c1_dv_pins>;
 };
 
+&i2c2 {
+       status = "okay";
+       pinctrl-names="default";
+       pinctrl-0=<&i2c2_h_pins>;
+
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
+               dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "okay";
+       };
+};
+
 &dwc3 {
        status = "okay";
 };
index 6952f6f..9be7ef8 100644 (file)
                status = "okay";
        };
 
-       lcd_extern_i2c {
-               compatible = "amlogic, lcd_i2c_T5800Q";
-               status = "disabled";
-               reg = <0x1c>; /*reg_address for i2c_T5800Q*/
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
                dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "okay";
        };
 };
 
                };
        };
 
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
        /*backlight*/
        bl_pwm_on_pins:bl_pwm_on_pin {
                mux {
                        function = "pwm_vs";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
        bl_pwm_combo_0_on_pins:bl_pwm_combo_0_on_pin {
                mux {
                        pins = "pwm_b";
                        function = "pwm_vs";
                };
        };
-
-       /*ldim*/
-       ldim_pwm_pins:ldim_pwm_pin {
-               mux {
-                       pins = "pwm_b";
-                       function = "pwm_b";
-               };
-       };
-       ldim_pwm_vs_pins:ldim_pwm_vs_pin {
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
                mux {
-                       pins = "pwm_vs_z6";
-                       function = "pwm_vs";
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
                };
        };
 };
index e122b49..334fe79 100644 (file)
                drc_enable = <0>;
                status = "okay";
        };
-       lcd_extern_i2c {
-               compatible = "amlogic, lcd_i2c_T5800Q";
-               status = "disabled";
-               reg = <0x1c>; /*reg_address for i2c_T5800Q*/
+
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
                dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "okay";
        };
 };
 
                };
        };
 
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
        /*backlight*/
        bl_pwm_on_pins:bl_pwm_on_pin {
                mux {
                        function = "pwm_vs";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
        bl_pwm_combo_0_on_pins:bl_pwm_combo_0_on_pin {
                mux {
                        pins = "pwm_b";
                        function = "pwm_vs";
                };
        };
-
-       /*ldim*/
-       ldim_pwm_pins:ldim_pwm_pin {
-               mux {
-                       pins = "pwm_b";
-                       function = "pwm_b";
-               };
-       };
-       ldim_pwm_vs_pins:ldim_pwm_vs_pin {
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
                mux {
-                       pins = "pwm_vs_z6";
-                       function = "pwm_vs";
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
                };
        };
 };
index df69bb4..17461a9 100644 (file)
                drc_enable = <0>;
                status = "okay";
        };
-       lcd_extern_i2c {
-               compatible = "amlogic, lcd_i2c_T5800Q";
-               status = "disabled";
-               reg = <0x1c>; /*reg_address for i2c_T5800Q*/
+
+       lcd_extern_i2c0: lcd_extern_i2c@0 {
+               compatible = "lcd_ext, i2c";
                dev_name = "i2c_T5800Q";
+               reg = <0x1c>;
+               status = "okay";
        };
 };
 
                };
        };
 
+       /*lcd_extern*/
+       lcd_extern_off_pins:lcd_extern_off_pin {
+               mux {
+                       pins = "GPIOH_2",
+                               "GPIOH_3";
+                       function = "gpio_periphs";
+                       /*output-high;*/
+                       output-low;
+                       /*input-enable;*/
+               };
+       };
+
        /*backlight*/
        bl_pwm_on_pins:bl_pwm_on_pin {
                mux {
                        function = "pwm_vs";
                };
        };
+       bl_pwm_off_pins:bl_pwm_off_pin {
+               mux {
+                       pins = "GPIOZ_6";
+                       function = "gpio_periphs";
+                       output-low;
+               };
+       };
        bl_pwm_combo_0_on_pins:bl_pwm_combo_0_on_pin {
                mux {
                        pins = "pwm_b";
                        function = "pwm_vs";
                };
        };
-
-       /*ldim*/
-       ldim_pwm_pins:ldim_pwm_pin {
-               mux {
-                       pins = "pwm_b";
-                       function = "pwm_b";
-               };
-       };
-       ldim_pwm_vs_pins:ldim_pwm_vs_pin {
+       bl_pwm_combo_off_pins:bl_pwm_combo_off_pin {
                mux {
-                       pins = "pwm_vs_z6";
-                       function = "pwm_vs";
+                       pins = "GPIOZ_6",
+                               "GPIOZ_7";
+                       function = "gpio_periphs";
+                       output-low;
                };
        };
 };
index 9a96c10..e4e04f5 100644 (file)
@@ -48,7 +48,7 @@
 #include "aml_bl_reg.h"
 
 /* #define AML_BACKLIGHT_DEBUG */
-static unsigned int bl_debug_print_flag;
+unsigned int bl_debug_print_flag;
 
 static struct aml_bl_drv_s *bl_drv;
 
@@ -104,6 +104,8 @@ static struct bl_config_s bl_config = {
                {.probe_flag = 0, .register_flag = 0,},
                {.probe_flag = 0, .register_flag = 0,},
        },
+
+       .pinmux_flag = 0xff,
 };
 
 const char *bl_chip_table[] = {
@@ -339,17 +341,19 @@ static inline unsigned int bl_do_div(unsigned long num, unsigned int den)
 }
 
 /* ****************************************************** */
-#define BL_PINMUX_MAX    6
+#define BL_PINMUX_MAX    8
 static char *bl_pinmux_str[BL_PINMUX_MAX] = {
        "pwm_on",               /* 0 */
        "pwm_vs_on",            /* 1 */
        "pwm_combo_0_1_on",     /* 2 */
        "pwm_combo_0_vs_1_on",  /* 3 */
        "pwm_combo_0_1_vs_on",  /* 4 */
+       "pwm_off",              /* 5 */
+       "pwm_combo_off",        /* 6 */
        "none",
 };
 
-static void bl_pwm_pinmux_set(struct bl_config_s *bconf)
+static void bl_pwm_pinmux_set(struct bl_config_s *bconf, int status)
 {
        int index = 0xff;
 
@@ -358,19 +362,27 @@ static void bl_pwm_pinmux_set(struct bl_config_s *bconf)
 
        switch (bconf->method) {
        case BL_CTRL_PWM:
-               if (bconf->bl_pwm->pwm_port == BL_PWM_VS)
-                       index = 1;
-               else
-                       index = 0;
+               if (status) {
+                       if (bconf->bl_pwm->pwm_port == BL_PWM_VS)
+                               index = 1;
+                       else
+                               index = 0;
+               } else {
+                       index = 5;
+               }
                break;
        case BL_CTRL_PWM_COMBO:
-               if (bconf->bl_pwm_combo0->pwm_port == BL_PWM_VS)
-                       index = 3;
-               else {
-                       if (bconf->bl_pwm_combo1->pwm_port == BL_PWM_VS)
-                               index = 4;
-                       else
-                               index = 2;
+               if (status) {
+                       if (bconf->bl_pwm_combo0->pwm_port == BL_PWM_VS) {
+                               index = 3;
+                       } else {
+                               if (bconf->bl_pwm_combo1->pwm_port == BL_PWM_VS)
+                                       index = 4;
+                               else
+                                       index = 2;
+                       }
+               } else {
+                       index = 6;
                }
                break;
        default:
@@ -383,16 +395,23 @@ static void bl_pwm_pinmux_set(struct bl_config_s *bconf)
                return;
        }
 
+       if (bconf->pinmux_flag == index) {
+               BLPR("pinmux %s is already selected\n",
+                       bl_pinmux_str[index]);
+               return;
+       }
+
        /* request pwm pinmux */
        bconf->pin = devm_pinctrl_get_select(bl_drv->dev, bl_pinmux_str[index]);
        if (IS_ERR(bconf->pin)) {
-               BLERR("set %s pinmux error\n", bl_pinmux_str[index]);
+               BLERR("set pinmux %s error\n", bl_pinmux_str[index]);
        } else {
                if (bl_debug_print_flag) {
-                       BLPR("request %s pinmux: %p\n",
+                       BLPR("set pinmux %s: %p\n",
                                bl_pinmux_str[index], bconf->pin);
                }
        }
+       bconf->pinmux_flag = index;
 }
 
 /* ****************************************************** */
@@ -678,9 +697,11 @@ static void bl_power_on(void)
                                msleep(bconf->pwm_on_delay);
                        /* step 2: power on pwm */
                        bl_pwm_ctrl(bconf->bl_pwm, 1);
+                       bl_pwm_pinmux_set(bconf, 1);
                } else {
                        /* step 1: power on pwm */
                        bl_pwm_ctrl(bconf->bl_pwm, 1);
+                       bl_pwm_pinmux_set(bconf, 1);
                        if (bconf->pwm_on_delay > 0)
                                msleep(bconf->pwm_on_delay);
                        /* step 2: power on enable */
@@ -696,10 +717,12 @@ static void bl_power_on(void)
                        /* step 2: power on pwm_combo */
                        bl_pwm_ctrl(bconf->bl_pwm_combo0, 1);
                        bl_pwm_ctrl(bconf->bl_pwm_combo1, 1);
+                       bl_pwm_pinmux_set(bconf, 1);
                } else {
                        /* step 1: power on pwm_combo */
                        bl_pwm_ctrl(bconf->bl_pwm_combo0, 1);
                        bl_pwm_ctrl(bconf->bl_pwm_combo1, 1);
+                       bl_pwm_pinmux_set(bconf, 1);
                        if (bconf->pwm_on_delay > 0)
                                msleep(bconf->pwm_on_delay);
                        /* step 2: power on enable */
@@ -809,6 +832,7 @@ static void bl_power_off(void)
        case BL_CTRL_PWM:
                if (bconf->en_sequence_reverse) {
                        /* step 1: power off pwm */
+                       bl_pwm_pinmux_set(bconf, 0);
                        bl_pwm_ctrl(bconf->bl_pwm, 0);
                        if (bconf->pwm_off_delay > 0)
                                msleep(bconf->pwm_off_delay);
@@ -820,12 +844,14 @@ static void bl_power_off(void)
                        /* step 2: power off pwm */
                        if (bconf->pwm_off_delay > 0)
                                msleep(bconf->pwm_off_delay);
+                       bl_pwm_pinmux_set(bconf, 0);
                        bl_pwm_ctrl(bconf->bl_pwm, 0);
                }
                break;
        case BL_CTRL_PWM_COMBO:
                if (bconf->en_sequence_reverse) {
                        /* step 1: power off pwm_combo */
+                       bl_pwm_pinmux_set(bconf, 0);
                        bl_pwm_ctrl(bconf->bl_pwm_combo0, 0);
                        bl_pwm_ctrl(bconf->bl_pwm_combo1, 0);
                        if (bconf->pwm_off_delay > 0)
@@ -838,6 +864,7 @@ static void bl_power_off(void)
                        /* step 2: power off pwm_combo */
                        if (bconf->pwm_off_delay > 0)
                                msleep(bconf->pwm_off_delay);
+                       bl_pwm_pinmux_set(bconf, 0);
                        bl_pwm_ctrl(bconf->bl_pwm_combo0, 0);
                        bl_pwm_ctrl(bconf->bl_pwm_combo1, 0);
                }
@@ -2136,7 +2163,6 @@ static int aml_bl_config_load(struct bl_config_s *bconf,
        case BL_CTRL_PWM:
        case BL_CTRL_PWM_COMBO:
                ret = aml_bl_pwm_channel_register(bconf, pdev->dev.of_node);
-               bl_pwm_pinmux_set(bconf);
                break;
 #ifdef CONFIG_AMLOGIC_BL_EXTERN
        case BL_CTRL_EXTERN:
@@ -3259,6 +3285,8 @@ static void aml_bl_init_status_update(void)
                aml_bl_set_level(bl_on_level);
        else
                aml_bl_update_status(bl_drv->bldev);
+
+       bl_pwm_pinmux_set(bl_drv->bconf, 1);
 }
 
 static int aml_bl_probe(struct platform_device *pdev)
@@ -3266,7 +3294,6 @@ static int aml_bl_probe(struct platform_device *pdev)
        const struct of_device_id *match;
        struct backlight_properties props;
        struct backlight_device *bldev;
-       struct bl_config_s *bconf;
        int ret;
 
 #ifdef AML_BACKLIGHT_DEBUG
@@ -3298,18 +3325,17 @@ static int aml_bl_probe(struct platform_device *pdev)
                bl_drv->data->chip_type,
                bl_drv->data->chip_name);
 
-       bconf = &bl_config;
        bl_drv->dev = &pdev->dev;
-       bl_drv->bconf = bconf;
-       ret = aml_bl_config_load(bconf, pdev);
+       bl_drv->bconf = &bl_config;
+       ret = aml_bl_config_load(bl_drv->bconf, pdev);
        if (ret)
                goto err;
 
        memset(&props, 0, sizeof(struct backlight_properties));
        props.type = BACKLIGHT_RAW;
        props.power = FB_BLANK_UNBLANK; /* full on */
-       props.max_brightness = (bconf->level_max > 0 ?
-                       bconf->level_max : BL_LEVEL_MAX);
+       props.max_brightness = (bl_drv->bconf->level_max > 0 ?
+                       bl_drv->bconf->level_max : BL_LEVEL_MAX);
        props.brightness = bl_on_level;
 
        bldev = backlight_device_register(AML_BL_NAME, &pdev->dev,
index ad81ac4..9009dee 100644 (file)
@@ -44,7 +44,8 @@ static int global_hw_init_on(void)
 {
        struct aml_ldim_driver_s *ldim_drv = aml_ldim_get_driver();
 
-       ldim_drv->pinmux_ctrl(ldim_drv->ldev_conf->pinmux_name);
+       ldim_set_duty_pwm(&(ldim_drv->ldev_conf->pwm_config));
+       ldim_drv->pinmux_ctrl(1);
        mdelay(2);
        ldim_gpio_set(ldim_drv->ldev_conf->en_gpio,
                ldim_drv->ldev_conf->en_gpio_on);
@@ -59,6 +60,7 @@ static int global_hw_init_off(void)
 
        ldim_gpio_set(ldim_drv->ldev_conf->en_gpio,
                ldim_drv->ldev_conf->en_gpio_off);
+       ldim_drv->pinmux_ctrl(0);
        ldim_pwm_off(&(ldim_drv->ldev_conf->pwm_config));
 
        return 0;
index d9cbc5f..2878280 100644 (file)
@@ -225,7 +225,8 @@ static int iw7027_hw_init_on(void)
        iw7027_power_on_init(IW7027_POWER_ON);
 
        /* step 5: supply stable vsync */
-       ldim_drv->pinmux_ctrl(ldim_drv->ldev_conf->pinmux_name);
+       ldim_set_duty_pwm(&(ldim_drv->ldev_conf->pwm_config));
+       ldim_drv->pinmux_ctrl(1);
 
        /* step 6: delay for system clock and light bar PSU stable */
        msleep(520);
@@ -265,6 +266,7 @@ static int iw7027_hw_init_off(void)
 
        ldim_gpio_set(ldim_drv->ldev_conf->en_gpio,
                ldim_drv->ldev_conf->en_gpio_off);
+       ldim_drv->pinmux_ctrl(0);
        ldim_pwm_off(&(ldim_drv->ldev_conf->pwm_config));
 
        return 0;
index 491ff07..e7a0456 100644 (file)
@@ -306,51 +306,44 @@ void ldim_pwm_off(struct bl_pwm_config_s *bl_pwm)
 static char *ldim_pinmux_str[] = {
        "ldim_pwm",               /* 0 */
        "ldim_pwm_vs",            /* 1 */
+       "ldim_pwm_off",            /* 1 */
        "none",
 };
 
-/* set ldim pwm_vs */
-static int ldim_pwm_pinmux_ctrl(char *pin_str)
+static int ldim_pwm_pinmux_ctrl(int status)
 {
        struct aml_ldim_driver_s *ldim_drv = aml_ldim_get_driver();
        struct bl_pwm_config_s *bl_pwm;
-       int ret = 0;
+       int ret = 0, index = 0xff;
 
-       if (strcmp(pin_str, "invalid") == 0)
+       if (strcmp(ldim_drv->ldev_conf->pinmux_name, "invalid") == 0)
                return 0;
 
        bl_pwm = &ldim_drv->ldev_conf->pwm_config;
        if (bl_pwm->pwm_port >= BL_PWM_MAX)
                return 0;
 
-       ldim_set_duty_pwm(bl_pwm);
+       if (bl_pwm->pwm_port == BL_PWM_VS)
+               index = (status) ? 1 : 2;
+       else
+               index = (status) ? 0 : 2;
 
-       if (ldim_drv->pinmux_flag)
+       if (ldim_drv->pinmux_flag == index) {
+               LDIMPR("pinmux %s is already selected\n",
+                       ldim_pinmux_str[index]);
                return 0;
+       }
 
        /* request pwm pinmux */
-       if (bl_pwm->pwm_port == BL_PWM_VS) {
-               ldim_drv->pin = devm_pinctrl_get_select(ldim_drv->dev,
-                       ldim_pinmux_str[1]);
-               if (IS_ERR(ldim_drv->pin)) {
-                       LDIMERR("set %s pinmux error\n",
-                               ldim_pinmux_str[1]);
-               } else {
-                       LDIMPR("request %s pinmux: %p\n",
-                               ldim_pinmux_str[1], ldim_drv->pin);
-               }
+       ldim_drv->pin = devm_pinctrl_get_select(ldim_drv->dev,
+               ldim_pinmux_str[index]);
+       if (IS_ERR(ldim_drv->pin)) {
+               LDIMERR("set pinmux %s error\n", ldim_pinmux_str[index]);
        } else {
-               ldim_drv->pin = devm_pinctrl_get_select(ldim_drv->dev,
-                       ldim_pinmux_str[0]);
-               if (IS_ERR(ldim_drv->pin)) {
-                       LDIMERR("set %s pinmux error\n",
-                               ldim_pinmux_str[0]);
-               } else {
-                       LDIMPR("request %s pinmux: %p\n",
-                               ldim_pinmux_str[0], ldim_drv->pin);
-               }
+               LDIMPR("set pinmux %s: %p\n",
+                       ldim_pinmux_str[index], ldim_drv->pin);
        }
-       ldim_drv->pinmux_flag = 1;
+       ldim_drv->pinmux_flag = index;
 
        return ret;
 }
@@ -498,6 +491,10 @@ static void ldim_config_print(void)
                                break;
                        }
                }
+               pr_info("pinmux_flag:        %d\n"
+                       "pinmux_pointer:     0x%p\n",
+                       ldim_drv->pinmux_flag,
+                       ldim_drv->pin);
        } else {
                pr_info("device config is null\n");
        }
@@ -607,9 +604,10 @@ static int ldim_dev_get_config_from_dts(struct device_node *np, int index)
        ret = of_property_read_string(child, "ldim_pwm_pinmux_sel", &str);
        if (ret) {
                LDIMERR("failed to get ldim_pwm_name\n");
-               str = "invalid";
+               strcpy(ldim_dev_config.pinmux_name, "invalid");
+       } else {
+               strcpy(ldim_dev_config.pinmux_name, str);
        }
-       strcpy(ldim_dev_config.pinmux_name, str);
 
        ret = of_property_read_string(child, "ldim_pwm_port", &str);
        if (ret) {
index 87e4735..6c60826 100644 (file)
@@ -1629,7 +1629,6 @@ static void ldim_func_ctrl(unsigned char status)
 static int ldim_on_init(void)
 {
        int ret = 0;
-       struct aml_ldim_driver_s *ldim_drv = aml_ldim_get_driver();
 
        LDIMPR("%s\n", __func__);
 
@@ -1642,7 +1641,7 @@ static int ldim_on_init(void)
        ldim_func_ctrl(0); /* default disable ldim function */
 
        if (ldim_driver.pinmux_ctrl)
-               ldim_driver.pinmux_ctrl(ldim_drv->ldev_conf->pinmux_name);
+               ldim_driver.pinmux_ctrl(1);
        ldim_on_flag = 1;
        ldim_level_update = 1;
 
@@ -1714,7 +1713,7 @@ static struct aml_ldim_driver_s ldim_driver = {
        .valid_flag = 0, /* default invalid, active when bl_ctrl_method=ldim */
        .dev_index = 0xff,
        .static_pic_flag = 0,
-       .pinmux_flag = 0,
+       .pinmux_flag = 0xff,
        .ldim_conf = &ldim_config,
        .ldev_conf = NULL,
        .ldim_matrix_buf = NULL,
index 7f5e91c..0c38412 100644 (file)
@@ -48,7 +48,8 @@ static int ob3350_hw_init_on(void)
                ldim_drv->ldev_conf->en_gpio_on);
        mdelay(2);
 
-       ldim_drv->pinmux_ctrl(ldim_drv->ldev_conf->pinmux_name);
+       ldim_set_duty_pwm(&(ldim_drv->ldev_conf->pwm_config));
+       ldim_drv->pinmux_ctrl(1);
        mdelay(20);
 
        return 0;
@@ -60,6 +61,7 @@ static int ob3350_hw_init_off(void)
 
        ldim_gpio_set(ldim_drv->ldev_conf->en_gpio,
                ldim_drv->ldev_conf->en_gpio_off);
+       ldim_drv->pinmux_ctrl(0);
        ldim_pwm_off(&(ldim_drv->ldev_conf->pwm_config));
 
        return 0;
index 4a4e997..6065410 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
-#include <linux/amlogic/i2c-amlogic.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/amlogic/media/vout/lcd/aml_bl.h>
 #include "bl_extern.h"
 
-unsigned int bl_extern_brightness;
 static struct aml_bl_extern_driver_s bl_extern_driver;
 
 static int bl_extern_set_level(unsigned int level)
 {
-       bl_extern_brightness = level & 0xff;
+       struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
+       unsigned int level_max, level_min;
+       unsigned int dim_max, dim_min;
+       int ret = 0;
+
+       if (bl_drv == NULL)
+               return -1;
+       level_max = bl_drv->bconf->level_max;
+       level_min = bl_drv->bconf->level_min;
+       dim_max = bl_extern_driver.config.dim_max;
+       dim_min = bl_extern_driver.config.dim_min;
+       level = dim_min - ((level - level_min) * (dim_min - dim_max)) /
+                       (level_max - level_min);
+
+       bl_extern_driver.brightness = level;
+       if (bl_extern_driver.status == 0)
+               return 0;
 
        if (bl_extern_driver.device_bri_update)
-               bl_extern_driver.device_bri_update(level);
+               ret = bl_extern_driver.device_bri_update(level);
 
-       return 0;
+       return ret;
 }
 
 static int bl_extern_power_on(void)
@@ -50,10 +64,11 @@ static int bl_extern_power_on(void)
        BLEX("%s\n", __func__);
 
        if (bl_extern_driver.device_power_on)
-               bl_extern_driver.device_power_on();
+               ret = bl_extern_driver.device_power_on();
+       bl_extern_driver.status = 1;
 
        /* restore bl level */
-       bl_extern_set_level(bl_extern_brightness);
+       bl_extern_set_level(bl_extern_driver.brightness);
 
        return ret;
 }
@@ -63,13 +78,16 @@ static int bl_extern_power_off(void)
 
        BLEX("%s\n", __func__);
 
+       bl_extern_driver.status = 0;
        if (bl_extern_driver.device_power_off)
-               bl_extern_driver.device_power_off();
+               ret = bl_extern_driver.device_power_off();
 
        return ret;
 }
 
 static struct aml_bl_extern_driver_s bl_extern_driver = {
+       .status = 0,
+       .brightness = 0,
        .power_on = bl_extern_power_on,
        .power_off = bl_extern_power_off,
        .set_level = bl_extern_set_level,
@@ -98,17 +116,27 @@ static unsigned char bl_extern_get_i2c_bus_str(const char *str)
        unsigned char i2c_bus;
 
        if (strncmp(str, "i2c_bus_ao", 10) == 0)
-               i2c_bus = AML_I2C_MASTER_AO;
+               i2c_bus = BL_EXTERN_I2C_BUS_4;
        else if (strncmp(str, "i2c_bus_a", 9) == 0)
-               i2c_bus = AML_I2C_MASTER_A;
+               i2c_bus = BL_EXTERN_I2C_BUS_0;
        else if (strncmp(str, "i2c_bus_b", 9) == 0)
-               i2c_bus = AML_I2C_MASTER_B;
+               i2c_bus = BL_EXTERN_I2C_BUS_1;
        else if (strncmp(str, "i2c_bus_c", 9) == 0)
-               i2c_bus = AML_I2C_MASTER_C;
+               i2c_bus = BL_EXTERN_I2C_BUS_2;
        else if (strncmp(str, "i2c_bus_d", 9) == 0)
-               i2c_bus = AML_I2C_MASTER_D;
+               i2c_bus = BL_EXTERN_I2C_BUS_3;
+       else if (strncmp(str, "i2c_bus_0", 10) == 0)
+               i2c_bus = BL_EXTERN_I2C_BUS_0;
+       else if (strncmp(str, "i2c_bus_1", 9) == 0)
+               i2c_bus = BL_EXTERN_I2C_BUS_1;
+       else if (strncmp(str, "i2c_bus_2", 9) == 0)
+               i2c_bus = BL_EXTERN_I2C_BUS_2;
+       else if (strncmp(str, "i2c_bus_3", 9) == 0)
+               i2c_bus = BL_EXTERN_I2C_BUS_3;
+       else if (strncmp(str, "i2c_bus_4", 9) == 0)
+               i2c_bus = BL_EXTERN_I2C_BUS_4;
        else {
-               i2c_bus = AML_I2C_MASTER_A;
+               i2c_bus = BL_EXTERN_I2C_BUS_MAX;
                BLEXERR("invalid i2c_bus: %s\n", str);
        }
 
@@ -123,7 +151,7 @@ static void bl_extern_config_print(void)
        BLEX("%s:\n", __func__);
        switch (bl_extern->config.type) {
        case BL_EXTERN_I2C:
-               pr_info("index:     %d\n"
+               pr_info("index:         %d\n"
                        "name:          %s\n"
                        "type:          i2c(%d)\n"
                        "i2c_addr:      0x%02x\n"
@@ -151,7 +179,7 @@ static void bl_extern_config_print(void)
        case BL_EXTERN_SPI:
                break;
        case BL_EXTERN_MIPI:
-               pr_info("index:     %d\n"
+               pr_info("index:         %d\n"
                        "name:          %s\n"
                        "type:          mipi(%d)\n"
                        "dim_min:       %d\n"
@@ -170,38 +198,46 @@ static void bl_extern_config_print(void)
 
 static int bl_extern_config_from_dts(struct device_node *np, int index)
 {
-       char be_propname[20];
+       char propname[20];
        struct device_node *child;
        const char *str;
        unsigned int temp[5], val;
        int ret = 0;
        struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
 
+       ret = of_property_read_string(np, "i2c_bus", &str);
+       if (ret == 0)
+               bl_extern->config.i2c_bus = BL_EXTERN_I2C_BUS_MAX;
+       else
+               bl_extern->config.i2c_bus = bl_extern_get_i2c_bus_str(str);
+
        /* get device config */
-       sprintf(be_propname, "extern_%d", index);
-       BLEX("load: %s\n", be_propname);
-       child = of_get_child_by_name(np, be_propname);
+       sprintf(propname, "extern_%d", index);
+       child = of_get_child_by_name(np, propname);
        if (child == NULL) {
-               BLEXERR("failed to get %s\n", be_propname);
+               BLEXERR("failed to get %s\n", propname);
                return -1;
        }
+       BLEX("load: %s\n", propname);
+
        ret = of_property_read_u32_array(child, "index", &temp[0], 1);
-       if (ret)
+       if (ret) {
                BLEXERR("failed to get index, exit\n");
-       else {
+       else {
                if (temp[0] == index)
                        bl_extern->config.index = temp[0];
                else {
-                       BLEXERR("index not match, exit\n");
+                       BLEXERR("index %d not match, exit\n", index);
                        return -1;
-                       }
                }
+       }
        ret = of_property_read_string(child, "extern_name", &str);
        if (ret) {
                BLEXERR("failed to get bl_extern_name\n");
-               str = "bl_extern_name";
+               strcpy(bl_extern->config.name, "none");
+       } else {
+               strcpy(bl_extern->config.name, str);
        }
-       strcpy(bl_extern->config.name, str);
 
        ret = of_property_read_u32(child, "type", &val);
        if (ret) {
@@ -227,30 +263,23 @@ static int bl_extern_config_from_dts(struct device_node *np, int index)
 
        switch (bl_extern->config.type) {
        case BL_EXTERN_I2C:
+               if (bl_extern->config.i2c_bus >= BL_EXTERN_I2C_BUS_MAX) {
+                       BLEXERR("failed to get i2c_bus\n");
+               } else {
+                       BLEX("%s i2c_bus=%s[%d]\n",
+                               bl_extern->config.name,
+                               str, bl_extern->config.i2c_bus);
+               }
+
                ret = of_property_read_u32(child, "i2c_address", &val);
                if (ret) {
                        BLEXERR("failed to get i2c_address\n");
                } else {
                        bl_extern->config.i2c_addr = (unsigned char)val;
-               }
-               if (lcd_debug_print_flag) {
                        BLEX("%s i2c_address=0x%02x\n",
                                bl_extern->config.name,
                                bl_extern->config.i2c_addr);
                }
-
-               ret = of_property_read_string(child, "i2c_bus", &str);
-               if (ret) {
-                       BLEXERR("failed to get i2c_bus\n");
-               } else {
-                       bl_extern->config.i2c_bus =
-                               bl_extern_get_i2c_bus_str(str);
-               }
-               if (lcd_debug_print_flag) {
-                       BLEX("%s i2c_bus=%s[%d]\n",
-                               bl_extern->config.name, str,
-                               bl_extern->config.i2c_bus);
-               }
                break;
        case BL_EXTERN_SPI:
                break;
@@ -264,30 +293,26 @@ static int bl_extern_config_from_dts(struct device_node *np, int index)
 
 static int bl_extern_add_driver(void)
 {
-       int ret = 0;
+       int ret = -1;
        struct bl_extern_config_s *extconf = &bl_extern_driver.config;
 
        if (strcmp(extconf->name, "i2c_lp8556") == 0) {
 #ifdef CONFIG_AMLOGIC_BL_EXTERN_I2C_LP8556
                ret = i2c_lp8556_probe();
 #endif
-               goto bl_extern_add_driver_next;
        } else if (strcmp(extconf->name, "mipi_lt070me05") == 0) {
 #ifdef CONFIG_AMLOGIC_BL_EXTERN_MIPI_LT070ME05
                ret = mipi_lt070me05_probe();
 #endif
-               goto bl_extern_add_driver_next;
        } else {
                BLEXERR("invalid device name: %s\n", extconf->name);
-               ret = -1;
        }
 
-bl_extern_add_driver_next:
        if (ret) {
                BLEXERR("add device driver failed %s(%d)\n",
                        extconf->name, extconf->index);
        } else {
-               BLEX("add device driver %s(%d)\n",
+               BLEX("add device driver %s(%d) ok\n",
                        extconf->name, extconf->index);
        }
 
@@ -296,30 +321,26 @@ bl_extern_add_driver_next:
 
 static int bl_extern_remove_driver(void)
 {
-       int ret = 0;
+       int ret = -1;
        struct bl_extern_config_s *extconf = &bl_extern_driver.config;
 
        if (strcmp(extconf->name, "i2c_lp8556") == 0) {
 #ifdef CONFIG_AMLOGIC_BL_EXTERN_I2C_LP8556
                ret = i2c_lp8556_remove();
 #endif
-               goto bl_extern_remove_driver_next;
        } else if (strcmp(extconf->name, "mipi_lt070me05") == 0) {
 #ifdef CONFIG_AMLOGIC_BL_EXTERN_MIPI_LT070ME05
                ret = mipi_lt070me05_remove();
 #endif
-               goto bl_extern_remove_driver_next;
        } else {
                BLEXERR("invalid device name: %s\n", extconf->name);
-               ret = -1;
        }
 
-bl_extern_remove_driver_next:
        if (ret) {
                BLEXERR("remove device driver failed %s(%d)\n",
                        extconf->name, extconf->index);
        } else {
-               BLEX("remove device driver %s(%d)\n",
+               BLEX("remove device driver %s(%d) ok\n",
                        extconf->name, extconf->index);
        }
 
@@ -330,8 +351,7 @@ int aml_bl_extern_device_load(int index)
 {
        int ret = 0;
 
-       bl_extern_config_from_dts(bl_extern_driver.dev->of_node,
-               index);
+       bl_extern_config_from_dts(bl_extern_driver.dev->of_node, index);
        bl_extern_add_driver();
        bl_extern_driver.config_print = bl_extern_config_print;
        BLEX("%s OK\n", __func__);
@@ -384,9 +404,6 @@ static int __init aml_bl_extern_init(void)
 {
        int ret;
 
-       if (lcd_debug_print_flag)
-               BLEX("%s\n", __func__);
-
        ret = platform_driver_register(&aml_bl_extern_driver);
        if (ret) {
                BLEXERR("driver register failed\n");
index 4aebb90..29ca493 100644 (file)
 #ifndef _BL_EXTERN_H_
 #define _BL_EXTERN_H_
 #include <linux/of.h>
+#include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/amlogic/aml_gpio_consumer.h>
 #include <linux/pinctrl/consumer.h>
-#include <linux/amlogic/media/vout/lcd/lcd_vout.h>
 
+extern unsigned int bl_debug_print_flag;
 #define BLEX(fmt, args...)     pr_info("bl extern: "fmt"", ## args)
-#define BLEXERR(fmt, args...)    pr_err("bl extern: error: "fmt"", ## args)
+#define BLEXERR(fmt, args...)  pr_err("bl extern: error: "fmt"", ## args)
+
+#define BL_EXTERN_DRIVER       "bl_extern"
+
+struct aml_bl_extern_i2c_dev_s {
+       char name[20];
+       struct i2c_client *client;
+};
+
+extern struct aml_bl_extern_i2c_dev_s *aml_bl_extern_i2c_get_dev(void);
+
+extern int bl_extern_i2c_write(struct i2c_client *i2client,
+               unsigned char *buff, unsigned int len);
+extern int bl_extern_i2c_read(struct i2c_client *i2client,
+               unsigned char *buff, unsigned int len);
 
-#define BL_EXTERN_DRIVER               "bl_extern"
 
 #ifdef CONFIG_AMLOGIC_BL_EXTERN_I2C_LP8556
 extern int i2c_lp8556_probe(void);
index e9eb1f0..a312537 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
-#include <linux/amlogic/i2c-amlogic.h>
 #include <linux/amlogic/media/vout/lcd/aml_bl_extern.h>
 #include "bl_extern.h"
 
@@ -30,8 +29,60 @@ struct aml_bl_extern_i2c_dev_s *aml_bl_extern_i2c_get_dev(void)
        return i2c_device;
 }
 
+int bl_extern_i2c_write(struct i2c_client *i2client,
+               unsigned char *buff, unsigned int len)
+{
+       struct i2c_msg msg;
+       int ret = 0;
+
+       if (i2client == NULL) {
+               BLEXERR("i2client is null\n");
+               return -1;
+       }
+
+       msg.addr = i2client->addr;
+       msg.flags = 0;
+       msg.len = len;
+       msg.buf = buff;
+
+       ret = i2c_transfer(i2client->adapter, &msg, 1);
+       if (ret < 0)
+               BLEXERR("i2c write failed [addr 0x%02x]\n", i2client->addr);
+
+       return ret;
+}
+
+int bl_extern_i2c_read(struct i2c_client *i2client,
+               unsigned char *buff, unsigned int len)
+{
+       struct i2c_msg msgs[2];
+       int ret = 0;
+
+       if (i2client == NULL) {
+               BLEXERR("i2client is null\n");
+               return -1;
+       }
+
+       msgs[0].addr = i2client->addr;
+       msgs[0].flags = 0;
+       msgs[0].len = 1;
+       msgs[0].buf = buff;
+       msgs[1].addr = i2client->addr;
+       msgs[1].flags = I2C_M_RD;
+       msgs[1].len = len;
+       msgs[1].buf = buff;
+
+       ret = i2c_transfer(i2client->adapter, msgs, 2);
+       if (ret < 0) {
+               BLEXERR("%s: i2c transfer failed [addr 0x%02x]\n",
+                       __func__, i2client->addr);
+       }
+
+       return ret;
+}
+
 static int bl_extern_i2c_config_from_dts(struct device *dev,
-       struct aml_bl_extern_i2c_dev_s *i2c_device)
+               struct aml_bl_extern_i2c_dev_s *i2c_dev)
 {
        int ret;
        struct device_node *np = dev->of_node;
@@ -39,20 +90,20 @@ static int bl_extern_i2c_config_from_dts(struct device *dev,
 
        ret = of_property_read_string(np, "dev_name", &str);
        if (ret) {
-               BLEXERR("failed to get dev_i2c_name\n");
-               str = "bl_extern_i2c_name";
+               BLEXERR("failed to get dev_name\n");
+               strcpy(i2c_dev->name, "none");
+       } else {
+               strcpy(i2c_dev->name, str);
        }
-       strcpy(i2c_device->name, str);
 
        return 0;
 }
 
 static int aml_bl_extern_i2c_probe(struct i2c_client *client,
-       const struct i2c_device_id *id)
+               const struct i2c_device_id *id)
 {
-       BLEX("I2C Address: 0x%02x", client->addr);
        if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
-               BLEXERR("I2C check functionality failed.");
+               BLEXERR("i2c check functionality failed.");
                return -ENODEV;
        }
 
@@ -63,6 +114,8 @@ static int aml_bl_extern_i2c_probe(struct i2c_client *client,
                return -ENOMEM;
        }
        i2c_device->client = client;
+       BLEX("i2c Address: 0x%02x", i2c_device->client->addr);
+
        bl_extern_i2c_config_from_dts(&client->dev, i2c_device);
 
        return 0;
@@ -84,7 +137,7 @@ static const struct i2c_device_id aml_bl_extern_i2c_id[] = {
 #ifdef CONFIG_OF
 static const struct of_device_id aml_bl_extern_i2c_dt_match[] = {
        {
-               .compatible = "amlogic, bl_extern_i2c",
+               .compatible = "bl_extern, i2c",
        },
        {},
 };
@@ -107,7 +160,7 @@ static int __init aml_bl_extern_i2c_init(void)
 {
        int ret;
 
-       if (lcd_debug_print_flag)
+       if (bl_debug_print_flag)
                BLEX("%s\n", __func__);
 
        ret = i2c_add_driver(&aml_bl_extern_i2c_driver);
index 77e1a2a..c62c0f2 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
-#include <linux/amlogic/i2c-amlogic.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/amlogic/media/vout/lcd/aml_bl_extern.h>
-#include <linux/amlogic/media/vout/lcd/aml_bl.h>
 #include "bl_extern.h"
 
 
-#define BL_EXTERN_INDEX                        0
 #define BL_EXTERN_NAME                 "i2c_lp8556"
 #define BL_EXTERN_TYPE                 BL_EXTERN_I2C
 
-#define BL_EXTERN_CMD_SIZE        4
-
-static unsigned int bl_status;
+static struct bl_extern_config_s *ext_config;
+static struct aml_bl_extern_i2c_dev_s *i2c_dev;
 
+#define BL_EXTERN_CMD_SIZE     4
 static unsigned char init_on_table[] = {
        0x00, 0xa2, 0x20, 0x00,
        0x00, 0xa5, 0x54, 0x00,
@@ -48,42 +45,28 @@ static unsigned char init_on_table[] = {
        0x00, 0xa1, 0xb7, 0x00,
        0x00, 0xa0, 0xff, 0x00,
        0x00, 0x00, 0x80, 0x00,
-       0xff, 0x00, 0x00, 0x00, //ending
+       0xff, 0x00, 0x00, 0x00, /*ending*/
 };
 
 static unsigned char init_off_table[] = {
-       0xff, 0x00, 0x00, 0x00, //ending
+       0xff, 0x00, 0x00, 0x00, /*ending*/
 };
 
-static int i2c_lp8556_write(struct i2c_client *i2client,
-               unsigned char *buff, unsigned int len)
-{
-       int ret = 0;
-       struct i2c_msg msg[] = {
-               {
-                       .addr = i2client->addr,
-                       .flags = 0,
-                       .len = len,
-                       .buf = buff,
-               }
-       };
-       BLEX("%s\n", __func__);
-
-       ret = i2c_transfer(i2client->adapter, msg, 1);
-       if (ret < 0)
-               BLEXERR("i2c write failed [addr 0x%02x]\n", i2client->addr);
-
-       return ret;
-}
-
 static int i2c_lp8556_power_cmd(unsigned char *init_table)
 {
        int i = 0, len;
        int ret = 0;
-       struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
-       struct aml_bl_extern_i2c_dev_s *i2c_dev = aml_bl_extern_i2c_get_dev();
+
 
        BLEX("%s\n", __func__);
+       if (ext_config == NULL) {
+               BLEXERR("invalid ext_config\n");
+               return -1;
+       }
+       if (i2c_dev == NULL) {
+               BLEXERR("invalid i2c device\n");
+               return -1;
+       }
 
        len = BL_EXTERN_CMD_SIZE;
        while (i <= BL_EXTERN_INIT_TABLE_MAX) {
@@ -92,16 +75,12 @@ static int i2c_lp8556_power_cmd(unsigned char *init_table)
                } else if (init_table[i] == BL_EXTERN_INIT_NONE) {
                        /* do nothing, only for delay */
                } else if (init_table[i] == BL_EXTERN_INIT_CMD) {
-                       if (i2c_dev == NULL) {
-                               BLEXERR("invalid i2c device\n");
-                               return -1;
-                       }
-                       ret = i2c_lp8556_write(i2c_dev->client,
+                       ret = bl_extern_i2c_write(i2c_dev->client,
                                &init_table[i+1], (len-2));
                } else {
-                       BLEXERR("%s(%d: %s): power_type %d is invalid\n",
-                               __func__, bl_extern->config.index,
-                               bl_extern->config.name, bl_extern->config.type);
+                       BLEXERR("%s: %s(%d): power_type %d is invalid\n",
+                               __func__, ext_config->name,
+                               ext_config->index, ext_config->type);
                }
                if (init_table[i+len-1] > 0)
                        mdelay(init_table[i+len-1]);
@@ -114,71 +93,56 @@ static int i2c_lp8556_power_cmd(unsigned char *init_table)
 static int i2c_lp8556_power_ctrl(int flag)
 {
        int ret = 0;
-       struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
+
        BLEX("%s\n", __func__);
 
+       if (ext_config == NULL) {
+               BLEXERR("invalid ext_config\n");
+               return -1;
+       }
+
        if (flag)
                ret = i2c_lp8556_power_cmd(init_on_table);
        else
                ret = i2c_lp8556_power_cmd(init_off_table);
 
-       BLEX("%s(%d: %s): %d\n",
-               __func__, bl_extern->config.index,
-               bl_extern->config.name, flag);
+       BLEX("%s: %s(%d): %d\n",
+               __func__, ext_config->name, ext_config->index, flag);
        return ret;
 }
 
 static int i2c_lp8556_power_on(void)
 {
        int ret;
+
        BLEX("%s\n", __func__);
 
-       bl_status = 1;
        ret = i2c_lp8556_power_ctrl(1);
 
        return ret;
-
 }
 
 static int i2c_lp8556_power_off(void)
 {
        int ret;
 
-       bl_status = 0;
        ret = i2c_lp8556_power_ctrl(0);
        return ret;
-
 }
 
 static int i2c_lp8556_set_level(unsigned int level)
 {
        unsigned char tData[3];
        int ret = 0;
-       struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
-       struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
-       struct aml_bl_extern_i2c_dev_s *i2c_dev = aml_bl_extern_i2c_get_dev();
-       unsigned int level_max, level_min;
-       unsigned int dim_max, dim_min;
-
-       if (bl_drv == NULL)
-               return -1;
-       level_max = bl_drv->bconf->level_max;
-       level_min = bl_drv->bconf->level_min;
-       dim_max = bl_extern->config.dim_max;
-       dim_min = bl_extern->config.dim_min;
-       level = dim_min - ((level - level_min) * (dim_min - dim_max)) /
-                       (level_max - level_min);
-       level &= 0xff;
 
        if (i2c_dev == NULL) {
                BLEXERR("invalid i2c device\n");
                return -1;
        }
-       if (bl_status) {
-               tData[0] = 0x0;
-               tData[1] = level;
-               ret = i2c_lp8556_write(i2c_dev->client, tData, 2);
-       }
+
+       tData[0] = 0x0;
+       tData[1] = level & 0xff;
+       ret = bl_extern_i2c_write(i2c_dev->client, tData, 2);
        return ret;
 }
 
@@ -191,11 +155,8 @@ static int i2c_lp8556_update(void)
                return -1;
        }
 
-       if (bl_extern->config.type == BL_EXTERN_MAX) {
-               bl_extern->config.index = BL_EXTERN_INDEX;
-               bl_extern->config.type = BL_EXTERN_TYPE;
-               strcpy(bl_extern->config.name, BL_EXTERN_NAME);
-       }
+       ext_config = &bl_extern->config;
+       i2c_dev = aml_bl_extern_i2c_get_dev();
 
        bl_extern->device_power_on = i2c_lp8556_power_on;
        bl_extern->device_power_off = i2c_lp8556_power_off;
index 5374b55..1dce058 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
-#include <linux/amlogic/i2c-amlogic.h>
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/amlogic/media/vout/lcd/aml_bl_extern.h>
-#include <linux/amlogic/media/vout/lcd/aml_bl.h>
 #include "bl_extern.h"
 
 
-#define BL_EXTERN_INDEX                        1
 #define BL_EXTERN_NAME                 "mipi_lt070me05"
 #define BL_EXTERN_TYPE                 BL_EXTERN_MIPI
 
-
-static unsigned int bl_status;
-
 static int mipi_lt070me05_power_on(void)
 {
-       bl_status = 1;
-
        return 0;
 }
 
 static int mipi_lt070me05_power_off(void)
 {
-       bl_status = 0;
-
        return 0;
 }
 
@@ -58,27 +48,12 @@ static int mipi_lt070me05_power_off(void)
 static int mipi_lt070me05_set_level(unsigned int level)
 {
        unsigned char payload[] = {0x15, 2, 0x51, 0xe6, 0xff, 0xff};
-       struct aml_bl_drv_s *bl_drv = aml_bl_get_driver();
-       struct aml_bl_extern_driver_s *bl_extern = aml_bl_extern_get_driver();
-       unsigned int level_max, level_min;
-       unsigned int dim_max, dim_min;
 
-       if (bl_drv == NULL)
-               return -1;
-       level_max = bl_drv->bconf->level_max;
-       level_min = bl_drv->bconf->level_min;
-       dim_max = bl_extern->config.dim_max;
-       dim_min = bl_extern->config.dim_min;
-       level = dim_min - ((level - level_min) * (dim_min - dim_max)) /
-                       (level_max - level_min);
-       level &= 0xff;
-
-       if (bl_status) {
-               payload[3] = level;
+       payload[3] = level & 0xff;
 #ifdef CONFIG_AMLOGIC_LCD_TABLET
-               dsi_write_cmd(&payload[0]);
+       dsi_write_cmd(&payload[0]);
 #endif
-       }
+
        return 0;
 }
 
@@ -91,12 +66,6 @@ static int mipi_lt070me05_update(void)
                return -1;
        }
 
-       if (bl_extern->config.type == BL_EXTERN_MAX) {
-               bl_extern->config.index = BL_EXTERN_INDEX;
-               bl_extern->config.type = BL_EXTERN_TYPE;
-               strcpy(bl_extern->config.name, BL_EXTERN_NAME);
-       }
-
        bl_extern->device_power_on = mipi_lt070me05_power_on;
        bl_extern->device_power_off = mipi_lt070me05_power_off;
        bl_extern->device_bri_update = mipi_lt070me05_set_level;
index 7609289..54124b6 100644 (file)
@@ -259,7 +259,7 @@ unsigned int lcd_cpu_gpio_get(unsigned int index)
        return gpiod_get_value(cpu_gpio->gpio);
 }
 
-const char *lcd_ttl_pinmux_str[] = {
+static char *lcd_ttl_pinmux_str[] = {
        "ttl_6bit_hvsync_on",      /* 0 */
        "ttl_6bit_de_on",          /* 1 */
        "ttl_6bit_hvsync_de_on",   /* 2 */
@@ -274,93 +274,91 @@ void lcd_ttl_pinmux_set(int status)
 {
        struct aml_lcd_drv_s *lcd_drv = aml_lcd_get_driver();
        struct lcd_config_s *pconf;
-       unsigned int index, num;
+       unsigned int base, index;
 
        if (lcd_debug_print_flag)
                LCDPR("%s: %d\n", __func__, status);
 
        pconf = lcd_drv->lcd_config;
        if (pconf->lcd_basic.lcd_bits == 6)
-               index = 0;
+               base = 0;
        else
-               index = 4;
+               base = 4;
 
        if (status) {
-               if (pconf->pinmux_flag == 0) {
-                       pconf->pinmux_flag = 1;
-                       switch (pconf->lcd_control.ttl_config->sync_valid) {
-                       case 1: /* hvsync */
-                               num = index + 0;
-                               break;
-                       case 2: /* DE */
-                               num = index + 1;
-                               break;
-                       default:
-                       case 3: /* DE + hvsync */
-                               num = index + 2;
-                               break;
-                       }
-               } else {
-                       LCDPR("ttl pinmux is already selected\n");
-                       return;
+               switch (pconf->lcd_control.ttl_config->sync_valid) {
+               case 1: /* hvsync */
+                       index = base + 0;
+                       break;
+               case 2: /* DE */
+                       index = base + 1;
+                       break;
+               default:
+               case 3: /* DE + hvsync */
+                       index = base + 2;
+                       break;
                }
        } else {
-               if (pconf->pinmux_flag) {
-                       pconf->pinmux_flag = 0;
-                       num = index + 3;
-               } else {
-                       LCDPR("ttl pinmux is already released\n");
-                       return;
-               }
+               index = base + 3;
+       }
+
+       if (pconf->pinmux_flag == index) {
+               LCDPR("pinmux %s is already selected\n",
+                       lcd_ttl_pinmux_str[index]);
+               return;
        }
 
        /* request pinmux */
        pconf->pin = devm_pinctrl_get_select(lcd_drv->dev,
-               lcd_ttl_pinmux_str[num]);
+               lcd_ttl_pinmux_str[index]);
        if (IS_ERR(pconf->pin))
-               LCDERR("set ttl pinmux error\n");
+               LCDERR("set ttl pinmux %s error\n", lcd_ttl_pinmux_str[index]);
+       else {
+               if (lcd_debug_print_flag) {
+                       LCDPR("set ttl pinmux %s: %p\n",
+                               lcd_ttl_pinmux_str[index], pconf->pin);
+               }
+       }
+       pconf->pinmux_flag = index;
 }
 
+static char *lcd_vbyone_pinmux_str[] = {
+       "vbyone",
+       "vbyone_off",
+       "none",
+};
+
 /* set VX1_LOCKN && VX1_HTPDN */
 void lcd_vbyone_pinmux_set(int status)
 {
        struct aml_lcd_drv_s *lcd_drv = aml_lcd_get_driver();
        struct lcd_config_s *pconf;
+       unsigned int index;
 
        if (lcd_debug_print_flag)
                LCDPR("%s: %d\n", __func__, status);
 
-#if 1
        pconf = lcd_drv->lcd_config;
-       if (status) {
-               if (pconf->pinmux_flag == 0) {
-                       pconf->pinmux_flag = 1;
-                       /* request pinmux */
-                       pconf->pin = devm_pinctrl_get_select(lcd_drv->dev,
-                               "vbyone");
-                       if (IS_ERR(pconf->pin))
-                               LCDERR("set vbyone pinmux error\n");
-               } else {
-                       LCDPR("vbyone pinmux is already selected\n");
-               }
-       } else {
-               if (pconf->pinmux_flag) {
-                       pconf->pinmux_flag = 0;
-                       /* release pinmux */
-                       devm_pinctrl_put(pconf->pin);
-               } else {
-                       LCDPR("vbyone pinmux is already released\n");
-               }
+       index = (status) ? 0 : 1;
+
+       if (pconf->pinmux_flag == index) {
+               LCDPR("pinmux %s is already selected\n",
+                       lcd_vbyone_pinmux_str[index]);
+               return;
        }
-#else
-       if (status) {
-               lcd_pinmux_clr_mask(7,
-                       ((1 << 1) | (1 << 2) | (1 << 9) | (1 << 10)));
-               lcd_pinmux_set_mask(7, ((1 << 11) | (1 << 12)));
+
+       pconf->pin = devm_pinctrl_get_select(lcd_drv->dev,
+               lcd_vbyone_pinmux_str[index]);
+       if (IS_ERR(pconf->pin)) {
+               LCDERR("set vbyone pinmux %s error\n",
+                       lcd_vbyone_pinmux_str[index]);
        } else {
-               lcd_pinmux_clr_mask(7, ((1 << 11) | (1 << 12)));
+               if (lcd_debug_print_flag) {
+                       LCDPR("set vbyone pinmux %s: %p\n",
+                               lcd_vbyone_pinmux_str[index], pconf->pin);
+               }
        }
-#endif
+       pconf->pinmux_flag = index;
 }
 
 unsigned int lcd_lvds_channel_on_value(struct lcd_config_s *pconf)
index 32c2224..20e343f 100644 (file)
@@ -30,7 +30,8 @@
 /* 20180620: fix coverity errors */
 /* 20180626: txl suuport */
 /* 20180718: mute: wait vsync for display shadow */
-#define LCD_DRV_VERSION    "20180718"
+/* 20180827: add pinmux off support */
+#define LCD_DRV_VERSION    "20180827"
 
 #define VPP_OUT_SATURATE            (1 << 0)
 
index 2711e3f..45a5ecb 100644 (file)
@@ -343,6 +343,12 @@ static int lcd_info_print(char *buf, int offset)
                        ((pconf->lcd_control.ttl_config->sync_valid >> 1) & 1),
                        ((pconf->lcd_control.ttl_config->swap_ctrl >> 1) & 1),
                        ((pconf->lcd_control.ttl_config->swap_ctrl >> 0) & 1));
+
+               len += snprintf((buf+len), n,
+                       "pinmux_flag     %d\n"
+                       "pinmux_pointer  0x%p\n\n",
+                       pconf->pinmux_flag,
+                       pconf->pin);
                break;
        case LCD_LVDS:
                n = lcd_debug_info_len(len + offset);
@@ -414,6 +420,12 @@ static int lcd_info_print(char *buf, int offset)
                                ((vx1_conf->ctrl_flag >> 2) & 0x1),
                                vx1_conf->cdr_training_hold);
                }
+
+               len += snprintf((buf+len), n,
+                       "pinmux_flag          %d\n"
+                       "pinmux_pointer       0x%p\n\n",
+                       pconf->pinmux_flag,
+                       pconf->pin);
                break;
        case LCD_MIPI:
 #ifdef CONFIG_AMLOGIC_LCD_TABLET
index 5821417..ee25a68 100644 (file)
@@ -236,9 +236,9 @@ static int lcd_extern_power_cmd_dynamic_size(unsigned char *init_table,
                                if (init_table[i+cmd_size+1] > 0)
                                        mdelay(init_table[i+cmd_size+1]);
                        } else {
-                               EXTERR("%s(%d: %s): type %d invalid\n",
-                                       __func__, ext_config->index,
-                                       ext_config->name, ext_config->type);
+                               EXTERR("%s: %s(%d): type %d invalid\n",
+                                       __func__, ext_config->name,
+                                       ext_config->index, ext_config->type);
                        }
                        i += (cmd_size + 2);
                        step++;
@@ -289,18 +289,18 @@ static int lcd_extern_power_cmd_dynamic_size(unsigned char *init_table,
                                if (init_table[i+cmd_size+1] > 0)
                                        mdelay(init_table[i+cmd_size+1]);
                        } else {
-                               EXTERR("%s(%d: %s): type %d invalid\n",
-                                       __func__, ext_config->index,
-                                       ext_config->name, ext_config->type);
+                               EXTERR("%s: %s(%d): type %d invalid\n",
+                                       __func__, ext_config->name,
+                                       ext_config->index, ext_config->type);
                        }
                        i += (cmd_size + 2);
                        step++;
                }
                break;
        default:
-               EXTERR("%s(%d: %s): extern_type %d is not support\n",
-                       __func__, ext_config->index,
-                       ext_config->name, ext_config->type);
+               EXTERR("%s: %s(%d): extern_type %d is not support\n",
+                       __func__, ext_config->name,
+                       ext_config->index, ext_config->type);
                break;
        }
 
@@ -351,9 +351,9 @@ static int lcd_extern_power_cmd_fixed_size(unsigned char *init_table, int flag)
                                ret = lcd_extern_i2c_write(i2c1_dev->client,
                                        &init_table[i+1], (cmd_size-2));
                        } else {
-                               EXTERR("%s(%d: %s): type %d invalid\n",
-                                       __func__, ext_config->index,
-                                       ext_config->name, ext_config->type);
+                               EXTERR("%s: %s(%d): type %d invalid\n",
+                                       __func__, ext_config->name,
+                                       ext_config->index, ext_config->type);
                        }
                        if (init_table[i+cmd_size-1] > 0)
                                mdelay(init_table[i+cmd_size-1]);
@@ -381,9 +381,9 @@ static int lcd_extern_power_cmd_fixed_size(unsigned char *init_table, int flag)
                                ret = lcd_extern_spi_write(&init_table[i+1],
                                        (cmd_size-2));
                        } else {
-                               EXTERR("%s(%d: %s): type %d invalid\n",
-                                       __func__, ext_config->index,
-                                       ext_config->name, ext_config->type);
+                               EXTERR("%s: %s(%d): type %d invalid\n",
+                                       __func__, ext_config->name,
+                                       ext_config->index, ext_config->type);
                        }
                        if (init_table[i+cmd_size-1] > 0)
                                mdelay(init_table[i+cmd_size-1]);
@@ -392,20 +392,28 @@ static int lcd_extern_power_cmd_fixed_size(unsigned char *init_table, int flag)
                }
                break;
        default:
-               EXTERR("%s(%d: %s): extern_type %d is not support\n",
-                       __func__, ext_config->index,
-                       ext_config->name, ext_config->type);
+               EXTERR("%s: %s(%d): extern_type %d is not support\n",
+                       __func__, ext_config->name,
+                       ext_config->index, ext_config->type);
                break;
        }
 
        return ret;
 }
 
-static int lcd_extern_power_cmd(unsigned char *init_table, int flag)
+static int lcd_extern_power_ctrl(int flag)
 {
+       unsigned char *init_table;
        unsigned char cmd_size;
        int ret = 0;
 
+       if (ext_config->type == LCD_EXTERN_SPI)
+               spi_gpio_init();
+
+       if (flag)
+               init_table = ext_config->table_init_on;
+       else
+               init_table = ext_config->table_init_off;
        cmd_size = ext_config->cmd_size;
        if (cmd_size < 1) {
                EXTERR("%s: cmd_size %d is invalid\n", __func__, cmd_size);
@@ -421,26 +429,11 @@ static int lcd_extern_power_cmd(unsigned char *init_table, int flag)
        else
                ret = lcd_extern_power_cmd_fixed_size(init_table, flag);
 
-       return ret;
-}
-
-static int lcd_extern_power_ctrl(int flag)
-{
-       int ret = 0;
-
-       if (ext_config->type == LCD_EXTERN_SPI)
-               spi_gpio_init();
-
-       if (flag)
-               ret = lcd_extern_power_cmd(ext_config->table_init_on, 1);
-       else
-               ret = lcd_extern_power_cmd(ext_config->table_init_off, 0);
-
        if (ext_config->type == LCD_EXTERN_SPI)
                spi_gpio_off();
 
-       EXTPR("%s(%d: %s): %d\n",
-               __func__, ext_config->index, ext_config->name, flag);
+       EXTPR("%s: %s(%d): %d\n",
+               __func__, ext_config->name, ext_config->index, flag);
        return ret;
 }
 
index d6e86c7..3f0b5ec 100644 (file)
@@ -58,6 +58,7 @@ static struct lcd_extern_config_s lcd_extern_config = {
        .type = LCD_EXTERN_MAX,
        .status = 0,
        .pinmux_valid = 0,
+       .pinmux_gpio_off = 2,
        .key_valid = 0,
        .addr_sel = 0,
 
@@ -65,9 +66,7 @@ static struct lcd_extern_config_s lcd_extern_config = {
        .i2c_addr2 = LCD_EXTERN_I2C_ADDR_INVALID,
        .i2c_bus = LCD_EXTERN_I2C_BUS_INVALID,
        .i2c_sck_gpio = LCD_EXTERN_GPIO_NUM_MAX,
-       .i2c_sck_gpio_off = 2,
        .i2c_sda_gpio = LCD_EXTERN_GPIO_NUM_MAX,
-       .i2c_sda_gpio_off = 2,
 
        .spi_gpio_cs = LCD_EXTERN_GPIO_NUM_MAX,
        .spi_gpio_clk = LCD_EXTERN_GPIO_NUM_MAX,
@@ -289,45 +288,56 @@ unsigned int lcd_extern_gpio_get(unsigned char index)
        return gpiod_get_value(ext_gpio->gpio);
 }
 
+#define LCD_EXTERN_PINMUX_MAX    3
+static char *lcd_extern_pinmux_str[LCD_EXTERN_PINMUX_MAX] = {
+       "extern_on",   /* 0 */
+       "extern_off",  /* 1 */
+       "none",
+};
+
 void lcd_extern_pinmux_set(int status)
 {
-       /* kernel4.9 can't release pins */
+       int index = 0xff;
+
        if (lcd_ext_driver == NULL)
                return;
 
        if (lcd_ext_driver->config->pinmux_valid == 0) {
-               if (lcd_debug_print_flag) {
-                       EXTPR("%s: pinmux_valid %d, bypass\n",
-                               __func__, lcd_ext_driver->config->pinmux_valid);
-               }
+               if (lcd_debug_print_flag)
+                       EXTPR("%s: pinmux invalid, bypass\n", __func__);
                return;
        }
 
        if (lcd_debug_print_flag)
                EXTPR("%s: %d\n", __func__, status);
 
-       if (status) {
-               /* release gpio */
-               if (lcd_ext_driver->pinmux_flag) {
-                       EXTPR("drv_index %d pinmux is already selected\n",
-                               lcd_ext_driver->config->index);
-                       return;
-               }
+       index = (status) ? 0 : 1;
 
-               /* request pinmux */
-               lcd_ext_driver->pin = devm_pinctrl_get_select(lcd_extern_dev,
-                       "extern_pins");
-               if (IS_ERR(lcd_ext_driver->pin)) {
-                       EXTERR("set drv_index %d pinmux error\n",
-                               lcd_ext_driver->config->index);
-               } else {
-                       if (lcd_debug_print_flag) {
-                               EXTPR("set drv_index %d pinmux ok\n",
-                                       lcd_ext_driver->config->index);
-                       }
+       if (lcd_ext_driver->pinmux_flag == index) {
+               EXTPR("%s(%d) pinmux %s is already selected\n",
+                       lcd_ext_driver->config->name,
+                       lcd_ext_driver->config->index,
+                       lcd_extern_pinmux_str[index]);
+               return;
+       }
+
+       /* request pinmux */
+       lcd_ext_driver->pin = devm_pinctrl_get_select(lcd_extern_dev,
+               lcd_extern_pinmux_str[index]);
+       if (IS_ERR(lcd_ext_driver->pin)) {
+               EXTERR("set %s(%d) pinmux %s error\n",
+                       lcd_ext_driver->config->name,
+                       lcd_ext_driver->config->index,
+                       lcd_extern_pinmux_str[index]);
+       } else {
+               if (lcd_debug_print_flag) {
+                       EXTPR("set %s(%d) pinmux %s ok\n",
+                               lcd_ext_driver->config->name,
+                               lcd_ext_driver->config->index,
+                               lcd_extern_pinmux_str[index]);
                }
-               lcd_ext_driver->pinmux_flag = 1;
        }
+       lcd_ext_driver->pinmux_flag = index;
 }
 
 #ifdef CONFIG_OF
@@ -1358,19 +1368,13 @@ static int lcd_extern_get_config(void)
                lcd_extern_config.i2c_bus = lcd_extern_get_i2c_bus_str(str);
 
        ret = of_property_read_u32_array(lcd_extern_dev->of_node,
-                       "i2c_gpio_off", &extern_para[0], 4);
+                       "i2c_gpio", &extern_para[0], 2);
        if (ret) {
                lcd_extern_config.i2c_sck_gpio = LCD_EXTERN_GPIO_NUM_MAX;
-               lcd_extern_config.i2c_sck_gpio_off = 2;
                lcd_extern_config.i2c_sda_gpio = LCD_EXTERN_GPIO_NUM_MAX;
-               lcd_extern_config.i2c_sda_gpio_off = 2;
        } else {
                lcd_extern_config.i2c_sck_gpio = (unsigned char)extern_para[0];
-               lcd_extern_config.i2c_sck_gpio_off =
-                       (unsigned char) extern_para[1];
-               lcd_extern_config.i2c_sda_gpio = (unsigned char)extern_para[2];
-               lcd_extern_config.i2c_sda_gpio_off =
-                       (unsigned char)extern_para[3];
+               lcd_extern_config.i2c_sda_gpio = (unsigned char)extern_para[1];
        }
 
        ret = of_property_read_string(lcd_extern_dev->of_node,
@@ -1381,6 +1385,15 @@ static int lcd_extern_get_config(void)
                lcd_extern_config.pinmux_valid = 1;
 
        ret = of_property_read_u32(lcd_extern_dev->of_node,
+                       "pinctrl_gpio_off", &extern_para[0]);
+       if (ret) {
+               lcd_extern_config.pinmux_gpio_off = 2;
+       } else {
+               lcd_extern_config.pinmux_gpio_off =
+                       (unsigned char)extern_para[0];
+       }
+
+       ret = of_property_read_u32(lcd_extern_dev->of_node,
                        "key_valid", &extern_para[0]);
        if (ret) {
                if (lcd_debug_print_flag)
@@ -1539,7 +1552,7 @@ static int lcd_extern_add_driver(struct lcd_extern_config_s *extconf)
        ext_drv = lcd_ext_driver;
 
        ext_drv->config = extconf;
-       ext_drv->pinmux_flag = 0;
+       ext_drv->pinmux_flag = 0xff;
 
        switch (ext_drv->config->type) {
        case LCD_EXTERN_I2C:
@@ -1791,6 +1804,10 @@ static ssize_t lcd_extern_info_show(struct class *class,
                pr_info("not support extern_type\n");
                break;
        }
+       if (econf->pinmux_valid) {
+               pr_info("pinmux_flag:     %d\n", lcd_ext_driver->pinmux_flag);
+               pr_info("pinmux_pointer:  0x%p\n", lcd_ext_driver->pin);
+       }
 
        return sprintf(buf, "\n");
 }
index 7a7c80b..a1adffb 100644 (file)
@@ -191,7 +191,7 @@ static struct lcd_config_s lcd_config_dft = {
                .mipi_config = &lcd_mipi_config,
        },
        .lcd_power = &lcd_power_config,
-       .pinmux_flag = 0,
+       .pinmux_flag = 0xff,
        .change_flag = 0,
        .retry_enable_flag = 0,
        .retry_enable_cnt = 0,
index 5a6b489..a5dd373 100644 (file)
@@ -26,11 +26,11 @@ enum bl_extern_type_e {
 };
 
 enum bl_extern_i2c_bus_e {
-       BL_EXTERN_I2C_BUS_AO = 0,
-       BL_EXTERN_I2C_BUS_A,
-       BL_EXTERN_I2C_BUS_B,
-       BL_EXTERN_I2C_BUS_C,
-       BL_EXTERN_I2C_BUS_D,
+       BL_EXTERN_I2C_BUS_0 = 0,
+       BL_EXTERN_I2C_BUS_1,
+       BL_EXTERN_I2C_BUS_2,
+       BL_EXTERN_I2C_BUS_3,
+       BL_EXTERN_I2C_BUS_4,
        BL_EXTERN_I2C_BUS_MAX,
 };
 #define BL_EXTERN_I2C_BUS_INVALID   0xff
@@ -59,8 +59,9 @@ struct bl_extern_config_s {
 };
 
 /* global API */
-#define BL_EXT_DRIVER_MAX    10
 struct aml_bl_extern_driver_s {
+       unsigned char status;
+       unsigned int brightness;
        int (*power_on)(void);
        int (*power_off)(void);
        int (*set_level)(unsigned int level);
@@ -72,12 +73,6 @@ struct aml_bl_extern_driver_s {
        struct device *dev;
 };
 
-struct aml_bl_extern_i2c_dev_s {
-       char name[20];
-       struct i2c_client *client;
-};
-
-extern struct aml_bl_extern_i2c_dev_s *aml_bl_extern_i2c_get_dev(void);
 extern struct aml_bl_extern_driver_s *aml_bl_extern_get_driver(void);
 extern int aml_bl_extern_device_load(int index);
 
index 6852f7c..0ccc27f 100644 (file)
@@ -120,7 +120,7 @@ struct aml_ldim_driver_s {
        int (*power_on)(void);
        int (*power_off)(void);
        int (*set_level)(unsigned int level);
-       int (*pinmux_ctrl)(char *pin_str);
+       int (*pinmux_ctrl)(int status);
        int (*pwm_vs_update)(void);
        int (*device_power_on)(void);
        int (*device_power_off)(void);
index c341dff..76edb60 100644 (file)
@@ -58,6 +58,7 @@ struct lcd_extern_config_s {
        enum lcd_extern_type_e type;
        unsigned char status;
        unsigned char pinmux_valid;
+       unsigned char pinmux_gpio_off;
        unsigned char key_valid;
        unsigned char addr_sel; /* internal used */
 
@@ -65,9 +66,7 @@ struct lcd_extern_config_s {
        unsigned char i2c_addr2;
        unsigned char i2c_bus;
        unsigned char i2c_sck_gpio;
-       unsigned char i2c_sck_gpio_off;
        unsigned char i2c_sda_gpio;
-       unsigned char i2c_sda_gpio_off;
 
        unsigned char spi_gpio_cs;
        unsigned char spi_gpio_clk;