forked from vuorioi/amg88xx-kernel-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amg88xx.h
156 lines (136 loc) · 4.02 KB
/
amg88xx.h
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef __LINUX_FOCALTECH_CORE_H__
#define __LINUX_FOCALTECH_CORE_H__
#include <linux/device.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/gpio.h>
#include <linux/delay.h>
#define DRIVER_NAME "amg88xx"
/*
* Since we're dealing with 12-bit numbers the sign-bit needs to be extended
* for the number to be represented correctly
*/
#define convert_to_s16(dst, src) \
dst = src & 0x800 ? (src | (0xf << 12)) : src
/* i2c register addresses */
#define DEVICE_MODE_REG 0x00
#define RESET_REG 0x01
#define FRAMERATE_REG 0x02
#define INTERRUPT_CTRL_REG 0x03
#define STATUS_FLAG_REG 0x04 // TODO | one sysfs entry
#define STATUS_FLAG_CLR_REG 0x05 // TODO |
#define MOVING_AVERAGE_REG 0x07 // TODO
#define UPPER_INTERRUPT_LOW_REG 0x08
#define UPPER_INTERRUPT_HIGH_REG 0x09
#define LOWER_INTERRUPT_LOW_REG 0x0a
#define LOWER_INTERRUPT_HIGH_REG 0x0b
#define INTERRUPT_HYST_LOW_REG 0x0c
#define INTERRUPT_HYST_HIGH_REG 0x0d
#define THERM_LOW_REG 0x0e
#define THERM_HIGH_REG 0x0f
#define PIXEL_ROW1_REG 0x10
#define PIXEL_ROW2_REG 0x11
#define PIXEL_ROW3_REG 0x12
#define PIXEL_ROW4_REG 0x13
#define PIXEL_ROW5_REG 0x14
#define PIXEL_ROW6_REG 0x15
#define PIXEL_ROW7_REG 0x16
#define PIXEL_ROW8_REG 0x17
#define SENSOR_FIRST_REG 0x80 // Pixel 1 low bits register
#define SENSOR_LAST_REG 0xFF // Pixel 64 high bits register
#define AMG_DEBUG_EN 1
#if AMG_DEBUG_EN
#define AMG_DEBUG(fmt, args...) \
do \
{ \
printk("[AMG/D]%s:" fmt "\n", __func__, ##args); \
} while (0)
#define AMG_FUNC_ENTER() \
do \
{ \
printk("[AMG]%s: Enter\n", __func__); \
} while (0)
#define AMG_FUNC_EXIT() \
do \
{ \
printk("[AMG]%s: Exit(%d)\n", __func__, __LINE__); \
} while (0)
#else /* #if AMG_DEBUG_EN*/
#define AMG_DEBUG(fmt, args...)
#define AMG_FUNC_ENTER()
#define AMG_FUNC_EXIT()
#endif
#define AMG_INFO(fmt, args...) \
do \
{ \
printk(KERN_ERR "[AMG/I]%s:" fmt "\n", __func__, ##args); \
} while (0)
#define AMG_ERROR(fmt, args...) \
do \
{ \
printk(KERN_ERR "[AMG/E]%s:" fmt "\n", __func__, ##args); \
} while (0)
#define ENABLE 1
#define DISABLE 0
#define AMG_I2C_VTG_MIN_UV 1800000
#define AMG_I2C_VTG_MAX_UV 1800000
/*
* Device configuration options that are mapped to register values
*/
enum amg88xx_device_mode
{
NORMAL_MODE = 0x0,
SLEEP_MODE = 0x10,
STANDBY60_MODE = 0x20,
STANDBY10_MODE = 0x21
};
static const char *mode_strs[4] = {
"normal",
"sleep",
"standby_60",
"standby_10"};
enum amg88xx_reset_mode
{
PARTIAL_RST = 0x30,
FULL_RST = 0x3f
};
enum amg88xx_fps
{
FPS10 = 0,
FPS1 = 1
};
enum amg88xx_interrupt_mode
{
DIFFERENCE_MODE = 0, // FIXME
ABSOLUTE_VALUE_MODE = 1
};
enum amg88xx_interrupt_state
{
INT_DISABLED = 0,
INT_ENABLED = 1
};
/*
* Structure for holding device related data
*/
struct amg88xx
{
struct i2c_client *client;
struct gpio_desc *int_gpio;
struct device *dev;
u32 en_gpio;
u32 en_gpio_flags;
int en;
bool power_disabled;
struct regulator *vcc_i2c;
struct pinctrl *pinctrl;
struct pinctrl_state *pins_active;
struct pinctrl_state *pins_suspend;
struct pinctrl_state *pins_release;
};
#endif