linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/5] stmpe: mfd & gpio updates
@ 2011-11-17  5:32 Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 1/5] mfd/stmpe: separate out controller and interface specific code Viresh Kumar
                   ` (5 more replies)
  0 siblings, 6 replies; 17+ messages in thread
From: Viresh Kumar @ 2011-11-17  5:32 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

Changes since V1:
- V2 of this patchset also includes, earlier sent patches, Acked-by Linus:
	 mfd/stmpe: separate out controller and interface specific code
	 mfd/stmpe: Add support for SPI interface
- Issues with above patches are also fixed
- MODULE_DESCRIPTION and MODULE_AUTHOR are fixed in stmpe-spi and stmpe-i2c
  files
- gpio-stmpe patch is update to use stmpe->partnum instead of
  stmpe->variant->id_val
- Patch "mfd/stmpe: Move struct stmpe_variant_info to linux/mfd/stmpe.h" is
  dropped as it is no longer required.

Viresh Kumar (5):
  mfd/stmpe: separate out controller and interface specific code
  mfd/stmpe: Add support for SPI interface
  mfd/stmpe: Add support for stmpe variant 610
  mfd/stmpe: ADD support for stmpe variant 801
  gpio/gpio-stmpe: ADD support for stmpe variant 801

 drivers/gpio/gpio-stmpe.c |   31 +++++-
 drivers/mfd/Kconfig       |   19 ++++-
 drivers/mfd/Makefile      |    2 +
 drivers/mfd/stmpe-i2c.c   |  109 ++++++++++++++++++++
 drivers/mfd/stmpe-spi.c   |  150 +++++++++++++++++++++++++++
 drivers/mfd/stmpe.c       |  250 ++++++++++++++++++++++++++-------------------
 drivers/mfd/stmpe.h       |   53 ++++++++++
 include/linux/mfd/stmpe.h |    9 ++-
 8 files changed, 512 insertions(+), 111 deletions(-)
 create mode 100644 drivers/mfd/stmpe-i2c.c
 create mode 100644 drivers/mfd/stmpe-spi.c

-- 
1.7.2.2


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH V2 1/5] mfd/stmpe: separate out controller and interface specific code
  2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
@ 2011-11-17  5:32 ` Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 2/5] mfd/stmpe: Add support for SPI interface Viresh Kumar
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Viresh Kumar @ 2011-11-17  5:32 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

Few STMPE controller can have register interface over SPI or I2C. Current
implementation only supports I2C and all code is present in a single file
stmpe.c. It would be better to separate out I2C interface specific code from
controller specific code. Later SPI specific code can be added in a separate
file.

This patch separates out I2C and controller specific code into separate files,
making stmpe.c independent of I2C.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/mfd/Kconfig       |   11 ++++
 drivers/mfd/Makefile      |    1 +
 drivers/mfd/stmpe-i2c.c   |  107 ++++++++++++++++++++++++++++++++++++
 drivers/mfd/stmpe.c       |  133 +++++++++++++++------------------------------
 drivers/mfd/stmpe.h       |   33 +++++++++++
 include/linux/mfd/stmpe.h |    7 ++-
 6 files changed, 200 insertions(+), 92 deletions(-)
 create mode 100644 drivers/mfd/stmpe-i2c.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index a67adcb..2f8561a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -293,6 +293,17 @@ config MFD_STMPE
 		Keypad: stmpe-keypad
 		Touchscreen: stmpe-ts
 
+menu "STMPE Interface Drivers"
+depends on MFD_STMPE
+
+config STMPE_I2C
+	bool "STMPE I2C Inteface"
+	depends on I2C
+	default y
+	help
+	  This is used to enable I2C interface of STMPE
+endmenu
+
 config MFD_TC3589X
 	bool "Support Toshiba TC35892 and variants"
 	depends on I2C=y && GENERIC_HARDIRQS
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index c580203..24ee9bb 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_SSP)	+= ti-ssp.o
 
 obj-$(CONFIG_MFD_STMPE)		+= stmpe.o
+obj-$(CONFIG_STMPE_I2C)		+= stmpe-i2c.o
 obj-$(CONFIG_MFD_TC3589X)	+= tc3589x.o
 obj-$(CONFIG_MFD_T7L66XB)	+= t7l66xb.o tmio_core.o
 obj-$(CONFIG_MFD_TC6387XB)	+= tc6387xb.o tmio_core.o
