[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220523175344.5845-5-markuss.broks@gmail.com>
Date: Mon, 23 May 2022 20:53:43 +0300
From: Markuss Broks <markuss.broks@...il.com>
To: linux-kernel@...r.kernel.org, jic23@...nel.org
Cc: ~postmarketos/upstreaming@...ts.sr.ht, phone-devel@...r.kernel.org,
Markuss Broks <markuss.broks@...il.com>,
Konrad Dybcio <konrad.dybcio@...ainline.org>,
Marijn Suijten <marijn.suijten@...ainline.org>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@...ainline.org>,
Song Qiang <songqiang1304521@...il.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Andy Gross <agross@...nel.org>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-msm@...r.kernel.org
Subject: [PATCH 4/5] proximity: vl53l0x: Handle the reset GPIO
Handle the GPIO connected to the XSHUT/RST_N pin of VL53L0X.
Signed-off-by: Markuss Broks <markuss.broks@...il.com>
---
drivers/iio/proximity/vl53l0x-i2c.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c
index 8581a873919f..36c48a824725 100644
--- a/drivers/iio/proximity/vl53l0x-i2c.c
+++ b/drivers/iio/proximity/vl53l0x-i2c.c
@@ -15,6 +15,7 @@
*/
#include <linux/delay.h>
+#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
@@ -44,6 +45,7 @@ struct vl53l0x_data {
struct i2c_client *client;
struct completion completion;
struct regulator *vdd_supply;
+ struct gpio_desc *reset_gpio;
};
static irqreturn_t vl53l0x_handle_irq(int irq, void *priv)
@@ -197,6 +199,8 @@ static void vl53l0x_power_off(void *_data)
{
struct vl53l0x_data *data = _data;
+ gpiod_set_value_cansleep(data->reset_gpio, 1);
+
regulator_disable(data->vdd_supply);
}
@@ -208,6 +212,8 @@ static int vl53l0x_power_on(struct vl53l0x_data *data)
if (ret)
return ret;
+ gpiod_set_value_cansleep(data->reset_gpio, 0);
+
usleep_range(3200, 5000);
return 0;
@@ -237,6 +243,11 @@ static int vl53l0x_probe(struct i2c_client *client)
return dev_err_probe(&client->dev, PTR_ERR(data->vdd_supply),
"Unable to get VDD regulator\n");
+ data->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
+ if (IS_ERR(data->reset_gpio))
+ return dev_err_probe(&client->dev, PTR_ERR(data->reset_gpio),
+ "Cannot get reset GPIO\n");
+
error = vl53l0x_power_on(data);
if (error)
return dev_err_probe(&client->dev, error,
--
2.36.1
Powered by blists - more mailing lists