tsl2772.h 3.7 KB

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