diff --git a/drivers/mfd/stmpe-i2c.c b/drivers/mfd/stmpe-i2c.c
new file mode 100644
index 0000000..0a43659
--- /dev/null
+++ b/drivers/mfd/stmpe-i2c.c
@@ -0,0 +1,107 @@
+/*
+ * ST Microelectronics MFD: stmpe's i2c client specific driver
+ *
+ * Copyright (C) ST-Ericsson SA 2010
+ * Copyright (C) ST Microelectronics SA 2011
+ *
+ * License Terms: GNU General Public License, version 2
+ * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
+ * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics
+ */
+
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include "stmpe.h"
+
+static int i2c_reg_read(struct stmpe *stmpe, u8 reg)
+{
+	struct i2c_client *i2c = stmpe->client;
+
+	return i2c_smbus_read_byte_data(i2c, reg);
+}
+
+static int i2c_reg_write(struct stmpe *stmpe, u8 reg, u8 val)
+{
+	struct i2c_client *i2c = stmpe->client;
+
+	return i2c_smbus_write_byte_data(i2c, reg, val);
+}
+
+static int i2c_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values)
+{
+	struct i2c_client *i2c = stmpe->client;
+
+	return i2c_smbus_read_i2c_block_data(i2c, reg, length, values);
+}
+
+static int i2c_block_write(struct stmpe *stmpe, u8 reg, u8 length,
+		const u8 *values)
+{
+	struct i2c_client *i2c = stmpe->client;
+
+	return i2c_smbus_write_i2c_block_data(i2c, reg, length, values);
+}
+
+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,
+};
+
+static int __devinit
+stmpe_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
+{
+	i2c_ci.data = (void *)id;
+	i2c_ci.irq = i2c->irq;
+	i2c_ci.client = i2c;
+	i2c_ci.dev = &i2c->dev;
+
+	return stmpe_probe(&i2c_ci, id->driver_data);
+}
+
+static int __devexit stmpe_i2c_remove(struct i2c_client *i2c)
+{
+	struct stmpe *stmpe = dev_get_drvdata(&i2c->dev);
+
+	return stmpe_remove(stmpe);
+}
+
+static const struct i2c_device_id stmpe_i2c_id[] = {
+	{ "stmpe811", STMPE811 },
+	{ "stmpe1601", STMPE1601 },
+	{ "stmpe2401", STMPE2401 },
+	{ "stmpe2403", STMPE2403 },
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, stmpe_id);
+
+static struct i2c_driver stmpe_i2c_driver = {
+	.driver.name	= "stmpe-i2c",
+	.driver.owner	= THIS_MODULE,
+#ifdef CONFIG_PM
+	.driver.pm	= &stmpe_dev_pm_ops,
+#endif
+	.probe		= stmpe_i2c_probe,
+	.remove		= __devexit_p(stmpe_i2c_remove),
+	.id_table	= stmpe_i2c_id,
+};
+
+static int __init stmpe_init(void)
+{
+	return i2c_add_driver(&stmpe_i2c_driver);
+}
+subsys_initcall(stmpe_init);
+
+static void __exit stmpe_exit(void)
+{
+	i2c_del_driver(&stmpe_i2c_driver);
+}
+module_exit(stmpe_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("STMPE MFD I2C Interface Driver");
+MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index 39efa62..83bacde 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -1,4 +1,6 @@
 /*
+ * ST Microelectronics MFD: stmpe's driver
+ *
  * Copyright (C) ST-Ericsson SA 2010
  *
  * License Terms: GNU General Public License, version 2
@@ -7,13 +9,11 @@
 
 #include <linux/gpio.h>
 #include <linux/kernel.h>
-#include <linux/module.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
+#include <linux/pm.h>
 #include <linux/slab.h>
-#include <linux/i2c.h>
 #include <linux/mfd/core.h>
-#include <linux/mfd/stmpe.h>
 #include "stmpe.h"
 
 static int __stmpe_enable(struct stmpe *stmpe, unsigned int blocks)
@@ -30,10 +30,9 @@ static int __stmpe_reg_read(struct stmpe *stmpe, u8 reg)
 {
 	int ret;
 
-	ret = i2c_smbus_read_byte_data(stmpe->i2c, reg);
+	ret = stmpe->ci->read_byte(stmpe, reg);
 	if (ret < 0)
-		dev_err(stmpe->dev, "failed to read reg %#x: %d\n",
-			reg, ret);
+		dev_err(stmpe->dev, "failed to read reg %#x: %d\n", reg, ret);
 
 	dev_vdbg(stmpe->dev, "rd: reg %#x => data %#x\n", reg, ret);
 
@@ -46,10 +45,9 @@ static int __stmpe_reg_write(struct stmpe *stmpe, u8 reg, u8 val)
 
 	dev_vdbg(stmpe->dev, "wr: reg %#x <= %#x\n", reg, val);
 
-	ret = i2c_smbus_write_byte_data(stmpe->i2c, reg, val);
+	ret = stmpe->ci->write_byte(stmpe, reg, val);
 	if (ret < 0)
-		dev_err(stmpe->dev, "failed to write reg %#x: %d\n",
-			reg, ret);
+		dev_err(stmpe->dev, "failed to write reg %#x: %d\n", reg, ret);
 
 	return ret;
 }
@@ -73,10 +71,9 @@ static int __stmpe_block_read(struct stmpe *stmpe, u8 reg, u8 length,
 {
 	int ret;
 
-	ret = i2c_smbus_read_i2c_block_data(stmpe->i2c, reg, length, values);
+	ret = stmpe->ci->read_block(stmpe, reg, length, values);
 	if (ret < 0)
-		dev_err(stmpe->dev, "failed to read regs %#x: %d\n",
-			reg, ret);
+		dev_err(stmpe->dev, "failed to read regs %#x: %d\n", reg, ret);
 
 	dev_vdbg(stmpe->dev, "rd: reg %#x (%d) => ret %#x\n", reg, length, ret);
 	stmpe_dump_bytes("stmpe rd: ", values, length);
@@ -92,11 +89,9 @@ static int __stmpe_block_write(struct stmpe *stmpe, u8 reg, u8 length,
 	dev_vdbg(stmpe->dev, "wr: regs %#x (%d)\n", reg, length);
 	stmpe_dump_bytes("stmpe wr: ", values, length);
 
-	ret = i2c_smbus_write_i2c_block_data(stmpe->i2c, reg, length,
-					     values);
+	ret = stmpe->ci->write_block(stmpe, reg, length, values);
 	if (ret < 0)
-		dev_err(stmpe->dev, "failed to write regs %#x: %d\n",
-			reg, ret);
+		dev_err(stmpe->dev, "failed to write regs %#x: %d\n", reg, ret);
 
 	return ret;
 }
@@ -874,34 +869,10 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe)
 	return ret;
 }
 
-#ifdef CONFIG_PM
-static int stmpe_suspend(struct device *dev)
-{
-	struct i2c_client *i2c = to_i2c_client(dev);
-	struct stmpe *stmpe = i2c_get_clientdata(i2c);
-
-	if (device_may_wakeup(&i2c->dev))
-		enable_irq_wake(stmpe->irq);
-
-	return 0;
-}
-
-static int stmpe_resume(struct device *dev)
+/* Called from client specific probe routines */
+int stmpe_probe(struct stmpe_client_info *ci, int partnum)
 {
-	struct i2c_client *i2c = to_i2c_client(dev);
-	struct stmpe *stmpe = i2c_get_clientdata(i2c);
-
-	if (device_may_wakeup(&i2c->dev))
-		disable_irq_wake(stmpe->irq);
-
-	return 0;
-}
-#endif
-
-static int __devinit stmpe_probe(struct i2c_client *i2c,
-				 const struct i2c_device_id *id)
-{
-	struct stmpe_platform_data *pdata = i2c->dev.platform_data;
+	struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev);
 	struct stmpe *stmpe;
 	int ret;
 
@@ -915,18 +886,19 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
 	mutex_init(&stmpe->irq_lock);
 	mutex_init(&stmpe->lock);
 
-	stmpe->dev = &i2c->dev;
-	stmpe->i2c = i2c;
-
+	stmpe->dev = ci->dev;
+	stmpe->client = ci->client;
 	stmpe->pdata = pdata;
 	stmpe->irq_base = pdata->irq_base;
-
-	stmpe->partnum = id->driver_data;
-	stmpe->variant = stmpe_variant_info[stmpe->partnum];
+	stmpe->ci = ci;
+	stmpe->partnum = 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);
 
