Skip to contentSkip to conversation

Add device tree support to the cyttsp driver

PATCH Superseded Oreste Salerno 2 participants 6 messages Dec 27, 2015

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Add device tree support to the cyttsp driver

This set of patches adds support to the cyttsp touchscreen driver to retrieve platform data details from the device tree. Additionally, they define a default init function that performs a hard reset of the chip on boot.

Oreste Salerno (3):
Input: cyttsp - remove unused irq_gpio from platform_data
Input: cyttsp - add device tree support
Input: cyttsp - add default init function

 .../bindings/input/touchscreen/cyttsp.txt          |  73 +++++++++++++
 drivers/input/touchscreen/cyttsp_core.c            | 120 +++++++++++++++++++--
 include/linux/input/cyttsp.h                       |   4 +-
 3 files changed, 189 insertions(+), 8 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt
Signature · 1 line
1.9.1
#5 lore raw

PATCH 3/3 Input: cyttsp - add default init function

When using device trees, it's not possible to assign an init() function in the platform data.
In case the init function has not been assigned, attempt to perform a hard reset of the chip, using reset gpio defined in the platform data / device tree.

---
 drivers/input/touchscreen/cyttsp_core.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/input/touchscreen/cyttsp_core.c +12 -0
index 54f6e51..e2589d3 100644
@@ -238,6 +238,16 @@ static int cyttsp_set_sysinfo_regs(struct cyttsp *ts)
 	return retval;
 }
 
+static void cyttsp_hard_reset(struct cyttsp *ts)
+{
+	if (ts->pdata->reset_gpio) {
+		gpiod_set_value_cansleep(ts->pdata->reset_gpio, 1);
+		msleep(CY_DELAY_DFLT);
+		gpiod_set_value_cansleep(ts->pdata->reset_gpio, 0);
+		msleep(CY_DELAY_DFLT);
+	}
+}
+
 static int cyttsp_soft_reset(struct cyttsp *ts)
 {
 	unsigned long timeout;
@@ -659,6 +669,8 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
 				error);
 			goto err_free_mem;
 		}
+	} else {
+		cyttsp_hard_reset(ts);
 	}
 
 	input_dev->name = pdata->name;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/3 Input: cyttsp - remove unused irq_gpio from platform_data

In reply to Oreste Salerno

This field is not being used and the irq is anyway passed via the 'irq' parameter to cyttsp_probe.

---
 include/linux/input/cyttsp.h | 1 -
 1 file changed, 1 deletion(-)
include/linux/input/cyttsp.h +0 -1
index 5af7c66..d7c2520 100644
@@ -51,7 +51,6 @@ struct cyttsp_platform_data {
 	int (*init)(void);
 	void (*exit)(void);
 	char *name;
-	s16 irq_gpio;
 	u8 *bl_keys;
 };
 
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/3 Input: cyttsp - add device tree support

In reply to Oreste Salerno

Add support for retrieving the platform data from the device tree.

---
 .../bindings/input/touchscreen/cyttsp.txt          |  73 ++++++++++++++
 drivers/input/touchscreen/cyttsp_core.c            | 108 +++++++++++++++++++--
 include/linux/input/cyttsp.h                       |   3 +
 3 files changed, 177 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt
Documentation/devicetree/bindings/input/touchscreen/cyttsp.txt new file +73 -0
new file mode 100644
index 0000000..8e0bcc73
@@ -0,0 +1,73 @@
+* Cypress cyttsp touchscreen controller
+
+Required properties:
+- compatible		: must be "cypress,cyttsp-i2c" or "cypress,cyttsp-spi"
+- reg			: Device address
+- spi-max-frequency 	: Maximum SPI clocking speed of the device (for cyttsp-spi)
+- interrupt-parent	: the phandle for the gpio controller
+			  (see interrupt binding[0]).
+- interrupts		: (gpio) interrupt to which the chip is connected
+			  (see interrupt binding[0]).
+- reset-gpios		: the reset gpio the chip is connected to
+			  (see GPIO binding[1] for more details).
+- maxx			: horizontal resolution of touchscreen (in pixels)
+- maxy			: vertical resolution of touchscreen (in pixels)
+- bootloader-key	: the bootloader key used to exit bootloader mode
+
+Optional properties:
+- use_hndshk		: enable handshake bit
+- act_dist		: active distance
+- act_intrvl		: active refresh interval in ms
+- tch_tmout		: active touch timeout in ms
+- lp_intrvl		: low power refresh interval in ms
+
+[0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+[1]: Documentation/devicetree/bindings/gpio/gpio.txt
+
+Example:
+	&i2c1 {
+		/* ... */
+		cyttsp@a {
+			compatible = "cypress,cyttsp-i2c";
+			reg = <0xa>;
+			interrupt-parent = <&msm_gpio>;
+			interrupts = <13 0x2008>;
+			reset-gpios = <&msm_gpio 12 0x00>;
+
+			maxx = <800>;
+			maxy = <480>;
+			bootloader-key = /bits/ 8 <0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08>;
+
+			use_hndshk;
+			act_dist = /bits/ 8 <0xF8>;
+			act_intrvl = /bits/ 8 <0x00>;
+			tch_tmout = /bits/ 8 <0xFF>;
+			lp_intrvl = /bits/ 8 <0x0A>;
+		};
+
+		/* ... */
+	};
+
+	&mcspi1 {
+		/* ... */
+		cyttsp@0 {
+			compatible = "cypress,cyttsp-spi";
+			spi-max-frequency = <6000000>;
+			reg = <0>;
+			interrupt-parent = <&msm_gpio>;
+			interrupts = <13 0x2008>;
+			reset-gpios = <&msm_gpio 12 0x00>;
+
+			maxx = <800>;
+			maxy = <480>;
+			bootloader-key = /bits/ 8 <0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08>;
+
+			use_hndshk;
+			act_dist = /bits/ 8 <0xF8>;
+			act_intrvl = /bits/ 8 <0x00>;
+			tch_tmout = /bits/ 8 <0xFF>;
+			lp_intrvl = /bits/ 8 <0x0A>;
+		};
+
+		/* ... */
+	};
drivers/input/touchscreen/cyttsp_core.c +101 -7

139 lines not on this page · raw message

include/linux/input/cyttsp.h +3 -0
index d7c2520..92a9d52 100644
@@ -29,6 +29,8 @@
 #ifndef _CYTTSP_H_
 #define _CYTTSP_H_
 
+#include <linux/gpio/consumer.h>
+
 #define CY_SPI_NAME "cyttsp-spi"
 #define CY_I2C_NAME "cyttsp-i2c"
 /* Active Power state scanning/processing refresh interval */
@@ -51,6 +53,7 @@ struct cyttsp_platform_data {
 	int (*init)(void);
 	void (*exit)(void);
 	char *name;
+	struct gpio_desc *reset_gpio;
 	u8 *bl_keys;
 };
 
Signature · 1 line
1.9.1
#3 lore raw

[PATCH] Input: fix err_cast.cocci warnings

drivers/input/touchscreen/cyttsp_core.c:637:9-16: WARNING: ERR_CAST can be used with pdata

drivers/input/touchscreen/cyttsp_core.c:637:9-16: WARNING: ERR_CAST can be used with pdata

Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...))

Generated by: scripts/coccinelle/api/err_cast.cocci

CC Oreste Salerno <[email protected]>

---

 cyttsp_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/cyttsp_core.c +1 -1
@@ -634,7 +634,7 @@ struct cyttsp *cyttsp_probe(const struct
 
 	pdata = cyttsp_get_platform_data(dev);
 	if (IS_ERR(pdata))
-		return ERR_PTR(PTR_ERR(pdata));
+		return ERR_CAST(pdata);
 
 	ts = kzalloc(sizeof(*ts) + xfer_buf_size, GFP_KERNEL);
 	input_dev = input_allocate_device();
#4 lore raw

Re: [PATCH 2/3] Input: cyttsp - add device tree support

In reply to Oreste Salerno
coccinelle warnings: (new ones prefixed by >>)

[if your patch is applied to the wrong git tree, please drop us a note to help improving the system] Hi Oreste,

[auto build test WARNING on input/next] [also build test WARNING on v4.4-rc6 next-20151223]

url:    https://github.com/0day-ci/linux/commits/Oreste-Salerno/Add-device-tree-support-to-the-cyttsp-driver/20151228-002949
base:   https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next

coccinelle warnings: (new ones prefixed by >>)

>> drivers/input/touchscreen/cyttsp_core.c:637:9-16: WARNING: ERR_CAST can be used with pdata

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation