From ab3978515aeb5f845af17134950808bedbfbcd07 Mon Sep 17 00:00:00 2001 From: zwl Date: Mon, 22 Sep 2014 20:50:06 +0800 Subject: [PATCH] rk312x:lvds: add pull down lcdc io when the first time of system suspend --- arch/arm/boot/dts/rk3126-86v.dts | 8 ++++ arch/arm/boot/dts/rk3126-sdk.dts | 8 ++++ arch/arm/boot/dts/rk3128-sdk.dts | 8 ++++ .../video/rockchip/transmitter/rk31xx_lvds.c | 45 +++++++++++++++++++ 4 files changed, 69 insertions(+) diff --git a/arch/arm/boot/dts/rk3126-86v.dts b/arch/arm/boot/dts/rk3126-86v.dts index 7ce872e8e825..061735349a75 100644 --- a/arch/arm/boot/dts/rk3126-86v.dts +++ b/arch/arm/boot/dts/rk3126-86v.dts @@ -185,6 +185,14 @@ pinctrl-names = "lcdc", "sleep"; pinctrl-0 = <&lcdc0_lcdc_d>; pinctrl-1 = <&lcdc0_lcdc_gpio>; + lcdc-gpios = <&gpio2 GPIO_B4 GPIO_ACTIVE_LOW + &gpio2 GPIO_B5 GPIO_ACTIVE_LOW + &gpio2 GPIO_B6 GPIO_ACTIVE_LOW + &gpio2 GPIO_B7 GPIO_ACTIVE_LOW + &gpio2 GPIO_C0 GPIO_ACTIVE_LOW + &gpio2 GPIO_C1 GPIO_ACTIVE_LOW + &gpio2 GPIO_C2 GPIO_ACTIVE_LOW + &gpio2 GPIO_C3 GPIO_ACTIVE_LOW>; }; &lcdc { diff --git a/arch/arm/boot/dts/rk3126-sdk.dts b/arch/arm/boot/dts/rk3126-sdk.dts index 3049052774d0..1574f44f664d 100755 --- a/arch/arm/boot/dts/rk3126-sdk.dts +++ b/arch/arm/boot/dts/rk3126-sdk.dts @@ -52,6 +52,14 @@ pinctrl-names = "lcdc", "sleep"; pinctrl-0 = <&lcdc0_lcdc_d>; pinctrl-1 = <&lcdc0_lcdc_gpio>; + lcdc-gpios = <&gpio2 GPIO_B4 GPIO_ACTIVE_LOW + &gpio2 GPIO_B5 GPIO_ACTIVE_LOW + &gpio2 GPIO_B6 GPIO_ACTIVE_LOW + &gpio2 GPIO_B7 GPIO_ACTIVE_LOW + &gpio2 GPIO_C0 GPIO_ACTIVE_LOW + &gpio2 GPIO_C1 GPIO_ACTIVE_LOW + &gpio2 GPIO_C2 GPIO_ACTIVE_LOW + &gpio2 GPIO_C3 GPIO_ACTIVE_LOW>; }; &lcdc { diff --git a/arch/arm/boot/dts/rk3128-sdk.dts b/arch/arm/boot/dts/rk3128-sdk.dts index 99a0d1525445..669f6e30d91b 100755 --- a/arch/arm/boot/dts/rk3128-sdk.dts +++ b/arch/arm/boot/dts/rk3128-sdk.dts @@ -36,6 +36,14 @@ pinctrl-names = "lcdc", "sleep"; pinctrl-0 = <&lcdc0_lcdc_d>; pinctrl-1 = <&lcdc0_lcdc_gpio>; + lcdc-gpios = <&gpio2 GPIO_B4 GPIO_ACTIVE_LOW + &gpio2 GPIO_B5 GPIO_ACTIVE_LOW + &gpio2 GPIO_B6 GPIO_ACTIVE_LOW + &gpio2 GPIO_B7 GPIO_ACTIVE_LOW + &gpio2 GPIO_C0 GPIO_ACTIVE_LOW + &gpio2 GPIO_C1 GPIO_ACTIVE_LOW + &gpio2 GPIO_C2 GPIO_ACTIVE_LOW + &gpio2 GPIO_C3 GPIO_ACTIVE_LOW>; }; &lcdc { diff --git a/drivers/video/rockchip/transmitter/rk31xx_lvds.c b/drivers/video/rockchip/transmitter/rk31xx_lvds.c index 50cfdab62f2a..dea0fa634dea 100755 --- a/drivers/video/rockchip/transmitter/rk31xx_lvds.c +++ b/drivers/video/rockchip/transmitter/rk31xx_lvds.c @@ -27,6 +27,12 @@ #include #include "rk31xx_lvds.h" +#ifdef CONFIG_OF +#include +#include +#include +#endif + #define grf_readl(offset) readl_relaxed(RK_GRF_VIRT + offset) #define grf_writel(v,offset) \ @@ -106,6 +112,44 @@ static int rk31xx_lvds_pwr_off(void) return 0; } +static int rk31xx_lvds_pull_down_io(void) +{ + int gpio; + int i = 0, gpio_nums = 0, val = 0; + enum of_gpio_flags flags; + char gpio_name[20] = {0}; + struct rk_lvds_device *lvds = rk31xx_lvds; + static bool pull_down = false; + + if (unlikely(!lvds) || !lvds->sys_state) + return 0; + + if (pull_down) + return 0; + + gpio_nums = of_gpio_named_count(lvds->dev->of_node, "lcdc-gpios"); + if (gpio_nums > 0) { + for (i = 0; i < gpio_nums; i++) { + gpio = of_get_named_gpio_flags(lvds->dev->of_node, + "lcdc-gpios", i, &flags); + if (!gpio_is_valid(gpio)) + continue; + val = !(flags & OF_GPIO_ACTIVE_LOW); + sprintf(gpio_name, "lcdc-gpio%d", i); + if (!gpio_request(gpio, gpio_name)) { + gpio_direction_output(gpio, val); + msleep(1); + } else { + dev_err(lvds->dev, "request %s gpio fail!\n", + gpio_name); + } + } + } + pull_down = true; + + return 0; +} + static int rk31xx_lvds_disable(void) { struct rk_lvds_device *lvds = rk31xx_lvds; @@ -127,6 +171,7 @@ static int rk31xx_lvds_disable(void) pinctrl_select_state(lvds->pins->p, lvds->pins->sleep_state); } + rk31xx_lvds_pull_down_io(); } #endif lvds->sys_state = false; -- 2.34.1