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