-	i2c_set_clientdata(i2c, stmpe);
+	if (ci->init)
+		ci->init(stmpe);
 
 	if (pdata->irq_over_gpio) {
 		ret = gpio_request_one(pdata->irq_gpio, GPIOF_DIR_IN, "stmpe");
@@ -938,7 +910,7 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
 
 		stmpe->irq = gpio_to_irq(pdata->irq_gpio);
 	} else {
-		stmpe->irq = i2c->irq;
+		stmpe->irq = ci->irq;
 	}
 
 	ret = stmpe_chip_init(stmpe);
@@ -950,8 +922,7 @@ static int __devinit stmpe_probe(struct i2c_client *i2c,
 		goto free_gpio;
 
 	ret = request_threaded_irq(stmpe->irq, NULL, stmpe_irq,
-				   pdata->irq_trigger | IRQF_ONESHOT,
-				   "stmpe", stmpe);
+			pdata->irq_trigger | IRQF_ONESHOT, "stmpe", stmpe);
 	if (ret) {
 		dev_err(stmpe->dev, "failed to request IRQ: %d\n", ret);
 		goto out_removeirq;
@@ -978,10 +949,8 @@ out_free:
 	return ret;
 }
 
-static int __devexit stmpe_remove(struct i2c_client *client)
+int stmpe_remove(struct stmpe *stmpe)
 {
-	struct stmpe *stmpe = i2c_get_clientdata(client);
-
 	mfd_remove_devices(stmpe->dev);
 
 	free_irq(stmpe->irq, stmpe);
@@ -995,45 +964,29 @@ static int __devexit stmpe_remove(struct i2c_client *client)
 	return 0;
 }
 
-static const struct i2c_device_id stmpe_id[] = {
-	{ "stmpe811", STMPE811 },
-	{ "stmpe1601", STMPE1601 },
-	{ "stmpe2401", STMPE2401 },
-	{ "stmpe2403", STMPE2403 },
-	{ }
-};
-MODULE_DEVICE_TABLE(i2c, stmpe_id);
-
 #ifdef CONFIG_PM
