aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/iio/light/tsl2x7x.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/staging/iio/light/tsl2x7x.h')
-rw-r--r--drivers/staging/iio/light/tsl2x7x.h91
1 files changed, 47 insertions, 44 deletions
diff --git a/drivers/staging/iio/light/tsl2x7x.h b/drivers/staging/iio/light/tsl2x7x.h
index 28b0e7fdc9b8..1097ee890ce2 100644
--- a/drivers/staging/iio/light/tsl2x7x.h
+++ b/drivers/staging/iio/light/tsl2x7x.h
@@ -1,79 +1,85 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
/*
* Device driver for monitoring ambient light intensity (lux)
* and proximity (prox) within the TAOS TSL2X7X family of devices.
*
* Copyright (c) 2012, TAOS Corporation.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __TSL2X7X_H
#define __TSL2X7X_H
struct tsl2x7x_lux {
- unsigned int ratio;
unsigned int ch0;
unsigned int ch1;
};
/* Max number of segments allowable in LUX table */
-#define TSL2X7X_MAX_LUX_TABLE_SIZE 9
+#define TSL2X7X_MAX_LUX_TABLE_SIZE 6
/* The default LUX tables all have 3 elements. */
#define TSL2X7X_DEF_LUX_TABLE_SZ 3
#define TSL2X7X_DEFAULT_TABLE_BYTES (sizeof(struct tsl2x7x_lux) * \
TSL2X7X_DEF_LUX_TABLE_SZ)
+/* Proximity diode to use */
+#define TSL2X7X_DIODE0 0x01
+#define TSL2X7X_DIODE1 0x02
+#define TSL2X7X_DIODE_BOTH 0x03
+
+/* LED Power */
+#define TSL2X7X_100_mA 0x00
+#define TSL2X7X_50_mA 0x01
+#define TSL2X7X_25_mA 0x02
+#define TSL2X7X_13_mA 0x03
+#define TSL2X7X_MAX_TIMER_CNT 0xFF
+
/**
- * struct tsl2x7x_default_settings - power on defaults unless
- * overridden by platform data.
- * @als_time: ALS Integration time - multiple of 50mS
- * @als_gain: Index into the ALS gain table.
- * @als_gain_trim: default gain trim to account for
- * aperture effects.
- * @wait_time: Time between PRX and ALS cycles
- * in 2.7 periods
- * @prx_time: 5.2ms prox integration time -
- * decrease in 2.7ms periods
- * @prx_gain: Proximity gain index
- * @prox_config: Prox configuration filters.
- * @als_cal_target: Known external ALS reading for
- * calibration.
- * @interrupts_en: Enable/Disable - 0x00 = none, 0x10 = als,
- * 0x20 = prx, 0x30 = bth
- * @persistence: H/W Filters, Number of 'out of limits'
- * ADC readings PRX/ALS.
+ * struct tsl2x7x_settings - Settings for the tsl2x7x driver
+ * @als_time: Integration time of the ALS channel ADCs in 2.73 ms
+ * increments. Total integration time is
+ * (256 - als_time) * 2.73.
+ * @als_gain: Index into the tsl2x7x_als_gain array.
+ * @als_gain_trim: Default gain trim to account for aperture effects.
+ * @wait_time: Time between proximity and ALS cycles in 2.73
+ * periods.
+ * @prox_time: Integration time of the proximity ADC in 2.73 ms
+ * increments. Total integration time is
+ * (256 - prx_time) * 2.73.
+ * @prox_gain: Index into the tsl2x7x_prx_gain array.
+ * @als_prox_config: The value of the ALS / Proximity configuration
+ * register.
+ * @als_cal_target: Known external ALS reading for calibration.
+ * @als_persistence: H/W Filters, Number of 'out of limits' ALS readings.
+ * @als_interrupt_en: Enable/Disable ALS interrupts
* @als_thresh_low: CH0 'low' count to trigger interrupt.
* @als_thresh_high: CH0 'high' count to trigger interrupt.
+ * @prox_persistence: H/W Filters, Number of 'out of limits' proximity
+ * readings.
+ * @prox_interrupt_en: Enable/Disable proximity interrupts.
* @prox_thres_low: Low threshold proximity detection.
- * @prox_thres_high: High threshold proximity detection
- * @prox_pulse_count: Number if proximity emitter pulses
- * @prox_max_samples_cal: Used for prox cal.
+ * @prox_thres_high: High threshold proximity detection.
+ * @prox_pulse_count: Number if proximity emitter pulses.
+ * @prox_max_samples_cal: The number of samples that are taken when performing
+ * a proximity calibration.
+ * @prox_diode Which diode(s) to use for driving the external
+ * LED(s) for proximity sensing.
+ * @prox_power The amount of power to use for the external LED(s).
*/
struct tsl2x7x_settings {
int als_time;
int als_gain;
int als_gain_trim;
int wait_time;
- int prx_time;
+ int prox_time;
int prox_gain;
- int prox_config;
+ int als_prox_config;
int als_cal_target;
- u8 interrupts_en;
- u8 persistence;
+ u8 als_persistence;
+ bool als_interrupt_en;
int als_thresh_low;
int als_thresh_high;
+ u8 prox_persistence;
+ bool prox_interrupt_en;
int prox_thres_low;
int prox_thres_high;
int prox_pulse_count;
@@ -84,9 +90,6 @@ struct tsl2x7x_settings {
/**
* struct tsl2X7X_platform_data - Platform callback, glass and defaults
- * @platform_power: Suspend/resume platform callback
- * @power_on: Power on callback
- * @power_off: Power off callback
* @platform_lux_table: Device specific glass coefficents
* @platform_default_settings: Device specific power on defaults
*