max86900.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #ifndef _MAX86900_H_
  2. #define _MAX86900_H_
  3. #include <linux/delay.h>
  4. #include <linux/i2c.h>
  5. #include <linux/irq.h>
  6. #include <linux/input.h>
  7. #include <linux/init.h>
  8. #include <linux/kernel.h>
  9. #include <linux/module.h>
  10. #include <linux/interrupt.h>
  11. #include <linux/leds.h>
  12. #include <linux/miscdevice.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/regulator/consumer.h>
  15. #include <linux/slab.h>
  16. #include <linux/types.h>
  17. #include <linux/uaccess.h>
  18. #include <linux/workqueue.h>
  19. #include <linux/spinlock.h>
  20. #include <linux/gpio.h>
  21. #include <linux/kthread.h>
  22. #include <linux/sched.h>
  23. #include <linux/time.h>
  24. #include <linux/timer.h>
  25. #define MAX86900_DEBUG
  26. #if defined(CONFIG_SENSORS_SSP_STM_HESTIA)
  27. #define HRM_EOL_FREQ_LOCK
  28. #endif
  29. #define MAX86900_SLAVE_ADDR 0x51
  30. #define MAX86900A_SLAVE_ADDR 0x57
  31. //MAX86900 Registers
  32. #define MAX86900_INTERRUPT_STATUS 0x00
  33. #define MAX86900_INTERRUPT_ENABLE 0x01
  34. #define MAX86900_FIFO_WRITE_POINTER 0x02
  35. #define MAX86900_OVF_COUNTER 0x03
  36. #define MAX86900_FIFO_READ_POINTER 0x04
  37. #define MAX86900_FIFO_DATA 0x05
  38. #define MAX86900_MODE_CONFIGURATION 0x06
  39. #define MAX86900_SPO2_CONFIGURATION 0x07
  40. #define MAX86900_LED_CONFIGURATION 0x09
  41. #define MAX86900_TEMP_INTEGER 0x16
  42. #define MAX86900_TEMP_FRACTION 0x17
  43. //Self Test
  44. #define MAX86900_TEST_MODE 0xFF
  45. #define MAX86900_TEST_GTST 0x80
  46. #define MAX86900_TEST_ENABLE_IDAC 0x81
  47. #define MAX86900_TEST_ENABLE_PLETH 0x82
  48. #define MAX86900_TEST_ALC 0x8F
  49. #define MAX86900_TEST_ROUTE_MODULATOR 0x97
  50. #define MAX86900_TEST_LOOK_MODE_RED 0x98
  51. #define MAX86900_TEST_LOOK_MODE_IR 0x99
  52. #define MAX86900_TEST_IDAC_GAIN 0x9C
  53. #define MAX86900_FIFO_SIZE 16
  54. typedef enum _PART_TYPE
  55. {
  56. PART_TYPE_MAX86900 = 0,
  57. PART_TYPE_MAX86900A,
  58. PART_TYPE_MAX86900B,
  59. PART_TYPE_MAX86900C,
  60. } PART_TYPE;
  61. struct max86900_platform_data
  62. {
  63. int (*init)(void);
  64. int (*deinit)(void);
  65. };
  66. struct max86900_device_data
  67. {
  68. struct i2c_client *client; // represents the slave device
  69. struct device *dev;
  70. struct input_dev *hrm_input_dev;
  71. struct mutex i2clock;
  72. struct mutex activelock;
  73. #if defined(CONFIG_SENSORS_SSP_STM_HESTIA)
  74. int ldo_en;
  75. int vdd_en;
  76. #else
  77. struct regulator *vdd_1p8;
  78. #if defined(CONFIG_SEC_KACTIVE_PROJECT) || defined(CONFIG_MACH_KSPORTSLTE_SPR)
  79. struct regulator *vdd_3p3;
  80. #endif
  81. const char *sub_ldo4;
  82. #if defined(CONFIG_SEC_KACTIVE_PROJECT) || defined(CONFIG_MACH_KSPORTSLTE_SPR)
  83. const char *led_l19;
  84. #endif
  85. #endif /* CONFIG_SENSORS_SSP_STM_HESTIA */
  86. bool *bio_status;
  87. atomic_t is_enable;
  88. atomic_t is_suspend;
  89. u8 led_current;
  90. u8 hr_range;
  91. u8 hr_range2;
  92. u8 look_mode_ir;
  93. u8 look_mode_red;
  94. u8 eol_test_is_enable;
  95. u8 part_type;
  96. u8 default_current;
  97. u8 test_current_ir;
  98. u8 test_current_red;
  99. u8 eol_test_status;
  100. u16 led;
  101. u16 sample_cnt;
  102. int hrm_int;
  103. int irq;
  104. int hrm_temp;
  105. char *eol_test_result;
  106. char *lib_ver;
  107. int ir_sum;
  108. int r_sum;
  109. };
  110. extern int sensors_create_symlink(struct kobject *target, const char *name);
  111. extern void sensors_remove_symlink(struct kobject *target, const char *name);
  112. extern int sensors_register(struct device *dev, void * drvdata,
  113. struct device_attribute *attributes[], char *name);
  114. extern void sensors_unregister(struct device *dev,
  115. struct device_attribute *attributes[]);
  116. #endif