From: Jonathan Cameron <jic23@kernel.org>
To: Christoph Rudorff <chris@rudorff.com>
Cc: "Linus Walleij" <linusw@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konradybcio@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH 1/3] iio: light: gp2ap002: add led power supply
Date: Sat, 17 Oct 2026 01:05:01 +0100 [thread overview]
Message-ID: <20261017010501.70eb3ee4@jic23-hlaptop> (raw)
In-Reply-To: <20261016-iio-light-gp2ap002-v1-1-7c93312fa8d5@rudorff.com>
On Fri, 16 Oct 2026 16:43:06 +0200
Christoph Rudorff <chris@rudorff.com> wrote:
> According to data sheet "Recommended external circuit"
> this got up to three supplies, we missed VLED
>
> Now it works (tested on msm8916-samsung-j5):
>
> $ cd /sys/bus/iio/devices/iio\:device1
> $ echo 1 > events/in_proximity_thresh_either_en
>
> $ iio_event_monitor /dev/iio\:device1
>
> Event: time: 1791460068846871297, type: proximity, channel: 0,
> evtype: thresh, direction: rising
>
> Event: time: 1791460068876669724, type: proximity, channel: 0,
> evtype: thresh, direction: falling
>
> ...
>
> Signed-off-by: Christoph Rudorff <chris@rudorff.com>
A few comments inline if you resolve the question Linus raised.
> ---
> drivers/iio/light/gp2ap002.c | 28 +++++++++++++++++++++++++---
> 1 file changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
> index de29081fd3b2..c03eb0f1988b 100644
> --- a/drivers/iio/light/gp2ap002.c
> +++ b/drivers/iio/light/gp2ap002.c
> @@ -129,6 +129,7 @@
> * @dev: pointer to parent device
> * @vdd: regulator controlling VDD
> * @vio: regulator controlling VIO
> + * @vled: regulator controlling VLED
> * @alsout: IIO ADC channel to convert the ALSOUT signal
> * @hys_far: hysteresis control from device tree
> * @hys_close: hysteresis control from device tree
> @@ -142,6 +143,7 @@ struct gp2ap002 {
> struct device *dev;
> struct regulator *vdd;
> struct regulator *vio;
> + struct regulator *vled;
> struct iio_channel *alsout;
> u8 hys_far;
> u8 hys_close;
> @@ -169,7 +171,7 @@ static irqreturn_t gp2ap002_prox_irq(int irq, void *d)
>
> if (val & GP2AP002_PROX_VO_DETECT) {
> /* Close */
> - dev_dbg(gp2ap002->dev, "close\n");
> + dev_dbg(gp2ap002->dev, "close %i\n", val);
Why?
> ret = regmap_write(gp2ap002->map, GP2AP002_HYS,
> gp2ap002->hys_far);
> if (ret)
> @@ -179,7 +181,7 @@ static irqreturn_t gp2ap002_prox_irq(int irq, void *d)
> IIO_EV_TYPE_THRESH, IIO_EV_DIR_RISING);
> } else {
> /* Far */
> - dev_dbg(gp2ap002->dev, "far\n");
> + dev_dbg(gp2ap002->dev, "far %i\n", val);
Why?
> ret = regmap_write(gp2ap002->map, GP2AP002_HYS,
> gp2ap002->hys_close);
> if (ret)
> @@ -530,14 +532,22 @@ static int gp2ap002_probe(struct i2c_client *client)
> if (IS_ERR(gp2ap002->vio))
> return dev_err_probe(dev, PTR_ERR(gp2ap002->vio),
> "failed to get VIO regulator\n");
> + // returns a dummy if not declared:
See comment syntax elsewhere and match it.
> + gp2ap002->vled = devm_regulator_get(dev, "vled");
> + if (IS_ERR(gp2ap002->vled))
> + return dev_err_probe(dev, PTR_ERR(gp2ap002->vled),
> + "failed to get VLED regulator\n");
>
> /* Operating voltage 2.4V .. 3.6V according to datasheet */
> ret = regulator_set_voltage(gp2ap002->vdd, 2400000, 3600000);
> if (ret) {
> - dev_err(dev, "failed to sett VDD voltage\n");
> + dev_err(dev, "failed to set VDD voltage\n");
Good to fix, but unrelated so separate patch.
> return ret;
> }
>
> + /* LED voltage 2.4V .. 3.6V according to datasheet */
> + /* nothing to set: it's a simple "regulator-fixed" gpio pin */
Use multiline comment syntax.
> +
> /* VIO should be between 1.65V and VDD */
> ret = regulator_get_voltage(gp2ap002->vdd);
> if (ret < 0) {
> @@ -560,6 +570,11 @@ static int gp2ap002_probe(struct i2c_client *client)
> dev_err(dev, "failed to enable VIO regulator\n");
> goto out_disable_vdd;
> }
> + ret = regulator_enable(gp2ap002->vled);
> + if (ret) {
> + dev_err(dev, "failed to enable VLED regulator\n");
> + goto out_disable_vio;
> + }
>
> msleep(20);
>
> @@ -635,6 +650,7 @@ static void gp2ap002_remove(struct i2c_client *client)
> iio_device_unregister(indio_dev);
> regulator_disable(gp2ap002->vio);
> regulator_disable(gp2ap002->vdd);
> + regulator_disable(gp2ap002->vled);
There are enough of them that if this goes forward consider using
the bulk handling.
> }
>
> static int gp2ap002_runtime_suspend(struct device *dev)
> @@ -659,6 +675,7 @@ static int gp2ap002_runtime_suspend(struct device *dev)
> */
> regulator_disable(gp2ap002->vio);
> regulator_disable(gp2ap002->vdd);
> + regulator_disable(gp2ap002->vled);
>
> return 0;
> }
> @@ -679,6 +696,11 @@ static int gp2ap002_runtime_resume(struct device *dev)
> dev_err(dev, "failed to enable VIO regulator in resume path\n");
> goto out_disable_vdd;
> }
> + ret = regulator_enable(gp2ap002->vled);
> + if (ret) {
> + dev_err(dev, "failed to enable VLED regulator in resume path\n");
> + goto out_disable_vio;
> + }
>
> msleep(20);
>
>
next prev parent reply other threads:[~2026-10-17 0:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 14:43 [PATCH 0/3] from my MSM8916-mainline: Christoph Rudorff
2026-10-16 14:43 ` [PATCH 1/3] iio: light: gp2ap002: add led power supply Christoph Rudorff
2026-10-16 14:48 ` sashiko-bot
2026-10-17 0:05 ` Jonathan Cameron [this message]
2026-10-16 14:43 ` [PATCH 2/3] iio: light: Update DT bindings for GP2AP002 Christoph Rudorff
2026-10-16 14:45 ` Krzysztof Kozlowski
2026-10-16 14:58 ` chr[]
2026-10-16 14:49 ` sashiko-bot
2026-10-16 21:01 ` Linus Walleij
2026-10-17 9:18 ` chr[]
2026-10-18 21:05 ` Linus Walleij
2026-10-16 14:43 ` [PATCH 3/3] arm64: dts: qcom: msm8916-samsung-j5: Add proximity sensor Christoph Rudorff
2026-10-16 15:11 ` Konrad Dybcio
2026-10-22 13:35 ` chr[]
2026-10-22 13:46 ` Konrad Dybcio
2026-10-22 14:27 ` chr[]
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=20261017010501.70eb3ee4@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andersson@kernel.org \
--cc=andy@kernel.org \
--cc=chris@rudorff.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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 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.