Re: [PATCH V2 1/1] iio: Added Capella cm3232 ambient light sensor driver.
On Wed, Jan 7, 2015 at 12:09 AM, Kevin Tsai kt...@capellamicro.com wrote: CM3232 is an advanced ambient light sensor with I2C protocol interface. The I2C slave address is internally hardwired as 0x10 (7-bit). Writing to configure register is byte mode, but reading ALS register requests to use word mode for 16-bit resolution. v2: Removed unused CM3232_CMD_ALS_HS. Modified cm3232_als_info structure. Removed id field. Modified cm3232_chip structure. Merged CM3232_als_it_bits and CM3232_als_it_values to cm3232_it_scale. Removed mutex lock. Renamed als_raw to regs_als. Moved it to cm3232_chip structure. Modified cm3232_read_als_it() and cm3232_write_als_it() to support val2. Thanks comments from Jeremiah Mahler, Peter Meerwald, Daniel Baluta, and Joe Perches. v1: Added cm3232.c to support Capella Microsystems CM3232 Ambient Light Sensor. Usually, we keep history out of the commit message - below the scissor line. Signed-off-by: Kevin Tsai kt...@capellamicro.com --- here is the place for adding changes since last versions .../devicetree/bindings/i2c/trivial-devices.txt| 1 + MAINTAINERS| 6 + drivers/iio/light/Kconfig | 11 + drivers/iio/light/Makefile | 1 + drivers/iio/light/cm3232.c | 411 + 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/light/cm3232.c diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt index 9f4e382..572a7c4 100644 --- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt @@ -34,6 +34,7 @@ atmel,24c512 i2c serial eeprom (24cxx) atmel,24c1024 i2c serial eeprom (24cxx) atmel,at97sc3204t i2c trusted platform module (TPM) capella,cm32181CM32181: Ambient Light Sensor +capella,cm3232 CM3232: Ambient Light Sensor catalyst,24c32 i2c serial eeprom cirrus,cs42l51 Cirrus Logic CS42L51 audio codec dallas,ds1307 64 x 8, Serial, I2C Real-Time Clock diff --git a/MAINTAINERS b/MAINTAINERS index ddb9ac8..06a613a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2378,6 +2378,12 @@ F: security/capability.c F: security/commoncap.c F: kernel/capability.c +CAPELLA MICROSYSTEMS LIGHT SENSOR DRIVER +M: Kevin Tsai kt...@capellamicro.com +S: Maintained +F: drivers/iio/light/cm* +F: Documentation/devicetree/bindings/i2c/trivial-devices.txt + CC2520 IEEE-802.15.4 RADIO DRIVER M: Varka Bhadram varkabhad...@gmail.com L: linux-w...@vger.kernel.org diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 5bea821..cd5028e 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -48,6 +48,17 @@ config CM32181 To compile this driver as a module, choose M here: the module will be called cm32181. +config CM3232 + depends on I2C + tristate CM3232 ambient light sensor + help +Say Y here if you use cm3232. +This option enables ambient light sensor using +Capella Microsystems cm3232 device driver. + +To compile this driver as a module, choose M here: +the module will be called cm3232. + config CM36651 depends on I2C tristate CM36651 driver diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 47877a3..f2c8d55 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_ADJD_S311) += adjd_s311.o obj-$(CONFIG_AL3320A) += al3320a.o obj-$(CONFIG_APDS9300) += apds9300.o obj-$(CONFIG_CM32181) += cm32181.o +obj-$(CONFIG_CM3232) += cm3232.o obj-$(CONFIG_CM36651) += cm36651.o obj-$(CONFIG_GP2AP020A00F) += gp2ap020a00f.o obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c new file mode 100644 index 000..b4b7d1b --- /dev/null +++ b/drivers/iio/light/cm3232.c @@ -0,0 +1,411 @@ +/* + * CM3232 Ambient Light Sensor + * + * Copyright (C) 2014-2015 Capella Microsystems Inc. + * Author: Kevin Tsai kt...@capellamicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2, as published + * by the Free Software Foundation. + * + * IIO driver for CM3232 (7-bit I2C slave address 0x10). + * + */ + +#include linux/delay.h +#include linux/err.h +#include linux/i2c.h +#include linux/module.h +#include linux/interrupt.h +#include linux/regulator/consumer.h +#include linux/iio/iio.h +#include linux/iio/sysfs.h +#include linux/iio/events.h Why do you need to include events.h? +#include
[PATCH V2 1/1] iio: Added Capella cm3232 ambient light sensor driver.
CM3232 is an advanced ambient light sensor with I2C protocol interface. The I2C slave address is internally hardwired as 0x10 (7-bit). Writing to configure register is byte mode, but reading ALS register requests to use word mode for 16-bit resolution. v2: Removed unused CM3232_CMD_ALS_HS. Modified cm3232_als_info structure. Removed id field. Modified cm3232_chip structure. Merged CM3232_als_it_bits and CM3232_als_it_values to cm3232_it_scale. Removed mutex lock. Renamed als_raw to regs_als. Moved it to cm3232_chip structure. Modified cm3232_read_als_it() and cm3232_write_als_it() to support val2. Thanks comments from Jeremiah Mahler, Peter Meerwald, Daniel Baluta, and Joe Perches. v1: Added cm3232.c to support Capella Microsystems CM3232 Ambient Light Sensor. Signed-off-by: Kevin Tsai kt...@capellamicro.com --- .../devicetree/bindings/i2c/trivial-devices.txt| 1 + MAINTAINERS| 6 + drivers/iio/light/Kconfig | 11 + drivers/iio/light/Makefile | 1 + drivers/iio/light/cm3232.c | 411 + 5 files changed, 430 insertions(+) create mode 100644 drivers/iio/light/cm3232.c diff --git a/Documentation/devicetree/bindings/i2c/trivial-devices.txt b/Documentation/devicetree/bindings/i2c/trivial-devices.txt index 9f4e382..572a7c4 100644 --- a/Documentation/devicetree/bindings/i2c/trivial-devices.txt +++ b/Documentation/devicetree/bindings/i2c/trivial-devices.txt @@ -34,6 +34,7 @@ atmel,24c512 i2c serial eeprom (24cxx) atmel,24c1024 i2c serial eeprom (24cxx) atmel,at97sc3204t i2c trusted platform module (TPM) capella,cm32181CM32181: Ambient Light Sensor +capella,cm3232 CM3232: Ambient Light Sensor catalyst,24c32 i2c serial eeprom cirrus,cs42l51 Cirrus Logic CS42L51 audio codec dallas,ds1307 64 x 8, Serial, I2C Real-Time Clock diff --git a/MAINTAINERS b/MAINTAINERS index ddb9ac8..06a613a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2378,6 +2378,12 @@ F: security/capability.c F: security/commoncap.c F: kernel/capability.c +CAPELLA MICROSYSTEMS LIGHT SENSOR DRIVER +M: Kevin Tsai kt...@capellamicro.com +S: Maintained +F: drivers/iio/light/cm* +F: Documentation/devicetree/bindings/i2c/trivial-devices.txt + CC2520 IEEE-802.15.4 RADIO DRIVER M: Varka Bhadram varkabhad...@gmail.com L: linux-w...@vger.kernel.org diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index 5bea821..cd5028e 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -48,6 +48,17 @@ config CM32181 To compile this driver as a module, choose M here: the module will be called cm32181. +config CM3232 + depends on I2C + tristate CM3232 ambient light sensor + help +Say Y here if you use cm3232. +This option enables ambient light sensor using +Capella Microsystems cm3232 device driver. + +To compile this driver as a module, choose M here: +the module will be called cm3232. + config CM36651 depends on I2C tristate CM36651 driver diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 47877a3..f2c8d55 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_ADJD_S311) += adjd_s311.o obj-$(CONFIG_AL3320A) += al3320a.o obj-$(CONFIG_APDS9300) += apds9300.o obj-$(CONFIG_CM32181) += cm32181.o +obj-$(CONFIG_CM3232) += cm3232.o obj-$(CONFIG_CM36651) += cm36651.o obj-$(CONFIG_GP2AP020A00F) += gp2ap020a00f.o obj-$(CONFIG_HID_SENSOR_ALS) += hid-sensor-als.o diff --git a/drivers/iio/light/cm3232.c b/drivers/iio/light/cm3232.c new file mode 100644 index 000..b4b7d1b --- /dev/null +++ b/drivers/iio/light/cm3232.c @@ -0,0 +1,411 @@ +/* + * CM3232 Ambient Light Sensor + * + * Copyright (C) 2014-2015 Capella Microsystems Inc. + * Author: Kevin Tsai kt...@capellamicro.com + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2, as published + * by the Free Software Foundation. + * + * IIO driver for CM3232 (7-bit I2C slave address 0x10). + * + */ + +#include linux/delay.h +#include linux/err.h +#include linux/i2c.h +#include linux/module.h +#include linux/interrupt.h +#include linux/regulator/consumer.h +#include linux/iio/iio.h +#include linux/iio/sysfs.h +#include linux/iio/events.h +#include linux/init.h + +/* Registers Address */ +#define CM3232_REG_ADDR_CMD 0x00 +#define CM3232_REG_ADDR_ALS 0x50 +#define CM3232_REG_ADDR_ID 0x53 + +/* CMD register */ +#define CM3232_CMD_ALS_DISABLE BIT(0) + +#define CM3232_CMD_ALS_IT_SHIFT 2 +#define CM3232_CMD_ALS_IT_MASK (0x07 CM3232_CMD_ALS_IT_SHIFT) +#define CM3232_CMD_ALS_IT_DEFAULT (0x01 CM3232_CMD_ALS_IT_SHIFT) +