Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 
0003 /*
0004  * Copyright (c) 2008 MtekVision Co., Ltd.
0005  *  Kwangwoo Lee <kwlee@mtekvision.com>
0006  *
0007  * Using code from:
0008  *  - ads7846.c
0009  *  Copyright (c) 2005 David Brownell
0010  *  Copyright (c) 2006 Nokia Corporation
0011  *  - corgi_ts.c
0012  *  Copyright (C) 2004-2005 Richard Purdie
0013  *  - omap_ts.[hc], ads7846.h, ts_osk.c
0014  *  Copyright (C) 2002 MontaVista Software
0015  *  Copyright (C) 2004 Texas Instruments
0016  *  Copyright (C) 2005 Dirk Behme
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; /* in jiffies */
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 /* defined in tsc2007_iio.c */
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 /* CONFIG_TOUCHSCREEN_TSC2007_IIO */
0099 
0100 #endif /* _TSC2007_H */