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