Add 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. For CM36672P, which is
a proximity-only sensor, also remove the IIO_LIGHT channel.

Signed-off-by: Erikas Bitovtas <[email protected]>
---
 drivers/iio/light/vcnl4000.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c
index a36c23813679..97dd930d57f6 100644
--- a/drivers/iio/light/vcnl4000.c
+++ b/drivers/iio/light/vcnl4000.c
@@ -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,
@@ -240,6 +241,8 @@ static const struct i2c_device_id vcnl4000_id[] = {
        { "vcnl4020", VCNL4010 },
        { "vcnl4040", VCNL4040 },
        { "vcnl4200", VCNL4200 },
+       { "cm36672p", CM36672P },
+       { "cm36686", VCNL4040 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, vcnl4000_id);
@@ -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,
@@ -2053,6 +2085,14 @@ static const struct of_device_id vcnl_4000_of_match[] = {
                .compatible = "vishay,vcnl4200",
                .data = (void *)VCNL4200,
        },
+       {
+               .compatible = "capella,cm36672p",
+               .data = (void *)CM36672P,
+       },
+       {
+               .compatible = "capella,cm36686",
+               .data = (void *)VCNL4040,
+       },
        { }
 };
 MODULE_DEVICE_TABLE(of, vcnl_4000_of_match);

-- 
2.53.0


Reply via email to