Skip to contentSkip to conversation

iio: proximity: Add Vishay VCNL36829 driver

PATCH Superseded Liu Yufei 4 participants 10 messages Oct 6 – Oct 17

Subsystems (2)
lore
Share & tools
lore

Liu Yufei

author
#0 lore raw

v2 cover iio: proximity: Add Vishay VCNL36829 driver

From: Liu Yufei <[email protected]>

This series adds support for the Vishay VCNL36829, an I2C proximity sensor with an integrated VCSEL emitter.

Patch 1 adds the devicetree binding.
Patch 2 adds the IIO driver, which exposes the proximity reading and a configurable integration time.

Tested on Orange Pi Zero 2W.

Changes in v2:
- dt-bindings: Collect Reviewed-by from Krzysztof.
- driver: Address review comments from Andy:
- Use a Datasheet: tag in the commit message.
- Drop mod_devicetable.h, sort the includes and include what is used.
- Drop the i2c_client pointer from the private data and use regmap_get_device() instead.
- Drop the unused i2c_set_clientdata().
- Enable a maple regmap cache, mark PS_DATA and DEV_ID volatile.
- Rework the integration time validation in write_raw().
- Use reverse xmas tree order for local variables.
- Document the power-up delay and use 3 * USEC_PER_MSEC.
- Warn and continue on an unknown device ID instead of failing.
- Join lines that fit within 100 columns.
- Simplify the Assisted-by tag.
- driver: Drop the i2c_check_functionality() call, as devm_regmap_init_i2c() already checks the adapter capabilities.

Link to v1: https://lore.kernel.org/linux-iio/[email protected]/

Liu Yufei (2):
dt-bindings: iio: proximity: Add Vishay VCNL36829
iio: proximity: Add driver for Vishay VCNL36829

 .../iio/proximity/vishay,vcnl36829.yaml       |  55 ++++
 MAINTAINERS                                   |   6 +
 drivers/iio/proximity/Kconfig                 |  11 +
 drivers/iio/proximity/Makefile                |   1 +
 drivers/iio/proximity/vcnl36829.c             | 298 ++++++++++++++++++
 5 files changed, 371 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
 create mode 100644 drivers/iio/proximity/vcnl36829.c

base-commit: 52c36105f76e96b638152a42e735f2e7767ed946

Signature · 1 line
2.53.0
author
#1 lore raw

PATCH v2 1/2 dt-bindings: iio: proximity: Add Vishay VCNL36829

From: Liu Yufei <[email protected]>

Add devicetree binding for the Vishay VCNL36829 proximity sensor.

The VCNL36829 is a proximity sensor with an integrated VCSEL emitter in a small package. It is controlled over I2C and has an interrupt output. It is powered by two supplies, vdd and vddio.

---
v2:
- Collect Reviewed-by from Krzysztof.

 .../iio/proximity/vishay,vcnl36829.yaml       | 55 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml new file +55 -0
new file mode 100644
index 000000000..6f20537ad
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/proximity/vishay,vcnl36829.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: VISHAY VCNL36829 Proximity Sensor
+
+maintainers:
+  - Liu Yufei <[email protected]>
+
+description: |
+  Proximity sensor with VCSEL in an ultra thin small package with I2C
+  interface.
+  Datasheet: https://www.vishay.com/docs/80580/vcnl36829um.pdf
+
+properties:
+  compatible:
+    const: vishay,vcnl36829
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  vddio-supply: true
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+  - vddio-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        proximity@60 {
+            compatible = "vishay,vcnl36829";
+            reg = <0x60>;
+            vdd-supply = <&vdd_reg>;
+            vddio-supply = <&vddio_reg>;
+            interrupt-parent = <&gpio>;
+            interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+        };
+    };
+...
MAINTAINERS +5 -0
index 8014b9f82..e6ef84b49 100644
@@ -28754,6 +28754,11 @@ S:	Maintained
 F:	drivers/input/serio/userio.c
 F:	include/uapi/linux/userio.h
 
+VISHAY VCNL36829 PROXIMITY SENSOR DRIVER
+M:	Liu Yufei <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
+
 VISHAY VEML3235 AMBIENT LIGHT SENSOR DRIVER
 M:	Javier Carrasco <[email protected]>
 S:	Maintained
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH v2 2/2 iio: proximity: Add driver for Vishay VCNL36829

In reply to Liu Yufei

From: Liu Yufei <[email protected]>

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

