Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 2 | #include <linux/i2c.h> |
Dmitry Torokhov | 0c444d9 | 2019-10-02 14:48:54 -0700 | [diff] [blame] | 3 | #include <linux/input.h> |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 4 | #include <linux/kthread.h> |
| 5 | #include <linux/mutex.h> |
| 6 | #include <linux/spinlock.h> |
| 7 | #include <linux/types.h> |
Stephen Rothwell | f6f1101 | 2008-08-11 17:04:32 +1000 | [diff] [blame] | 8 | #include <linux/of_device.h> |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 9 | |
| 10 | enum ams_irq { |
| 11 | AMS_IRQ_FREEFALL = 0x01, |
| 12 | AMS_IRQ_SHOCK = 0x02, |
| 13 | AMS_IRQ_GLOBAL = 0x04, |
| 14 | AMS_IRQ_ALL = |
| 15 | AMS_IRQ_FREEFALL | |
| 16 | AMS_IRQ_SHOCK | |
| 17 | AMS_IRQ_GLOBAL, |
| 18 | }; |
| 19 | |
| 20 | struct ams { |
| 21 | /* Locks */ |
| 22 | spinlock_t irq_lock; |
| 23 | struct mutex lock; |
| 24 | |
| 25 | /* General properties */ |
| 26 | struct device_node *of_node; |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 27 | struct platform_device *of_dev; |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 28 | char has_device; |
| 29 | char vflag; |
| 30 | u32 orient1; |
| 31 | u32 orient2; |
| 32 | |
| 33 | /* Interrupt worker */ |
| 34 | struct work_struct worker; |
| 35 | u8 worker_irqs; |
| 36 | |
| 37 | /* Implementation |
| 38 | * |
| 39 | * Only call these functions with the main lock held. |
| 40 | */ |
| 41 | void (*exit)(void); |
| 42 | |
| 43 | void (*get_xyz)(s8 *x, s8 *y, s8 *z); |
| 44 | u8 (*get_vendor)(void); |
| 45 | |
| 46 | void (*clear_irq)(enum ams_irq reg); |
| 47 | |
| 48 | #ifdef CONFIG_SENSORS_AMS_I2C |
| 49 | /* I2C properties */ |
Jean Delvare | 810ad7b | 2008-10-17 17:51:12 +0200 | [diff] [blame] | 50 | struct i2c_client *i2c_client; |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 51 | #endif |
| 52 | |
| 53 | /* Joystick emulation */ |
Dmitry Torokhov | 0c444d9 | 2019-10-02 14:48:54 -0700 | [diff] [blame] | 54 | struct input_dev *idev; |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 55 | __u16 bustype; |
| 56 | |
| 57 | /* calibrated null values */ |
| 58 | int xcalib, ycalib, zcalib; |
| 59 | }; |
| 60 | |
| 61 | extern struct ams ams_info; |
| 62 | |
| 63 | extern void ams_sensors(s8 *x, s8 *y, s8 *z); |
| 64 | extern int ams_sensor_attach(void); |
Jean Delvare | 98ceb75 | 2010-01-31 04:03:23 +0000 | [diff] [blame] | 65 | extern void ams_sensor_detach(void); |
Stelian Pop | dcb69dd | 2006-12-12 18:18:30 +0100 | [diff] [blame] | 66 | |
| 67 | extern int ams_pmu_init(struct device_node *np); |
| 68 | extern int ams_i2c_init(struct device_node *np); |
| 69 | |
| 70 | extern int ams_input_init(void); |
| 71 | extern void ams_input_exit(void); |