-static const struct dev_pm_ops stmpe_dev_pm_ops = {
-	.suspend	= stmpe_suspend,
-	.resume		= stmpe_resume,
-};
-#endif
+static int stmpe_suspend(struct device *dev)
+{
+	struct stmpe *stmpe = dev_get_drvdata(dev);
 
-static struct i2c_driver stmpe_driver = {
-	.driver.name	= "stmpe",
-	.driver.owner	= THIS_MODULE,
-#ifdef CONFIG_PM
-	.driver.pm	= &stmpe_dev_pm_ops,
-#endif
-	.probe		= stmpe_probe,
-	.remove		= __devexit_p(stmpe_remove),
-	.id_table	= stmpe_id,
-};
+	if (device_may_wakeup(dev))
+		enable_irq_wake(stmpe->irq);
 
-static int __init stmpe_init(void)
-{
-	return i2c_add_driver(&stmpe_driver);
+	return 0;
 }
-subsys_initcall(stmpe_init);
 
-static void __exit stmpe_exit(void)
+static int stmpe_resume(struct device *dev)
 {
-	i2c_del_driver(&stmpe_driver);
+	struct stmpe *stmpe = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(stmpe->irq);
+
+	return 0;
 }
-module_exit(stmpe_exit);
 
-MODULE_LICENSE("GPL v2");
-MODULE_DESCRIPTION("STMPE MFD core driver");
-MODULE_AUTHOR("Rabin Vincent <rabin.vincent@stericsson.com>");
+const struct dev_pm_ops stmpe_dev_pm_ops = {
+	.suspend	= stmpe_suspend,
+	.resume		= stmpe_resume,
+};
+#endif
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index e4ee3895..18d89a6 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -8,6 +8,14 @@
 #ifndef __STMPE_H
 #define __STMPE_H
 
+#include <linux/device.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/stmpe.h>
+#include <linux/printk.h>
+#include <linux/types.h>
+
+extern const struct dev_pm_ops stmpe_dev_pm_ops;
+
 #ifdef STMPE_DUMP_BYTES
 static inline void stmpe_dump_bytes(const char *str, const void *buf,
 				    size_t len)
@@ -67,6 +75,31 @@ struct stmpe_variant_info {
 	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
+ * @write_byte: write single byte
+ * @read_block: read block or multiple bytes
+ * @write_block: write block or multiple bytes
+ * @init: client init routine, called during probe
+ */
+struct stmpe_client_info {
+	void *data;
+	int irq;
+	void *client;
+	struct device *dev;
+	int (*read_byte)(struct stmpe *stmpe, u8 reg);
+	int (*write_byte)(struct stmpe *stmpe, u8 reg, u8 val);
+	int (*read_block)(struct stmpe *stmpe, u8 reg, u8 len, u8 *values);
+	int (*write_block)(struct stmpe *stmpe, u8 reg, u8 len,
+			const u8 *values);
+	void (*init)(struct stmpe *stmpe);
+};
+
+int stmpe_probe(struct stmpe_client_info *ci, int partnum);
+int stmpe_remove(struct stmpe *stmpe);
+
 #define STMPE_ICR_LSB_HIGH	(1 << 2)
 #define STMPE_ICR_LSB_EDGE	(1 << 1)
 #define STMPE_ICR_LSB_GIM	(1 << 0)
diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h
index 270d661..babc6b2 100644
--- a/include/linux/mfd/stmpe.h
+++ b/include/linux/mfd/stmpe.h
@@ -50,13 +50,15 @@ enum {
 
 
 struct stmpe_variant_info;
+struct stmpe_client_info;
 
 /**
  * struct stmpe - STMPE MFD structure
  * @lock: lock protecting I/O operations
  * @irq_lock: IRQ bus lock
  * @dev: device, mostly for dev_dbg()
- * @i2c: i2c client
+ * @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
@@ -72,7 +74,8 @@ struct stmpe {
 	struct mutex lock;
 	struct mutex irq_lock;
 	struct device *dev;
-	struct i2c_client *i2c;
+	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] 17+ messages in thread

* [PATCH V2 2/5] mfd/stmpe: Add support for SPI interface
  2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 1/5] mfd/stmpe: separate out controller and interface specific code Viresh Kumar
@ 2011-11-17  5:32 ` Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 3/5] mfd/stmpe: Add support for stmpe variant 610 Viresh Kumar
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 17+ messages in thread
From: Viresh Kumar @ 2011-11-17  5:32 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

Few STMPE controller can have register interface over SPI or I2C. Current
implementation only supports I2C.

This patch adds support for SPI interface for accessing STMPE's address space.

Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/mfd/Kconfig     |    8 ++-
 drivers/mfd/Makefile    |    1 +
 drivers/mfd/stmpe-spi.c |  148 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/mfd/stmpe.h     |    1 +
 4 files changed, 157 insertions(+), 1 deletions(-)
 create mode 100644 drivers/mfd/stmpe-spi.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2f8561a..ebfb296 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -272,7 +272,7 @@ config TWL6040_CORE
 
 config MFD_STMPE
 	bool "Support STMicroelectronics STMPE"
-	depends on I2C=y && GENERIC_HARDIRQS
+	depends on (I2C=y || SPI_MASTER=y) && GENERIC_HARDIRQS
 	select MFD_CORE
 	help
 	  Support for the STMPE family of I/O Expanders from
@@ -302,6 +302,12 @@ config STMPE_I2C
 	default y
 	help
 	  This is used to enable I2C interface of STMPE
+
+config STMPE_SPI
+	bool "STMPE SPI Inteface"
+	depends on SPI_MASTER
+	help
+	  This is used to enable SPI interface of STMPE
 endmenu
 
 config MFD_TC3589X
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 24ee9bb..eac1e9f 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_MFD_TI_SSP)	+= ti-ssp.o
 
 obj-$(CONFIG_MFD_STMPE)		+= stmpe.o
 obj-$(CONFIG_STMPE_I2C)		+= stmpe-i2c.o
+obj-$(CONFIG_STMPE_SPI)		+= stmpe-spi.o
 obj-$(CONFIG_MFD_TC3589X)	+= tc3589x.o
 obj-$(CONFIG_MFD_T7L66XB)	+= t7l66xb.o tmio_core.o
 obj-$(CONFIG_MFD_TC6387XB)	+= tc6387xb.o tmio_core.o
diff --git a/drivers/mfd/stmpe-spi.c b/drivers/mfd/stmpe-spi.c
new file mode 100644
index 0000000..53efce4
--- /dev/null
+++ b/drivers/mfd/stmpe-spi.c
@@ -0,0 +1,148 @@
+/*
+ * ST Microelectronics MFD: stmpe's spi client specific driver
+ *
+ * Copyright (C) ST Microelectronics SA 2011
+ *
+ * License Terms: GNU General Public License, version 2
+ * Author: Viresh Kumar <viresh.kumar@st.com> for ST Microelectronics
+ */
+
+#include <linux/spi/spi.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/types.h>
+#include "stmpe.h"
+
+#define READ_CMD	(1 << 7)
+
+static int spi_reg_read(struct stmpe *stmpe, u8 reg)
+{
+	struct spi_device *spi = stmpe->client;
+	int status = spi_w8r16(spi, reg | READ_CMD);
+
+	return (status < 0) ? status : status >> 8;
+}
+
+static int spi_reg_write(struct stmpe *stmpe, u8 reg, u8 val)
+{
+	struct spi_device *spi = stmpe->client;
+	u16 cmd = (val << 8) | reg;
+
+	return spi_write(spi, (const u8 *)&cmd, 2);
+}
+
+static int spi_block_read(struct stmpe *stmpe, u8 reg, u8 length, u8 *values)
+{
+	int ret, i;
+
+	for (i = 0; i < length; i++) {
+		ret = spi_reg_read(stmpe, reg + i);
+		if (ret < 0)
+			return ret;
+		*(values + i) = ret;
+	}
+
+	return 0;
+}
+
+static int spi_block_write(struct stmpe *stmpe, u8 reg, u8 length,
+		const u8 *values)
+{
+	int ret = 0, i;
+
+	for (i = length; i > 0; i--, reg++) {
+		ret = spi_reg_write(stmpe, reg, *(values + i - 1));
+		if (ret < 0)
+			return ret;
+	}
+
+	return ret;
+}
+
+static void spi_init(struct stmpe *stmpe)
+{
+	struct spi_device *spi = stmpe->client;
+
+	spi->bits_per_word = 8;
+
+	/* This register is only present for stmpe811 */
+	if (stmpe->variant->id_val == 0x0811)
+		spi_reg_write(stmpe, STMPE811_REG_SPI_CFG, spi->mode);
+
+	if (spi_setup(spi) < 0)
+		dev_dbg(&spi->dev, "spi_setup failed\n");
+}
+
+static struct stmpe_client_info spi_ci = {
+	.read_byte = spi_reg_read,
+	.write_byte = spi_reg_write,
+	.read_block = spi_block_read,
+	.write_block = spi_block_write,
+	.init = spi_init,
+};
+
+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",
+				(spi->max_speed_hz/1000));
+		return -EINVAL;
+	}
+
+	spi_ci.irq = spi->irq;
+	spi_ci.client = spi;
+	spi_ci.dev = &spi->dev;
+
+	return stmpe_probe(&spi_ci, id->driver_data);
+}
+
+static int __devexit stmpe_spi_remove(struct spi_device *spi)
+{
+	struct stmpe *stmpe = dev_get_drvdata(&spi->dev);
+
+	return stmpe_remove(stmpe);
+}
+
+static const struct spi_device_id stmpe_spi_id[] = {
+	{ "stmpe811", STMPE811 },
+	{ "stmpe1601", STMPE1601 },
+	{ "stmpe2401", STMPE2401 },
+	{ "stmpe2403", STMPE2403 },
+	{ }
+};
+MODULE_DEVICE_TABLE(spi, stmpe_id);
+
+static struct spi_driver stmpe_spi_driver = {
+	.driver = {
+		.name	= "stmpe-spi",
+		.bus	= &spi_bus_type,
+		.owner	= THIS_MODULE,
+#ifdef CONFIG_PM
+		.pm	= &stmpe_dev_pm_ops,
+#endif
+	},
+	.probe		= stmpe_spi_probe,
+	.remove		= __devexit_p(stmpe_spi_remove),
+	.id_table	= stmpe_spi_id,
+};
+
+static int __init stmpe_init(void)
+{
+	return spi_register_driver(&stmpe_spi_driver);
+}
+subsys_initcall(stmpe_init);
+
+static void __exit stmpe_exit(void)
+{
+	spi_unregister_driver(&stmpe_spi_driver);
+}
+module_exit(stmpe_exit);
+
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("STMPE MFD SPI Interface Driver");
+MODULE_AUTHOR("Viresh Kumar <viresh.kumar@st.com>");
diff --git a/drivers/mfd/stmpe.h b/drivers/mfd/stmpe.h
index 18d89a6..a73f4c1 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -120,6 +120,7 @@ int stmpe_remove(struct stmpe *stmpe);
 
 #define STMPE811_REG_CHIP_ID		0x00
 #define STMPE811_REG_SYS_CTRL2		0x04
