iio: gp2ap020a00f: Add a driver for the device
PATCH v9 1/1 iio: gp2ap020a00f: Add a driver for the device
Add a new driver for the ambient light/proximity sensor device. The driver exposes three channels: light_clear light_ir and proximity. It also supports triggered buffer, high and low ambient light threshold event and proximity detection events.
---
This driver supports:
- reading channels through read_raw callback,
- four events - rising and falling ambient light events and rising and falling proximity roc events.
- triggers for all the three channels (triggers can't be enabled simultaneosly with proximity detection event)
This is a follow-up of the previous series. The patch with DT bindings documentation [1] for the driver has been already acked [2]. This patch includes following improvements:
- switched over to using OP2_CONT_OPERATION mode for read_raw calls to avoid the need for adding more complexity in the adjust_lux_mode function.
- removed mutex protection from the thresh_event_handler, as it turned out to be superfluous and precluded waking the read_raw callback up.
- calling irq_work_queue only when triggers are enabled
- modified names of interrupt handlers - als_event_handler name was misleading as it also reports proximity threshold events (not to be confused with proximity sensing events which have their dedicated handler), that act as data ready events for the proximity channel but are not exposed to the user space
- returning 0 instead of -EBUSY from the write_event_config callback if the state is already set
- made slight adjustements to the code formating (modified the names of few flags which allowed to remove some line breaks).
[1] - http://www.spinics.net/lists/linux-iio/msg09768.html
[2] - http://www.spinics.net/lists/linux-iio/msg09772.html
Thanks,
Jacek Anaszewski
drivers/iio/light/Kconfig | 12 + drivers/iio/light/Makefile | 1 + drivers/iio/light/gp2ap020a00f.c | 1622 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 1635 insertions(+) create mode 100644 drivers/iio/light/gp2ap020a00f.c
drivers/iio/light/Kconfig +12 -0
@@ -27,6 +27,18 @@ config APDS9300 To compile this driver as a module, choose M here: the module will be called apds9300. +config GP2AP020A00F + tristate "Sharp GP2AP020A00F Proximity/ALS sensor" + depends on I2C + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say Y here if you have a Sharp GP2AP020A00F proximity/ALS combo-chip + hooked to an I2C bus. + + To compile this driver as a module, choose M here: the + module will be called gp2ap020a00f. + config HID_SENSOR_ALS depends on HID_SENSOR_HUB select IIO_BUFFER
drivers/iio/light/Makefile +1 -0
@@ -5,6 +5,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_ADJD_S311) += adjd_s311.o obj-$(CONFIG_APDS9300) += apds9300.o +obj-$(CONFIG_GP2AP020A00F) += gp2ap020a00f.o obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o
drivers/iio/light/gp2ap020a00f.c new file +1622 -0
1,622 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 8 lines · Jacek Anaszewski
Add a new driver for the ambient light/proximity sensor device. The driver exposes three channels:
light_clearlight_irand proximity. It also supports triggered buffer, high and low ambient light threshold event and proximity detection events.Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Very nice driver for a beast of a device. Far as I can see you've managed to handle all the weird corners due to the limited interrupt generator and auto switching the gain. Impressive bit of code.
Applied to the togreg branch ofgit://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git
along with the DT bindings.
Thanks for all you hard work on this.
Jonathan