xref: /linux/include/linux/mfd/stmpe.h (revision fc1882dcb5031953169a38260a0e653910825e46)
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,
4227e34995SRabin Vincent 	STMPE_IDX_ICR_LSB,
4327e34995SRabin Vincent 	STMPE_IDX_IER_LSB,
44230f13a5SJean-Nicolas Graux 	STMPE_IDX_ISR_LSB,
4527e34995SRabin Vincent 	STMPE_IDX_ISR_MSB,
4627e34995SRabin Vincent 	STMPE_IDX_GPMR_LSB,
4727e34995SRabin Vincent 	STMPE_IDX_GPSR_LSB,
4827e34995SRabin Vincent 	STMPE_IDX_GPCR_LSB,
4927e34995SRabin Vincent 	STMPE_IDX_GPDR_LSB,
5027e34995SRabin Vincent 	STMPE_IDX_GPEDR_MSB,
5127e34995SRabin Vincent 	STMPE_IDX_GPRER_LSB,
5227e34995SRabin Vincent 	STMPE_IDX_GPFER_LSB,
5380e1dd82SLinus Walleij 	STMPE_IDX_GPPUR_LSB,
5480e1dd82SLinus Walleij 	STMPE_IDX_GPPDR_LSB,
5527e34995SRabin Vincent 	STMPE_IDX_GPAFR_U_MSB,
5627e34995SRabin Vincent 	STMPE_IDX_IEGPIOR_LSB,
57230f13a5SJean-Nicolas Graux 	STMPE_IDX_ISGPIOR_LSB,
5827e34995SRabin Vincent 	STMPE_IDX_ISGPIOR_MSB,
5927e34995SRabin Vincent 	STMPE_IDX_MAX,
6027e34995SRabin Vincent };
6127e34995SRabin Vincent 
6227e34995SRabin Vincent 
6327e34995SRabin Vincent struct stmpe_variant_info;
641a6e4b74SViresh Kumar struct stmpe_client_info;
65*fc1882dcSLinus Walleij struct stmpe_platform_data;
6627e34995SRabin Vincent 
6727e34995SRabin Vincent /**
6827e34995SRabin Vincent  * struct stmpe - STMPE MFD structure
699c9e3214SLinus Walleij  * @vcc: optional VCC regulator
709c9e3214SLinus Walleij  * @vio: optional VIO regulator
7127e34995SRabin Vincent  * @lock: lock protecting I/O operations
7227e34995SRabin Vincent  * @irq_lock: IRQ bus lock
7327e34995SRabin Vincent  * @dev: device, mostly for dev_dbg()
7476f93992SLee Jones  * @irq_domain: IRQ domain
751a6e4b74SViresh Kumar  * @client: client - i2c or spi
761a6e4b74SViresh Kumar  * @ci: client specific information
774dcaa6b6SOm Prakash  * @partnum: part number
7827e34995SRabin Vincent  * @variant: the detected STMPE model number
7927e34995SRabin Vincent  * @regs: list of addresses of registers which are at different addresses on
8027e34995SRabin Vincent  *	  different variants.  Indexed by one of STMPE_IDX_*.
8173de16dbSViresh Kumar  * @irq: irq number for stmpe
8227e34995SRabin Vincent  * @num_gpios: number of gpios, differs for variants
8327e34995SRabin Vincent  * @ier: cache of IER registers for bus_lock
8427e34995SRabin Vincent  * @oldier: cache of IER registers for bus_lock
8527e34995SRabin Vincent  * @pdata: platform data
8627e34995SRabin Vincent  */
8727e34995SRabin Vincent struct stmpe {
889c9e3214SLinus Walleij 	struct regulator *vcc;
899c9e3214SLinus Walleij 	struct regulator *vio;
9027e34995SRabin Vincent 	struct mutex lock;
9127e34995SRabin Vincent 	struct mutex irq_lock;
9227e34995SRabin Vincent 	struct device *dev;
9376f93992SLee Jones 	struct irq_domain *domain;
941a6e4b74SViresh Kumar 	void *client;
951a6e4b74SViresh Kumar 	struct stmpe_client_info *ci;
9627e34995SRabin Vincent 	enum stmpe_partnum partnum;
9727e34995SRabin Vincent 	struct stmpe_variant_info *variant;
9827e34995SRabin Vincent 	const u8 *regs;
9927e34995SRabin Vincent 
10073de16dbSViresh Kumar 	int irq;
10127e34995SRabin Vincent 	int num_gpios;
10227e34995SRabin Vincent 	u8 ier[2];
10327e34995SRabin Vincent 	u8 oldier[2];
10427e34995SRabin Vincent 	struct stmpe_platform_data *pdata;
10527e34995SRabin Vincent };
10627e34995SRabin Vincent 
10727e34995SRabin Vincent extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data);
10827e34995SRabin Vincent extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg);
10927e34995SRabin Vincent extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length,
11027e34995SRabin Vincent 			    u8 *values);
11127e34995SRabin Vincent extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
11227e34995SRabin Vincent 			     const u8 *values);
11327e34995SRabin Vincent extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val);
11427e34995SRabin Vincent extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins,
11527e34995SRabin Vincent 			     enum stmpe_block block);
11627e34995SRabin Vincent extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks);
11727e34995SRabin Vincent extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
11827e34995SRabin Vincent 
119b8e9cf0bSWolfram Sang #define STMPE_GPIO_NOREQ_811_TOUCH	(0xf0)
120b8e9cf0bSWolfram Sang 
12127e34995SRabin Vincent #endif
122