From: Fabio Estevam <festevam@gmail.com>
To: hverkuil-cisco@xs4all.nl
Cc: lars@metafoo.de, robh+dt@kernel.org, devicetree@vger.kernel.org,
linux-media@vger.kernel.org, tharvey@gateworks.com,
frieder.schrempf@kontron.de, niklas.soderlund@ragnatech.se,
Fabio Estevam <festevam@gmail.com>
Subject: [PATCH 2/3] media: i2c: adv7180: Allow the control of the reset pin
Date: Sun, 30 May 2021 17:44:09 -0300 [thread overview]
Message-ID: <20210530204410.676831-2-festevam@gmail.com> (raw)
In-Reply-To: <20210530204410.676831-1-festevam@gmail.com>
On a design where the ADV7180 pin is pulled down, it is not possible
to make it functional unless the GPIO connected to this pin goes
high.
Add support for the reset GPIO by introducing an optional property
called 'reset-gpios'.
Note: the reset operation is still performed via software as recommended
by the Analog Devices, but the reset GPIO still needs to go high to make
the chip operational.
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
drivers/media/i2c/adv7180.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 44bb6fe85644..2811f2c337fa 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -205,6 +205,7 @@ struct adv7180_state {
struct mutex mutex; /* mutual excl. when accessing chip */
int irq;
struct gpio_desc *pwdn_gpio;
+ struct gpio_desc *reset_gpio;
v4l2_std_id curr_norm;
bool powered;
bool streaming;
@@ -473,13 +474,15 @@ static int adv7180_g_frame_interval(struct v4l2_subdev *sd,
static void adv7180_set_power_pin(struct adv7180_state *state, bool on)
{
- if (!state->pwdn_gpio)
+ if (!state->pwdn_gpio && !state->reset_gpio)
return;
if (on) {
+ gpiod_set_value_cansleep(state->reset_gpio, 0);
gpiod_set_value_cansleep(state->pwdn_gpio, 0);
usleep_range(5000, 10000);
} else {
+ gpiod_set_value_cansleep(state->reset_gpio, 1);
gpiod_set_value_cansleep(state->pwdn_gpio, 1);
}
}
@@ -1338,6 +1341,15 @@ static int adv7180_probe(struct i2c_client *client,
return ret;
}
+ state->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(state->reset_gpio)) {
+ ret = PTR_ERR(state->reset_gpio);
+ v4l_err(client, "request for reset pin failed: %d\n", ret);
+ return ret;
+ }
+
+
if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
state->csi_client = i2c_new_dummy_device(client->adapter,
ADV7180_DEFAULT_CSI_I2C_ADDR);
--
2.25.1
next prev parent reply other threads:[~2021-05-30 20:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-30 20:44 [PATCH 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Fabio Estevam
2021-05-30 20:44 ` Fabio Estevam [this message]
2021-05-31 7:02 ` [PATCH 2/3] media: i2c: adv7180: Allow the control of the reset pin Frieder Schrempf
2021-05-31 10:48 ` Fabio Estevam
2021-05-30 20:44 ` [PATCH 3/3] media: i2c: adv7180: Print the chip ID on probe Fabio Estevam
2021-05-31 7:04 ` Frieder Schrempf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210530204410.676831-2-festevam@gmail.com \
--to=festevam@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=frieder.schrempf@kontron.de \
--cc=hverkuil-cisco@xs4all.nl \
--cc=lars@metafoo.de \
--cc=linux-media@vger.kernel.org \
--cc=niklas.soderlund@ragnatech.se \
--cc=robh+dt@kernel.org \
--cc=tharvey@gateworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).