BH1770GLC / SFH7770 combined ambient light / proximity sensor
cover BH1770GLC / SFH7770 combined ambient light / proximity sensor
This patch introduces driver for Rohm BH1770GLC and Osram SFH7770 combined ambient light and proximity sensor.
Driver is divided to 3 parts. Core-part contains common functionality for both parts of the chips. ALS and PS specific functionalities are in separate files.
ALS part is fully based on threshold interrupts. Driver doesn't provide direct control for threshold levels. Instead, based on sensitivity setting, threshold levels are updated after every interrupt. This method keeps sensor to follow changes in the lightning.
PS part uses interrupt for high threshold events and delayed work to simulate missing low threshold interrupts. This way driver is able to react proximity on / off events using only high threshold interrupt. Proximity sensing can utilize up to 3 IR leds for movement detection. Driver supports 1-3 leds configurations.
Platform data is used to provide IR led configuration: number of channels and absolute maximum operating currents for the leds.
Chip is kept running only when someone keeps device handles open. Otherwise chip is powered down and optionally power supplies are turned off.
Interfaces:
Both parts of the driver provides results via separate misc char device.
sysfs interface:als_calib - (RW) calibration coeffient (default is neutral value)
als_mode - (R) returns current chip operational state for ALS als_rate - (RW) ALS side measurement rate in ms als_sens - (RW) sensitivity for changes in lightning level ps_calib - (RW) calibration coeffient ps_leds - (RW) IR led currents in mA ps_mode - (R) returns current chip operational state for PS ps_rate - (RW) PS side measurement rates (separate rates for below /
above threshold condition)ps_threshold - (RW) threshold levelschip_id - (R) chip version and revision information
Tested in top of 2.6.32 kernel. Applies to 2.6.34-RC3.
Samu Onkalo (1):
misc: bh1770glc: Driver for bh1770glc combined als and ps sensor
drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 3 + drivers/misc/bh1770glc.h | 169 ++++++++++++ drivers/misc/bh1770glc_als.c | 424 +++++++++++++++++++++++++++++ drivers/misc/bh1770glc_core.c | 301 +++++++++++++++++++++ drivers/misc/bh1770glc_ps.c | 585 +++++++++++++++++++++++++++++++++++++++++ include/linux/bh1770glc.h | 39 +++ 7 files changed, 1533 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/bh1770glc.h create mode 100644 drivers/misc/bh1770glc_als.c create mode 100644 drivers/misc/bh1770glc_core.c create mode 100644 drivers/misc/bh1770glc_ps.c create mode 100644 include/linux/bh1770glc.h
PATCH 1/1 misc: bh1770glc: Driver for bh1770glc combined als and ps sensor
Driver for combined ambient light and proximity sensor. BH1770GLC and SW compatible SFH7770 sensors are supported.
--- drivers/misc/Kconfig | 12 + drivers/misc/Makefile | 3 + drivers/misc/bh1770glc.h | 169 ++++++++++++ drivers/misc/bh1770glc_als.c | 424 +++++++++++++++++++++++++++++ drivers/misc/bh1770glc_core.c | 301 +++++++++++++++++++++ drivers/misc/bh1770glc_ps.c | 585 +++++++++++++++++++++++++++++++++++++++++ include/linux/bh1770glc.h | 39 +++ 7 files changed, 1533 insertions(+), 0 deletions(-) create mode 100644 drivers/misc/bh1770glc.h create mode 100644 drivers/misc/bh1770glc_als.c create mode 100644 drivers/misc/bh1770glc_core.c create mode 100644 drivers/misc/bh1770glc_ps.c create mode 100644 include/linux/bh1770glc.h
drivers/misc/Kconfig +12 -0
@@ -311,6 +311,18 @@ config TI_DAC7512 This driver can also be built as a module. If so, the module will be calles ti_dac7512. +config BH1770GLC + tristate "Rohm BH1770GLC ambient light and proximity sensor" + depends on I2C + default n + ---help--- + Say Y here if you want to build a driver for BH1770GLC + combined ambient light and proximity sensor chip. + Driver supports also Osram SFH7770 version of the chip. + + To compile this driver as a module, choose M here: the + module will be called bh1770glc. If unsure, say N here. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +3 -0
@@ -2,6 +2,8 @@ # Makefile for misc devices that really don't fit anywhere else. # +bh1770glc-objs := bh1770glc_core.o bh1770glc_als.o bh1770glc_ps.o + obj-$(CONFIG_IBM_ASM) += ibmasm/ obj-$(CONFIG_HDPU_FEATURES) += hdpuftrs/ obj-$(CONFIG_AD525X_DPOT) += ad525x_dpot.o
@@ -25,6 +27,7 @@ obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o obj-$(CONFIG_DS1682) += ds1682.o obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o +obj-$(CONFIG_BH1770GLC) += bh1770glc.o obj-$(CONFIG_C2PORT) += c2port/ obj-$(CONFIG_IWMC3200TOP) += iwmc3200top/ obj-y += eeprom/
drivers/misc/bh1770glc.h new file +169 -0
169 lines not on this page · raw message
drivers/misc/bh1770glc_als.c new file +424 -0
424 lines not on this page · raw message
drivers/misc/bh1770glc_core.c new file +301 -0
301 lines not on this page · raw message
drivers/misc/bh1770glc_ps.c new file +585 -0
585 lines not on this page · raw message
include/linux/bh1770glc.h new file +39 -0
@@ -0,0 +1,39 @@ +#ifndef __BH1770GLC_H__ +#define __BH1770GLC_H__ + +struct bh1770glc_platform_data { +/* IR-Led configuration for proximity sensing */ +#define BH1770GLC_LED1 0x00 +#define BH1770GLC_LED12 0x01 +#define BH1770GLC_LED13 0x02 +#define BH1770GLC_LED123 0x03 + +__u8 leds; +/* led_max_curr is a safetylimit for IR leds */ +#define BH1770GLC_LED_5mA 0 +#define BH1770GLC_LED_10mA 1 +#define BH1770GLC_LED_20mA 2 +#define BH1770GLC_LED_50mA 3 +#define BH1770GLC_LED_100mA 4 +#define BH1770GLC_LED_150mA 5 +#define BH1770GLC_LED_200mA 6 +__u8 led_max_curr; +__u8 led_def_curr[3 ]; + +int (*setup_resources)(void ); +int (*release_resources)(void ); +}; + +/* Device name: /dev/bh1770glc_ps */ +struct bh1770glc_ps { +__u8 led1; +__u8 led2; +__u8 led3; +} __attribute__((packed)); + +/* Device name: /dev/bh1770glc_als */ +struct bh1770glc_als { +__u16 lux; +} __attribute__((packed)); + +#endif
Signature · 1 line
1.6.0.4