---
v2:
- Address review comments from Andy (see cover letter for details).

 MAINTAINERS                       |   1 +
 drivers/iio/proximity/Kconfig     |  11 ++
 drivers/iio/proximity/Makefile    |   1 +
 drivers/iio/proximity/vcnl36829.c | 298 ++++++++++++++++++++++++++++++
 4 files changed, 311 insertions(+)
 create mode 100644 drivers/iio/proximity/vcnl36829.c
MAINTAINERS +1 -0
index e6ef84b49..5612b9371 100644
@@ -28758,6 +28758,7 @@ VISHAY VCNL36829 PROXIMITY SENSOR DRIVER
 M:	Liu Yufei <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
+F:	drivers/iio/proximity/vcnl36829.c
 
 VISHAY VEML3235 AMBIENT LIGHT SENSOR DRIVER
 M:	Javier Carrasco <[email protected]>
drivers/iio/proximity/Kconfig +11 -0
index bb77fad2a..f3cec799d 100644
@@ -233,6 +233,17 @@ config VCNL3020
 	  To compile this driver as a module, choose M here: the
 	  module will be called vcnl3020.
 
+config VCNL36829
+	tristate "Vishay VCNL36829 proximity sensor"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y here if you want to build a driver for the Vishay VCNL36829
+	  proximity sensor with integrated VCSEL.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called vcnl36829.
+
 config VL53L0X_I2C
 	tristate "STMicroelectronics VL53L0X ToF ranger sensor (I2C)"
 	depends on I2C
drivers/iio/proximity/Makefile +1 -0
index 4352833dd..8a65e42fb 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_SX9360)		+= sx9360.o
 obj-$(CONFIG_SX_COMMON) 	+= sx_common.o
 obj-$(CONFIG_SX9500)		+= sx9500.o
 obj-$(CONFIG_VCNL3020)		+= vcnl3020.o
+obj-$(CONFIG_VCNL36829)		+= vcnl36829.o
 obj-$(CONFIG_VL53L0X_I2C)	+= vl53l0x-i2c.o
 obj-$(CONFIG_VL53L1X_I2C)	+= vl53l1x-i2c.o
 obj-$(CONFIG_AW96103)		+= aw96103.o
drivers/iio/proximity/vcnl36829.c new file +298 -0

298 lines not on this page · raw message

Signature · 1 line
2.53.0
Reviewed-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] iio: proximity: Add driver for Vishay VCNL36829

Quoted 19 lines · On Tue, 6 Oct 2026 18:09:43 +0800 Liu Yufei <[email protected]> wrote:

From: Liu Yufei <[email protected]>

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

---

...

Quoted 36 lines
drivers/iio/proximity/vcnl36829.c new file +36 -0
+static int vcnl36829_probe(struct i2c_client *client)
+{
+	struct device *dev = &client->dev;
+	struct vcnl36829_data *data;
+	struct iio_dev *indio_dev;
+	struct regmap *regmap;
+	unsigned int reg;
+	int ret;
+
+	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
+	if (!indio_dev)
+		return -ENOMEM;
+
+	regmap = devm_regmap_init_i2c(client, &vcnl36829_regmap_config);
+	if (IS_ERR(regmap))
+		return dev_err_probe(dev, PTR_ERR(regmap), "Regmap setup failed\n");
+
+	data = iio_priv(indio_dev);
+	data->regmap = regmap;
+
+	indio_dev->name = "vcnl36829";
+	indio_dev->info = &vcnl36829_info;
+	indio_dev->channels = vcnl36829_channels;
+	indio_dev->num_channels = ARRAY_SIZE(vcnl36829_channels);
+	indio_dev->modes = INDIO_DIRECT_MODE;
+
+	ret = devm_regulator_get_enable(dev, "vdd");
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to enable vdd\n");
+
+	ret = devm_regulator_get_enable(dev, "vddio");
+	if (ret)
+		return dev_err_probe(dev, ret, "failed to enable vddio\n");
+
+	/*
+	 * The datasheet does not specify a power-up settling time.

drivers/iio/proximity/vcnl36829.c line 234

Quoted 10 lines
drivers/iio/proximity/vcnl36829.c new file +10 -0
+	 * Wait 3 ms after enabling the supplies before accessing the
+	 * device, as a conservative value.
+	 */
+	fsleep(3 * USEC_PER_MSEC);
+
+	ret = regmap_read(regmap, VCNL36829_DEV_ID, &reg);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to read device ID\n");
+	if ((reg & 0xFF) != VCNL36829_DEV_ID_VAL)
+		dev_warn(dev, "Unknown device ID 0x%x\n", reg & 0xFF);

I'd rather be soft and do dev_info() instead (perhaps this could be tweaked when applying).

Otherwise this looks good to me!

Signature · 2 lines
Kind regards,
Joshua Crofts
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] iio: proximity: Add driver for Vishay VCNL36829

In reply to Liu Yufei
Quoted 8 lines · Liu Yufei

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.

Quoted 4 lines

The following attributes are exposed:
- in_proximity0_raw
- in_proximity_integration_time
- in_proximity_integration_time_available

...

drivers/iio/proximity/vcnl36829.c line 117

Quoted 3 lines
drivers/iio/proximity/vcnl36829.c new file +3 -0
+static int vcnl36829_write_raw(struct iio_dev *indio_dev,
+			       struct iio_chan_spec const *chan, int val,
+			       int val2, long mask)

Please, wrap on a logical boundary:

struct iio_chan_spec const *chan, int val, int val2, long mask)

Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#5 lore raw

v3 cover iio: proximity: Add Vishay VCNL36829 driver

In reply to Liu Yufei

From: Liu Yufei <[email protected]>

This series adds support for the Vishay VCNL36829, an I2C proximity sensor with an integrated VCSEL emitter.

Patch 1 adds the devicetree binding.
Patch 2 adds the IIO driver, which exposes the proximity reading and a configurable integration time.

Tested on Orange Pi Zero 2W.

Changes in v3:
- driver: Collect Reviewed-by from Joshua Crofts and Andy Shevchenko.
- driver: Use dev_info() instead of dev_warn() for an unknown device ID (Joshua Crofts).
- driver: Wrap the write_raw() arguments on a logical boundary (Andy Shevchenko).

Changes in v2:
- dt-bindings: Collect Reviewed-by from Krzysztof.
- driver: Address review comments from Andy:
- Use a Datasheet: tag in the commit message.
- Drop mod_devicetable.h, sort the includes and include what is used.
- Drop the i2c_client pointer from the private data and use regmap_get_device() instead.
- Drop the unused i2c_set_clientdata().
- Enable a maple regmap cache, mark PS_DATA and DEV_ID volatile.
- Rework the integration time validation in write_raw().
- Use reverse xmas tree order for local variables.
- Document the power-up delay and use 3 * USEC_PER_MSEC.
- Warn and continue on an unknown device ID instead of failing.
- Join lines that fit within 100 columns.
- Simplify the Assisted-by tag.
- driver: Drop the i2c_check_functionality() call, as devm_regmap_init_i2c() already checks the adapter capabilities.

Link to v2: https://lore.kernel.org/linux-iio/[email protected]/
Link to v1: https://lore.kernel.org/linux-iio/[email protected]/

Liu Yufei (2):
dt-bindings: iio: proximity: Add Vishay VCNL36829
iio: proximity: Add driver for Vishay VCNL36829

 .../iio/proximity/vishay,vcnl36829.yaml       |  55 ++++
 MAINTAINERS                                   |   6 +
 drivers/iio/proximity/Kconfig                 |  11 +
 drivers/iio/proximity/Makefile                |   1 +
 drivers/iio/proximity/vcnl36829.c             | 298 ++++++++++++++++++
 5 files changed, 371 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
 create mode 100644 drivers/iio/proximity/vcnl36829.c

base-commit: 52c36105f76e96b638152a42e735f2e7767ed946

Signature · 1 line
2.53.0
author
#6 lore raw

PATCH v3 1/2 dt-bindings: iio: proximity: Add Vishay VCNL36829

From: Liu Yufei <[email protected]>

Add devicetree binding for the Vishay VCNL36829 proximity sensor.

The VCNL36829 is a proximity sensor with an integrated VCSEL emitter in a small package. It is controlled over I2C and has an interrupt output. It is powered by two supplies, vdd and vddio.

---
v3: No changes.

 .../iio/proximity/vishay,vcnl36829.yaml       | 55 +++++++++++++++++++
 MAINTAINERS                                   |  5 ++
 2 files changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml new file +55 -0
new file mode 100644
index 000000000..6f20537ad
@@ -0,0 +1,55 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/proximity/vishay,vcnl36829.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: VISHAY VCNL36829 Proximity Sensor
+
+maintainers:
+  - Liu Yufei <[email protected]>
+
+description: |
+  Proximity sensor with VCSEL in an ultra thin small package with I2C
+  interface.
+  Datasheet: https://www.vishay.com/docs/80580/vcnl36829um.pdf
+
+properties:
+  compatible:
+    const: vishay,vcnl36829
+
+  reg:
+    maxItems: 1
+
+  vdd-supply: true
+
+  vddio-supply: true
+
+  interrupts:
+    maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - vdd-supply
+  - vddio-supply
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        proximity@60 {
+            compatible = "vishay,vcnl36829";
+            reg = <0x60>;
+            vdd-supply = <&vdd_reg>;
+            vddio-supply = <&vddio_reg>;
+            interrupt-parent = <&gpio>;
+            interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+        };
+    };
+...
MAINTAINERS +5 -0
index 8014b9f82..e6ef84b49 100644
@@ -28754,6 +28754,11 @@ S:	Maintained
 F:	drivers/input/serio/userio.c
 F:	include/uapi/linux/userio.h
 
+VISHAY VCNL36829 PROXIMITY SENSOR DRIVER
+M:	Liu Yufei <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
+
 VISHAY VEML3235 AMBIENT LIGHT SENSOR DRIVER
 M:	Javier Carrasco <[email protected]>
 S:	Maintained
Signature · 1 line
2.53.0
author
#7 lore raw

PATCH v3 2/2 iio: proximity: Add driver for Vishay VCNL36829

In reply to Liu Yufei

From: Liu Yufei <[email protected]>

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

---
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).

 MAINTAINERS                       |   1 +
 drivers/iio/proximity/Kconfig     |  11 ++
 drivers/iio/proximity/Makefile    |   1 +
 drivers/iio/proximity/vcnl36829.c | 298 ++++++++++++++++++++++++++++++
 4 files changed, 311 insertions(+)
 create mode 100644 drivers/iio/proximity/vcnl36829.c
MAINTAINERS +1 -0
index e6ef84b49..5612b9371 100644
@@ -28758,6 +28758,7 @@ VISHAY VCNL36829 PROXIMITY SENSOR DRIVER
 M:	Liu Yufei <[email protected]>
 S:	Maintained
 F:	Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
+F:	drivers/iio/proximity/vcnl36829.c
 
 VISHAY VEML3235 AMBIENT LIGHT SENSOR DRIVER
 M:	Javier Carrasco <[email protected]>
drivers/iio/proximity/Kconfig +11 -0
index bb77fad2a..f3cec799d 100644
@@ -233,6 +233,17 @@ config VCNL3020
 	  To compile this driver as a module, choose M here: the
 	  module will be called vcnl3020.
 
+config VCNL36829
+	tristate "Vishay VCNL36829 proximity sensor"
+	depends on I2C
+	select REGMAP_I2C
+	help
+	  Say Y here if you want to build a driver for the Vishay VCNL36829
+	  proximity sensor with integrated VCSEL.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called vcnl36829.
+
 config VL53L0X_I2C
 	tristate "STMicroelectronics VL53L0X ToF ranger sensor (I2C)"
 	depends on I2C
drivers/iio/proximity/Makefile +1 -0
index 4352833dd..8a65e42fb 100644
@@ -22,6 +22,7 @@ obj-$(CONFIG_SX9360)		+= sx9360.o
 obj-$(CONFIG_SX_COMMON) 	+= sx_common.o
 obj-$(CONFIG_SX9500)		+= sx9500.o
 obj-$(CONFIG_VCNL3020)		+= vcnl3020.o
+obj-$(CONFIG_VCNL36829)		+= vcnl36829.o
 obj-$(CONFIG_VL53L0X_I2C)	+= vl53l0x-i2c.o
 obj-$(CONFIG_VL53L1X_I2C)	+= vl53l1x-i2c.o
 obj-$(CONFIG_AW96103)		+= aw96103.o
drivers/iio/proximity/vcnl36829.c new file +298 -0

298 lines not on this page · raw message

Signature · 1 line
2.53.0
maintainer
#8 lore raw

Re: [PATCH v3 2/2] iio: proximity: Add driver for Vishay VCNL36829

Quoted 20 lines · On Fri, 16 Oct 2026 09:22:18 +0800 Liu Yufei <[email protected]> wrote:

From: Liu Yufei <[email protected]>

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

Quoted 8 lines

---
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.

drivers/iio/proximity/vcnl36829.c line 47

Quoted 8 lines
drivers/iio/proximity/vcnl36829.c new file +2 -0
new file mode 100644
index 000000000..217a32aad
 
+
+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.

Quoted 22 lines
drivers/iio/proximity/vcnl36829.c new file +22 -0
+
+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, &reg);
+		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:

drivers/iio/proximity/vcnl36829.c line 104

Quoted 10 lines
drivers/iio/proximity/vcnl36829.c new file +10 -0
+		ret = regmap_read(regmap, VCNL36829_PS_CONF2, &reg);
+		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.

Quoted 9 lines
drivers/iio/proximity/vcnl36829.c new file +9 -0
+		 */
+		*val = 0;
+		*val2 = FIELD_GET(VCNL36829_PS_IT_MSK, reg) * 25;
+		return IIO_VAL_INT_PLUS_MICRO;
+
+	default:
+		return -EINVAL;
+	}
+}

drivers/iio/proximity/vcnl36829.c line 233

Quoted 10 lines
drivers/iio/proximity/vcnl36829.c new file +7 -0
 
 
+static int vcnl36829_probe(struct i2c_client *client)
+{
 
+
+	ret = regmap_read(regmap, VCNL36829_DEV_ID, &reg);
+	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..

Quoted 2 lines
drivers/iio/proximity/vcnl36829.c new file +1 -0
+		dev_info(dev, "Unknown device ID 0x%x\n", reg & 0xFF);
maintainer
#9 lore raw
In reply to Liu Yufei
Quoted 10 lines · On Fri, 16 Oct 2026 09:22:16 +0800 Liu Yufei <[email protected]> wrote:

From: Liu Yufei <[email protected]>

This series adds support for the Vishay VCNL36829, an I2C proximity sensor with an integrated VCSEL emitter.

Patch 1 adds the devicetree binding.
Patch 2 adds the IIO driver, which exposes the proximity reading and a configurable integration time.

Tested on Orange Pi Zero 2W.

Hi Liu Yufei,

Small process thing first. Start a fresh thread for each version. This is to avoid the treads becoming complex to follow and has the side effect that they actually turn up as 'recent' in reviewer's inboxes.

I'd have looked at this a lot later today (or perhaps not at all) if I didn't happen to notice it in patch work after changing status on another patch.

Jonathan

Quoted 43 lines

Changes in v3:
- driver: Collect Reviewed-by from Joshua Crofts and Andy Shevchenko.
- driver: Use dev_info() instead of dev_warn() for an unknown device ID (Joshua Crofts).
- driver: Wrap the write_raw() arguments on a logical boundary (Andy Shevchenko).

Changes in v2:
- dt-bindings: Collect Reviewed-by from Krzysztof.
- driver: Address review comments from Andy:
- Use a Datasheet: tag in the commit message.
- Drop mod_devicetable.h, sort the includes and include what is used.
- Drop the i2c_client pointer from the private data and use regmap_get_device() instead.
- Drop the unused i2c_set_clientdata().
- Enable a maple regmap cache, mark PS_DATA and DEV_ID volatile.
- Rework the integration time validation in write_raw().
- Use reverse xmas tree order for local variables.
- Document the power-up delay and use 3 * USEC_PER_MSEC.
- Warn and continue on an unknown device ID instead of failing.
- Join lines that fit within 100 columns.
- Simplify the Assisted-by tag.
- driver: Drop the i2c_check_functionality() call, as devm_regmap_init_i2c() already checks the adapter capabilities.

Link to v2: https://lore.kernel.org/linux-iio/[email protected]/
Link to v1: https://lore.kernel.org/linux-iio/[email protected]/

Liu Yufei (2):
dt-bindings: iio: proximity: Add Vishay VCNL36829
iio: proximity: Add driver for Vishay VCNL36829

 .../iio/proximity/vishay,vcnl36829.yaml       |  55 ++++
 MAINTAINERS                                   |   6 +
 drivers/iio/proximity/Kconfig                 |  11 +
 drivers/iio/proximity/Makefile                |   1 +
 drivers/iio/proximity/vcnl36829.c             | 298 ++++++++++++++++++
 5 files changed, 371 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/proximity/vishay,vcnl36829.yaml
 create mode 100644 drivers/iio/proximity/vcnl36829.c

base-commit: 52c36105f76e96b638152a42e735f2e7767ed946