aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/ams/ams.h
diff options
context:
space:
mode:
authorStelian Pop <stelian@popies.net>2006-12-12 12:18:30 -0500
committerJean Delvare <khali@arrakis.delvare>2006-12-12 12:18:30 -0500
commitdcb69dd010c182507a8db8940618f6413f65e0af (patch)
treeb0a2d0795866d7d787af82be6041cf3cabb6c640 /drivers/hwmon/ams/ams.h
parent61db011d403388b2dd342489d7110cf13cb99025 (diff)
hwmon: New AMS hardware monitoring driver
This driver adds support for the Apple Motion Sensor (AMS) as found in 2005 revisions of Apple PowerBooks and iBooks. It implements both the PMU and I2C variants. The I2C driver and mouse emulation is based on code by Stelian Pop, while the PMU driver has been developped by Michael Hanselmann. HD parking support will be added later. Various people contributed fixes to this driver, including Aristeu Sergio Rozanski Filho and Jean Delvare. Signed-off-by: Stelian Pop <stelian@popies.net> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Robert Love <rml@novell.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/hwmon/ams/ams.h')
-rw-r--r--drivers/hwmon/ams/ams.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/drivers/hwmon/ams/ams.h b/drivers/hwmon/ams/ams.h
new file mode 100644
index 000000000000..240730e6bcde
--- /dev/null
+++ b/drivers/hwmon/ams/ams.h
@@ -0,0 +1,72 @@
1#include <linux/i2c.h>
2#include <linux/input.h>
3#include <linux/kthread.h>
4#include <linux/mutex.h>
5#include <linux/spinlock.h>
6#include <linux/types.h>
7#include <asm/of_device.h>
8
9enum 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
19struct ams {
20 /* Locks */
21 spinlock_t irq_lock;
22 struct mutex lock;
23
24 /* General properties */
25 struct device_node *of_node;
26 struct of_device *of_dev;
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 */
49 int i2c_bus;
50 int i2c_address;
51 struct i2c_client i2c_client;
52#endif
53
54 /* Joystick emulation */
55 struct task_struct *kthread;
56 struct input_dev *idev;
57 __u16 bustype;
58
59 /* calibrated null values */
60 int xcalib, ycalib, zcalib;
61};
62
63extern struct ams ams_info;
64
65extern void ams_sensors(s8 *x, s8 *y, s8 *z);
66extern int ams_sensor_attach(void);
67
68extern int ams_pmu_init(struct device_node *np);
69extern int ams_i2c_init(struct device_node *np);
70
71extern int ams_input_init(void);
72extern void ams_input_exit(void);