ams.h 1.4 KB

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