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