ams.h 1.4 KB

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