devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Enable display and touchscreen for Vybrid Tower
@ 2016-06-24 19:44 Anthony Felice
  2016-06-24 19:44 ` [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller Anthony Felice
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Anthony Felice @ 2016-06-24 19:44 UTC (permalink / raw)
  To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A,
	tony.felice-jEh4hwF5bVhBDgjK7y7TUQ
  Cc: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, stefan-XLVq0VzYD2Y,
	linux-I+IVW8TIWO2tmTQ+vhA3Yw, fabio.estevam-3arQi8VN3Tc,
	geert-Td1EMuHUCqxL1ZNQvxDV9g, mwelling-EkmVulN54Sk,
	sre-DgEjT+Ai2ygdnm+yROfE0A,
	damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/,
	maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

This patchset enables the TWR-LCD-RGB display and the CRTouch-based touchscreen
on the Vybrid Tower platform. Both display and touchscreen have been tested and
verified working with this patchset on a Rev J Vybrid Tower system.

Anthony Felice (4):
  ARM: dts: vf610-twr: Enable display controller
  input: touchscreen: crtouch_ts: Add driver
  ARM: dts: vf610-twr: Add crtouch node and pinmux
  ARM: imx_v6_v7_defconfig: enable useful configurations for Vybrid

 .../bindings/input/touchscreen/crtouch_ts.txt      |  14 ++
 arch/arm/boot/dts/vf610-twr.dts                    |  62 +++++
 arch/arm/configs/imx_v6_v7_defconfig               |   6 +-
 drivers/input/touchscreen/Kconfig                  |  10 +
 drivers/input/touchscreen/Makefile                 |   1 +
 drivers/input/touchscreen/crtouch_ts.c             | 279 +++++++++++++++++++++
 6 files changed, 368 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
 create mode 100644 drivers/input/touchscreen/crtouch_ts.c

-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller
  2016-06-24 19:44 [PATCH 0/4] Enable display and touchscreen for Vybrid Tower Anthony Felice
@ 2016-06-24 19:44 ` Anthony Felice
  2016-06-25 20:53   ` Stefan Agner
  2016-06-24 19:44 ` [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver Anthony Felice
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Anthony Felice @ 2016-06-24 19:44 UTC (permalink / raw)
  To: dri-devel, shawnguo, tony.felice
  Cc: dmitry.torokhov, robh+dt, mark.rutland, kernel, stefan, linux,
	fabio.estevam, geert, mwelling, sre, damien.riegel,
	maitysanchayan, linux-input, devicetree, linux-kernel,
	linux-arm-kernel

This adds nodes to enable tcon0 and dcu0 for the Vybrid Tower. These
are used to drive the Vybrid Tower TWR-LCD-RGB display. Also, a node
for the nec nl4827hc19-05b panel on the TWR-LCD-RGB display has been
added.

Signed-off-by: Anthony Felice <tony.felice@timesys.com>
---
 arch/arm/boot/dts/vf610-twr.dts | 48 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/arch/arm/boot/dts/vf610-twr.dts b/arch/arm/boot/dts/vf610-twr.dts
index cdc1007..ad1aff9 100644
--- a/arch/arm/boot/dts/vf610-twr.dts
+++ b/arch/arm/boot/dts/vf610-twr.dts
@@ -66,6 +66,10 @@
 		clock-frequency = <50000000>;
 	};
 
+	panel: panel {
+		compatible = "nec,nl4827hc19-05b";
+	};
+
 	regulators {
 		compatible = "simple-bus";
 		#address-cells = <1>;
@@ -134,6 +138,13 @@
 				 <&clks VF610_CLK_ENET_EXT>;
 };
 
