From 46e4dbc2fd86325cb4bc8151b588358010e06b45 Mon Sep 17 00:00:00 2001 From: Zefa Chen Date: Mon, 17 Aug 2020 17:05:15 +0800 Subject: [PATCH] media: i2c: gc2053 add power-gpios Signed-off-by: Zefa Chen Change-Id: Ibdf6400e56b72378a41c2ef1cc6e4f2a56ea2a7e --- drivers/media/i2c/gc2053.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/gc2053.c b/drivers/media/i2c/gc2053.c index 3a7a16352a0e..f24f19111b8e 100644 --- a/drivers/media/i2c/gc2053.c +++ b/drivers/media/i2c/gc2053.c @@ -118,6 +118,7 @@ struct gc2053 { struct clk *xvclk; struct gpio_desc *reset_gpio; struct gpio_desc *pwdn_gpio; + struct gpio_desc *power_gpio; struct regulator_bulk_data supplies[GC2053_NUM_SUPPLIES]; struct pinctrl *pinctrl; @@ -726,17 +727,20 @@ static int __gc2053_power_on(struct gc2053 *gc2053) dev_err(dev, "Failed to enable regulators\n"); goto disable_clk; } - - if (!IS_ERR(gc2053->reset_gpio)) + if (!IS_ERR(gc2053->power_gpio)) { + gpiod_set_value_cansleep(gc2053->power_gpio, 1); + usleep_range(100, 200); + } + if (!IS_ERR(gc2053->reset_gpio)) { gpiod_set_value_cansleep(gc2053->reset_gpio, 1); - - usleep_range(1000, 2000); + usleep_range(100, 200); + } if (!IS_ERR(gc2053->pwdn_gpio)) gpiod_set_value_cansleep(gc2053->pwdn_gpio, 0); if (!IS_ERR(gc2053->reset_gpio)) gpiod_set_value_cansleep(gc2053->reset_gpio, 0); - + usleep_range(3000, 6000); /* 8192 cycles prior to first SCCB transaction */ delay_us = gc2053_cal_delay(8192); usleep_range(delay_us, delay_us * 2); @@ -765,6 +769,8 @@ static void __gc2053_power_off(struct gc2053 *gc2053) if (ret < 0) dev_dbg(dev, "could not set pins\n"); } + if (!IS_ERR(gc2053->power_gpio)) + gpiod_set_value_cansleep(gc2053->power_gpio, 0); regulator_bulk_disable(GC2053_NUM_SUPPLIES, gc2053->supplies); } @@ -1327,6 +1333,10 @@ static int gc2053_probe(struct i2c_client *client, if (IS_ERR(gc2053->pwdn_gpio)) dev_info(dev, "Failed to get pwdn-gpios, maybe no used\n"); + gc2053->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); + if (IS_ERR(gc2053->power_gpio)) + dev_warn(dev, "Failed to get power-gpios\n"); + ret = gc2053_configure_regulators(gc2053); if (ret) { dev_err(dev, "Failed to get power regulators\n");