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