Skip to contentSkip to conversation

A few patches to cyttsp

PATCH In review Dmitry Torokhov 2 participants 11 messages Nov 14, 2011 – Nov 16, 2011

Subsystems (3)
lore
Share & tools
lore

Dmitry Torokhov

author maintainer
#0 lore raw

cover A few patches to cyttsp

Hi Javier,

I am sending a few patches that I made while trying to understand the Cypress TTSP driver. I am still not quite happy with the SPI read method and I am also wondering if cyttsp_power_on could be made less messy.

Current open/close methods seem to be not very useful: even though we stop interrupts we do not put the chip into low power mode. Is there a way to do so?

Regarding PM methods - why do we have conditional 'use sleep' and what exactly wakeup() method is supposed to do? Why is it a platform method?

Thanks.

Signature · 1 line
Dmitry
author maintainer
#1 lore raw

PATCH 1/7 Input: cyttsp - move up into main touchscreen directory

All the other touchscreen drivers do not use separate directories so let's follow the same suit.

---

 drivers/input/touchscreen/Kconfig              |   39 +
 drivers/input/touchscreen/Makefile             |    4 
 drivers/input/touchscreen/cyttsp/Kconfig       |   36 -
 drivers/input/touchscreen/cyttsp/Makefile      |    3 
 drivers/input/touchscreen/cyttsp/cyttsp_core.c |  768 ------------------------
 drivers/input/touchscreen/cyttsp/cyttsp_core.h |   59 --
 drivers/input/touchscreen/cyttsp/cyttsp_i2c.c  |  178 ------
 drivers/input/touchscreen/cyttsp/cyttsp_spi.c  |  275 ---------
 drivers/input/touchscreen/cyttsp_core.c        |  767 ++++++++++++++++++++++++
 drivers/input/touchscreen/cyttsp_core.h        |   59 ++
 drivers/input/touchscreen/cyttsp_i2c.c         |  178 ++++++
 drivers/input/touchscreen/cyttsp_spi.c         |  274 +++++++++
 12 files changed, 1318 insertions(+), 1322 deletions(-)
 delete mode 100644 drivers/input/touchscreen/cyttsp/Kconfig
 delete mode 100644 drivers/input/touchscreen/cyttsp/Makefile
 delete mode 100644 drivers/input/touchscreen/cyttsp/cyttsp_core.c
 delete mode 100644 drivers/input/touchscreen/cyttsp/cyttsp_core.h
 delete mode 100644 drivers/input/touchscreen/cyttsp/cyttsp_i2c.c
 delete mode 100644 drivers/input/touchscreen/cyttsp/cyttsp_spi.c
 create mode 100644 drivers/input/touchscreen/cyttsp_core.c
 create mode 100644 drivers/input/touchscreen/cyttsp_core.h
 create mode 100644 drivers/input/touchscreen/cyttsp_i2c.c
 create mode 100644 drivers/input/touchscreen/cyttsp_spi.c
drivers/input/touchscreen/Kconfig +37 -2
index 6e918f8..9537404 100644
@@ -136,6 +136,43 @@ config TOUCHSCREEN_CY8CTMG110
 	  To compile this driver as a module, choose M here: the
 	  module will be called cy8ctmg110_ts.
 
+config TOUCHSCREEN_CYTTSP_CORE
+	tristate "Cypress TTSP touchscreen core"
+	depends on INPUT_TOUCHSCREEN
+	help
+          Say Y here if you have a touchscreen interface using one
+          controller from the Cypress TrueTouch(tm) Standard Product
+	  family.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cyttsp_core.
+
+config TOUCHSCREEN_CYTTSP_I2C
+	tristate "Cypress TTSP i2c touchscreen"
+	depends on I2C && TOUCHSCREEN_CYTTSP_CORE
+	help
+	  Say Y here if you have a Cypress TTSP touchscreen
+	  connected to your system with an I2C interface.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cyttsp_i2c.
+
+config TOUCHSCREEN_CYTTSP_SPI
+	tristate "Cypress TTSP spi touchscreen"
+	depends on SPI_MASTER && TOUCHSCREEN_CYTTSP_CORE
+	help
+	  Say Y here if you have a Cypress TTSP touchscreen
+	  connected to your  with an SPI interface.
+
+	  If unsure, say N.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called cyttsp_spi.
+
 config TOUCHSCREEN_DA9034
 	tristate "Touchscreen support for Dialog Semiconductor DA9034"
 	depends on PMIC_DA903X
@@ -775,6 +812,4 @@ config TOUCHSCREEN_TPS6507X
 	  To compile this driver as a module, choose M here: the
 	  module will be called tps6507x_ts.
 
-source "drivers/input/touchscreen/cyttsp/Kconfig"
-
 endif
drivers/input/touchscreen/Makefile +3 -1
index d697e16..d1848e7 100644
@@ -17,6 +17,9 @@ obj-$(CONFIG_TOUCHSCREEN_ATMEL_TSADCC)	+= atmel_tsadcc.o
 obj-$(CONFIG_TOUCHSCREEN_BITSY)		+= h3600_ts_input.o
 obj-$(CONFIG_TOUCHSCREEN_BU21013)       += bu21013_ts.o
 obj-$(CONFIG_TOUCHSCREEN_CY8CTMG110)	+= cy8ctmg110_ts.o
+obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE)   += cyttsp_core.o
+obj-$(CONFIG_TOUCHSCREEN_CYTTSP_I2C)    += cyttsp_i2c.o
+obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI)    += cyttsp_spi.o
 obj-$(CONFIG_TOUCHSCREEN_DA9034)	+= da9034-ts.o
 obj-$(CONFIG_TOUCHSCREEN_DA9052)	+= da9052_tsi.o
 obj-$(CONFIG_TOUCHSCREEN_DYNAPRO)	+= dynapro.o
@@ -64,4 +67,3 @@ obj-$(CONFIG_TOUCHSCREEN_WM97XX_MAINSTONE)	+= mainstone-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_WM97XX_ZYLONITE)	+= zylonite-wm97xx.o
 obj-$(CONFIG_TOUCHSCREEN_W90X900)	+= w90p910_ts.o
 obj-$(CONFIG_TOUCHSCREEN_TPS6507X)	+= tps6507x-ts.o
-obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE)	+= cyttsp/
drivers/input/touchscreen/cyttsp/Kconfig deleted +0 -36
deleted file mode 100644
index c8bc322..0000000
@@ -1,36 +0,0 @@
-config TOUCHSCREEN_CYTTSP_CORE
-	tristate "Cypress TTSP touchscreen core"
-	depends on INPUT_TOUCHSCREEN
-	help
-          Say Y here if you have a touchscreen interface using one
-          controller from the Cypress TrueTouch(tm) Standard Product
-	  family.
-
-	  If unsure, say N.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called cyttsp_core.
-
-config TOUCHSCREEN_CYTTSP_I2C
-	tristate "Cypress TTSP i2c touchscreen"
-	depends on I2C && TOUCHSCREEN_CYTTSP_CORE
-	help
-	  Say Y here if you have a Cypress TTSP touchscreen
-	  connected to your system with an I2C interface.
-
-	  If unsure, say N.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called cyttsp_i2c.
-
-config TOUCHSCREEN_CYTTSP_SPI
-	tristate "Cypress TTSP spi touchscreen"
-	depends on SPI_MASTER && TOUCHSCREEN_CYTTSP_CORE
-	help
-	  Say Y here if you have a Cypress TTSP touchscreen
-	  connected to your  with an SPI interface.
-
-	  If unsure, say N.
-
-	  To compile this driver as a module, choose M here: the
-	  module will be called cyttsp_spi.
drivers/input/touchscreen/cyttsp/Makefile deleted +0 -3
deleted file mode 100644
index 687eeaa..0000000
@@ -1,3 +0,0 @@
-obj-$(CONFIG_TOUCHSCREEN_CYTTSP_CORE)   += cyttsp_core.o
-obj-$(CONFIG_TOUCHSCREEN_CYTTSP_I2C)    += cyttsp_i2c.o
-obj-$(CONFIG_TOUCHSCREEN_CYTTSP_SPI)    += cyttsp_spi.o
drivers/input/touchscreen/cyttsp/cyttsp_core.c deleted +0 -768

768 lines not on this page · raw message

drivers/input/touchscreen/cyttsp/cyttsp_core.h deleted +0 -59

59 lines not on this page · raw message

drivers/input/touchscreen/cyttsp/cyttsp_i2c.c deleted +0 -178

178 lines not on this page · raw message

drivers/input/touchscreen/cyttsp/cyttsp_spi.c deleted +0 -275

275 lines not on this page · raw message

drivers/input/touchscreen/cyttsp_core.c new file +767 -0

767 lines not on this page · raw message

drivers/input/touchscreen/cyttsp_core.h new file +59 -0

59 lines not on this page · raw message

drivers/input/touchscreen/cyttsp_i2c.c new file +178 -0

178 lines not on this page · raw message

drivers/input/touchscreen/cyttsp_spi.c new file +274 -0

274 lines not on this page · raw message

author maintainer
#2 lore raw

PATCH 2/7 Input: cyttsp - rework Kconfig entries

In reply to Dmitry Torokhov

Rework Kconfig entries to match the style of other drivers supporting multiple transports: have users select driver core and then appropriate transport (SPI/I2C) as a sub-option.

---

 drivers/input/touchscreen/Kconfig |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)
drivers/input/touchscreen/Kconfig +11 -17
index 9537404..e377535 100644
@@ -137,12 +137,12 @@ config TOUCHSCREEN_CY8CTMG110
 	  module will be called cy8ctmg110_ts.
 
 config TOUCHSCREEN_CYTTSP_CORE
-	tristate "Cypress TTSP touchscreen core"
-	depends on INPUT_TOUCHSCREEN
+	tristate "Cypress TTSP touchscreen"
 	help
-          Say Y here if you have a touchscreen interface using one
-          controller from the Cypress TrueTouch(tm) Standard Product
-	  family.
+	  Say Y here if you have a touchscreen using controller from
+	  the Cypress TrueTouch(tm) Standard Product family connected
+	  to your system. You will also need to select appropriate
+	  bus connection below.
 
 	  If unsure, say N.
 
@@ -150,25 +150,19 @@ config TOUCHSCREEN_CYTTSP_CORE
 	  module will be called cyttsp_core.
 
 config TOUCHSCREEN_CYTTSP_I2C
-	tristate "Cypress TTSP i2c touchscreen"
-	depends on I2C && TOUCHSCREEN_CYTTSP_CORE
+	tristate "support I2C bus connection"
+	depends on TOUCHSCREEN_CYTTSP_CORE && I2C
 	help
-	  Say Y here if you have a Cypress TTSP touchscreen
-	  connected to your system with an I2C interface.
-
-	  If unsure, say N.
+	  Say Y here if the touchscreen is connected via I2C bus.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called cyttsp_i2c.
 
 config TOUCHSCREEN_CYTTSP_SPI
-	tristate "Cypress TTSP spi touchscreen"
-	depends on SPI_MASTER && TOUCHSCREEN_CYTTSP_CORE
+	tristate "support SPI bus connection"
+	depends on TOUCHSCREEN_CYTTSP_CORE && SPI_MASTER
 	help
-	  Say Y here if you have a Cypress TTSP touchscreen
-	  connected to your  with an SPI interface.
-
-	  If unsure, say N.
+	  Say Y here if the touchscreen is connected via SPI bus.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called cyttsp_spi.
author maintainer
#3 lore raw

PATCH 3/7 Input: cyttsp - guard PM methods with CONFIG_PM_SLEEP

In reply to Dmitry Torokhov

This will prevent compiler from complaining about PM methods defined but not used in case when CONFIG_PM_RUNTIME is defined but CONFIG_PM_SLEEP is not.

---

 drivers/input/touchscreen/cyttsp_core.c |    2 +-
 drivers/input/touchscreen/cyttsp_core.h |    2 +-
 drivers/input/touchscreen/cyttsp_i2c.c  |    7 +++----
 drivers/input/touchscreen/cyttsp_spi.c  |    7 +++----
 4 files changed, 8 insertions(+), 10 deletions(-)
drivers/input/touchscreen/cyttsp_core.c +1 -1
index 47a0958..54f36d6 100644
@@ -592,7 +592,7 @@ bypass:
 	return retval;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 int cyttsp_resume(void *handle)
 {
 	struct cyttsp *ts = handle;
drivers/input/touchscreen/cyttsp_core.h +1 -1
index c4c7d9e..1a0fd9d 100644
@@ -51,7 +51,7 @@ void *cyttsp_core_init(struct cyttsp_bus_ops *bus_ops,
 		       struct device *dev, int irq);
 
 void cyttsp_core_release(void *handle);
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 int cyttsp_resume(void *handle);
 int cyttsp_suspend(void *handle);
 #endif
drivers/input/touchscreen/cyttsp_i2c.c +3 -4
index d7d62d4..697c7a88 100644
@@ -122,7 +122,7 @@ static int __devexit cyttsp_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int cyttsp_i2c_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
@@ -138,9 +138,10 @@ static int cyttsp_i2c_resume(struct device *dev)
 
 	return cyttsp_resume(ts->ttsp_client);
 }
-static SIMPLE_DEV_PM_OPS(cyttsp_i2c_pm, cyttsp_i2c_suspend, cyttsp_i2c_resume);
 #endif
 
+static SIMPLE_DEV_PM_OPS(cyttsp_i2c_pm, cyttsp_i2c_suspend, cyttsp_i2c_resume);
+
 static const struct i2c_device_id cyttsp_i2c_id[] = {
 	{ CY_I2C_NAME, 0 },  { }
 };
