[U-Boot] [PATCH 1/4] sunxi: video: Add support for LCD reset pin

On some boards there is a gpio to reset the LCD panel, add support for this.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- board/sunxi/Kconfig | 8 ++++++++ drivers/video/sunxi_display.c | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 0226d28..70e6f4d 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -317,6 +317,14 @@ config VIDEO_LCD_POWER Set the power enable pin for the LCD panel. This takes a string in the format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
+config VIDEO_LCD_RESET + string "LCD panel reset pin" + depends on VIDEO + default "" + ---help--- + Set the reset pin for the LCD panel. This takes a string in the format + understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + config VIDEO_LCD_BL_EN string "LCD panel backlight enable pin" depends on VIDEO diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index dbda97e..7f01401 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -592,7 +592,7 @@ static void sunxi_lcdc_enable(void)
static void sunxi_lcdc_panel_enable(void) { - int pin; + int pin, reset_pin;
/* * Start with backlight disabled to avoid the screen flashing to @@ -610,6 +610,12 @@ static void sunxi_lcdc_panel_enable(void) gpio_direction_output(pin, PWM_OFF); }
+ reset_pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_RESET); + if (reset_pin != -1) { + gpio_request(reset_pin, "lcd_reset"); + gpio_direction_output(reset_pin, 0); /* Assert reset */ + } + /* Give the backlight some time to turn off and power up the panel. */ mdelay(40); pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_POWER); @@ -617,6 +623,9 @@ static void sunxi_lcdc_panel_enable(void) gpio_request(pin, "lcd_power"); gpio_direction_output(pin, 1); } + + if (reset_pin != -1) + gpio_direction_output(reset_pin, 1); /* De-assert reset */ }
static void sunxi_lcdc_backlight_enable(void)

This commits adds support for configuring a a bitbang i2c controller, which is used on some boards to configure the LCD panel (via i2c).
Signed-off-by: Hans de Goede hdegoede@redhat.com --- board/sunxi/Kconfig | 24 ++++++++++++++++++++++++ board/sunxi/board.c | 10 ++++++++++ include/configs/sunxi-common.h | 16 ++++++++++++++++ 3 files changed, 50 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 70e6f4d..ef59e21 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -349,6 +349,30 @@ config VIDEO_LCD_BL_PWM_ACTIVE_LOW ---help--- Set this if the backlight pwm output is active low.
+config VIDEO_LCD_PANEL_I2C + bool "LCD panel needs to be configured via i2c" + depends on VIDEO + default m + ---help--- + Say y here if the LCD panel needs to be configured via i2c. This + will add a bitbang i2c controller using gpios to talk to the LCD. + +config VIDEO_LCD_PANEL_I2C_SDA + string "LCD panel i2c interface SDA pin" + depends on VIDEO_LCD_PANEL_I2C + default "PG12" + ---help--- + Set the SDA pin for the LCD i2c interface. This takes a string in the + format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + +config VIDEO_LCD_PANEL_I2C_SCL + string "LCD panel i2c interface SCL pin" + depends on VIDEO_LCD_PANEL_I2C + default "PG10" + ---help--- + Set the SCL pin for the LCD i2c interface. This takes a string in the + format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. +
# Note only one of these may be selected at a time! But hidden choices are # not supported by Kconfig diff --git a/board/sunxi/board.c b/board/sunxi/board.c index b70e00c..e1891d1 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -33,6 +33,12 @@ #include <linux/usb/musb.h> #include <net.h>
+#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD) +/* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */ +int soft_i2c_gpio_sda; +int soft_i2c_gpio_scl; +#endif + DECLARE_GLOBAL_DATA_PTR;
/* add board specific code here */ @@ -152,6 +158,10 @@ void i2c_init_board(void) sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUNXI_GPB0_TWI0); sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUNXI_GPB0_TWI0); clock_twi_onoff(0, 1); +#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD) + soft_i2c_gpio_sda = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_PANEL_I2C_SDA); + soft_i2c_gpio_scl = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_PANEL_I2C_SCL); +#endif }
#ifdef CONFIG_SPL_BUILD diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index fa9ac29..dc9a8a8 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -243,6 +243,22 @@ #define CONFIG_SYS_I2C_MVTWSI #define CONFIG_SYS_I2C_SPEED 400000 #define CONFIG_SYS_I2C_SLAVE 0x7f + +#if defined CONFIG_VIDEO_LCD_PANEL_I2C && !(defined CONFIG_SPL_BUILD) +#define CONFIG_SYS_I2C_SOFT +#define CONFIG_SYS_I2C_SOFT_SPEED 50000 +#define CONFIG_SYS_I2C_SOFT_SLAVE 0x00 +#define CONFIG_VIDEO_LCD_I2C_BUS 0 /* The lcd panel soft i2c is bus 0 */ +#define CONFIG_SYS_SPD_BUS_NUM 1 /* And the axp209 i2c bus is bus 1 */ +/* We use pin names in Kconfig and sunxi_name_to_gpio() */ +#define CONFIG_SOFT_I2C_GPIO_SDA soft_i2c_gpio_sda +#define CONFIG_SOFT_I2C_GPIO_SCL soft_i2c_gpio_scl +#ifndef __ASSEMBLY__ +extern int soft_i2c_gpio_sda; +extern int soft_i2c_gpio_scl; +#endif +#endif + #define CONFIG_CMD_I2C
/* PMU */

