* [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property
@ 2021-05-31 11:22 Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 2/3] media: adv7180: Add optional reset GPIO Fabio Estevam
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Fabio Estevam @ 2021-05-31 11:22 UTC (permalink / raw)
To: hverkuil-cisco
Cc: lars, robh+dt, devicetree, linux-media, tharvey,
frieder.schrempf, niklas.soderlund, Fabio Estevam
Introduce the 'reset-gpios' property to describe the GPIO that connects
to the ADV7180 reset pin.
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
Changes since v1:
- None
Documentation/devicetree/bindings/media/i2c/adv7180.yaml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/media/i2c/adv7180.yaml b/Documentation/devicetree/bindings/media/i2c/adv7180.yaml
index bcfd93739b4f..1f1aa46f5724 100644
--- a/Documentation/devicetree/bindings/media/i2c/adv7180.yaml
+++ b/Documentation/devicetree/bindings/media/i2c/adv7180.yaml
@@ -35,6 +35,9 @@ properties:
powerdown-gpios:
maxItems: 1
+ reset-gpios:
+ maxItems: 1
+
port:
$ref: /schemas/graph.yaml#/properties/port
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/3] media: adv7180: Add optional reset GPIO
2021-05-31 11:22 [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Fabio Estevam
@ 2021-05-31 11:22 ` Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 3/3] media: i2c: adv7180: Print the chip ID on probe Fabio Estevam
2021-06-04 21:33 ` [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Rob Herring
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2021-05-31 11:22 UTC (permalink / raw)
To: hverkuil-cisco
Cc: lars, robh+dt, devicetree, linux-media, tharvey,
frieder.schrempf, niklas.soderlund, Fabio Estevam
From: Frieder Schrempf <frieder.schrempf@kontron.de>
There is a reset input that can be controlled by GPIO. Let's add it
to let the driver control it if required.
Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
Changes since v1:
- Used Frieder's version of the patch.
drivers/media/i2c/adv7180.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 44bb6fe85644..2890041cc231 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 *rst_gpio;
v4l2_std_id curr_norm;
bool powered;
bool streaming;
@@ -484,6 +485,19 @@ static void adv7180_set_power_pin(struct adv7180_state *state, bool on)
}
}
+static void adv7180_set_reset_pin(struct adv7180_state *state, bool on)
+{
+ if (!state->rst_gpio)
+ return;
+
+ if (on) {
+ gpiod_set_value_cansleep(state->rst_gpio, 1);
+ } else {
+ gpiod_set_value_cansleep(state->rst_gpio, 0);
+ usleep_range(5000, 10000);
+ }
+}
+
static int adv7180_set_power(struct adv7180_state *state, bool on)
{
u8 val;
@@ -1263,6 +1277,7 @@ static int init_device(struct adv7180_state *state)
mutex_lock(&state->mutex);
adv7180_set_power_pin(state, true);
+ adv7180_set_reset_pin(state, false);
adv7180_write(state, ADV7180_REG_PWR_MAN, ADV7180_PWR_MAN_RES);
usleep_range(5000, 10000);
@@ -1338,6 +1353,14 @@ static int adv7180_probe(struct i2c_client *client,
return ret;
}
+ state->rst_gpio = devm_gpiod_get_optional(&client->dev, "reset",
+ GPIOD_OUT_HIGH);
+ if (IS_ERR(state->rst_gpio)) {
+ ret = PTR_ERR(state->rst_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);
@@ -1428,6 +1451,7 @@ static int adv7180_remove(struct i2c_client *client)
i2c_unregister_device(state->vpp_client);
i2c_unregister_device(state->csi_client);
+ adv7180_set_reset_pin(state, true);
adv7180_set_power_pin(state, false);
mutex_destroy(&state->mutex);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] media: i2c: adv7180: Print the chip ID on probe
2021-05-31 11:22 [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 2/3] media: adv7180: Add optional reset GPIO Fabio Estevam
@ 2021-05-31 11:22 ` Fabio Estevam
2021-06-04 21:33 ` [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Rob Herring
2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2021-05-31 11:22 UTC (permalink / raw)
To: hverkuil-cisco
Cc: lars, robh+dt, devicetree, linux-media, tharvey,
frieder.schrempf, niklas.soderlund, Fabio Estevam
Improve the probe message by printing the chip ID version.
Signed-off-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
---
Changes since v1:
- Added Frieder's Reviewed-by tag.
drivers/media/i2c/adv7180.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c
index 2890041cc231..4f99b46e7eaa 100644
--- a/drivers/media/i2c/adv7180.c
+++ b/drivers/media/i2c/adv7180.c
@@ -1415,11 +1415,19 @@ static int adv7180_probe(struct i2c_client *client,
if (ret)
goto err_free_irq;
- v4l_info(client, "chip found @ 0x%02x (%s)\n",
- client->addr, client->adapter->name);
+ mutex_lock(&state->mutex);
+ ret = adv7180_read(state, ADV7180_REG_IDENT);
+ mutex_unlock(&state->mutex);
+ if (ret < 0)
+ goto err_v4l2_async_unregister;
+
+ v4l_info(client, "chip id 0x%x found @ 0x%02x (%s)\n",
+ ret, client->addr, client->adapter->name);
return 0;
+err_v4l2_async_unregister:
+ v4l2_async_unregister_subdev(sd);
err_free_irq:
if (state->irq > 0)
free_irq(client->irq, state);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property
2021-05-31 11:22 [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 2/3] media: adv7180: Add optional reset GPIO Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 3/3] media: i2c: adv7180: Print the chip ID on probe Fabio Estevam
@ 2021-06-04 21:33 ` Rob Herring
2 siblings, 0 replies; 4+ messages in thread
From: Rob Herring @ 2021-06-04 21:33 UTC (permalink / raw)
To: Fabio Estevam
Cc: niklas.soderlund, hverkuil-cisco, linux-media, robh+dt, lars,
tharvey, devicetree, frieder.schrempf
On Mon, 31 May 2021 08:22:35 -0300, Fabio Estevam wrote:
> Introduce the 'reset-gpios' property to describe the GPIO that connects
> to the ADV7180 reset pin.
>
> Signed-off-by: Fabio Estevam <festevam@gmail.com>
> ---
> Changes since v1:
> - None
>
> Documentation/devicetree/bindings/media/i2c/adv7180.yaml | 3 +++
> 1 file changed, 3 insertions(+)
>
Acked-by: Rob Herring <robh@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-04 21:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-31 11:22 [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 2/3] media: adv7180: Add optional reset GPIO Fabio Estevam
2021-05-31 11:22 ` [PATCH v2 3/3] media: i2c: adv7180: Print the chip ID on probe Fabio Estevam
2021-06-04 21:33 ` [PATCH v2 1/3] dt-bindings: adv7180: Introduce the 'reset-gpios' property Rob Herring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.