ltr303.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Lite-On LTR-501ALS Linux Driver
  2. *
  3. * Copyright (C) 2011 Lite-On Technology Corp (Singapore)
  4. *
  5. * This program is distributed in the hope that it will be useful, but
  6. * WITHOUT ANY WARRANTY; without even the implied warranty of
  7. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. *
  9. */
  10. #ifndef _LTR303_H
  11. #define _LTR303_H
  12. #include <linux/ioctl.h>
  13. /* LTR-559 Registers */
  14. #define LTR303_ALS_CONTR 0x80
  15. #define LTR303_PS_CONTR 0x81
  16. #define LTR303_PS_LED 0x82
  17. #define LTR303_PS_N_PULSES 0x83
  18. #define LTR303_PS_MEAS_RATE 0x84
  19. #define LTR303_ALS_MEAS_RATE 0x85
  20. #define LTR303_PART_ID 0x86
  21. #define LTR303_MANUFACTURER_ID 0x87
  22. #define LTR303_INTERRUPT 0x8F
  23. #define LTR303_PS_THRES_UP_0 0x90
  24. #define LTR303_PS_THRES_UP_1 0x91
  25. #define LTR303_PS_THRES_LOW_0 0x92
  26. #define LTR303_PS_THRES_LOW_1 0x93
  27. #define LTR303_ALS_THRES_UP_0 0x97
  28. #define LTR303_ALS_THRES_UP_1 0x98
  29. #define LTR303_ALS_THRES_LOW_0 0x99
  30. #define LTR303_ALS_THRES_LOW_1 0x9A
  31. #define LTR303_INTERRUPT_PERSIST 0x9E
  32. /* 559's Read Only Registers */
  33. #define LTR303_ALS_DATA_CH1_0 0x88
  34. #define LTR303_ALS_DATA_CH1_1 0x89
  35. #define LTR303_ALS_DATA_CH0_0 0x8A
  36. #define LTR303_ALS_DATA_CH0_1 0x8B
  37. #define LTR303_ALS_PS_STATUS 0x8C
  38. #define LTR303_PS_DATA_0 0x8D
  39. #define LTR303_PS_DATA_1 0x8E
  40. /* Basic Operating Modes */
  41. #define MODE_ALS_ON_Range1 0x01 ///for als gain x1
  42. #define MODE_ALS_ON_Range2 0x05 ///for als gain x2
  43. #define MODE_ALS_ON_Range3 0x09 ///for als gain x4
  44. #define MODE_ALS_ON_Range4 0x0D ///for als gain x8
  45. #define MODE_ALS_ON_Range5 0x19 ///for als gain x48
  46. #define MODE_ALS_ON_Range6 0x1D ///for als gain x96
  47. #define MODE_ALS_StdBy 0x00
  48. #define ALS_RANGE_64K 1
  49. #define ALS_RANGE_32K 2
  50. #define ALS_RANGE_16K 4
  51. #define ALS_RANGE_8K 8
  52. #define ALS_RANGE_1300 48
  53. #define ALS_RANGE_600 96
  54. #define MODE_PS_ON_Gain16 0x03
  55. #define MODE_PS_ON_Gain32 0x0B
  56. #define MODE_PS_ON_Gain64 0x0F
  57. #define MODE_PS_StdBy 0x00
  58. #define PS_RANGE16 1
  59. #define PS_RANGE32 4
  60. #define PS_RANGE64 8
  61. /*
  62. * Magic Number
  63. * ============
  64. * Refer to file ioctl-number.txt for allocation
  65. */
  66. #define LTR303_IOCTL_MAGIC 'c'
  67. /* IOCTLs for LTR303 device */
  68. #define LTR303_IOCTL_PS_ENABLE _IOW(LTR303_IOCTL_MAGIC, 0, char *)
  69. #define LTR303_IOCTL_ALS_ENABLE _IOW(LTR303_IOCTL_MAGIC, 1, char *)
  70. #define LTR303_IOCTL_READ_PS_DATA _IOR(LTR303_IOCTL_MAGIC, 2, char *)
  71. #define LTR303_IOCTL_READ_PS_INT _IOR(LTR303_IOCTL_MAGIC, 3, char *)
  72. #define LTR303_IOCTL_READ_ALS_DATA _IOR(LTR303_IOCTL_MAGIC, 4, char *)
  73. #define LTR303_IOCTL_READ_ALS_INT _IOR(LTR303_IOCTL_MAGIC, 5, char *)
  74. /* Power On response time in ms */
  75. #define PON_DELAY 600
  76. #define WAKEUP_DELAY 10
  77. #define LTR303_SUCCESS 0
  78. #define LTR303_ERR_I2C -1
  79. #define LTR303_ERR_STATUS -3
  80. #define LTR303_ERR_SETUP_FAILURE -4
  81. #define LTR303_ERR_GETGSENSORDATA -5
  82. #define LTR303_ERR_IDENTIFICATION -6
  83. /* Interrupt vector number to use when probing IRQ number.
  84. * User changeable depending on sys interrupt.
  85. * For IRQ numbers used, see /proc/interrupts.
  86. */
  87. #define GPIO_INT_NO 32
  88. #endif