Merge tag 'parisc-for-6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
[linux-block.git] / include / linux / platform_data / tsl2772.h
CommitLineData
5a1f2de1 1/* SPDX-License-Identifier: GPL-2.0+ */
3c97c08b
JB
2/*
3 * Device driver for monitoring ambient light intensity (lux)
4e24c171 4 * and proximity (prox) within the TAOS TSL2772 family of devices.
3c97c08b
JB
5 *
6 * Copyright (c) 2012, TAOS Corporation.
4e24c171 7 * Copyright (c) 2017-2018 Brian Masney <masneyb@onstation.org>
3c97c08b
JB
8 */
9
4e24c171
BM
10#ifndef __TSL2772_H
11#define __TSL2772_H
3c97c08b 12
4e24c171 13struct tsl2772_lux {
3c97c08b
JB
14 unsigned int ch0;
15 unsigned int ch1;
16};
17
30f130d2 18/* Max number of segments allowable in LUX table */
4e24c171 19#define TSL2772_MAX_LUX_TABLE_SIZE 6
30f130d2 20/* The default LUX tables all have 3 elements. */
4e24c171
BM
21#define TSL2772_DEF_LUX_TABLE_SZ 3
22#define TSL2772_DEFAULT_TABLE_BYTES (sizeof(struct tsl2772_lux) * \
23 TSL2772_DEF_LUX_TABLE_SZ)
30f130d2 24
96c44e2e 25/* Proximity diode to use */
4e24c171
BM
26#define TSL2772_DIODE0 0x01
27#define TSL2772_DIODE1 0x02
28#define TSL2772_DIODE_BOTH 0x03
96c44e2e
BM
29
30/* LED Power */
4e24c171
BM
31#define TSL2772_100_mA 0x00
32#define TSL2772_50_mA 0x01
33#define TSL2772_25_mA 0x02
34#define TSL2772_13_mA 0x03
96c44e2e 35
3c97c08b 36/**
4e24c171 37 * struct tsl2772_settings - Settings for the tsl2772 driver
ffb036a0
BM
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.
4e24c171 41 * @als_gain: Index into the tsl2772_als_gain array.
ffb036a0
BM
42 * @als_gain_trim: Default gain trim to account for aperture effects.
43 * @wait_time: Time between proximity and ALS cycles in 2.73
44 * periods.
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.
4e24c171 48 * @prox_gain: Index into the tsl2772_prx_gain array.
e1f35926
BM
49 * @als_prox_config: The value of the ALS / Proximity configuration
50 * register.
ffb036a0
BM
51 * @als_cal_target: Known external ALS reading for calibration.
52 * @als_persistence: H/W Filters, Number of 'out of limits' ALS readings.
4123e69a 53 * @als_interrupt_en: Enable/Disable ALS interrupts
3c97c08b
JB
54 * @als_thresh_low: CH0 'low' count to trigger interrupt.
55 * @als_thresh_high: CH0 'high' count to trigger interrupt.
ffb036a0
BM
56 * @prox_persistence: H/W Filters, Number of 'out of limits' proximity
57 * readings.
58 * @prox_interrupt_en: Enable/Disable proximity interrupts.
3c97c08b 59 * @prox_thres_low: Low threshold proximity detection.
ffb036a0
BM
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).
3c97c08b 67 */
4e24c171 68struct tsl2772_settings {
3c97c08b
JB
69 int als_time;
70 int als_gain;
71 int als_gain_trim;
72 int wait_time;
dc6ebdd3 73 int prox_time;
3c97c08b 74 int prox_gain;
e1f35926 75 int als_prox_config;
3c97c08b 76 int als_cal_target;
490941db 77 u8 als_persistence;
4123e69a 78 bool als_interrupt_en;
3c97c08b
JB
79 int als_thresh_low;
80 int als_thresh_high;
490941db 81 u8 prox_persistence;
4123e69a 82 bool prox_interrupt_en;
3c97c08b
JB
83 int prox_thres_low;
84 int prox_thres_high;
85 int prox_pulse_count;
86 int prox_max_samples_cal;
2ab5b724
BM
87 int prox_diode;
88 int prox_power;
3c97c08b
JB
89};
90
91/**
4e24c171 92 * struct tsl2772_platform_data - Platform callback, glass and defaults
3c97c08b
JB
93 * @platform_lux_table: Device specific glass coefficents
94 * @platform_default_settings: Device specific power on defaults
3c97c08b 95 */
4e24c171
BM
96struct tsl2772_platform_data {
97 struct tsl2772_lux platform_lux_table[TSL2772_MAX_LUX_TABLE_SIZE];
98 struct tsl2772_settings *platform_default_settings;
3c97c08b
JB
99};
100
4e24c171 101#endif /* __TSL2772_H */