Add support for the 6" 480x800 tl059wv5c0 panel used on e.g. Utoo P66 and Aigo M60/M608/M606 tablets.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- board/sunxi/Kconfig | 8 ++++++++ drivers/video/sunxi_display.c | 7 +++++++ 2 files changed, 15 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index ef59e21..19e7286 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -411,6 +411,14 @@ config VIDEO_LCD_PANEL_HITACHI_TX18D42VM ---help--- 7.85" 1024x768 Hitachi tx18d42vm LCD panel support
+config VIDEO_LCD_TL059WV5C0 + bool "tl059wv5c0 LCD panel" + select VIDEO_LCD_PANEL_I2C + select VIDEO_LCD_IF_PARALLEL + ---help--- + Say Y here to add support for the 6" 480x800 tl059wv5c0 panel used + on e.g. Utoo P66 and Aigo M60/M608/M606 tablets. + endchoice
diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index 7f01401..4e12150 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -18,6 +18,7 @@ #include <errno.h> #include <fdtdec.h> #include <fdt_support.h> +#include <i2c.h> #include <video_fb.h> #include "videomodes.h" #include "hitachi_tx18d42vm_lcd.h" @@ -1030,6 +1031,12 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode, mdelay(50); /* Wait for lcd controller power on */ hitachi_tx18d42vm_init(); } + if (IS_ENABLED(CONFIG_VIDEO_LCD_TL059WV5C0)) { + unsigned int orig_i2c_bus = i2c_get_bus_num(); + i2c_set_bus_num(CONFIG_VIDEO_LCD_I2C_BUS); + i2c_reg_write(0x5c, 0x04, 0x42); /* Turn on the LCD */ + i2c_set_bus_num(orig_i2c_bus); + } sunxi_composer_mode_set(mode, address); sunxi_lcdc_tcon0_mode_set(mode, false); sunxi_composer_enable();

