linux/drivers/staging/iio/light/tsl2x7x.h
<<
>>
Prefs
   1/*
   2 * Device driver for monitoring ambient light intensity (lux)
   3 * and proximity (prox) within the TAOS TSL2X7X family of devices.
   4 *
   5 * Copyright (c) 2012, TAOS Corporation.
   6 *
   7 * This program is free software; you can redistribute it and/or modify
   8 * it under the terms of the GNU General Public License as published by
   9 * the Free Software Foundation; either version 2 of the License, or
  10 * (at your option) any later version.
  11 *
  12 * This program is distributed in the hope that it will be useful, but WITHOUT
  13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  15 * more details.
  16 *
  17 * You should have received a copy of the GNU General Public License along
  18 * with this program; if not, write to the Free Software Foundation, Inc.,
  19 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  20 */
  21
  22#ifndef __TSL2X7X_H
  23#define __TSL2X7X_H
  24#include <linux/pm.h>
  25
  26/* Max number of segments allowable in LUX table */
  27#define TSL2X7X_MAX_LUX_TABLE_SIZE              9
  28#define MAX_DEFAULT_TABLE_BYTES (sizeof(int) * TSL2X7X_MAX_LUX_TABLE_SIZE)
  29
  30struct iio_dev;
  31
  32struct tsl2x7x_lux {
  33        unsigned int ratio;
  34        unsigned int ch0;
  35        unsigned int ch1;
  36};
  37
  38/**
  39 * struct tsl2x7x_default_settings - power on defaults unless
  40 *                                   overridden by platform data.
  41 *  @als_time:              ALS Integration time - multiple of 50mS
  42 *  @als_gain:              Index into the ALS gain table.
  43 *  @als_gain_trim:         default gain trim to account for
  44 *                          aperture effects.
  45 *  @wait_time:             Time between PRX and ALS cycles
  46 *                          in 2.7 periods
  47 *  @prx_time:              5.2ms prox integration time -
  48 *                          decrease in 2.7ms periods
  49 *  @prx_gain:              Proximity gain index
  50 *  @prox_config:           Prox configuration filters.
  51 *  @als_cal_target:        Known external ALS reading for
  52 *                          calibration.
  53 *  @interrupts_en:         Enable/Disable - 0x00 = none, 0x10 = als,
  54 *                                           0x20 = prx,  0x30 = bth
  55 *  @persistence:           H/W Filters, Number of 'out of limits'
  56 *                          ADC readings PRX/ALS.
  57 *  @als_thresh_low:        CH0 'low' count to trigger interrupt.
  58 *  @als_thresh_high:       CH0 'high' count to trigger interrupt.
  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:  Used for prox cal.
  63 */
  64struct tsl2x7x_settings {
  65        int als_time;
  66        int als_gain;
  67        int als_gain_trim;
  68        int wait_time;
  69        int prx_time;
  70        int prox_gain;
  71        int prox_config;
  72        int als_cal_target;
  73        u8  interrupts_en;
  74        u8  persistence;
  75        int als_thresh_low;
  76        int als_thresh_high;
  77        int prox_thres_low;
  78        int prox_thres_high;
  79        int prox_pulse_count;
  80        int prox_max_samples_cal;
  81};
  82
  83/**
  84 * struct tsl2X7X_platform_data - Platform callback, glass and defaults
  85 * @platform_power:            Suspend/resume platform callback
  86 * @power_on:                  Power on callback
  87 * @power_off:                 Power off callback
  88 * @platform_lux_table:        Device specific glass coefficents
  89 * @platform_default_settings: Device specific power on defaults
  90 *
  91 */
  92struct tsl2X7X_platform_data {
  93        int (*platform_power)(struct device *dev, pm_message_t);
  94        int (*power_on)      (struct iio_dev *indio_dev);
  95        int (*power_off)     (struct i2c_client *dev);
  96        struct tsl2x7x_lux platform_lux_table[TSL2X7X_MAX_LUX_TABLE_SIZE];
  97        struct tsl2x7x_settings *platform_default_settings;
  98};
  99
 100#endif /* __TSL2X7X_H */
 101