Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH v4 5/7] Input: pixcir_i2c_ts: support upto 5 fingers and hardware provided tracking IDs
From: Roger Quadros @ 2014-05-05  9:04 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: rydberg-Hk7bIW8heu4wFerOooGFRg, balbi-l0cyMroinI0,
	dmurphy-l0cyMroinI0, mugunthanvnm-l0cyMroinI0,
	nsekhar-l0cyMroinI0, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Roger Quadros
In-Reply-To: <1399280678-23925-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>

Some variants of the Pixcir touch controller support upto 5
simultaneous fingers and hardware tracking IDs. Prepare the driver
for that.

Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 74 ++++++++++++++++++++++++-------
 include/linux/input/pixcir_ts.h           | 12 +++++
 2 files changed, 69 insertions(+), 17 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 3123699..927aed1 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -27,18 +27,20 @@
 #include <linux/input/pixcir_ts.h>
 #include <linux/gpio.h>
 
-#define PIXCIR_MAX_SLOTS       2
+#define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
 
 struct pixcir_i2c_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
-	const struct pixcir_ts_platform_data *chip;
+	const struct pixcir_ts_platform_data *pdata;
 	bool exiting;
+	int max_fingers;	/* Max fingers supported in this instance */
 };
 
 struct pixcir_touch {
 	int x;
 	int y;
+	int id;
 };
 
 struct pixcir_report_data {
@@ -49,13 +51,21 @@ struct pixcir_report_data {
 static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
 			    struct pixcir_report_data *report)
 {
-	u8 rdbuf[10], wrbuf[1] = { 0 };
+	u8 rdbuf[2 + PIXCIR_MAX_SLOTS * 5];
+	u8 wrbuf[1] = { 0 };
 	u8 *bufptr;
 	u8 touch;
 	int ret, i;
+	int readsize;
+	const struct pixcir_i2c_chip_data *chip = &tsdata->pdata->chip;
 
 	memset(report, 0, sizeof(struct pixcir_report_data));
 
+	i = chip->has_hw_ids ? 1 : 0;
+	readsize = 2 + tsdata->max_fingers * (4 + i);
+	if (readsize > sizeof(rdbuf))
+		readsize = sizeof(rdbuf);
+
 	ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf));
 	if (ret != sizeof(wrbuf)) {
 		dev_err(&tsdata->client->dev,
@@ -64,7 +74,7 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
 		return;
 	}
 
-	ret = i2c_master_recv(tsdata->client, rdbuf, sizeof(rdbuf));
+	ret = i2c_master_recv(tsdata->client, rdbuf, readsize);
 	if (ret != sizeof(rdbuf)) {
 		dev_err(&tsdata->client->dev,
 			"%s: i2c_master_recv failed(), ret=%d\n",
@@ -73,8 +83,8 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
 	}
 
 	touch = rdbuf[0] & 0x7;
-	if (touch > PIXCIR_MAX_SLOTS)
-		touch = PIXCIR_MAX_SLOTS;
+	if (touch > tsdata->max_fingers)
+		touch = tsdata->max_fingers;
 
 	report->num_touches = touch;
 	bufptr = &rdbuf[2];
@@ -83,7 +93,12 @@ static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
 		report->touches[i].x = (bufptr[1] << 8) | bufptr[0];
 		report->touches[i].y = (bufptr[3] << 8) | bufptr[2];
 
-		bufptr = &bufptr[4];
+		if (chip->has_hw_ids) {
+			report->touches[i].id = bufptr[4];
+			bufptr = &bufptr[5];
+		} else {
+			bufptr = &bufptr[4];
+		}
 	}
 }
 
@@ -95,22 +110,35 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
 	struct pixcir_touch *touch;
 	int n, i, slot;
 	struct device *dev = &ts->client->dev;
+	const struct pixcir_i2c_chip_data *chip = &ts->pdata->chip;
 
 	n = report->num_touches;
 	if (n > PIXCIR_MAX_SLOTS)
 		n = PIXCIR_MAX_SLOTS;
 
-	for (i = 0; i < n; i++) {
-		touch = &report->touches[i];
-		pos[i].x = touch->x;
-		pos[i].y = touch->y;
-	}
+	if (!chip->has_hw_ids) {
+		for (i = 0; i < n; i++) {
+			touch = &report->touches[i];
+			pos[i].x = touch->x;
+			pos[i].y = touch->y;
+		}
 
-	input_mt_assign_slots(ts->input, slots, pos, n);
+		input_mt_assign_slots(ts->input, slots, pos, n);
+	}
 
 	for (i = 0; i < n; i++) {
 		touch = &report->touches[i];
-		slot = slots[i];
+
+		if (chip->has_hw_ids) {
+			slot = input_mt_get_slot_by_key(ts->input, touch->id);
+			if (slot < 0) {
+				dev_dbg(dev, "no free slot for id 0x%x\n",
+					touch->id);
+				continue;
+			}
+		} else {
+			slot = slots[i];
+		}
 
 		input_mt_slot(ts->input, slot);
 		input_mt_report_slot_state(ts->input,
@@ -130,7 +158,7 @@ static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
 static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 {
 	struct pixcir_i2c_ts_data *tsdata = dev_id;
-	const struct pixcir_ts_platform_data *pdata = tsdata->chip;
+	const struct pixcir_ts_platform_data *pdata = tsdata->pdata;
 	struct pixcir_report_data report;
 
 	while (!tsdata->exiting) {
@@ -359,6 +387,11 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 			dev_err(dev, "Invalid gpio_attb in pdata\n");
 			return -EINVAL;
 		}
+
+		if (pdata->chip.max_fingers <= 0) {
+			dev_err(dev, "Invalid max_fingers in pdata\n");
+			return -EINVAL;
+		}
 	}
 
 	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
@@ -373,7 +406,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 
 	tsdata->client = client;
 	tsdata->input = input;
-	tsdata->chip = pdata;
+	tsdata->pdata = pdata;
 
 	input->name = client->name;
 	input->id.bustype = BUS_I2C;
@@ -389,7 +422,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
 	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
 
-	error = input_mt_init_slots(input, PIXCIR_MAX_SLOTS,
+	tsdata->max_fingers = tsdata->pdata->chip.max_fingers;
+	if (tsdata->max_fingers > PIXCIR_MAX_SLOTS) {
+		tsdata->max_fingers = PIXCIR_MAX_SLOTS;
+		dev_info(dev, "Limiting maximum fingers to %d\n",
+			 tsdata->max_fingers);
+	}
+
+	error = input_mt_init_slots(input, tsdata->max_fingers,
 				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
 	if (error) {
 		dev_err(dev, "Error initializing Multi-Touch slots\n");
diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h
index 160cf35..7bae83b 100644
--- a/include/linux/input/pixcir_ts.h
+++ b/include/linux/input/pixcir_ts.h
@@ -43,10 +43,22 @@ enum pixcir_int_mode {
 #define PIXCIR_INT_ENABLE	(1UL << 3)
 #define PIXCIR_INT_POL_HIGH	(1UL << 2)
 
+/**
+ * struct pixcir_irc_chip_data - chip related data
+ * @max_fingers:	Max number of fingers reported simultaneously by h/w
+ * @has_hw_ids:		Hardware supports finger tracking IDs
+ *
+ */
+struct pixcir_i2c_chip_data {
+	u8 max_fingers;
+	bool has_hw_ids;
+};
+
 struct pixcir_ts_platform_data {
 	int x_max;
 	int y_max;
 	int gpio_attb;		/* GPIO connected to ATTB line */
+	struct pixcir_i2c_chip_data chip;
 };
 
 #endif
-- 
1.8.3.2

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

* [PATCH v4 6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend
From: Roger Quadros @ 2014-05-05  9:04 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: rydberg-Hk7bIW8heu4wFerOooGFRg, balbi-l0cyMroinI0,
	dmurphy-l0cyMroinI0, mugunthanvnm-l0cyMroinI0,
	nsekhar-l0cyMroinI0, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Roger Quadros
In-Reply-To: <1399280678-23925-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>

Improve the suspend and resume handlers to allow the device
to wakeup the system from suspend.

Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Acked-by: Mugunthan V N <mugunthanvnm-l0cyMroinI0@public.gmane.org>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 53 ++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 927aed1..5f6a27e 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -348,21 +348,66 @@ static void pixcir_input_close(struct input_dev *dev)
 static int pixcir_i2c_ts_suspend(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
+	struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
+	struct input_dev *input = ts->input;
+	int ret = 0;
+
+	mutex_lock(&input->mutex);
+
+	if (input->users) {
+		ret = pixcir_stop(ts);
+		if (ret)
+			goto unlock;
+	}
+
+	/*
+	 * If wakeup is enabled we need to enable interrupt generation
+	 * but don't need to process any reports i.e. ts->exiting must be true.
+	 */
+	if (device_may_wakeup(&client->dev)) {
+		/* enable wakeup interrupt generation */
+		ret = pixcir_int_enable(ts, 1);
+		if (ret) {
+			dev_err(dev, "Failed to enable interrupt generation\n");
+			goto unlock;
+		}
 
-	if (device_may_wakeup(&client->dev))
 		enable_irq_wake(client->irq);
+	}
 
-	return 0;
+unlock:
+	mutex_unlock(&input->mutex);
+
+	return ret;
 }
 
 static int pixcir_i2c_ts_resume(struct device *dev)
 {
 	struct i2c_client *client = to_i2c_client(dev);
+	struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
+	struct input_dev *input = ts->input;
+	int ret = 0;
 
-	if (device_may_wakeup(&client->dev))
+	mutex_lock(&input->mutex);
+
+	if (device_may_wakeup(&client->dev)) {
 		disable_irq_wake(client->irq);
 
-	return 0;
+		/* disable wakeup interrupt generation */
+		ret = pixcir_int_enable(ts, 0);
+		if (ret) {
+			dev_err(dev, "Failed to disable interrupt generation\n");
+			goto unlock;
+		}
+	}
+
+	if (input->users)
+		ret = pixcir_start(ts);
+
+unlock:
+	mutex_unlock(&input->mutex);
+
+	return ret;
 }
 #endif
 
-- 
1.8.3.2

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

* [PATCH v4 7/7] Input: pixcir_i2c_ts: Add device tree support
From: Roger Quadros @ 2014-05-05  9:04 UTC (permalink / raw)
  To: dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w
  Cc: rydberg-Hk7bIW8heu4wFerOooGFRg, balbi-l0cyMroinI0,
	dmurphy-l0cyMroinI0, mugunthanvnm-l0cyMroinI0,
	nsekhar-l0cyMroinI0, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA, Roger Quadros
In-Reply-To: <1399280678-23925-1-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>

Provide device tree support and binding information.
Also provide support for a new chip "pixcir_tangoc".

Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
---
 .../bindings/input/touchscreen/pixcir_i2c_ts.txt   | 26 ++++++++
 .../devicetree/bindings/vendor-prefixes.txt        |  1 +
 drivers/input/touchscreen/pixcir_i2c_ts.c          | 78 ++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
new file mode 100644
index 0000000..0ab9505
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt
@@ -0,0 +1,26 @@
+* Pixcir I2C touchscreen controllers
+
+Required properties:
+- compatible: must be "pixcir,pixcir_ts" or "pixcir,pixcir_tangoc"
+- reg: I2C address of the chip
+- interrupts: interrupt to which the chip is connected
+- attb-gpio: GPIO connected to the ATTB line of the chip
+- x-size: horizontal resolution of touchscreen
+- y-size: vertical resolution of touchscreen
+
+Example:
+
+	i2c@00000000 {
+		/* ... */
+
+		pixcir_ts@5c {
+			compatible = "pixcir,pixcir_ts";
+			reg = <0x5c>;
+			interrupts = <2 0>;
+			attb-gpio = <&gpf 2 0 2>;
+			x-size = <800>;
+			y-size = <600>;
+		};
+
+		/* ... */
+	};
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index abc3080..2270ebe 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -94,6 +94,7 @@ panasonic	Panasonic Corporation
 phytec	PHYTEC Messtechnik GmbH
 picochip	Picochip Ltd
 plathome	Plat'Home Co., Ltd.
+pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 powervr	PowerVR (deprecated, use img)
 qca	Qualcomm Atheros, Inc.
 qcom	Qualcomm Technologies, Inc
diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 5f6a27e..bd547ea 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -26,6 +26,9 @@
 #include <linux/input/mt.h>
 #include <linux/input/pixcir_ts.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/of_device.h>
 
 #define PIXCIR_MAX_SLOTS       5 /* Max fingers supported by driver */
 
@@ -414,16 +417,70 @@ unlock:
 static SIMPLE_DEV_PM_OPS(pixcir_dev_pm_ops,
 			 pixcir_i2c_ts_suspend, pixcir_i2c_ts_resume);
 
+#ifdef CONFIG_OF
+static const struct of_device_id pixcir_of_match[];
+
+static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
+{
+	struct pixcir_ts_platform_data *pdata;
+	struct device_node *np = dev->of_node;
+
+	const struct of_device_id *match;
+
+	match = of_match_device(of_match_ptr(pixcir_of_match), dev);
+	if (!match)
+		return ERR_PTR(-EINVAL);
+
+	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return ERR_PTR(-ENOMEM);
+
+	pdata->chip = *(const struct pixcir_i2c_chip_data *)match->data;
+
+	pdata->gpio_attb = of_get_named_gpio(np, "attb-gpio", 0);
+	/* gpio_attb validity is checked in probe */
+
+	if (of_property_read_u32(np, "x-size", &pdata->x_max)) {
+		dev_err(dev, "Failed to get x-size property\n");
+		return ERR_PTR(-EINVAL);
+	}
+	pdata->x_max -= 1;
+
+	if (of_property_read_u32(np, "y-size", &pdata->y_max)) {
+		dev_err(dev, "Failed to get y-size property\n");
+		return ERR_PTR(-EINVAL);
+	}
+	pdata->y_max -= 1;
+
+	dev_dbg(dev, "%s: x %d, y %d, gpio %d\n", __func__,
+		pdata->x_max + 1, pdata->y_max + 1, pdata->gpio_attb);
+
+	return pdata;
+}
+#else
+static struct pixcir_ts_platform_data *pixcir_parse_dt(struct device *dev)
+{
+	return ERR_PTR(-EINVAL);
+}
+#endif
+
 static int pixcir_i2c_ts_probe(struct i2c_client *client,
 					 const struct i2c_device_id *id)
 {
 	const struct pixcir_ts_platform_data *pdata =
 			dev_get_platdata(&client->dev);
 	struct device *dev = &client->dev;
+	struct device_node *np = dev->of_node;
 	struct pixcir_i2c_ts_data *tsdata;
 	struct input_dev *input;
 	int error;
 
+	if (np && !pdata) {
+		pdata = pixcir_parse_dt(dev);
+		if (IS_ERR(pdata))
+			return PTR_ERR(pdata);
+	}
+
 	if (!pdata) {
 		dev_err(&client->dev, "platform data not defined\n");
 		return -EINVAL;
@@ -534,15 +591,36 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client)
 
 static const struct i2c_device_id pixcir_i2c_ts_id[] = {
 	{ "pixcir_ts", 0 },
+	{ "pixcir_tangoc", 0 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, pixcir_i2c_ts_id);
 
+#ifdef CONFIG_OF
+static const struct pixcir_i2c_chip_data pixcir_ts_data = {
+	.max_fingers = 2,
+	/* no hw id support */
+};
+
+static const struct pixcir_i2c_chip_data pixcir_tangoc_data = {
+	.max_fingers = 5,
+	.has_hw_ids = true,
+};
+
+static const struct of_device_id pixcir_of_match[] = {
+	{ .compatible = "pixcir,pixcir_ts", .data = &pixcir_ts_data },
+	{ .compatible = "pixcir,pixcir_tangoc", .data = &pixcir_tangoc_data },
+	{ }
+};
+MODULE_DEVICE_TABLE(of, pixcir_of_match);
+#endif
+
 static struct i2c_driver pixcir_i2c_ts_driver = {
 	.driver = {
 		.owner	= THIS_MODULE,
 		.name	= "pixcir_ts",
 		.pm	= &pixcir_dev_pm_ops,
+		.of_match_table = of_match_ptr(pixcir_of_match),
 	},
 	.probe		= pixcir_i2c_ts_probe,
 	.remove		= pixcir_i2c_ts_remove,
-- 
1.8.3.2

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

* [PATCH v4 4/7] Input: pixcir_i2c_ts: Use Type-B Multi-Touch protocol
From: Roger Quadros @ 2014-05-05  9:04 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: rydberg, balbi, dmurphy, mugunthanvnm, nsekhar, linux-input,
	linux-kernel, devicetree, Roger Quadros
In-Reply-To: <1399280678-23925-1-git-send-email-rogerq@ti.com>

Switch to using the Type-B Multi-Touch protocol.

Signed-off-by: Roger Quadros <rogerq@ti.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 125 ++++++++++++++++++++++--------
 1 file changed, 94 insertions(+), 31 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index d0f6989..3123699 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -23,9 +23,12 @@
 #include <linux/slab.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
+#include <linux/input/mt.h>
 #include <linux/input/pixcir_ts.h>
 #include <linux/gpio.h>
 
+#define PIXCIR_MAX_SLOTS       2
+
 struct pixcir_i2c_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
@@ -33,12 +36,25 @@ struct pixcir_i2c_ts_data {
 	bool exiting;
 };
 
-static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
+struct pixcir_touch {
+	int x;
+	int y;
+};
+
+struct pixcir_report_data {
+	int num_touches;
+	struct pixcir_touch touches[PIXCIR_MAX_SLOTS];
+};
+
+static void pixcir_ts_parse(struct pixcir_i2c_ts_data *tsdata,
+			    struct pixcir_report_data *report)
 {
-	struct pixcir_i2c_ts_data *tsdata = data;
 	u8 rdbuf[10], wrbuf[1] = { 0 };
+	u8 *bufptr;
 	u8 touch;
-	int ret;
+	int ret, i;
+
+	memset(report, 0, sizeof(struct pixcir_report_data));
 
 	ret = i2c_master_send(tsdata->client, wrbuf, sizeof(wrbuf));
 	if (ret != sizeof(wrbuf)) {
@@ -56,45 +72,85 @@ static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
 		return;
 	}
 
-	touch = rdbuf[0];
-	if (touch) {
-		u16 posx1 = (rdbuf[3] << 8) | rdbuf[2];
-		u16 posy1 = (rdbuf[5] << 8) | rdbuf[4];
-		u16 posx2 = (rdbuf[7] << 8) | rdbuf[6];
-		u16 posy2 = (rdbuf[9] << 8) | rdbuf[8];
-
-		input_report_key(tsdata->input, BTN_TOUCH, 1);
-		input_report_abs(tsdata->input, ABS_X, posx1);
-		input_report_abs(tsdata->input, ABS_Y, posy1);
-
-		input_report_abs(tsdata->input, ABS_MT_POSITION_X, posx1);
-		input_report_abs(tsdata->input, ABS_MT_POSITION_Y, posy1);
-		input_mt_sync(tsdata->input);
-
-		if (touch == 2) {
-			input_report_abs(tsdata->input,
-					 ABS_MT_POSITION_X, posx2);
-			input_report_abs(tsdata->input,
-					 ABS_MT_POSITION_Y, posy2);
-			input_mt_sync(tsdata->input);
-		}
-	} else {
-		input_report_key(tsdata->input, BTN_TOUCH, 0);
+	touch = rdbuf[0] & 0x7;
+	if (touch > PIXCIR_MAX_SLOTS)
+		touch = PIXCIR_MAX_SLOTS;
+
+	report->num_touches = touch;
+	bufptr = &rdbuf[2];
+
+	for (i = 0; i < touch; i++) {
+		report->touches[i].x = (bufptr[1] << 8) | bufptr[0];
+		report->touches[i].y = (bufptr[3] << 8) | bufptr[2];
+
+		bufptr = &bufptr[4];
 	}
+}
+
+static void pixcir_ts_report(struct pixcir_i2c_ts_data *ts,
+			     struct pixcir_report_data *report)
+{
+	struct input_mt_pos pos[PIXCIR_MAX_SLOTS];
+	int slots[PIXCIR_MAX_SLOTS];
+	struct pixcir_touch *touch;
+	int n, i, slot;
+	struct device *dev = &ts->client->dev;
 
-	input_sync(tsdata->input);
+	n = report->num_touches;
+	if (n > PIXCIR_MAX_SLOTS)
+		n = PIXCIR_MAX_SLOTS;
+
+	for (i = 0; i < n; i++) {
+		touch = &report->touches[i];
+		pos[i].x = touch->x;
+		pos[i].y = touch->y;
+	}
+
+	input_mt_assign_slots(ts->input, slots, pos, n);
+
+	for (i = 0; i < n; i++) {
+		touch = &report->touches[i];
+		slot = slots[i];
+
+		input_mt_slot(ts->input, slot);
+		input_mt_report_slot_state(ts->input,
+					   MT_TOOL_FINGER, true);
+
+		input_event(ts->input, EV_ABS, ABS_MT_POSITION_X, touch->x);
+		input_event(ts->input, EV_ABS, ABS_MT_POSITION_Y, touch->y);
+
+		dev_dbg(dev, "%d: slot %d, x %d, y %d\n",
+			i, slot, touch->x, touch->y);
+	}
+
+	input_mt_sync_frame(ts->input);
+	input_sync(ts->input);
 }
 
 static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 {
 	struct pixcir_i2c_ts_data *tsdata = dev_id;
 	const struct pixcir_ts_platform_data *pdata = tsdata->chip;
+	struct pixcir_report_data report;
 
 	while (!tsdata->exiting) {
-		pixcir_ts_poscheck(tsdata);
-
-		if (gpio_get_value(pdata->gpio_attb))
+		/* parse packet */
+		pixcir_ts_parse(tsdata, &report);
+
+		/* report it */
+		pixcir_ts_report(tsdata, &report);
+
+		if (gpio_get_value(pdata->gpio_attb)) {
+			if (report.num_touches) {
+				/*
+				 * Last report with no finger up?
+				 * Do it now then.
+				 */
+				input_mt_sync_frame(tsdata->input);
+				input_sync(tsdata->input);
+			}
 			break;
+		}
 
 		msleep(20);
 	}
@@ -333,6 +389,13 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 	input_set_abs_params(input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0);
 	input_set_abs_params(input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0);
 
+	error = input_mt_init_slots(input, PIXCIR_MAX_SLOTS,
+				    INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED);
+	if (error) {
+		dev_err(dev, "Error initializing Multi-Touch slots\n");
+		return error;
+	}
+
 	input_set_drvdata(input, tsdata);
 
 	error = devm_gpio_request_one(dev, pdata->gpio_attb,
-- 
1.8.3.2


^ permalink raw reply related

* [PATCH v2] elantech: Fix elantech on Gigabyte U2442
From: Hans de Goede @ 2014-05-05 12:34 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Benjamin Tissoires, linux-input, Philipp Wolfer, Hans de Goede,
	stable

The hw_version 3 elantech touchpad on the Gigabyte U2442 does not accept
0x0b as initialization value for r10, this stand-alone version of the driver:
http://planet76.com/drivers/elantech/psmouse-elantech-v6.tar.bz2

Uses 0x03 which does work, so this means not setting bit 3 of r10 which sets:
"Enable Real H/W Resolution In Absolute mode"

Which will result in half the x and y resolution we get with that bit set,
so simply not setting it everywhere is not a solution. We've been unable
to find a way to identifty touchpads where setting the bit will fail, so this
patch uses a dmi based blacklist for this.

https://bugzilla.kernel.org/show_bug.cgi?id=61151

Cc: stable@vger.kernel.org
Reported-by: Philipp Wolfer <ph.wolfer@gmail.com>
Tested-by: Philipp Wolfer <ph.wolfer@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>

--

Changes in v2: Add cc: stable.
---
 Documentation/input/elantech.txt |  5 ++++-
 drivers/input/mouse/elantech.c   | 26 +++++++++++++++++++++++++-
 drivers/input/mouse/elantech.h   |  1 +
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Documentation/input/elantech.txt b/Documentation/input/elantech.txt
index 5602eb7..e1ae127 100644
--- a/Documentation/input/elantech.txt
+++ b/Documentation/input/elantech.txt
@@ -504,9 +504,12 @@ byte 5:
 * reg_10
 
    bit   7   6   5   4   3   2   1   0
-         0   0   0   0   0   0   0   A
+         0   0   0   0   R   F   T   A
 
          A: 1 = enable absolute tracking
+         T: 1 = enable two finger mode auto correct
+         F: 1 = disable ABS Position Filter
+         R: 1 = enable real hardware resolution
 
 6.2 Native absolute mode 6 byte packet format
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index 088d354..b96e978 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/delay.h>
+#include <linux/dmi.h>
 #include <linux/slab.h>
 #include <linux/module.h>
 #include <linux/input.h>
@@ -831,7 +832,11 @@ static int elantech_set_absolute_mode(struct psmouse *psmouse)
 		break;
 
 	case 3:
-		etd->reg_10 = 0x0b;
+		if (etd->set_hw_resolution)
+			etd->reg_10 = 0x0b;
+		else
+			etd->reg_10 = 0x03;
+
 		if (elantech_write_reg(psmouse, 0x10, etd->reg_10))
 			rc = -1;
 
@@ -1331,6 +1336,22 @@ static int elantech_reconnect(struct psmouse *psmouse)
 }
 
 /*
+ * Some hw_version 3 models go into error state when we try to set bit 3 of r10
+ */
+static const struct dmi_system_id no_hw_res_dmi_table[] = {
+#if defined(CONFIG_DMI) && defined(CONFIG_X86)
+	{
+		/* Gigabyte U2442 */
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "U2442"),
+		},
+	},
+#endif
+	{ }
+};
+
+/*
  * determine hardware version and set some properties according to it.
  */
 static int elantech_set_properties(struct elantech_data *etd)
@@ -1390,6 +1411,9 @@ static int elantech_set_properties(struct elantech_data *etd)
 	 */
 	etd->crc_enabled = ((etd->fw_version & 0x4000) == 0x4000);
 
+	/* Enable real hardware resolution on hw_version 3 ? */
+	etd->set_hw_resolution = !dmi_check_system(no_hw_res_dmi_table);
+
 	return 0;
 }
 
diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h
index 036a04a..9e0e2a1 100644
--- a/drivers/input/mouse/elantech.h
+++ b/drivers/input/mouse/elantech.h
@@ -130,6 +130,7 @@ struct elantech_data {
 	bool jumpy_cursor;
 	bool reports_pressure;
 	bool crc_enabled;
+	bool set_hw_resolution;
 	unsigned char hw_version;
 	unsigned int fw_version;
 	unsigned int single_finger_reports;
-- 
1.9.0

^ permalink raw reply related

* Re: [PATCH] HID: core: fix computation of the report size
From: Jiri Kosina @ 2014-05-05 13:55 UTC (permalink / raw)
  To: Benjamin Tissoires; +Cc: linux-input, linux-kernel, Matthias Bayer
In-Reply-To: <1398894520-30407-1-git-send-email-benjamin.tissoires@redhat.com>

On Wed, 30 Apr 2014, Benjamin Tissoires wrote:

> The extra seven bits are only required when allocating the report buffer.
> We can not use those extra bytes for the length of the report in the
> generic implementation of .request because the device might (will) refuse
> the set_report command.
> This has been verified on the Atmel touchpad found on the Samsung Ativ 9
> plus, which uses hid-multitouch and HID over I2C. Without this fix, the
> device refuses to switch to the multitouch mode, and it becomes unresponsive
> from the user point of view.
> 
> Actually, this has been discussed during the initial submission of the
> commit 4fa5a7f76cc7b6ac87f57741edd2b124851d119f, see
> https://patchwork.kernel.org/patch/3621751/
> 
> Unfortunately, I completely forgot about it later.
> 
> Reported-by: Matthias Bayer <thematthiasbayer@gmail.com>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
> 
> Hi Jiri,
> 
> can you schedule this fix for 3.15?
> 
> Fortunately, the device required some ACPI changes, so it was not seen at all
> in 3.13 and before. I am not sure of the status of 3.14, but it is definitively
> not working in 3.15.

Gah, indeed, a nasty bug.

Queuing for 3.15 now, thanks!

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: [PATCH] hid-quirks: Add NO_INIT_REPORTS quirk for Synaptics Touch Pad V 103S
From: Jiri Kosina @ 2014-05-05 13:57 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Dmitry Torokhov, Benjamin Tissoires, Peter Hutterer, linux-input,
	stable
In-Reply-To: <1399052893-3762-1-git-send-email-hdegoede@redhat.com>

On Fri, 2 May 2014, Hans de Goede wrote:

> This touchpad seriously dislikes init reports, not only timeing out, but
> also refusing to work after this.
> 
> Cc: stable@vger.kernel.org
> Reported-and-tested-by: Vincent Fortier <th0ma7@gmail.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  drivers/hid/hid-ids.h           | 1 +
>  drivers/hid/usbhid/hid-quirks.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index c8af720..43f246e 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -834,6 +834,7 @@
>  #define USB_DEVICE_ID_SYNAPTICS_LTS2	0x1d10
>  #define USB_DEVICE_ID_SYNAPTICS_HD	0x0ac3
>  #define USB_DEVICE_ID_SYNAPTICS_QUAD_HD	0x1ac3
> +#define USB_DEVICE_ID_SYNAPTICS_TP_V103	0x5710
>  
>  #define USB_VENDOR_ID_THINGM		0x27b8
>  #define USB_DEVICE_ID_BLINK1		0x01ed
> diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c
> index dbd8387..8e4ddb3 100644
> --- a/drivers/hid/usbhid/hid-quirks.c
> +++ b/drivers/hid/usbhid/hid-quirks.c
> @@ -119,6 +119,7 @@ static const struct hid_blacklist {
>  	{ USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_LTS2, HID_QUIRK_NO_INIT_REPORTS },
>  	{ USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_HD, HID_QUIRK_NO_INIT_REPORTS },
>  	{ USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD, HID_QUIRK_NO_INIT_REPORTS },
> +	{ USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP_V103, HID_QUIRK_NO_INIT_REPORTS },
>  
>  	{ 0, 0 }
>  };

Applied, thanks.

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
From: Tony Lindgren @ 2014-05-05 19:41 UTC (permalink / raw)
  To: Sebastian Reichel
  Cc: Sebastian Reichel, Dmitry Torokhov, Dmitry Torokhov, linux-input,
	Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
	devicetree, linux-omap, linux-kernel
In-Reply-To: <1398470179-20880-2-git-send-email-sre@kernel.org>

* Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> Add common DT binding documentation for touchscreen devices and
> implement input_parse_touchscreen_of_params, which parses the common
> properties and configures the input device accordingly.
> 
> The method currently does not interpret the axis inversion properties,
> since there is no matching flag in the generic linux input device.
> 
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
>  drivers/input/input.c                              | 34 ++++++++++++++++++++++
>  include/linux/input.h                              |  8 +++++
>  3 files changed, 69 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> new file mode 100644
> index 0000000..d8e0616
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> @@ -0,0 +1,27 @@
> +General Touchscreen Properties:
> +
> +Optional properties for Touchscreens:
> + - touchscreen-size-x		: horizontal resolution of touchscreen
> +				  (in pixels)
> + - touchscreen-size-y		: vertical resolution of touchscreen
> +				  (in pixels)
> + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> +				  dependent on the controller)
> + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> +				  device (in pixels)
> + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> +				  device (in pixels)
> + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> +				  device (arbitrary range dependent on the
> +				  controller)
> + - touchscreen-inverted-x	: X axis is inverted (boolean)
> + - touchscreen-inverted-y	: Y axis is inverted (boolean)

We probably also need something to swap x and y depending on the
display orientation in addition to the touchscreen-inverted-x and y.
Just swapping x and y is not enough depending if we rotate by 270
degrees instead of 90 degrees.

Naturally that part can be added later.

Regards,

That 

^ permalink raw reply

* Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
From: Dmitry Torokhov @ 2014-05-05 19:51 UTC (permalink / raw)
  To: Tony Lindgren
  Cc: Sebastian Reichel, Sebastian Reichel, linux-input, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
	linux-omap, linux-kernel
In-Reply-To: <20140505194125.GD25949@atomide.com>

On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > Add common DT binding documentation for touchscreen devices and
> > implement input_parse_touchscreen_of_params, which parses the common
> > properties and configures the input device accordingly.
> > 
> > The method currently does not interpret the axis inversion properties,
> > since there is no matching flag in the generic linux input device.
> > 
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > ---
> >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> >  include/linux/input.h                              |  8 +++++
> >  3 files changed, 69 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > 
> > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > new file mode 100644
> > index 0000000..d8e0616
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > @@ -0,0 +1,27 @@
> > +General Touchscreen Properties:
> > +
> > +Optional properties for Touchscreens:
> > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > +				  (in pixels)
> > + - touchscreen-size-y		: vertical resolution of touchscreen
> > +				  (in pixels)
> > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > +				  dependent on the controller)
> > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > +				  device (in pixels)
> > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > +				  device (in pixels)
> > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > +				  device (arbitrary range dependent on the
> > +				  controller)

Fuzz seems like linux-specific property, not generic one.


> > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> 
> We probably also need something to swap x and y depending on the
> display orientation in addition to the touchscreen-inverted-x and y.
> Just swapping x and y is not enough depending if we rotate by 270
> degrees instead of 90 degrees.
> 
> Naturally that part can be added later.

So far we've been relying on upper layers (such as tslib) to perform
such transformations rather than re-implementing it in every driver. Are
we saying that we need to implement this in input core?

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
From: Tony Lindgren @ 2014-05-05 20:12 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Sebastian Reichel, Sebastian Reichel, linux-input, Rob Herring,
	Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala, devicetree,
	linux-omap, linux-kernel
In-Reply-To: <20140505195139.GA26978@core.coreip.homeip.net>

* Dmitry Torokhov <dmitry.torokhov@gmail.com> [140505 12:52]:
> On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> > * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > > Add common DT binding documentation for touchscreen devices and
> > > implement input_parse_touchscreen_of_params, which parses the common
> > > properties and configures the input device accordingly.
> > > 
> > > The method currently does not interpret the axis inversion properties,
> > > since there is no matching flag in the generic linux input device.
> > > 
> > > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > > ---
> > >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> > >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> > >  include/linux/input.h                              |  8 +++++
> > >  3 files changed, 69 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > new file mode 100644
> > > index 0000000..d8e0616
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > @@ -0,0 +1,27 @@
> > > +General Touchscreen Properties:
> > > +
> > > +Optional properties for Touchscreens:
> > > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-size-y		: vertical resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > > +				  dependent on the controller)
> > > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > > +				  device (arbitrary range dependent on the
> > > +				  controller)
> 
> Fuzz seems like linux-specific property, not generic one.
> 
> 
> > > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> > 
> > We probably also need something to swap x and y depending on the
> > display orientation in addition to the touchscreen-inverted-x and y.
> > Just swapping x and y is not enough depending if we rotate by 270
> > degrees instead of 90 degrees.
> > 
> > Naturally that part can be added later.
> 
> So far we've been relying on upper layers (such as tslib) to perform
> such transformations rather than re-implementing it in every driver. Are
> we saying that we need to implement this in input core?

We seem to have that already partially implemented at least with
ti,swap-xy in Documentation/devicetree/bindings/input/ads7846.txt.

But that only works for the 90 degree rotation case as it's missing
something similar to touchscreen-inverted-x I just noticed few days
ago while trying to make some legacy code disappear :)

No idea where rotation should be specified. But if the panel is
rotated based on the DT property or kernel cmdline, probably the
touchscreen should be too? In most cases touchscreens are integrated
together with the LCD panel, and they are not separate like other
input devices.

Regards,

Tony

^ permalink raw reply

* [PATCH] iio:hid-sensor-hub: Add in quirk for sensor hub in Lenovo Ideapad Yogas
From: Peter F. Patel-Schneider @ 2014-05-05 22:55 UTC (permalink / raw)
  To: linux-input, jkosina; +Cc: Srinivas Pandruvada

The sensor hub in Lenovo Yogas needs the enumeration quirk.  I've been running 
the patch for over a month with no problems, whereas the unpatched drivers 
reliably mis-initialized the sensors. (This is a resending of a previous patch 
that had formatting issues.)

Signed-off-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
---
  drivers/hid/hid-ids.h        | 3 +++
  drivers/hid/hid-sensor-hub.c | 3 +++
  2 files changed, 6 insertions(+)

diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 5a5248f..f944e37 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -823,6 +823,9 @@
  #define USB_DEVICE_ID_SYNAPTICS_HD	0x0ac3
  #define USB_DEVICE_ID_SYNAPTICS_QUAD_HD	0x1ac3

+#define USB_VENDOR_ID_TEXAS_INSTRUMENTS	0x2047
+#define USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA	0x0855
+
  #define USB_VENDOR_ID_THINGM		0x27b8
  #define USB_DEVICE_ID_BLINK1		0x01ed

diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
index 46f4480..597732b 100644
--- a/drivers/hid/hid-sensor-hub.c
+++ b/drivers/hid/hid-sensor-hub.c
@@ -665,6 +665,9 @@ static const struct hid_device_id sensor_hub_devices[] = {
  	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_INTEL_1,
  			USB_DEVICE_ID_INTEL_HID_SENSOR),
  			.driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
+	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, USB_VENDOR_ID_TEXAS_INSTRUMENTS,
+		     USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA),
+		     .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
  	{ HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
  		     HID_ANY_ID) },
  	{ }


^ permalink raw reply related

* Re: [PATCH] iio:hid-sensor-hub: Add in quirk for sensor hub in Lenovo Ideapad Yogas
From: Srinivas Pandruvada @ 2014-05-05 23:03 UTC (permalink / raw)
  To: Peter F. Patel-Schneider; +Cc: linux-input, jkosina
In-Reply-To: <536816E4.2040109@gmail.com>

On 05/05/2014 03:55 PM, Peter F. Patel-Schneider wrote:
> The sensor hub in Lenovo Yogas needs the enumeration quirk.  I've been 
> running the patch for over a month with no problems, whereas the 
> unpatched drivers reliably mis-initialized the sensors. (This is a 
> resending of a previous patch that had formatting issues.)
>
> Signed-off-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>
> ---
>  drivers/hid/hid-ids.h        | 3 +++
>  drivers/hid/hid-sensor-hub.c | 3 +++
>  2 files changed, 6 insertions(+)
>
> diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
> index 5a5248f..f944e37 100644
> --- a/drivers/hid/hid-ids.h
> +++ b/drivers/hid/hid-ids.h
> @@ -823,6 +823,9 @@
>  #define USB_DEVICE_ID_SYNAPTICS_HD    0x0ac3
>  #define USB_DEVICE_ID_SYNAPTICS_QUAD_HD    0x1ac3
>
> +#define USB_VENDOR_ID_TEXAS_INSTRUMENTS    0x2047
> +#define USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA    0x0855
> +
>  #define USB_VENDOR_ID_THINGM        0x27b8
>  #define USB_DEVICE_ID_BLINK1        0x01ed
>
> diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c
> index 46f4480..597732b 100644
> --- a/drivers/hid/hid-sensor-hub.c
> +++ b/drivers/hid/hid-sensor-hub.c
> @@ -665,6 +665,9 @@ static const struct hid_device_id 
> sensor_hub_devices[] = {
>      { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, 
> USB_VENDOR_ID_INTEL_1,
>              USB_DEVICE_ID_INTEL_HID_SENSOR),
>              .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
> +    { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, 
> USB_VENDOR_ID_TEXAS_INSTRUMENTS,
> +             USB_DEVICE_ID_TEXAS_INSTRUMENTS_LENOVO_YOGA),
> +             .driver_data = HID_SENSOR_HUB_ENUM_QUIRK},
>      { HID_DEVICE(HID_BUS_ANY, HID_GROUP_SENSOR_HUB, HID_ANY_ID,
>               HID_ANY_ID) },
>      { }
>
>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Thanks,
Srinivas

^ permalink raw reply

* Re: [PATCH] iio:hid-sensor-hub: Add in quirk for sensor hub in Lenovo Ideapad Yogas
From: Jiri Kosina @ 2014-05-05 23:02 UTC (permalink / raw)
  To: Peter F. Patel-Schneider; +Cc: linux-input, Srinivas Pandruvada
In-Reply-To: <536816E4.2040109@gmail.com>

On Mon, 5 May 2014, Peter F. Patel-Schneider wrote:

> The sensor hub in Lenovo Yogas needs the enumeration quirk.  I've been running
> the patch for over a month with no problems, whereas the unpatched drivers
> reliably mis-initialized the sensors. (This is a resending of a previous patch
> that had formatting issues.)
> 
> Signed-off-by: Peter F. Patel-Schneider <pfpschneider@gmail.com>

Now applied. Will be pushing it for 3.15. Thanks,

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply

* Re: [PATCHv3 1/5] Input: add common DT binding for touchscreens
From: Sebastian Reichel @ 2014-05-05 23:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Tony Lindgren, linux-input, Rob Herring, Pawel Moll, Mark Rutland,
	Ian Campbell, Kumar Gala, devicetree, linux-omap, linux-kernel
In-Reply-To: <20140505195139.GA26978@core.coreip.homeip.net>

[-- Attachment #1: Type: text/plain, Size: 3183 bytes --]

On Mon, May 05, 2014 at 12:51:39PM -0700, Dmitry Torokhov wrote:
> On Mon, May 05, 2014 at 12:41:26PM -0700, Tony Lindgren wrote:
> > * Sebastian Reichel <sre@kernel.org> [140425 16:56]:
> > > Add common DT binding documentation for touchscreen devices and
> > > implement input_parse_touchscreen_of_params, which parses the common
> > > properties and configures the input device accordingly.
> > > 
> > > The method currently does not interpret the axis inversion properties,
> > > since there is no matching flag in the generic linux input device.
> > > 
> > > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > > ---
> > >  .../bindings/input/touchscreen/touchscreen.txt     | 27 +++++++++++++++++
> > >  drivers/input/input.c                              | 34 ++++++++++++++++++++++
> > >  include/linux/input.h                              |  8 +++++
> > >  3 files changed, 69 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > 
> > > diff --git a/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > new file mode 100644
> > > index 0000000..d8e0616
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt
> > > @@ -0,0 +1,27 @@
> > > +General Touchscreen Properties:
> > > +
> > > +Optional properties for Touchscreens:
> > > + - touchscreen-size-x		: horizontal resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-size-y		: vertical resolution of touchscreen
> > > +				  (in pixels)
> > > + - touchscreen-max-pressure	: maximum reported pressure (arbitrary range
> > > +				  dependent on the controller)
> > > + - touchscreen-fuzz-x		: horizontal noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-y		: vertical noise value of the absolute input
> > > +				  device (in pixels)
> > > + - touchscreen-fuzz-pressure	: pressure noise value of the absolute input
> > > +				  device (arbitrary range dependent on the
> > > +				  controller)
> 
> Fuzz seems like linux-specific property, not generic one.

I don't know about the term "fuzz", but the idea is pretty generic
IMHO. It's similar to debouncing switches/buttons.

> > > + - touchscreen-inverted-x	: X axis is inverted (boolean)
> > > + - touchscreen-inverted-y	: Y axis is inverted (boolean)
> > 
> > We probably also need something to swap x and y depending on the
> > display orientation in addition to the touchscreen-inverted-x and y.
> > Just swapping x and y is not enough depending if we rotate by 270
> > degrees instead of 90 degrees.
> > 
> > Naturally that part can be added later.
> 
> So far we've been relying on upper layers (such as tslib) to perform
> such transformations rather than re-implementing it in every driver. Are
> we saying that we need to implement this in input core?

I would appreciate to add this later to move on with this patchset.
Having the N900's touchscreen working via DT in 3.16 would be nice
now that the display is working :)

-- Sebastian

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply

* Re: [linux-sunxi] Re: [PATCH v5 8/8] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards
From: Maxime Ripard @ 2014-05-05 22:51 UTC (permalink / raw)
  To: Carlo Caione
  Cc: linux-arm-kernel, hdegoede, emilio, wens, sameo, dmitry.torokhov,
	linux-input, linux-doc, lgirdwood, broonie, lee.jones,
	boris.brezillon, linux-sunxi
In-Reply-To: <CAOQ7t2Z6rLAMGXocPNcKgOUp9iy6XZkh4O6jThPkdm5M6UMGtw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4733 bytes --]

On Sat, May 03, 2014 at 02:21:06PM +0200, Carlo Caione wrote:
> On Sat, May 3, 2014 at 3:09 AM, Maxime Ripard
> <maxime.ripard@free-electrons.com> wrote:
> > Hi,
> >
> > On Thu, May 01, 2014 at 02:29:34PM +0200, Carlo Caione wrote:
> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> >> Signed-off-by: Carlo Caione <carlo@caione.org>
> >> ---
> >>  arch/arm/boot/dts/sun4i-a10-a1000.dts           | 58 ++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun4i-a10-cubieboard.dts      | 58 ++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun4i-a10-hackberry.dts       | 64 ++++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun4i-a10-inet97fv2.dts       | 58 ++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun4i-a10-mini-xplus.dts      | 65 +++++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts  | 64 ++++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun4i-a10-pcduino.dts         | 58 ++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun7i-a20-cubieboard2.dts     | 59 ++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun7i-a20-cubietruck.dts      | 59 ++++++++++++++++++++++
> >>  arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 59 ++++++++++++++++++++++
> >>  10 files changed, 602 insertions(+)
> >>
> >> diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts b/arch/arm/boot/dts/sun4i-a10-a1000.dts
> >> index fa746aea..57d3fb4 100644
> >> --- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
> >> +++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
> >> @@ -88,6 +88,56 @@
> >>                       pinctrl-names = "default";
> >>                       pinctrl-0 = <&i2c0_pins_a>;
> >>                       status = "okay";
> >> +
> >> +                     axp209: pmic@34 {
> >> +                             compatible = "x-powers,axp209";
> >> +                             reg = <0x34>;
> >> +                             interrupts = <0>;
> >> +
> >> +                             interrupt-controller;
> >> +                             #interrupt-cells = <1>;
> >> +
> >> +                             acin-supply = <&reg_axp_ipsout>;
> >> +                             vin2-supply = <&reg_axp_ipsout>;
> >> +                             vin3-supply = <&reg_axp_ipsout>;
> >> +                             ldo24in-supply = <&reg_axp_ipsout>;
> >> +                             ldo3in-supply = <&reg_axp_ipsout>;
> >> +                             ldo5in-supply = <&reg_axp_ipsout>;
> >> +
> >> +                             regulators {
> >> +                                     x-powers,dcdc-freq = <1500>;
> >> +
> >> +                                     axp_vcore_reg: dcdc2 {
> >> +                                             regulator-min-microvolt = <700000>;
> >> +                                             regulator-max-microvolt = <2275000>;
> >> +                                             regulator-always-on;
> >> +                                     };
> >> +
> >> +                                     axp_ddr_reg: dcdc3 {
> >> +                                             regulator-always-on;
> >> +                                     };
> >> +
> >> +                                     axp_rtc_reg: ldo1 {
> >> +                                             regulator-always-on;
> >> +                                     };
> >> +
> >> +                                     axp_analog_reg: ldo2 {
> >> +                                             regulator-always-on;
> >> +                                     };
> >> +
> >> +                                     axp_pll_reg: ldo3 {
> >> +                                             regulator-always-on;
> >> +                                     };
> >> +
> >> +                                     axp_hdmi_reg: ldo4 {
> >> +                                             regulator-always-on;
> >> +                                     };
> >> +
> >> +                                     axp_mic_reg: ldo5 {
> >> +                                             regulator-always-on;
> >
> > Do all these regulators need to be always on? It makes sense for the
> > pll and vcore, but I don't get why the mic and hdmi regulators need
> > this.
> 
> I did this way because I don't have the schematics for all the board
> so I thought it was safer to leave all the regulators enabled

Well, we have the schematics for most of these boards (at least all
the cubie and olinuxinos).

As far as the other boards are concerned, if we don't have that
information, I'd say leave them alone until someone has access to
these informations.

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply

* Re: [PATCH RESEND 1/2] input: gpio_keys_polled: Convert to devm-* API
From: Dmitry Torokhov @ 2014-05-06  4:18 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: linux-input
In-Reply-To: <1398789659.346407871@f204.i.mail.ru>

On Tue, Apr 29, 2014 at 08:40:59PM +0400, Alexander Shiyan wrote:
> Tue, 29 Apr 2014 09:36:49 -0700 от Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> > On Tue, Apr 29, 2014 at 08:24:19PM +0400, Alexander Shiyan wrote:
> ...
> > > > > > > > On Sat, Apr 26, 2014 at 09:53:13AM +0400, Alexander Shiyan wrote:
> > > > > > > > > Replace existing resource handling in the driver with managed
> > > > > > > > > device resource, this ensures more consistent error values and
> > > > > > > > > simplifies error paths.
> > > > > > > > > kzalloc -> devm_kzalloc
> > > > > > > > > gpio_request_one -> devm_gpio_request_one
> > > > > ...
> > > > > > > > @@ -162,8 +160,7 @@ static struct gpio_keys_platform_data *gpio_keys_polled_get_devtree_pdata(struct
> > > > > > > >  		if (of_property_read_u32(pp, "linux,code", &button->code)) {
> > > > > > > >  			dev_err(dev, "Button without keycode: 0x%x\n",
> > > > > > > >  				button->gpio);
> > > > > > > > -			error = -EINVAL;
> > > > > > > > -			goto err_free_pdata;
> > > > > > > > +			return ERR_PTR(-EINVAL);
> > > > > > > >  		}
> > > > > > > 
> > > > > > > We can even use return value from of_property_read_u32() on error.
> > > > > > > 
> > > > > > > All other looks OK.
> > > > > > 
> > > > > > Do you have hardware that uses gpio_keys_polled?
> > > > > 
> > > > > Yes.
> > > > 
> > > > So did you have a chance to actually try my version(s)? I would feel
> > > > much better if you had ;)
> > > 
> > > Unfortunately, due to the large following weekends, I cannot do it earlier
> > > than 2 weeks.
> > 
> > That is fine, there is no rush.
> 
> OK. In this case it would be nice to have a separate branch with poll-series
> and this patch. Can you make it?

I just pushed new input-polldev branch containing input polldev changes
and your patches to gpio-keys and gpio-keys-polled. It is based on 3.14.

Thanks.

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

^ permalink raw reply

* Re: [PATCH v2] elantech: Fix elantech on Gigabyte U2442
From: Dmitry Torokhov @ 2014-05-06  4:18 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Benjamin Tissoires, linux-input, Philipp Wolfer, stable
In-Reply-To: <1399293293-32482-1-git-send-email-hdegoede@redhat.com>

On Mon, May 05, 2014 at 02:34:53PM +0200, Hans de Goede wrote:
> The hw_version 3 elantech touchpad on the Gigabyte U2442 does not accept
> 0x0b as initialization value for r10, this stand-alone version of the driver:
> http://planet76.com/drivers/elantech/psmouse-elantech-v6.tar.bz2
> 
> Uses 0x03 which does work, so this means not setting bit 3 of r10 which sets:
> "Enable Real H/W Resolution In Absolute mode"
> 
> Which will result in half the x and y resolution we get with that bit set,
> so simply not setting it everywhere is not a solution. We've been unable
> to find a way to identifty touchpads where setting the bit will fail, so this
> patch uses a dmi based blacklist for this.
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=61151
> 
> Cc: stable@vger.kernel.org
> Reported-by: Philipp Wolfer <ph.wolfer@gmail.com>
> Tested-by: Philipp Wolfer <ph.wolfer@gmail.com>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v4 2/7] Input: pixcir_i2c_ts: Initialize interrupt mode and power mode
From: Dmitry Torokhov @ 2014-05-06  5:19 UTC (permalink / raw)
  To: Roger Quadros
  Cc: rydberg-Hk7bIW8heu4wFerOooGFRg, balbi-l0cyMroinI0,
	dmurphy-l0cyMroinI0, mugunthanvnm-l0cyMroinI0,
	nsekhar-l0cyMroinI0, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1399280678-23925-3-git-send-email-rogerq-l0cyMroinI0@public.gmane.org>

Hi Roger,

On Mon, May 05, 2014 at 12:04:33PM +0300, Roger Quadros wrote:
> @@ -192,8 +364,8 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client)
>  
>  	device_init_wakeup(&client->dev, 0);
>  
> -	tsdata->exiting = true;
> -	mb();
> +	if (!tsdata->exiting)
> +		pixcir_stop(tsdata);
>  

I think if we change tsdata->exiting to tsdata->running we won't have to
do it here. Does the version of the patch below work for you?

-- 
Dmitry

Input: pixcir_i2c_ts - initialize interrupt mode and power mode

From: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>

Introduce helper functions to configure power and interrupt registers.
Default to IDLE mode on probe as device supports auto wakeup to ACVIE mode
on detecting finger touch.

Configure interrupt mode and polarity on start up.  Power down on device
closure or module removal.

Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
Acked-by: Mugunthan V N <mugunthanvnm-l0cyMroinI0@public.gmane.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c |  182 ++++++++++++++++++++++++++++-
 include/linux/input/pixcir_ts.h           |   42 +++++++
 2 files changed, 216 insertions(+), 8 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 724b839..7d39268 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -29,7 +29,7 @@ struct pixcir_i2c_ts_data {
 	struct i2c_client *client;
 	struct input_dev *input;
 	const struct pixcir_ts_platform_data *chip;
-	bool exiting;
+	bool running;
 };
 
 static void pixcir_ts_poscheck(struct pixcir_i2c_ts_data *data)
@@ -88,7 +88,7 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 {
 	struct pixcir_i2c_ts_data *tsdata = dev_id;
 
-	while (!tsdata->exiting) {
+	while (tsdata->running) {
 		pixcir_ts_poscheck(tsdata);
 
 		if (tsdata->chip->attb_read_val())
@@ -100,6 +100,164 @@ static irqreturn_t pixcir_ts_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static int pixcir_set_power_mode(struct pixcir_i2c_ts_data *ts,
+				 enum pixcir_power_mode mode)
+{
+	struct device *dev = &ts->client->dev;
+	int ret;
+
+	ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_POWER_MODE);
+	if (ret < 0) {
+		dev_err(dev, "%s: can't read reg 0x%x : %d\n",
+			__func__, PIXCIR_REG_POWER_MODE, ret);
+		return ret;
+	}
+
+	ret &= ~PIXCIR_POWER_MODE_MASK;
+	ret |= mode;
+
+	/* Always AUTO_IDLE */
+	ret |= PIXCIR_POWER_ALLOW_IDLE;
+
+	ret = i2c_smbus_write_byte_data(ts->client, PIXCIR_REG_POWER_MODE, ret);
+	if (ret < 0) {
+		dev_err(dev, "%s: can't write reg 0x%x : %d\n",
+			__func__, PIXCIR_REG_POWER_MODE, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+/*
+ * Set the interrupt mode for the device i.e. ATTB line behaviour
+ *
+ * @polarity : 1 for active high, 0 for active low.
+ */
+static int pixcir_set_int_mode(struct pixcir_i2c_ts_data *ts,
+			       enum pixcir_int_mode mode, bool polarity)
+{
+	struct device *dev = &ts->client->dev;
+	int ret;
+
+	ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_INT_MODE);
+	if (ret < 0) {
+		dev_err(dev, "%s: can't read reg 0x%x : %d\n",
+			__func__, PIXCIR_REG_INT_MODE, ret);
+		return ret;
+	}
+
+	ret &= ~PIXCIR_INT_MODE_MASK;
+	ret |= mode;
+
+	if (polarity)
+		ret |= PIXCIR_INT_POL_HIGH;
+	else
+		ret &= ~PIXCIR_INT_POL_HIGH;
+
+	ret = i2c_smbus_write_byte_data(ts->client, PIXCIR_REG_INT_MODE, ret);
+	if (ret < 0) {
+		dev_err(dev, "%s: can't write reg 0x%x : %d\n",
+			__func__, PIXCIR_REG_INT_MODE, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+/*
+ * Enable/disable interrupt generation
+ */
+static int pixcir_int_enable(struct pixcir_i2c_ts_data *ts, bool enable)
+{
+	struct device *dev = &ts->client->dev;
+	int ret;
+
+	ret = i2c_smbus_read_byte_data(ts->client, PIXCIR_REG_INT_MODE);
+	if (ret < 0) {
+		dev_err(dev, "%s: can't read reg 0x%x : %d\n",
+			__func__, PIXCIR_REG_INT_MODE, ret);
+		return ret;
+	}
+
+	if (enable)
+		ret |= PIXCIR_INT_ENABLE;
+	else
+		ret &= ~PIXCIR_INT_ENABLE;
+
+	ret = i2c_smbus_write_byte_data(ts->client, PIXCIR_REG_INT_MODE, ret);
+	if (ret < 0) {
+		dev_err(dev, "%s: can't write reg 0x%x : %d\n",
+			__func__, PIXCIR_REG_INT_MODE, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static int pixcir_start(struct pixcir_i2c_ts_data *ts)
+{
+	struct device *dev = &ts->client->dev;
+	int error;
+
+	/* LEVEL_TOUCH interrupt with active low polarity */
+	error = pixcir_set_int_mode(ts, PIXCIR_INT_LEVEL_TOUCH, 0);
+	if (error) {
+		dev_err(dev, "Failed to set interrupt mode: %d\n", error);
+		return error;
+	}
+
+	ts->running = true;
+	mb();	/* Update status before IRQ can fire */
+
+	/* enable interrupt generation */
+	error = pixcir_int_enable(ts, true);
+	if (error) {
+		dev_err(dev, "Failed to enable interrupt generation: %d\n",
+			error);
+		return error;
+	}
+
+	return 0;
+}
+
+static int pixcir_stop(struct pixcir_i2c_ts_data *ts)
+{
+	int error;
+
+	/* Disable interrupt generation */
+	error = pixcir_int_enable(ts, false);
+	if (error) {
+		dev_err(&ts->client->dev,
+			"Failed to disable interrupt generation: %d\n",
+			error);
+		return error;
+	}
+
+	/* Exit ISR if running, no more report parsing */
+	ts->running = false;
+	mb();	/* update status before we synchronize irq */
+
+	/* Wait till running ISR is complete */
+	synchronize_irq(ts->client->irq);
+
+	return 0;
+}
+
+static int pixcir_input_open(struct input_dev *dev)
+{
+	struct pixcir_i2c_ts_data *ts = input_get_drvdata(dev);
+
+	return pixcir_start(ts);
+}
+
+static void pixcir_input_close(struct input_dev *dev)
+{
+	struct pixcir_i2c_ts_data *ts = input_get_drvdata(dev);
+
+	pixcir_stop(ts);
+}
+
 #ifdef CONFIG_PM_SLEEP
 static int pixcir_i2c_ts_suspend(struct device *dev)
 {
@@ -156,6 +314,8 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 
 	input->name = client->name;
 	input->id.bustype = BUS_I2C;
+	input->open = pixcir_input_open;
+	input->close = pixcir_input_close;
 
 	__set_bit(EV_KEY, input->evbit);
 	__set_bit(EV_ABS, input->evbit);
@@ -175,11 +335,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 		return error;
 	}
 
+	/* Always be in IDLE mode to save power, device supports auto wake */
+	error = pixcir_set_power_mode(tsdata, PIXCIR_POWER_IDLE);
+	if (error) {
+		dev_err(dev, "Failed to set IDLE mode\n");
+		return error;
+	}
+
+	/* Stop device till opened */
+	error = pixcir_stop(tsdata);
+	if (error)
+		return error;
+
 	error = input_register_device(input);
 	if (error)
 		return error;
 
-	i2c_set_clientdata(client, tsdata);
 	device_init_wakeup(&client->dev, 1);
 
 	return 0;
@@ -187,13 +358,8 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 
 static int pixcir_i2c_ts_remove(struct i2c_client *client)
 {
-	struct pixcir_i2c_ts_data *tsdata = i2c_get_clientdata(client);
-
 	device_init_wakeup(&client->dev, 0);
 
-	tsdata->exiting = true;
-	mb();
-
 	return 0;
 }
 
diff --git a/include/linux/input/pixcir_ts.h b/include/linux/input/pixcir_ts.h
index 7163d91..7942804 100644
--- a/include/linux/input/pixcir_ts.h
+++ b/include/linux/input/pixcir_ts.h
@@ -1,6 +1,48 @@
 #ifndef	_PIXCIR_I2C_TS_H
 #define	_PIXCIR_I2C_TS_H
 
+/*
+ * Register map
+ */
+#define PIXCIR_REG_POWER_MODE	51
+#define PIXCIR_REG_INT_MODE	52
+
+/*
+ * Power modes:
+ * active: max scan speed
+ * idle: lower scan speed with automatic transition to active on touch
+ * halt: datasheet says sleep but this is more like halt as the chip
+ *       clocks are cut and it can only be brought out of this mode
+ *	 using the RESET pin.
+ */
+enum pixcir_power_mode {
+	PIXCIR_POWER_ACTIVE,
+	PIXCIR_POWER_IDLE,
+	PIXCIR_POWER_HALT,
+};
+
+#define PIXCIR_POWER_MODE_MASK	0x03
+#define PIXCIR_POWER_ALLOW_IDLE (1UL << 2)
+
+/*
+ * Interrupt modes:
+ * periodical: interrupt is asserted periodicaly
+ * diff coordinates: interrupt is asserted when coordinates change
+ * level on touch: interrupt level asserted during touch
+ * pulse on touch: interrupt pulse asserted druing touch
+ *
+ */
+enum pixcir_int_mode {
+	PIXCIR_INT_PERIODICAL,
+	PIXCIR_INT_DIFF_COORD,
+	PIXCIR_INT_LEVEL_TOUCH,
+	PIXCIR_INT_PULSE_TOUCH,
+};
+
+#define PIXCIR_INT_MODE_MASK	0x03
+#define PIXCIR_INT_ENABLE	(1UL << 3)
+#define PIXCIR_INT_POL_HIGH	(1UL << 2)
+
 struct pixcir_ts_platform_data {
 	int (*attb_read_val)(void);
 	int x_max;
--
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 related

* Re: [PATCH v4 6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend
From: Dmitry Torokhov @ 2014-05-06  5:21 UTC (permalink / raw)
  To: Roger Quadros
  Cc: rydberg, balbi, dmurphy, mugunthanvnm, nsekhar, linux-input,
	linux-kernel, devicetree
In-Reply-To: <1399280678-23925-7-git-send-email-rogerq@ti.com>

On Mon, May 05, 2014 at 12:04:37PM +0300, Roger Quadros wrote:
> Improve the suspend and resume handlers to allow the device
> to wakeup the system from suspend.
> 
> Signed-off-by: Roger Quadros <rogerq@ti.com>
> Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
> ---
>  drivers/input/touchscreen/pixcir_i2c_ts.c | 53 ++++++++++++++++++++++++++++---
>  1 file changed, 49 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
> index 927aed1..5f6a27e 100644
> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
> @@ -348,21 +348,66 @@ static void pixcir_input_close(struct input_dev *dev)
>  static int pixcir_i2c_ts_suspend(struct device *dev)
>  {
>  	struct i2c_client *client = to_i2c_client(dev);
> +	struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
> +	struct input_dev *input = ts->input;
> +	int ret = 0;
> +
> +	mutex_lock(&input->mutex);
> +
> +	if (input->users) {
> +		ret = pixcir_stop(ts);
> +		if (ret)
> +			goto unlock;
> +	}
> +
> +	/*
> +	 * If wakeup is enabled we need to enable interrupt generation
> +	 * but don't need to process any reports i.e. ts->exiting must be true.
> +	 */
> +	if (device_may_wakeup(&client->dev)) {
> +		/* enable wakeup interrupt generation */
> +		ret = pixcir_int_enable(ts, 1);
> +		if (ret) {
> +			dev_err(dev, "Failed to enable interrupt generation\n");
> +			goto unlock;
> +		}

I am not sure why we need to disable event processing here. Why not do

	if (device_may_wakeup(&client->dev)) {
		enable_irq_wake(client->irq); 
		ret = pixcir_int_enable(ts, true);
		...
	} else if (input->users) {
		ret = pixcir_stop(ts);
	}

like many of the drivers do?

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [linux-sunxi] Re: [PATCH v5 1/8] mfd: AXP20x: Add mfd driver for AXP20x PMIC
From: Lee Jones @ 2014-05-06  7:14 UTC (permalink / raw)
  To: Carlo Caione
  Cc: boris.brezillon, sameo, linux-doc, emilio, linux-sunxi,
	dmitry.torokhov, lgirdwood, hdegoede, wens, broonie, linux-input,
	maxime.ripard, linux-arm-kernel
In-Reply-To: <CAOQ7t2ZNRxuRhQbr-PMUKFSiwXrypBEA1_LmT9fzw6=-+k6awQ@mail.gmail.com>

> >> This patch introduces the preliminary support for PMICs X-Powers AXP202
> >> and AXP209. The AXP209 and AXP202 are the PMUs (Power Management Unit)
> >> used by A10, A13 and A20 SoCs and developed by X-Powers, a sister company
> >> of Allwinner.
> >>
> >> The core enables support for two subsystems:
> >> - PEK (Power Enable Key)
> >> - Regulators
> >>
> >> Signed-off-by: Carlo Caione <carlo@caione.org>
> >> Acked-by: Lee Jones <lee.jones@linaro.org>
> >> ---
> >
> > I guess I can just apply this and expect not to see any adverse
> > symptoms?
> 
> It has been tested with a sun7i/cubieboard2 with to adverse symptoms.
> It's not core stuff so I guess you could apply it.
> 
> Thank you,

Applied, thanks.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply

* Re: [linux-sunxi] Re: [PATCH v5 8/8] ARM: sun7i/sun4i: dt: Add AXP209 support to various boards
From: Carlo Caione @ 2014-05-06  7:38 UTC (permalink / raw)
  To: Maxime Ripard
  Cc: Carlo Caione, linux-arm-kernel, Hans De Goede, Emilio Lopez,
	wens Tsai, sameo, Dmitry Torokhov, linux-input, linux-doc,
	Liam Girdwood, Mark Brown, Lee Jones, boris.brezillon,
	linux-sunxi
In-Reply-To: <20140505225139.GD9464@lukather>

On Tue, May 6, 2014 at 12:51 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> On Sat, May 03, 2014 at 02:21:06PM +0200, Carlo Caione wrote:
>> On Sat, May 3, 2014 at 3:09 AM, Maxime Ripard
>> <maxime.ripard@free-electrons.com> wrote:
>> > Hi,
>> >
>> > On Thu, May 01, 2014 at 02:29:34PM +0200, Carlo Caione wrote:
>> >> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> >> Signed-off-by: Carlo Caione <carlo@caione.org>
>> >> ---
>> >>  arch/arm/boot/dts/sun4i-a10-a1000.dts           | 58 ++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun4i-a10-cubieboard.dts      | 58 ++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun4i-a10-hackberry.dts       | 64 ++++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun4i-a10-inet97fv2.dts       | 58 ++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun4i-a10-mini-xplus.dts      | 65 +++++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun4i-a10-olinuxino-lime.dts  | 64 ++++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun4i-a10-pcduino.dts         | 58 ++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun7i-a20-cubieboard2.dts     | 59 ++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun7i-a20-cubietruck.dts      | 59 ++++++++++++++++++++++
>> >>  arch/arm/boot/dts/sun7i-a20-olinuxino-micro.dts | 59 ++++++++++++++++++++++
>> >>  10 files changed, 602 insertions(+)
>> >>
>> >> diff --git a/arch/arm/boot/dts/sun4i-a10-a1000.dts b/arch/arm/boot/dts/sun4i-a10-a1000.dts
>> >> index fa746aea..57d3fb4 100644
>> >> --- a/arch/arm/boot/dts/sun4i-a10-a1000.dts
>> >> +++ b/arch/arm/boot/dts/sun4i-a10-a1000.dts
>> >> @@ -88,6 +88,56 @@
>> >>                       pinctrl-names = "default";
>> >>                       pinctrl-0 = <&i2c0_pins_a>;
>> >>                       status = "okay";
>> >> +
>> >> +                     axp209: pmic@34 {
>> >> +                             compatible = "x-powers,axp209";
>> >> +                             reg = <0x34>;
>> >> +                             interrupts = <0>;
>> >> +
>> >> +                             interrupt-controller;
>> >> +                             #interrupt-cells = <1>;
>> >> +
>> >> +                             acin-supply = <&reg_axp_ipsout>;
>> >> +                             vin2-supply = <&reg_axp_ipsout>;
>> >> +                             vin3-supply = <&reg_axp_ipsout>;
>> >> +                             ldo24in-supply = <&reg_axp_ipsout>;
>> >> +                             ldo3in-supply = <&reg_axp_ipsout>;
>> >> +                             ldo5in-supply = <&reg_axp_ipsout>;
>> >> +
>> >> +                             regulators {
>> >> +                                     x-powers,dcdc-freq = <1500>;
>> >> +
>> >> +                                     axp_vcore_reg: dcdc2 {
>> >> +                                             regulator-min-microvolt = <700000>;
>> >> +                                             regulator-max-microvolt = <2275000>;
>> >> +                                             regulator-always-on;
>> >> +                                     };
>> >> +
>> >> +                                     axp_ddr_reg: dcdc3 {
>> >> +                                             regulator-always-on;
>> >> +                                     };
>> >> +
>> >> +                                     axp_rtc_reg: ldo1 {
>> >> +                                             regulator-always-on;
>> >> +                                     };
>> >> +
>> >> +                                     axp_analog_reg: ldo2 {
>> >> +                                             regulator-always-on;
>> >> +                                     };
>> >> +
>> >> +                                     axp_pll_reg: ldo3 {
>> >> +                                             regulator-always-on;
>> >> +                                     };
>> >> +
>> >> +                                     axp_hdmi_reg: ldo4 {
>> >> +                                             regulator-always-on;
>> >> +                                     };
>> >> +
>> >> +                                     axp_mic_reg: ldo5 {
>> >> +                                             regulator-always-on;
>> >
>> > Do all these regulators need to be always on? It makes sense for the
>> > pll and vcore, but I don't get why the mic and hdmi regulators need
>> > this.
>>
>> I did this way because I don't have the schematics for all the board
>> so I thought it was safer to leave all the regulators enabled
>
> Well, we have the schematics for most of these boards (at least all
> the cubie and olinuxinos).
>
> As far as the other boards are concerned, if we don't have that
> information, I'd say leave them alone until someone has access to
> these informations.

What do you mean exactly with "leave them alone". The problem is that
if the regulator is not explicitly marked as always-on, it is disabled
at boot time, so I think that the most safe thing to do is leave them
on to avoid turning off something at boot time that could be
important.

-- 
Carlo Caione

^ permalink raw reply

* Re: [PATCH v4 2/7] Input: pixcir_i2c_ts: Initialize interrupt mode and power mode
From: Roger Quadros @ 2014-05-06  8:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: rydberg, balbi, dmurphy, mugunthanvnm, nsekhar, linux-input,
	linux-kernel, devicetree
In-Reply-To: <20140506051922.GA2608@core.coreip.homeip.net>

Dmitry,

On 05/06/2014 08:19 AM, Dmitry Torokhov wrote:
> Hi Roger,
> 
> On Mon, May 05, 2014 at 12:04:33PM +0300, Roger Quadros wrote:
>> @@ -192,8 +364,8 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client)
>>  
>>  	device_init_wakeup(&client->dev, 0);
>>  
>> -	tsdata->exiting = true;
>> -	mb();
>> +	if (!tsdata->exiting)
>> +		pixcir_stop(tsdata);
>>  
> 
> I think if we change tsdata->exiting to tsdata->running we won't have to
> do it here. Does the version of the patch below work for you?
> 

The call to pixcir_stop() was not required in the original version as well. It seems
that the root of the problem for remove() and suspend() that I was trying to solve
was in the pixcir_stop() function. i.e. the order of mb() and synchronize_irq();

But I like your version more since "running" reflects the behaviour more accurately
than "exiting".

cheers,
-roger

^ permalink raw reply

* Re: [PATCH v4 6/7] Input: pixcir_i2c_ts: Implement wakeup from suspend
From: Roger Quadros @ 2014-05-06  8:33 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: rydberg-Hk7bIW8heu4wFerOooGFRg, balbi-l0cyMroinI0,
	dmurphy-l0cyMroinI0, mugunthanvnm-l0cyMroinI0,
	nsekhar-l0cyMroinI0, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20140506052148.GB2608-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>

On 05/06/2014 08:21 AM, Dmitry Torokhov wrote:
> On Mon, May 05, 2014 at 12:04:37PM +0300, Roger Quadros wrote:
>> Improve the suspend and resume handlers to allow the device
>> to wakeup the system from suspend.
>>
>> Signed-off-by: Roger Quadros <rogerq-l0cyMroinI0@public.gmane.org>
>> Acked-by: Mugunthan V N <mugunthanvnm-l0cyMroinI0@public.gmane.org>
>> ---
>>  drivers/input/touchscreen/pixcir_i2c_ts.c | 53 ++++++++++++++++++++++++++++---
>>  1 file changed, 49 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
>> index 927aed1..5f6a27e 100644
>> --- a/drivers/input/touchscreen/pixcir_i2c_ts.c
>> +++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
>> @@ -348,21 +348,66 @@ static void pixcir_input_close(struct input_dev *dev)
>>  static int pixcir_i2c_ts_suspend(struct device *dev)
>>  {
>>  	struct i2c_client *client = to_i2c_client(dev);
>> +	struct pixcir_i2c_ts_data *ts = i2c_get_clientdata(client);
>> +	struct input_dev *input = ts->input;
>> +	int ret = 0;
>> +
>> +	mutex_lock(&input->mutex);
>> +
>> +	if (input->users) {
>> +		ret = pixcir_stop(ts);
>> +		if (ret)
>> +			goto unlock;
>> +	}
>> +
>> +	/*
>> +	 * If wakeup is enabled we need to enable interrupt generation
>> +	 * but don't need to process any reports i.e. ts->exiting must be true.
>> +	 */
>> +	if (device_may_wakeup(&client->dev)) {
>> +		/* enable wakeup interrupt generation */
>> +		ret = pixcir_int_enable(ts, 1);
>> +		if (ret) {
>> +			dev_err(dev, "Failed to enable interrupt generation\n");
>> +			goto unlock;
>> +		}
> 
> I am not sure why we need to disable event processing here. Why not do
> 
> 	if (device_may_wakeup(&client->dev)) {
> 		enable_irq_wake(client->irq); 
> 		ret = pixcir_int_enable(ts, true);
> 		...
> 	} else if (input->users) {
> 		ret = pixcir_stop(ts);
> 	}
> 
> like many of the drivers do?

Seems to work without disabling event processing. I'll send a v5 with this
and patch 2 fixed as per your suggestion. Thanks.

cheers,
-roger
--
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

* [PATCH v5 0/7] Input: pixcir_i2c_ts: Add Type-B Multi-touch and DT support
From: Roger Quadros @ 2014-05-06 11:06 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: rydberg, balbi, dmurphy, mugunthanvnm, nsekhar, linux-input,
	linux-kernel, devicetree, Roger Quadros

Hi Dmitry,

This series does the following

- use devres managed resource allocations
- convert to Type-B multi touch protocol
- support upto 5 fingers with hardware supplied tracking IDs
- device tree support

Please queue this for -next (3.16). Thanks.

cheers,
-roger

Changelog:

v5:
- Changed ts->exiting flag to ts->running in patch 2.
- Don't call pixcir_stop() from .suspend() if wakeup is required.

v4:
- Imporved pixcir_stop() as per Dmitry's suggestion.
- Removed unnecessary input_unregister_device() from .remove().

v3:
- Rebased to 3.15-rc3
- Fixed suspend while touchscreen in use
- Fixed module removal while touchscreen in use

v2:
- Addressed review comments and re-arranged patch order

v1:
- http://article.gmane.org/gmane.linux.kernel/1616417

--
Roger Quadros (7):
  Input: pixcir_i2c_ts: Use devres managed resource allocations
  Input: pixcir_i2c_ts - initialize interrupt mode and power mode
  Input: pixcir_i2c_ts: Get rid of pdata->attb_read_val()
  Input: pixcir_i2c_ts: Use Type-B Multi-Touch protocol
  Input: pixcir_i2c_ts: support upto 5 fingers and hardware provided
    tracking IDs
  Input: pixcir_i2c_ts: Implement wakeup from suspend
  Input: pixcir_i2c_ts: Add device tree support

 .../bindings/input/touchscreen/pixcir_i2c_ts.txt   |  26 +
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 drivers/input/touchscreen/pixcir_i2c_ts.c          | 524 ++++++++++++++++++---
 include/linux/input/pixcir_ts.h                    |  56 ++-
 4 files changed, 540 insertions(+), 67 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/pixcir_i2c_ts.txt

-- 
1.8.3.2

^ permalink raw reply

* [PATCH v5 1/7] Input: pixcir_i2c_ts: Use devres managed resource allocations
From: Roger Quadros @ 2014-05-06 11:06 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: rydberg, balbi, dmurphy, mugunthanvnm, nsekhar, linux-input,
	linux-kernel, devicetree, Roger Quadros
In-Reply-To: <1399374372-29123-1-git-send-email-rogerq@ti.com>

Use devm_() and friends for allocating memory, input device
and IRQ.

Signed-off-by: Roger Quadros <rogerq@ti.com>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
---
 drivers/input/touchscreen/pixcir_i2c_ts.c | 38 ++++++++++++-------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/drivers/input/touchscreen/pixcir_i2c_ts.c b/drivers/input/touchscreen/pixcir_i2c_ts.c
index 02392d2..8a083bd 100644
--- a/drivers/input/touchscreen/pixcir_i2c_ts.c
+++ b/drivers/input/touchscreen/pixcir_i2c_ts.c
@@ -130,6 +130,7 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 {
 	const struct pixcir_ts_platform_data *pdata =
 			dev_get_platdata(&client->dev);
+	struct device *dev = &client->dev;
 	struct pixcir_i2c_ts_data *tsdata;
 	struct input_dev *input;
 	int error;
@@ -139,12 +140,14 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
-	tsdata = kzalloc(sizeof(*tsdata), GFP_KERNEL);
-	input = input_allocate_device();
-	if (!tsdata || !input) {
-		dev_err(&client->dev, "Failed to allocate driver data!\n");
-		error = -ENOMEM;
-		goto err_free_mem;
+	tsdata = devm_kzalloc(dev, sizeof(*tsdata), GFP_KERNEL);
+	if (!tsdata)
+		return -ENOMEM;
+
+	input = devm_input_allocate_device(dev);
+	if (!input) {
+		dev_err(&client->dev, "Failed to allocate input device\n");
+		return -ENOMEM;
 	}
 
 	tsdata->client = client;
@@ -165,29 +168,22 @@ static int pixcir_i2c_ts_probe(struct i2c_client *client,
 
 	input_set_drvdata(input, tsdata);
 
-	error = request_threaded_irq(client->irq, NULL, pixcir_ts_isr,
-				     IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
-				     client->name, tsdata);
+	error = devm_request_threaded_irq(dev, client->irq, NULL, pixcir_ts_isr,
+					  IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+					  client->name, tsdata);
 	if (error) {
-		dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
-		goto err_free_mem;
+		dev_err(dev, "failed to request irq %d\n", client->irq);
+		return error;
 	}
 
 	error = input_register_device(input);
 	if (error)
-		goto err_free_irq;
+		return error;
 
 	i2c_set_clientdata(client, tsdata);
 	device_init_wakeup(&client->dev, 1);
 
 	return 0;
-
-err_free_irq:
-	free_irq(client->irq, tsdata);
-err_free_mem:
-	input_free_device(input);
-	kfree(tsdata);
-	return error;
 }
 
 static int pixcir_i2c_ts_remove(struct i2c_client *client)
@@ -198,10 +194,6 @@ static int pixcir_i2c_ts_remove(struct i2c_client *client)
 
 	tsdata->exiting = true;
 	mb();
-	free_irq(client->irq, tsdata);
-
-	input_unregister_device(tsdata->input);
-	kfree(tsdata);
 
 	return 0;
 }
-- 
1.8.3.2

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox