0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019 #ifndef _TSC2007_H
0020 #define _TSC2007_H
0021
0022 struct gpio_desc;
0023
0024 #define TSC2007_MEASURE_TEMP0 (0x0 << 4)
0025 #define TSC2007_MEASURE_AUX (0x2 << 4)
0026 #define TSC2007_MEASURE_TEMP1 (0x4 << 4)
0027 #define TSC2007_ACTIVATE_XN (0x8 << 4)
0028 #define TSC2007_ACTIVATE_YN (0x9 << 4)
0029 #define TSC2007_ACTIVATE_YP_XN (0xa << 4)
0030 #define TSC2007_SETUP (0xb << 4)
0031 #define TSC2007_MEASURE_X (0xc << 4)
0032 #define TSC2007_MEASURE_Y (0xd << 4)
0033 #define TSC2007_MEASURE_Z1 (0xe << 4)
0034 #define TSC2007_MEASURE_Z2 (0xf << 4)
0035
0036 #define TSC2007_POWER_OFF_IRQ_EN (0x0 << 2)
0037 #define TSC2007_ADC_ON_IRQ_DIS0 (0x1 << 2)
0038 #define TSC2007_ADC_OFF_IRQ_EN (0x2 << 2)
0039 #define TSC2007_ADC_ON_IRQ_DIS1 (0x3 << 2)
0040
0041 #define TSC2007_12BIT (0x0 << 1)
0042 #define TSC2007_8BIT (0x1 << 1)
0043
0044 #define MAX_12BIT ((1 << 12) - 1)
0045
0046 #define ADC_ON_12BIT (TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0)
0047
0048 #define READ_Y (ADC_ON_12BIT | TSC2007_MEASURE_Y)
0049 #define READ_Z1 (ADC_ON_12BIT | TSC2007_MEASURE_Z1)
0050 #define READ_Z2 (ADC_ON_12BIT | TSC2007_MEASURE_Z2)
0051 #define READ_X (ADC_ON_12BIT | TSC2007_MEASURE_X)
0052 #define PWRDOWN (TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN)
0053
0054 struct ts_event {
0055 u16 x;
0056 u16 y;
0057 u16 z1, z2;
0058 };
0059
0060 struct tsc2007 {
0061 struct input_dev *input;
0062 char phys[32];
0063
0064 struct i2c_client *client;
0065
0066 u16 model;
0067 u16 x_plate_ohms;
0068 u16 max_rt;
0069 unsigned long poll_period;
0070 int fuzzx;
0071 int fuzzy;
0072 int fuzzz;
0073
0074 struct gpio_desc *gpiod;
0075 int irq;
0076
0077 wait_queue_head_t wait;
0078 bool stopped;
0079
0080 int (*get_pendown_state)(struct device *);
0081 void (*clear_penirq)(void);
0082
0083 struct mutex mlock;
0084 };
0085
0086 int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd);
0087 u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc);
0088 bool tsc2007_is_pen_down(struct tsc2007 *ts);
0089
0090 #if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2007_IIO)
0091
0092 int tsc2007_iio_configure(struct tsc2007 *ts);
0093 #else
0094 static inline int tsc2007_iio_configure(struct tsc2007 *ts)
0095 {
0096 return 0;
0097 }
0098 #endif
0099
0100 #endif