1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #ifndef _AMS_H |
3 | #define _AMS_H |
4 | |
5 | #include <linux/i2c.h> |
6 | #include <linux/input.h> |
7 | #include <linux/kthread.h> |
8 | #include <linux/mutex.h> |
9 | #include <linux/platform_device.h> |
10 | #include <linux/spinlock.h> |
11 | #include <linux/types.h> |
12 | |
13 | enum ams_irq { |
14 | AMS_IRQ_FREEFALL = 0x01, |
15 | AMS_IRQ_SHOCK = 0x02, |
16 | AMS_IRQ_GLOBAL = 0x04, |
17 | AMS_IRQ_ALL = |
18 | AMS_IRQ_FREEFALL | |
19 | AMS_IRQ_SHOCK | |
20 | AMS_IRQ_GLOBAL, |
21 | }; |
22 | |
23 | struct ams { |
24 | /* Locks */ |
25 | spinlock_t irq_lock; |
26 | struct mutex lock; |
27 | |
28 | /* General properties */ |
29 | struct device_node *of_node; |
30 | struct platform_device *of_dev; |
31 | char has_device; |
32 | char vflag; |
33 | u32 orient1; |
34 | u32 orient2; |
35 | |
36 | /* Interrupt worker */ |
37 | struct work_struct worker; |
38 | u8 worker_irqs; |
39 | |
40 | /* Implementation |
41 | * |
42 | * Only call these functions with the main lock held. |
43 | */ |
44 | void (*exit)(void); |
45 | |
46 | void (*get_xyz)(s8 *x, s8 *y, s8 *z); |
47 | u8 (*get_vendor)(void); |
48 | |
49 | void (*clear_irq)(enum ams_irq reg); |
50 | |
51 | #ifdef CONFIG_SENSORS_AMS_I2C |
52 | /* I2C properties */ |
53 | struct i2c_client *i2c_client; |
54 | #endif |
55 | |
56 | /* Joystick emulation */ |
57 | struct input_dev *idev; |
58 | __u16 bustype; |
59 | |
60 | /* calibrated null values */ |
61 | int xcalib, ycalib, zcalib; |
62 | }; |
63 | |
64 | extern struct ams ams_info; |
65 | |
66 | extern void ams_sensors(s8 *x, s8 *y, s8 *z); |
67 | extern int ams_sensor_attach(void); |
68 | extern void ams_sensor_detach(void); |
69 | |
70 | extern int ams_pmu_init(struct device_node *np); |
71 | extern int ams_i2c_init(struct device_node *np); |
72 | |
73 | extern int ams_input_init(void); |
74 | extern void ams_input_exit(void); |
75 | |
76 | #endif /* _AMS_H */ |
77 | |