On Mon, 2015-02-16 at 23:25 +0100, Hans de Goede wrote:
Add support for the 6" 480x800 tl059wv5c0 panel used on e.g. Utoo P66 and Aigo M60/M608/M606 tablets.
Signed-off-by: Hans de Goede hdegoede@redhat.com
All 4 patches: Acked-by: Ian Campbell ijc@hellion.org.uk
I a couple of small comments on this one, which you can either ignore or fixup as you commit:
board/sunxi/Kconfig | 8 ++++++++ drivers/video/sunxi_display.c | 7 +++++++ 2 files changed, 15 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index ef59e21..19e7286 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -411,6 +411,14 @@ config VIDEO_LCD_PANEL_HITACHI_TX18D42VM ---help--- 7.85" 1024x768 Hitachi tx18d42vm LCD panel support
+config VIDEO_LCD_TL059WV5C0
- bool "tl059wv5c0 LCD panel"
- select VIDEO_LCD_PANEL_I2C
- select VIDEO_LCD_IF_PARALLEL
- ---help---
- Say Y here to add support for the 6" 480x800 tl059wv5c0 panel used
- on e.g. Utoo P66 and Aigo M60/M608/M606 tablets.
"Say Y" doesn't really make sense within a choice option. Better to follow the lead of the Hitachi panel above and '6" 480x800 tl059wv5c0 panel'. I'm not sure a non-exhaustive list of boards/tablets is useful either -- presumably if we know to list them here we also know to enable the option in the defconfig.
@@ -1030,6 +1031,12 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode, mdelay(50); /* Wait for lcd controller power on */ hitachi_tx18d42vm_init(); }
if (IS_ENABLED(CONFIG_VIDEO_LCD_TL059WV5C0)) {
unsigned int orig_i2c_bus = i2c_get_bus_num();
i2c_set_bus_num(CONFIG_VIDEO_LCD_I2C_BUS);
I see that you save and restore the value but it might be nice for the relevant axp drivers to also call this using CONFIG_SYS_SPD_BUS_NUM? (I'm assuming it is set initially to this via i2c_init_all()?)
Ian.

Hi,
On 18-02-15 10:21, Ian Campbell wrote:
On Mon, 2015-02-16 at 23:25 +0100, Hans de Goede wrote:
Add support for the 6" 480x800 tl059wv5c0 panel used on e.g. Utoo P66 and Aigo M60/M608/M606 tablets.
Signed-off-by: Hans de Goede hdegoede@redhat.com
All 4 patches: Acked-by: Ian Campbell ijc@hellion.org.uk
Thanks for the review.
I a couple of small comments on this one, which you can either ignore or fixup as you commit:
board/sunxi/Kconfig | 8 ++++++++ drivers/video/sunxi_display.c | 7 +++++++ 2 files changed, 15 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index ef59e21..19e7286 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -411,6 +411,14 @@ config VIDEO_LCD_PANEL_HITACHI_TX18D42VM ---help--- 7.85" 1024x768 Hitachi tx18d42vm LCD panel support
+config VIDEO_LCD_TL059WV5C0
- bool "tl059wv5c0 LCD panel"
- select VIDEO_LCD_PANEL_I2C
- select VIDEO_LCD_IF_PARALLEL
- ---help---
- Say Y here to add support for the 6" 480x800 tl059wv5c0 panel used
- on e.g. Utoo P66 and Aigo M60/M608/M606 tablets.
"Say Y" doesn't really make sense within a choice option. Better to follow the lead of the Hitachi panel above and '6" 480x800 tl059wv5c0 panel'.
I agree, fixed.
I'm not sure a non-exhaustive list of boards/tablets is useful either -- presumably if we know to list them here we also know to enable the option in the defconfig.
Although the patch in the end is small, figuring out that this LCD needs bit banging i2c + a magic write took me a lot of time, during which I also found out that it is at least used with these tablets (I've an UTOO P66 myself, I'm preparing a patch for adding support for that), so I would like to keep this around so that if anyone ever shows up with one of the involved Aigo tablets we know what to do to get the LCD to work.
@@ -1030,6 +1031,12 @@ static void sunxi_mode_set(const struct ctfb_res_modes *mode, mdelay(50); /* Wait for lcd controller power on */ hitachi_tx18d42vm_init(); }
if (IS_ENABLED(CONFIG_VIDEO_LCD_TL059WV5C0)) {
unsigned int orig_i2c_bus = i2c_get_bus_num();
i2c_set_bus_num(CONFIG_VIDEO_LCD_I2C_BUS);
I see that you save and restore the value but it might be nice for the relevant axp drivers to also call this using CONFIG_SYS_SPD_BUS_NUM?
I would rather not "pollute" the axp209 driver with this, eventually this should all move to the device model and the set_bus calls should go away.
(I'm assuming it is set initially to this via i2c_init_all()?)
Correct.
Regards,
Hans

p.s.
On 18-02-15 10:21, Ian Campbell wrote:
On Mon, 2015-02-16 at 23:25 +0100, Hans de Goede wrote:
Add support for the 6" 480x800 tl059wv5c0 panel used on e.g. Utoo P66 and Aigo M60/M608/M606 tablets.
Signed-off-by: Hans de Goede hdegoede@redhat.com
All 4 patches: Acked-by: Ian Campbell ijc@hellion.org.uk
Pushed to u-boot-sunxi/next
Regards,
Hans

Sending out 5V when there is a charger connected to the otg port is not a good idea, so check for this and error out.
Note this commit currently breaks otg support on the q8h tablets, as we need to do some magic with the pmic there to get vbus info, this is deliberate (better safe then sorry), fixing this is on my TODO list.
Signed-off-by: Hans de Goede hdegoede@redhat.com --- board/sunxi/Kconfig | 8 ++++++++ configs/Ampe_A76_defconfig | 1 + configs/Chuwi_V7_CW0825_defconfig | 1 + configs/Hyundai_A7HD_defconfig | 1 + configs/Inet_86VS_defconfig | 1 + configs/TZX-Q8-713B7_defconfig | 1 + drivers/usb/musb-new/sunxi.c | 25 +++++++++++++++++++++++++ 7 files changed, 38 insertions(+)
diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 19e7286..febcc8e 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -228,6 +228,14 @@ config USB0_VBUS_PIN Set the Vbus enable pin for usb0 (otg). This takes a string in the format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
+config USB0_VBUS_DET + string "Vbus detect pin for usb0 (otg)" + depends on USB_MUSB_SUNXI + default "" + ---help--- + Set the Vbus detect pin for usb0 (otg). This takes a string in the + format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H. + config USB1_VBUS_PIN string "Vbus enable pin for usb1 (ehci0)" default "PH6" if MACH_SUN4I || MACH_SUN7I diff --git a/configs/Ampe_A76_defconfig b/configs/Ampe_A76_defconfig index 2054fc3..f8ceb6c 100644 --- a/configs/Ampe_A76_defconfig +++ b/configs/Ampe_A76_defconfig @@ -3,6 +3,7 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER" CONFIG_FDTFILE="sun5i-a13-ampe-a76.dtb" CONFIG_USB_MUSB_SUNXI=y CONFIG_USB0_VBUS_PIN="PG12" +CONFIG_USB0_VBUS_DET="PG01" CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:82,up:22,lo:22,hs:1,vs:1,sync:3,vmode:0" CONFIG_VIDEO_LCD_POWER="AXP0-0" CONFIG_VIDEO_LCD_BL_EN="AXP0-1" diff --git a/configs/Chuwi_V7_CW0825_defconfig b/configs/Chuwi_V7_CW0825_defconfig index 680b631..1ef23e4 100644 --- a/configs/Chuwi_V7_CW0825_defconfig +++ b/configs/Chuwi_V7_CW0825_defconfig @@ -3,6 +3,7 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER" CONFIG_FDTFILE="sun4i-a10-chuwi-v7-cw0825.dtb" CONFIG_USB_MUSB_SUNXI=y CONFIG_USB0_VBUS_PIN="PB9" +CONFIG_USB0_VBUS_DET="PH5" CONFIG_VIDEO_LCD_MODE="x:1024,y:768,depth:24,pclk_khz:51000,le:19,ri:300,up:6,lo:31,hs:1,vs:1,sync:3,vmode:0" CONFIG_VIDEO_LCD_POWER="PH8" CONFIG_VIDEO_LCD_BL_EN="PH7" diff --git a/configs/Hyundai_A7HD_defconfig b/configs/Hyundai_A7HD_defconfig index 204640e..6b784e2 100644 --- a/configs/Hyundai_A7HD_defconfig +++ b/configs/Hyundai_A7HD_defconfig @@ -6,6 +6,7 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER" CONFIG_FDTFILE="sun4i-a10-hyundai-a7hd.dtb" CONFIG_USB_MUSB_SUNXI=y CONFIG_USB0_VBUS_PIN="PB09" +CONFIG_USB0_VBUS_DET="PH5" CONFIG_USB1_VBUS_PIN="" CONFIG_USB2_VBUS_PIN="PH6" CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:51000,le:45,ri:274,up:22,lo:12,hs:1,vs:1,sync:3,vmode:0" diff --git a/configs/Inet_86VS_defconfig b/configs/Inet_86VS_defconfig index ce9985a..50c073a 100644 --- a/configs/Inet_86VS_defconfig +++ b/configs/Inet_86VS_defconfig @@ -3,6 +3,7 @@ CONFIG_SYS_EXTRA_OPTIONS="AXP209_POWER" CONFIG_FDTFILE="sun5i-a13-inet-86vs.dtb" CONFIG_USB_MUSB_SUNXI=y CONFIG_USB0_VBUS_PIN="PG12" +CONFIG_USB0_VBUS_DET="PG1" CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:45,ri:209,up:22,lo:22,hs:1,vs:1,sync:3,vmode:0" CONFIG_VIDEO_LCD_POWER="AXP0-0" CONFIG_VIDEO_LCD_BL_EN="AXP0-1" diff --git a/configs/TZX-Q8-713B7_defconfig b/configs/TZX-Q8-713B7_defconfig index 7b7b9dd..c22286a 100644 --- a/configs/TZX-Q8-713B7_defconfig +++ b/configs/TZX-Q8-713B7_defconfig @@ -3,6 +3,7 @@ CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=2,AXP209_POWER" CONFIG_FDTFILE="sun5i-a13-tzx-q8-713b7.dtb" CONFIG_USB_MUSB_SUNXI=y CONFIG_USB0_VBUS_PIN="PG12" +CONFIG_USB0_VBUS_DET="PG1" CONFIG_VIDEO_LCD_MODE="x:800,y:480,depth:18,pclk_khz:33000,le:87,ri:40,up:31,lo:13,hs:1,vs:1,sync:3,vmode:0" CONFIG_VIDEO_LCD_POWER="AXP0-0" CONFIG_VIDEO_LCD_BL_EN="AXP0-1" diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 4646a3d..b77e938 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -22,7 +22,9 @@ */ #include <common.h> #include <asm/arch/cpu.h> +#include <asm/arch/gpio.h> #include <asm/arch/usbc.h> +#include <asm-generic/gpio.h> #include "linux-compat.h" #include "musb_core.h"
@@ -224,6 +226,29 @@ static int sunxi_musb_init(struct musb *musb)
pr_debug("%s():\n", __func__);
+ if (is_host_enabled(musb)) { + int vbus_det = sunxi_name_to_gpio(CONFIG_USB0_VBUS_DET); + if (vbus_det == -1) { + eprintf("Error invalid Vusb-det pin\n"); + return -EINVAL; + } + + err = gpio_request(vbus_det, "vbus0_det"); + if (err) + return err; + err = gpio_direction_input(vbus_det); + if (err) + return err; + + err = gpio_get_value(vbus_det); + if (err) { + eprintf("Error: A charger is plugged into the OTG\n"); + return -EIO; + } + + gpio_free(vbus_det); + } + err = sunxi_usbc_request_resources(0); if (err) return err;
participants (2)
-
Hans de Goede
-
Ian Campbell