1 2/* 3 * Copyright (c) 2008 MtekVision Co., Ltd. 4 * Kwangwoo Lee <kwlee@mtekvision.com> 5 * 6 * Using code from: 7 * - ads7846.c 8 * Copyright (c) 2005 David Brownell 9 * Copyright (c) 2006 Nokia Corporation 10 * - corgi_ts.c 11 * Copyright (C) 2004-2005 Richard Purdie 12 * - omap_ts.[hc], ads7846.h, ts_osk.c 13 * Copyright (C) 2002 MontaVista Software 14 * Copyright (C) 2004 Texas Instruments 15 * Copyright (C) 2005 Dirk Behme 16 * 17 * This program is free software; you can redistribute it and/or modify 18 * it under the terms of the GNU General Public License version 2 as 19 * published by the Free Software Foundation. 20 */ 21 22#ifndef _TSC2007_H 23#define _TSC2007_H 24 25#define TSC2007_MEASURE_TEMP0 (0x0 << 4) 26#define TSC2007_MEASURE_AUX (0x2 << 4) 27#define TSC2007_MEASURE_TEMP1 (0x4 << 4) 28#define TSC2007_ACTIVATE_XN (0x8 << 4) 29#define TSC2007_ACTIVATE_YN (0x9 << 4) 30#define TSC2007_ACTIVATE_YP_XN (0xa << 4) 31#define TSC2007_SETUP (0xb << 4) 32#define TSC2007_MEASURE_X (0xc << 4) 33#define TSC2007_MEASURE_Y (0xd << 4) 34#define TSC2007_MEASURE_Z1 (0xe << 4) 35#define TSC2007_MEASURE_Z2 (0xf << 4) 36 37#define TSC2007_POWER_OFF_IRQ_EN (0x0 << 2) 38#define TSC2007_ADC_ON_IRQ_DIS0 (0x1 << 2) 39#define TSC2007_ADC_OFF_IRQ_EN (0x2 << 2) 40#define TSC2007_ADC_ON_IRQ_DIS1 (0x3 << 2) 41 42#define TSC2007_12BIT (0x0 << 1) 43#define TSC2007_8BIT (0x1 << 1) 44 45#define MAX_12BIT ((1 << 12) - 1) 46 47#define ADC_ON_12BIT (TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0) 48 49#define READ_Y (ADC_ON_12BIT | TSC2007_MEASURE_Y) 50#define READ_Z1 (ADC_ON_12BIT | TSC2007_MEASURE_Z1) 51#define READ_Z2 (ADC_ON_12BIT | TSC2007_MEASURE_Z2) 52#define READ_X (ADC_ON_12BIT | TSC2007_MEASURE_X) 53#define PWRDOWN (TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN) 54 55struct ts_event { 56 u16 x; 57 u16 y; 58 u16 z1, z2; 59}; 60 61struct tsc2007 { 62 struct input_dev *input; 63 char phys[32]; 64 65 struct i2c_client *client; 66 67 u16 model; 68 u16 x_plate_ohms; 69 u16 max_rt; 70 unsigned long poll_period; /* in jiffies */ 71 int fuzzx; 72 int fuzzy; 73 int fuzzz; 74 75 unsigned int gpio; 76 int irq; 77 78 wait_queue_head_t wait; 79 bool stopped; 80 81 int (*get_pendown_state)(struct device *); 82 void (*clear_penirq)(void); 83 84 struct mutex mlock; 85}; 86 87int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd); 88u32 tsc2007_calculate_resistance(struct tsc2007 *tsc, struct ts_event *tc); 89bool tsc2007_is_pen_down(struct tsc2007 *ts); 90 91#if IS_ENABLED(CONFIG_TOUCHSCREEN_TSC2007_IIO) 92/* defined in tsc2007_iio.c */ 93int tsc2007_iio_configure(struct tsc2007 *ts); 94#else 95static inline int tsc2007_iio_configure(struct tsc2007 *ts) 96{ 97 return 0; 98} 99#endif /* CONFIG_TOUCHSCREEN_TSC2007_IIO */ 100 101#endif /* _TSC2007_H */ 102