2019-06-04 15:10:57 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2010-07-02 18:22:08 +07:00
|
|
|
/*
|
|
|
|
* Copyright (C) ST-Ericsson SA 2010
|
|
|
|
*
|
|
|
|
* Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __LINUX_MFD_STMPE_H
|
|
|
|
#define __LINUX_MFD_STMPE_H
|
|
|
|
|
2012-01-30 23:46:54 +07:00
|
|
|
#include <linux/mutex.h>
|
|
|
|
|
2018-12-21 20:46:31 +07:00
|
|
|
#define STMPE_SAMPLE_TIME(x) ((x & 0xf) << 4)
|
|
|
|
#define STMPE_MOD_12B(x) ((x & 0x1) << 3)
|
|
|
|
#define STMPE_REF_SEL(x) ((x & 0x1) << 1)
|
|
|
|
#define STMPE_ADC_FREQ(x) (x & 0x3)
|
|
|
|
#define STMPE_AVE_CTRL(x) ((x & 0x3) << 6)
|
|
|
|
#define STMPE_DET_DELAY(x) ((x & 0x7) << 3)
|
|
|
|
#define STMPE_SETTLING(x) (x & 0x7)
|
|
|
|
#define STMPE_FRACTION_Z(x) (x & 0x7)
|
|
|
|
#define STMPE_I_DRIVE(x) (x & 0x1)
|
|
|
|
#define STMPE_OP_MODE(x) ((x & 0x7) << 1)
|
|
|
|
|
2018-12-21 20:46:32 +07:00
|
|
|
#define STMPE811_REG_ADC_CTRL1 0x20
|
|
|
|
#define STMPE811_REG_ADC_CTRL2 0x21
|
|
|
|
|
2012-01-30 23:46:54 +07:00
|
|
|
struct device;
|
2014-05-09 04:16:35 +07:00
|
|
|
struct regulator;
|
2010-07-02 18:22:08 +07: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 12:32:22 +07:00
|
|
|
STMPE610,
|
2011-11-17 12:32:23 +07:00
|
|
|
STMPE801,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE811,
|
2016-08-10 14:39:14 +07:00
|
|
|
STMPE1600,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE1601,
|
2013-04-09 15:35:19 +07:00
|
|
|
STMPE1801,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE2401,
|
|
|
|
STMPE2403,
|
2012-01-27 04:17:03 +07:00
|
|
|
STMPE_NBR_PARTS
|
2010-07-02 18:22:08 +07: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,
|
2016-08-10 14:39:06 +07:00
|
|
|
STMPE_IDX_SYS_CTRL,
|
|
|
|
STMPE_IDX_SYS_CTRL2,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_ICR_LSB,
|
|
|
|
STMPE_IDX_IER_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_IER_MSB,
|
2013-04-09 15:35:19 +07:00
|
|
|
STMPE_IDX_ISR_LSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_ISR_MSB,
|
|
|
|
STMPE_IDX_GPMR_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_GPMR_CSB,
|
|
|
|
STMPE_IDX_GPMR_MSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_GPSR_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_GPSR_CSB,
|
|
|
|
STMPE_IDX_GPSR_MSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_GPCR_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_GPCR_CSB,
|
|
|
|
STMPE_IDX_GPCR_MSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_GPDR_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_GPDR_CSB,
|
|
|
|
STMPE_IDX_GPDR_MSB,
|
|
|
|
STMPE_IDX_GPEDR_LSB,
|
|
|
|
STMPE_IDX_GPEDR_CSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_GPEDR_MSB,
|
|
|
|
STMPE_IDX_GPRER_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_GPRER_CSB,
|
|
|
|
STMPE_IDX_GPRER_MSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_GPFER_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_GPFER_CSB,
|
|
|
|
STMPE_IDX_GPFER_MSB,
|
2014-11-04 07:48:47 +07:00
|
|
|
STMPE_IDX_GPPUR_LSB,
|
|
|
|
STMPE_IDX_GPPDR_LSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_GPAFR_U_MSB,
|
|
|
|
STMPE_IDX_IEGPIOR_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_IEGPIOR_CSB,
|
|
|
|
STMPE_IDX_IEGPIOR_MSB,
|
2013-04-09 15:35:19 +07:00
|
|
|
STMPE_IDX_ISGPIOR_LSB,
|
2016-08-10 14:39:11 +07:00
|
|
|
STMPE_IDX_ISGPIOR_CSB,
|
2010-07-02 18:22:08 +07:00
|
|
|
STMPE_IDX_ISGPIOR_MSB,
|
|
|
|
STMPE_IDX_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct stmpe_variant_info;
|
2011-11-17 12:32:20 +07:00
|
|
|
struct stmpe_client_info;
|
2016-05-25 19:22:02 +07:00
|
|
|
struct stmpe_platform_data;
|
2010-07-02 18:22:08 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct stmpe - STMPE MFD structure
|
2014-05-09 04:16:35 +07:00
|
|
|
* @vcc: optional VCC regulator
|
|
|
|
* @vio: optional VIO regulator
|
2010-07-02 18:22:08 +07:00
|
|
|
* @lock: lock protecting I/O operations
|
|
|
|
* @irq_lock: IRQ bus lock
|
|
|
|
* @dev: device, mostly for dev_dbg()
|
2012-11-05 22:10:31 +07:00
|
|
|
* @irq_domain: IRQ domain
|
2011-11-17 12:32:20 +07:00
|
|
|
* @client: client - i2c or spi
|
|
|
|
* @ci: client specific information
|
2011-06-27 14:54:22 +07:00
|
|
|
* @partnum: part number
|
2010-07-02 18:22:08 +07: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 11:14:06 +07:00
|
|
|
* @irq: irq number for stmpe
|
2010-07-02 18:22:08 +07: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 04:16:35 +07:00
|
|
|
struct regulator *vcc;
|
|
|
|
struct regulator *vio;
|
2010-07-02 18:22:08 +07:00
|
|
|
struct mutex lock;
|
|
|
|
struct mutex irq_lock;
|
|
|
|
struct device *dev;
|
2012-11-05 22:10:31 +07:00
|
|
|
struct irq_domain *domain;
|
2011-11-17 12:32:20 +07:00
|
|
|
void *client;
|
|
|
|
struct stmpe_client_info *ci;
|
2010-07-02 18:22:08 +07:00
|
|
|
enum stmpe_partnum partnum;
|
|
|
|
struct stmpe_variant_info *variant;
|
|
|
|
const u8 *regs;
|
|
|
|
|
2011-11-08 11:14:06 +07:00
|
|
|
int irq;
|
2010-07-02 18:22:08 +07:00
|
|
|
int num_gpios;
|
|
|
|
u8 ier[2];
|
|
|
|
u8 oldier[2];
|
|
|
|
struct stmpe_platform_data *pdata;
|
2018-12-21 20:46:32 +07:00
|
|
|
|
|
|
|
/* For devices that use an ADC */
|
|
|
|
u8 sample_time;
|
|
|
|
u8 mod_12b;
|
|
|
|
u8 ref_sel;
|
|
|
|
u8 adc_freq;
|
2010-07-02 18:22:08 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
2018-12-21 20:46:32 +07:00
|
|
|
extern int stmpe811_adc_common_init(struct stmpe *stmpe);
|
2010-07-02 18:22:08 +07:00
|
|
|
|
2010-08-16 22:14:44 +07:00
|
|
|
#define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
|
|
|
|
|
2010-07-02 18:22:08 +07:00
|
|
|
#endif
|