1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Device driver for monitoring ambient light intensity (lux)
4 * and proximity (prox) within the TAOS TSL2772 family of devices.
6 * Copyright (c) 2012, TAOS Corporation.
7 * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
18 /* Max number of segments allowable in LUX table */
19 #define TSL2772_MAX_LUX_TABLE_SIZE 6
20 /* The default LUX tables all have 3 elements. */
21 #define TSL2772_DEF_LUX_TABLE_SZ 3
22 #define TSL2772_DEFAULT_TABLE_BYTES (sizeof(struct tsl2772_lux) * \
23 TSL2772_DEF_LUX_TABLE_SZ)
25 /* Proximity diode to use */
26 #define TSL2772_DIODE0 0x01
27 #define TSL2772_DIODE1 0x02
28 #define TSL2772_DIODE_BOTH 0x03
31 #define TSL2772_100_mA 0x00
32 #define TSL2772_50_mA 0x01
33 #define TSL2772_25_mA 0x02
34 #define TSL2772_13_mA 0x03
37 * struct tsl2772_settings - Settings for the tsl2772 driver
38 * @als_time: Integration time of the ALS channel ADCs in 2.73 ms
39 * increments. Total integration time is
40 * (256 - als_time) * 2.73.
41 * @als_gain: Index into the tsl2772_als_gain array.
42 * @als_gain_trim: Default gain trim to account for aperture effects.
43 * @wait_time: Time between proximity and ALS cycles in 2.73
45 * @prox_time: Integration time of the proximity ADC in 2.73 ms
46 * increments. Total integration time is
47 * (256 - prx_time) * 2.73.
48 * @prox_gain: Index into the tsl2772_prx_gain array.
49 * @als_prox_config: The value of the ALS / Proximity configuration
51 * @als_cal_target: Known external ALS reading for calibration.
52 * @als_persistence: H/W Filters, Number of 'out of limits' ALS readings.
53 * @als_interrupt_en: Enable/Disable ALS interrupts
54 * @als_thresh_low: CH0 'low' count to trigger interrupt.
55 * @als_thresh_high: CH0 'high' count to trigger interrupt.
56 * @prox_persistence: H/W Filters, Number of 'out of limits' proximity
58 * @prox_interrupt_en: Enable/Disable proximity interrupts.
59 * @prox_thres_low: Low threshold proximity detection.
60 * @prox_thres_high: High threshold proximity detection.
61 * @prox_pulse_count: Number if proximity emitter pulses.
62 * @prox_max_samples_cal: The number of samples that are taken when performing
63 * a proximity calibration.
64 * @prox_diode Which diode(s) to use for driving the external
65 * LED(s) for proximity sensing.
66 * @prox_power The amount of power to use for the external LED(s).
68 struct tsl2772_settings
{
78 bool als_interrupt_en
;
82 bool prox_interrupt_en
;
86 int prox_max_samples_cal
;
92 * struct tsl2772_platform_data - Platform callback, glass and defaults
93 * @platform_lux_table: Device specific glass coefficents
94 * @platform_default_settings: Device specific power on defaults
96 struct tsl2772_platform_data
{
97 struct tsl2772_lux platform_lux_table
[TSL2772_MAX_LUX_TABLE_SIZE
];
98 struct tsl2772_settings
*platform_default_settings
;
101 #endif /* __TSL2772_H */