xref: /linux/include/linux/mfd/stmpe.h (revision 897ac6674c64ca94df5b70ea5c6815a296e1d32a)
127e34995SRabin Vincent /*
227e34995SRabin Vincent  * Copyright (C) ST-Ericsson SA 2010
327e34995SRabin Vincent  *
427e34995SRabin Vincent  * License Terms: GNU General Public License, version 2
527e34995SRabin Vincent  * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
627e34995SRabin Vincent  */
727e34995SRabin Vincent 
827e34995SRabin Vincent #ifndef __LINUX_MFD_STMPE_H
927e34995SRabin Vincent #define __LINUX_MFD_STMPE_H
1027e34995SRabin Vincent 
11313162d0SPaul Gortmaker #include <linux/mutex.h>
12313162d0SPaul Gortmaker 
13313162d0SPaul Gortmaker struct device;
149c9e3214SLinus Walleij struct regulator;
1527e34995SRabin Vincent 
1627e34995SRabin Vincent enum stmpe_block {
1727e34995SRabin Vincent 	STMPE_BLOCK_GPIO	= 1 << 0,
1827e34995SRabin Vincent 	STMPE_BLOCK_KEYPAD	= 1 << 1,
1927e34995SRabin Vincent 	STMPE_BLOCK_TOUCHSCREEN	= 1 << 2,
2027e34995SRabin Vincent 	STMPE_BLOCK_ADC		= 1 << 3,
2127e34995SRabin Vincent 	STMPE_BLOCK_PWM		= 1 << 4,
2227e34995SRabin Vincent 	STMPE_BLOCK_ROTATOR	= 1 << 5,
2327e34995SRabin Vincent };
2427e34995SRabin Vincent 
2527e34995SRabin Vincent enum stmpe_partnum {
261cda2394SViresh Kumar 	STMPE610,
277f7f4ea1SViresh Kumar 	STMPE801,
2827e34995SRabin Vincent 	STMPE811,
2927e34995SRabin Vincent 	STMPE1601,
30230f13a5SJean-Nicolas Graux 	STMPE1801,
3127e34995SRabin Vincent 	STMPE2401,
3227e34995SRabin Vincent 	STMPE2403,
33e31f9b82SChris Blair 	STMPE_NBR_PARTS
3427e34995SRabin Vincent };
3527e34995SRabin Vincent 
3627e34995SRabin Vincent /*
3727e34995SRabin Vincent  * For registers whose locations differ on variants,  the correct address is
3827e34995SRabin Vincent  * obtained by indexing stmpe->regs with one of the following.
3927e34995SRabin Vincent  */
4027e34995SRabin Vincent enum {
4127e34995SRabin Vincent 	STMPE_IDX_CHIP_ID,
420f4be8cfSPatrice Chotard 	STMPE_IDX_SYS_CTRL,
430f4be8cfSPatrice Chotard 	STMPE_IDX_SYS_CTRL2,
4427e34995SRabin Vincent 	STMPE_IDX_ICR_LSB,
4527e34995SRabin Vincent 	STMPE_IDX_IER_LSB,
46*897ac667SPatrice Chotard 	STMPE_IDX_IER_MSB,
47230f13a5SJean-Nicolas Graux 	STMPE_IDX_ISR_LSB,
4827e34995SRabin Vincent 	STMPE_IDX_ISR_MSB,
4927e34995SRabin Vincent 	STMPE_IDX_GPMR_LSB,
50*897ac667SPatrice Chotard 	STMPE_IDX_GPMR_CSB,
51*897ac667SPatrice Chotard 	STMPE_IDX_GPMR_MSB,
5227e34995SRabin Vincent 	STMPE_IDX_GPSR_LSB,
53*897ac667SPatrice Chotard 	STMPE_IDX_GPSR_CSB,
54*897ac667SPatrice Chotard 	STMPE_IDX_GPSR_MSB,
5527e34995SRabin Vincent 	STMPE_IDX_GPCR_LSB,
56*897ac667SPatrice Chotard 	STMPE_IDX_GPCR_CSB,
57*897ac667SPatrice Chotard 	STMPE_IDX_GPCR_MSB,
5827e34995SRabin Vincent 	STMPE_IDX_GPDR_LSB,
59*897ac667SPatrice Chotard 	STMPE_IDX_GPDR_CSB,
60*897ac667SPatrice Chotard 	STMPE_IDX_GPDR_MSB,
61*897ac667SPatrice Chotard 	STMPE_IDX_GPEDR_LSB,
62*897ac667SPatrice Chotard 	STMPE_IDX_GPEDR_CSB,
6327e34995SRabin Vincent 	STMPE_IDX_GPEDR_MSB,
6427e34995SRabin Vincent 	STMPE_IDX_GPRER_LSB,
65*897ac667SPatrice Chotard 	STMPE_IDX_GPRER_CSB,
66*897ac667SPatrice Chotard 	STMPE_IDX_GPRER_MSB,
6727e34995SRabin Vincent 	STMPE_IDX_GPFER_LSB,
68*897ac667SPatrice Chotard 	STMPE_IDX_GPFER_CSB,
69*897ac667SPatrice Chotard 	STMPE_IDX_GPFER_MSB,
7080e1dd82SLinus Walleij 	STMPE_IDX_GPPUR_LSB,
7180e1dd82SLinus Walleij 	STMPE_IDX_GPPDR_LSB,
7227e34995SRabin Vincent 	STMPE_IDX_GPAFR_U_MSB,
7327e34995SRabin Vincent 	STMPE_IDX_IEGPIOR_LSB,
74*897ac667SPatrice Chotard 	STMPE_IDX_IEGPIOR_CSB,
75*897ac667SPatrice Chotard 	STMPE_IDX_IEGPIOR_MSB,
76230f13a5SJean-Nicolas Graux 	STMPE_IDX_ISGPIOR_LSB,
77*897ac667SPatrice Chotard 	STMPE_IDX_ISGPIOR_CSB,
7827e34995SRabin Vincent 	STMPE_IDX_ISGPIOR_MSB,
7927e34995SRabin Vincent 	STMPE_IDX_MAX,
8027e34995SRabin Vincent };
8127e34995SRabin Vincent 
8227e34995SRabin Vincent 
8327e34995SRabin Vincent struct stmpe_variant_info;
841a6e4b74SViresh Kumar struct stmpe_client_info;
85fc1882dcSLinus Walleij struct stmpe_platform_data;
8627e34995SRabin Vincent 
8727e34995SRabin Vincent /**
8827e34995SRabin Vincent  * struct stmpe - STMPE MFD structure
899c9e3214SLinus Walleij  * @vcc: optional VCC regulator
909c9e3214SLinus Walleij  * @vio: optional VIO regulator
9127e34995SRabin Vincent  * @lock: lock protecting I/O operations
9227e34995SRabin Vincent  * @irq_lock: IRQ bus lock
9327e34995SRabin Vincent  * @dev: device, mostly for dev_dbg()
9476f93992SLee Jones  * @irq_domain: IRQ domain
951a6e4b74SViresh Kumar  * @client: client - i2c or spi
961a6e4b74SViresh Kumar  * @ci: client specific information
974dcaa6b6SOm Prakash  * @partnum: part number
9827e34995SRabin Vincent  * @variant: the detected STMPE model number
9927e34995SRabin Vincent  * @regs: list of addresses of registers which are at different addresses on
10027e34995SRabin Vincent  *	  different variants.  Indexed by one of STMPE_IDX_*.
10173de16dbSViresh Kumar  * @irq: irq number for stmpe
10227e34995SRabin Vincent  * @num_gpios: number of gpios, differs for variants
10327e34995SRabin Vincent  * @ier: cache of IER registers for bus_lock
10427e34995SRabin Vincent  * @oldier: cache of IER registers for bus_lock
10527e34995SRabin Vincent  * @pdata: platform data
10627e34995SRabin Vincent  */
10727e34995SRabin Vincent struct stmpe {
1089c9e3214SLinus Walleij 	struct regulator *vcc;
1099c9e3214SLinus Walleij 	struct regulator *vio;
11027e34995SRabin Vincent 	struct mutex lock;
11127e34995SRabin Vincent 	struct mutex irq_lock;
11227e34995SRabin Vincent 	struct device *dev;
11376f93992SLee Jones 	struct irq_domain *domain;
1141a6e4b74SViresh Kumar 	void *client;
1151a6e4b74SViresh Kumar 	struct stmpe_client_info *ci;
11627e34995SRabin Vincent 	enum stmpe_partnum partnum;
11727e34995SRabin Vincent 	struct stmpe_variant_info *variant;
11827e34995SRabin Vincent 	const u8 *regs;
11927e34995SRabin Vincent 
12073de16dbSViresh Kumar 	int irq;
12127e34995SRabin Vincent 	int num_gpios;
12227e34995SRabin Vincent 	u8 ier[2];
12327e34995SRabin Vincent 	u8 oldier[2];
12427e34995SRabin Vincent 	struct stmpe_platform_data *pdata;
12527e34995SRabin Vincent };
12627e34995SRabin Vincent 
12727e34995SRabin Vincent extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data);
12827e34995SRabin Vincent extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg);
12927e34995SRabin Vincent extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length,
13027e34995SRabin Vincent 			    u8 *values);
13127e34995SRabin Vincent extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
13227e34995SRabin Vincent 			     const u8 *values);
13327e34995SRabin Vincent extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val);
13427e34995SRabin Vincent extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins,
13527e34995SRabin Vincent 			     enum stmpe_block block);
13627e34995SRabin Vincent extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks);
13727e34995SRabin Vincent extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
13827e34995SRabin Vincent 
139b8e9cf0bSWolfram Sang #define STMPE_GPIO_NOREQ_811_TOUCH	(0xf0)
140b8e9cf0bSWolfram Sang 
14127e34995SRabin Vincent #endif
142