From: Jonathan Cameron <jic23@kernel.org>
To: Liu Yufei <lyf98405@gmail.com>
Cc: "Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Joshua Crofts" <joshua.crofts1@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Andy Shevchenko" <andriy.shevchenko@intel.com>
Subject: Re: [PATCH v3 2/2] iio: proximity: Add driver for Vishay VCNL36829
Date: Sat, 17 Oct 2026 21:20:36 +0100 [thread overview]
Message-ID: <20261017212036.53e5a8c8@jic23-hlaptop> (raw)
In-Reply-To: <20261016012218.40223-3-lyf98405@gmail.com>
On Fri, 16 Oct 2026 09:22:18 +0800
Liu Yufei <lyf98405@gmail.com> wrote:
> From: Liu Yufei <lyf98405@gmail.com>
>
> Add an IIO driver for the Vishay VCNL36829 proximity sensor with
> integrated VCSEL, connected over I2C.
>
> At probe the driver enables the vdd and vddio supplies, waits for the
> sensor to power up, checks the device ID, configures the VCSEL current
> and photodiodes, and turns the proximity engine on. The sensor is put
> back into shutdown when the device is removed.
>
> The following attributes are exposed:
> - in_proximity0_raw
> - in_proximity_integration_time
> - in_proximity_integration_time_available
>
> Datasheet: https://www.vishay.com/docs/80580/vcnl36829um.pdf
> Assisted-by: LLM
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
> Signed-off-by: Liu Yufei <lyf98405@gmail.com>
> ---
> v3:
> - Use dev_info() instead of dev_warn() for an unknown device ID
> (Joshua Crofts).
> - Wrap the write_raw() arguments on a logical boundary (Andy Shevchenko).
> v2:
> - Address review comments from Andy (see cover letter for details).
>
Nice little driver. I'll tweak the first thing whilst applying.
Applied series to the testing branch of iio.git. That will be rebased on rc1
once available at which point I'll push it out for linux-next to pick up.
> diff --git a/drivers/iio/proximity/vcnl36829.c b/drivers/iio/proximity/vcnl36829.c
> new file mode 100644
> index 000000000..217a32aad
> --- /dev/null
> +++ b/drivers/iio/proximity/vcnl36829.c
> +
> +static const int vcnl36829_it_range[] = {0, 25, 0, 25, 0, 375};
Trivial but preferred style for IIO has { 0, ... 375 };
I'll tidy that up.
> +
> +static int vcnl36829_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + struct vcnl36829_data *data = iio_priv(indio_dev);
> + struct device *dev = regmap_get_device(data->regmap);
> + struct regmap *regmap = data->regmap;
> + unsigned int reg;
> + int ret;
> +
> + switch (mask) {
> + case IIO_CHAN_INFO_RAW:
> + ret = regmap_read(regmap, chan->address, ®);
> + if (ret) {
> + dev_err(dev, "Data read failed: %d\n", ret);
> + return ret;
> + }
> + *val = reg;
> + return IIO_VAL_INT;
> +
> + case IIO_CHAN_INFO_INT_TIME:
> + ret = regmap_read(regmap, VCNL36829_PS_CONF2, ®);
> + if (ret) {
> + dev_err(dev, "Data read failed: %d\n", ret);
> + return ret;
> + }
> + /*
> + * PS_IT field 0 would mean 12.5us, which does not fit the
> + * 25us step used here. The driver never programs field 0:
> + * probe sets 25us and write_raw rejects anything below 25us,
> + * so the field is always >= 1 and val2 = field * 25 holds.
I suppose we can relax that later without it being a regression if
it turns out someone wants to use 12.5 usecs.
> + */
> + *val = 0;
> + *val2 = FIELD_GET(VCNL36829_PS_IT_MSK, reg) * 25;
> + return IIO_VAL_INT_PLUS_MICRO;
> +
> + default:
> + return -EINVAL;
> + }
> +}
> +static int vcnl36829_probe(struct i2c_client *client)
> +{
> +
> + ret = regmap_read(regmap, VCNL36829_DEV_ID, ®);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to read device ID\n");
> + if ((reg & 0xFF) != VCNL36829_DEV_ID_VAL)
Not that important, but for consistency I'd have given that a field name,
despite it not having one on the datasheet..
> + dev_info(dev, "Unknown device ID 0x%x\n", reg & 0xFF);
>
next prev parent reply other threads:[~2026-10-17 20:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 10:09 [PATCH v2 0/2] iio: proximity: Add Vishay VCNL36829 driver Liu Yufei
2026-10-06 10:09 ` [PATCH v2 1/2] dt-bindings: iio: proximity: Add Vishay VCNL36829 Liu Yufei
2026-10-06 10:09 ` [PATCH v2 2/2] iio: proximity: Add driver for " Liu Yufei
2026-10-06 11:44 ` Joshua Crofts
2026-10-12 20:36 ` Andy Shevchenko
2026-10-16 1:22 ` [PATCH v3 0/2] iio: proximity: Add Vishay VCNL36829 driver Liu Yufei
2026-10-16 1:22 ` [PATCH v3 1/2] dt-bindings: iio: proximity: Add Vishay VCNL36829 Liu Yufei
2026-10-16 1:22 ` [PATCH v3 2/2] iio: proximity: Add driver for " Liu Yufei
2026-10-17 20:20 ` Jonathan Cameron [this message]
2026-10-17 20:00 ` [PATCH v3 0/2] iio: proximity: Add Vishay VCNL36829 driver Jonathan Cameron
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=20261017212036.53e5a8c8@jic23-hlaptop \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=joshua.crofts1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lyf98405@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®