iio: light: Add support for Capella cm36686 and cm36672p sensors
Subsystems (2)
v5 cover iio: light: Add support for Capella cm36686 and cm36672p sensors
This patch series adds support for Capella cm36686 and cm36672p ambient light and proximity sensors.
Capella cm36686 is a combined ambient light and proximity sensor with adjustable integration time, interrupt and hysteresis support. It has the slave address of 0x60. cm36672p is partially compatible with cm36686, in that it is a proximity-only sensor that shares the same proximity register field interface with cm36686.
Unfortunately, datasheets for these sensors are not publicly available. Initially, this patch series introduced a new driver, which had code based on Android downstream kernels for devices which did use these sensors and a previous submission for cm36672p to mailing lists:
https://github.com/LineageOS/android_kernel_xiaomi_msm8992/blob/cm-14.1/drivers/iio/light/cm36686.c
https://github.com/shakalaca/ASUS_ZenFone_ZD551KL/blob/android-6.0/kernel/drivers/input/misc/cm36283.c
https://lore.kernel.org/linux-iio/[email protected]/
The following code has been tested on Asus ZenFone 2 Laser/Selfie, which uses cm36686 as its ambient light and proximity sensor.
Changes since v4:
- CM36672P is only partially compatible with CM36686, reword patch series commits to reflect that.
- Add comment explaining why we use VCNL4040 device ID for CM36686.
- Link to v4:
https://lore.kernel.org/linux-iio/[email protected]/
Changes since v3 (misversioned as v1):
- Move Capella enum IDs up so device IDs are sorted by string literal.
- Move device tree table entries up so they are sorted by string literal.
- Add a trailing comma to the cm36672p_channels proximity channel entry.
- Link to v3:
https://lore.kernel.org/linux-iio/[email protected]/
Changes since v2:
- Remove the previous unnecessary proposed driver and bindings.
- Add a fallback compatible for cm36686 of vcnl4040.
- Add a new compatible for cm36672p.
- Add channel info for cm36672p.
- Remove redundant information in the dt-bindings commit message.
- Link to v2:
https://lore.kernel.org/linux-iio/[email protected]/
Changes since v1:
- Add copyright information.
- Sort includes in alphabetical order.
- Add trailing commas.
- Remove blank spaces where unnecessary.
- Add a fallback for capella,cm36686 compatible.
- Make power supplies required.
- Add '-microamp' suffix for capella,proximity-led-current.
- Replace local caching and i2c_smbus calls with regmap API.
- Make interrupt optional.
- Add action or reset only after setup is done.
- Replace mutex_[un]lock calls with guard(mutex)
- Add comments on where mutex is used.
- Add comments on proximity register defaults.
- Remove default proximity sensor duty ratio and integration time. Those were taken from the testing device and had no real reason to be there.
- Replace dev_err_probe on device's part ID with a warning.
- Replace chip->supplies property with a single devm_regulator_bulk_get_enable call.
- Use individual structs instead of array-style device info
- Remove enums which are no longer used.
- Link to v1:
https://lore.kernel.org/linux-iio/[email protected]/
---
Erikas Bitovtas (2):
dt-bindings: iio: light: vcnl4000: add Capella CM36686 and CM36672P
iio: light: vcnl4000: add support for Capella CM36686 and CM36672P.../bindings/iio/light/vishay,vcnl4000.yaml | 17 +++++---- drivers/iio/light/vcnl4000.c | 41 ++++++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-)
---
base-commit: 350adaf7fde9fdbd9aeed6d442a9ae90c6a3ab97
change-id: 20260201-cm36686-fc7a8385f1cd
Best regards,
Signature · 1 line
Erikas Bitovtas <[email protected]>
PATCH v5 1/2 dt-bindings: iio: light: vcnl4000: add Capella CM36686 and CM36672P
Capella CM36686 is an ambient light and proximity sensor developed by Capella Microsystems, now a subsidiary of Vishay Intertechnology Inc. It has an I2C address of 0x60 and is fully compatible with an existing driver for VCNL4040. Capella CM36672P is a proximity-only sensor that is partially compatible with CM36686 - they share the same register fields for proximity sensing, but ambient light sensor register fields in CM36672P are reserved. Add compatibles for cm36672p and cm36686, with a fallback for cm36686 of vcnl4040.
--- .../devicetree/bindings/iio/light/vishay,vcnl4000.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
Documentation/devicetree/bindings/iio/light/vishay,vcnl4000.yaml +11 -6
@@ -18,12 +18,17 @@ allOf: properties: compatible: - enum: - - vishay,vcnl4000 - - vishay,vcnl4010 - - vishay,vcnl4020 - - vishay,vcnl4040 - - vishay,vcnl4200 + oneOf: + - enum: + - capella,cm36672p + - vishay,vcnl4000 + - vishay,vcnl4010 + - vishay,vcnl4020 + - vishay,vcnl4040 + - vishay,vcnl4200 + - items: + - const: capella,cm36686 + - const: vishay,vcnl4040 interrupts: maxItems: 1
Signature · 1 line
2.53.0
Re: [PATCH v5 1/2] dt-bindings: iio: light: vcnl4000: add Capella CM36686 and CM36672P
Quoted 10 lines · Erikas Bitovtas
Capella CM36686 is an ambient light and proximity sensor developed by Capella Microsystems, now a subsidiary of Vishay Intertechnology Inc. It has an I2C address of
0x60and is fully compatible with an existing driver for VCNL4040. Capella CM36672P is a proximity-only sensor that is partially compatible with CM36686 - they share the same register fields for proximity sensing, but ambient light sensor register fields in CM36672P are reserved. Add compatibles for cm36672p and cm36686, with a fallback for cm36686 of vcnl4040.Signed-off-by Erikas Bitovtas <[email protected]>
pw-bot: not-applicable
PATCH v5 2/2 iio: light: vcnl4000: add support for Capella CM36686 and CM36672P
In reply to Erikas BitovtasAdd support for Capella's CM36686 and CM36672P sensors. Capella CM36686 is an ambient light and proximity sensor that is fully compatible with VCNL4040 and can be used as is.
CM36672P is partially compatible with VCNL4040 - it uses the same register fields for proximity sensing, but the ambient light registers are reserved. For CM36672P, we reuse vcnl4040_channels, but remove the IIO_LIGHT channel and ambient light integration time.
--- drivers/iio/light/vcnl4000.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/iio/light/vcnl4000.c +41 -0
@@ -185,6 +185,7 @@ static const int vcnl4040_ps_oversampling_ratio[] = {1, 2, 4, 8};#define VCNL4000_SLEEP_DELAY_MS 2000/* before we enter pm_runtime_suspend */ enum vcnl4000_device_ids { +CM36672P ,VCNL4000 ,VCNL4010 ,VCNL4040 ,
@@ -235,6 +236,8 @@ struct vcnl4000_chip_spec { };static const struct i2c_device_id vcnl4000_id[] = { + {"cm36672p" ,CM36672P }, + {"cm36686" ,VCNL4040 }, {"vcnl4000" ,VCNL4000 }, {"vcnl4010" ,VCNL4010 }, {"vcnl4020" ,VCNL4010 },
@@ -1842,6 +1845,22 @@ static const struct iio_chan_spec vcnl4040_channels[] = { } }; +static const struct iio_chan_spec cm36672p_channels[] = { + { + .type =IIO_PROXIMITY , + .info_mask_separate =BIT (IIO_CHAN_INFO_RAW ) | +BIT (IIO_CHAN_INFO_INT_TIME ) | +BIT (IIO_CHAN_INFO_OVERSAMPLING_RATIO ) | +BIT (IIO_CHAN_INFO_CALIBBIAS ), + .info_mask_separate_available =BIT (IIO_CHAN_INFO_INT_TIME ) | +BIT (IIO_CHAN_INFO_OVERSAMPLING_RATIO ) | +BIT (IIO_CHAN_INFO_CALIBBIAS ), + .ext_info = vcnl4000_ext_info, + .event_spec = vcnl4040_event_spec, + .num_event_specs =ARRAY_SIZE (vcnl4040_event_spec), + }, +}; +static const struct iio_info vcnl4000_info = { .read_raw = vcnl4000_read_raw, };
@@ -1867,6 +1886,19 @@ static const struct iio_info vcnl4040_info = { };static const struct vcnl4000_chip_spec vcnl4000_chip_spec_cfg[] = { + [CM36672P ] = { + .prod ="CM36672P" , + .init = vcnl4200_init, + .measure_proximity = vcnl4200_measure_proximity, + .set_power_state = vcnl4200_set_power_state, + .channels = cm36672p_channels, + .num_channels =ARRAY_SIZE (cm36672p_channels), + .info = &vcnl4040_info, + .irq_thread = vcnl4040_irq_thread, + .int_reg =VCNL4040_INT_FLAGS , + .ps_it_times = &vcnl4040_ps_it_times, + .num_ps_it_times =ARRAY_SIZE (vcnl4040_ps_it_times), + }, [VCNL4000 ] = { .prod ="VCNL4000" , .init = vcnl4000_init,
@@ -2033,6 +2065,15 @@ static int vcnl4000_probe(struct i2c_client *client) }static const struct of_device_id vcnl_4000_of_match[] = { + { + .compatible ="capella,cm36672p" , + .data = (void *)CM36672P , + }, +/* Capella CM36686 is fully compatible with Vishay VCNL4040 */ + { + .compatible ="capella,cm36686" , + .data = (void *)VCNL4040 , + }, { .compatible ="vishay,vcnl4000" , .data = (void *)VCNL4000 ,
Signature · 1 line
2.53.0
Jonathan Cameron
maintainerQuoted 3 lines · On Tue, 17 Feb 2026 14:13:14 +0200 Erikas Bitovtas <[email protected]> wrote:
This patch series adds support for Capella cm36686 and cm36672p ambient light and proximity sensors.
Series applied to the testing branch of iio.git.
I'll be rebasing on rc1 after the weekend and then pushing out as togreg for linux-next to pick up.
Thanks,
Jonathan