+&dcu0 {
+	fsl,panel = <&panel>;
+	pinctrl-names = "default";
+	pinctrl-0 = <&pinctrl_dcu0>;
+	status = "okay";
+};
+
 &dspi0 {
 	bus-num = <0>;
 	pinctrl-names = "default";
@@ -210,6 +221,39 @@
 
 &iomuxc {
 	vf610-twr {
+		pinctrl_dcu0: dcu0grp {
+			fsl,pins = <
+				VF610_PAD_PTE0__DCU0_HSYNC	0x42
+				VF610_PAD_PTE1__DCU0_VSYNC	0x42
+				VF610_PAD_PTE2__DCU0_PCLK	0x42
+				VF610_PAD_PTE4__DCU0_DE		0x42
+				VF610_PAD_PTE5__DCU0_R0		0x42
+				VF610_PAD_PTE6__DCU0_R1		0x42
+				VF610_PAD_PTE7__DCU0_R2		0x42
+				VF610_PAD_PTE8__DCU0_R3		0x42
+				VF610_PAD_PTE9__DCU0_R4		0x42
+				VF610_PAD_PTE10__DCU0_R5	0x42
+				VF610_PAD_PTE11__DCU0_R6	0x42
+				VF610_PAD_PTE12__DCU0_R7	0x42
+				VF610_PAD_PTE13__DCU0_G0	0x42
+				VF610_PAD_PTE14__DCU0_G1	0x42
+				VF610_PAD_PTE15__DCU0_G2	0x42
+				VF610_PAD_PTE16__DCU0_G3	0x42
+				VF610_PAD_PTE17__DCU0_G4	0x42
+				VF610_PAD_PTE18__DCU0_G5	0x42
+				VF610_PAD_PTE19__DCU0_G6	0x42
+				VF610_PAD_PTE20__DCU0_G7	0x42
+				VF610_PAD_PTE21__DCU0_B0	0x42
+				VF610_PAD_PTE22__DCU0_B1	0x42
+				VF610_PAD_PTE23__DCU0_B2	0x42
+				VF610_PAD_PTE24__DCU0_B3	0x42
+				VF610_PAD_PTE25__DCU0_B4	0x42
+				VF610_PAD_PTE26__DCU0_B5	0x42
+				VF610_PAD_PTE27__DCU0_B6	0x42
+				VF610_PAD_PTE28__DCU0_B7	0x42
+			>;
+		};
+
 		pinctrl_adc0_ad5: adc0ad5grp {
 			fsl,pins = <
 				VF610_PAD_PTC30__ADC0_SE5		0xa1
@@ -370,6 +414,10 @@
 	status = "okay";
 };
 
+&tcon0 {
+	status = "okay";
+};
+
 &uart1 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&pinctrl_uart1>;
-- 
2.7.4

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

* [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver
  2016-06-24 19:44 [PATCH 0/4] Enable display and touchscreen for Vybrid Tower Anthony Felice
  2016-06-24 19:44 ` [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller Anthony Felice
@ 2016-06-24 19:44 ` Anthony Felice
       [not found]   ` <1466797486-31558-3-git-send-email-tony.felice-jEh4hwF5bVhBDgjK7y7TUQ@public.gmane.org>
                     ` (2 more replies)
  2016-06-24 19:44 ` [PATCH 3/4] ARM: dts: vf610-twr: Add crtouch node and pinmux Anthony Felice
  2016-06-24 19:44 ` [PATCH 4/4] ARM: imx_v6_v7_defconfig: enable useful configurations for Vybrid Anthony Felice
  3 siblings, 3 replies; 11+ messages in thread
From: Anthony Felice @ 2016-06-24 19:44 UTC (permalink / raw)
  To: dri-devel, shawnguo, tony.felice
  Cc: dmitry.torokhov, robh+dt, mark.rutland, kernel, stefan, linux,
	fabio.estevam, geert, mwelling, sre, damien.riegel,
	maitysanchayan, linux-input, devicetree, linux-kernel,
	linux-arm-kernel

Add driver for the Vybrid Tower CRTouch-based touchscreen. This is
required for the touchscreen on the TWR-LCD-RGB to work on the Vybrid
Tower platform.

There is a known issue with this driver: rarely, SW1 on the TWR-LCD-RGB
module needs to be pressed in order for the touchscreen to begin
functioning.

Signed-off-by: Anthony Felice <tony.felice@timesys.com>
---
 .../bindings/input/touchscreen/crtouch_ts.txt      |  14 ++
 drivers/input/touchscreen/Kconfig                  |  10 +
 drivers/input/touchscreen/Makefile                 |   1 +
 drivers/input/touchscreen/crtouch_ts.c             | 279 +++++++++++++++++++++
 4 files changed, 304 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
 create mode 100644 drivers/input/touchscreen/crtouch_ts.c

diff --git a/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
new file mode 100644
index 0000000..cfb966c
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
@@ -0,0 +1,14 @@
+* Freescale CRTOUCH based touchscreen
+
+Required Properties:
+- compatible must be fsl,crtouch_ts
+- reg: I2C address of the touchscreen
+- irq-gpio: GPIO to use as event IRQ
+
+Example:
+
+	touch: crtouch@49 {
+		compatible = "fsl,crtouch_ts";
+		reg = <0x49>;
+		irq-gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
+	};
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 8ecdc38..799e342 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1155,4 +1155,14 @@ config TOUCHSCREEN_ROHM_BU21023
 	  To compile this driver as a module, choose M here: the
 	  module will be called bu21023_ts.
 
+config TOUCHSCREEN_CRTOUCH
+	tristate "Freescale CRTOUCH based touchscreen"
+	depends on I2C
+	help
+	  Say Y here if you have a CRTOUCH based touchscreen
+	  controller.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called crtouch_ts.
+
 endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index f42975e..8cb0a7a 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -95,3 +95,4 @@ obj-$(CONFIG_TOUCHSCREEN_TPS6507X)	+= tps6507x-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ZFORCE)	+= zforce_ts.o
 obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)	+= colibri-vf50-ts.o
 obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023)	+= rohm_bu21023.o
+obj-$(CONFIG_TOUCHSCREEN_CRTOUCH)	+= crtouch_ts.o
diff --git a/drivers/input/touchscreen/crtouch_ts.c b/drivers/input/touchscreen/crtouch_ts.c
new file mode 100644
index 0000000..bb87a8e
--- /dev/null
+++ b/drivers/input/touchscreen/crtouch_ts.c
@@ -0,0 +1,279 @@
+/*
+ * Driver for Freescale Semiconductor CRTOUCH - A Resistive and Capacitive
+ * touch device with i2c interface
+ *
+ * Copyright 2012 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/input.h>
+#include <linux/input/mt.h>
+#include <linux/slab.h>
+#include <linux/bitops.h>
+#include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+
+/* Resistive touch sense status registers */
+#define RES_STA_ERROR			0x00
+#define RES_STA_STATUS1			0x01
+#define	RES_STA_STATUS2			0x02
+#define RES_STA_X_MSB			0x03
+#define RES_STA_X_LSB			0x04
+#define RES_STA_Y_MSB			0x05
+#define RES_STA_Y_LSB			0x06
+#define RES_STA_PRES_MSB		0x07
+#define RES_STA_RRES_LSB		0x08
+#define RES_STA_FIFO_STATUS		0x09
+#define RES_STA_FIFO_X_MSB		0x0a
+#define RES_STA_FIFO_X_LSB		0x0b
+#define RES_STA_FIFO_Y_MSB		0x0c
+#define RES_STA_FIFO_Y_LSB		0x0d
+#define RES_STA_FIFO_PRES_MSB		0x0e
+#define RES_STA_FIFO_PRES_LSB		0x0f
+#define RES_STA_UART_BRATE_MSB		0x10
+#define RES_STA_UART_BRATE_MID		0x11
+#define RES_STA_UART_BRATE_LSB		0x12
+#define RES_STA_DEV_IDEN		0x13
+#define RES_STA_SLIDE_DISPLACE		0x14
+#define RES_STA_ROTATE_ANGLE		0x15
+
+/* Resistive touch configuration registers */
+#define CR_CON_SYSTEM			0x40
+#define CR_CON_TRIG_EVENT		0x41
+#define CR_CON_FIFO_SETUP		0x42
+#define CR_CON_SAMPLING_RATE		0x43
+#define CR_CON_X_DELAY_MSB		0x44
+#define CR_CON_X_DELAY_LSB		0x45
+#define CR_CON_Y_DELAY_MSB		0x46
+#define CR_CON_Y_DELAY_LSB		0x47
+#define CR_CON_Z_DELAY_MSB		0x48
+#define CR_CON_Z_DELAY_LSB		0x49
+#define CR_CON_DIS_HOR_MSB		0x4a
+#define CR_CON_DIS_HOR_LSB		0x4b
+#define CR_CON_DIS_VER_MSB		0x4c
+#define CR_CON_DIS_VER_LSB		0x4d
+#define CR_CON_SLIDE_STEPS		0x4e
+
+#define RTST_EVENT			BIT(7)
+#define RTS2T_EVENT			BIT(6)
+#define RTSZ_EVENT			BIT(5)
+#define RTSR_EVENT			BIT(4)
+#define RTSS_EVENT			BIT(3)
+#define RTSF_EVENT			BIT(2)
+#define RTSRDY_EVENT			BIT(0)
+
+#define RTSSD_MASK			BIT(2)
+#define RTSSD_H_NEG			BIT(2)
+#define RTSSD_V_POS			BIT(3)
+#define RTSSD_V_NEG			BIT(4)
+
+#define RTSRD_MASK			BIT(4)
+#define RTSRD_COUNTER_CLK_WISE		BIT(4)
+
+#define RTSZD_MASK			BIT(5)
+#define RTSZD_ZOOM_OUT			BIT(5)
+
+#define CRTOUCH_MAX_FINGER		2
+#define CRTOUCH_MAX_AREA		0xfff
+#define CRTOUCH_MAX_X			0x01df
+#define CRTOUCH_MAX_Y			0x010f
+
+struct crtouch_ts_data {
+	struct i2c_client	*client;
+	struct input_dev	*input_dev;
+};
+
+static u8 crtouch_read_reg(struct i2c_client *client, int addr)
+{
+	return i2c_smbus_read_byte_data(client, addr);
+}
+
+static int crtouch_write_reg(struct i2c_client *client, int addr, int data)
+{
+	return i2c_smbus_write_byte_data(client, addr, data);
+}
+
+static void calibration_pointer(u16 *x_orig, u16 *y_orig)
+{
+	u16 x, y;
+
+	x = CRTOUCH_MAX_X - *x_orig;
+	*x_orig = x;
+
+	y = CRTOUCH_MAX_Y - *y_orig;
+	*y_orig = y;
+}
+
+static irqreturn_t crtouch_ts_interrupt(int irq, void *dev_id)
+{
+	struct crtouch_ts_data *data = dev_id;
+	struct i2c_client *client = data->client;
+	u8 status1;
+	u16 valuep, valuex, valuey;
+
+	status1 = crtouch_read_reg(client, RES_STA_STATUS1);
+
+	/* For single touch */
+	if (status1 & RTST_EVENT) {
+		valuep = crtouch_read_reg(client, RES_STA_PRES_MSB);
+		valuep = ((valuep << 8) |
+			crtouch_read_reg(client, RES_STA_RRES_LSB));
+		valuex = crtouch_read_reg(client, RES_STA_X_MSB);
+		valuex = ((valuex << 8) |
+			crtouch_read_reg(client, RES_STA_X_LSB));
+		valuey = crtouch_read_reg(client, RES_STA_Y_MSB);
+		valuey = ((valuey << 8) |
+			crtouch_read_reg(client, RES_STA_Y_LSB));
+		calibration_pointer(&valuex, &valuey);
+		input_report_key(data->input_dev, BTN_TOUCH, 1);
+		input_report_abs(data->input_dev, ABS_X, valuex);
+		input_report_abs(data->input_dev, ABS_Y, valuey);
+		input_report_abs(data->input_dev, ABS_PRESSURE, valuep);
+		input_sync(data->input_dev);
+	} else {
+		input_report_abs(data->input_dev, ABS_PRESSURE, 0);
+		input_event(data->input_dev, EV_KEY, BTN_TOUCH, 0);
+		input_sync(data->input_dev);
+	}
+
+	return IRQ_HANDLED;
+}
+
+static void crtouch_ts_reg_init(struct crtouch_ts_data *data)
+{
+	struct i2c_client *client = data->client;
+
+	crtouch_write_reg(client, CR_CON_SYSTEM, 0x9c);
+	crtouch_write_reg(client, CR_CON_TRIG_EVENT, 0xf9);
+	crtouch_write_reg(client, CR_CON_FIFO_SETUP, 0x1f);
+	crtouch_write_reg(client, CR_CON_SAMPLING_RATE, 0x08);
+	crtouch_write_reg(client, CR_CON_DIS_HOR_MSB, 0x01);
+	crtouch_write_reg(client, CR_CON_DIS_HOR_LSB, 0xdf);
+	crtouch_write_reg(client, CR_CON_DIS_VER_MSB, 0x01);
+	crtouch_write_reg(client, CR_CON_DIS_VER_LSB, 0x0f);
+}
+
+static int crtouch_ts_probe(struct i2c_client *client,
+			    const struct i2c_device_id *id)
+{
+	struct crtouch_ts_data *data;
+	struct input_dev *input_dev;
+	int error = -1, irq_gpio;
+
+	dev_info(&client->dev, "Freescale CRTOUCH driver\n");
+
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	input_dev = input_allocate_device();
+	if (!data || !input_dev) {
+		dev_err(&client->dev, "Failed to allocate memory\n");
+		error = -ENOMEM;
+		goto err_free_mem;
+	}
+
+	data->client = client;
+	data->input_dev = input_dev;
+
+	input_dev->name = "crtouch_ts";
+	input_dev->id.bustype = BUS_I2C;
+	input_dev->dev.parent = &client->dev;
+
+	/* For single touch */
+	__set_bit(EV_KEY, input_dev->evbit);
+	__set_bit(BTN_TOUCH, input_dev->keybit);
+	__set_bit(EV_ABS, input_dev->evbit);
+	__set_bit(ABS_X, input_dev->absbit);
+	__set_bit(ABS_Y, input_dev->absbit);
+	__set_bit(ABS_PRESSURE, input_dev->absbit);
+
+	input_set_abs_params(input_dev, ABS_X, 0, CRTOUCH_MAX_X, 0, 0);
+	input_set_abs_params(input_dev, ABS_Y, 0, CRTOUCH_MAX_Y, 0, 0);
+	input_set_abs_params(input_dev, ABS_PRESSURE, 0,
+			     CRTOUCH_MAX_AREA, 0, 0);
+
+	input_set_drvdata(input_dev, data);
+
+	crtouch_ts_reg_init(data);
+
+	irq_gpio = of_get_named_gpio(client->dev.of_node, "irq-gpio", 0);
+	if (!gpio_is_valid(irq_gpio))
+		goto err_free_mem;
+
+	error = gpio_request_one(irq_gpio, GPIOF_IN, "TS_IRQ");
+	if (error) {
+		dev_err(&client->dev, "Failed to request gpio\n");
+		goto err_free_mem;
+	}
+
+	error = request_threaded_irq(gpio_to_irq(irq_gpio), NULL,
+				     crtouch_ts_interrupt,
+				     IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
+				     "crtouch_ts", data);
+
+	if (error) {
+		dev_err(&client->dev, "Failed to register interrupt\n");
+		goto err_free_mem;
+	}
+
+	error = input_register_device(data->input_dev);
+	if (error)
+		goto err_free_irq;
+
+	i2c_set_clientdata(client, data);
+	return 0;
+
+err_free_irq:
+	free_irq(client->irq, data);
+err_free_mem:
+	input_free_device(input_dev);
+	kfree(data);
+	return error;
+}
+
+static int crtouch_ts_remove(struct i2c_client *client)
+{
+	struct crtouch_ts_data *data = i2c_get_clientdata(client);
+
+	free_irq(client->irq, data);
+	input_unregister_device(data->input_dev);
+	kfree(data);
+
+	return 0;
+}
+
+static const struct i2c_device_id crtouch_ts_id[] = {
+	{"crtouch_ts", 0},
+	{ }
+};
+MODULE_DEVICE_TABLE(i2c, crtouch_ts_id);
+
+static const struct of_device_id crtouch_ts_dt_ids[] = {
+	{ .compatible = "fsl,crtouch_ts", },
+	{ /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, crtouch_ts_dt_ids);
+
+static struct i2c_driver crtouch_ts_i2c_driver = {
+	.driver = {
+		   .name = "crtouch_ts",
+		   .owner = THIS_MODULE,
+		   .of_match_table = crtouch_ts_dt_ids,
+		   },
+	.probe = crtouch_ts_probe,
+	.remove = crtouch_ts_remove,
+	.id_table = crtouch_ts_id,
+};
+
+module_i2c_driver(crtouch_ts_i2c_driver);
+
+MODULE_AUTHOR("Alison Wang <b18965@freescale.com>");
+MODULE_DESCRIPTION("Touchscreen driver for Freescale CRTOUCH");
+MODULE_LICENSE("GPL");
-- 
2.7.4

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

* [PATCH 3/4] ARM: dts: vf610-twr: Add crtouch node and pinmux
  2016-06-24 19:44 [PATCH 0/4] Enable display and touchscreen for Vybrid Tower Anthony Felice
  2016-06-24 19:44 ` [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller Anthony Felice
  2016-06-24 19:44 ` [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver Anthony Felice
@ 2016-06-24 19:44 ` Anthony Felice
  2016-06-24 19:44 ` [PATCH 4/4] ARM: imx_v6_v7_defconfig: enable useful configurations for Vybrid Anthony Felice
  3 siblings, 0 replies; 11+ messages in thread
From: Anthony Felice @ 2016-06-24 19:44 UTC (permalink / raw)
  To: dri-devel, shawnguo, tony.felice
  Cc: dmitry.torokhov, robh+dt, mark.rutland, kernel, stefan, linux,
	fabio.estevam, geert, mwelling, sre, damien.riegel,
	maitysanchayan, linux-input, devicetree, linux-kernel,
	linux-arm-kernel

This adds a node for crtouch, the touchscreen controller of the Vybrid
Tower. Pinmux for the gpio irq used by crtouch is also defined in this
commit.

Signed-off-by: Anthony Felice <tony.felice@timesys.com>
---
 arch/arm/boot/dts/vf610-twr.dts | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/arch/arm/boot/dts/vf610-twr.dts b/arch/arm/boot/dts/vf610-twr.dts
index ad1aff9..5d5cecf 100644
--- a/arch/arm/boot/dts/vf610-twr.dts
+++ b/arch/arm/boot/dts/vf610-twr.dts
@@ -217,6 +217,14 @@
 	       VDDIO-supply = <&reg_3p3v>;
 	       clocks = <&clks VF610_CLK_SAI2>;
        };
+
+	touch: crtouch@49 {
+		compatible = "fsl,crtouch_ts";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_touchscreen>;
+		reg = <0x49>;
+		irq-gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
+	};
 };
 
 &iomuxc {
@@ -365,6 +373,12 @@
 			>;
 		};
 
+		pinctrl_touchscreen: touchscreengrp {
+			fsl,pins = <
+				VF610_PAD_PTA31__GPIO_21	0x219d
+			>;
+		};
+
 		pinctrl_uart1: uart1grp {
 			fsl,pins = <
 				VF610_PAD_PTB4__UART1_TX		0x21a2
-- 
2.7.4

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

* [PATCH 4/4] ARM: imx_v6_v7_defconfig: enable useful configurations for Vybrid
  2016-06-24 19:44 [PATCH 0/4] Enable display and touchscreen for Vybrid Tower Anthony Felice
                   ` (2 preceding siblings ...)
  2016-06-24 19:44 ` [PATCH 3/4] ARM: dts: vf610-twr: Add crtouch node and pinmux Anthony Felice
@ 2016-06-24 19:44 ` Anthony Felice
  3 siblings, 0 replies; 11+ messages in thread
From: Anthony Felice @ 2016-06-24 19:44 UTC (permalink / raw)
  To: dri-devel, shawnguo, tony.felice
  Cc: mark.rutland, devicetree, maitysanchayan, damien.riegel,
	linux-kernel, dmitry.torokhov, linux, stefan, sre, mwelling,
	robh+dt, geert, kernel, linux-input, fabio.estevam,
	linux-arm-kernel

Enable configuration options useful for the Vybrid Tower platform:
- CRTouch Touchscreen support.
- DRM support for Freescale DCU.

Regenerated config using savedefconfig (which removes some configs
which are now enabled by default).

Signed-off-by: Anthony Felice <tony.felice@timesys.com>
---
 arch/arm/configs/imx_v6_v7_defconfig | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
index 21339ce..0b9de5c 100644
--- a/arch/arm/configs/imx_v6_v7_defconfig
+++ b/arch/arm/configs/imx_v6_v7_defconfig
@@ -1,6 +1,5 @@
 CONFIG_KERNEL_LZO=y
 CONFIG_SYSVIPC=y
-CONFIG_FHANDLE=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_IKCONFIG=y
@@ -72,7 +71,6 @@ CONFIG_IP_PNP_DHCP=y
 # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
 # CONFIG_INET_XFRM_MODE_TUNNEL is not set
 # CONFIG_INET_XFRM_MODE_BEET is not set
-# CONFIG_INET_LRO is not set
 CONFIG_NETFILTER=y
 CONFIG_CAN=y
 CONFIG_CAN_FLEXCAN=y
@@ -170,6 +168,7 @@ CONFIG_TOUCHSCREEN_TSC2007=y
 CONFIG_TOUCHSCREEN_STMPE=y
 CONFIG_TOUCHSCREEN_SX8654=y
 CONFIG_TOUCHSCREEN_COLIBRI_VF50=y
+CONFIG_TOUCHSCREEN_CRTOUCH=y
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_MMA8450=y
 CONFIG_SERIO_SERPORT=m
@@ -227,12 +226,12 @@ CONFIG_MEDIA_USB_SUPPORT=y
 CONFIG_USB_VIDEO_CLASS=m
 CONFIG_V4L_PLATFORM_DRIVERS=y
 CONFIG_SOC_CAMERA=y
-CONFIG_VIDEO_MX3=y
 CONFIG_V4L_MEM2MEM_DRIVERS=y
 CONFIG_VIDEO_CODA=y
 CONFIG_SOC_CAMERA_OV2640=y
 CONFIG_IMX_IPUV3_CORE=y
 CONFIG_DRM=y
+CONFIG_DRM_FSL_DCU=y
 CONFIG_DRM_PANEL_SIMPLE=y
 CONFIG_DRM_DW_HDMI_AHB_AUDIO=m
 CONFIG_DRM_IMX=y
@@ -333,7 +332,6 @@ CONFIG_VF610_ADC=y
 CONFIG_PWM=y
 CONFIG_PWM_FSL_FTM=y
 CONFIG_PWM_IMX=y
-CONFIG_NVMEM=y
 CONFIG_NVMEM_IMX_OCOTP=y
 CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
-- 
2.7.4

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

* Re: [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver
       [not found]   ` <1466797486-31558-3-git-send-email-tony.felice-jEh4hwF5bVhBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-24 22:04     ` Dmitry Torokhov
  2016-06-27 18:50       ` Tony Felice
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry Torokhov @ 2016-06-24 22:04 UTC (permalink / raw)
  To: Anthony Felice
  Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A,
	mark.rutland-5wv7dgnIgG8, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
	stefan-XLVq0VzYD2Y, linux-I+IVW8TIWO2tmTQ+vhA3Yw,
	fabio.estevam-3arQi8VN3Tc, geert-Td1EMuHUCqxL1ZNQvxDV9g,
	mwelling-EkmVulN54Sk, sre-DgEjT+Ai2ygdnm+yROfE0A,
	damien.riegel-4ysUXcep3aM1wj+D4I0NRVaTQe2KTcn/,
	maitysanchayan-Re5JQEeQqe8AvxtiuMwx3w,
	linux-input-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

Hi Anthony,

On Fri, Jun 24, 2016 at 03:44:44PM -0400, Anthony Felice wrote:
> Add driver for the Vybrid Tower CRTouch-based touchscreen. This is
> required for the touchscreen on the TWR-LCD-RGB to work on the Vybrid
> Tower platform.
> 
> There is a known issue with this driver: rarely, SW1 on the TWR-LCD-RGB
> module needs to be pressed in order for the touchscreen to begin
> functioning.

Hmm. Could it be that you want level interrupt and not edge? Or maybe
you want to read state after requesting interrupt?

> 
> Signed-off-by: Anthony Felice <tony.felice-jEh4hwF5bVhBDgjK7y7TUQ@public.gmane.org>
> ---
>  .../bindings/input/touchscreen/crtouch_ts.txt      |  14 ++
>  drivers/input/touchscreen/Kconfig                  |  10 +
>  drivers/input/touchscreen/Makefile                 |   1 +
>  drivers/input/touchscreen/crtouch_ts.c             | 279 +++++++++++++++++++++
>  4 files changed, 304 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
>  create mode 100644 drivers/input/touchscreen/crtouch_ts.c
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> new file mode 100644
> index 0000000..cfb966c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> @@ -0,0 +1,14 @@
> +* Freescale CRTOUCH based touchscreen
> +
> +Required Properties:
> +- compatible must be fsl,crtouch_ts
> +- reg: I2C address of the touchscreen
> +- irq-gpio: GPIO to use as event IRQ
> +
> +Example:
> +
> +	touch: crtouch@49 {
> +		compatible = "fsl,crtouch_ts";
> +		reg = <0x49>;
> +		irq-gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;

You are not using it as gpio but only as interrupt source, so please
set it up as regular interrupt and let I2C core set it up for you so
that you will only need to call request_irq(client->irq, ...)

		interrupts = <&gpio0 21 IRQ_TYPE_EDGE_FALLING>;

> +	};
> diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
> index 8ecdc38..799e342 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1155,4 +1155,14 @@ config TOUCHSCREEN_ROHM_BU21023
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called bu21023_ts.
>  
> +config TOUCHSCREEN_CRTOUCH
> +	tristate "Freescale CRTOUCH based touchscreen"
> +	depends on I2C
> +	help
> +	  Say Y here if you have a CRTOUCH based touchscreen
> +	  controller.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called crtouch_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
> index f42975e..8cb0a7a 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -95,3 +95,4 @@ obj-$(CONFIG_TOUCHSCREEN_TPS6507X)	+= tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE)	+= zforce_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)	+= colibri-vf50-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023)	+= rohm_bu21023.o
> +obj-$(CONFIG_TOUCHSCREEN_CRTOUCH)	+= crtouch_ts.o
> diff --git a/drivers/input/touchscreen/crtouch_ts.c b/drivers/input/touchscreen/crtouch_ts.c
> new file mode 100644
> index 0000000..bb87a8e
> --- /dev/null
> +++ b/drivers/input/touchscreen/crtouch_ts.c
> @@ -0,0 +1,279 @@
> +/*
> + * Driver for Freescale Semiconductor CRTOUCH - A Resistive and Capacitive
> + * touch device with i2c interface
> + *
> + * Copyright 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/i2c.h>
> +#include <linux/interrupt.h>
> +#include <linux/input.h>
> +#include <linux/input/mt.h>
> +#include <linux/slab.h>
> +#include <linux/bitops.h>
> +#include <linux/gpio.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
> +
> +/* Resistive touch sense status registers */
> +#define RES_STA_ERROR			0x00
> +#define RES_STA_STATUS1			0x01
> +#define	RES_STA_STATUS2			0x02
> +#define RES_STA_X_MSB			0x03
> +#define RES_STA_X_LSB			0x04
> +#define RES_STA_Y_MSB			0x05
> +#define RES_STA_Y_LSB			0x06
> +#define RES_STA_PRES_MSB		0x07
> +#define RES_STA_RRES_LSB		0x08
> +#define RES_STA_FIFO_STATUS		0x09
> +#define RES_STA_FIFO_X_MSB		0x0a
> +#define RES_STA_FIFO_X_LSB		0x0b
> +#define RES_STA_FIFO_Y_MSB		0x0c
> +#define RES_STA_FIFO_Y_LSB		0x0d
> +#define RES_STA_FIFO_PRES_MSB		0x0e
> +#define RES_STA_FIFO_PRES_LSB		0x0f
> +#define RES_STA_UART_BRATE_MSB		0x10
> +#define RES_STA_UART_BRATE_MID		0x11
> +#define RES_STA_UART_BRATE_LSB		0x12
> +#define RES_STA_DEV_IDEN		0x13
> +#define RES_STA_SLIDE_DISPLACE		0x14
> +#define RES_STA_ROTATE_ANGLE		0x15
> +
> +/* Resistive touch configuration registers */
> +#define CR_CON_SYSTEM			0x40
> +#define CR_CON_TRIG_EVENT		0x41
> +#define CR_CON_FIFO_SETUP		0x42
> +#define CR_CON_SAMPLING_RATE		0x43
> +#define CR_CON_X_DELAY_MSB		0x44
> +#define CR_CON_X_DELAY_LSB		0x45
> +#define CR_CON_Y_DELAY_MSB		0x46
> +#define CR_CON_Y_DELAY_LSB		0x47
> +#define CR_CON_Z_DELAY_MSB		0x48
> +#define CR_CON_Z_DELAY_LSB		0x49
> +#define CR_CON_DIS_HOR_MSB		0x4a
> +#define CR_CON_DIS_HOR_LSB		0x4b
> +#define CR_CON_DIS_VER_MSB		0x4c
> +#define CR_CON_DIS_VER_LSB		0x4d
> +#define CR_CON_SLIDE_STEPS		0x4e
> +
> +#define RTST_EVENT			BIT(7)
> +#define RTS2T_EVENT			BIT(6)
> +#define RTSZ_EVENT			BIT(5)
> +#define RTSR_EVENT			BIT(4)
> +#define RTSS_EVENT			BIT(3)
> +#define RTSF_EVENT			BIT(2)
> +#define RTSRDY_EVENT			BIT(0)
> +
> +#define RTSSD_MASK			BIT(2)
> +#define RTSSD_H_NEG			BIT(2)
> +#define RTSSD_V_POS			BIT(3)
> +#define RTSSD_V_NEG			BIT(4)
> +
> +#define RTSRD_MASK			BIT(4)
> +#define RTSRD_COUNTER_CLK_WISE		BIT(4)
> +
> +#define RTSZD_MASK			BIT(5)
> +#define RTSZD_ZOOM_OUT			BIT(5)
> +
> +#define CRTOUCH_MAX_FINGER		2
> +#define CRTOUCH_MAX_AREA		0xfff
> +#define CRTOUCH_MAX_X			0x01df
> +#define CRTOUCH_MAX_Y			0x010f
> +
> +struct crtouch_ts_data {
> +	struct i2c_client	*client;
> +	struct input_dev	*input_dev;
> +};
> +
> +static u8 crtouch_read_reg(struct i2c_client *client, int addr)
> +{
> +	return i2c_smbus_read_byte_data(client, addr);
> +}
> +
> +static int crtouch_write_reg(struct i2c_client *client, int addr, int data)
> +{
> +	return i2c_smbus_write_byte_data(client, addr, data);
> +}
> +
> +static void calibration_pointer(u16 *x_orig, u16 *y_orig)
> +{
> +	u16 x, y;
> +
> +	x = CRTOUCH_MAX_X - *x_orig;
> +	*x_orig = x;
> +
> +	y = CRTOUCH_MAX_Y - *y_orig;
> +	*y_orig = y;
> +}
> +
> +static irqreturn_t crtouch_ts_interrupt(int irq, void *dev_id)
> +{
> +	struct crtouch_ts_data *data = dev_id;
> +	struct i2c_client *client = data->client;
> +	u8 status1;
> +	u16 valuep, valuex, valuey;
> +
> +	status1 = crtouch_read_reg(client, RES_STA_STATUS1);
> +
> +	/* For single touch */
> +	if (status1 & RTST_EVENT) {
> +		valuep = crtouch_read_reg(client, RES_STA_PRES_MSB);
> +		valuep = ((valuep << 8) |
> +			crtouch_read_reg(client, RES_STA_RRES_LSB));

Is it possible to read 2 bytes at once?

> +		valuex = crtouch_read_reg(client, RES_STA_X_MSB);
> +		valuex = ((valuex << 8) |
> +			crtouch_read_reg(client, RES_STA_X_LSB));
> +		valuey = crtouch_read_reg(client, RES_STA_Y_MSB);
> +		valuey = ((valuey << 8) |
> +			crtouch_read_reg(client, RES_STA_Y_LSB));
> +		calibration_pointer(&valuex, &valuey);

I'd do conversion inline - it is clearer what is going on.

> +		input_report_key(data->input_dev, BTN_TOUCH, 1);
> +		input_report_abs(data->input_dev, ABS_X, valuex);
> +		input_report_abs(data->input_dev, ABS_Y, valuey);
> +		input_report_abs(data->input_dev, ABS_PRESSURE, valuep);
> +		input_sync(data->input_dev);
> +	} else {
> +		input_report_abs(data->input_dev, ABS_PRESSURE, 0);
> +		input_event(data->input_dev, EV_KEY, BTN_TOUCH, 0);
> +		input_sync(data->input_dev);
> +	}

input_sync() can go here.

> +
> +	return IRQ_HANDLED;
> +}
> +
> +static void crtouch_ts_reg_init(struct crtouch_ts_data *data)
> +{
> +	struct i2c_client *client = data->client;
> +
> +	crtouch_write_reg(client, CR_CON_SYSTEM, 0x9c);
> +	crtouch_write_reg(client, CR_CON_TRIG_EVENT, 0xf9);
> +	crtouch_write_reg(client, CR_CON_FIFO_SETUP, 0x1f);
> +	crtouch_write_reg(client, CR_CON_SAMPLING_RATE, 0x08);
> +	crtouch_write_reg(client, CR_CON_DIS_HOR_MSB, 0x01);
> +	crtouch_write_reg(client, CR_CON_DIS_HOR_LSB, 0xdf);
> +	crtouch_write_reg(client, CR_CON_DIS_VER_MSB, 0x01);
> +	crtouch_write_reg(client, CR_CON_DIS_VER_LSB, 0x0f);

Should we fetch any of this data from DTS? I assume CR_CON_DIS_HOR/VER
is resolution? Or not?

Also, why no error handling?

> +}
> +
> +static int crtouch_ts_probe(struct i2c_client *client,
> +			    const struct i2c_device_id *id)
> +{
> +	struct crtouch_ts_data *data;
> +	struct input_dev *input_dev;
> +	int error = -1, irq_gpio;
> +
> +	dev_info(&client->dev, "Freescale CRTOUCH driver\n");

Please drop this.

> +
> +	data = kzalloc(sizeof(*data), GFP_KERNEL);
> +	input_dev = input_allocate_device();

Please use devm* and you will be able to get rid of crtouch_ts_remove().

> +	if (!data || !input_dev) {
> +		dev_err(&client->dev, "Failed to allocate memory\n");
> +		error = -ENOMEM;
> +		goto err_free_mem;
> +	}
> +
> +	data->client = client;
> +	data->input_dev = input_dev;
> +
> +	input_dev->name = "crtouch_ts";
> +	input_dev->id.bustype = BUS_I2C;
> +	input_dev->dev.parent = &client->dev;
> +
> +	/* For single touch */
> +	__set_bit(EV_KEY, input_dev->evbit);
> +	__set_bit(BTN_TOUCH, input_dev->keybit);
> +	__set_bit(EV_ABS, input_dev->evbit);
> +	__set_bit(ABS_X, input_dev->absbit);
> +	__set_bit(ABS_Y, input_dev->absbit);
> +	__set_bit(ABS_PRESSURE, input_dev->absbit);
> +
> +	input_set_abs_params(input_dev, ABS_X, 0, CRTOUCH_MAX_X, 0, 0);
> +	input_set_abs_params(input_dev, ABS_Y, 0, CRTOUCH_MAX_Y, 0, 0);
> +	input_set_abs_params(input_dev, ABS_PRESSURE, 0,
> +			     CRTOUCH_MAX_AREA, 0, 0);
> +
> +	input_set_drvdata(input_dev, data);
> +
> +	crtouch_ts_reg_init(data);
> +
> +	irq_gpio = of_get_named_gpio(client->dev.of_node, "irq-gpio", 0);
> +	if (!gpio_is_valid(irq_gpio))
> +		goto err_free_mem;
> +
> +	error = gpio_request_one(irq_gpio, GPIOF_IN, "TS_IRQ");
> +	if (error) {
> +		dev_err(&client->dev, "Failed to request gpio\n");
> +		goto err_free_mem;
> +	}
> +
> +	error = request_threaded_irq(gpio_to_irq(irq_gpio), NULL,
> +				     crtouch_ts_interrupt,
> +				     IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
> +				     "crtouch_ts", data);

As i mentioned above replace everything starting with of_get_named_gpio
with:

	error = devm_request_threaded_irq(&cleint->dev, client->irq,
					  NULL, crtouch_ts_interrupt,
					  IRQF_ONESHOT,
					  "crtouch_ts", data);

> +
> +	if (error) {
> +		dev_err(&client->dev, "Failed to register interrupt\n");
> +		goto err_free_mem;
> +	}
> +
> +	error = input_register_device(data->input_dev);
> +	if (error)
> +		goto err_free_irq;
> +
> +	i2c_set_clientdata(client, data);
> +	return 0;
> +
> +err_free_irq:
> +	free_irq(client->irq, data);
> +err_free_mem:
> +	input_free_device(input_dev);
> +	kfree(data);
> +	return error;
> +}
> +
> +static int crtouch_ts_remove(struct i2c_client *client)
> +{
> +	struct crtouch_ts_data *data = i2c_get_clientdata(client);
> +
> +	free_irq(client->irq, data);
> +	input_unregister_device(data->input_dev);
> +	kfree(data);

With devm it can all be dropped.

> +
> +	return 0;
> +}
> +
> +static const struct i2c_device_id crtouch_ts_id[] = {
> +	{"crtouch_ts", 0},
> +	{ }
> +};
> +MODULE_DEVICE_TABLE(i2c, crtouch_ts_id);
> +
> +static const struct of_device_id crtouch_ts_dt_ids[] = {
> +	{ .compatible = "fsl,crtouch_ts", },
> +	{ /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, crtouch_ts_dt_ids);
> +
> +static struct i2c_driver crtouch_ts_i2c_driver = {
> +	.driver = {
> +		   .name = "crtouch_ts",
> +		   .owner = THIS_MODULE,

No need to set owner.

> +		   .of_match_table = crtouch_ts_dt_ids,

			.of_match_table = of_match_ptr(crtouch_ts_dt_ids),

Also, no PM methods?

> +		   },
> +	.probe = crtouch_ts_probe,
> +	.remove = crtouch_ts_remove,
> +	.id_table = crtouch_ts_id,
> +};
> +
> +module_i2c_driver(crtouch_ts_i2c_driver);
> +
> +MODULE_AUTHOR("Alison Wang <b18965-KZfg59tc24xl57MIdRCFDg@public.gmane.org>");
> +MODULE_DESCRIPTION("Touchscreen driver for Freescale CRTOUCH");
> +MODULE_LICENSE("GPL");
> -- 
> 2.7.4
> 

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver
  2016-06-24 19:44 ` [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver Anthony Felice
       [not found]   ` <1466797486-31558-3-git-send-email-tony.felice-jEh4hwF5bVhBDgjK7y7TUQ@public.gmane.org>
@ 2016-06-25 20:40   ` Stefan Agner
  2016-06-28 20:55   ` Rob Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Stefan Agner @ 2016-06-25 20:40 UTC (permalink / raw)
  To: Anthony Felice
  Cc: dri-devel, shawnguo, dmitry.torokhov, robh+dt, mark.rutland,
	kernel, linux, fabio.estevam, geert, mwelling, sre,
	damien.riegel, maitysanchayan, linux-input, devicetree,
	linux-kernel, linux-arm-kernel

On 2016-06-24 12:44, Anthony Felice wrote:
> Add driver for the Vybrid Tower CRTouch-based touchscreen. This is
> required for the touchscreen on the TWR-LCD-RGB to work on the Vybrid
> Tower platform.
> 
> There is a known issue with this driver: rarely, SW1 on the TWR-LCD-RGB
> module needs to be pressed in order for the touchscreen to begin
> functioning.
> 
> Signed-off-by: Anthony Felice <tony.felice@timesys.com>
> ---
>  .../bindings/input/touchscreen/crtouch_ts.txt      |  14 ++
>  drivers/input/touchscreen/Kconfig                  |  10 +
>  drivers/input/touchscreen/Makefile                 |   1 +
>  drivers/input/touchscreen/crtouch_ts.c             | 279 +++++++++++++++++++++
>  4 files changed, 304 insertions(+)
>  create mode 100644
> Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
>  create mode 100644 drivers/input/touchscreen/crtouch_ts.c
> 
> diff --git
> a/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> new file mode 100644
> index 0000000..cfb966c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> @@ -0,0 +1,14 @@
> +* Freescale CRTOUCH based touchscreen
> +
> +Required Properties:
> +- compatible must be fsl,crtouch_ts

Compatible strings usually use a dash instead of underline.


> +- reg: I2C address of the touchscreen
> +- irq-gpio: GPIO to use as event IRQ
> +
> +Example:
> +
> +	touch: crtouch@49 {
> +		compatible = "fsl,crtouch_ts";
> +		reg = <0x49>;
> +		irq-gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
> +	};
> diff --git a/drivers/input/touchscreen/Kconfig
> b/drivers/input/touchscreen/Kconfig
> index 8ecdc38..799e342 100644
> --- a/drivers/input/touchscreen/Kconfig
> +++ b/drivers/input/touchscreen/Kconfig
> @@ -1155,4 +1155,14 @@ config TOUCHSCREEN_ROHM_BU21023
>  	  To compile this driver as a module, choose M here: the
>  	  module will be called bu21023_ts.
>  
> +config TOUCHSCREEN_CRTOUCH
> +	tristate "Freescale CRTOUCH based touchscreen"
> +	depends on I2C

You probably also need to add OF here.

> +	help
> +	  Say Y here if you have a CRTOUCH based touchscreen
> +	  controller.
> +
> +	  To compile this driver as a module, choose M here: the
> +	  module will be called crtouch_ts.
> +
>  endif
> diff --git a/drivers/input/touchscreen/Makefile
> b/drivers/input/touchscreen/Makefile
> index f42975e..8cb0a7a 100644
> --- a/drivers/input/touchscreen/Makefile
> +++ b/drivers/input/touchscreen/Makefile
> @@ -95,3 +95,4 @@ obj-$(CONFIG_TOUCHSCREEN_TPS6507X)	+= tps6507x-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ZFORCE)	+= zforce_ts.o
>  obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)	+= colibri-vf50-ts.o
>  obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023)	+= rohm_bu21023.o
> +obj-$(CONFIG_TOUCHSCREEN_CRTOUCH)	+= crtouch_ts.o
> diff --git a/drivers/input/touchscreen/crtouch_ts.c
> b/drivers/input/touchscreen/crtouch_ts.c
> new file mode 100644
> index 0000000..bb87a8e
> --- /dev/null
> +++ b/drivers/input/touchscreen/crtouch_ts.c
> @@ -0,0 +1,279 @@
> +/*
> + * Driver for Freescale Semiconductor CRTOUCH - A Resistive and Capacitive
> + * touch device with i2c interface
> + *
> + * Copyright 2012 Freescale Semiconductor, Inc.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/i2c.h>
> +#include <linux/interrupt.h>
> +#include <linux/input.h>
> +#include <linux/input/mt.h>
> +#include <linux/slab.h>
> +#include <linux/bitops.h>
> +#include <linux/gpio.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
> +
> +/* Resistive touch sense status registers */
> +#define RES_STA_ERROR			0x00
> +#define RES_STA_STATUS1			0x01
> +#define	RES_STA_STATUS2			0x02

