iio: light: Adding driver for ISL29018 ALS
Subsystems (4)
PATCH v2 1/1 iio: light: Adding driver for ISL29018 ALS
From: Rhyland Klein <[email protected]>
Adding support for the ISL 29018 ambient light and proximity sensor.
Addressed comments from Jonathan Cameron's review
* Removed some excess dbg prints that only printed function name
* Renamed some properties to make them more descriptive
* Added a property to list available adc resolutions
--- .../staging/iio/Documentation/sysfs-bus-iio-light | 59 ++ drivers/staging/iio/light/Kconfig | 11 + drivers/staging/iio/light/Makefile | 1 + drivers/staging/iio/light/isl29018.c | 564 ++++++++++++++++++++ 4 files changed, 635 insertions(+), 0 deletions(-) create mode 100644 drivers/staging/iio/Documentation/sysfs-bus-iio-light create mode 100755 drivers/staging/iio/light/isl29018.c
drivers/staging/iio/Documentation/sysfs-bus-iio-light new file +59 -0
@@ -0,0 +1,59 @@ + +What: /sys/bus/iio/devices/device[n]/range +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + Hardware dependent ADC Full Scale Range used for some ambient + light sensors in calculating lux. + +What: /sys/bus/iio/devices/device[n]/adc_resolution +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + Hardware dependent ADC resolution of the ambient light sensor + used in calculating the lux. + +What: /sys/bus/iio/devices/device[n]/adc_resolution_available +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + Hardware dependent list of possible values supported for the + adc_resolution of the given sensor. + +What: /sys/bus/iio/devices/device[n]/illuminance0 +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + This should return the calculated lux from the light sensor. If + it comes back in SI units, it should also inclue _input else it + should include _raw to signify it is not in SI units. + +What: /sys/bus/iio/devices/device[n]/ + proximity_on_chip_ambient_infrared_supression +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + Hardware dependent mode for an ALS device to calculate the value + in proximity mode. When this is enabled, then the device should + use a infrared sensor reading to remove infrared noise from the + proximity reading. If this is not enabled, the driver can still + do this calculation manually by reading the infrared sensor + value and doing the negation in sw. + +What: /sys/bus/iio/devices/device[n]/proximity +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + This property is supported by proximity sensors and should be + used to return the value of a reading by the sensor. If this + value is returned in SI units, it should also include _input + but if it is not, then it should include _raw. + +What: /sys/bus/iio/devices/device[n]/intensity_infrared +KernelVersion: 2.6.35 +Contact: [email protected] +Description: + This property is supported by sensors that have an infrared + sensing mode. This value should be the output from a reading + and if expressed in SI units, should include _input. If this + value is not in SI units, then it should include _raw.
drivers/staging/iio/light/Kconfig +11 -0
@@ -13,3 +13,14 @@ config SENSORS_TSL2563 This driver can also be built as a module. If so, the module will be called tsl2563. +config SENSORS_ISL29018 + tristate "ISL 29018 light and proximity sensor" + depends on I2C + default n + help + If you say yes here you get support for ambient light sensing and + proximity ir sensing from Intersil ISL29018. + This driver will provide the measurements of ambient light intensity + in lux, proximity infrared sensing and normal infrared sensing. + Data from sensor is accessible via sysfs. +
drivers/staging/iio/light/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o +obj-$(CONFIG_SENSORS_ISL29018) += isl29018.o
drivers/staging/iio/light/isl29018.c new file +564 -0
564 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Quoted 1 line · On Tue, 2010-10-05 at 14:19 -0700, [email protected]…
Adding support for the ISL 29018 ambient light and proximity sensor.
Trivial comments below.
drivers/staging/iio/light/isl29018.c
Quoted 1 line
drivers/staging/iio/light/isl29018.c +0
-0
[]
drivers/staging/iio/light/isl29018.c line 90
Quoted 4 lines
drivers/staging/iio/light/isl29018.c +4
-0+static int isl29018_set_range (struct i2c_client *client,unsigned long range, +unsigned int *new_range) +{ +unsigned long supp_ranges[] = {1000 ,4000 ,16000 ,64000 };
static const
drivers/staging/iio/light/isl29018.c line 110
Quoted 4 lines
drivers/staging/iio/light/isl29018.c +4
-0+static int isl29018_set_resolution (struct i2c_client *client, +unsigned long adcbit,unsigned int *conf_adc_bit) +{ +unsigned long supp_adcbit[] = {16 ,12 ,8 ,4 };
here too
drivers/staging/iio/light/isl29018.c line 456
Quoted 10 lines
drivers/staging/iio/light/isl29018.c +10
-0+static int isl29018_chip_init (struct i2c_client *client) +{ +struct isl29018_chip *chip =i2c_get_clientdata (client); +int status; +int i; +int new_adc_bit; +unsigned int new_range; + +for (i =0 ; i <ARRAY_SIZE (chip->reg_cache); i++) + chip->reg_cache[i] =0 ;
memset?
Quoted 17 lines
-----Original Message-----
From: Joe Perches [mailto:[email protected]]
Sent: Tuesday, October 05, 2010 2:35 PM
To: Rhyland Klein
Cc: [email protected]; Andrew Chew; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]; Laxman Dewangan
Subject: Re: [PATCH v2] iio: light: Adding driver for ISL29018 ALSQuoted 1 line · On Tue, 2010-10-05 at 14:19 -0700, [email protected] wrote:
Adding support for the ISL 29018 ambient light and proximity sensor.
Trivial comments below.
Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/staging/iio/light/isl29018.c
[]
Quoted 7 lines
Quoted 1 line
+static int isl29018_set_range(struct
i2c_client*client, unsigned longrange,
drivers/staging/iio/light/isl29018.c line 90
Quoted 3 lines
drivers/staging/iio/light/isl29018.c new file +3
-0+ unsigned int *new_range) +{ +unsigned long supp_ranges[] = {1000 ,4000 ,16000 ,64000 };static const
Will change.
Quoted 7 lines
drivers/staging/iio/light/isl29018.c line 110
Quoted 5 lines
drivers/staging/iio/light/isl29018.c new file +4
-0+static int isl29018_set_resolution (struct i2c_client *client, +unsigned long adcbit,unsigned int *conf_adc_bit) +{ +unsigned long supp_adcbit[] = {16 ,12 ,8 ,4 };here too
This too.
Quoted 14 lines
drivers/staging/iio/light/isl29018.c line 456
Quoted 11 lines
drivers/staging/iio/light/isl29018.c new file +10
-0+static int isl29018_chip_init (struct i2c_client *client) +{ +struct isl29018_chip *chip =i2c_get_clientdata (client); +int status; +int i; +int new_adc_bit; +unsigned int new_range; + +for (i =0 ; i <ARRAY_SIZE (chip->reg_cache); i++) + chip->reg_cache[i] =0 ;memset?
I could use memset, except this is only 4 registers = 32 bytes, so I don't think that is really worth it do you?
Quoted 15 lines · Rhyland Klein
Quoted 4 lines
-----Original Message-----
From: Joe Perches [mailto:[email protected]]Review
Quoted 1 line
(quoted diff) +0
-0
b/drivers/staging/iio/light/isl29018.cQuoted 11 lines
drivers/staging/iio/light/isl29018.c line 456
Quoted 10 lines
drivers/staging/iio/light/isl29018.c new file +10
-0+static int isl29018_chip_init (struct i2c_client *client) +{ +struct isl29018_chip *chip =i2c_get_clientdata (client); +int status; +int i; +int new_adc_bit; +unsigned int new_range; + +for (i =0 ; i <ARRAY_SIZE (chip->reg_cache); i++) + chip->reg_cache[i] =0 ;memset?
Quoted 2 lines
I could use memset, except this is only 4 registers = 32 bytes, so I don't think that is really worth it do you?
Your choice. I don't care really. I didn't look to see how many elements were in chip->reg_cache.
I just noted it as whenever I see a loop initialization like that, I think memset not loop.
cheers, Joe