ams.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include <linux/i2c.h>
  2. #include <linux/input-polldev.h>
  3. #include <linux/kthread.h>
  4. #include <linux/mutex.h>
  5. #include <linux/spinlock.h>
  6. #include <linux/types.h>
  7. #include <linux/of_device.h>
  8. enum ams_irq {
  9. AMS_IRQ_FREEFALL = 0x01,
  10. AMS_IRQ_SHOCK = 0x02,
  11. AMS_IRQ_GLOBAL = 0x04,
  12. AMS_IRQ_ALL =
  13. AMS_IRQ_FREEFALL |
  14. AMS_IRQ_SHOCK |
  15. AMS_IRQ_GLOBAL,
  16. };
  17. struct ams {
  18. /* Locks */
  19. spinlock_t irq_lock;
  20. struct mutex lock;
  21. /* General properties */
  22. struct device_node *of_node;
  23. struct platform_device *of_dev;
  24. char has_device;
  25. char vflag;
  26. u32 orient1;
  27. u32 orient2;
  28. /* Interrupt worker */
  29. struct work_struct worker;
  30. u8 worker_irqs;
  31. /* Implementation
  32. *
  33. * Only call these functions with the main lock held.
  34. */
  35. void (*exit)(void);
  36. void (*get_xyz)(s8 *x, s8 *y, s8 *z);
  37. u8 (*get_vendor)(void);
  38. void (*clear_irq)(enum ams_irq reg);
  39. #ifdef CONFIG_SENSORS_AMS_I2C
  40. /* I2C properties */
  41. struct i2c_client *i2c_client;
  42. #endif
  43. /* Joystick emulation */
  44. struct input_polled_dev *idev;
  45. __u16 bustype;
  46. /* calibrated null values */
  47. int xcalib, ycalib, zcalib;
  48. };
  49. extern struct ams ams_info;
  50. extern void ams_sensors(s8 *x, s8 *y, s8 *z);
  51. extern int ams_sensor_attach(void);
  52. extern void ams_sensor_detach(void);
  53. extern int ams_pmu_init(struct device_node *np);
  54. extern int ams_i2c_init(struct device_node *np);
  55. extern int ams_input_init(void);
  56. extern void ams_input_exit(void);