2010-07-02 19:22:08 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) ST-Ericsson SA 2010
|
|
|
|
*
|
|
|
|
* License Terms: GNU General Public License, version 2
|
|
|
|
* Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_MFD_STMPE_H
|
|
|
|
#define __LINUX_MFD_STMPE_H
|
|
|
|
|
2012-01-31 00:46:54 +08:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
|
|
|
|
struct device;
|
2014-05-09 05:16:35 +08:00
|
|
|
struct regulator;
|
2010-07-02 19:22:08 +08:00
|
|
|
|
|
|
|
enum stmpe_block {
|
|
|
|
STMPE_BLOCK_GPIO = 1 << 0,
|
|
|
|
STMPE_BLOCK_KEYPAD = 1 << 1,
|
|
|
|
STMPE_BLOCK_TOUCHSCREEN = 1 << 2,
|
|
|
|
STMPE_BLOCK_ADC = 1 << 3,
|
|
|
|
STMPE_BLOCK_PWM = 1 << 4,
|
|
|
|
STMPE_BLOCK_ROTATOR = 1 << 5,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum stmpe_partnum {
|
2011-11-17 13:32:22 +08:00
|
|
|
STMPE610,
|
2011-11-17 13:32:23 +08:00
|
|
|
STMPE801,
|
2010-07-02 19:22:08 +08:00
|
|
|
STMPE811,
|
|
|
|
STMPE1601,
|
2013-04-09 16:35:19 +08:00
|
|
|
STMPE1801,
|
2010-07-02 19:22:08 +08:00
|
|
|
STMPE2401,
|
|
|
|
STMPE2403,
|
2012-01-27 05:17:03 +08:00
|
|
|
STMPE_NBR_PARTS
|
2010-07-02 19:22:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For registers whose locations differ on variants, the correct address is
|
|
|
|
* obtained by indexing stmpe->regs with one of the following.
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
STMPE_IDX_CHIP_ID,
|
|
|
|
STMPE_IDX_ICR_LSB,
|
|
|
|
STMPE_IDX_IER_LSB,
|
2013-04-09 16:35:19 +08:00
|
|
|
STMPE_IDX_ISR_LSB,
|
2010-07-02 19:22:08 +08:00
|
|
|
STMPE_IDX_ISR_MSB,
|
|
|
|
STMPE_IDX_GPMR_LSB,
|
|
|
|
STMPE_IDX_GPSR_LSB,
|
|
|
|
STMPE_IDX_GPCR_LSB,
|
|
|
|
STMPE_IDX_GPDR_LSB,
|
|
|
|
STMPE_IDX_GPEDR_MSB,
|
|
|
|
STMPE_IDX_GPRER_LSB,
|
|
|
|
STMPE_IDX_GPFER_LSB,
|
2014-11-04 08:48:47 +08:00
|
|
|
STMPE_IDX_GPPUR_LSB,
|
|
|
|
STMPE_IDX_GPPDR_LSB,
|
2010-07-02 19:22:08 +08:00
|
|
|
STMPE_IDX_GPAFR_U_MSB,
|
|
|
|
STMPE_IDX_IEGPIOR_LSB,
|
2013-04-09 16:35:19 +08:00
|
|
|
STMPE_IDX_ISGPIOR_LSB,
|
2010-07-02 19:22:08 +08:00
|
|
|
STMPE_IDX_ISGPIOR_MSB,
|
|
|
|
STMPE_IDX_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct stmpe_variant_info;
|
2011-11-17 13:32:20 +08:00
|
|
|
struct stmpe_client_info;
|
2010-07-02 19:22:08 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct stmpe - STMPE MFD structure
|
2014-05-09 05:16:35 +08:00
|
|
|
* @vcc: optional VCC regulator
|
|
|
|
* @vio: optional VIO regulator
|
2010-07-02 19:22:08 +08:00
|
|
|
* @lock: lock protecting I/O operations
|
|
|
|
* @irq_lock: IRQ bus lock
|
|
|
|
* @dev: device, mostly for dev_dbg()
|
2012-11-05 23:10:31 +08:00
|
|
|
* @irq_domain: IRQ domain
|
2011-11-17 13:32:20 +08:00
|
|
|
* @client: client - i2c or spi
|
|
|
|
* @ci: client specific information
|
2011-06-27 15:54:22 +08:00
|
|
|
* @partnum: part number
|
2010-07-02 19:22:08 +08:00
|
|
|
* @variant: the detected STMPE model number
|
|
|
|
* @regs: list of addresses of registers which are at different addresses on
|
|
|
|
* different variants. Indexed by one of STMPE_IDX_*.
|
2011-11-08 12:14:06 +08:00
|
|
|
* @irq: irq number for stmpe
|
2010-07-02 19:22:08 +08:00
|
|
|
* @num_gpios: number of gpios, differs for variants
|
|
|
|
* @ier: cache of IER registers for bus_lock
|
|
|
|
* @oldier: cache of IER registers for bus_lock
|
|
|
|
* @pdata: platform data
|
|
|
|
*/
|
|
|
|
struct stmpe {
|
2014-05-09 05:16:35 +08:00
|
|
|
struct regulator *vcc;
|
|
|
|
struct regulator *vio;
|
2010-07-02 19:22:08 +08:00
|
|
|
struct mutex lock;
|
|
|
|
struct mutex irq_lock;
|
|
|
|
struct device *dev;
|
2012-11-05 23:10:31 +08:00
|
|
|
struct irq_domain *domain;
|
2011-11-17 13:32:20 +08:00
|
|
|
void *client;
|
|
|
|
struct stmpe_client_info *ci;
|
2010-07-02 19:22:08 +08:00
|
|
|
enum stmpe_partnum partnum;
|
|
|
|
struct stmpe_variant_info *variant;
|
|
|
|
const u8 *regs;
|
|
|
|
|
2011-11-08 12:14:06 +08:00
|
|
|
int irq;
|
2010-07-02 19:22:08 +08:00
|
|
|
int num_gpios;
|
|
|
|
u8 ier[2];
|
|
|
|
u8 oldier[2];
|
|
|
|
struct stmpe_platform_data *pdata;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern int stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 data);
|
|
|
|
extern int stmpe_reg_read(struct stmpe *stmpe, u8 reg);
|
|
|
|
extern int stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length,
|
|
|
|
u8 *values);
|
|
|
|
extern int stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
|
|
|
|
const u8 *values);
|
|
|
|
extern int stmpe_set_bits(struct stmpe *stmpe, u8 reg, u8 mask, u8 val);
|
|
|
|
extern int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins,
|
|
|
|
enum stmpe_block block);
|
|
|
|
extern int stmpe_enable(struct stmpe *stmpe, unsigned int blocks);
|
|
|
|
extern int stmpe_disable(struct stmpe *stmpe, unsigned int blocks);
|
|
|
|
|
2010-08-16 23:14:44 +08:00
|
|
|
#define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
|
|
|
|
|
2010-07-02 19:22:08 +08:00
|
|
|
/**
|
|
|
|
* struct stmpe_platform_data - STMPE platform data
|
|
|
|
* @id: device id to distinguish between multiple STMPEs on the same board
|
|
|
|
* @blocks: bitmask of blocks to enable (use STMPE_BLOCK_*)
|
|
|
|
* @irq_trigger: IRQ trigger to use for the interrupt to the host
|
2010-07-21 14:11:07 +08:00
|
|
|
* @autosleep: bool to enable/disable stmpe autosleep
|
|
|
|
* @autosleep_timeout: inactivity timeout in milliseconds for autosleep
|
2011-11-08 12:14:06 +08:00
|
|
|
* @irq_over_gpio: true if gpio is used to get irq
|
|
|
|
* @irq_gpio: gpio number over which irq will be requested (significant only if
|
|
|
|
* irq_over_gpio is true)
|
2010-07-02 19:22:08 +08:00
|
|
|
*/
|
|
|
|
struct stmpe_platform_data {
|
|
|
|
int id;
|
|
|
|
unsigned int blocks;
|
|
|
|
unsigned int irq_trigger;
|
2010-07-21 14:11:07 +08:00
|
|
|
bool autosleep;
|
2011-11-08 12:14:06 +08:00
|
|
|
bool irq_over_gpio;
|
|
|
|
int irq_gpio;
|
2010-07-21 14:11:07 +08:00
|
|
|
int autosleep_timeout;
|
2010-07-02 19:22:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|