+#define STMPE811_REG_SPI_CFG		0x08
 #define STMPE811_REG_INT_CTRL		0x09
 #define STMPE811_REG_INT_EN		0x0A
 #define STMPE811_REG_INT_STA		0x0B
-- 
1.7.2.2


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH V2 3/5] mfd/stmpe: Add support for stmpe variant 610
  2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 1/5] mfd/stmpe: separate out controller and interface specific code Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 2/5] mfd/stmpe: Add support for SPI interface Viresh Kumar
@ 2011-11-17  5:32 ` Viresh Kumar
  2011-11-17  9:12   ` Linus Walleij
  2011-11-17  5:32 ` [PATCH V2 4/5] mfd/stmpe: ADD support for stmpe variant 801 Viresh Kumar
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 17+ messages in thread
From: Viresh Kumar @ 2011-11-17  5:32 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 0a43659..b11d33b 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 53efce4..46963a5 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 83bacde..67ff3dc 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 babc6b2..342005a 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] 17+ messages in thread

* [PATCH V2 4/5] mfd/stmpe: ADD support for stmpe variant 801
  2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
                   ` (2 preceding siblings ...)
  2011-11-17  5:32 ` [PATCH V2 3/5] mfd/stmpe: Add support for stmpe variant 610 Viresh Kumar
@ 2011-11-17  5:32 ` Viresh Kumar
  2011-11-17  5:32 ` [PATCH V2 5/5] gpio/gpio-stmpe: " Viresh Kumar
  2011-11-21  4:32 ` [PATCH 5/5 V3] " Viresh Kumar
  5 siblings, 0 replies; 17+ messages in thread
