xref: /OK3568_Linux_fs/kernel/include/linux/spi/ads7846.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /* linux/spi/ads7846.h */
3*4882a593Smuzhiyun 
4*4882a593Smuzhiyun /* Touchscreen characteristics vary between boards and models.  The
5*4882a593Smuzhiyun  * platform_data for the device's "struct device" holds this information.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * It's OK if the min/max values are zero.
8*4882a593Smuzhiyun  */
9*4882a593Smuzhiyun enum ads7846_filter {
10*4882a593Smuzhiyun 	ADS7846_FILTER_OK,
11*4882a593Smuzhiyun 	ADS7846_FILTER_REPEAT,
12*4882a593Smuzhiyun 	ADS7846_FILTER_IGNORE,
13*4882a593Smuzhiyun };
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun struct ads7846_platform_data {
16*4882a593Smuzhiyun 	u16	model;			/* 7843, 7845, 7846, 7873. */
17*4882a593Smuzhiyun 	u16	vref_delay_usecs;	/* 0 for external vref; etc */
18*4882a593Smuzhiyun 	u16	vref_mv;		/* external vref value, milliVolts
19*4882a593Smuzhiyun 					 * ads7846: if 0, use internal vref */
20*4882a593Smuzhiyun 	bool	keep_vref_on;		/* set to keep vref on for differential
21*4882a593Smuzhiyun 					 * measurements as well */
22*4882a593Smuzhiyun 	bool	swap_xy;		/* swap x and y axes */
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	/* Settling time of the analog signals; a function of Vcc and the
25*4882a593Smuzhiyun 	 * capacitance on the X/Y drivers.  If set to non-zero, two samples
26*4882a593Smuzhiyun 	 * are taken with settle_delay us apart, and the second one is used.
27*4882a593Smuzhiyun 	 * ~150 uSec with 0.01uF caps.
28*4882a593Smuzhiyun 	 */
29*4882a593Smuzhiyun 	u16	settle_delay_usecs;
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun 	/* If set to non-zero, after samples are taken this delay is applied
32*4882a593Smuzhiyun 	 * and penirq is rechecked, to help avoid false events.  This value
33*4882a593Smuzhiyun 	 * is affected by the material used to build the touch layer.
34*4882a593Smuzhiyun 	 */
35*4882a593Smuzhiyun 	u16	penirq_recheck_delay_usecs;
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun 	u16	x_plate_ohms;
38*4882a593Smuzhiyun 	u16	y_plate_ohms;
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun 	u16	x_min, x_max;
41*4882a593Smuzhiyun 	u16	y_min, y_max;
42*4882a593Smuzhiyun 	u16	pressure_min, pressure_max;
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun 	u16	debounce_max;		/* max number of additional readings
45*4882a593Smuzhiyun 					 * per sample */
46*4882a593Smuzhiyun 	u16	debounce_tol;		/* tolerance used for filtering */
47*4882a593Smuzhiyun 	u16	debounce_rep;		/* additional consecutive good readings
48*4882a593Smuzhiyun 					 * required after the first two */
49*4882a593Smuzhiyun 	int	gpio_pendown;		/* the GPIO used to decide the pendown
50*4882a593Smuzhiyun 					 * state if get_pendown_state == NULL */
51*4882a593Smuzhiyun 	int	gpio_pendown_debounce;	/* platform specific debounce time for
52*4882a593Smuzhiyun 					 * the gpio_pendown */
53*4882a593Smuzhiyun 	int	(*get_pendown_state)(void);
54*4882a593Smuzhiyun 	int	(*filter_init)	(const struct ads7846_platform_data *pdata,
55*4882a593Smuzhiyun 				 void **filter_data);
56*4882a593Smuzhiyun 	int	(*filter)	(void *filter_data, int data_idx, int *val);
57*4882a593Smuzhiyun 	void	(*filter_cleanup)(void *filter_data);
58*4882a593Smuzhiyun 	void	(*wait_for_sync)(void);
59*4882a593Smuzhiyun 	bool	wakeup;
60*4882a593Smuzhiyun 	unsigned long irq_flags;
61*4882a593Smuzhiyun };
62*4882a593Smuzhiyun 
63