summaryrefstree
path: root/kernel/drivers/optics/max86900.h
blob: 2544f6066b7ef9bb229d5bd911342646f9c29e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef _MAX86900_H_
#define _MAX86900_H_

#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/irq.h>
#include <linux/input.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/leds.h>
#include <linux/miscdevice.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/workqueue.h>
#include <linux/spinlock.h>
#include <linux/gpio.h>

#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/time.h>
#include <linux/timer.h>

#define MAX86900_DEBUG

#define MAX86900_SLAVE_ADDR			0x51
#define MAX86900A_SLAVE_ADDR		0x57

/* MAX86900 Registers */
#define MAX86900_INTERRUPT_STATUS	0x00
#define MAX86900_INTERRUPT_ENABLE	0x01

#define MAX86900_FIFO_WRITE_POINTER	0x02
#define MAX86900_OVF_COUNTER		0x03
#define MAX86900_FIFO_READ_POINTER	0x04
#define MAX86900_FIFO_DATA			0x05
#define MAX86900_MODE_CONFIGURATION	0x06
#define MAX86900_SPO2_CONFIGURATION	0x07
#define MAX86900_LED_CONFIGURATION	0x09
#define MAX86900_TEMP_INTEGER		0x16
#define MAX86900_TEMP_FRACTION		0x17


/* Self Test */
#define MAX86900_TEST_MODE		0xFF
#define MAX86900_TEST_GTST		0x80
#define MAX86900_TEST_ENABLE_IDAC	0x81
#define MAX86900_TEST_ENABLE_PLETH	0x82
#define MAX86900_TEST_ALC			0x8F
#define MAX86900_TEST_ROUTE_MODULATOR	0x97
#define MAX86900_TEST_LOOK_MODE_RED		0x98
#define MAX86900_TEST_LOOK_MODE_IR		0x99
#define MAX86900_TEST_IDAC_GAIN		0x9C


#define MAX86900_FIFO_SIZE		16

typedef enum _PART_TYPE {
	PART_TYPE_MAX86900 = 0,
	PART_TYPE_MAX86900A,
	PART_TYPE_MAX86900B,
	PART_TYPE_MAX86900C,
} PART_TYPE;

struct max86900_platform_data {
	int (*init)(void);
	int (*deinit)(void);
};

struct max86900_device_data {
	struct i2c_client *client;          /* represents the slave device */
	struct device *dev;
	struct input_dev *hrm_input_dev;
	struct mutex i2clock;
	struct mutex activelock;
	struct mutex storelock;
	struct regulator *vdd_1p8;
	struct regulator *vdd_3p3;
	bool *bio_status;
	u8 is_enable;
	u8 led_current;
	u8 hr_range;
	u8 hr_range2;
	u8 look_mode_ir;
	u8 look_mode_red;
	u8 eol_test_is_enable;
	u8 part_type;
	u8 default_current;
	u8 test_current_ir;
	u8 test_current_red;
	u8 eol_test_status;
	u16 led;
	u16 sample_cnt;
	int hrm_int;
	int irq;
	int hrm_temp;
	char *eol_test_result;
	char *lib_ver;
	int ir_sum;
	int r_sum;
};

extern int sensors_create_symlink(struct input_dev *inputdev);
extern void sensors_remove_symlink(struct input_dev *inputdev);
extern int sensors_register(struct device *dev, void *drvdata,
	struct device_attribute *attributes[], char *name);
extern void sensors_unregister(struct device *dev,
	struct device_attribute *attributes[]);
#endif