Nit: there is a tab between define and RES_STA_STATUS2, all other lines
have spaces.

--
Stefan

<snip>

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

* Re: [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller
  2016-06-24 19:44 ` [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller Anthony Felice
@ 2016-06-25 20:53   ` Stefan Agner
  2016-06-27 17:11     ` Tony Felice
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Agner @ 2016-06-25 20:53 UTC (permalink / raw)
  To: Anthony Felice
  Cc: dri-devel, shawnguo, dmitry.torokhov, robh+dt, mark.rutland,
	kernel, linux, fabio.estevam, geert, mwelling, sre,
	damien.riegel, maitysanchayan, linux-input, devicetree,
	linux-kernel, linux-arm-kernel

On 2016-06-24 12:44, Anthony Felice wrote:
> This adds nodes to enable tcon0 and dcu0 for the Vybrid Tower. These
> are used to drive the Vybrid Tower TWR-LCD-RGB display. Also, a node
> for the nec nl4827hc19-05b panel on the TWR-LCD-RGB display has been
> added.

So my pixel clock polarity changes which will be part of 4.7 work for
Tower? I could never actually test that since I don't have the display
here...
https://patchwork.kernel.org/patch/8874971/

This patch looks good to me:
Acked-by: Stefan Agner <stefan@agner.ch>

--
Stefan

> 
> Signed-off-by: Anthony Felice <tony.felice@timesys.com>
> ---
>  arch/arm/boot/dts/vf610-twr.dts | 48 +++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
> 
> diff --git a/arch/arm/boot/dts/vf610-twr.dts b/arch/arm/boot/dts/vf610-twr.dts
> index cdc1007..ad1aff9 100644
> --- a/arch/arm/boot/dts/vf610-twr.dts
> +++ b/arch/arm/boot/dts/vf610-twr.dts
> @@ -66,6 +66,10 @@
>  		clock-frequency = <50000000>;
>  	};
>  
> +	panel: panel {
> +		compatible = "nec,nl4827hc19-05b";
> +	};
> +
>  	regulators {
>  		compatible = "simple-bus";
>  		#address-cells = <1>;
> @@ -134,6 +138,13 @@
>  				 <&clks VF610_CLK_ENET_EXT>;
>  };
>  
> +&dcu0 {
> +	fsl,panel = <&panel>;
> +	pinctrl-names = "default";
> +	pinctrl-0 = <&pinctrl_dcu0>;
> +	status = "okay";
> +};
> +
>  &dspi0 {
>  	bus-num = <0>;
>  	pinctrl-names = "default";
> @@ -210,6 +221,39 @@
>  
>  &iomuxc {
>  	vf610-twr {
> +		pinctrl_dcu0: dcu0grp {
> +			fsl,pins = <
> +				VF610_PAD_PTE0__DCU0_HSYNC	0x42
> +				VF610_PAD_PTE1__DCU0_VSYNC	0x42
> +				VF610_PAD_PTE2__DCU0_PCLK	0x42
> +				VF610_PAD_PTE4__DCU0_DE		0x42
> +				VF610_PAD_PTE5__DCU0_R0		0x42
> +				VF610_PAD_PTE6__DCU0_R1		0x42
> +				VF610_PAD_PTE7__DCU0_R2		0x42
> +				VF610_PAD_PTE8__DCU0_R3		0x42
> +				VF610_PAD_PTE9__DCU0_R4		0x42
> +				VF610_PAD_PTE10__DCU0_R5	0x42
> +				VF610_PAD_PTE11__DCU0_R6	0x42
> +				VF610_PAD_PTE12__DCU0_R7	0x42
> +				VF610_PAD_PTE13__DCU0_G0	0x42
> +				VF610_PAD_PTE14__DCU0_G1	0x42
> +				VF610_PAD_PTE15__DCU0_G2	0x42
> +				VF610_PAD_PTE16__DCU0_G3	0x42
> +				VF610_PAD_PTE17__DCU0_G4	0x42
> +				VF610_PAD_PTE18__DCU0_G5	0x42
> +				VF610_PAD_PTE19__DCU0_G6	0x42
> +				VF610_PAD_PTE20__DCU0_G7	0x42
> +				VF610_PAD_PTE21__DCU0_B0	0x42
> +				VF610_PAD_PTE22__DCU0_B1	0x42
> +				VF610_PAD_PTE23__DCU0_B2	0x42
> +				VF610_PAD_PTE24__DCU0_B3	0x42
> +				VF610_PAD_PTE25__DCU0_B4	0x42
> +				VF610_PAD_PTE26__DCU0_B5	0x42
> +				VF610_PAD_PTE27__DCU0_B6	0x42
> +				VF610_PAD_PTE28__DCU0_B7	0x42
> +			>;
> +		};
> +
>  		pinctrl_adc0_ad5: adc0ad5grp {
>  			fsl,pins = <
>  				VF610_PAD_PTC30__ADC0_SE5		0xa1
> @@ -370,6 +414,10 @@
>  	status = "okay";
>  };
>  
> +&tcon0 {
> +	status = "okay";
> +};
> +
>  &uart1 {
>  	pinctrl-names = "default";
>  	pinctrl-0 = <&pinctrl_uart1>;

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

* Re: [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller
  2016-06-25 20:53   ` Stefan Agner
@ 2016-06-27 17:11     ` Tony Felice
  0 siblings, 0 replies; 11+ messages in thread
From: Tony Felice @ 2016-06-27 17:11 UTC (permalink / raw)
  To: Stefan Agner
  Cc: mark.rutland, devicetree, maitysanchayan, damien.riegel,
	linux-kernel, dmitry.torokhov, linux, dri-devel, sre, mwelling,
	robh+dt, geert, kernel, linux-input, fabio.estevam, shawnguo,
	linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 4372 bytes --]

Hi Stefan,

Yes, these changes do work for the Tower board!

-Tony

On Sat, Jun 25, 2016 at 4:53 PM, Stefan Agner <stefan@agner.ch> wrote:

> On 2016-06-24 12:44, Anthony Felice wrote:
> > This adds nodes to enable tcon0 and dcu0 for the Vybrid Tower. These
> > are used to drive the Vybrid Tower TWR-LCD-RGB display. Also, a node
> > for the nec nl4827hc19-05b panel on the TWR-LCD-RGB display has been
> > added.
>
> So my pixel clock polarity changes which will be part of 4.7 work for
> Tower? I could never actually test that since I don't have the display
> here...
> https://patchwork.kernel.org/patch/8874971/
>
> This patch looks good to me:
> Acked-by: Stefan Agner <stefan@agner.ch>
>
> --
> Stefan
>
> >
> > Signed-off-by: Anthony Felice <tony.felice@timesys.com>
> > ---
> >  arch/arm/boot/dts/vf610-twr.dts | 48
> +++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 48 insertions(+)
> >
> > diff --git a/arch/arm/boot/dts/vf610-twr.dts
> b/arch/arm/boot/dts/vf610-twr.dts
> > index cdc1007..ad1aff9 100644
> > --- a/arch/arm/boot/dts/vf610-twr.dts
> > +++ b/arch/arm/boot/dts/vf610-twr.dts
> > @@ -66,6 +66,10 @@
> >               clock-frequency = <50000000>;
> >       };
> >
> > +     panel: panel {
> > +             compatible = "nec,nl4827hc19-05b";
> > +     };
> > +
> >       regulators {
> >               compatible = "simple-bus";
> >               #address-cells = <1>;
> > @@ -134,6 +138,13 @@
> >                                <&clks VF610_CLK_ENET_EXT>;
> >  };
> >
> > +&dcu0 {
> > +     fsl,panel = <&panel>;
> > +     pinctrl-names = "default";
> > +     pinctrl-0 = <&pinctrl_dcu0>;
> > +     status = "okay";
> > +};
> > +
> >  &dspi0 {
> >       bus-num = <0>;
> >       pinctrl-names = "default";
> > @@ -210,6 +221,39 @@
> >
> >  &iomuxc {
> >       vf610-twr {
> > +             pinctrl_dcu0: dcu0grp {
> > +                     fsl,pins = <
> > +                             VF610_PAD_PTE0__DCU0_HSYNC      0x42
> > +                             VF610_PAD_PTE1__DCU0_VSYNC      0x42
> > +                             VF610_PAD_PTE2__DCU0_PCLK       0x42
> > +                             VF610_PAD_PTE4__DCU0_DE         0x42
> > +                             VF610_PAD_PTE5__DCU0_R0         0x42
> > +                             VF610_PAD_PTE6__DCU0_R1         0x42
> > +                             VF610_PAD_PTE7__DCU0_R2         0x42
> > +                             VF610_PAD_PTE8__DCU0_R3         0x42
> > +                             VF610_PAD_PTE9__DCU0_R4         0x42
> > +                             VF610_PAD_PTE10__DCU0_R5        0x42
> > +                             VF610_PAD_PTE11__DCU0_R6        0x42
> > +                             VF610_PAD_PTE12__DCU0_R7        0x42
> > +                             VF610_PAD_PTE13__DCU0_G0        0x42
> > +                             VF610_PAD_PTE14__DCU0_G1        0x42
> > +                             VF610_PAD_PTE15__DCU0_G2        0x42
> > +                             VF610_PAD_PTE16__DCU0_G3        0x42
> > +                             VF610_PAD_PTE17__DCU0_G4        0x42
> > +                             VF610_PAD_PTE18__DCU0_G5        0x42
> > +                             VF610_PAD_PTE19__DCU0_G6        0x42
> > +                             VF610_PAD_PTE20__DCU0_G7        0x42
> > +                             VF610_PAD_PTE21__DCU0_B0        0x42
> > +                             VF610_PAD_PTE22__DCU0_B1        0x42
> > +                             VF610_PAD_PTE23__DCU0_B2        0x42
> > +                             VF610_PAD_PTE24__DCU0_B3        0x42
> > +                             VF610_PAD_PTE25__DCU0_B4        0x42
> > +                             VF610_PAD_PTE26__DCU0_B5        0x42
> > +                             VF610_PAD_PTE27__DCU0_B6        0x42
> > +                             VF610_PAD_PTE28__DCU0_B7        0x42
> > +                     >;
> > +             };
> > +
> >               pinctrl_adc0_ad5: adc0ad5grp {
> >                       fsl,pins = <
> >                               VF610_PAD_PTC30__ADC0_SE5
>  0xa1
> > @@ -370,6 +414,10 @@
> >       status = "okay";
> >  };
> >
> > +&tcon0 {
> > +     status = "okay";
> > +};
> > +
> >  &uart1 {
> >       pinctrl-names = "default";
> >       pinctrl-0 = <&pinctrl_uart1>;
>



-- 
Tony Felice
Support Engineering Manager
Timesys Corporation

[-- Attachment #1.2: Type: text/html, Size: 6600 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver
  2016-06-24 22:04     ` Dmitry Torokhov
@ 2016-06-27 18:50       ` Tony Felice
  0 siblings, 0 replies; 11+ messages in thread
From: Tony Felice @ 2016-06-27 18:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: mark.rutland, devicetree, maitysanchayan, damien.riegel,
	linux-kernel, linux, sre, mwelling, robh+dt, geert, dri-devel,
	kernel, linux-input, fabio.estevam, shawnguo, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 16466 bytes --]

Hi Dmitry, Stefan,

Thanks for your valuable feedback, I really appreciate it. I will review
and submit V2 patchset based on this. Please see a few comments in-line.

-Tony


On Fri, Jun 24, 2016 at 6:04 PM, Dmitry Torokhov <dmitry.torokhov@gmail.com>
wrote:

> Hi Anthony,
>
> On Fri, Jun 24, 2016 at 03:44:44PM -0400, Anthony Felice wrote:
> > Add driver for the Vybrid Tower CRTouch-based touchscreen. This is
> > required for the touchscreen on the TWR-LCD-RGB to work on the Vybrid
> > Tower platform.
> >
> > There is a known issue with this driver: rarely, SW1 on the TWR-LCD-RGB
> > module needs to be pressed in order for the touchscreen to begin
> > functioning.
>
> Hmm. Could it be that you want level interrupt and not edge? Or maybe
> you want to read state after requesting interrupt?
>

I dug up an old email thread about this - According to this, the reason for
the failure is the crtouch chip is configured with the CRTSLEEP bit
initially set.  This means the chip goes into sleep mode between touchscreen
scans, and if the host tries to access it during this time it will start to
wake up, but will NAK until it is initialized.   The hardware solution is
to tie the WAKEUP pin low on the crtouch chip; otherwise, the driver needs
to run a loop to clear the CRTSLEEP bit in the crtouch configuration
register to prevent the device from sleeping. I will investigate further,
if this is the solution I will include as part of V2 patchset.

>
> > Signed-off-by: Anthony Felice <tony.felice@timesys.com>
> > ---
> >  .../bindings/input/touchscreen/crtouch_ts.txt      |  14 ++
> >  drivers/input/touchscreen/Kconfig                  |  10 +
> >  drivers/input/touchscreen/Makefile                 |   1 +
> >  drivers/input/touchscreen/crtouch_ts.c             | 279
> +++++++++++++++++++++
> >  4 files changed, 304 insertions(+)
> >  create mode 100644
> Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> >  create mode 100644 drivers/input/touchscreen/crtouch_ts.c
> >
> > diff --git
> a/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> > new file mode 100644
> > index 0000000..cfb966c
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> > @@ -0,0 +1,14 @@
> > +* Freescale CRTOUCH based touchscreen
> > +
> > +Required Properties:
> > +- compatible must be fsl,crtouch_ts
> > +- reg: I2C address of the touchscreen
> > +- irq-gpio: GPIO to use as event IRQ
> > +
> > +Example:
> > +
> > +     touch: crtouch@49 {
> > +             compatible = "fsl,crtouch_ts";
> > +             reg = <0x49>;
> > +             irq-gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;
>
> You are not using it as gpio but only as interrupt source, so please
> set it up as regular interrupt and let I2C core set it up for you so
> that you will only need to call request_irq(client->irq, ...)
>
>                 interrupts = <&gpio0 21 IRQ_TYPE_EDGE_FALLING>;
>
> > +     };
> > diff --git a/drivers/input/touchscreen/Kconfig
> b/drivers/input/touchscreen/Kconfig
> > index 8ecdc38..799e342 100644
> > --- a/drivers/input/touchscreen/Kconfig
> > +++ b/drivers/input/touchscreen/Kconfig
> > @@ -1155,4 +1155,14 @@ config TOUCHSCREEN_ROHM_BU21023
> >         To compile this driver as a module, choose M here: the
> >         module will be called bu21023_ts.
> >
> > +config TOUCHSCREEN_CRTOUCH
> > +     tristate "Freescale CRTOUCH based touchscreen"
> > +     depends on I2C
> > +     help
> > +       Say Y here if you have a CRTOUCH based touchscreen
> > +       controller.
> > +
> > +       To compile this driver as a module, choose M here: the
> > +       module will be called crtouch_ts.
> > +
> >  endif
> > diff --git a/drivers/input/touchscreen/Makefile
> b/drivers/input/touchscreen/Makefile
> > index f42975e..8cb0a7a 100644
> > --- a/drivers/input/touchscreen/Makefile
> > +++ b/drivers/input/touchscreen/Makefile
> > @@ -95,3 +95,4 @@ obj-$(CONFIG_TOUCHSCREEN_TPS6507X)  += tps6507x-ts.o
> >  obj-$(CONFIG_TOUCHSCREEN_ZFORCE)     += zforce_ts.o
> >  obj-$(CONFIG_TOUCHSCREEN_COLIBRI_VF50)       += colibri-vf50-ts.o
> >  obj-$(CONFIG_TOUCHSCREEN_ROHM_BU21023)       += rohm_bu21023.o
> > +obj-$(CONFIG_TOUCHSCREEN_CRTOUCH)    += crtouch_ts.o
> > diff --git a/drivers/input/touchscreen/crtouch_ts.c
> b/drivers/input/touchscreen/crtouch_ts.c
> > new file mode 100644
> > index 0000000..bb87a8e
> > --- /dev/null
> > +++ b/drivers/input/touchscreen/crtouch_ts.c
> > @@ -0,0 +1,279 @@
> > +/*
> > + * Driver for Freescale Semiconductor CRTOUCH - A Resistive and
> Capacitive
> > + * touch device with i2c interface
> > + *
> > + * Copyright 2012 Freescale Semiconductor, Inc.
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; either version 2 of the License, or
> > + * (at your option) any later version.
> > + */
> > +
> > +#include <linux/module.h>
> > +#include <linux/init.h>
> > +#include <linux/i2c.h>
> > +#include <linux/interrupt.h>
> > +#include <linux/input.h>
> > +#include <linux/input/mt.h>
> > +#include <linux/slab.h>
> > +#include <linux/bitops.h>
> > +#include <linux/gpio.h>
> > +#include <linux/of.h>
> > +#include <linux/of_gpio.h>
> > +
> > +/* Resistive touch sense status registers */
> > +#define RES_STA_ERROR                        0x00
> > +#define RES_STA_STATUS1                      0x01
> > +#define      RES_STA_STATUS2                 0x02
> > +#define RES_STA_X_MSB                        0x03
> > +#define RES_STA_X_LSB                        0x04
> > +#define RES_STA_Y_MSB                        0x05
> > +#define RES_STA_Y_LSB                        0x06
> > +#define RES_STA_PRES_MSB             0x07
> > +#define RES_STA_RRES_LSB             0x08
> > +#define RES_STA_FIFO_STATUS          0x09
> > +#define RES_STA_FIFO_X_MSB           0x0a
> > +#define RES_STA_FIFO_X_LSB           0x0b
> > +#define RES_STA_FIFO_Y_MSB           0x0c
> > +#define RES_STA_FIFO_Y_LSB           0x0d
> > +#define RES_STA_FIFO_PRES_MSB                0x0e
> > +#define RES_STA_FIFO_PRES_LSB                0x0f
> > +#define RES_STA_UART_BRATE_MSB               0x10
> > +#define RES_STA_UART_BRATE_MID               0x11
> > +#define RES_STA_UART_BRATE_LSB               0x12
> > +#define RES_STA_DEV_IDEN             0x13
> > +#define RES_STA_SLIDE_DISPLACE               0x14
> > +#define RES_STA_ROTATE_ANGLE         0x15
> > +
> > +/* Resistive touch configuration registers */
> > +#define CR_CON_SYSTEM                        0x40
> > +#define CR_CON_TRIG_EVENT            0x41
> > +#define CR_CON_FIFO_SETUP            0x42
> > +#define CR_CON_SAMPLING_RATE         0x43
> > +#define CR_CON_X_DELAY_MSB           0x44
> > +#define CR_CON_X_DELAY_LSB           0x45
> > +#define CR_CON_Y_DELAY_MSB           0x46
> > +#define CR_CON_Y_DELAY_LSB           0x47
> > +#define CR_CON_Z_DELAY_MSB           0x48
> > +#define CR_CON_Z_DELAY_LSB           0x49
> > +#define CR_CON_DIS_HOR_MSB           0x4a
> > +#define CR_CON_DIS_HOR_LSB           0x4b
> > +#define CR_CON_DIS_VER_MSB           0x4c
> > +#define CR_CON_DIS_VER_LSB           0x4d
> > +#define CR_CON_SLIDE_STEPS           0x4e
> > +
> > +#define RTST_EVENT                   BIT(7)
> > +#define RTS2T_EVENT                  BIT(6)
> > +#define RTSZ_EVENT                   BIT(5)
> > +#define RTSR_EVENT                   BIT(4)
> > +#define RTSS_EVENT                   BIT(3)
> > +#define RTSF_EVENT                   BIT(2)
> > +#define RTSRDY_EVENT                 BIT(0)
> > +
> > +#define RTSSD_MASK                   BIT(2)
> > +#define RTSSD_H_NEG                  BIT(2)
> > +#define RTSSD_V_POS                  BIT(3)
> > +#define RTSSD_V_NEG                  BIT(4)
> > +
> > +#define RTSRD_MASK                   BIT(4)
> > +#define RTSRD_COUNTER_CLK_WISE               BIT(4)
> > +
> > +#define RTSZD_MASK                   BIT(5)
> > +#define RTSZD_ZOOM_OUT                       BIT(5)
> > +
> > +#define CRTOUCH_MAX_FINGER           2
> > +#define CRTOUCH_MAX_AREA             0xfff
> > +#define CRTOUCH_MAX_X                        0x01df
> > +#define CRTOUCH_MAX_Y                        0x010f
> > +
> > +struct crtouch_ts_data {
> > +     struct i2c_client       *client;
> > +     struct input_dev        *input_dev;
> > +};
> > +
> > +static u8 crtouch_read_reg(struct i2c_client *client, int addr)
> > +{
> > +     return i2c_smbus_read_byte_data(client, addr);
> > +}
> > +
> > +static int crtouch_write_reg(struct i2c_client *client, int addr, int
> data)
> > +{
> > +     return i2c_smbus_write_byte_data(client, addr, data);
> > +}
> > +
> > +static void calibration_pointer(u16 *x_orig, u16 *y_orig)
> > +{
> > +     u16 x, y;
> > +
> > +     x = CRTOUCH_MAX_X - *x_orig;
> > +     *x_orig = x;
> > +
> > +     y = CRTOUCH_MAX_Y - *y_orig;
> > +     *y_orig = y;
> > +}
> > +
> > +static irqreturn_t crtouch_ts_interrupt(int irq, void *dev_id)
> > +{
> > +     struct crtouch_ts_data *data = dev_id;
> > +     struct i2c_client *client = data->client;
> > +     u8 status1;
> > +     u16 valuep, valuex, valuey;
> > +
> > +     status1 = crtouch_read_reg(client, RES_STA_STATUS1);
> > +
> > +     /* For single touch */
> > +     if (status1 & RTST_EVENT) {
> > +             valuep = crtouch_read_reg(client, RES_STA_PRES_MSB);
> > +             valuep = ((valuep << 8) |
> > +                     crtouch_read_reg(client, RES_STA_RRES_LSB));
>
> Is it possible to read 2 bytes at once?
>
> > +             valuex = crtouch_read_reg(client, RES_STA_X_MSB);
> > +             valuex = ((valuex << 8) |
> > +                     crtouch_read_reg(client, RES_STA_X_LSB));
> > +             valuey = crtouch_read_reg(client, RES_STA_Y_MSB);
> > +             valuey = ((valuey << 8) |
> > +                     crtouch_read_reg(client, RES_STA_Y_LSB));
> > +             calibration_pointer(&valuex, &valuey);
>
> I'd do conversion inline - it is clearer what is going on.
>
> > +             input_report_key(data->input_dev, BTN_TOUCH, 1);
> > +             input_report_abs(data->input_dev, ABS_X, valuex);
> > +             input_report_abs(data->input_dev, ABS_Y, valuey);
> > +             input_report_abs(data->input_dev, ABS_PRESSURE, valuep);
> > +             input_sync(data->input_dev);
> > +     } else {
> > +             input_report_abs(data->input_dev, ABS_PRESSURE, 0);
> > +             input_event(data->input_dev, EV_KEY, BTN_TOUCH, 0);
> > +             input_sync(data->input_dev);
> > +     }
>
> input_sync() can go here.
>
> > +
> > +     return IRQ_HANDLED;
> > +}
> > +
> > +static void crtouch_ts_reg_init(struct crtouch_ts_data *data)
> > +{
> > +     struct i2c_client *client = data->client;
> > +
> > +     crtouch_write_reg(client, CR_CON_SYSTEM, 0x9c);
> > +     crtouch_write_reg(client, CR_CON_TRIG_EVENT, 0xf9);
> > +     crtouch_write_reg(client, CR_CON_FIFO_SETUP, 0x1f);
> > +     crtouch_write_reg(client, CR_CON_SAMPLING_RATE, 0x08);
> > +     crtouch_write_reg(client, CR_CON_DIS_HOR_MSB, 0x01);
> > +     crtouch_write_reg(client, CR_CON_DIS_HOR_LSB, 0xdf);
> > +     crtouch_write_reg(client, CR_CON_DIS_VER_MSB, 0x01);
> > +     crtouch_write_reg(client, CR_CON_DIS_VER_LSB, 0x0f);
>
> Should we fetch any of this data from DTS? I assume CR_CON_DIS_HOR/VER
> is resolution? Or not?
>

Yes, the HOR/VER info can at least be fetched from DTS. I will fix as part
of V2 patchset.


>
> Also, why no error handling?
>
> > +}
> > +
> > +static int crtouch_ts_probe(struct i2c_client *client,
> > +                         const struct i2c_device_id *id)
> > +{
> > +     struct crtouch_ts_data *data;
> > +     struct input_dev *input_dev;
> > +     int error = -1, irq_gpio;
> > +
> > +     dev_info(&client->dev, "Freescale CRTOUCH driver\n");
>
> Please drop this.
>
> > +
> > +     data = kzalloc(sizeof(*data), GFP_KERNEL);
> > +     input_dev = input_allocate_device();
>
> Please use devm* and you will be able to get rid of crtouch_ts_remove().
>
> > +     if (!data || !input_dev) {
> > +             dev_err(&client->dev, "Failed to allocate memory\n");
> > +             error = -ENOMEM;
> > +             goto err_free_mem;
> > +     }
> > +
> > +     data->client = client;
> > +     data->input_dev = input_dev;
> > +
> > +     input_dev->name = "crtouch_ts";
> > +     input_dev->id.bustype = BUS_I2C;
> > +     input_dev->dev.parent = &client->dev;
> > +
> > +     /* For single touch */
> > +     __set_bit(EV_KEY, input_dev->evbit);
> > +     __set_bit(BTN_TOUCH, input_dev->keybit);
> > +     __set_bit(EV_ABS, input_dev->evbit);
> > +     __set_bit(ABS_X, input_dev->absbit);
> > +     __set_bit(ABS_Y, input_dev->absbit);
> > +     __set_bit(ABS_PRESSURE, input_dev->absbit);
> > +
> > +     input_set_abs_params(input_dev, ABS_X, 0, CRTOUCH_MAX_X, 0, 0);
> > +     input_set_abs_params(input_dev, ABS_Y, 0, CRTOUCH_MAX_Y, 0, 0);
> > +     input_set_abs_params(input_dev, ABS_PRESSURE, 0,
> > +                          CRTOUCH_MAX_AREA, 0, 0);
> > +
> > +     input_set_drvdata(input_dev, data);
> > +
> > +     crtouch_ts_reg_init(data);
> > +
> > +     irq_gpio = of_get_named_gpio(client->dev.of_node, "irq-gpio", 0);
> > +     if (!gpio_is_valid(irq_gpio))
> > +             goto err_free_mem;
> > +
> > +     error = gpio_request_one(irq_gpio, GPIOF_IN, "TS_IRQ");
> > +     if (error) {
> > +             dev_err(&client->dev, "Failed to request gpio\n");
> > +             goto err_free_mem;
> > +     }
> > +
> > +     error = request_threaded_irq(gpio_to_irq(irq_gpio), NULL,
> > +                                  crtouch_ts_interrupt,
> > +                                  IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
> > +                                  "crtouch_ts", data);
>
> As i mentioned above replace everything starting with of_get_named_gpio
> with:
>
>         error = devm_request_threaded_irq(&cleint->dev, client->irq,
>                                           NULL, crtouch_ts_interrupt,
>                                           IRQF_ONESHOT,
>                                           "crtouch_ts", data);
>
> > +
> > +     if (error) {
> > +             dev_err(&client->dev, "Failed to register interrupt\n");
> > +             goto err_free_mem;
> > +     }
> > +
> > +     error = input_register_device(data->input_dev);
> > +     if (error)
> > +             goto err_free_irq;
> > +
> > +     i2c_set_clientdata(client, data);
> > +     return 0;
> > +
> > +err_free_irq:
> > +     free_irq(client->irq, data);
> > +err_free_mem:
> > +     input_free_device(input_dev);
> > +     kfree(data);
> > +     return error;
> > +}
> > +
> > +static int crtouch_ts_remove(struct i2c_client *client)
> > +{
> > +     struct crtouch_ts_data *data = i2c_get_clientdata(client);
> > +
> > +     free_irq(client->irq, data);
> > +     input_unregister_device(data->input_dev);
> > +     kfree(data);
>
> With devm it can all be dropped.
>
> > +
> > +     return 0;
> > +}
> > +
> > +static const struct i2c_device_id crtouch_ts_id[] = {
> > +     {"crtouch_ts", 0},
> > +     { }
> > +};
> > +MODULE_DEVICE_TABLE(i2c, crtouch_ts_id);
> > +
> > +static const struct of_device_id crtouch_ts_dt_ids[] = {
> > +     { .compatible = "fsl,crtouch_ts", },
> > +     { /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, crtouch_ts_dt_ids);
> > +
> > +static struct i2c_driver crtouch_ts_i2c_driver = {
> > +     .driver = {
> > +                .name = "crtouch_ts",
> > +                .owner = THIS_MODULE,
>
> No need to set owner.
>
> > +                .of_match_table = crtouch_ts_dt_ids,
>
>                         .of_match_table = of_match_ptr(crtouch_ts_dt_ids),
>
> Also, no PM methods?
>
>
Well, the main reason for no PM methods is the original driver did not have
PM methods. I can implement sleep/resume methods, and if all is working
well will submit as part of V2.


> > +                },
> > +     .probe = crtouch_ts_probe,
> > +     .remove = crtouch_ts_remove,
> > +     .id_table = crtouch_ts_id,
> > +};
> > +
> > +module_i2c_driver(crtouch_ts_i2c_driver);
> > +
> > +MODULE_AUTHOR("Alison Wang <b18965@freescale.com>");
> > +MODULE_DESCRIPTION("Touchscreen driver for Freescale CRTOUCH");
> > +MODULE_LICENSE("GPL");
> > --
> > 2.7.4
> >
>
> Thanks.
>
> --
> Dmitry
>



-- 
Tony Felice
Support Engineering Manager
Timesys Corporation

[-- Attachment #1.2: Type: text/html, Size: 21883 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver
  2016-06-24 19:44 ` [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver Anthony Felice
       [not found]   ` <1466797486-31558-3-git-send-email-tony.felice-jEh4hwF5bVhBDgjK7y7TUQ@public.gmane.org>
  2016-06-25 20:40   ` Stefan Agner
@ 2016-06-28 20:55   ` Rob Herring
  2 siblings, 0 replies; 11+ messages in thread
From: Rob Herring @ 2016-06-28 20:55 UTC (permalink / raw)
  To: Anthony Felice
  Cc: mark.rutland, devicetree, maitysanchayan, damien.riegel,
	linux-kernel, dmitry.torokhov, linux, sre, mwelling, geert,
	dri-devel, kernel, linux-input, fabio.estevam, shawnguo,
	linux-arm-kernel

On Fri, Jun 24, 2016 at 03:44:44PM -0400, Anthony Felice wrote:
> Add driver for the Vybrid Tower CRTouch-based touchscreen. This is
> required for the touchscreen on the TWR-LCD-RGB to work on the Vybrid
> Tower platform.
> 
> There is a known issue with this driver: rarely, SW1 on the TWR-LCD-RGB
> module needs to be pressed in order for the touchscreen to begin
> functioning.
> 
> Signed-off-by: Anthony Felice <tony.felice@timesys.com>
> ---
>  .../bindings/input/touchscreen/crtouch_ts.txt      |  14 ++
>  drivers/input/touchscreen/Kconfig                  |  10 +
>  drivers/input/touchscreen/Makefile                 |   1 +
>  drivers/input/touchscreen/crtouch_ts.c             | 279 +++++++++++++++++++++
>  4 files changed, 304 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
>  create mode 100644 drivers/input/touchscreen/crtouch_ts.c
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> new file mode 100644
> index 0000000..cfb966c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/crtouch_ts.txt
> @@ -0,0 +1,14 @@
> +* Freescale CRTOUCH based touchscreen
> +
> +Required Properties:
> +- compatible must be fsl,crtouch_ts
> +- reg: I2C address of the touchscreen
> +- irq-gpio: GPIO to use as event IRQ
> +
> +Example:
> +
> +	touch: crtouch@49 {

touchscreen@49

> +		compatible = "fsl,crtouch_ts";

Use '-', not '_'.

> +		reg = <0x49>;
> +		irq-gpio = <&gpio0 21 GPIO_ACTIVE_HIGH>;

As Dmitry said.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2016-06-28 20:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 19:44 [PATCH 0/4] Enable display and touchscreen for Vybrid Tower Anthony Felice
2016-06-24 19:44 ` [PATCH 1/4] ARM: dts: vf610-twr: Enable display controller Anthony Felice
2016-06-25 20:53   ` Stefan Agner
2016-06-27 17:11     ` Tony Felice
2016-06-24 19:44 ` [PATCH 2/4] input: touchscreen: crtouch_ts: Add driver Anthony Felice
     [not found]   ` <1466797486-31558-3-git-send-email-tony.felice-jEh4hwF5bVhBDgjK7y7TUQ@public.gmane.org>
2016-06-24 22:04     ` Dmitry Torokhov
2016-06-27 18:50       ` Tony Felice
2016-06-25 20:40   ` Stefan Agner
2016-06-28 20:55   ` Rob Herring
2016-06-24 19:44 ` [PATCH 3/4] ARM: dts: vf610-twr: Add crtouch node and pinmux Anthony Felice
2016-06-24 19:44 ` [PATCH 4/4] ARM: imx_v6_v7_defconfig: enable useful configurations for Vybrid Anthony Felice

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