Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Hi Marcus, On 08/19/2018 11:50 PM, Marcus Folkesson wrote: Hi, On Tue, Aug 07, 2018 at 12:27:03PM +0200, Parthiban Nallathambi wrote: Add support for VCNL4035, which is capable of Ambient light sensing (ALS) and proximity function. This patch adds support only for ALS function Signed-off-by: Parthiban Nallathambi Changelog since v1: 1. Fixed 0-day warning on le16_to_cpu usage 2. Persistence value is directly mapped to datasheet's value to avoid confusions of usage from sysfs Changelog in v3: - Usage of lock is not needed, removed mutex locking - ALS threshold and persistence configuration available as events and threshold events are notified to userspace - Usage of devm_ is re-ordered and exit handling updated - Complexity in timestamp calculation is removed and used iio_get_time_ns Changelog in v4: - New white light index is introduced for getting data from white spectrum - PM enable/disable is called from read_raw accordingly - Probe exit handling re-ordered Changelog in v5: - White spectrum is mesaured as "_CLEAR" intesity, so removed white spectrum modifier - Header re-ordering - Trigger init and de-init into separate function - Indentation correct and usage of dev_err in place of pr_err Changelog in v6: - Usage of devm_ for trigger probing and cleanups - pm_runtime re-order and exit patch corrections - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle lux can be calculated based on IT sensitivity - _CLEAR to _BOTH although measurement is only WHITE spectrum for traditional reasons --- As Jonathan already pointed out, the changelog should go here. A tip is to use notes (see `man git-notes`) to add a changelog and then generate the patches with `git format-patch --notes `. I find it really neat. Sure, thanks for the hint about git notes. drivers/iio/light/Kconfig| 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/vcnl4035.c | 686 +++ 3 files changed, 699 insertions(+) create mode 100644 drivers/iio/light/vcnl4035.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index c7ef8d1862d6..b7069a4c28a2 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -447,6 +447,18 @@ config VCNL4000 To compile this driver as a module, choose M here: the module will be called vcnl4000. +config VCNL4035 + tristate "VCNL4035 combined ALS and proximity sensor" + select REGMAP_I2C + depends on I2C + help +Say Y here if you want to build a driver for the Vishay VCNL4035, +combined ambient light (ALS) and proximity sensor. Currently only ALS +function is available. + +To compile this driver as a module, choose M here: the +module will be called vcnl4035. + config VEML6070 tristate "VEML6070 UV A light sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 80943af5d627..dce98511a59b 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o obj-$(CONFIG_VCNL4000)+= vcnl4000.o +obj-$(CONFIG_VCNL4035) += vcnl4035.o obj-$(CONFIG_VEML6070)+= veml6070.o obj-$(CONFIG_VL6180) += vl6180.o obj-$(CONFIG_ZOPT2201)+= zopt2201.o diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c new file mode 100644 index ..e9f471d93a15 --- /dev/null +++ b/drivers/iio/light/vcnl4035.c @@ -0,0 +1,686 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 + * + * Copyright (c) 2018, DENX Software Engineering GmbH + * Author: Parthiban Nallathambi + * + * + * TODO: Proximity + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define VCNL4035_DRV_NAME "vcnl4035" +#define VCNL4035_IRQ_NAME "vcnl4035_event" +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" + +/* Device registers */ +#define VCNL4035_ALS_CONF 0x00 +#define VCNL4035_ALS_THDH 0x01 +#define VCNL4035_ALS_THDL 0x02 +#define VCNL4035_ALS_DATA 0x0B +#define VCNL4035_WHITE_DATA0x0C +#define VCNL4035_INT_FLAG 0x0D +#define VCNL4035_DEV_ID0x0E + +/* Register masks */ +#define VCNL4035_MODE_ALS_MASK BIT(0) +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) + +/* Default values */ +#define VCNL4035_MODE_ALS_ENABLE BIT(0) +#define VCNL4035_MODE_ALS_DISABLE 0x00 +#define
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Hi Marcus, On 08/19/2018 11:50 PM, Marcus Folkesson wrote: Hi, On Tue, Aug 07, 2018 at 12:27:03PM +0200, Parthiban Nallathambi wrote: Add support for VCNL4035, which is capable of Ambient light sensing (ALS) and proximity function. This patch adds support only for ALS function Signed-off-by: Parthiban Nallathambi Changelog since v1: 1. Fixed 0-day warning on le16_to_cpu usage 2. Persistence value is directly mapped to datasheet's value to avoid confusions of usage from sysfs Changelog in v3: - Usage of lock is not needed, removed mutex locking - ALS threshold and persistence configuration available as events and threshold events are notified to userspace - Usage of devm_ is re-ordered and exit handling updated - Complexity in timestamp calculation is removed and used iio_get_time_ns Changelog in v4: - New white light index is introduced for getting data from white spectrum - PM enable/disable is called from read_raw accordingly - Probe exit handling re-ordered Changelog in v5: - White spectrum is mesaured as "_CLEAR" intesity, so removed white spectrum modifier - Header re-ordering - Trigger init and de-init into separate function - Indentation correct and usage of dev_err in place of pr_err Changelog in v6: - Usage of devm_ for trigger probing and cleanups - pm_runtime re-order and exit patch corrections - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle lux can be calculated based on IT sensitivity - _CLEAR to _BOTH although measurement is only WHITE spectrum for traditional reasons --- As Jonathan already pointed out, the changelog should go here. A tip is to use notes (see `man git-notes`) to add a changelog and then generate the patches with `git format-patch --notes `. I find it really neat. Sure, thanks for the hint about git notes. drivers/iio/light/Kconfig| 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/vcnl4035.c | 686 +++ 3 files changed, 699 insertions(+) create mode 100644 drivers/iio/light/vcnl4035.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index c7ef8d1862d6..b7069a4c28a2 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -447,6 +447,18 @@ config VCNL4000 To compile this driver as a module, choose M here: the module will be called vcnl4000. +config VCNL4035 + tristate "VCNL4035 combined ALS and proximity sensor" + select REGMAP_I2C + depends on I2C + help +Say Y here if you want to build a driver for the Vishay VCNL4035, +combined ambient light (ALS) and proximity sensor. Currently only ALS +function is available. + +To compile this driver as a module, choose M here: the +module will be called vcnl4035. + config VEML6070 tristate "VEML6070 UV A light sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 80943af5d627..dce98511a59b 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o obj-$(CONFIG_VCNL4000)+= vcnl4000.o +obj-$(CONFIG_VCNL4035) += vcnl4035.o obj-$(CONFIG_VEML6070)+= veml6070.o obj-$(CONFIG_VL6180) += vl6180.o obj-$(CONFIG_ZOPT2201)+= zopt2201.o diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c new file mode 100644 index ..e9f471d93a15 --- /dev/null +++ b/drivers/iio/light/vcnl4035.c @@ -0,0 +1,686 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 + * + * Copyright (c) 2018, DENX Software Engineering GmbH + * Author: Parthiban Nallathambi + * + * + * TODO: Proximity + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define VCNL4035_DRV_NAME "vcnl4035" +#define VCNL4035_IRQ_NAME "vcnl4035_event" +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" + +/* Device registers */ +#define VCNL4035_ALS_CONF 0x00 +#define VCNL4035_ALS_THDH 0x01 +#define VCNL4035_ALS_THDL 0x02 +#define VCNL4035_ALS_DATA 0x0B +#define VCNL4035_WHITE_DATA0x0C +#define VCNL4035_INT_FLAG 0x0D +#define VCNL4035_DEV_ID0x0E + +/* Register masks */ +#define VCNL4035_MODE_ALS_MASK BIT(0) +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) + +/* Default values */ +#define VCNL4035_MODE_ALS_ENABLE BIT(0) +#define VCNL4035_MODE_ALS_DISABLE 0x00 +#define
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Hi, On Tue, Aug 07, 2018 at 12:27:03PM +0200, Parthiban Nallathambi wrote: > Add support for VCNL4035, which is capable of Ambient light > sensing (ALS) and proximity function. This patch adds support > only for ALS function > > Signed-off-by: Parthiban Nallathambi > > Changelog since v1: > > 1. Fixed 0-day warning on le16_to_cpu usage > 2. Persistence value is directly mapped to datasheet's value to > avoid confusions of usage from sysfs > > Changelog in v3: > - Usage of lock is not needed, removed mutex locking > - ALS threshold and persistence configuration available > as events and threshold events are notified to userspace > - Usage of devm_ is re-ordered and exit handling updated > - Complexity in timestamp calculation is removed and used > iio_get_time_ns > > Changelog in v4: > - New white light index is introduced for getting data from > white spectrum > - PM enable/disable is called from read_raw accordingly > - Probe exit handling re-ordered > > Changelog in v5: > - White spectrum is mesaured as "_CLEAR" intesity, so removed > white spectrum modifier > - Header re-ordering > - Trigger init and de-init into separate function > - Indentation correct and usage of dev_err in place of pr_err > > Changelog in v6: > - Usage of devm_ for trigger probing and cleanups > - pm_runtime re-order and exit patch corrections > - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle > lux can be calculated based on IT sensitivity > - _CLEAR to _BOTH although measurement is only WHITE spectrum > for traditional reasons > --- As Jonathan already pointed out, the changelog should go here. A tip is to use notes (see `man git-notes`) to add a changelog and then generate the patches with `git format-patch --notes `. I find it really neat. > drivers/iio/light/Kconfig| 12 + > drivers/iio/light/Makefile | 1 + > drivers/iio/light/vcnl4035.c | 686 > +++ > 3 files changed, 699 insertions(+) > create mode 100644 drivers/iio/light/vcnl4035.c > > diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig > index c7ef8d1862d6..b7069a4c28a2 100644 > --- a/drivers/iio/light/Kconfig > +++ b/drivers/iio/light/Kconfig > @@ -447,6 +447,18 @@ config VCNL4000 >To compile this driver as a module, choose M here: the >module will be called vcnl4000. > > +config VCNL4035 > + tristate "VCNL4035 combined ALS and proximity sensor" > + select REGMAP_I2C > + depends on I2C > + help > + Say Y here if you want to build a driver for the Vishay VCNL4035, > + combined ambient light (ALS) and proximity sensor. Currently only ALS > + function is available. > + > + To compile this driver as a module, choose M here: the > + module will be called vcnl4035. > + > config VEML6070 > tristate "VEML6070 UV A light sensor" > depends on I2C > diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile > index 80943af5d627..dce98511a59b 100644 > --- a/drivers/iio/light/Makefile > +++ b/drivers/iio/light/Makefile > @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o > obj-$(CONFIG_TSL4531)+= tsl4531.o > obj-$(CONFIG_US5182D)+= us5182d.o > obj-$(CONFIG_VCNL4000) += vcnl4000.o > +obj-$(CONFIG_VCNL4035) += vcnl4035.o > obj-$(CONFIG_VEML6070) += veml6070.o > obj-$(CONFIG_VL6180) += vl6180.o > obj-$(CONFIG_ZOPT2201) += zopt2201.o > diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c > new file mode 100644 > index ..e9f471d93a15 > --- /dev/null > +++ b/drivers/iio/light/vcnl4035.c > @@ -0,0 +1,686 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 > + * > + * Copyright (c) 2018, DENX Software Engineering GmbH > + * Author: Parthiban Nallathambi > + * > + * > + * TODO: Proximity > + */ > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define VCNL4035_DRV_NAME"vcnl4035" > +#define VCNL4035_IRQ_NAME"vcnl4035_event" > +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" > + > +/* Device registers */ > +#define VCNL4035_ALS_CONF0x00 > +#define VCNL4035_ALS_THDH0x01 > +#define VCNL4035_ALS_THDL0x02 > +#define VCNL4035_ALS_DATA0x0B > +#define VCNL4035_WHITE_DATA 0x0C > +#define VCNL4035_INT_FLAG0x0D > +#define VCNL4035_DEV_ID 0x0E > + > +/* Register masks */ > +#define VCNL4035_MODE_ALS_MASK BIT(0) > +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) > +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) > +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) > +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) > +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) > +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) > + > +/* Default values */
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Hi, On Tue, Aug 07, 2018 at 12:27:03PM +0200, Parthiban Nallathambi wrote: > Add support for VCNL4035, which is capable of Ambient light > sensing (ALS) and proximity function. This patch adds support > only for ALS function > > Signed-off-by: Parthiban Nallathambi > > Changelog since v1: > > 1. Fixed 0-day warning on le16_to_cpu usage > 2. Persistence value is directly mapped to datasheet's value to > avoid confusions of usage from sysfs > > Changelog in v3: > - Usage of lock is not needed, removed mutex locking > - ALS threshold and persistence configuration available > as events and threshold events are notified to userspace > - Usage of devm_ is re-ordered and exit handling updated > - Complexity in timestamp calculation is removed and used > iio_get_time_ns > > Changelog in v4: > - New white light index is introduced for getting data from > white spectrum > - PM enable/disable is called from read_raw accordingly > - Probe exit handling re-ordered > > Changelog in v5: > - White spectrum is mesaured as "_CLEAR" intesity, so removed > white spectrum modifier > - Header re-ordering > - Trigger init and de-init into separate function > - Indentation correct and usage of dev_err in place of pr_err > > Changelog in v6: > - Usage of devm_ for trigger probing and cleanups > - pm_runtime re-order and exit patch corrections > - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle > lux can be calculated based on IT sensitivity > - _CLEAR to _BOTH although measurement is only WHITE spectrum > for traditional reasons > --- As Jonathan already pointed out, the changelog should go here. A tip is to use notes (see `man git-notes`) to add a changelog and then generate the patches with `git format-patch --notes `. I find it really neat. > drivers/iio/light/Kconfig| 12 + > drivers/iio/light/Makefile | 1 + > drivers/iio/light/vcnl4035.c | 686 > +++ > 3 files changed, 699 insertions(+) > create mode 100644 drivers/iio/light/vcnl4035.c > > diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig > index c7ef8d1862d6..b7069a4c28a2 100644 > --- a/drivers/iio/light/Kconfig > +++ b/drivers/iio/light/Kconfig > @@ -447,6 +447,18 @@ config VCNL4000 >To compile this driver as a module, choose M here: the >module will be called vcnl4000. > > +config VCNL4035 > + tristate "VCNL4035 combined ALS and proximity sensor" > + select REGMAP_I2C > + depends on I2C > + help > + Say Y here if you want to build a driver for the Vishay VCNL4035, > + combined ambient light (ALS) and proximity sensor. Currently only ALS > + function is available. > + > + To compile this driver as a module, choose M here: the > + module will be called vcnl4035. > + > config VEML6070 > tristate "VEML6070 UV A light sensor" > depends on I2C > diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile > index 80943af5d627..dce98511a59b 100644 > --- a/drivers/iio/light/Makefile > +++ b/drivers/iio/light/Makefile > @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o > obj-$(CONFIG_TSL4531)+= tsl4531.o > obj-$(CONFIG_US5182D)+= us5182d.o > obj-$(CONFIG_VCNL4000) += vcnl4000.o > +obj-$(CONFIG_VCNL4035) += vcnl4035.o > obj-$(CONFIG_VEML6070) += veml6070.o > obj-$(CONFIG_VL6180) += vl6180.o > obj-$(CONFIG_ZOPT2201) += zopt2201.o > diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c > new file mode 100644 > index ..e9f471d93a15 > --- /dev/null > +++ b/drivers/iio/light/vcnl4035.c > @@ -0,0 +1,686 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 > + * > + * Copyright (c) 2018, DENX Software Engineering GmbH > + * Author: Parthiban Nallathambi > + * > + * > + * TODO: Proximity > + */ > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define VCNL4035_DRV_NAME"vcnl4035" > +#define VCNL4035_IRQ_NAME"vcnl4035_event" > +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" > + > +/* Device registers */ > +#define VCNL4035_ALS_CONF0x00 > +#define VCNL4035_ALS_THDH0x01 > +#define VCNL4035_ALS_THDL0x02 > +#define VCNL4035_ALS_DATA0x0B > +#define VCNL4035_WHITE_DATA 0x0C > +#define VCNL4035_INT_FLAG0x0D > +#define VCNL4035_DEV_ID 0x0E > + > +/* Register masks */ > +#define VCNL4035_MODE_ALS_MASK BIT(0) > +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) > +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) > +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) > +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) > +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) > +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) > + > +/* Default values */
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
On Tue, 7 Aug 2018 12:27:03 +0200 Parthiban Nallathambi wrote: > Add support for VCNL4035, which is capable of Ambient light > sensing (ALS) and proximity function. This patch adds support > only for ALS function > > Signed-off-by: Parthiban Nallathambi > Changelog should be below the --- as we don't want it in the final git commit log. > Changelog since v1: > > 1. Fixed 0-day warning on le16_to_cpu usage > 2. Persistence value is directly mapped to datasheet's value to > avoid confusions of usage from sysfs > > Changelog in v3: > - Usage of lock is not needed, removed mutex locking > - ALS threshold and persistence configuration available > as events and threshold events are notified to userspace > - Usage of devm_ is re-ordered and exit handling updated > - Complexity in timestamp calculation is removed and used > iio_get_time_ns > > Changelog in v4: > - New white light index is introduced for getting data from > white spectrum > - PM enable/disable is called from read_raw accordingly > - Probe exit handling re-ordered > > Changelog in v5: > - White spectrum is mesaured as "_CLEAR" intesity, so removed > white spectrum modifier > - Header re-ordering > - Trigger init and de-init into separate function > - Indentation correct and usage of dev_err in place of pr_err > > Changelog in v6: > - Usage of devm_ for trigger probing and cleanups > - pm_runtime re-order and exit patch corrections > - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle > lux can be calculated based on IT sensitivity > - _CLEAR to _BOTH although measurement is only WHITE spectrum > for traditional reasons My main issue remaining in here is with the ordering in probe and remove. It becomes very messy and unclear once runtime_pm is present. I've note how I think that can be cleaned up though such that the remove is the obvious unwind of the probe. Unless I missing something (more than possible on a Sunday evening after a nice dinner :) you aren't actually stopping the device from auto suspending when running in buffered mode. Jonathan > --- > drivers/iio/light/Kconfig| 12 + > drivers/iio/light/Makefile | 1 + > drivers/iio/light/vcnl4035.c | 686 > +++ > 3 files changed, 699 insertions(+) > create mode 100644 drivers/iio/light/vcnl4035.c > > diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig > index c7ef8d1862d6..b7069a4c28a2 100644 > --- a/drivers/iio/light/Kconfig > +++ b/drivers/iio/light/Kconfig > @@ -447,6 +447,18 @@ config VCNL4000 >To compile this driver as a module, choose M here: the >module will be called vcnl4000. > > +config VCNL4035 > + tristate "VCNL4035 combined ALS and proximity sensor" > + select REGMAP_I2C > + depends on I2C > + help > + Say Y here if you want to build a driver for the Vishay VCNL4035, > + combined ambient light (ALS) and proximity sensor. Currently only ALS > + function is available. > + > + To compile this driver as a module, choose M here: the > + module will be called vcnl4035. > + > config VEML6070 > tristate "VEML6070 UV A light sensor" > depends on I2C > diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile > index 80943af5d627..dce98511a59b 100644 > --- a/drivers/iio/light/Makefile > +++ b/drivers/iio/light/Makefile > @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o > obj-$(CONFIG_TSL4531)+= tsl4531.o > obj-$(CONFIG_US5182D)+= us5182d.o > obj-$(CONFIG_VCNL4000) += vcnl4000.o > +obj-$(CONFIG_VCNL4035) += vcnl4035.o > obj-$(CONFIG_VEML6070) += veml6070.o > obj-$(CONFIG_VL6180) += vl6180.o > obj-$(CONFIG_ZOPT2201) += zopt2201.o > diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c > new file mode 100644 > index ..e9f471d93a15 > --- /dev/null > +++ b/drivers/iio/light/vcnl4035.c > @@ -0,0 +1,686 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 > + * > + * Copyright (c) 2018, DENX Software Engineering GmbH > + * Author: Parthiban Nallathambi > + * Nitpick. One blank line is plenty here. > + * > + * TODO: Proximity > + */ > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define VCNL4035_DRV_NAME"vcnl4035" > +#define VCNL4035_IRQ_NAME"vcnl4035_event" > +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" > + > +/* Device registers */ > +#define VCNL4035_ALS_CONF0x00 > +#define VCNL4035_ALS_THDH0x01 > +#define VCNL4035_ALS_THDL0x02 > +#define VCNL4035_ALS_DATA0x0B > +#define VCNL4035_WHITE_DATA 0x0C > +#define VCNL4035_INT_FLAG0x0D > +#define VCNL4035_DEV_ID 0x0E > + > +/* Register masks */ > +#define VCNL4035_MODE_ALS_MASK
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
On Tue, 7 Aug 2018 12:27:03 +0200 Parthiban Nallathambi wrote: > Add support for VCNL4035, which is capable of Ambient light > sensing (ALS) and proximity function. This patch adds support > only for ALS function > > Signed-off-by: Parthiban Nallathambi > Changelog should be below the --- as we don't want it in the final git commit log. > Changelog since v1: > > 1. Fixed 0-day warning on le16_to_cpu usage > 2. Persistence value is directly mapped to datasheet's value to > avoid confusions of usage from sysfs > > Changelog in v3: > - Usage of lock is not needed, removed mutex locking > - ALS threshold and persistence configuration available > as events and threshold events are notified to userspace > - Usage of devm_ is re-ordered and exit handling updated > - Complexity in timestamp calculation is removed and used > iio_get_time_ns > > Changelog in v4: > - New white light index is introduced for getting data from > white spectrum > - PM enable/disable is called from read_raw accordingly > - Probe exit handling re-ordered > > Changelog in v5: > - White spectrum is mesaured as "_CLEAR" intesity, so removed > white spectrum modifier > - Header re-ordering > - Trigger init and de-init into separate function > - Indentation correct and usage of dev_err in place of pr_err > > Changelog in v6: > - Usage of devm_ for trigger probing and cleanups > - pm_runtime re-order and exit patch corrections > - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle > lux can be calculated based on IT sensitivity > - _CLEAR to _BOTH although measurement is only WHITE spectrum > for traditional reasons My main issue remaining in here is with the ordering in probe and remove. It becomes very messy and unclear once runtime_pm is present. I've note how I think that can be cleaned up though such that the remove is the obvious unwind of the probe. Unless I missing something (more than possible on a Sunday evening after a nice dinner :) you aren't actually stopping the device from auto suspending when running in buffered mode. Jonathan > --- > drivers/iio/light/Kconfig| 12 + > drivers/iio/light/Makefile | 1 + > drivers/iio/light/vcnl4035.c | 686 > +++ > 3 files changed, 699 insertions(+) > create mode 100644 drivers/iio/light/vcnl4035.c > > diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig > index c7ef8d1862d6..b7069a4c28a2 100644 > --- a/drivers/iio/light/Kconfig > +++ b/drivers/iio/light/Kconfig > @@ -447,6 +447,18 @@ config VCNL4000 >To compile this driver as a module, choose M here: the >module will be called vcnl4000. > > +config VCNL4035 > + tristate "VCNL4035 combined ALS and proximity sensor" > + select REGMAP_I2C > + depends on I2C > + help > + Say Y here if you want to build a driver for the Vishay VCNL4035, > + combined ambient light (ALS) and proximity sensor. Currently only ALS > + function is available. > + > + To compile this driver as a module, choose M here: the > + module will be called vcnl4035. > + > config VEML6070 > tristate "VEML6070 UV A light sensor" > depends on I2C > diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile > index 80943af5d627..dce98511a59b 100644 > --- a/drivers/iio/light/Makefile > +++ b/drivers/iio/light/Makefile > @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o > obj-$(CONFIG_TSL4531)+= tsl4531.o > obj-$(CONFIG_US5182D)+= us5182d.o > obj-$(CONFIG_VCNL4000) += vcnl4000.o > +obj-$(CONFIG_VCNL4035) += vcnl4035.o > obj-$(CONFIG_VEML6070) += veml6070.o > obj-$(CONFIG_VL6180) += vl6180.o > obj-$(CONFIG_ZOPT2201) += zopt2201.o > diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c > new file mode 100644 > index ..e9f471d93a15 > --- /dev/null > +++ b/drivers/iio/light/vcnl4035.c > @@ -0,0 +1,686 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 > + * > + * Copyright (c) 2018, DENX Software Engineering GmbH > + * Author: Parthiban Nallathambi > + * Nitpick. One blank line is plenty here. > + * > + * TODO: Proximity > + */ > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define VCNL4035_DRV_NAME"vcnl4035" > +#define VCNL4035_IRQ_NAME"vcnl4035_event" > +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" > + > +/* Device registers */ > +#define VCNL4035_ALS_CONF0x00 > +#define VCNL4035_ALS_THDH0x01 > +#define VCNL4035_ALS_THDL0x02 > +#define VCNL4035_ALS_DATA0x0B > +#define VCNL4035_WHITE_DATA 0x0C > +#define VCNL4035_INT_FLAG0x0D > +#define VCNL4035_DEV_ID 0x0E > + > +/* Register masks */ > +#define VCNL4035_MODE_ALS_MASK
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
On Sat, 11 Aug 2018 23:25:41 +0800 kbuild test robot wrote: > Hi Parthiban, > > Thank you for the patch! Yet something to improve: The issue here is I think that you should be simply calling hweight8 rather than directly calling the fallback software version. I 'might' fix that up if it is the only issue known to remain. Thanks, Jonathan > > [auto build test ERROR on iio/togreg] > [also build test ERROR on v4.18-rc8 next-20180810] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > url: > https://github.com/0day-ci/linux/commits/Parthiban-Nallathambi/iio-light-Add-support-for-vishay-vcnl4035/20180810-012903 > base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg > config: ia64-allmodconfig (attached as .config) > compiler: ia64-linux-gcc (GCC) 8.1.0 > reproduce: > wget > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O > ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > GCC_VERSION=8.1.0 make.cross ARCH=ia64 > > All errors (new ones prefixed by >>): > >ERROR: "ia64_delay_loop" [drivers/spi/spi-thunderx.ko] undefined! >ERROR: "__sw_hweight8" [drivers/net/wireless/mediatek/mt76/mt76.ko] > undefined! >ERROR: "ia64_delay_loop" [drivers/net/phy/mdio-cavium.ko] undefined! > >> ERROR: "__sw_hweight8" [drivers/iio/light/vcnl4035.ko] undefined! > > --- > 0-DAY kernel test infrastructureOpen Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
On Sat, 11 Aug 2018 23:25:41 +0800 kbuild test robot wrote: > Hi Parthiban, > > Thank you for the patch! Yet something to improve: The issue here is I think that you should be simply calling hweight8 rather than directly calling the fallback software version. I 'might' fix that up if it is the only issue known to remain. Thanks, Jonathan > > [auto build test ERROR on iio/togreg] > [also build test ERROR on v4.18-rc8 next-20180810] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > url: > https://github.com/0day-ci/linux/commits/Parthiban-Nallathambi/iio-light-Add-support-for-vishay-vcnl4035/20180810-012903 > base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg > config: ia64-allmodconfig (attached as .config) > compiler: ia64-linux-gcc (GCC) 8.1.0 > reproduce: > wget > https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O > ~/bin/make.cross > chmod +x ~/bin/make.cross > # save the attached .config to linux build tree > GCC_VERSION=8.1.0 make.cross ARCH=ia64 > > All errors (new ones prefixed by >>): > >ERROR: "ia64_delay_loop" [drivers/spi/spi-thunderx.ko] undefined! >ERROR: "__sw_hweight8" [drivers/net/wireless/mediatek/mt76/mt76.ko] > undefined! >ERROR: "ia64_delay_loop" [drivers/net/phy/mdio-cavium.ko] undefined! > >> ERROR: "__sw_hweight8" [drivers/iio/light/vcnl4035.ko] undefined! > > --- > 0-DAY kernel test infrastructureOpen Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Hi Parthiban, Thank you for the patch! Yet something to improve: [auto build test ERROR on iio/togreg] [also build test ERROR on v4.18-rc8 next-20180810] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Parthiban-Nallathambi/iio-light-Add-support-for-vishay-vcnl4035/20180810-012903 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 8.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=8.1.0 make.cross ARCH=ia64 All errors (new ones prefixed by >>): ERROR: "ia64_delay_loop" [drivers/spi/spi-thunderx.ko] undefined! ERROR: "__sw_hweight8" [drivers/net/wireless/mediatek/mt76/mt76.ko] undefined! ERROR: "ia64_delay_loop" [drivers/net/phy/mdio-cavium.ko] undefined! >> ERROR: "__sw_hweight8" [drivers/iio/light/vcnl4035.ko] undefined! --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Hi Parthiban, Thank you for the patch! Yet something to improve: [auto build test ERROR on iio/togreg] [also build test ERROR on v4.18-rc8 next-20180810] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Parthiban-Nallathambi/iio-light-Add-support-for-vishay-vcnl4035/20180810-012903 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 8.1.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=8.1.0 make.cross ARCH=ia64 All errors (new ones prefixed by >>): ERROR: "ia64_delay_loop" [drivers/spi/spi-thunderx.ko] undefined! ERROR: "__sw_hweight8" [drivers/net/wireless/mediatek/mt76/mt76.ko] undefined! ERROR: "ia64_delay_loop" [drivers/net/phy/mdio-cavium.ko] undefined! >> ERROR: "__sw_hweight8" [drivers/iio/light/vcnl4035.ko] undefined! --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Add support for VCNL4035, which is capable of Ambient light sensing (ALS) and proximity function. This patch adds support only for ALS function Signed-off-by: Parthiban Nallathambi Changelog since v1: 1. Fixed 0-day warning on le16_to_cpu usage 2. Persistence value is directly mapped to datasheet's value to avoid confusions of usage from sysfs Changelog in v3: - Usage of lock is not needed, removed mutex locking - ALS threshold and persistence configuration available as events and threshold events are notified to userspace - Usage of devm_ is re-ordered and exit handling updated - Complexity in timestamp calculation is removed and used iio_get_time_ns Changelog in v4: - New white light index is introduced for getting data from white spectrum - PM enable/disable is called from read_raw accordingly - Probe exit handling re-ordered Changelog in v5: - White spectrum is mesaured as "_CLEAR" intesity, so removed white spectrum modifier - Header re-ordering - Trigger init and de-init into separate function - Indentation correct and usage of dev_err in place of pr_err Changelog in v6: - Usage of devm_ for trigger probing and cleanups - pm_runtime re-order and exit patch corrections - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle lux can be calculated based on IT sensitivity - _CLEAR to _BOTH although measurement is only WHITE spectrum for traditional reasons --- drivers/iio/light/Kconfig| 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/vcnl4035.c | 686 +++ 3 files changed, 699 insertions(+) create mode 100644 drivers/iio/light/vcnl4035.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index c7ef8d1862d6..b7069a4c28a2 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -447,6 +447,18 @@ config VCNL4000 To compile this driver as a module, choose M here: the module will be called vcnl4000. +config VCNL4035 + tristate "VCNL4035 combined ALS and proximity sensor" + select REGMAP_I2C + depends on I2C + help +Say Y here if you want to build a driver for the Vishay VCNL4035, +combined ambient light (ALS) and proximity sensor. Currently only ALS +function is available. + +To compile this driver as a module, choose M here: the +module will be called vcnl4035. + config VEML6070 tristate "VEML6070 UV A light sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 80943af5d627..dce98511a59b 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o obj-$(CONFIG_VCNL4000) += vcnl4000.o +obj-$(CONFIG_VCNL4035) += vcnl4035.o obj-$(CONFIG_VEML6070) += veml6070.o obj-$(CONFIG_VL6180) += vl6180.o obj-$(CONFIG_ZOPT2201) += zopt2201.o diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c new file mode 100644 index ..e9f471d93a15 --- /dev/null +++ b/drivers/iio/light/vcnl4035.c @@ -0,0 +1,686 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 + * + * Copyright (c) 2018, DENX Software Engineering GmbH + * Author: Parthiban Nallathambi + * + * + * TODO: Proximity + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define VCNL4035_DRV_NAME "vcnl4035" +#define VCNL4035_IRQ_NAME "vcnl4035_event" +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" + +/* Device registers */ +#define VCNL4035_ALS_CONF 0x00 +#define VCNL4035_ALS_THDH 0x01 +#define VCNL4035_ALS_THDL 0x02 +#define VCNL4035_ALS_DATA 0x0B +#define VCNL4035_WHITE_DATA0x0C +#define VCNL4035_INT_FLAG 0x0D +#define VCNL4035_DEV_ID0x0E + +/* Register masks */ +#define VCNL4035_MODE_ALS_MASK BIT(0) +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) + +/* Default values */ +#define VCNL4035_MODE_ALS_ENABLE BIT(0) +#define VCNL4035_MODE_ALS_DISABLE 0x00 +#define VCNL4035_MODE_ALS_INT_ENABLE BIT(1) +#define VCNL4035_MODE_ALS_INT_DISABLE 0 +#define VCNL4035_DEV_ID_VAL0x80 +#define VCNL4035_ALS_IT_DEFAULT0x01 +#define VCNL4035_ALS_PERS_DEFAULT 0x00 +#define VCNL4035_ALS_THDH_DEFAULT 5000 +#define VCNL4035_ALS_THDL_DEFAULT 100 +#define VCNL4035_SLEEP_DELAY_MS2000 + +struct vcnl4035_data { + struct i2c_client *client; + struct regmap *regmap; +
[PATCH v6 1/2] iio: light: Add support for vishay vcnl4035
Add support for VCNL4035, which is capable of Ambient light sensing (ALS) and proximity function. This patch adds support only for ALS function Signed-off-by: Parthiban Nallathambi Changelog since v1: 1. Fixed 0-day warning on le16_to_cpu usage 2. Persistence value is directly mapped to datasheet's value to avoid confusions of usage from sysfs Changelog in v3: - Usage of lock is not needed, removed mutex locking - ALS threshold and persistence configuration available as events and threshold events are notified to userspace - Usage of devm_ is re-ordered and exit handling updated - Complexity in timestamp calculation is removed and used iio_get_time_ns Changelog in v4: - New white light index is introduced for getting data from white spectrum - PM enable/disable is called from read_raw accordingly - Probe exit handling re-ordered Changelog in v5: - White spectrum is mesaured as "_CLEAR" intesity, so removed white spectrum modifier - Header re-ordering - Trigger init and de-init into separate function - Indentation correct and usage of dev_err in place of pr_err Changelog in v6: - Usage of devm_ for trigger probing and cleanups - pm_runtime re-order and exit patch corrections - IIO_INTENSITY to IIO_LIGHT, lux/steps are fixed at IT cycle lux can be calculated based on IT sensitivity - _CLEAR to _BOTH although measurement is only WHITE spectrum for traditional reasons --- drivers/iio/light/Kconfig| 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/vcnl4035.c | 686 +++ 3 files changed, 699 insertions(+) create mode 100644 drivers/iio/light/vcnl4035.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index c7ef8d1862d6..b7069a4c28a2 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -447,6 +447,18 @@ config VCNL4000 To compile this driver as a module, choose M here: the module will be called vcnl4000. +config VCNL4035 + tristate "VCNL4035 combined ALS and proximity sensor" + select REGMAP_I2C + depends on I2C + help +Say Y here if you want to build a driver for the Vishay VCNL4035, +combined ambient light (ALS) and proximity sensor. Currently only ALS +function is available. + +To compile this driver as a module, choose M here: the +module will be called vcnl4035. + config VEML6070 tristate "VEML6070 UV A light sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 80943af5d627..dce98511a59b 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -44,6 +44,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o obj-$(CONFIG_VCNL4000) += vcnl4000.o +obj-$(CONFIG_VCNL4035) += vcnl4035.o obj-$(CONFIG_VEML6070) += veml6070.o obj-$(CONFIG_VL6180) += vl6180.o obj-$(CONFIG_ZOPT2201) += zopt2201.o diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c new file mode 100644 index ..e9f471d93a15 --- /dev/null +++ b/drivers/iio/light/vcnl4035.c @@ -0,0 +1,686 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 + * + * Copyright (c) 2018, DENX Software Engineering GmbH + * Author: Parthiban Nallathambi + * + * + * TODO: Proximity + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define VCNL4035_DRV_NAME "vcnl4035" +#define VCNL4035_IRQ_NAME "vcnl4035_event" +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" + +/* Device registers */ +#define VCNL4035_ALS_CONF 0x00 +#define VCNL4035_ALS_THDH 0x01 +#define VCNL4035_ALS_THDL 0x02 +#define VCNL4035_ALS_DATA 0x0B +#define VCNL4035_WHITE_DATA0x0C +#define VCNL4035_INT_FLAG 0x0D +#define VCNL4035_DEV_ID0x0E + +/* Register masks */ +#define VCNL4035_MODE_ALS_MASK BIT(0) +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) + +/* Default values */ +#define VCNL4035_MODE_ALS_ENABLE BIT(0) +#define VCNL4035_MODE_ALS_DISABLE 0x00 +#define VCNL4035_MODE_ALS_INT_ENABLE BIT(1) +#define VCNL4035_MODE_ALS_INT_DISABLE 0 +#define VCNL4035_DEV_ID_VAL0x80 +#define VCNL4035_ALS_IT_DEFAULT0x01 +#define VCNL4035_ALS_PERS_DEFAULT 0x00 +#define VCNL4035_ALS_THDH_DEFAULT 5000 +#define VCNL4035_ALS_THDL_DEFAULT 100 +#define VCNL4035_SLEEP_DELAY_MS2000 + +struct vcnl4035_data { + struct i2c_client *client; + struct regmap *regmap; +