diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-01-26 17:59:05 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@kernel.org> | 2023-02-06 08:48:36 +0100 |
commit | 0a844ab77bd1ee9349e34c2beac049dc4b50bf58 (patch) | |
tree | 961b54d498d4edaab5c2500b70ca5bb414080326 /drivers/media/i2c/ov5670.c | |
parent | cf9ab879910f620fca10562ce9223b54463dff70 (diff) | |
download | linux-stable-0a844ab77bd1ee9349e34c2beac049dc4b50bf58.tar.gz linux-stable-0a844ab77bd1ee9349e34c2beac049dc4b50bf58.tar.bz2 linux-stable-0a844ab77bd1ee9349e34c2beac049dc4b50bf58.zip |
media: i2c: ov5670: Probe GPIOs
The OV5670 has a powerdown and reset pin, named respectively "PWDN" and
"XSHUTDOWN".
Optionally probe the gpios connected to the pins during the driver probe
routine.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Luca Weiss <luca@z3ntu.xyz>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/i2c/ov5670.c')
-rw-r--r-- | drivers/media/i2c/ov5670.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c index e71f13360480..0290f33f619d 100644 --- a/drivers/media/i2c/ov5670.c +++ b/drivers/media/i2c/ov5670.c @@ -3,6 +3,7 @@ #include <linux/acpi.h> #include <linux/clk.h> +#include <linux/gpio/consumer.h> #include <linux/i2c.h> #include <linux/mod_devicetable.h> #include <linux/module.h> @@ -1848,6 +1849,10 @@ struct ov5670 { /* Regulators */ struct regulator_bulk_data supplies[OV5670_NUM_SUPPLIES]; + /* Power-down and reset gpios. */ + struct gpio_desc *pwdn_gpio; /* PWDNB pin. */ + struct gpio_desc *reset_gpio; /* XSHUTDOWN pin. */ + /* To serialize asynchronus callbacks */ struct mutex mutex; @@ -2500,6 +2505,23 @@ static int ov5670_regulators_probe(struct ov5670 *ov5670) ov5670->supplies); } +static int ov5670_gpio_probe(struct ov5670 *ov5670) +{ + struct i2c_client *client = v4l2_get_subdevdata(&ov5670->sd); + + ov5670->pwdn_gpio = devm_gpiod_get_optional(&client->dev, "powerdown", + GPIOD_OUT_LOW); + if (IS_ERR(ov5670->pwdn_gpio)) + return PTR_ERR(ov5670->pwdn_gpio); + + ov5670->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ov5670->reset_gpio)) + return PTR_ERR(ov5670->reset_gpio); + + return 0; +} + static int ov5670_probe(struct i2c_client *client) { struct ov5670 *ov5670; @@ -2540,6 +2562,12 @@ static int ov5670_probe(struct i2c_client *client) goto error_print; } + ret = ov5670_gpio_probe(ov5670); + if (ret) { + err_msg = "GPIO probe failed"; + goto error_print; + } + full_power = acpi_dev_state_d0(&client->dev); if (full_power) { /* Check module identity */ |