From: Viresh Kumar @ 2011-11-17  5:32 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 b11d33b..373f423 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 46963a5..b58c43c 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 67ff3dc..fc2c6af 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 a73f4c1..7b8e13f 100644
--- a/drivers/mfd/stmpe.h
+++ b/drivers/mfd/stmpe.h
@@ -105,6 +105,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 342005a..ca1d7a3 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] 17+ messages in thread

* [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
                   ` (3 preceding siblings ...)
  2011-11-17  5:32 ` [PATCH V2 4/5] mfd/stmpe: ADD support for stmpe variant 801 Viresh Kumar
@ 2011-11-17  5:32 ` Viresh Kumar
  2011-11-18 11:59   ` Rabin Vincent
  2011-11-21  4:32 ` [PATCH 5/5 V3] " Viresh Kumar
  5 siblings, 1 reply; 17+ messages in thread
From: Viresh Kumar @ 2011-11-17  5:32 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..000b019 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->partnum == 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->partnum == 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->partnum != 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] 17+ messages in thread

* Re: [PATCH V2 3/5] mfd/stmpe: Add support for stmpe variant 610
  2011-11-17  5:32 ` [PATCH V2 3/5] mfd/stmpe: Add support for stmpe variant 610 Viresh Kumar
@ 2011-11-17  9:12   ` Linus Walleij
  0 siblings, 0 replies; 17+ messages in thread
From: Linus Walleij @ 2011-11-17  9:12 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rabin.vincent, 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 Thu, Nov 17, 2011 at 6:32 AM, Viresh Kumar <viresh.kumar@st.com> wrote:

> 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>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Thanks,
Linus Walleij

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-17  5:32 ` [PATCH V2 5/5] gpio/gpio-stmpe: " Viresh Kumar
@ 2011-11-18 11:59   ` Rabin Vincent
  2011-11-21  4:20     ` Viresh Kumar
  0 siblings, 1 reply; 17+ messages in thread
From: Rabin Vincent @ 2011-11-18 11:59 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 Thu, Nov 17, 2011 at 11:02, Viresh Kumar <viresh.kumar@st.com> wrote:
> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
> index 4c980b5..000b019 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);
>  }

This code,

 (1) for 801, when clearing one GPIO, sets all the others.
 (2) for other devices, adds an an unnecessary read (within stmpe_set_bits()),
     which wasn't there before.