@@ -149,9 +150,7 @@ static struct i2c_driver cyttsp_i2c_driver = {
 	.driver = {
 		.name = CY_I2C_NAME,
 		.owner = THIS_MODULE,
-#ifdef CONFIG_PM
 		.pm = &cyttsp_i2c_pm,
-#endif
 	},
 	.probe = cyttsp_i2c_probe,
 	.remove = __devexit_p(cyttsp_i2c_remove),
drivers/input/touchscreen/cyttsp_spi.c +3 -4
index 1324695..8138a96 100644
@@ -227,7 +227,7 @@ static int __devexit cyttsp_spi_remove(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int cyttsp_spi_suspend(struct device *dev)
 {
 	struct cyttsp_spi *ts = dev_get_drvdata(dev);
@@ -241,16 +241,15 @@ static int cyttsp_spi_resume(struct device *dev)
 
 	return cyttsp_resume(ts->ttsp_client);
 }
-static SIMPLE_DEV_PM_OPS(cyttsp_spi_pm, cyttsp_spi_suspend, cyttsp_spi_resume);
 #endif
 
+static SIMPLE_DEV_PM_OPS(cyttsp_spi_pm, cyttsp_spi_suspend, cyttsp_spi_resume);
+
 static struct spi_driver cyttsp_spi_driver = {
 	.driver = {
 		.name = CY_SPI_NAME,
 		.owner = THIS_MODULE,
-#ifdef CONFIG_PM
 		.pm = &cyttsp_spi_pm,
-#endif
 	},
 	.probe = cyttsp_spi_probe,
 	.remove = __devexit_p(cyttsp_spi_remove),
author maintainer
#4 lore raw

PATCH 4/7 Input: cyttsp - device does not belong in bus structure

In reply to Dmitry Torokhov

bus structure is supposed to be constant and shared between several instances of the device.

---

 drivers/input/touchscreen/cyttsp_core.c |    8 +++--
 drivers/input/touchscreen/cyttsp_core.h |    8 +++--
 drivers/input/touchscreen/cyttsp_i2c.c  |   31 +++++++++++---------
 drivers/input/touchscreen/cyttsp_spi.c  |   48 ++++++++++++++++---------------
 4 files changed, 50 insertions(+), 45 deletions(-)
drivers/input/touchscreen/cyttsp_core.c +4 -4
index 54f36d6..4bc9fcd 100644
@@ -145,7 +145,7 @@ struct cyttsp {
 	struct input_dev *input;
 	char phys[32];
 	const struct cyttsp_platform_data *platform_data;
-	struct cyttsp_bus_ops *bus_ops;
+	const struct cyttsp_bus_ops *bus_ops;
 	struct cyttsp_bootloader_data bl_data;
 	struct cyttsp_sysinfo_data sysinfo_data;
 	struct completion bl_ready;
@@ -169,7 +169,7 @@ static int ttsp_read_block_data(struct cyttsp *ts, u8 command,
 		return -EINVAL;
 
 	for (tries = 0; tries < CY_NUM_RETRY && (retval < 0); tries++) {
-		retval = ts->bus_ops->read(ts->bus_ops, command, length, buf);
+		retval = ts->bus_ops->read(ts->dev, command, length, buf);
 		if (retval)
 			msleep(CY_DELAY_DFLT);
 	}
@@ -187,7 +187,7 @@ static int ttsp_write_block_data(struct cyttsp *ts, u8 command,
 		return -EINVAL;
 
 	for (tries = 0; tries < CY_NUM_RETRY && (retval < 0); tries++) {
-		retval = ts->bus_ops->write(ts->bus_ops, command, length, buf);
+		retval = ts->bus_ops->write(ts->dev, command, length, buf);
 		if (retval)
 			msleep(CY_DELAY_DFLT);
 	}
@@ -672,7 +672,7 @@ static void cyttsp_close(struct input_dev *dev)
 	free_irq(ts->irq, ts);
 }
 
-void *cyttsp_core_init(struct cyttsp_bus_ops *bus_ops,
+void *cyttsp_core_init(const struct cyttsp_bus_ops *bus_ops,
 		       struct device *dev, int irq)
 {
 	struct input_dev *input_device;
drivers/input/touchscreen/cyttsp_core.h +4 -4
index 1a0fd9d..36f94ec 100644
@@ -42,12 +42,12 @@
 
 
 struct cyttsp_bus_ops {
-	s32 (*write)(void *handle, u8 addr, u8 length, const void *values);
-	s32 (*read)(void *handle, u8 addr, u8 length, void *values);
-	struct device *dev;
+	int (*write)(struct device *dev,
+		     u8 addr, u8 length, const void *values);
+	int (*read)(struct device *dev, u8 addr, u8 length, void *values);
 };
 
-void *cyttsp_core_init(struct cyttsp_bus_ops *bus_ops,
+void *cyttsp_core_init(const struct cyttsp_bus_ops *bus_ops,
 		       struct device *dev, int irq);
 
 void cyttsp_core_release(void *handle);
drivers/input/touchscreen/cyttsp_i2c.c +17 -14
index 697c7a88..5911d9c 100644
@@ -37,16 +37,16 @@
 #define CY_I2C_DATA_SIZE  128
 
 struct cyttsp_i2c {
-	struct cyttsp_bus_ops ops;
 	struct i2c_client *client;
 	void *ttsp_client;
 	u8 wr_buf[CY_I2C_DATA_SIZE];
 };
 
-static s32 ttsp_i2c_read_block_data(void *handle, u8 addr,
-	u8 length, void *values)
+static int ttsp_i2c_read_block_data(struct device *dev,
+				    u8 addr, u8 length, void *values)
 {
-	struct cyttsp_i2c *ts = container_of(handle, struct cyttsp_i2c, ops);
+	struct i2c_client *client = to_i2c_client(dev);
+	struct cyttsp_i2c *ts = i2c_get_clientdata(client);
 	int retval = 0;
 
 	retval = i2c_master_send(ts->client, &addr, 1);
@@ -61,10 +61,11 @@ static s32 ttsp_i2c_read_block_data(void *handle, u8 addr,
 	return (retval < 0) ? retval : 0;
 }
 
-static s32 ttsp_i2c_write_block_data(void *handle, u8 addr,
-	u8 length, const void *values)
+static int ttsp_i2c_write_block_data(struct device *dev,
+				     u8 addr, u8 length, const void *values)
 {
-	struct cyttsp_i2c *ts = container_of(handle, struct cyttsp_i2c, ops);
+	struct i2c_client *client = to_i2c_client(dev);
+	struct cyttsp_i2c *ts = i2c_get_clientdata(client);
 	int retval;
 
 	ts->wr_buf[0] = addr;
@@ -78,8 +79,13 @@ static s32 ttsp_i2c_write_block_data(void *handle, u8 addr,
 	return (retval < 0) ? retval : 0;
 }
 
+static const struct cyttsp_bus_ops cyttsp_i2c_bus_ops = {
+	.write		= ttsp_i2c_write_block_data,
+	.read		= ttsp_i2c_read_block_data,
+};
+
 static int __devinit cyttsp_i2c_probe(struct i2c_client *client,
-	const struct i2c_device_id *id)
+				      const struct i2c_device_id *id)
 {
 	struct cyttsp_i2c *ts;
 
@@ -96,11 +102,8 @@ static int __devinit cyttsp_i2c_probe(struct i2c_client *client,
 	/* register driver_data */
 	ts->client = client;
 	i2c_set_clientdata(client, ts);
-	ts->ops.write = ttsp_i2c_write_block_data;
-	ts->ops.read = ttsp_i2c_read_block_data;
-	ts->ops.dev = &client->dev;
 
-	ts->ttsp_client = cyttsp_core_init(&ts->ops, &client->dev, client->irq);
+	ts->ttsp_client = cyttsp_core_init(&cyttsp_i2c_bus_ops, &client->dev, client->irq);
 	if (IS_ERR(ts->ttsp_client)) {
 		int retval = PTR_ERR(ts->ttsp_client);
 		kfree(ts);
@@ -114,11 +117,11 @@ static int __devinit cyttsp_i2c_probe(struct i2c_client *client,
 /* registered in driver struct */
 static int __devexit cyttsp_i2c_remove(struct i2c_client *client)
 {
-	struct cyttsp_i2c *ts;
+	struct cyttsp_i2c *ts = i2c_get_clientdata(client);
 
-	ts = i2c_get_clientdata(client);
 	cyttsp_core_release(ts->ttsp_client);
 	kfree(ts);
+
 	return 0;
 }
 
drivers/input/touchscreen/cyttsp_spi.c +25 -23

118 lines not on this page · raw message

author maintainer
#5 lore raw

PATCH 5/7 Input: cyttsp - set up bus type in input device

In reply to Dmitry Torokhov

Also clean up input device initialization.

---

 drivers/input/touchscreen/cyttsp_core.c |    7 +++----
 drivers/input/touchscreen/cyttsp_core.h |    2 ++
 drivers/input/touchscreen/cyttsp_i2c.c  |    2 ++
 drivers/input/touchscreen/cyttsp_spi.c  |    4 +++-
 4 files changed, 10 insertions(+), 5 deletions(-)
drivers/input/touchscreen/cyttsp_core.c +3 -4
index 4bc9fcd..764efd6 100644
@@ -719,18 +719,17 @@ void *cyttsp_core_init(const struct cyttsp_bus_ops *bus_ops,
 	}
 
 	ts->input = input_device;
+	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
+
 	input_device->name = ts->platform_data->name;
-	snprintf(ts->phys, sizeof(ts->phys), "%s", dev_name(dev));
 	input_device->phys = ts->phys;
+	input_device->id.bustype = bus_ops->bustype;
 	input_device->dev.parent = ts->dev;
 	input_device->open = cyttsp_open;
 	input_device->close = cyttsp_close;
 	input_set_drvdata(input_device, ts);
 
-	__set_bit(EV_SYN, input_device->evbit);
-	__set_bit(EV_KEY, input_device->evbit);
 	__set_bit(EV_ABS, input_device->evbit);
-
 	input_set_abs_params(input_device, ABS_MT_POSITION_X,
 			     0, ts->platform_data->maxx, 0, 0);
 	input_set_abs_params(input_device, ABS_MT_POSITION_Y,
drivers/input/touchscreen/cyttsp_core.h +2 -0
index 36f94ec..979a2f1 100644
@@ -36,12 +36,14 @@
 #include <linux/kernel.h>
 #include <linux/err.h>
 #include <linux/module.h>
+#include <linux/types.h>
 #include <linux/input/cyttsp.h>
 
 #define CY_NUM_RETRY                4 /* max number of retries for read ops */
 
 
 struct cyttsp_bus_ops {
+	u16 bustype;
 	int (*write)(struct device *dev,
 		     u8 addr, u8 length, const void *values);
 	int (*read)(struct device *dev, u8 addr, u8 length, void *values);
drivers/input/touchscreen/cyttsp_i2c.c +2 -0
index 5911d9c..3c2dd9d 100644
@@ -32,6 +32,7 @@
 #include "cyttsp_core.h"
 
 #include <linux/i2c.h>
+#include <linux/input.h>
 #include <linux/slab.h>
 
 #define CY_I2C_DATA_SIZE  128
@@ -80,6 +81,7 @@ static int ttsp_i2c_write_block_data(struct device *dev,
 }
 
 static const struct cyttsp_bus_ops cyttsp_i2c_bus_ops = {
+	.bustype	= BUS_I2C,
 	.write		= ttsp_i2c_write_block_data,
 	.read		= ttsp_i2c_read_block_data,
 };
drivers/input/touchscreen/cyttsp_spi.c +3 -1
index 4540262..4c689c7 100644
@@ -31,8 +31,9 @@
 
 #include "cyttsp_core.h"
 
-#include <linux/spi/spi.h>
 #include <linux/delay.h>
+#include <linux/input.h>
+#include <linux/spi/spi.h>
 
 #define CY_SPI_WR_OP      0x00 /* r/~w */
 #define CY_SPI_RD_OP      0x01
@@ -179,6 +180,7 @@ static int ttsp_spi_write_block_data(struct device *dev,
 }
 
 static const struct cyttsp_bus_ops cyttsp_spi_bus_ops = {
+	.bustype	= BUS_SPI,
 	.write		= ttsp_spi_write_block_data,
 	.read		= ttsp_spi_read_block_data,
 };
author maintainer
#6 lore raw

PATCH 6/7 Input: cyttsp - use unified structure for ts object

In reply to Dmitry Torokhov

Have bus implementation request needed transfer buffer size and consolidate everything into single touchscreen object. Make sure that the transfer buffer is cache line aligned as required by SPI interface.

Also rework the probe routine to request IRQ right away and ensure that we return properly encoded error codes.

---

 drivers/input/touchscreen/cyttsp_core.c |  284 ++++++++++---------------------
 drivers/input/touchscreen/cyttsp_core.h |   91 +++++++++-
 drivers/input/touchscreen/cyttsp_i2c.c  |   95 ++++------
 drivers/input/touchscreen/cyttsp_spi.c  |  128 ++++++--------
 4 files changed, 274 insertions(+), 324 deletions(-)
drivers/input/touchscreen/cyttsp_core.c +95 -189
index 764efd6..ccdfa10 100644
@@ -72,86 +72,6 @@
 #define CY_MAX_FINGER               4
 #define CY_MAX_ID                   16
 
-struct cyttsp_tch {
-	__be16 x, y;
-	u8 z;
-} __packed;
-
-/* TrueTouch Standard Product Gen3 interface definition */
-struct cyttsp_xydata {
-	u8 hst_mode;
-	u8 tt_mode;
-	u8 tt_stat;
-	struct cyttsp_tch tch1;
-	u8 touch12_id;
-	struct cyttsp_tch tch2;
-	u8 gest_cnt;
-	u8 gest_id;
-	struct cyttsp_tch tch3;
-	u8 touch34_id;
-	struct cyttsp_tch tch4;
-	u8 tt_undef[3];
-	u8 act_dist;
-	u8 tt_reserved;
-} __packed;
-
-/* TTSP System Information interface definition */
-struct cyttsp_sysinfo_data {
-	u8 hst_mode;
-	u8 mfg_cmd;
-	u8 mfg_stat;
-	u8 cid[3];
-	u8 tt_undef1;
-	u8 uid[8];
-	u8 bl_verh;
-	u8 bl_verl;
-	u8 tts_verh;
-	u8 tts_verl;
-	u8 app_idh;
-	u8 app_idl;
-	u8 app_verh;
-	u8 app_verl;
-	u8 tt_undef[5];
-	u8 scn_typ;
-	u8 act_intrvl;
-	u8 tch_tmout;
-	u8 lp_intrvl;
-};
-
-/* TTSP Bootloader Register Map interface definition */
-#define CY_BL_CHKSUM_OK 0x01
-struct cyttsp_bootloader_data {
-	u8 bl_file;
-	u8 bl_status;
-	u8 bl_error;
-	u8 blver_hi;
-	u8 blver_lo;
-	u8 bld_blver_hi;
-	u8 bld_blver_lo;
-	u8 ttspver_hi;
-	u8 ttspver_lo;
-	u8 appid_hi;
-	u8 appid_lo;
-	u8 appver_hi;
-	u8 appver_lo;
-	u8 cid_0;
-	u8 cid_1;
-	u8 cid_2;
-};
-
-struct cyttsp {
-	struct device *dev;
-	int irq;
-	struct input_dev *input;
-	char phys[32];
-	const struct cyttsp_platform_data *platform_data;
-	const struct cyttsp_bus_ops *bus_ops;
-	struct cyttsp_bootloader_data bl_data;
-	struct cyttsp_sysinfo_data sysinfo_data;
-	struct completion bl_ready;
-	enum cyttsp_powerstate power_state;
-};
-
 static const u8 bl_command[] = {
 	0x00,			/* file offset */
 	0xFF,			/* command */
@@ -242,9 +162,9 @@ static int cyttsp_exit_bl_mode(struct cyttsp *ts)
 	u8 bl_cmd[sizeof(bl_command)];
 
 	memcpy(bl_cmd, bl_command, sizeof(bl_command));
-	if (ts->platform_data->bl_keys)
+	if (ts->pdata->bl_keys)
 		memcpy(&bl_cmd[sizeof(bl_command) - CY_NUM_BL_KEYS],
-			ts->platform_data->bl_keys, sizeof(bl_command));
+			ts->pdata->bl_keys, sizeof(bl_command));
 
 	retval = ttsp_write_block_data(ts, CY_REG_BASE,
 		sizeof(bl_cmd), (void *)bl_cmd);
@@ -324,15 +244,15 @@ static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
 {
 	int retval = 0;
 
-	if (ts->platform_data->act_intrvl != CY_ACT_INTRVL_DFLT ||
-		ts->platform_data->tch_tmout != CY_TCH_TMOUT_DFLT ||
-		ts->platform_data->lp_intrvl != CY_LP_INTRVL_DFLT) {
+	if (ts->pdata->act_intrvl != CY_ACT_INTRVL_DFLT ||
+		ts->pdata->tch_tmout != CY_TCH_TMOUT_DFLT ||
+		ts->pdata->lp_intrvl != CY_LP_INTRVL_DFLT) {
 
 		u8 intrvl_ray[3];
 
-		intrvl_ray[0] = ts->platform_data->act_intrvl;
-		intrvl_ray[1] = ts->platform_data->tch_tmout;
-		intrvl_ray[2] = ts->platform_data->lp_intrvl;
+		intrvl_ray[0] = ts->pdata->act_intrvl;
+		intrvl_ray[1] = ts->pdata->tch_tmout;
+		intrvl_ray[2] = ts->pdata->lp_intrvl;
 
 		/* set intrvl registers */
 		retval = ttsp_write_block_data(ts,
@@ -366,7 +286,7 @@ static int cyttsp_act_dist_setup(struct cyttsp *ts)
 	u8 act_dist_setup;
 
 	/* Init gesture; active distance setup */
-	act_dist_setup = ts->platform_data->act_dist;
+	act_dist_setup = ts->pdata->act_dist;
 	retval = ttsp_write_block_data(ts, CY_REG_ACT_DIST,
 		sizeof(act_dist_setup), &act_dist_setup);
 
@@ -439,7 +359,7 @@ static int cyttsp_handle_tchdata(struct cyttsp *ts)
 		return 0;
 
 	/* provide flow control handshake */
-	if (ts->platform_data->use_hndshk)
+	if (ts->pdata->use_hndshk)
 		if (cyttsp_hndshk(ts, xy_data.hst_mode))
 			return 0;
 
@@ -537,17 +457,8 @@ static int cyttsp_power_on(struct cyttsp *ts)
 {
 	int retval = 0;
 
-	if (!ts)
-		return -ENOMEM;
-
 	ts->power_state = CY_BL_STATE;
-
-	/* enable interrupts */
-	retval = request_threaded_irq(ts->irq, NULL, cyttsp_irq,
-		IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-		ts->platform_data->name, ts);
-	if (retval < 0)
-		goto bypass;
+	enable_irq(ts->irq);
 
 	retval = cyttsp_soft_reset(ts);
 	if (retval == 0)
@@ -593,20 +504,19 @@ bypass:
 }
 
 #ifdef CONFIG_PM_SLEEP
-int cyttsp_resume(void *handle)
+int cyttsp_resume(struct cyttsp *ts)
 {
-	struct cyttsp *ts = handle;
 	int retval = 0;
 	struct cyttsp_xydata xydata;
 
 	if (!ts)
 		return retval;
 
-	if (ts->platform_data->use_sleep && (ts->power_state !=
+	if (ts->pdata->use_sleep && (ts->power_state !=
 					     CY_ACTIVE_STATE)) {
 
-		if (ts->platform_data->wakeup)
-			retval = ts->platform_data->wakeup();
+		if (ts->pdata->wakeup)
+			retval = ts->pdata->wakeup();
 		else
 			retval = -ENOSYS;
 
@@ -624,15 +534,14 @@ int cyttsp_resume(void *handle)
 }
 EXPORT_SYMBOL_GPL(cyttsp_resume);
 
-int cyttsp_suspend(void *handle)
+int cyttsp_suspend(struct cyttsp *ts)
 {
-	struct cyttsp *ts = handle;
 	u8 sleep_mode = 0;
 	int retval = 0;
 
-	if (ts->platform_data->use_sleep &&
+	if (ts->pdata->use_sleep &&
 		(ts->power_state == CY_ACTIVE_STATE)) {
-		sleep_mode = ts->platform_data->use_sleep;
+		sleep_mode = ts->pdata->use_sleep;
 		retval = ttsp_write_block_data(ts,
 			CY_REG_BASE, sizeof(sleep_mode), &sleep_mode);
 		if (retval >= 0)
@@ -651,115 +560,112 @@ static int cyttsp_open(struct input_dev *dev)
 	return cyttsp_power_on(ts);
 }
 
-void cyttsp_core_release(void *handle)
-{
-	struct cyttsp *ts = handle;
-
-	if (ts) {
-		free_irq(ts->irq, ts);
-		input_unregister_device(ts->input);
-		if (ts->platform_data->exit)
-			ts->platform_data->exit();
-		kfree(ts);
-	}
-}
-EXPORT_SYMBOL_GPL(cyttsp_core_release);
-
 static void cyttsp_close(struct input_dev *dev)
 {
 	struct cyttsp *ts = input_get_drvdata(dev);
 
-	free_irq(ts->irq, ts);
+	disable_irq(ts->irq);
 }
 
-void *cyttsp_core_init(const struct cyttsp_bus_ops *bus_ops,
-		       struct device *dev, int irq)
+struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
+			    struct device *dev, int irq, size_t xfer_buf_size)
 {
-	struct input_dev *input_device;
-	int ret;
-
-	struct cyttsp *ts = kzalloc(sizeof(*ts), GFP_KERNEL);
-
-	if (!ts) {
-		pr_err("%s: Error, kzalloc\n", __func__);
-		goto error_alloc_data;
+	const struct cyttsp_platform_data *pdata = dev->platform_data;
+	struct cyttsp *ts;
+	struct input_dev *input_dev;
+	int error;
+
+	if (!dev || !bus_ops || !pdata || !pdata->name || irq <= 0) {
+		error = -EINVAL;
+		goto err_out;
 	}
 
-	if (dev == NULL || bus_ops == NULL) {
-		kfree(ts);
-		goto error_alloc_data;
+	ts = kzalloc(sizeof(*ts) + xfer_buf_size, GFP_KERNEL);
+	input_dev = input_allocate_device();
+	if (!ts || !input_dev) {
+		error = -ENOMEM;
+		goto err_free_mem;
 	}
 
 	ts->dev = dev;
-	ts->platform_data = dev->platform_data;
+	ts->input = input_dev;
+	ts->pdata = pdata;
 	ts->bus_ops = bus_ops;
+	ts->irq = irq;
+
 	init_completion(&ts->bl_ready);
+	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
 
-	if (ts->platform_data->init) {
-		if (ts->platform_data->init()) {
-			dev_dbg(ts->dev, "%s: Error, platform init failed!\n",
-				__func__);
-			goto error_init;
+	if (pdata->init) {
+		error = pdata->init();
+		if (error) {
+			dev_err(ts->dev, "platform init failed, err: %d\n",
+				error);
+			goto err_free_mem;
 		}
 	}
 
-	ts->irq = irq;
-	if (ts->irq <= 0) {
-		dev_dbg(ts->dev, "%s: Error, failed to allocate irq\n",
-			__func__);
-			goto error_init;
-	}
+	input_dev->name = pdata->name;
+	input_dev->phys = ts->phys;
+	input_dev->id.bustype = bus_ops->bustype;
+	input_dev->dev.parent = ts->dev;
 
-	/* Create the input device and register it. */
-	input_device = input_allocate_device();
-	if (!input_device) {
-		dev_dbg(ts->dev, "%s: Error, failed to allocate input device\n",
-			__func__);
-		goto error_input_allocate_device;
-	}
+	input_dev->open = cyttsp_open;
+	input_dev->close = cyttsp_close;
 
-	ts->input = input_device;
-	snprintf(ts->phys, sizeof(ts->phys), "%s/input0", dev_name(dev));
+	input_set_drvdata(input_dev, ts);
 
-	input_device->name = ts->platform_data->name;
-	input_device->phys = ts->phys;
-	input_device->id.bustype = bus_ops->bustype;
-	input_device->dev.parent = ts->dev;
-	input_device->open = cyttsp_open;
-	input_device->close = cyttsp_close;
-	input_set_drvdata(input_device, ts);
-
-	__set_bit(EV_ABS, input_device->evbit);
-	input_set_abs_params(input_device, ABS_MT_POSITION_X,
-			     0, ts->platform_data->maxx, 0, 0);
-	input_set_abs_params(input_device, ABS_MT_POSITION_Y,
-			     0, ts->platform_data->maxy, 0, 0);
-	input_set_abs_params(input_device, ABS_MT_TOUCH_MAJOR,
+	__set_bit(EV_ABS, input_dev->evbit);
+	input_set_abs_params(input_dev, ABS_MT_POSITION_X,
+			     0, pdata->maxx, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
+			     0, pdata->maxy, 0, 0);
+	input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
 			     0, CY_MAXZ, 0, 0);
 
-	input_mt_init_slots(input_device, CY_MAX_ID);
+	input_mt_init_slots(input_dev, CY_MAX_ID);
 
-	ret = input_register_device(input_device);
-	if (ret) {
-		dev_err(ts->dev, "%s: Error, failed to register input device: %d\n",
-			__func__, ret);
-		goto error_input_register_device;
+	error = request_threaded_irq(ts->irq, NULL, cyttsp_irq,
+				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+				     pdata->name, ts);
+	if (error) {
+		dev_err(ts->dev, "failed to request IRQ %d, err: %d\n",
+			ts->irq, error);
+		goto err_platform_exit;
 	}
+	disable_irq(ts->irq);
 
-	goto no_error;
+	error = input_register_device(input_dev);
+	if (error) {
+		dev_err(ts->dev, "failed to register input device: %d\n",
+			error);
+		goto err_free_irq;
+	}
 
-error_input_register_device:
-	input_free_device(input_device);
-error_input_allocate_device:
-	if (ts->platform_data->exit)
-		ts->platform_data->exit();
-error_init:
-	kfree(ts);
-error_alloc_data:
-no_error:
 	return ts;
+
+err_free_irq:
+	free_irq(ts->irq, ts);
+err_platform_exit:
+	if (pdata->exit)
+		pdata->exit();
+err_free_mem:
+	input_free_device(input_dev);
+	kfree(ts);
+err_out:
+	return ERR_PTR(error);
+}
+EXPORT_SYMBOL_GPL(cyttsp_probe);
+
+void cyttsp_remove(struct cyttsp *ts)
+{
+	free_irq(ts->irq, ts);
+	input_unregister_device(ts->input);
+	if (ts->pdata->exit)
+		ts->pdata->exit();
+	kfree(ts);
 }
-EXPORT_SYMBOL_GPL(cyttsp_core_init);
+EXPORT_SYMBOL_GPL(cyttsp_remove);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("Cypress TrueTouch(R) Standard touchscreen driver core");
drivers/input/touchscreen/cyttsp_core.h +86 -5

105 lines not on this page · raw message

drivers/input/touchscreen/cyttsp_i2c.c +37 -58

184 lines not on this page · raw message

drivers/input/touchscreen/cyttsp_spi.c +56 -72

242 lines not on this page · raw message

author maintainer
#7 lore raw

PATCH 7/7 Input: cyttsp - consolidate PM methods

In reply to Dmitry Torokhov

The PM methods are basically the same for SPI and I2C busses, so let's use the same dev_pm_ops for both of them.

---

 drivers/input/touchscreen/cyttsp_core.c |   22 ++++++++++------------
 drivers/input/touchscreen/cyttsp_core.h |    6 ++----
 drivers/input/touchscreen/cyttsp_i2c.c  |   22 +---------------------
 drivers/input/touchscreen/cyttsp_spi.c  |   20 +-------------------
 4 files changed, 14 insertions(+), 56 deletions(-)
drivers/input/touchscreen/cyttsp_core.c +10 -12
index ccdfa10..cd0fe40 100644
@@ -504,16 +504,13 @@ bypass:
 }
 
 #ifdef CONFIG_PM_SLEEP
-int cyttsp_resume(struct cyttsp *ts)
+static int cyttsp_resume(struct device *dev)
 {
+	struct cyttsp *ts = dev_get_drvdata(dev);
 	int retval = 0;
 	struct cyttsp_xydata xydata;
 
-	if (!ts)
-		return retval;
-
-	if (ts->pdata->use_sleep && (ts->power_state !=
-					     CY_ACTIVE_STATE)) {
+	if (ts->pdata->use_sleep && ts->power_state != CY_ACTIVE_STATE) {
 
 		if (ts->pdata->wakeup)
 			retval = ts->pdata->wakeup();
@@ -532,16 +529,15 @@ int cyttsp_resume(struct cyttsp *ts)
 
 	return retval;
 }
-EXPORT_SYMBOL_GPL(cyttsp_resume);
 
-int cyttsp_suspend(struct cyttsp *ts)
+static int cyttsp_suspend(struct device *dev)
 {
+	struct cyttsp *ts = dev_get_drvdata(dev);
 	u8 sleep_mode = 0;
 	int retval = 0;
 
-	if (ts->pdata->use_sleep &&
-		(ts->power_state == CY_ACTIVE_STATE)) {
-		sleep_mode = ts->pdata->use_sleep;
+	if (ts->pdata->use_sleep && ts->power_state == CY_ACTIVE_STATE) {
+		sleep_mode = ts->platform_data->use_sleep;
 		retval = ttsp_write_block_data(ts,
 			CY_REG_BASE, sizeof(sleep_mode), &sleep_mode);
 		if (retval >= 0)
@@ -550,9 +546,11 @@ int cyttsp_suspend(struct cyttsp *ts)
 
 	return retval;
 }
-EXPORT_SYMBOL_GPL(cyttsp_suspend);
 #endif
 
+SIMPLE_DEV_PM_OPS(cyttsp_pm_ops, cyttsp_suspend, cyttsp_resume);
+EXPORT_SYMBOL_GPL(cyttsp_pm_ops);
+
 static int cyttsp_open(struct input_dev *dev)
 {
 	struct cyttsp *ts = input_get_drvdata(dev);
drivers/input/touchscreen/cyttsp_core.h +2 -4
index 1d9f185..5087b2b 100644
@@ -134,9 +134,7 @@ struct cyttsp {
 struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 			    struct device *dev, int irq, size_t xfer_buf_size);
 void cyttsp_remove(struct cyttsp *ts);
-#ifdef CONFIG_PM_SLEEP
-int cyttsp_resume(struct cyttsp *ts);
-int cyttsp_suspend(struct cyttsp *ts);
-#endif
+
+extern const struct dev_pm_ops cyttsp_pm_ops;
 
 #endif /* __CYTTSP_CORE_H__ */
drivers/input/touchscreen/cyttsp_i2c.c +1 -21
index b476441..2b6acf4 100644
@@ -107,26 +107,6 @@ static int __devexit cyttsp_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int cyttsp_i2c_suspend(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct cyttsp *ts = i2c_get_clientdata(client);
-
-	return cyttsp_suspend(ts);
-}
-
-static int cyttsp_i2c_resume(struct device *dev)
-{
-	struct i2c_client *client = to_i2c_client(dev);
-	struct cyttsp *ts = i2c_get_clientdata(client);
-
-	return cyttsp_resume(ts);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(cyttsp_i2c_pm, cyttsp_i2c_suspend, cyttsp_i2c_resume);
-
 static const struct i2c_device_id cyttsp_i2c_id[] = {
 	{ CY_I2C_NAME, 0 },
 	{ }
@@ -137,7 +117,7 @@ static struct i2c_driver cyttsp_i2c_driver = {
 	.driver = {
 		.name	= CY_I2C_NAME,
 		.owner	= THIS_MODULE,
-		.pm	= &cyttsp_i2c_pm,
+		.pm	= &cyttsp_pm_ops,
 	},
 	.probe		= cyttsp_i2c_probe,
 	.remove		= __devexit_p(cyttsp_i2c_remove),
drivers/input/touchscreen/cyttsp_spi.c +1 -19
index eafa357..61a2e6c 100644
@@ -215,29 +215,11 @@ static int __devexit cyttsp_spi_remove(struct spi_device *spi)
 	return 0;
 }
 
-#ifdef CONFIG_PM_SLEEP
-static int cyttsp_spi_suspend(struct device *dev)
-{
-	struct cyttsp *ts = dev_get_drvdata(dev);
-
-	return cyttsp_suspend(ts);
-}
-
-static int cyttsp_spi_resume(struct device *dev)
-{
-	struct cyttsp *ts = dev_get_drvdata(dev);
-
-	return cyttsp_resume(ts);
-}
-#endif
-
-static SIMPLE_DEV_PM_OPS(cyttsp_spi_pm, cyttsp_spi_suspend, cyttsp_spi_resume);
-
 static struct spi_driver cyttsp_spi_driver = {
 	.driver = {
 		.name	= CY_SPI_NAME,
 		.owner	= THIS_MODULE,
-		.pm	= &cyttsp_spi_pm,
+		.pm	= &cyttsp_pm_ops,
 	},
 	.probe	= cyttsp_spi_probe,
 	.remove = __devexit_p(cyttsp_spi_remove),
#8 lore raw
In reply to Dmitry Torokhov
Quoted 6 lines · Dmitry Torokhov

Hi Javier,

I am sending a few patches that I made while trying to understand the Cypress TTSP driver. I am still not quite happy with the SPI read method and I am also wondering if cyttsp_power_on could be made less messy.

Hi Dmitry,

Thank you very much for the review and the patches. One question, when sending new versions of the patch-set, do you want me to keep the history of your patches or should I merge all of them and submit just three patches (core, i2c, spi) to make easier future revisions?

Sure, Kevin will cleanup the SPI read method and I will make cyttsp_power_on more cleaner.

Quoted 4 lines

Current open/close methods seem to be not very useful: even though we stop interrupts we do not put the chip into low power mode. Is there a way to do so?

Yes, the controller can be put to sleep (low power mode). I will add that to the close function for the next version of the patch-set.

Quoted 3 lines

Regarding PM methods - why do we have conditional 'use sleep' and what exactly wakeup() method is supposed to do? Why is it a platform method?

It was meant to let each board to decide if it wants to go sleep and to define a specific handler for wakeup. This is for example the board file of the OMAP Encore machine type (B & N Nook's color)

static struct cyttsp_platform_data cyttsp_i2c_platform_data = {
.wakeup = cyttsp_i2c_wakeup,
.init = cyttsp_i2c_init,
.....
}

In the same way it exists an init board specific function that gets called from cyttsp_core_init() if the board has defined one:

void *cyttsp_core_init(struct cyttsp_bus_ops *bus_ops,
struct device *dev, int irq)
{
....

	if (ts->platform_data->init) {
		if (ts->platform_data->init()) {
			dev_dbg(ts->dev, "%s: Error, platform init failed!\n",
				__func__);
			goto error_init;
		}
	}

....
}

This is necessary because each board may need to configure differently the connection with the chip. For example, OMAP boards will have to configure the mux pins and so on.

Is this correct? or the driver should not have these handlers and trust that the platform specific code did all the set up before?

Again, thank you for the review and your comments.

Best regards,

Signature · 7 lines
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#9 lore raw
Quoted 9 lines · Javier Martinez Canillas
Quoted 6 lines · Dmitry Torokhov

Hi Javier,

I am sending a few patches that I made while trying to understand the Cypress TTSP driver. I am still not quite happy with the SPI read method and I am also wondering if cyttsp_power_on could be made less messy.

Quoted 6 lines

Hi Dmitry,

Thank you very much for the review and the patches. One question, when sending new versions of the patch-set, do you want me to keep the history of your patches or should I merge all of them and submit just three patches (core, i2c, spi) to make easier future revisions?

You may merge them, I think it will be easier.

Quoted 3 lines

Sure, Kevin will cleanup the SPI read method and I will make cyttsp_power_on more cleaner.

Thanks.

Quoted 8 lines
Quoted 5 lines

Current open/close methods seem to be not very useful: even though we stop interrupts we do not put the chip into low power mode. Is there a way to do so?

Yes, the controller can be put to sleep (low power mode). I will add that to the close function for the next version of the patch-set.

Excellent.

Quoted 7 lines
Quoted 4 lines

Regarding PM methods - why do we have conditional 'use sleep' and what exactly wakeup() method is supposed to do? Why is it a platform method?

It was meant to let each board to decide if it wants to go sleep and to define a specific handler for wakeup.

Why would a board not want to go to sleep? Normally boards want to specify whether they want to have device as a wakeup source and such devices, instead of shutting down in suspend method, just configure their IRQ as a wakeup IRQ and that is it.

Quoted 5 lines

This is for example the board
file of the OMAP Encore machine type (B & N Nook's color)

static struct cyttsp_platform_data cyttsp_i2c_platform_data = {
.wakeup = cyttsp_i2c_wakeup,

OK, so in this particular case what does cyttsp_i2c_wakeup actually does?

Quoted 21 lines

.init = cyttsp_i2c_init,
.....
}

In the same way it exists an init board specific function that gets called from cyttsp_core_init() if the board has defined one:

void *cyttsp_core_init(struct cyttsp_bus_ops *bus_ops,
struct device *dev, int irq)
{
....

	if (ts->platform_data->init) {
		if (ts->platform_data->init()) {
			dev_dbg(ts->dev, "%s: Error, platform init failed!\n",
				__func__);
			goto error_init;
		}
	}

....
}

Quoted 6 lines

This is necessary because each board may need to configure differently the connection with the chip. For example, OMAP boards will have to configure the mux pins and so on.

Is this correct? or the driver should not have these handlers and trust that the platform specific code did all the set up before?

I think it depends on the kind of set up is happening. Static setup (such as registering memory regsions, configuring IRQ type, etc) is probably done upfront; if you need to talk to the hardware then custom method is fine.

Thanks.

Signature · 1 line
Dmitry
#10 lore raw
Quoted 10 lines · Dmitry Torokhov
Quoted 9 lines · Javier Martinez Canillas
Quoted 6 lines · Dmitry Torokhov

Hi Javier,

I am sending a few patches that I made while trying to understand the Cypress TTSP driver. I am still not quite happy with the SPI read method and I am also wondering if cyttsp_power_on could be made less messy.

Quoted 9 lines
Quoted 6 lines

Hi Dmitry,

Thank you very much for the review and the patches. One question, when sending new versions of the patch-set, do you want me to keep the history of your patches or should I merge all of them and submit just three patches (core, i2c, spi) to make easier future revisions?

You may merge them, I think it will be easier.

Ok, thanks.

Quoted 22 lines
Quoted 3 lines

Sure, Kevin will cleanup the SPI read method and I will make cyttsp_power_on more cleaner.

Thanks.

Quoted 8 lines
Quoted 5 lines

Current open/close methods seem to be not very useful: even though we stop interrupts we do not put the chip into low power mode. Is there a way to do so?

Yes, the controller can be put to sleep (low power mode). I will add that to the close function for the next version of the patch-set.

Excellent.

Quoted 5 lines
Quoted 4 lines

Regarding PM methods - why do we have conditional 'use sleep' and what exactly wakeup() method is supposed to do? Why is it a platform method?

Quoted 8 lines
Quoted 2 lines

It was meant to let each board to decide if it wants to go sleep and to define a specific handler for wakeup.

Why would a board not want to go to sleep? Normally boards want to specify whether they want to have device as a wakeup source and such devices, instead of shutting down in suspend method, just configure their IRQ as a wakeup IRQ and that is it.

Yes, you are right. Also, the chip has different low power modes (light, medium and deep) and use_sleep was also thought so board code could decide on which low power mode the device has to enter on suspend.

But, yes. The sleep shouldn't be conditional and we should have a low power mode by default. Also if the user defines a wakeup() handler, then the device should enter in a low power mode where interrupts are still fired (so the board can use this device as a wakeup source).

Quoted 9 lines
Quoted 5 lines

This is for example the board
file of the OMAP Encore machine type (B & N Nook's color)

static struct cyttsp_platform_data cyttsp_i2c_platform_data = { .wakeup = cyttsp_i2c_wakeup,

OK, so in this particular case what does cyttsp_i2c_wakeup actually does?

In this case in particular, nothing...

static int cyttsp_i2c_wakeup(void)

{
        return 0;
}

I think is because the resume code returned -ENOSYS if use_sleep was set and not wakeup handler was defined. So a dummy handler was defined.

int cyttsp_resume(void *handle)
{
...

		if (ts->platform_data->wakeup)
			retval = ts->platform_data->wakeup();
		else
			retval = -ENOSYS;

...
}

Quoted 25 lines
Quoted 25 lines

        .init = cyttsp_i2c_init,
.....
}

In the same way it exists an init board specific function that gets called from cyttsp_core_init() if the board has defined one:

void *cyttsp_core_init(struct cyttsp_bus_ops *bus_ops,
                     struct device *dev, int irq)
{
....
      if (ts->platform_data->init) {
              if (ts->platform_data->init()) {
                      dev_dbg(ts->dev, "%s: Error, platform init failed!\n", __func__);
                      goto error_init;
              }
      }
....
}

This is necessary because each board may need to configure differently the connection with the chip. For example, OMAP boards will have to configure the mux pins and so on.

Quoted 8 lines
Quoted 2 lines

Is this correct? or the driver should not have these handlers and trust that the platform specific code did all the set up before?

I think it depends on the kind of set up is happening. Static setup (such as registering memory regsions, configuring IRQ type, etc) is probably done upfront; if you need to talk to the hardware then custom method is fine.

Great, I'll keep this init handler then.

Quoted 5 lines

Thanks.

--
Dmitry

Thank you and best regards,

Signature · 7 lines
Javier Martínez Canillas
(+34) 682 39 81 69
Barcelona, Spain
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html