* [PATCH 1/5] mfd/stmpe: Pass partnum as param to stmpe_probe()
2011-11-16 11:26 [PATCH 0/5] stmpe: mfd & gpio updates Viresh Kumar
@ 2011-11-16 11:26 ` Viresh Kumar
2011-11-16 15:35 ` Rabin Vincent
2011-11-16 11:26 ` [PATCH 2/5] mfd/stmpe: Move struct stmpe_variant_info to linux/mfd/stmpe.h Viresh Kumar
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Viresh Kumar @ 2011-11-16 11:26 UTC (permalink / raw)
To: rabin.vincent, linus.walleij, srinidhi.kasagar
Cc: sameo, linux-kernel, armando.visconti, shiraz.hashim, vipin.kumar,
rajeev-dlh.kumar, deepak.sikri, vipulkumar.samar, amit.virdi,
viresh.kumar, pratyush.anand, bhupesh.sharma, viresh.linux,
bhavna.yadav, vincenzo.frascino, mirko.gardi, grant.likely
partnum is required during probe to get variant's info. Currently partnum was
getting set in i2c interface after it is used and is not at all getting set in
spi interface.
This can be passed as param to stmpe_probe, so that it is available early. With
this, there is no need of i2c interface's init() routine, as it does nothing
else than calling dev_set_drvdata(). So better remove this routine for i2c.
partnum defined in struct stmpe is of no use now, as it is only used once during
probe of stmpe, so we can remove it from struct stmpe too.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
drivers/mfd/stmpe-i2c.c | 11 +----------
drivers/mfd/stmpe-spi.c | 5 +++--
drivers/mfd/stmpe.c | 8 +++++---
drivers/mfd/stmpe.h | 2 +-
include/linux/mfd/stmpe.h | 2 --
5 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index 72fa08b..671fd5c 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -45,20 +45,11 @@ static int i2c_block_write(struct stmpe *stmpe, u8 reg, u8 length,
return i2c_smbus_write_i2c_block_data(i2c, reg, length, values);
}
-static void i2c_init(struct stmpe *stmpe)
-{
- struct i2c_device_id *id = stmpe->ci->data;
-
- stmpe->partnum = id->driver_data;
- dev_set_drvdata(stmpe->dev, stmpe);
-}
-
static struct stmpe_client_info i2c_ci = {
.read_byte = i2c_reg_read,
.write_byte = i2c_reg_write,
.read_block = i2c_block_read,
.write_block = i2c_block_write,
- .init = i2c_init,
};
static int __devinit
@@ -69,7 +60,7 @@ stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
i2c_ci.client = i2c;
i2c_ci.dev = &i2c->dev;
- return stmpe_probe(&i2c_ci);
+ return stmpe_probe(&i2c_ci, id->driver_data);
}
static int __devexit stmpe_i2c_remove(struct i2c_client *i2c)
diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c
index 6f1c0ad3..21861d8 100644
--- a/drivers/mfd/stmpe-spi.c
+++ b/drivers/mfd/stmpe-spi.c
@@ -64,7 +64,6 @@ static void spi_init(struct stmpe *stmpe)
{
struct spi_device *spi = stmpe->client;
- dev_set_drvdata(stmpe->dev, stmpe);
spi->bits_per_word = 8;
/* This register is only present for stmpe811 */
@@ -86,6 +85,8 @@ static struct stmpe_client_info spi_ci = {
static int __devinit
stmpe_spi_probe(struct spi_device *spi)
{
+ const struct spi_device_id *id = spi_get_device_id(spi);
+
/* don't exceed max specified rate - 1MHz - Limitation of STMPE */
if (spi->max_speed_hz > 1000000) {
dev_dbg(&spi->dev, "f(sample) %d KHz?\n",
@@ -97,7 +98,7 @@ stmpe_spi_probe(struct spi_device *spi)
spi_ci.client = spi;
spi_ci.dev = &spi->dev;
- return stmpe_probe(&spi_ci);
+ return stmpe_probe(&spi_ci, id->driver_data);
}
static int __devexit stmpe_spi_remove(struct spi_device *spi)
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 3ff2edb..a564f91 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -870,7 +870,7 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe)
}
/* Called from client specific probe routines */
-int stmpe_probe(struct stmpe_client_info *ci)
+int stmpe_probe(struct stmpe_client_info *ci, int partnum)
{
struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev);
struct stmpe *stmpe;
@@ -891,11 +891,13 @@ int stmpe_probe(struct stmpe_client_info *ci)
stmpe->pdata = pdata;
stmpe->irq_base = pdata->irq_base;
stmpe->ci = ci;
- stmpe->variant = stmpe_variant_info[stmpe->partnum];
+ stmpe->variant = stmpe_variant_info[partnum];
stmpe->regs = stmpe->variant->regs;
stmpe->num_gpios = stmpe->variant->num_gpios;
+ dev_set_drvdata(stmpe->dev, stmpe);
- ci->init(stmpe);
+ if (ci->init)
+ ci->init(stmpe);
if (pdata->irq_over_gpio) {
ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index 908f482..a73f4c1 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -97,7 +97,7 @@ struct stmpe_client_info {
void (*init)(struct stmpe *stmpe);
};
-int stmpe_probe(struct stmpe_client_info *ci);
+int stmpe_probe(struct stmpe_client_info *ci, int partnum);
int stmpe_remove(struct stmpe *stmpe);
#define STMPE_ICR_LSB_HIGH (1 << 2)
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index babc6b2..5afaf89 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -59,7 +59,6 @@ struct stmpe_client_info;
* @dev: device, mostly for dev_dbg()
* @client: client - i2c or spi
* @ci: client specific information
- * @partnum: part number
* @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_*.
@@ -76,7 +75,6 @@ struct stmpe {
struct device *dev;
void *client;
struct stmpe_client_info *ci;
- enum stmpe_partnum partnum;
struct stmpe_variant_info *variant;
const u8 *regs;
--
1.7.2.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 1/5] mfd/stmpe: Pass partnum as param to stmpe_probe()
2011-11-16 11:26 ` [PATCH 1/5] mfd/stmpe: Pass partnum as param to stmpe_probe() Viresh Kumar
@ 2011-11-16 15:35 ` Rabin Vincent
2011-11-17 3:36 ` Viresh Kumar
0 siblings, 1 reply; 8+ messages in thread
From: Rabin Vincent @ 2011-11-16 15:35 UTC (permalink / raw)
To: Viresh Kumar
Cc: linus.walleij, srinidhi.kasagar, sameo, linux-kernel,
armando.visconti, shiraz.hashim, vipin.kumar, rajeev-dlh.kumar,
deepak.sikri, vipulkumar.samar, amit.virdi, pratyush.anand,
bhupesh.sharma, viresh.linux, bhavna.yadav, vincenzo.frascino,
mirko.gardi, grant.likely
On Wed, Nov 16, 2011 at 16:56, Viresh Kumar <viresh.kumar@st.com> wrote:
> partnum is required during probe to get variant's info. Currently partnum was
> getting set in i2c interface after it is used and is not at all getting set in
> spi interface.
So your previous patch is broken? Please fix it and resend it instead
since it's not merged yet.
>
> This can be passed as param to stmpe_probe, so that it is available early. With
> this, there is no need of i2c interface's init() routine, as it does nothing
> else than calling dev_set_drvdata(). So better remove this routine for i2c.
>
> partnum defined in struct stmpe is of no use now, as it is only used once during
> probe of stmpe, so we can remove it from struct stmpe too.
Not quite; it's used from drivers/input/keyboard/stmpe-keypad.c. Please
preserve this stmpe->partnum, drop your 2/5 patch which exposes variant
externally, and instead use stmpe->partnum in 5/5.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/5] mfd/stmpe: Pass partnum as param to stmpe_probe()
2011-11-16 15:35 ` Rabin Vincent
@ 2011-11-17 3:36 ` Viresh Kumar
0 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2011-11-17 3:36 UTC (permalink / raw)
To: Rabin Vincent
Cc: Linus WALLEIJ, Srinidhi KASAGAR, sameo@linux.intel.com,
linux-kernel@vger.kernel.org, Armando VISCONTI, Shiraz HASHIM,
Vipin KUMAR, Rajeev KUMAR, Deepak SIKRI, Vipul Kumar SAMAR,
Amit VIRDI, Pratyush ANAND, Bhupesh SHARMA,
viresh.linux@gmail.com, Bhavna YADAV, Vincenzo FRASCINO,
Mirko GARDI, grant.likely@secretlab.ca
On 11/16/2011 9:05 PM, Rabin Vincent wrote:
> On Wed, Nov 16, 2011 at 16:56, Viresh Kumar <viresh.kumar@st.com> wrote:
>> partnum is required during probe to get variant's info. Currently partnum was
>> getting set in i2c interface after it is used and is not at all getting set in
>> spi interface.
>
> So your previous patch is broken? Please fix it and resend it instead
> since it's not merged yet.
>
Sure.
>>
>> This can be passed as param to stmpe_probe, so that it is available early. With
>> this, there is no need of i2c interface's init() routine, as it does nothing
>> else than calling dev_set_drvdata(). So better remove this routine for i2c.
>>
>> partnum defined in struct stmpe is of no use now, as it is only used once during
>> probe of stmpe, so we can remove it from struct stmpe too.
>
> Not quite; it's used from drivers/input/keyboard/stmpe-keypad.c. Please
> preserve this stmpe->partnum, drop your 2/5 patch which exposes variant
> externally, and instead use stmpe->partnum in 5/5.
Yes, will do this.
--
viresh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/5] mfd/stmpe: Move struct stmpe_variant_info to linux/mfd/stmpe.h
2011-11-16 11:26 [PATCH 0/5] stmpe: mfd & gpio updates Viresh Kumar
2011-11-16 11:26 ` [PATCH 1/5] mfd/stmpe: Pass partnum as param to stmpe_probe() Viresh Kumar
@ 2011-11-16 11:26 ` Viresh Kumar
2011-11-16 11:26 ` [PATCH 3/5] mfd/stmpe: Add support for stmpe variant 610 Viresh Kumar
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2011-11-16 11:26 UTC (permalink / raw)
To: rabin.vincent, linus.walleij, srinidhi.kasagar
Cc: sameo, linux-kernel, armando.visconti, shiraz.hashim, vipin.kumar,
rajeev-dlh.kumar, deepak.sikri, vipulkumar.samar, amit.virdi,
viresh.kumar, pratyush.anand, bhupesh.sharma, viresh.linux,
bhavna.yadav, vincenzo.frascino, mirko.gardi, grant.likely
From: Pratyush Anand <pratyush.anand@st.com>
Some variants like GPIO of STMPE801 have different register definition. So,
variant ID will be needed by stmpe-gpio.c to distinguish between STMPE801. Move
this struct definition from drivers/mfd/stmpe.h to include/linux/stmpe.h
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
---
drivers/mfd/stmpe.h | 32 --------------------------------
include/linux/mfd/stmpe.h | 33 +++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 32 deletions(-)
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index a73f4c1..7df0bda 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -44,38 +44,6 @@ struct stmpe_variant_block {
};
/**
- * struct stmpe_variant_info - variant-specific information
- * @name: part name
- * @id_val: content of CHIPID register
- * @id_mask: bits valid in CHIPID register for comparison with id_val
- * @num_gpios: number of GPIOS
- * @af_bits: number of bits used to specify the alternate function
- * @regs: variant specific registers.
- * @blocks: list of blocks present on this device
- * @num_blocks: number of blocks present on this device
- * @num_irqs: number of internal IRQs available on this device
- * @enable: callback to enable the specified blocks.
- * Called with the I/O lock held.
- * @get_altfunc: callback to get the alternate function number for the
- * specific block
- * @enable_autosleep: callback to configure autosleep with specified timeout
- */
-struct stmpe_variant_info {
- const char *name;
- u16 id_val;
- u16 id_mask;
- int num_gpios;
- int af_bits;
- const u8 *regs;
- struct stmpe_variant_block *blocks;
- int num_blocks;
- int num_irqs;
- int (*enable)(struct stmpe *stmpe, unsigned int blocks, bool enable);
- int (*get_altfunc)(struct stmpe *stmpe, enum stmpe_block block);
- int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout);
-};
-
-/**
* struct stmpe_client_info - i2c or spi specific routines/info
* @data: client specific data
* @read_byte: read single byte
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 5afaf89..102c06d 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -51,6 +51,7 @@ enum {
struct stmpe_variant_info;
struct stmpe_client_info;
+struct stmpe_variant_block;
/**
* struct stmpe - STMPE MFD structure
@@ -86,6 +87,38 @@ struct stmpe {
struct stmpe_platform_data *pdata;
};
+/**
+ * struct stmpe_variant_info - variant-specific information
+ * @name: part name
+ * @id_val: content of CHIPID register
+ * @id_mask: bits valid in CHIPID register for comparison with id_val
+ * @num_gpios: number of GPIOS
+ * @af_bits: number of bits used to specify the alternate function
+ * @regs: variant specific registers.
+ * @blocks: list of blocks present on this device
+ * @num_blocks: number of blocks present on this device
+ * @num_irqs: number of internal IRQs available on this device
+ * @enable: callback to enable the specified blocks.
+ * Called with the I/O lock held.
+ * @get_altfunc: callback to get the alternate function number for the
+ * specific block
+ * @enable_autosleep: callback to configure autosleep with specified timeout
+ */
+struct stmpe_variant_info {
+ const char *name;
+ u16 id_val;
+ u16 id_mask;
+ int num_gpios;
+ int af_bits;
+ const u8 *regs;
+ struct stmpe_variant_block *blocks;
+ int num_blocks;
+ int num_irqs;
+ int (*enable)(struct stmpe *stmpe, unsigned int blocks, bool enable);
+ int (*get_altfunc)(struct stmpe *stmpe, enum stmpe_block block);
+ int (*enable_autosleep)(struct stmpe *stmpe, int autosleep_timeout);
+};
+
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,
--
1.7.2.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/5] mfd/stmpe: Add support for stmpe variant 610
2011-11-16 11:26 [PATCH 0/5] stmpe: mfd & gpio updates Viresh Kumar
2011-11-16 11:26 ` [PATCH 1/5] mfd/stmpe: Pass partnum as param to stmpe_probe() Viresh Kumar
2011-11-16 11:26 ` [PATCH 2/5] mfd/stmpe: Move struct stmpe_variant_info to linux/mfd/stmpe.h Viresh Kumar
@ 2011-11-16 11:26 ` Viresh Kumar
2011-11-16 11:26 ` [PATCH 4/5] mfd/stmpe: ADD support for stmpe variant 801 Viresh Kumar
2011-11-16 11:26 ` [PATCH 5/5] gpio/gpio-stmpe: " Viresh Kumar
4 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2011-11-16 11:26 UTC (permalink / raw)
To: rabin.vincent, linus.walleij, srinidhi.kasagar
Cc: sameo, linux-kernel, armando.visconti, shiraz.hashim, vipin.kumar,
rajeev-dlh.kumar, deepak.sikri, vipulkumar.samar, amit.virdi,
viresh.kumar, pratyush.anand, bhupesh.sharma, viresh.linux,
bhavna.yadav, vincenzo.frascino, mirko.gardi, grant.likely
STMPE610 is very much like STMPE811, except the number of gpio pins, which is 8
in 811 and 6 in 610. This patch adds support for variant 610. STMPE610 will
share most of the code with STMPE811.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
drivers/mfd/stmpe-i2c.c | 1 +
drivers/mfd/stmpe-spi.c | 1 +
drivers/mfd/stmpe.c | 20 ++++++++++++++++++--
include/linux/mfd/stmpe.h | 1 +
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index 671fd5c..c004319 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -71,6 +71,7 @@ static int __devexit stmpe_i2c_remove(struct i2c_client *i2c)
}
static const struct i2c_device_id stmpe_i2c_id[] = {
+ { "stmpe610", STMPE610 },
{ "stmpe811", STMPE811 },
{ "stmpe1601", STMPE1601 },
{ "stmpe2401", STMPE2401 },
diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c
index 21861d8..25928f6 100644
--- a/drivers/mfd/stmpe-spi.c
+++ b/drivers/mfd/stmpe-spi.c
@@ -109,6 +109,7 @@ static int __devexit stmpe_spi_remove(struct spi_device *spi)
}
static const struct spi_device_id stmpe_spi_id[] = {
+ { "stmpe610", STMPE610 },
{ "stmpe811", STMPE811 },
{ "stmpe1601", STMPE1601 },
{ "stmpe2401", STMPE2401 },
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index a564f91..34046b5 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -321,7 +321,7 @@ static struct mfd_cell stmpe_keypad_cell = {
};
/*
- * Touchscreen (STMPE811)
+ * Touchscreen (STMPE811 or STMPE610)
*/
static struct resource stmpe_ts_resources[] = {
@@ -346,7 +346,7 @@ static struct mfd_cell stmpe_ts_cell = {
};
/*
- * STMPE811
+ * STMPE811 or STMPE610
*/
static const u8 stmpe811_regs[] = {
@@ -417,6 +417,21 @@ static struct stmpe_variant_info stmpe811 = {
.get_altfunc = stmpe811_get_altfunc,
};
+/* Similar to 811, except number of gpios */
+static struct stmpe_variant_info stmpe610 = {
+ .name = "stmpe610",
+ .id_val = 0x0811,
+ .id_mask = 0xffff,
+ .num_gpios = 6,
+ .af_bits = 1,
+ .regs = stmpe811_regs,
+ .blocks = stmpe811_blocks,
+ .num_blocks = ARRAY_SIZE(stmpe811_blocks),
+ .num_irqs = STMPE811_NR_INTERNAL_IRQS,
+ .enable = stmpe811_enable,
+ .get_altfunc = stmpe811_get_altfunc,
+};
+
/*
* STMPE1601
*/
@@ -651,6 +666,7 @@ static struct stmpe_variant_info stmpe2403 = {
};
static struct stmpe_variant_info *stmpe_variant_info[] = {
+ [STMPE610] = &stmpe610,
[STMPE811] = &stmpe811,
[STMPE1601] = &stmpe1601,
[STMPE2401] = &stmpe2401,
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 102c06d..79e4fc4 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -20,6 +20,7 @@ enum stmpe_block {
};
enum stmpe_partnum {
+ STMPE610,
STMPE811,
STMPE1601,
STMPE2401,
--
1.7.2.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 4/5] mfd/stmpe: ADD support for stmpe variant 801
2011-11-16 11:26 [PATCH 0/5] stmpe: mfd & gpio updates Viresh Kumar
` (2 preceding siblings ...)
2011-11-16 11:26 ` [PATCH 3/5] mfd/stmpe: Add support for stmpe variant 610 Viresh Kumar
@ 2011-11-16 11:26 ` Viresh Kumar
2011-11-16 11:26 ` [PATCH 5/5] gpio/gpio-stmpe: " Viresh Kumar
4 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2011-11-16 11:26 UTC (permalink / raw)
To: rabin.vincent, linus.walleij, srinidhi.kasagar
Cc: sameo, linux-kernel, armando.visconti, shiraz.hashim, vipin.kumar,
rajeev-dlh.kumar, deepak.sikri, vipulkumar.samar, amit.virdi,
viresh.kumar, pratyush.anand, bhupesh.sharma, viresh.linux,
bhavna.yadav, vincenzo.frascino, mirko.gardi, grant.likely
STMPE801 is a GPIO expander. Registers for 801 are much different from other
variants. This patch adds support for STMPE801 in stmpe mfd driver.
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
drivers/mfd/stmpe-i2c.c | 1 +
drivers/mfd/stmpe-spi.c | 1 +
drivers/mfd/stmpe.c | 97 +++++++++++++++++++++++++++++++++++++++------
drivers/mfd/stmpe.h | 19 +++++++++
include/linux/mfd/stmpe.h | 1 +
5 files changed, 106 insertions(+), 13 deletions(-)
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
index c004319..278da8a 100644
--- a/drivers/mfd/stmpe-i2c.c
+++ b/drivers/mfd/stmpe-i2c.c
@@ -72,6 +72,7 @@ static int __devexit stmpe_i2c_remove(struct i2c_client *i2c)
static const struct i2c_device_id stmpe_i2c_id[] = {
{ "stmpe610", STMPE610 },
+ { "stmpe801", STMPE801 },
{ "stmpe811", STMPE811 },
{ "stmpe1601", STMPE1601 },
{ "stmpe2401", STMPE2401 },
diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c
index 25928f6..ac7ac99 100644
--- a/drivers/mfd/stmpe-spi.c
+++ b/drivers/mfd/stmpe-spi.c
@@ -110,6 +110,7 @@ static int __devexit stmpe_spi_remove(struct spi_device *spi)
static const struct spi_device_id stmpe_spi_id[] = {
{ "stmpe610", STMPE610 },
+ { "stmpe801", STMPE801 },
{ "stmpe811", STMPE811 },
{ "stmpe1601", STMPE1601 },
{ "stmpe2401", STMPE2401 },
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 34046b5..ad241fc 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -241,12 +241,14 @@ int stmpe_set_altfunc(struct stmpe *stmpe, u32 pins, enum stmpe_block block)
u8 regaddr = stmpe->regs[STMPE_IDX_GPAFR_U_MSB];
int af_bits = variant->af_bits;
int numregs = DIV_ROUND_UP(stmpe->num_gpios * af_bits, 8);
- int afperreg = 8 / af_bits;
int mask = (1 << af_bits) - 1;
u8 regs[numregs];
- int af;
- int ret;
+ int af, afperreg, ret;
+
+ if (!variant->get_altfunc)
+ return 0;
+ afperreg = 8 / af_bits;
mutex_lock(&stmpe->lock);
ret = __stmpe_enable(stmpe, STMPE_BLOCK_GPIO);
@@ -321,6 +323,50 @@ static struct mfd_cell stmpe_keypad_cell = {
};
/*
+ * STMPE801
+ */
+static const u8 stmpe801_regs[] = {
+ [STMPE_IDX_CHIP_ID] = STMPE801_REG_CHIP_ID,
+ [STMPE_IDX_ICR_LSB] = STMPE801_REG_SYS_CTRL,
+ [STMPE_IDX_GPMR_LSB] = STMPE801_REG_GPIO_MP_STA,
+ [STMPE_IDX_GPSR_LSB] = STMPE801_REG_GPIO_SET_PIN,
+ [STMPE_IDX_GPCR_LSB] = STMPE801_REG_GPIO_SET_PIN,
+ [STMPE_IDX_GPDR_LSB] = STMPE801_REG_GPIO_DIR,
+ [STMPE_IDX_IEGPIOR_LSB] = STMPE801_REG_GPIO_INT_EN,
+ [STMPE_IDX_ISGPIOR_MSB] = STMPE801_REG_GPIO_INT_STA,
+
+};
+
+static struct stmpe_variant_block stmpe801_blocks[] = {
+ {
+ .cell = &stmpe_gpio_cell,
+ .irq = 0,
+ .block = STMPE_BLOCK_GPIO,
+ },
+};
+
+static int stmpe801_enable(struct stmpe *stmpe, unsigned int blocks,
+ bool enable)
+{
+ if (blocks & STMPE_BLOCK_GPIO)
+ return 0;
+ else
+ return -EINVAL;
+}
+
+static struct stmpe_variant_info stmpe801 = {
+ .name = "stmpe801",
+ .id_val = STMPE801_ID,
+ .id_mask = 0xffff,
+ .num_gpios = 8,
+ .regs = stmpe801_regs,
+ .blocks = stmpe801_blocks,
+ .num_blocks = ARRAY_SIZE(stmpe801_blocks),
+ .num_irqs = STMPE801_NR_INTERNAL_IRQS,
+ .enable = stmpe801_enable,
+};
+
+/*
* Touchscreen (STMPE811 or STMPE610)
*/
@@ -667,6 +713,7 @@ static struct stmpe_variant_info stmpe2403 = {
static struct stmpe_variant_info *stmpe_variant_info[] = {
[STMPE610] = &stmpe610,
+ [STMPE801] = &stmpe801,
[STMPE811] = &stmpe811,
[STMPE1601] = &stmpe1601,
[STMPE2401] = &stmpe2401,
@@ -683,6 +730,11 @@ static irqreturn_t stmpe_irq(int irq, void *data)
int ret;
int i;
+ if (variant->id_val == STMPE801_ID) {
+ handle_nested_irq(stmpe->irq_base);
+ return IRQ_HANDLED;
+ }
+
ret = stmpe_block_read(stmpe, israddr, num, isr);
if (ret < 0)
return IRQ_NONE;
@@ -769,14 +821,17 @@ static struct irq_chip stmpe_irq_chip = {
static int __devinit stmpe_irq_init(struct stmpe *stmpe)
{
+ struct irq_chip *chip = NULL;
int num_irqs = stmpe->variant->num_irqs;
int base = stmpe->irq_base;
int irq;
+ if (stmpe->variant->id_val != STMPE801_ID)
+ chip = &stmpe_irq_chip;
+
for (irq = base; irq < base + num_irqs; irq++) {
irq_set_chip_data(irq, stmpe);
- irq_set_chip_and_handler(irq, &stmpe_irq_chip,
- handle_edge_irq);
+ irq_set_chip_and_handler(irq, chip, handle_edge_irq);
irq_set_nested_thread(irq, 1);
#ifdef CONFIG_ARM
set_irq_flags(irq, IRQF_VALID);
@@ -808,7 +863,7 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe)
unsigned int irq_trigger = stmpe->pdata->irq_trigger;
int autosleep_timeout = stmpe->pdata->autosleep_timeout;
struct stmpe_variant_info *variant = stmpe->variant;
- u8 icr = STMPE_ICR_LSB_GIM;
+ u8 icr;
unsigned int id;
u8 data[2];
int ret;
@@ -831,16 +886,32 @@ static int __devinit stmpe_chip_init(struct stmpe *stmpe)
if (ret)
return ret;
- if (irq_trigger == IRQF_TRIGGER_FALLING ||
- irq_trigger == IRQF_TRIGGER_RISING)
- icr |= STMPE_ICR_LSB_EDGE;
+ if (id == STMPE801_ID)
+ icr = STMPE801_REG_SYS_CTRL_INT_EN;
+ else
+ icr = STMPE_ICR_LSB_GIM;
+
+ /* STMPE801 doesn't support Edge interrupts */
+ if (id != STMPE801_ID) {
+ if (irq_trigger == IRQF_TRIGGER_FALLING ||
+ irq_trigger == IRQF_TRIGGER_RISING)
+ icr |= STMPE_ICR_LSB_EDGE;
+ }
if (irq_trigger == IRQF_TRIGGER_RISING ||
- irq_trigger == IRQF_TRIGGER_HIGH)
- icr |= STMPE_ICR_LSB_HIGH;
+ irq_trigger == IRQF_TRIGGER_HIGH) {
+ if (id == STMPE801_ID)
+ icr |= STMPE801_REG_SYS_CTRL_INT_HI;
+ else
+ icr |= STMPE_ICR_LSB_HIGH;
+ }
- if (stmpe->pdata->irq_invert_polarity)
- icr ^= STMPE_ICR_LSB_HIGH;
+ if (stmpe->pdata->irq_invert_polarity) {
+ if (id == STMPE801_ID)
+ icr ^= STMPE801_REG_SYS_CTRL_INT_HI;
+ else
+ icr ^= STMPE_ICR_LSB_HIGH;
+ }
if (stmpe->pdata->autosleep) {
ret = stmpe_autosleep(stmpe, autosleep_timeout);
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index 7df0bda..476d1bb 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -73,6 +73,25 @@ int stmpe_remove(struct stmpe *stmpe);
#define STMPE_ICR_LSB_GIM (1 << 0)
/*
+ * STMPE801
+ */
+#define STMPE801_ID 0x0108
+#define STMPE801_NR_INTERNAL_IRQS 1
+
+#define STMPE801_REG_CHIP_ID 0x00
+#define STMPE801_REG_VERSION_ID 0x02
+#define STMPE801_REG_SYS_CTRL 0x04
+#define STMPE801_REG_GPIO_INT_EN 0x08
+#define STMPE801_REG_GPIO_INT_STA 0x09
+#define STMPE801_REG_GPIO_MP_STA 0x10
+#define STMPE801_REG_GPIO_SET_PIN 0x11
+#define STMPE801_REG_GPIO_DIR 0x12
+
+#define STMPE801_REG_SYS_CTRL_RESET (1 << 7)
+#define STMPE801_REG_SYS_CTRL_INT_EN (1 << 2)
+#define STMPE801_REG_SYS_CTRL_INT_HI (1 << 0)
+
+/*
* STMPE811
*/
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 79e4fc4..17f3de8 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -21,6 +21,7 @@ enum stmpe_block {
enum stmpe_partnum {
STMPE610,
+ STMPE801,
STMPE811,
STMPE1601,
STMPE2401,
--
1.7.2.2
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
2011-11-16 11:26 [PATCH 0/5] stmpe: mfd & gpio updates Viresh Kumar
` (3 preceding siblings ...)
2011-11-16 11:26 ` [PATCH 4/5] mfd/stmpe: ADD support for stmpe variant 801 Viresh Kumar
@ 2011-11-16 11:26 ` Viresh Kumar
4 siblings, 0 replies; 8+ messages in thread
From: Viresh Kumar @ 2011-11-16 11:26 UTC (permalink / raw)
To: rabin.vincent, linus.walleij, srinidhi.kasagar
Cc: sameo, linux-kernel, armando.visconti, shiraz.hashim, vipin.kumar,
rajeev-dlh.kumar, deepak.sikri, vipulkumar.samar, amit.virdi,
viresh.kumar, pratyush.anand, bhupesh.sharma, viresh.linux,
bhavna.yadav, vincenzo.frascino, mirko.gardi, grant.likely
STMPE801 is a GPIO expander. GPIO registers for 801 are slightly different from other
variants. This patch adds support for STMPE801 in stmpe gpio driver.
Signed-off-by: Bhupesh Sharma <bhupesh.sharma@st.com>
Signed-off-by: Pratyush Anand <pratyush.anand@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
---
drivers/gpio/gpio-stmpe.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 4c980b5..cba57f6 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -65,7 +65,15 @@ static void stmpe_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
u8 reg = stmpe->regs[which] - (offset / 8);
u8 mask = 1 << (offset % 8);
- stmpe_reg_write(stmpe, reg, mask);
+ /*
+ * Some variants have single register for gpio set/clear functionality.
+ * For them we need to write 0 to clear and 1 to set.
+ */
+ if (!val && (stmpe->regs[STMPE_IDX_GPSR_LSB] ==
+ stmpe->regs[STMPE_IDX_GPCR_LSB]))
+ stmpe_set_bits(stmpe, reg, mask, ~mask);
+ else
+ stmpe_set_bits(stmpe, reg, mask, mask);
}
static int stmpe_gpio_direction_output(struct gpio_chip *chip,
@@ -125,10 +133,19 @@ static struct gpio_chip template_chip = {
static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type)
{
struct stmpe_gpio *stmpe_gpio = irq_data_get_irq_chip_data(d);
+ struct stmpe *stmpe = stmpe_gpio->stmpe;
int offset = d->irq - stmpe_gpio->irq_base;
int regoffset = offset / 8;
int mask = 1 << (offset % 8);
+ /* STMPE801 doesn't have RE and FE registers */
+ if (stmpe->variant->id_val == STMPE801) {
+ if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
+ return 0;
+ else
+ return -EINVAL;
+ }
+
if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
return -EINVAL;
@@ -165,6 +182,11 @@ static void stmpe_gpio_irq_sync_unlock(struct irq_data *d)
int i, j;
for (i = 0; i < CACHE_NR_REGS; i++) {
+ /* STMPE801 doesn't have RE and FE registers */
+ if ((stmpe->variant->id_val == STMPE801) &&
+ (i != REG_IE))
+ continue;
+
for (j = 0; j < num_banks; j++) {
u8 old = stmpe_gpio->oldregs[i][j];
u8 new = stmpe_gpio->regs[i][j];
@@ -241,8 +263,11 @@ static irqreturn_t stmpe_gpio_irq(int irq, void *dev)
}
stmpe_reg_write(stmpe, statmsbreg + i, status[i]);
- stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB] + i,
- status[i]);
+
+ /* Edge detect register is not present on 801 */
+ if (stmpe->variant->id_val != STMPE801)
+ stmpe_reg_write(stmpe, stmpe->regs[STMPE_IDX_GPEDR_MSB]
+ + i, status[i]);
}
return IRQ_HANDLED;
--
1.7.2.2
^ permalink raw reply related [flat|nested] 8+ messages in thread