Please rework to something like:

	if (stmpe->regs[...)
		stmpe_set_bits(stmpe, reg, mask, val ? mask : 0);
	else
		stmpe_reg_write(stmpe, reg, 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->partnum == STMPE801) {
> +               if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
> +                       return 0;

This looks wrong.  From the datasheet I see that it supports edges only,
so perhaps you meant to say IRQ_TYPE_EDGE_* above.

In that case please reorganize this to add the return 0 after the
existing check which excludes levels (below).

> +               else
> +                       return -EINVAL;
> +       }
> +
>        if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
>                return -EINVAL;

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-18 11:59   ` Rabin Vincent
@ 2011-11-21  4:20     ` Viresh Kumar
  2011-11-21 14:51       ` Mark Brown
  0 siblings, 1 reply; 17+ messages in thread
From: Viresh Kumar @ 2011-11-21  4:20 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/18/2011 5:29 PM, Rabin Vincent wrote:
> On Thu, Nov 17, 2011 at 11:02, Viresh Kumar <viresh.kumar@st.com> wrote:
>> diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
>> index 4c980b5..000b019 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)
>> +       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);
>>  }
> 
> This code,
> 
>  (1) for 801, when clearing one GPIO, sets all the others.

I assumed stmpe_set_bits will only affect bits which are 1
in mask and i was wrong. :(

>  (2) for other devices, adds an an unnecessary read (within stmpe_set_bits()),
>      which wasn't there before.
> 

Correct.

> Please rework to something like:
> 
> 	if (stmpe->regs[...)
> 		stmpe_set_bits(stmpe, reg, mask, val ? mask : 0);
> 	else
> 		stmpe_reg_write(stmpe, reg, mask);
> 

Sure.

>>
>>  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->partnum == STMPE801) {
>> +               if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
>> +                       return 0;
> 
> This looks wrong.  From the datasheet I see that it supports edges only,
> so perhaps you meant to say IRQ_TYPE_EDGE_* above.
> 

I meant to say IRQ_TYPE_LEVEL* only, but i was wrong. I didn't read the manual
correctly. :(

> In that case please reorganize this to add the return 0 after the
> existing check which excludes levels (below).
> 

Sure

-- 
viresh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 5/5 V3] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
                   ` (4 preceding siblings ...)
  2011-11-17  5:32 ` [PATCH V2 5/5] gpio/gpio-stmpe: " Viresh Kumar
@ 2011-11-21  4:32 ` Viresh Kumar
  2011-12-19 17:53   ` [PATVCH V3 Resend 5/5] " Samuel Ortiz
  5 siblings, 1 reply; 17+ messages in thread
From: Viresh Kumar @ 2011-11-21  4:32 UTC (permalink / raw)
  To: rabin.vincent, linus.walleij, srinidhi.kasagar
  Cc: 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, sameo, linux-kernel, 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>
---

Changes since V2:
- stmpe_gpio_set() is updates, so that it doesn't configure other gpio pins by
  mistake.
- STMPE801 also supports Edge interrupts and not level ints. Code updated for
  this too.

 drivers/gpio/gpio-stmpe.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 4c980b5..87a68a8 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -65,7 +65,14 @@ 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 (stmpe->regs[STMPE_IDX_GPSR_LSB] == stmpe->regs[STMPE_IDX_GPCR_LSB])
+		stmpe_set_bits(stmpe, reg, mask, val ? mask : 0);
+	else
+		stmpe_reg_write(stmpe, reg, mask);
 }
 
 static int stmpe_gpio_direction_output(struct gpio_chip *chip,
@@ -132,6 +139,10 @@ static int stmpe_gpio_irq_set_type(struct irq_data *d, unsigned int type)
 	if (type == IRQ_TYPE_LEVEL_LOW || type == IRQ_TYPE_LEVEL_HIGH)
 		return -EINVAL;
 
+	/* STMPE801 doesn't have RE and FE registers */
+	if (stmpe_gpio->stmpe->partnum == STMPE801)
+		return 0;
+
 	if (type == IRQ_TYPE_EDGE_RISING)
 		stmpe_gpio->regs[REG_RE][regoffset] |= mask;
 	else
@@ -165,6 +176,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->partnum == 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 +257,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->partnum != 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] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-21  4:20     ` Viresh Kumar
@ 2011-11-21 14:51       ` Mark Brown
  2011-11-22  3:48         ` Viresh Kumar
  0 siblings, 1 reply; 17+ messages in thread
From: Mark Brown @ 2011-11-21 14:51 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rabin Vincent, 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 Mon, Nov 21, 2011 at 09:50:05AM +0530, Viresh Kumar wrote:
> On 11/18/2011 5:29 PM, Rabin Vincent wrote:

> >  (1) for 801, when clearing one GPIO, sets all the others.

> I assumed stmpe_set_bits will only affect bits which are 1
> in mask and i was wrong. :(

That does look like a straight bug in stmpe_set_bits() which ought to be
fixed regardless of anything else.

> >  (2) for other devices, adds an an unnecessary read (within stmpe_set_bits()),
> >      which wasn't there before.

> Correct.

> > Please rework to something like:

Looking at the code in stmpe.c it might be as well to convert to regmap
which would if nothing else save a bunch of custom code in the driver
and let you use the cache code to eliminate the read.  Probably that
will help eliminate reads in other places too.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-21 14:51       ` Mark Brown
@ 2011-11-22  3:48         ` Viresh Kumar
  2011-12-12 14:20           ` Samuel Ortiz
  0 siblings, 1 reply; 17+ messages in thread
From: Viresh Kumar @ 2011-11-22  3:48 UTC (permalink / raw)
  To: Mark Brown, sameo@linux.intel.com
  Cc: Rabin Vincent, Linus WALLEIJ, Srinidhi KASAGAR,
	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/21/2011 8:21 PM, Mark Brown wrote:
>> > I assumed stmpe_set_bits will only affect bits which are 1
>> > in mask and i was wrong. :(
> That does look like a straight bug in stmpe_set_bits() which ought to be
> fixed regardless of anything else.
> 

I think so. I will fix it in a separate patch.

>>> > >  (2) for other devices, adds an an unnecessary read (within stmpe_set_bits()),
>>> > >      which wasn't there before.
>> > Correct.
>>> > > Please rework to something like:
> Looking at the code in stmpe.c it might be as well to convert to regmap
> which would if nothing else save a bunch of custom code in the driver
> and let you use the cache code to eliminate the read.  Probably that
> will help eliminate reads in other places too.

Ya, i already got this feedback from Rabin. I am a bit busy right now and so
requested sameo to accept this patchset as it is. I will update drivers to use
regmap as soon as i get some time.

-- 
viresh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-22  3:48         ` Viresh Kumar
@ 2011-12-12 14:20           ` Samuel Ortiz
  2011-12-13  3:34             ` Viresh Kumar
  0 siblings, 1 reply; 17+ messages in thread
From: Samuel Ortiz @ 2011-12-12 14:20 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Mark Brown, Rabin Vincent, Linus WALLEIJ, Srinidhi KASAGAR,
	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

Hi Viresh,

On Tue, Nov 22, 2011 at 09:18:54AM +0530, Viresh Kumar wrote:
> On 11/21/2011 8:21 PM, Mark Brown wrote:
> >> > I assumed stmpe_set_bits will only affect bits which are 1
> >> > in mask and i was wrong. :(
> > That does look like a straight bug in stmpe_set_bits() which ought to be
> > fixed regardless of anything else.
> > 
> 
> I think so. I will fix it in a separate patch.
> 
> >>> > >  (2) for other devices, adds an an unnecessary read (within stmpe_set_bits()),
> >>> > >      which wasn't there before.
> >> > Correct.
> >>> > > Please rework to something like:
> > Looking at the code in stmpe.c it might be as well to convert to regmap
> > which would if nothing else save a bunch of custom code in the driver
> > and let you use the cache code to eliminate the read.  Probably that
> > will help eliminate reads in other places too.
> 
> Ya, i already got this feedback from Rabin. I am a bit busy right now and so
> requested sameo to accept this patchset as it is. I will update drivers to use
> regmap as soon as i get some time.
Ok, so I reverted your first 2 patches patchset since it seems it was
problematic. Now, I think Rabin's concern on your patch #5 seems valid, and
I'd like you to fix it before applying this patchset.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-12-12 14:20           ` Samuel Ortiz
@ 2011-12-13  3:34             ` Viresh Kumar
  2011-12-13 20:38               ` Samuel Ortiz
  0 siblings, 1 reply; 17+ messages in thread
From: Viresh Kumar @ 2011-12-13  3:34 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Mark Brown, Rabin Vincent, Linus WALLEIJ, Srinidhi KASAGAR,
	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 12/12/2011 7:50 PM, Samuel Ortiz wrote:
> Ok, so I reverted your first 2 patches patchset since it seems it was
> problematic. Now, I think Rabin's concern on your patch #5 seems valid, and
> I'd like you to fix it before applying this patchset.

Which problem are you talking about? Issues in v2 of patch 5/5 or converting to regmap?

Earlier once are already fixed in V3 of 5/5. And for later one, i already confirmed to
do it in a separate patchset.

-- 
viresh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-12-13  3:34             ` Viresh Kumar
@ 2011-12-13 20:38               ` Samuel Ortiz
  2011-12-14  3:59                 ` Viresh Kumar
  0 siblings, 1 reply; 17+ messages in thread
From: Samuel Ortiz @ 2011-12-13 20:38 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Mark Brown, Rabin Vincent, Linus WALLEIJ, Srinidhi KASAGAR,
	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

Hi Viresh,

On Tue, Dec 13, 2011 at 09:04:18AM +0530, Viresh Kumar wrote:
> On 12/12/2011 7:50 PM, Samuel Ortiz wrote:
> > Ok, so I reverted your first 2 patches patchset since it seems it was
> > problematic. Now, I think Rabin's concern on your patch #5 seems valid, and
> > I'd like you to fix it before applying this patchset.
> 
> Which problem are you talking about? Issues in v2 of patch 5/5 or converting to regmap?
> 
> Earlier once are already fixed in V3 of 5/5. And for later one, i already confirmed to
> do it in a separate patchset.
I haven't received a V3 for 5/5. Could you please re-send it to me ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH V2 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-12-13 20:38               ` Samuel Ortiz
@ 2011-12-14  3:59                 ` Viresh Kumar
  0 siblings, 0 replies; 17+ messages in thread
From: Viresh Kumar @ 2011-12-14  3:59 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: Mark Brown, Rabin Vincent, Linus WALLEIJ, Srinidhi KASAGAR,
	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 12/14/2011 2:08 AM, Samuel Ortiz wrote:
> I haven't received a V3 for 5/5. Could you please re-send it to me ?

I sent it again. :)

-- 
viresh

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATVCH V3 Resend 5/5] gpio/gpio-stmpe: ADD support for stmpe variant 801
  2011-11-21  4:32 ` [PATCH 5/5 V3] " Viresh Kumar
@ 2011-12-19 17:53   ` Samuel Ortiz
  0 siblings, 0 replies; 17+ messages in thread
From: Samuel Ortiz @ 2011-12-19 17:53 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: rabin.vincent, linus.walleij, srinidhi.kasagar, 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, linux-kernel

Hi Viresh,

On Wed, Dec 14, 2011 at 09:28:27AM +0530, Viresh Kumar wrote:
> 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>
> ---
> 
> Hi Samuel,
> 
> Please apply this patch instead of V2 5/5.
All 5 patches applied now, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2011-12-19 17:49 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-17  5:32 [PATCH V2 0/5] stmpe: mfd & gpio updates Viresh Kumar
2011-11-17  5:32 ` [PATCH V2 1/5] mfd/stmpe: separate out controller and interface specific code Viresh Kumar
2011-11-17  5:32 ` [PATCH V2 2/5] mfd/stmpe: Add support for SPI interface Viresh Kumar
2011-11-17  5:32 ` [PATCH V2 3/5] mfd/stmpe: Add support for stmpe variant 610 Viresh Kumar
2011-11-17  9:12   ` Linus Walleij
2011-11-17  5:32 ` [PATCH V2 4/5] mfd/stmpe: ADD support for stmpe variant 801 Viresh Kumar
2011-11-17  5:32 ` [PATCH V2 5/5] gpio/gpio-stmpe: " Viresh Kumar
2011-11-18 11:59   ` Rabin Vincent
2011-11-21  4:20     ` Viresh Kumar
2011-11-21 14:51       ` Mark Brown
2011-11-22  3:48         ` Viresh Kumar
2011-12-12 14:20           ` Samuel Ortiz
2011-12-13  3:34             ` Viresh Kumar
2011-12-13 20:38               ` Samuel Ortiz
2011-12-14  3:59                 ` Viresh Kumar
2011-11-21  4:32 ` [PATCH 5/5 V3] " Viresh Kumar
2011-12-19 17:53   ` [PATVCH V3 Resend 5/5] " Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).