linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Input related patches
@ 2012-11-14 13:47 Lee Jones
  2012-11-14 13:47 ` [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists Lee Jones
                   ` (4 more replies)
  0 siblings, 5 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-14 13:47 UTC (permalink / raw)
  To: linux-kernel

These have all already been on the MLs for some time now. I've
applied all of the Acks acquired and bunched them up into a
single patch-set for the convenience of the maintainer.

 .../devicetree/bindings/input/stmpe-keypad.txt     |   39 +++++++
 arch/arm/mach-ux500/board-mop500-stuib.c           |   70 +-----------
 drivers/input/keyboard/stmpe-keypad.c              |   67 +++++++++--
 drivers/input/touchscreen/bu21013_ts.c             |  117 +++++++++++++++++---
 drivers/mfd/stmpe.c                                |    1 +
 include/linux/input/bu21013.h                      |    8 +-
 6 files changed, 204 insertions(+), 98 deletions(-)


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

* [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists
  2012-11-14 13:47 [PATCH 0/5] Input related patches Lee Jones
@ 2012-11-14 13:47 ` Lee Jones
  2012-11-23 15:50   ` Lee Jones
  2012-11-26 12:16   ` Lee Jones
  2012-11-14 13:47 ` [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver Lee Jones
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-14 13:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Dmitry Torokhov, linux-input

Currently the BU21013 Touch Screen driver requests a regulator by the
name of 'V-TOUCH', which doesn't exist anywhere in the kernel. The
correct name, as referenced in platform regulator code is 'avdd'. Here,
when we request a regulator, we use the correct name instead.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/input/touchscreen/bu21013_ts.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 5c487d2..2fae682 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -461,7 +461,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	bu21013_data->chip = pdata;
 	bu21013_data->client = client;
 
-	bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
+	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
 	if (IS_ERR(bu21013_data->regulator)) {
 		dev_err(&client->dev, "regulator_get failed\n");
 		error = PTR_ERR(bu21013_data->regulator);
-- 
1.7.9.5


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

* [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-14 13:47 [PATCH 0/5] Input related patches Lee Jones
  2012-11-14 13:47 ` [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists Lee Jones
@ 2012-11-14 13:47 ` Lee Jones
  2012-11-21 18:42   ` Dmitry Torokhov
  2012-11-22 12:10   ` Lee Jones
  2012-11-14 13:47 ` [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting Lee Jones
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-14 13:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Dmitry Torokhov, linux-input

These GPIO init and exit functions have no place in platform data.
Instead they should be part of the driver. This patch moves them to
their rightful place, which subsequently elevates platform data of
yet more cruft.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 arch/arm/mach-ux500/board-mop500-stuib.c |   70 +--------------------------
 drivers/input/touchscreen/bu21013_ts.c   |   76 ++++++++++++++++++++++++++----
 include/linux/input/bu21013.h            |    8 +---
 3 files changed, 70 insertions(+), 84 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c
index 564f57d..eb19a7e 100644
--- a/arch/arm/mach-ux500/board-mop500-stuib.c
+++ b/arch/arm/mach-ux500/board-mop500-stuib.c
@@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
  * BU21013 ROHM touchscreen interface on the STUIBs
  */
 
-/* tracks number of bu21013 devices being enabled */
-static int bu21013_devices;
-
 #define TOUCH_GPIO_PIN  84
 
 #define TOUCH_XMAX	384
@@ -88,73 +85,8 @@ static int bu21013_devices;
 #define PRCMU_CLOCK_OCR		0x1CC
 #define TSC_EXT_CLOCK_9_6MHZ	0x840000
 
-/**
- * bu21013_gpio_board_init : configures the touch panel.
- * @reset_pin: reset pin number
- * This function can be used to configures
- * the voltage and reset the touch panel controller.
- */
-static int bu21013_gpio_board_init(int reset_pin)
-{
-	int retval = 0;
-
-	bu21013_devices++;
-	if (bu21013_devices == 1) {
-		retval = gpio_request(reset_pin, "touchp_reset");
-		if (retval) {
-			printk(KERN_ERR "Unable to request gpio reset_pin");
-			return retval;
-		}
-		retval = gpio_direction_output(reset_pin, 1);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-	}
-
-	return retval;
-}
-
-/**
- * bu21013_gpio_board_exit : deconfigures the touch panel controller
- * @reset_pin: reset pin number
- * This function can be used to deconfigures the chip selection
- * for touch panel controller.
- */
-static int bu21013_gpio_board_exit(int reset_pin)
-{
-	int retval = 0;
-
-	if (bu21013_devices == 1) {
-		retval = gpio_direction_output(reset_pin, 0);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-		gpio_set_value(reset_pin, 0);
-	}
-	bu21013_devices--;
-
-	return retval;
-}
-
-/**
- * bu21013_read_pin_val : get the interrupt pin value
- * This function can be used to get the interrupt pin value for touch panel
- * controller.
- */
-static int bu21013_read_pin_val(void)
-{
-	return gpio_get_value(TOUCH_GPIO_PIN);
-}
-
 static struct bu21013_platform_device tsc_plat_device = {
-	.cs_en = bu21013_gpio_board_init,
-	.cs_dis = bu21013_gpio_board_exit,
-	.irq_read_val = bu21013_read_pin_val,
-	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
+	.touch_pin = TOUCH_GPIO_PIN,
 	.touch_x_max = TOUCH_XMAX,
 	.touch_y_max = TOUCH_YMAX,
 	.ext_clk = false,
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 2fae682..5d8fc75 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -14,6 +14,10 @@
 #include <linux/slab.h>
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
+#include <linux/gpio.h>
+
+/* Reference tracking for multiple displays. */
+static int bu21013_devices = 0;
 
 #define PEN_DOWN_INTR	0
 #define MAX_FINGERS	2
@@ -262,7 +266,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 			return IRQ_NONE;
 		}
 
-		data->intr_pin = data->chip->irq_read_val();
+		data->intr_pin = gpio_get_value(data->chip->touch_pin);
 		if (data->intr_pin == PEN_DOWN_INTR)
 			wait_event_timeout(data->wait, data->touch_stopped,
 					   msecs_to_jiffies(2));
@@ -272,6 +276,60 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 }
 
 /**
+ * bu21013_gpio_board_init() - configures the touch panel
+ * @reset_pin: reset pin number
+ *
+ * This function is used to configure the voltage and
+ * reset the touch panel controller.
+ */
+static int bu21013_gpio_board_init(int reset_pin)
+{
+	int retval = 0;
+
+	bu21013_devices++;
+	if (bu21013_devices == 1) {
+		retval = gpio_request(reset_pin, "touchp_reset");
+		if (retval) {
+			printk(KERN_ERR "Unable to request gpio reset_pin");
+			return retval;
+		}
+		retval = gpio_direction_output(reset_pin, 1);
+		if (retval < 0) {
+			printk(KERN_ERR "%s: gpio direction failed\n",
+					__func__);
+			return retval;
+		}
+	}
+
+	return retval;
+}
+
+/**
+ * bu21013_gpio_board_exit() - deconfigures the touch panel controller
+ * @reset_pin: reset pin number
+ *
+ * This function is used to deconfigure the chip selection
+ * for touch panel controller.
+ */
+static int bu21013_gpio_board_exit(int reset_pin)
+{
+	int retval = 0;
+
+	if (bu21013_devices == 1) {
+		retval = gpio_direction_output(reset_pin, 0);
+		if (retval < 0) {
+			printk(KERN_ERR "%s: gpio direction failed\n",
+					__func__);
+			return retval;
+		}
+		gpio_set_value(reset_pin, 0);
+	}
+	bu21013_devices--;
+
+	return retval;
+}
+
+/**
  * bu21013_init_chip() - power on sequence for the bu21013 controller
  * @data: device structure pointer
  *
@@ -449,6 +507,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
+	pdata->irq = gpio_to_irq(pdata->touch_pin);
+
 	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
 	in_dev = input_allocate_device();
 	if (!bu21013_data || !in_dev) {
@@ -478,12 +538,10 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	init_waitqueue_head(&bu21013_data->wait);
 
 	/* configure the gpio pins */
-	if (pdata->cs_en) {
-		error = pdata->cs_en(pdata->cs_pin);
-		if (error < 0) {
-			dev_err(&client->dev, "chip init failed\n");
-			goto err_disable_regulator;
-		}
+	error = bu21013_gpio_board_init(pdata->cs_pin);
+	if (error < 0) {
+		dev_err(&client->dev, "chip init failed\n");
+		goto err_disable_regulator;
 	}
 
 	/* configure the touch panel controller */
@@ -531,7 +589,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 err_free_irq:
 	bu21013_free_irq(bu21013_data);
 err_cs_disable:
-	pdata->cs_dis(pdata->cs_pin);
+	bu21013_gpio_board_exit(pdata->cs_pin);
 err_disable_regulator:
 	regulator_disable(bu21013_data->regulator);
 err_put_regulator:
@@ -555,7 +613,7 @@ static int __devexit bu21013_remove(struct i2c_client *client)
 
 	bu21013_free_irq(bu21013_data);
 
-	bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
+	bu21013_gpio_board_exit(bu21013_data->chip->cs_pin);
 
 	input_unregister_device(bu21013_data->in_dev);
 
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
index 05e0328..01a2975 100644
--- a/include/linux/input/bu21013.h
+++ b/include/linux/input/bu21013.h
@@ -9,13 +9,11 @@
 
 /**
  * struct bu21013_platform_device - Handle the platform data
- * @cs_en:	pointer to the cs enable function
- * @cs_dis:	pointer to the cs disable function
- * @irq_read_val:    pointer to read the pen irq value function
  * @touch_x_max: touch x max
  * @touch_y_max: touch y max
  * @cs_pin: chip select pin
  * @irq: irq pin
+ * @touch_pin: touch gpio pin
  * @ext_clk: external clock flag
  * @x_flip: x flip flag
  * @y_flip: y flip flag
@@ -24,13 +22,11 @@
  * This is used to handle the platform data
  */
 struct bu21013_platform_device {
-	int (*cs_en)(int reset_pin);
-	int (*cs_dis)(int reset_pin);
-	int (*irq_read_val)(void);
 	int touch_x_max;
 	int touch_y_max;
 	unsigned int cs_pin;
 	unsigned int irq;
+	unsigned int touch_pin;
 	bool ext_clk;
 	bool x_flip;
 	bool y_flip;
-- 
1.7.9.5


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

* [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-14 13:47 [PATCH 0/5] Input related patches Lee Jones
  2012-11-14 13:47 ` [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists Lee Jones
  2012-11-14 13:47 ` [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver Lee Jones
@ 2012-11-14 13:47 ` Lee Jones
  2012-11-23 15:52   ` Lee Jones
  2012-11-27 11:38   ` [PATCH 3/5 v3] " Lee Jones
  2012-11-14 13:47 ` [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree Lee Jones
  2012-11-14 13:47 ` [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver Lee Jones
  4 siblings, 2 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-14 13:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Dmitry Torokhov, linux-input

Now we can register the BU21013_ts touch screen when booting with
Device Tree enabled. Here we parse all the necessary components
previously expected to be passed from platform data.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/input/touchscreen/bu21013_ts.c |   39 ++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 5d8fc75..afef874 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -15,6 +15,8 @@
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 /* Reference tracking for multiple displays. */
 static int bu21013_devices = 0;
@@ -487,13 +489,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
  * This function used to initializes the i2c-client touchscreen
  * driver and returns integer.
  */
+static void __devinit bu21013_of_probe(struct device_node *np,
+				struct bu21013_platform_device *pdata)
+{
+	pdata->y_flip = pdata->x_flip = false;
+
+	if (of_get_property(np, "rohm,flip-x", NULL))
+		pdata->x_flip = true;
+
+	if (of_get_property(np, "rohm,flip-y", NULL))
+		pdata->y_flip = true;
+
+	of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
+	of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
+
+	pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
+	pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
+
+	pdata->ext_clk = false;
+}
+
 static int __devinit bu21013_probe(struct i2c_client *client,
 					const struct i2c_device_id *id)
 {
 	struct bu21013_ts_data *bu21013_data;
 	struct input_dev *in_dev;
-	const struct bu21013_platform_device *pdata =
-					client->dev.platform_data;
+	struct device_node *np = client->dev.of_node;
+	struct bu21013_platform_device *pdata = client->dev.platform_data;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter,
@@ -503,8 +525,17 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	}
 
 	if (!pdata) {
-		dev_err(&client->dev, "platform data not defined\n");
-		return -EINVAL;
+		if (np) {
+			pdata = devm_kzalloc(&client->dev, sizeof(*pdata),
+					GFP_KERNEL);
+			if (!pdata)
+				return -ENOMEM;
+
+			bu21013_of_probe(np, pdata);
+		} else {
+			dev_err(&client->dev, "no device tree or platform data\n");
+			return -EINVAL;
+		}
 	}
 
 	pdata->irq = gpio_to_irq(pdata->touch_pin);
-- 
1.7.9.5


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

* [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree
  2012-11-14 13:47 [PATCH 0/5] Input related patches Lee Jones
                   ` (2 preceding siblings ...)
  2012-11-14 13:47 ` [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting Lee Jones
@ 2012-11-14 13:47 ` Lee Jones
  2012-11-23 15:53   ` Lee Jones
  2013-01-08  8:38   ` Lee Jones
  2012-11-14 13:47 ` [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver Lee Jones
  4 siblings, 2 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-14 13:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Dmitry Torokhov, linux-input

This patch allows the STMPE driver to be successfully probed and
initialised when Device Tree support is enabled. Besides the usual
platform data changes, we also separate the process of filling in
the 'in use' pin bitmap, as we have to extract the information from
Device Tree in the DT boot case.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/input/keyboard/stmpe-keypad.c |   67 ++++++++++++++++++++++++++++-----
 drivers/mfd/stmpe.c                   |    1 +
 2 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 470a877..4ae01d5 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -257,19 +257,73 @@ static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
 			      (plat->debounce_ms << 1));
 }
 
+static int stmpe_keypad_fill_used_pins(struct platform_device *pdev,
+				struct stmpe_keypad *keypad,
+				struct stmpe_keypad_platform_data *plat)
+{
+	struct device_node *np = pdev->dev.of_node;
+	unsigned int proplen;
+	const __be32 *prop;
+	int i;
+
+	if (np) {
+		prop = of_get_property(np, "linux,keymap", &proplen);
+		if (!prop) {
+			dev_err(&pdev->dev,
+				"linux,keymap property not defined\n");
+			return -EINVAL;
+		}
+
+		for (i = 0; i < proplen / sizeof(u32); i++) {
+			unsigned int key = be32_to_cpup(prop + i);
+
+			keypad->cols |= 1 << KEY_COL(key);
+			keypad->rows |= 1 << KEY_ROW(key);
+		}
+	} else {
+		for (i = 0; i < plat->keymap_data->keymap_size; i++) {
+			unsigned int key = plat->keymap_data->keymap[i];
+
+			keypad->cols |= 1 << KEY_COL(key);
+			keypad->rows |= 1 << KEY_ROW(key);
+		}
+	}
+
+	return 0;
+}
+
+static void __devinit stmpe_keypad_of_probe(struct device_node *np,
+				struct stmpe_keypad_platform_data *plat)
+{
+	of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
+	of_property_read_u32(np, "st,scan-count", &plat->scan_count);
+
+	if (of_get_property(np, "st,no-autorepeat", NULL))
+		plat->no_autorepeat = true;
+}
+
 static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
 {
 	struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
 	struct stmpe_keypad_platform_data *plat;
+	struct device_node *np = pdev->dev.of_node;
 	struct stmpe_keypad *keypad;
 	struct input_dev *input;
 	int ret;
 	int irq;
-	int i;
 
 	plat = stmpe->pdata->keypad;
-	if (!plat)
-		return -ENODEV;
+	if (!plat) {
+		if (np) {
+			plat = devm_kzalloc(&pdev->dev,
+					sizeof(*plat), GFP_KERNEL);
+			if (!plat)
+				return -ENOMEM;
+
+			stmpe_keypad_of_probe(np, plat);
+		} else
+			return -ENODEV;
+	}
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
@@ -300,12 +354,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
 	if (!plat->no_autorepeat)
 		__set_bit(EV_REP, input->evbit);
 
-	for (i = 0; i < plat->keymap_data->keymap_size; i++) {
-		unsigned int key = plat->keymap_data->keymap[i];
-
-		keypad->cols |= 1 << KEY_COL(key);
-		keypad->rows |= 1 << KEY_ROW(key);
-	}
+	stmpe_keypad_fill_used_pins(pdev, keypad, plat);
 
 	keypad->stmpe = stmpe;
 	keypad->plat = plat;
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index ba157d4..b03cc64 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -321,6 +321,7 @@ static struct resource stmpe_keypad_resources[] = {
 
 static struct mfd_cell stmpe_keypad_cell = {
 	.name		= "stmpe-keypad",
+	.of_compatible  = "st,stmpe-keypad",
 	.resources	= stmpe_keypad_resources,
 	.num_resources	= ARRAY_SIZE(stmpe_keypad_resources),
 };
-- 
1.7.9.5


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

* [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver
  2012-11-14 13:47 [PATCH 0/5] Input related patches Lee Jones
                   ` (3 preceding siblings ...)
  2012-11-14 13:47 ` [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree Lee Jones
@ 2012-11-14 13:47 ` Lee Jones
  2012-11-23 15:54   ` Lee Jones
  2012-11-24  8:23   ` Dmitry Torokhov
  4 siblings, 2 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-14 13:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Lee Jones, Dmitry Torokhov, linux-input

Here we add the required documentation for the STMPE Device
Tree bindings. It describes all of the bindings currently
supported by the driver.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 .../devicetree/bindings/input/stmpe-keypad.txt     |   39 ++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/input/stmpe-keypad.txt

diff --git a/Documentation/devicetree/bindings/input/stmpe-keypad.txt b/Documentation/devicetree/bindings/input/stmpe-keypad.txt
new file mode 100644
index 0000000..1b97222
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/stmpe-keypad.txt
@@ -0,0 +1,39 @@
+* STMPE Keypad
+
+Required properties:
+ - compatible               : "st,stmpe-keypad"
+ - linux,keymap             : See ./matrix-keymap.txt
+
+Optional properties:
+ - debounce-interval        : Debouncing interval time in milliseconds
+ - st,scan-count            : Scanning cycles elapsed before key data is updated
+ - st,no-autorepeat         : If specified device will not autorepeat
+
+Example:
+
+	stmpe_keypad {
+		compatible = "st,stmpe-keypad";
+
+		debounce-interval = <64>;
+		st,scan-count = <8>;
+		st,no-autorepeat;
+
+		linux,keymap = <0x205006b
+				0x4010074
+				0x3050072
+				0x1030004
+				0x502006a
+				0x500000a
+				0x5008b
+				0x706001c
+				0x405000b
+				0x6070003
+				0x3040067
+				0x303006c
+				0x60400e7
+				0x602009e
+				0x4020073
+				0x5050002
+				0x4030069
+				0x3020008>;
+	};
-- 
1.7.9.5


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

* Re: [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-14 13:47 ` [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver Lee Jones
@ 2012-11-21 18:42   ` Dmitry Torokhov
  2012-11-22 11:28     ` Lee Jones
  2012-11-22 12:10   ` Lee Jones
  1 sibling, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-21 18:42 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

Hi Lee,

On Wed, Nov 14, 2012 at 01:47:14PM +0000, Lee Jones wrote:
> @@ -272,6 +276,60 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
>  }
>  
>  /**
> + * bu21013_gpio_board_init() - configures the touch panel
> + * @reset_pin: reset pin number
> + *
> + * This function is used to configure the voltage and
> + * reset the touch panel controller.
> + */
> +static int bu21013_gpio_board_init(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	bu21013_devices++;
> +	if (bu21013_devices == 1) {

This does not make sense. If gpio is per-device now then we should
simply set it up and not count devices.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-21 18:42   ` Dmitry Torokhov
@ 2012-11-22 11:28     ` Lee Jones
  0 siblings, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-22 11:28 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

On Wed, 21 Nov 2012, Dmitry Torokhov wrote:

> Hi Lee,
> 
> On Wed, Nov 14, 2012 at 01:47:14PM +0000, Lee Jones wrote:
> > @@ -272,6 +276,60 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
> >  }
> >  
> >  /**
> > + * bu21013_gpio_board_init() - configures the touch panel
> > + * @reset_pin: reset pin number
> > + *
> > + * This function is used to configure the voltage and
> > + * reset the touch panel controller.
> > + */
> > +static int bu21013_gpio_board_init(int reset_pin)
> > +{
> > +	int retval = 0;
> > +
> > +	bu21013_devices++;
> > +	if (bu21013_devices == 1) {
> 
> This does not make sense. If gpio is per-device now then we should
> simply set it up and not count devices.

No problem. I'll fixup.

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

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

* Re: [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-14 13:47 ` [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver Lee Jones
  2012-11-21 18:42   ` Dmitry Torokhov
@ 2012-11-22 12:10   ` Lee Jones
  2012-11-23 15:52     ` Lee Jones
  2012-11-24  7:43     ` Dmitry Torokhov
  1 sibling, 2 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-22 12:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

Author: Lee Jones <lee.jones@linaro.org>
Date:   Fri Sep 28 10:29:07 2012 +0100

    Input: bu21013_ts - Move GPIO init and exit functions into the driver
    
    These GPIO init and exit functions have no place in platform data.
    Instead they should be part of the driver. This patch moves them to
    their rightful place, which subsequently elevates platform data of
    yet more cruft.
    
    Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Cc: linux-input@vger.kernel.org
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>

diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c
index 564f57d..eb19a7e 100644
--- a/arch/arm/mach-ux500/board-mop500-stuib.c
+++ b/arch/arm/mach-ux500/board-mop500-stuib.c
@@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
  * BU21013 ROHM touchscreen interface on the STUIBs
  */
 
-/* tracks number of bu21013 devices being enabled */
-static int bu21013_devices;
-
 #define TOUCH_GPIO_PIN  84
 
 #define TOUCH_XMAX	384
@@ -88,73 +85,8 @@ static int bu21013_devices;
 #define PRCMU_CLOCK_OCR		0x1CC
 #define TSC_EXT_CLOCK_9_6MHZ	0x840000
 
-/**
- * bu21013_gpio_board_init : configures the touch panel.
- * @reset_pin: reset pin number
- * This function can be used to configures
- * the voltage and reset the touch panel controller.
- */
-static int bu21013_gpio_board_init(int reset_pin)
-{
-	int retval = 0;
-
-	bu21013_devices++;
-	if (bu21013_devices == 1) {
-		retval = gpio_request(reset_pin, "touchp_reset");
-		if (retval) {
-			printk(KERN_ERR "Unable to request gpio reset_pin");
-			return retval;
-		}
-		retval = gpio_direction_output(reset_pin, 1);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-	}
-
-	return retval;
-}
-
-/**
- * bu21013_gpio_board_exit : deconfigures the touch panel controller
- * @reset_pin: reset pin number
- * This function can be used to deconfigures the chip selection
- * for touch panel controller.
- */
-static int bu21013_gpio_board_exit(int reset_pin)
-{
-	int retval = 0;
-
-	if (bu21013_devices == 1) {
-		retval = gpio_direction_output(reset_pin, 0);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-		gpio_set_value(reset_pin, 0);
-	}
-	bu21013_devices--;
-
-	return retval;
-}
-
-/**
- * bu21013_read_pin_val : get the interrupt pin value
- * This function can be used to get the interrupt pin value for touch panel
- * controller.
- */
-static int bu21013_read_pin_val(void)
-{
-	return gpio_get_value(TOUCH_GPIO_PIN);
-}
-
 static struct bu21013_platform_device tsc_plat_device = {
-	.cs_en = bu21013_gpio_board_init,
-	.cs_dis = bu21013_gpio_board_exit,
-	.irq_read_val = bu21013_read_pin_val,
-	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
+	.touch_pin = TOUCH_GPIO_PIN,
 	.touch_x_max = TOUCH_XMAX,
 	.touch_y_max = TOUCH_YMAX,
 	.ext_clk = false,
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 2fae682..08ffb19 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
+#include <linux/gpio.h>
 
 #define PEN_DOWN_INTR	0
 #define MAX_FINGERS	2
@@ -262,7 +263,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 			return IRQ_NONE;
 		}
 
-		data->intr_pin = data->chip->irq_read_val();
+		data->intr_pin = gpio_get_value(data->chip->touch_pin);
 		if (data->intr_pin == PEN_DOWN_INTR)
 			wait_event_timeout(data->wait, data->touch_stopped,
 					   msecs_to_jiffies(2));
@@ -272,6 +273,54 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 }
 
 /**
+ * bu21013_gpio_board_init() - configures the touch panel
+ * @reset_pin: reset pin number
+ *
+ * This function is used to configure the voltage and
+ * reset the touch panel controller.
+ */
+static int bu21013_gpio_board_init(int reset_pin)
+{
+	int retval = 0;
+
+	retval = gpio_request(reset_pin, "touchp_reset");
+	if (retval) {
+		printk(KERN_ERR "Unable to request gpio reset_pin");
+		return retval;
+	}
+	retval = gpio_direction_output(reset_pin, 1);
+	if (retval < 0) {
+		printk(KERN_ERR "%s: gpio direction failed\n",
+		       __func__);
+		return retval;
+	}
+
+	return retval;
+}
+
+/**
+ * bu21013_gpio_board_exit() - deconfigures the touch panel controller
+ * @reset_pin: reset pin number
+ *
+ * This function is used to deconfigure the chip selection
+ * for touch panel controller.
+ */
+static int bu21013_gpio_board_exit(int reset_pin)
+{
+	int retval = 0;
+
+	retval = gpio_direction_output(reset_pin, 0);
+	if (retval < 0) {
+		printk(KERN_ERR "%s: gpio direction failed\n",
+		       __func__);
+		return retval;
+	}
+	gpio_set_value(reset_pin, 0);
+
+	return retval;
+}
+
+/**
  * bu21013_init_chip() - power on sequence for the bu21013 controller
  * @data: device structure pointer
  *
@@ -449,6 +498,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
+	pdata->irq = gpio_to_irq(pdata->touch_pin);
+
 	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
 	in_dev = input_allocate_device();
 	if (!bu21013_data || !in_dev) {
@@ -478,12 +529,10 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	init_waitqueue_head(&bu21013_data->wait);
 
 	/* configure the gpio pins */
-	if (pdata->cs_en) {
-		error = pdata->cs_en(pdata->cs_pin);
-		if (error < 0) {
-			dev_err(&client->dev, "chip init failed\n");
-			goto err_disable_regulator;
-		}
+	error = bu21013_gpio_board_init(pdata->cs_pin);
+	if (error < 0) {
+		dev_err(&client->dev, "chip init failed\n");
+		goto err_disable_regulator;
 	}
 
 	/* configure the touch panel controller */
@@ -531,7 +580,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 err_free_irq:
 	bu21013_free_irq(bu21013_data);
 err_cs_disable:
-	pdata->cs_dis(pdata->cs_pin);
+	bu21013_gpio_board_exit(pdata->cs_pin);
 err_disable_regulator:
 	regulator_disable(bu21013_data->regulator);
 err_put_regulator:
@@ -555,7 +604,7 @@ static int __devexit bu21013_remove(struct i2c_client *client)
 
 	bu21013_free_irq(bu21013_data);
 
-	bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
+	bu21013_gpio_board_exit(bu21013_data->chip->cs_pin);
 
 	input_unregister_device(bu21013_data->in_dev);
 
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
index 05e0328..01a2975 100644
--- a/include/linux/input/bu21013.h
+++ b/include/linux/input/bu21013.h
@@ -9,13 +9,11 @@
 
 /**
  * struct bu21013_platform_device - Handle the platform data
- * @cs_en:	pointer to the cs enable function
- * @cs_dis:	pointer to the cs disable function
- * @irq_read_val:    pointer to read the pen irq value function
  * @touch_x_max: touch x max
  * @touch_y_max: touch y max
  * @cs_pin: chip select pin
  * @irq: irq pin
+ * @touch_pin: touch gpio pin
  * @ext_clk: external clock flag
  * @x_flip: x flip flag
  * @y_flip: y flip flag
@@ -24,13 +22,11 @@
  * This is used to handle the platform data
  */
 struct bu21013_platform_device {
-	int (*cs_en)(int reset_pin);
-	int (*cs_dis)(int reset_pin);
-	int (*irq_read_val)(void);
 	int touch_x_max;
 	int touch_y_max;
 	unsigned int cs_pin;
 	unsigned int irq;
+	unsigned int touch_pin;
 	bool ext_clk;
 	bool x_flip;
 	bool y_flip;

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

* Re: [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists
  2012-11-14 13:47 ` [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists Lee Jones
@ 2012-11-23 15:50   ` Lee Jones
  2012-11-26 12:16   ` Lee Jones
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-23 15:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

> Currently the BU21013 Touch Screen driver requests a regulator by the
> name of 'V-TOUCH', which doesn't exist anywhere in the kernel. The
> correct name, as referenced in platform regulator code is 'avdd'. Here,
> when we request a regulator, we use the correct name instead.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/input/touchscreen/bu21013_ts.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 5c487d2..2fae682 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -461,7 +461,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  	bu21013_data->chip = pdata;
>  	bu21013_data->client = client;
>  
> -	bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
> +	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
>  	if (IS_ERR(bu21013_data->regulator)) {
>  		dev_err(&client->dev, "regulator_get failed\n");
>  		error = PTR_ERR(bu21013_data->regulator);
> -- 
> 1.7.9.5

Friendly poke for Dmitry.

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

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

* Re: [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-22 12:10   ` Lee Jones
@ 2012-11-23 15:52     ` Lee Jones
  2012-11-24  7:43     ` Dmitry Torokhov
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-23 15:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

On Thu, 22 Nov 2012, Lee Jones wrote:

> Author: Lee Jones <lee.jones@linaro.org>
> Date:   Fri Sep 28 10:29:07 2012 +0100
> 
>     Input: bu21013_ts - Move GPIO init and exit functions into the driver
>     
>     These GPIO init and exit functions have no place in platform data.
>     Instead they should be part of the driver. This patch moves them to
>     their rightful place, which subsequently elevates platform data of
>     yet more cruft.
>     
>     Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>     Cc: linux-input@vger.kernel.org
>     Acked-by: Arnd Bergmann <arnd@arndb.de>
>     Acked-by: Linus Walleij <linus.walleij@linaro.org>
>     Signed-off-by: Lee Jones <lee.jones@linaro.org>
> 
> diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c
> index 564f57d..eb19a7e 100644
> --- a/arch/arm/mach-ux500/board-mop500-stuib.c
> +++ b/arch/arm/mach-ux500/board-mop500-stuib.c
> @@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
>   * BU21013 ROHM touchscreen interface on the STUIBs
>   */
>  
> -/* tracks number of bu21013 devices being enabled */
> -static int bu21013_devices;
> -
>  #define TOUCH_GPIO_PIN  84
>  
>  #define TOUCH_XMAX	384
> @@ -88,73 +85,8 @@ static int bu21013_devices;
>  #define PRCMU_CLOCK_OCR		0x1CC
>  #define TSC_EXT_CLOCK_9_6MHZ	0x840000
>  
> -/**
> - * bu21013_gpio_board_init : configures the touch panel.
> - * @reset_pin: reset pin number
> - * This function can be used to configures
> - * the voltage and reset the touch panel controller.
> - */
> -static int bu21013_gpio_board_init(int reset_pin)
> -{
> -	int retval = 0;
> -
> -	bu21013_devices++;
> -	if (bu21013_devices == 1) {
> -		retval = gpio_request(reset_pin, "touchp_reset");
> -		if (retval) {
> -			printk(KERN_ERR "Unable to request gpio reset_pin");
> -			return retval;
> -		}
> -		retval = gpio_direction_output(reset_pin, 1);
> -		if (retval < 0) {
> -			printk(KERN_ERR "%s: gpio direction failed\n",
> -					__func__);
> -			return retval;
> -		}
> -	}
> -
> -	return retval;
> -}
> -
> -/**
> - * bu21013_gpio_board_exit : deconfigures the touch panel controller
> - * @reset_pin: reset pin number
> - * This function can be used to deconfigures the chip selection
> - * for touch panel controller.
> - */
> -static int bu21013_gpio_board_exit(int reset_pin)
> -{
> -	int retval = 0;
> -
> -	if (bu21013_devices == 1) {
> -		retval = gpio_direction_output(reset_pin, 0);
> -		if (retval < 0) {
> -			printk(KERN_ERR "%s: gpio direction failed\n",
> -					__func__);
> -			return retval;
> -		}
> -		gpio_set_value(reset_pin, 0);
> -	}
> -	bu21013_devices--;
> -
> -	return retval;
> -}
> -
> -/**
> - * bu21013_read_pin_val : get the interrupt pin value
> - * This function can be used to get the interrupt pin value for touch panel
> - * controller.
> - */
> -static int bu21013_read_pin_val(void)
> -{
> -	return gpio_get_value(TOUCH_GPIO_PIN);
> -}
> -
>  static struct bu21013_platform_device tsc_plat_device = {
> -	.cs_en = bu21013_gpio_board_init,
> -	.cs_dis = bu21013_gpio_board_exit,
> -	.irq_read_val = bu21013_read_pin_val,
> -	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
> +	.touch_pin = TOUCH_GPIO_PIN,
>  	.touch_x_max = TOUCH_XMAX,
>  	.touch_y_max = TOUCH_YMAX,
>  	.ext_clk = false,
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 2fae682..08ffb19 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -14,6 +14,7 @@
>  #include <linux/slab.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/module.h>
> +#include <linux/gpio.h>
>  
>  #define PEN_DOWN_INTR	0
>  #define MAX_FINGERS	2
> @@ -262,7 +263,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
>  			return IRQ_NONE;
>  		}
>  
> -		data->intr_pin = data->chip->irq_read_val();
> +		data->intr_pin = gpio_get_value(data->chip->touch_pin);
>  		if (data->intr_pin == PEN_DOWN_INTR)
>  			wait_event_timeout(data->wait, data->touch_stopped,
>  					   msecs_to_jiffies(2));
> @@ -272,6 +273,54 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
>  }
>  
>  /**
> + * bu21013_gpio_board_init() - configures the touch panel
> + * @reset_pin: reset pin number
> + *
> + * This function is used to configure the voltage and
> + * reset the touch panel controller.
> + */
> +static int bu21013_gpio_board_init(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	retval = gpio_request(reset_pin, "touchp_reset");
> +	if (retval) {
> +		printk(KERN_ERR "Unable to request gpio reset_pin");
> +		return retval;
> +	}
> +	retval = gpio_direction_output(reset_pin, 1);
> +	if (retval < 0) {
> +		printk(KERN_ERR "%s: gpio direction failed\n",
> +		       __func__);
> +		return retval;
> +	}
> +
> +	return retval;
> +}
> +
> +/**
> + * bu21013_gpio_board_exit() - deconfigures the touch panel controller
> + * @reset_pin: reset pin number
> + *
> + * This function is used to deconfigure the chip selection
> + * for touch panel controller.
> + */
> +static int bu21013_gpio_board_exit(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	retval = gpio_direction_output(reset_pin, 0);
> +	if (retval < 0) {
> +		printk(KERN_ERR "%s: gpio direction failed\n",
> +		       __func__);
> +		return retval;
> +	}
> +	gpio_set_value(reset_pin, 0);
> +
> +	return retval;
> +}
> +
> +/**
>   * bu21013_init_chip() - power on sequence for the bu21013 controller
>   * @data: device structure pointer
>   *
> @@ -449,6 +498,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> +	pdata->irq = gpio_to_irq(pdata->touch_pin);
> +
>  	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
>  	in_dev = input_allocate_device();
>  	if (!bu21013_data || !in_dev) {
> @@ -478,12 +529,10 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  	init_waitqueue_head(&bu21013_data->wait);
>  
>  	/* configure the gpio pins */
> -	if (pdata->cs_en) {
> -		error = pdata->cs_en(pdata->cs_pin);
> -		if (error < 0) {
> -			dev_err(&client->dev, "chip init failed\n");
> -			goto err_disable_regulator;
> -		}
> +	error = bu21013_gpio_board_init(pdata->cs_pin);
> +	if (error < 0) {
> +		dev_err(&client->dev, "chip init failed\n");
> +		goto err_disable_regulator;
>  	}
>  
>  	/* configure the touch panel controller */
> @@ -531,7 +580,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  err_free_irq:
>  	bu21013_free_irq(bu21013_data);
>  err_cs_disable:
> -	pdata->cs_dis(pdata->cs_pin);
> +	bu21013_gpio_board_exit(pdata->cs_pin);
>  err_disable_regulator:
>  	regulator_disable(bu21013_data->regulator);
>  err_put_regulator:
> @@ -555,7 +604,7 @@ static int __devexit bu21013_remove(struct i2c_client *client)
>  
>  	bu21013_free_irq(bu21013_data);
>  
> -	bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
> +	bu21013_gpio_board_exit(bu21013_data->chip->cs_pin);
>  
>  	input_unregister_device(bu21013_data->in_dev);
>  
> diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
> index 05e0328..01a2975 100644
> --- a/include/linux/input/bu21013.h
> +++ b/include/linux/input/bu21013.h
> @@ -9,13 +9,11 @@
>  
>  /**
>   * struct bu21013_platform_device - Handle the platform data
> - * @cs_en:	pointer to the cs enable function
> - * @cs_dis:	pointer to the cs disable function
> - * @irq_read_val:    pointer to read the pen irq value function
>   * @touch_x_max: touch x max
>   * @touch_y_max: touch y max
>   * @cs_pin: chip select pin
>   * @irq: irq pin
> + * @touch_pin: touch gpio pin
>   * @ext_clk: external clock flag
>   * @x_flip: x flip flag
>   * @y_flip: y flip flag
> @@ -24,13 +22,11 @@
>   * This is used to handle the platform data
>   */
>  struct bu21013_platform_device {
> -	int (*cs_en)(int reset_pin);
> -	int (*cs_dis)(int reset_pin);
> -	int (*irq_read_val)(void);
>  	int touch_x_max;
>  	int touch_y_max;
>  	unsigned int cs_pin;
>  	unsigned int irq;
> +	unsigned int touch_pin;
>  	bool ext_clk;
>  	bool x_flip;
>  	bool y_flip;

Friendly poke for Dmitry.

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

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

* Re: [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-14 13:47 ` [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting Lee Jones
@ 2012-11-23 15:52   ` Lee Jones
  2012-11-24  7:50     ` Dmitry Torokhov
  2012-11-27 11:38   ` [PATCH 3/5 v3] " Lee Jones
  1 sibling, 1 reply; 32+ messages in thread
From: Lee Jones @ 2012-11-23 15:52 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

On Wed, 14 Nov 2012, Lee Jones wrote:

> Now we can register the BU21013_ts touch screen when booting with
> Device Tree enabled. Here we parse all the necessary components
> previously expected to be passed from platform data.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/input/touchscreen/bu21013_ts.c |   39 ++++++++++++++++++++++++++++----
>  1 file changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 5d8fc75..afef874 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -15,6 +15,8 @@
>  #include <linux/regulator/consumer.h>
>  #include <linux/module.h>
>  #include <linux/gpio.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
>  
>  /* Reference tracking for multiple displays. */
>  static int bu21013_devices = 0;
> @@ -487,13 +489,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
>   * This function used to initializes the i2c-client touchscreen
>   * driver and returns integer.
>   */
> +static void __devinit bu21013_of_probe(struct device_node *np,
> +				struct bu21013_platform_device *pdata)
> +{
> +	pdata->y_flip = pdata->x_flip = false;
> +
> +	if (of_get_property(np, "rohm,flip-x", NULL))
> +		pdata->x_flip = true;
> +
> +	if (of_get_property(np, "rohm,flip-y", NULL))
> +		pdata->y_flip = true;
> +
> +	of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
> +	of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
> +
> +	pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
> +	pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
> +
> +	pdata->ext_clk = false;
> +}
> +
>  static int __devinit bu21013_probe(struct i2c_client *client,
>  					const struct i2c_device_id *id)
>  {
>  	struct bu21013_ts_data *bu21013_data;
>  	struct input_dev *in_dev;
> -	const struct bu21013_platform_device *pdata =
> -					client->dev.platform_data;
> +	struct device_node *np = client->dev.of_node;
> +	struct bu21013_platform_device *pdata = client->dev.platform_data;
>  	int error;
>  
>  	if (!i2c_check_functionality(client->adapter,
> @@ -503,8 +525,17 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  	}
>  
>  	if (!pdata) {
> -		dev_err(&client->dev, "platform data not defined\n");
> -		return -EINVAL;
> +		if (np) {
> +			pdata = devm_kzalloc(&client->dev, sizeof(*pdata),
> +					GFP_KERNEL);
> +			if (!pdata)
> +				return -ENOMEM;
> +
> +			bu21013_of_probe(np, pdata);
> +		} else {
> +			dev_err(&client->dev, "no device tree or platform data\n");
> +			return -EINVAL;
> +		}
>  	}
>  
>  	pdata->irq = gpio_to_irq(pdata->touch_pin);
> -- 
> 1.7.9.5
> 

Friendly poke for Dmitry.

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

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

* Re: [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree
  2012-11-14 13:47 ` [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree Lee Jones
@ 2012-11-23 15:53   ` Lee Jones
  2013-01-08  8:38   ` Lee Jones
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-23 15:53 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

On Wed, 14 Nov 2012, Lee Jones wrote:

> This patch allows the STMPE driver to be successfully probed and
> initialised when Device Tree support is enabled. Besides the usual
> platform data changes, we also separate the process of filling in
> the 'in use' pin bitmap, as we have to extract the information from
> Device Tree in the DT boot case.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/input/keyboard/stmpe-keypad.c |   67 ++++++++++++++++++++++++++++-----
>  drivers/mfd/stmpe.c                   |    1 +
>  2 files changed, 59 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
> index 470a877..4ae01d5 100644
> --- a/drivers/input/keyboard/stmpe-keypad.c
> +++ b/drivers/input/keyboard/stmpe-keypad.c
> @@ -257,19 +257,73 @@ static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
>  			      (plat->debounce_ms << 1));
>  }
>  
> +static int stmpe_keypad_fill_used_pins(struct platform_device *pdev,
> +				struct stmpe_keypad *keypad,
> +				struct stmpe_keypad_platform_data *plat)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	unsigned int proplen;
> +	const __be32 *prop;
> +	int i;
> +
> +	if (np) {
> +		prop = of_get_property(np, "linux,keymap", &proplen);
> +		if (!prop) {
> +			dev_err(&pdev->dev,
> +				"linux,keymap property not defined\n");
> +			return -EINVAL;
> +		}
> +
> +		for (i = 0; i < proplen / sizeof(u32); i++) {
> +			unsigned int key = be32_to_cpup(prop + i);
> +
> +			keypad->cols |= 1 << KEY_COL(key);
> +			keypad->rows |= 1 << KEY_ROW(key);
> +		}
> +	} else {
> +		for (i = 0; i < plat->keymap_data->keymap_size; i++) {
> +			unsigned int key = plat->keymap_data->keymap[i];
> +
> +			keypad->cols |= 1 << KEY_COL(key);
> +			keypad->rows |= 1 << KEY_ROW(key);
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static void __devinit stmpe_keypad_of_probe(struct device_node *np,
> +				struct stmpe_keypad_platform_data *plat)
> +{
> +	of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
> +	of_property_read_u32(np, "st,scan-count", &plat->scan_count);
> +
> +	if (of_get_property(np, "st,no-autorepeat", NULL))
> +		plat->no_autorepeat = true;
> +}
> +
>  static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  {
>  	struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
>  	struct stmpe_keypad_platform_data *plat;
> +	struct device_node *np = pdev->dev.of_node;
>  	struct stmpe_keypad *keypad;
>  	struct input_dev *input;
>  	int ret;
>  	int irq;
> -	int i;
>  
>  	plat = stmpe->pdata->keypad;
> -	if (!plat)
> -		return -ENODEV;
> +	if (!plat) {
> +		if (np) {
> +			plat = devm_kzalloc(&pdev->dev,
> +					sizeof(*plat), GFP_KERNEL);
> +			if (!plat)
> +				return -ENOMEM;
> +
> +			stmpe_keypad_of_probe(np, plat);
> +		} else
> +			return -ENODEV;
> +	}
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
> @@ -300,12 +354,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  	if (!plat->no_autorepeat)
>  		__set_bit(EV_REP, input->evbit);
>  
> -	for (i = 0; i < plat->keymap_data->keymap_size; i++) {
> -		unsigned int key = plat->keymap_data->keymap[i];
> -
> -		keypad->cols |= 1 << KEY_COL(key);
> -		keypad->rows |= 1 << KEY_ROW(key);
> -	}
> +	stmpe_keypad_fill_used_pins(pdev, keypad, plat);
>  
>  	keypad->stmpe = stmpe;
>  	keypad->plat = plat;
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index ba157d4..b03cc64 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -321,6 +321,7 @@ static struct resource stmpe_keypad_resources[] = {
>  
>  static struct mfd_cell stmpe_keypad_cell = {
>  	.name		= "stmpe-keypad",
> +	.of_compatible  = "st,stmpe-keypad",
>  	.resources	= stmpe_keypad_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_keypad_resources),
>  };
> -- 
> 1.7.9.5
> 

You guessed it, friendly poke for Dmitry.

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

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

* Re: [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver
  2012-11-14 13:47 ` [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver Lee Jones
@ 2012-11-23 15:54   ` Lee Jones
  2012-11-24  8:23   ` Dmitry Torokhov
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-23 15:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

On Wed, 14 Nov 2012, Lee Jones wrote:

> Here we add the required documentation for the STMPE Device
> Tree bindings. It describes all of the bindings currently
> supported by the driver.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  .../devicetree/bindings/input/stmpe-keypad.txt     |   39 ++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/input/stmpe-keypad.txt
> 
> diff --git a/Documentation/devicetree/bindings/input/stmpe-keypad.txt b/Documentation/devicetree/bindings/input/stmpe-keypad.txt
> new file mode 100644
> index 0000000..1b97222
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/input/stmpe-keypad.txt
> @@ -0,0 +1,39 @@
> +* STMPE Keypad
> +
> +Required properties:
> + - compatible               : "st,stmpe-keypad"
> + - linux,keymap             : See ./matrix-keymap.txt
> +
> +Optional properties:
> + - debounce-interval        : Debouncing interval time in milliseconds
> + - st,scan-count            : Scanning cycles elapsed before key data is updated
> + - st,no-autorepeat         : If specified device will not autorepeat
> +
> +Example:
> +
> +	stmpe_keypad {
> +		compatible = "st,stmpe-keypad";
> +
> +		debounce-interval = <64>;
> +		st,scan-count = <8>;
> +		st,no-autorepeat;
> +
> +		linux,keymap = <0x205006b
> +				0x4010074
> +				0x3050072
> +				0x1030004
> +				0x502006a
> +				0x500000a
> +				0x5008b
> +				0x706001c
> +				0x405000b
> +				0x6070003
> +				0x3040067
> +				0x303006c
> +				0x60400e7
> +				0x602009e
> +				0x4020073
> +				0x5050002
> +				0x4030069
> +				0x3020008>;
> +	};
> -- 
> 1.7.9.5
> 

Last one.

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

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

* Re: [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-22 12:10   ` Lee Jones
  2012-11-23 15:52     ` Lee Jones
@ 2012-11-24  7:43     ` Dmitry Torokhov
  2012-11-26 10:43       ` Lee Jones
  2012-11-26 12:01       ` [PATCH 2/5 v2] " Lee Jones
  1 sibling, 2 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-24  7:43 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

Hi Lee,

On Thu, Nov 22, 2012 at 12:10:30PM +0000, Lee Jones wrote:
>  
>  /**
> + * bu21013_gpio_board_init() - configures the touch panel
> + * @reset_pin: reset pin number
> + *
> + * This function is used to configure the voltage and
> + * reset the touch panel controller.
> + */
> +static int bu21013_gpio_board_init(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	retval = gpio_request(reset_pin, "touchp_reset");
> +	if (retval) {
> +		printk(KERN_ERR "Unable to request gpio reset_pin");
> +		return retval;
> +	}
> +	retval = gpio_direction_output(reset_pin, 1);
> +	if (retval < 0) {
> +		printk(KERN_ERR "%s: gpio direction failed\n",
> +		       __func__);
> +		return retval;
> +	}

gpio_request_one() is handy here.

> +
> +	return retval;
> +}
> +
> +/**
> + * bu21013_gpio_board_exit() - deconfigures the touch panel controller
> + * @reset_pin: reset pin number
> + *
> + * This function is used to deconfigure the chip selection
> + * for touch panel controller.
> + */
> +static int bu21013_gpio_board_exit(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	retval = gpio_direction_output(reset_pin, 0);
> +	if (retval < 0) {
> +		printk(KERN_ERR "%s: gpio direction failed\n",
> +		       __func__);
> +		return retval;
> +	}
> +	gpio_set_value(reset_pin, 0);
> +

You ate forgetting to free gpio here. TBH the original did forget too.


> +	return retval;
> +}
> +
> +/**
>   * bu21013_init_chip() - power on sequence for the bu21013 controller
>   * @data: device structure pointer
>   *
> @@ -449,6 +498,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> +	pdata->irq = gpio_to_irq(pdata->touch_pin);
> +

Does it even compile? pdata is const...

Does the version below still work for you?

Thanks.

-- 
Dmitry

Input: bu21013_ts - move GPIO init and exit functions into the driver

From: Lee Jones <lee.jones@linaro.org>

These GPIO init and exit functions have no place in platform data, they
should be part of the driver instead,

Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 arch/arm/mach-ux500/board-mop500-stuib.c |   95 +-----------------------------
 drivers/input/touchscreen/bu21013_ts.c   |   69 ++++++++++++++++------
 include/linux/input/bu21013.h            |    9 +--
 3 files changed, 56 insertions(+), 117 deletions(-)

diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c
index 8c97977..1243428 100644
--- a/arch/arm/mach-ux500/board-mop500-stuib.c
+++ b/arch/arm/mach-ux500/board-mop500-stuib.c
@@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
  * BU21013 ROHM touchscreen interface on the STUIBs
  */
 
-/* tracks number of bu21013 devices being enabled */
-static int bu21013_devices;
-
 #define TOUCH_GPIO_PIN  84
 
 #define TOUCH_XMAX	384
@@ -88,85 +85,8 @@ static int bu21013_devices;
 #define PRCMU_CLOCK_OCR		0x1CC
 #define TSC_EXT_CLOCK_9_6MHZ	0x840000
 
-/**
- * bu21013_gpio_board_init : configures the touch panel.
- * @reset_pin: reset pin number
- * This function can be used to configures
- * the voltage and reset the touch panel controller.
- */
-static int bu21013_gpio_board_init(int reset_pin)
-{
-	int retval = 0;
-
-	bu21013_devices++;
-	if (bu21013_devices == 1) {
-		retval = gpio_request(reset_pin, "touchp_reset");
-		if (retval) {
-			printk(KERN_ERR "Unable to request gpio reset_pin");
-			return retval;
-		}
-		retval = gpio_direction_output(reset_pin, 1);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-	}
-
-	return retval;
-}
-
-/**
- * bu21013_gpio_board_exit : deconfigures the touch panel controller
- * @reset_pin: reset pin number
- * This function can be used to deconfigures the chip selection
- * for touch panel controller.
- */
-static int bu21013_gpio_board_exit(int reset_pin)
-{
-	int retval = 0;
-
-	if (bu21013_devices == 1) {
-		retval = gpio_direction_output(reset_pin, 0);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-		gpio_set_value(reset_pin, 0);
-	}
-	bu21013_devices--;
-
-	return retval;
-}
-
-/**
- * bu21013_read_pin_val : get the interrupt pin value
- * This function can be used to get the interrupt pin value for touch panel
- * controller.
- */
-static int bu21013_read_pin_val(void)
-{
-	return gpio_get_value(TOUCH_GPIO_PIN);
-}
-
 static struct bu21013_platform_device tsc_plat_device = {
-	.cs_en = bu21013_gpio_board_init,
-	.cs_dis = bu21013_gpio_board_exit,
-	.irq_read_val = bu21013_read_pin_val,
-	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
-	.touch_x_max = TOUCH_XMAX,
-	.touch_y_max = TOUCH_YMAX,
-	.ext_clk = false,
-	.x_flip = false,
-	.y_flip = true,
-};
-
-static struct bu21013_platform_device tsc_plat2_device = {
-	.cs_en = bu21013_gpio_board_init,
-	.cs_dis = bu21013_gpio_board_exit,
-	.irq_read_val = bu21013_read_pin_val,
-	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
+	.touch_pin = TOUCH_GPIO_PIN,
 	.touch_x_max = TOUCH_XMAX,
 	.touch_y_max = TOUCH_YMAX,
 	.ext_clk = false,
@@ -181,21 +101,14 @@ static struct i2c_board_info __initdata u8500_i2c3_devices_stuib[] = {
 	},
 	{
 		I2C_BOARD_INFO("bu21013_tp", 0x5D),
-		.platform_data = &tsc_plat2_device,
+		.platform_data = &tsc_plat_device,
 	},
-
 };
 
 void __init mop500_stuib_init(void)
 {
-	if (machine_is_hrefv60()) {
-		tsc_plat_device.cs_pin = HREFV60_TOUCH_RST_GPIO;
-		tsc_plat2_device.cs_pin = HREFV60_TOUCH_RST_GPIO;
-	} else {
-		tsc_plat_device.cs_pin = GPIO_BU21013_CS;
-		tsc_plat2_device.cs_pin = GPIO_BU21013_CS;
-
-	}
+	tsc_plat_device.cs_pin = machine_is_hrefv60() ?
+				HREFV60_TOUCH_RST_GPIO : GPIO_BU21013_CS;
 
 	mop500_uib_i2c_add(0, mop500_i2c0_devices_stuib,
 			ARRAY_SIZE(mop500_i2c0_devices_stuib));
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 1e8cddd..88f4252 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
+#include <linux/gpio.h>
 
 #define PEN_DOWN_INTR	0
 #define MAX_FINGERS	2
@@ -148,11 +149,12 @@
 struct bu21013_ts_data {
 	struct i2c_client *client;
 	wait_queue_head_t wait;
-	bool touch_stopped;
 	const struct bu21013_platform_device *chip;
 	struct input_dev *in_dev;
-	unsigned int intr_pin;
 	struct regulator *regulator;
+	unsigned int irq;
+	unsigned int intr_pin;
+	bool touch_stopped;
 };
 
 /**
@@ -262,7 +264,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 			return IRQ_NONE;
 		}
 
-		data->intr_pin = data->chip->irq_read_val();
+		data->intr_pin = gpio_get_value(data->chip->touch_pin);
 		if (data->intr_pin == PEN_DOWN_INTR)
 			wait_event_timeout(data->wait, data->touch_stopped,
 					   msecs_to_jiffies(2));
@@ -418,10 +420,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
 {
 	bu21013_data->touch_stopped = true;
 	wake_up(&bu21013_data->wait);
-	free_irq(bu21013_data->chip->irq, bu21013_data);
+	free_irq(bu21013_data->irq, bu21013_data);
 }
 
 /**
+ * bu21013_cs_disable() - deconfigures the touch panel controller
+ * @bu21013_data: device structure pointer
+ *
+ * This function is used to deconfigure the chip selection
+ * for touch panel controller.
+ */
+static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
+{
+	int error;
+
+	error = gpio_direction_output(bu21013_data->chip->cs_pin, 0);
+	if (error < 0)
+		dev_warn(&bu21013_data->client->dev,
+			 "%s: gpio direction failed, error: %d\n",
+			 __func__, error);
+	else
+		gpio_set_value(bu21013_data->chip->cs_pin, 0);
+
+	gpio_free(bu21013_data->chip->cs_pin);
+}
+
+
+/**
  * bu21013_probe() - initializes the i2c-client touchscreen driver
  * @client: i2c client structure pointer
  * @id: i2c device id pointer
@@ -430,7 +455,7 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
  * driver and returns integer.
  */
 static int bu21013_probe(struct i2c_client *client,
-					const struct i2c_device_id *id)
+			 const struct i2c_device_id *id)
 {
 	struct bu21013_ts_data *bu21013_data;
 	struct input_dev *in_dev;
@@ -449,6 +474,11 @@ static int bu21013_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
+	if (!gpio_is_valid(pdata->touch_pin)) {
+		dev_err(&client->dev, "invalid touch_pin supplied\n");
+		return -EINVAL;
+	}
+
 	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
 	in_dev = input_allocate_device();
 	if (!bu21013_data || !in_dev) {
@@ -460,6 +490,7 @@ static int bu21013_probe(struct i2c_client *client,
 	bu21013_data->in_dev = in_dev;
 	bu21013_data->chip = pdata;
 	bu21013_data->client = client;
+	bu21013_data->irq = gpio_to_irq(pdata->touch_pin);
 
 	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
 	if (IS_ERR(bu21013_data->regulator)) {
@@ -478,12 +509,11 @@ static int bu21013_probe(struct i2c_client *client,
 	init_waitqueue_head(&bu21013_data->wait);
 
 	/* configure the gpio pins */
-	if (pdata->cs_en) {
-		error = pdata->cs_en(pdata->cs_pin);
-		if (error < 0) {
-			dev_err(&client->dev, "chip init failed\n");
-			goto err_disable_regulator;
-		}
+	error = gpio_request_one(pdata->cs_pin, GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
+				 "touchp_reset");
+	if (error < 0) {
+		dev_err(&client->dev, "Unable to request gpio reset_pin\n");
+		goto err_disable_regulator;
 	}
 
 	/* configure the touch panel controller */
@@ -508,12 +538,13 @@ static int bu21013_probe(struct i2c_client *client,
 						pdata->touch_y_max, 0, 0);
 	input_set_drvdata(in_dev, bu21013_data);
 
-	error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq,
+	error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq,
 				     IRQF_TRIGGER_FALLING | IRQF_SHARED |
 					IRQF_ONESHOT,
 				     DRIVER_TP, bu21013_data);
 	if (error) {
-		dev_err(&client->dev, "request irq %d failed\n", pdata->irq);
+		dev_err(&client->dev, "request irq %d failed\n",
+			bu21013_data->irq);
 		goto err_cs_disable;
 	}
 
@@ -531,7 +562,7 @@ static int bu21013_probe(struct i2c_client *client,
 err_free_irq:
 	bu21013_free_irq(bu21013_data);
 err_cs_disable:
-	pdata->cs_dis(pdata->cs_pin);
+	bu21013_cs_disable(bu21013_data);
 err_disable_regulator:
 	regulator_disable(bu21013_data->regulator);
 err_put_regulator:
@@ -555,7 +586,7 @@ static int bu21013_remove(struct i2c_client *client)
 
 	bu21013_free_irq(bu21013_data);
 
-	bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
+	bu21013_cs_disable(bu21013_data);
 
 	input_unregister_device(bu21013_data->in_dev);
 
@@ -584,9 +615,9 @@ static int bu21013_suspend(struct device *dev)
 
 	bu21013_data->touch_stopped = true;
 	if (device_may_wakeup(&client->dev))
-		enable_irq_wake(bu21013_data->chip->irq);
+		enable_irq_wake(bu21013_data->irq);
 	else
-		disable_irq(bu21013_data->chip->irq);
+		disable_irq(bu21013_data->irq);
 
 	regulator_disable(bu21013_data->regulator);
 
@@ -621,9 +652,9 @@ static int bu21013_resume(struct device *dev)
 	bu21013_data->touch_stopped = false;
 
 	if (device_may_wakeup(&client->dev))
-		disable_irq_wake(bu21013_data->chip->irq);
+		disable_irq_wake(bu21013_data->irq);
 	else
-		enable_irq(bu21013_data->chip->irq);
+		enable_irq(bu21013_data->irq);
 
 	return 0;
 }
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
index 05e0328..3ad1be5 100644
--- a/include/linux/input/bu21013.h
+++ b/include/linux/input/bu21013.h
@@ -9,13 +9,11 @@
 
 /**
  * struct bu21013_platform_device - Handle the platform data
- * @cs_en:	pointer to the cs enable function
- * @cs_dis:	pointer to the cs disable function
- * @irq_read_val:    pointer to read the pen irq value function
  * @touch_x_max: touch x max
  * @touch_y_max: touch y max
  * @cs_pin: chip select pin
  * @irq: irq pin
+ * @touch_pin: touch gpio pin
  * @ext_clk: external clock flag
  * @x_flip: x flip flag
  * @y_flip: y flip flag
@@ -24,13 +22,10 @@
  * This is used to handle the platform data
  */
 struct bu21013_platform_device {
-	int (*cs_en)(int reset_pin);
-	int (*cs_dis)(int reset_pin);
-	int (*irq_read_val)(void);
 	int touch_x_max;
 	int touch_y_max;
 	unsigned int cs_pin;
-	unsigned int irq;
+	unsigned int touch_pin;
 	bool ext_clk;
 	bool x_flip;
 	bool y_flip;

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

* Re: [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-23 15:52   ` Lee Jones
@ 2012-11-24  7:50     ` Dmitry Torokhov
  2012-11-26  9:07       ` Lee Jones
  2012-11-26 10:50       ` [PATCH 3/5 v2] " Lee Jones
  0 siblings, 2 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-24  7:50 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

On Fri, Nov 23, 2012 at 03:52:58PM +0000, Lee Jones wrote:
> On Wed, 14 Nov 2012, Lee Jones wrote:
> 
> > Now we can register the BU21013_ts touch screen when booting with
> > Device Tree enabled. Here we parse all the necessary components
> > previously expected to be passed from platform data.
> > 
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: linux-input@vger.kernel.org
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  drivers/input/touchscreen/bu21013_ts.c |   39 ++++++++++++++++++++++++++++----
> >  1 file changed, 35 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> > index 5d8fc75..afef874 100644
> > --- a/drivers/input/touchscreen/bu21013_ts.c
> > +++ b/drivers/input/touchscreen/bu21013_ts.c
> > @@ -15,6 +15,8 @@
> >  #include <linux/regulator/consumer.h>
> >  #include <linux/module.h>
> >  #include <linux/gpio.h>
> > +#include <linux/of.h>
> > +#include <linux/of_gpio.h>
> >  
> >  /* Reference tracking for multiple displays. */
> >  static int bu21013_devices = 0;
> > @@ -487,13 +489,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
> >   * This function used to initializes the i2c-client touchscreen
> >   * driver and returns integer.
> >   */
> > +static void __devinit bu21013_of_probe(struct device_node *np,
> > +				struct bu21013_platform_device *pdata)
> > +{
> > +	pdata->y_flip = pdata->x_flip = false;
> > +
> > +	if (of_get_property(np, "rohm,flip-x", NULL))
> > +		pdata->x_flip = true;

	pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");

?

Can I also get patch documenting the DT properties?

Thanks.

-- 
Dmitry

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

* Re: [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver
  2012-11-14 13:47 ` [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver Lee Jones
  2012-11-23 15:54   ` Lee Jones
@ 2012-11-24  8:23   ` Dmitry Torokhov
  1 sibling, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-24  8:23 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

On Wed, Nov 14, 2012 at 01:47:17PM +0000, Lee Jones wrote:
> Here we add the required documentation for the STMPE Device
> Tree bindings. It describes all of the bindings currently
> supported by the driver.

Folded into the patch adding DT support to stmpe-keypad and applied.
Thank you Lee.

-- 
Dmitry

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

* Re: [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-24  7:50     ` Dmitry Torokhov
@ 2012-11-26  9:07       ` Lee Jones
  2012-11-26  9:31         ` Dmitry Torokhov
  2012-11-26 10:50       ` [PATCH 3/5 v2] " Lee Jones
  1 sibling, 1 reply; 32+ messages in thread
From: Lee Jones @ 2012-11-26  9:07 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

On Fri, 23 Nov 2012, Dmitry Torokhov wrote:

> On Fri, Nov 23, 2012 at 03:52:58PM +0000, Lee Jones wrote:
> > On Wed, 14 Nov 2012, Lee Jones wrote:
> > 
> > > Now we can register the BU21013_ts touch screen when booting with
> > > Device Tree enabled. Here we parse all the necessary components
> > > previously expected to be passed from platform data.
> > > 
> > > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > Cc: linux-input@vger.kernel.org
> > > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > ---
> > >  drivers/input/touchscreen/bu21013_ts.c |   39 ++++++++++++++++++++++++++++----
> > >  1 file changed, 35 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> > > index 5d8fc75..afef874 100644
> > > --- a/drivers/input/touchscreen/bu21013_ts.c
> > > +++ b/drivers/input/touchscreen/bu21013_ts.c
> > > @@ -15,6 +15,8 @@
> > >  #include <linux/regulator/consumer.h>
> > >  #include <linux/module.h>
> > >  #include <linux/gpio.h>
> > > +#include <linux/of.h>
> > > +#include <linux/of_gpio.h>
> > >  
> > >  /* Reference tracking for multiple displays. */
> > >  static int bu21013_devices = 0;
> > > @@ -487,13 +489,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
> > >   * This function used to initializes the i2c-client touchscreen
> > >   * driver and returns integer.
> > >   */
> > > +static void __devinit bu21013_of_probe(struct device_node *np,
> > > +				struct bu21013_platform_device *pdata)
> > > +{
> > > +	pdata->y_flip = pdata->x_flip = false;
> > > +
> > > +	if (of_get_property(np, "rohm,flip-x", NULL))
> > > +		pdata->x_flip = true;
> 
> 	pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
> 
> ?

Yes, we can do this now it exists.

> Can I also get patch documenting the DT properties?

Sure. As a follow-up? I'll resubmit this first, right away.

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

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

* Re: [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-26  9:07       ` Lee Jones
@ 2012-11-26  9:31         ` Dmitry Torokhov
  0 siblings, 0 replies; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-26  9:31 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

On Mon, Nov 26, 2012 at 09:07:36AM +0000, Lee Jones wrote:
> On Fri, 23 Nov 2012, Dmitry Torokhov wrote:
> 
> > On Fri, Nov 23, 2012 at 03:52:58PM +0000, Lee Jones wrote:
> > > On Wed, 14 Nov 2012, Lee Jones wrote:
> > > 
> > > > Now we can register the BU21013_ts touch screen when booting with
> > > > Device Tree enabled. Here we parse all the necessary components
> > > > previously expected to be passed from platform data.
> > > > 
> > > > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > > Cc: linux-input@vger.kernel.org
> > > > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > > > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > > ---
> > > >  drivers/input/touchscreen/bu21013_ts.c |   39 ++++++++++++++++++++++++++++----
> > > >  1 file changed, 35 insertions(+), 4 deletions(-)
> > > > 
> > > > diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> > > > index 5d8fc75..afef874 100644
> > > > --- a/drivers/input/touchscreen/bu21013_ts.c
> > > > +++ b/drivers/input/touchscreen/bu21013_ts.c
> > > > @@ -15,6 +15,8 @@
> > > >  #include <linux/regulator/consumer.h>
> > > >  #include <linux/module.h>
> > > >  #include <linux/gpio.h>
> > > > +#include <linux/of.h>
> > > > +#include <linux/of_gpio.h>
> > > >  
> > > >  /* Reference tracking for multiple displays. */
> > > >  static int bu21013_devices = 0;
> > > > @@ -487,13 +489,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
> > > >   * This function used to initializes the i2c-client touchscreen
> > > >   * driver and returns integer.
> > > >   */
> > > > +static void __devinit bu21013_of_probe(struct device_node *np,
> > > > +				struct bu21013_platform_device *pdata)
> > > > +{
> > > > +	pdata->y_flip = pdata->x_flip = false;
> > > > +
> > > > +	if (of_get_property(np, "rohm,flip-x", NULL))
> > > > +		pdata->x_flip = true;
> > 
> > 	pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
> > 
> > ?
> 
> Yes, we can do this now it exists.
> 
> > Can I also get patch documenting the DT properties?
> 
> Sure. As a follow-up? I'll resubmit this first, right away.

No preference but I am going to fold documentation with the patch
implementing DT support anyway.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-24  7:43     ` Dmitry Torokhov
@ 2012-11-26 10:43       ` Lee Jones
  2012-11-26 12:01       ` [PATCH 2/5 v2] " Lee Jones
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-26 10:43 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

On Fri, 23 Nov 2012, Dmitry Torokhov wrote:

> Hi Lee,
> 
> On Thu, Nov 22, 2012 at 12:10:30PM +0000, Lee Jones wrote:
> >  
> >  /**
> > + * bu21013_gpio_board_init() - configures the touch panel
> > + * @reset_pin: reset pin number
> > + *
> > + * This function is used to configure the voltage and
> > + * reset the touch panel controller.
> > + */
> > +static int bu21013_gpio_board_init(int reset_pin)
> > +{
> > +	int retval = 0;
> > +
> > +	retval = gpio_request(reset_pin, "touchp_reset");
> > +	if (retval) {
> > +		printk(KERN_ERR "Unable to request gpio reset_pin");
> > +		return retval;
> > +	}
> > +	retval = gpio_direction_output(reset_pin, 1);
> > +	if (retval < 0) {
> > +		printk(KERN_ERR "%s: gpio direction failed\n",
> > +		       __func__);
> > +		return retval;
> > +	}
> 
> gpio_request_one() is handy here.

Okay, I'll look into that.

> > +
> > +	return retval;
> > +}
> > +
> > +/**
> > + * bu21013_gpio_board_exit() - deconfigures the touch panel controller
> > + * @reset_pin: reset pin number
> > + *
> > + * This function is used to deconfigure the chip selection
> > + * for touch panel controller.
> > + */
> > +static int bu21013_gpio_board_exit(int reset_pin)
> > +{
> > +	int retval = 0;
> > +
> > +	retval = gpio_direction_output(reset_pin, 0);
> > +	if (retval < 0) {
> > +		printk(KERN_ERR "%s: gpio direction failed\n",
> > +		       __func__);
> > +		return retval;
> > +	}
> > +	gpio_set_value(reset_pin, 0);
> > +
> 
> You ate forgetting to free gpio here. TBH the original did forget too.
> 
> 
> > +	return retval;
> > +}
> > +
> > +/**
> >   * bu21013_init_chip() - power on sequence for the bu21013 controller
> >   * @data: device structure pointer
> >   *
> > @@ -449,6 +498,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
> >  		return -EINVAL;
> >  	}
> >  
> > +	pdata->irq = gpio_to_irq(pdata->touch_pin);
> > +
> 
> Does it even compile? pdata is const...
> 
> Does the version below still work for you?

The version I sent you works. I have a working touchscreen.

> Thanks.
> 
> -- 
> Dmitry
> 
> Input: bu21013_ts - move GPIO init and exit functions into the driver
> 
> From: Lee Jones <lee.jones@linaro.org>
> 
> These GPIO init and exit functions have no place in platform data, they
> should be part of the driver instead,
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  arch/arm/mach-ux500/board-mop500-stuib.c |   95 +-----------------------------
>  drivers/input/touchscreen/bu21013_ts.c   |   69 ++++++++++++++++------
>  include/linux/input/bu21013.h            |    9 +--
>  3 files changed, 56 insertions(+), 117 deletions(-)
> 
> diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c
> index 8c97977..1243428 100644
> --- a/arch/arm/mach-ux500/board-mop500-stuib.c
> +++ b/arch/arm/mach-ux500/board-mop500-stuib.c
> @@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
>   * BU21013 ROHM touchscreen interface on the STUIBs
>   */
>  
> -/* tracks number of bu21013 devices being enabled */
> -static int bu21013_devices;
> -
>  #define TOUCH_GPIO_PIN  84
>  
>  #define TOUCH_XMAX	384
> @@ -88,85 +85,8 @@ static int bu21013_devices;
>  #define PRCMU_CLOCK_OCR		0x1CC
>  #define TSC_EXT_CLOCK_9_6MHZ	0x840000
>  
> -/**
> - * bu21013_gpio_board_init : configures the touch panel.
> - * @reset_pin: reset pin number
> - * This function can be used to configures
> - * the voltage and reset the touch panel controller.
> - */
> -static int bu21013_gpio_board_init(int reset_pin)
> -{
> -	int retval = 0;
> -
> -	bu21013_devices++;
> -	if (bu21013_devices == 1) {
> -		retval = gpio_request(reset_pin, "touchp_reset");
> -		if (retval) {
> -			printk(KERN_ERR "Unable to request gpio reset_pin");
> -			return retval;
> -		}
> -		retval = gpio_direction_output(reset_pin, 1);
> -		if (retval < 0) {
> -			printk(KERN_ERR "%s: gpio direction failed\n",
> -					__func__);
> -			return retval;
> -		}
> -	}
> -
> -	return retval;
> -}
> -
> -/**
> - * bu21013_gpio_board_exit : deconfigures the touch panel controller
> - * @reset_pin: reset pin number
> - * This function can be used to deconfigures the chip selection
> - * for touch panel controller.
> - */
> -static int bu21013_gpio_board_exit(int reset_pin)
> -{
> -	int retval = 0;
> -
> -	if (bu21013_devices == 1) {
> -		retval = gpio_direction_output(reset_pin, 0);
> -		if (retval < 0) {
> -			printk(KERN_ERR "%s: gpio direction failed\n",
> -					__func__);
> -			return retval;
> -		}
> -		gpio_set_value(reset_pin, 0);
> -	}
> -	bu21013_devices--;
> -
> -	return retval;
> -}
> -
> -/**
> - * bu21013_read_pin_val : get the interrupt pin value
> - * This function can be used to get the interrupt pin value for touch panel
> - * controller.
> - */
> -static int bu21013_read_pin_val(void)
> -{
> -	return gpio_get_value(TOUCH_GPIO_PIN);
> -}
> -
>  static struct bu21013_platform_device tsc_plat_device = {
> -	.cs_en = bu21013_gpio_board_init,
> -	.cs_dis = bu21013_gpio_board_exit,
> -	.irq_read_val = bu21013_read_pin_val,
> -	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
> -	.touch_x_max = TOUCH_XMAX,
> -	.touch_y_max = TOUCH_YMAX,
> -	.ext_clk = false,
> -	.x_flip = false,
> -	.y_flip = true,
> -};
> -
> -static struct bu21013_platform_device tsc_plat2_device = {
> -	.cs_en = bu21013_gpio_board_init,
> -	.cs_dis = bu21013_gpio_board_exit,
> -	.irq_read_val = bu21013_read_pin_val,
> -	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
> +	.touch_pin = TOUCH_GPIO_PIN,
>  	.touch_x_max = TOUCH_XMAX,
>  	.touch_y_max = TOUCH_YMAX,
>  	.ext_clk = false,
> @@ -181,21 +101,14 @@ static struct i2c_board_info __initdata u8500_i2c3_devices_stuib[] = {
>  	},
>  	{
>  		I2C_BOARD_INFO("bu21013_tp", 0x5D),
> -		.platform_data = &tsc_plat2_device,
> +		.platform_data = &tsc_plat_device,
>  	},
> -
>  };
>  
>  void __init mop500_stuib_init(void)
>  {
> -	if (machine_is_hrefv60()) {
> -		tsc_plat_device.cs_pin = HREFV60_TOUCH_RST_GPIO;
> -		tsc_plat2_device.cs_pin = HREFV60_TOUCH_RST_GPIO;
> -	} else {
> -		tsc_plat_device.cs_pin = GPIO_BU21013_CS;
> -		tsc_plat2_device.cs_pin = GPIO_BU21013_CS;
> -
> -	}
> +	tsc_plat_device.cs_pin = machine_is_hrefv60() ?
> +				HREFV60_TOUCH_RST_GPIO : GPIO_BU21013_CS;
>  
>  	mop500_uib_i2c_add(0, mop500_i2c0_devices_stuib,
>  			ARRAY_SIZE(mop500_i2c0_devices_stuib));
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 1e8cddd..88f4252 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -14,6 +14,7 @@
>  #include <linux/slab.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/module.h>
> +#include <linux/gpio.h>
>  
>  #define PEN_DOWN_INTR	0
>  #define MAX_FINGERS	2
> @@ -148,11 +149,12 @@
>  struct bu21013_ts_data {
>  	struct i2c_client *client;
>  	wait_queue_head_t wait;
> -	bool touch_stopped;
>  	const struct bu21013_platform_device *chip;
>  	struct input_dev *in_dev;
> -	unsigned int intr_pin;
>  	struct regulator *regulator;
> +	unsigned int irq;
> +	unsigned int intr_pin;
> +	bool touch_stopped;
>  };
>  
>  /**
> @@ -262,7 +264,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
>  			return IRQ_NONE;
>  		}
>  
> -		data->intr_pin = data->chip->irq_read_val();
> +		data->intr_pin = gpio_get_value(data->chip->touch_pin);
>  		if (data->intr_pin == PEN_DOWN_INTR)
>  			wait_event_timeout(data->wait, data->touch_stopped,
>  					   msecs_to_jiffies(2));
> @@ -418,10 +420,33 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
>  {
>  	bu21013_data->touch_stopped = true;
>  	wake_up(&bu21013_data->wait);
> -	free_irq(bu21013_data->chip->irq, bu21013_data);
> +	free_irq(bu21013_data->irq, bu21013_data);
>  }
>  
>  /**
> + * bu21013_cs_disable() - deconfigures the touch panel controller
> + * @bu21013_data: device structure pointer
> + *
> + * This function is used to deconfigure the chip selection
> + * for touch panel controller.
> + */
> +static void bu21013_cs_disable(struct bu21013_ts_data *bu21013_data)
> +{
> +	int error;
> +
> +	error = gpio_direction_output(bu21013_data->chip->cs_pin, 0);
> +	if (error < 0)
> +		dev_warn(&bu21013_data->client->dev,
> +			 "%s: gpio direction failed, error: %d\n",
> +			 __func__, error);
> +	else
> +		gpio_set_value(bu21013_data->chip->cs_pin, 0);
> +
> +	gpio_free(bu21013_data->chip->cs_pin);
> +}
> +
> +
> +/**
>   * bu21013_probe() - initializes the i2c-client touchscreen driver
>   * @client: i2c client structure pointer
>   * @id: i2c device id pointer
> @@ -430,7 +455,7 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
>   * driver and returns integer.
>   */
>  static int bu21013_probe(struct i2c_client *client,
> -					const struct i2c_device_id *id)
> +			 const struct i2c_device_id *id)
>  {
>  	struct bu21013_ts_data *bu21013_data;
>  	struct input_dev *in_dev;
> @@ -449,6 +474,11 @@ static int bu21013_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> +	if (!gpio_is_valid(pdata->touch_pin)) {
> +		dev_err(&client->dev, "invalid touch_pin supplied\n");
> +		return -EINVAL;
> +	}
> +
>  	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
>  	in_dev = input_allocate_device();
>  	if (!bu21013_data || !in_dev) {
> @@ -460,6 +490,7 @@ static int bu21013_probe(struct i2c_client *client,
>  	bu21013_data->in_dev = in_dev;
>  	bu21013_data->chip = pdata;
>  	bu21013_data->client = client;
> +	bu21013_data->irq = gpio_to_irq(pdata->touch_pin);
>  
>  	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
>  	if (IS_ERR(bu21013_data->regulator)) {
> @@ -478,12 +509,11 @@ static int bu21013_probe(struct i2c_client *client,
>  	init_waitqueue_head(&bu21013_data->wait);
>  
>  	/* configure the gpio pins */
> -	if (pdata->cs_en) {
> -		error = pdata->cs_en(pdata->cs_pin);
> -		if (error < 0) {
> -			dev_err(&client->dev, "chip init failed\n");
> -			goto err_disable_regulator;
> -		}
> +	error = gpio_request_one(pdata->cs_pin, GPIOF_DIR_OUT | GPIOF_INIT_HIGH,
> +				 "touchp_reset");
> +	if (error < 0) {
> +		dev_err(&client->dev, "Unable to request gpio reset_pin\n");
> +		goto err_disable_regulator;
>  	}
>  
>  	/* configure the touch panel controller */
> @@ -508,12 +538,13 @@ static int bu21013_probe(struct i2c_client *client,
>  						pdata->touch_y_max, 0, 0);
>  	input_set_drvdata(in_dev, bu21013_data);
>  
> -	error = request_threaded_irq(pdata->irq, NULL, bu21013_gpio_irq,
> +	error = request_threaded_irq(bu21013_data->irq, NULL, bu21013_gpio_irq,
>  				     IRQF_TRIGGER_FALLING | IRQF_SHARED |
>  					IRQF_ONESHOT,
>  				     DRIVER_TP, bu21013_data);
>  	if (error) {
> -		dev_err(&client->dev, "request irq %d failed\n", pdata->irq);
> +		dev_err(&client->dev, "request irq %d failed\n",
> +			bu21013_data->irq);
>  		goto err_cs_disable;
>  	}
>  
> @@ -531,7 +562,7 @@ static int bu21013_probe(struct i2c_client *client,
>  err_free_irq:
>  	bu21013_free_irq(bu21013_data);
>  err_cs_disable:
> -	pdata->cs_dis(pdata->cs_pin);
> +	bu21013_cs_disable(bu21013_data);
>  err_disable_regulator:
>  	regulator_disable(bu21013_data->regulator);
>  err_put_regulator:
> @@ -555,7 +586,7 @@ static int bu21013_remove(struct i2c_client *client)
>  
>  	bu21013_free_irq(bu21013_data);
>  
> -	bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
> +	bu21013_cs_disable(bu21013_data);
>  
>  	input_unregister_device(bu21013_data->in_dev);
>  
> @@ -584,9 +615,9 @@ static int bu21013_suspend(struct device *dev)
>  
>  	bu21013_data->touch_stopped = true;
>  	if (device_may_wakeup(&client->dev))
> -		enable_irq_wake(bu21013_data->chip->irq);
> +		enable_irq_wake(bu21013_data->irq);
>  	else
> -		disable_irq(bu21013_data->chip->irq);
> +		disable_irq(bu21013_data->irq);
>  
>  	regulator_disable(bu21013_data->regulator);
>  
> @@ -621,9 +652,9 @@ static int bu21013_resume(struct device *dev)
>  	bu21013_data->touch_stopped = false;
>  
>  	if (device_may_wakeup(&client->dev))
> -		disable_irq_wake(bu21013_data->chip->irq);
> +		disable_irq_wake(bu21013_data->irq);
>  	else
> -		enable_irq(bu21013_data->chip->irq);
> +		enable_irq(bu21013_data->irq);
>  
>  	return 0;
>  }
> diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
> index 05e0328..3ad1be5 100644
> --- a/include/linux/input/bu21013.h
> +++ b/include/linux/input/bu21013.h
> @@ -9,13 +9,11 @@
>  
>  /**
>   * struct bu21013_platform_device - Handle the platform data
> - * @cs_en:	pointer to the cs enable function
> - * @cs_dis:	pointer to the cs disable function
> - * @irq_read_val:    pointer to read the pen irq value function
>   * @touch_x_max: touch x max
>   * @touch_y_max: touch y max
>   * @cs_pin: chip select pin
>   * @irq: irq pin
> + * @touch_pin: touch gpio pin
>   * @ext_clk: external clock flag
>   * @x_flip: x flip flag
>   * @y_flip: y flip flag
> @@ -24,13 +22,10 @@
>   * This is used to handle the platform data
>   */
>  struct bu21013_platform_device {
> -	int (*cs_en)(int reset_pin);
> -	int (*cs_dis)(int reset_pin);
> -	int (*irq_read_val)(void);
>  	int touch_x_max;
>  	int touch_y_max;
>  	unsigned int cs_pin;
> -	unsigned int irq;
> +	unsigned int touch_pin;
>  	bool ext_clk;
>  	bool x_flip;
>  	bool y_flip;

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

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

* [PATCH 3/5 v2] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-24  7:50     ` Dmitry Torokhov
  2012-11-26  9:07       ` Lee Jones
@ 2012-11-26 10:50       ` Lee Jones
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-26 10:50 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

Author: Lee Jones <lee.jones@linaro.org>
Date:   Fri Sep 28 14:35:43 2012 +0100

    Input: bu21013_ts - Add support for Device Tree booting
    
    Now we can register the BU21013_ts touch screen when booting with
    Device Tree enabled. Here we parse all the necessary components
    previously expected to be passed from platform data.
    
    Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Cc: linux-input@vger.kernel.org
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>

diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 08ffb19..7d240f0 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -15,6 +15,8 @@
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #define PEN_DOWN_INTR	0
 #define MAX_FINGERS	2
@@ -478,13 +480,30 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
  * This function used to initializes the i2c-client touchscreen
  * driver and returns integer.
  */
+static void __devinit bu21013_of_probe(struct device_node *np,
+				struct bu21013_platform_device *pdata)
+{
+	pdata->y_flip = pdata->x_flip = false;
+
+	pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
+	pdata->y_flip = of_property_read_bool(np, "rohm,flip-y");
+
+	of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
+	of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
+
+	pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
+	pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
+
+	pdata->ext_clk = false;
+}
+
 static int __devinit bu21013_probe(struct i2c_client *client,
 					const struct i2c_device_id *id)
 {
 	struct bu21013_ts_data *bu21013_data;
 	struct input_dev *in_dev;
-	const struct bu21013_platform_device *pdata =
-					client->dev.platform_data;
+	struct device_node *np = client->dev.of_node;
+	struct bu21013_platform_device *pdata = client->dev.platform_data;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter,
@@ -494,8 +513,17 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	}
 
 	if (!pdata) {
-		dev_err(&client->dev, "platform data not defined\n");
-		return -EINVAL;
+		if (np) {
+			pdata = devm_kzalloc(&client->dev, sizeof(*pdata),
+					GFP_KERNEL);
+			if (!pdata)
+				return -ENOMEM;
+
+			bu21013_of_probe(np, pdata);
+		} else {
+			dev_err(&client->dev, "no device tree or platform data\n");
+			return -EINVAL;
+		}
 	}
 
 	pdata->irq = gpio_to_irq(pdata->touch_pin);

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

* [PATCH 2/5 v2] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-24  7:43     ` Dmitry Torokhov
  2012-11-26 10:43       ` Lee Jones
@ 2012-11-26 12:01       ` Lee Jones
  2012-11-26 16:46         ` Dmitry Torokhov
  1 sibling, 1 reply; 32+ messages in thread
From: Lee Jones @ 2012-11-26 12:01 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

Author: Lee Jones <lee.jones@linaro.org>
Date:   Fri Sep 28 10:29:07 2012 +0100

    Input: bu21013_ts - Move GPIO init and exit functions into the driver
    
    These GPIO init and exit functions have no place in platform data.
    Instead they should be part of the driver. This patch moves them to
    their rightful place, which subsequently elevates platform data of
    yet more cruft.
    
    Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Cc: linux-input@vger.kernel.org
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>

diff --git a/arch/arm/mach-ux500/board-mop500-stuib.c b/arch/arm/mach-ux500/board-mop500-stuib.c
index 564f57d..eb19a7e 100644
--- a/arch/arm/mach-ux500/board-mop500-stuib.c
+++ b/arch/arm/mach-ux500/board-mop500-stuib.c
@@ -77,9 +77,6 @@ static struct i2c_board_info __initdata mop500_i2c0_devices_stuib[] = {
  * BU21013 ROHM touchscreen interface on the STUIBs
  */
 
-/* tracks number of bu21013 devices being enabled */
-static int bu21013_devices;
-
 #define TOUCH_GPIO_PIN  84
 
 #define TOUCH_XMAX	384
@@ -88,73 +85,8 @@ static int bu21013_devices;
 #define PRCMU_CLOCK_OCR		0x1CC
 #define TSC_EXT_CLOCK_9_6MHZ	0x840000
 
-/**
- * bu21013_gpio_board_init : configures the touch panel.
- * @reset_pin: reset pin number
- * This function can be used to configures
- * the voltage and reset the touch panel controller.
- */
-static int bu21013_gpio_board_init(int reset_pin)
-{
-	int retval = 0;
-
-	bu21013_devices++;
-	if (bu21013_devices == 1) {
-		retval = gpio_request(reset_pin, "touchp_reset");
-		if (retval) {
-			printk(KERN_ERR "Unable to request gpio reset_pin");
-			return retval;
-		}
-		retval = gpio_direction_output(reset_pin, 1);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-	}
-
-	return retval;
-}
-
-/**
- * bu21013_gpio_board_exit : deconfigures the touch panel controller
- * @reset_pin: reset pin number
- * This function can be used to deconfigures the chip selection
- * for touch panel controller.
- */
-static int bu21013_gpio_board_exit(int reset_pin)
-{
-	int retval = 0;
-
-	if (bu21013_devices == 1) {
-		retval = gpio_direction_output(reset_pin, 0);
-		if (retval < 0) {
-			printk(KERN_ERR "%s: gpio direction failed\n",
-					__func__);
-			return retval;
-		}
-		gpio_set_value(reset_pin, 0);
-	}
-	bu21013_devices--;
-
-	return retval;
-}
-
-/**
- * bu21013_read_pin_val : get the interrupt pin value
- * This function can be used to get the interrupt pin value for touch panel
- * controller.
- */
-static int bu21013_read_pin_val(void)
-{
-	return gpio_get_value(TOUCH_GPIO_PIN);
-}
-
 static struct bu21013_platform_device tsc_plat_device = {
-	.cs_en = bu21013_gpio_board_init,
-	.cs_dis = bu21013_gpio_board_exit,
-	.irq_read_val = bu21013_read_pin_val,
-	.irq = NOMADIK_GPIO_TO_IRQ(TOUCH_GPIO_PIN),
+	.touch_pin = TOUCH_GPIO_PIN,
 	.touch_x_max = TOUCH_XMAX,
 	.touch_y_max = TOUCH_YMAX,
 	.ext_clk = false,
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 2fae682..16f29d6 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -14,6 +14,7 @@
 #include <linux/slab.h>
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
+#include <linux/gpio.h>
 
 #define PEN_DOWN_INTR	0
 #define MAX_FINGERS	2
@@ -262,7 +263,7 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 			return IRQ_NONE;
 		}
 
-		data->intr_pin = data->chip->irq_read_val();
+		data->intr_pin = gpio_get_value(data->chip->touch_pin);
 		if (data->intr_pin == PEN_DOWN_INTR)
 			wait_event_timeout(data->wait, data->touch_stopped,
 					   msecs_to_jiffies(2));
@@ -272,6 +273,49 @@ static irqreturn_t bu21013_gpio_irq(int irq, void *device_data)
 }
 
 /**
+ * bu21013_gpio_board_init() - configures the touch panel
+ * @reset_pin: reset pin number
+ *
+ * This function is used to configure the voltage and
+ * reset the touch panel controller.
+ */
+static int bu21013_gpio_board_init(int reset_pin)
+{
+	int retval = 0;
+
+	retval = gpio_request_one(reset_pin, GPIOF_INIT_HIGH, "touchp_reset");
+	if (retval) {
+		printk(KERN_ERR "Unable to request gpio reset_pin");
+		return retval;
+	}
+
+	return retval;
+}
+
+/**
+ * bu21013_gpio_board_exit() - deconfigures the touch panel controller
+ * @reset_pin: reset pin number
+ *
+ * This function is used to deconfigure the chip selection
+ * for touch panel controller.
+ */
+static int bu21013_gpio_board_exit(int reset_pin)
+{
+	int retval = 0;
+
+	retval = gpio_direction_output(reset_pin, 0);
+	if (retval < 0) {
+		printk(KERN_ERR "%s: gpio direction failed\n",
+		       __func__);
+		return retval;
+	}
+	gpio_set_value(reset_pin, 0);
+	gpio_free(reset_pin);
+
+	return retval;
+}
+
+/**
  * bu21013_init_chip() - power on sequence for the bu21013 controller
  * @data: device structure pointer
  *
@@ -449,6 +493,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 		return -EINVAL;
 	}
 
+	pdata->irq = gpio_to_irq(pdata->touch_pin);
+
 	bu21013_data = kzalloc(sizeof(struct bu21013_ts_data), GFP_KERNEL);
 	in_dev = input_allocate_device();
 	if (!bu21013_data || !in_dev) {
@@ -478,12 +524,10 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	init_waitqueue_head(&bu21013_data->wait);
 
 	/* configure the gpio pins */
-	if (pdata->cs_en) {
-		error = pdata->cs_en(pdata->cs_pin);
-		if (error < 0) {
-			dev_err(&client->dev, "chip init failed\n");
-			goto err_disable_regulator;
-		}
+	error = bu21013_gpio_board_init(pdata->cs_pin);
+	if (error < 0) {
+		dev_err(&client->dev, "chip init failed\n");
+		goto err_disable_regulator;
 	}
 
 	/* configure the touch panel controller */
@@ -531,7 +575,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 err_free_irq:
 	bu21013_free_irq(bu21013_data);
 err_cs_disable:
-	pdata->cs_dis(pdata->cs_pin);
+	bu21013_gpio_board_exit(pdata->cs_pin);
 err_disable_regulator:
 	regulator_disable(bu21013_data->regulator);
 err_put_regulator:
@@ -555,7 +599,7 @@ static int __devexit bu21013_remove(struct i2c_client *client)
 
 	bu21013_free_irq(bu21013_data);
 
-	bu21013_data->chip->cs_dis(bu21013_data->chip->cs_pin);
+	bu21013_gpio_board_exit(bu21013_data->chip->cs_pin);
 
 	input_unregister_device(bu21013_data->in_dev);
 
diff --git a/include/linux/input/bu21013.h b/include/linux/input/bu21013.h
index 05e0328..01a2975 100644
--- a/include/linux/input/bu21013.h
+++ b/include/linux/input/bu21013.h
@@ -9,13 +9,11 @@
 
 /**
  * struct bu21013_platform_device - Handle the platform data
- * @cs_en:	pointer to the cs enable function
- * @cs_dis:	pointer to the cs disable function
- * @irq_read_val:    pointer to read the pen irq value function
  * @touch_x_max: touch x max
  * @touch_y_max: touch y max
  * @cs_pin: chip select pin
  * @irq: irq pin
+ * @touch_pin: touch gpio pin
  * @ext_clk: external clock flag
  * @x_flip: x flip flag
  * @y_flip: y flip flag
@@ -24,13 +22,11 @@
  * This is used to handle the platform data
  */
 struct bu21013_platform_device {
-	int (*cs_en)(int reset_pin);
-	int (*cs_dis)(int reset_pin);
-	int (*irq_read_val)(void);
 	int touch_x_max;
 	int touch_y_max;
 	unsigned int cs_pin;
 	unsigned int irq;
+	unsigned int touch_pin;
 	bool ext_clk;
 	bool x_flip;
 	bool y_flip;

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

* Re: [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists
  2012-11-14 13:47 ` [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists Lee Jones
  2012-11-23 15:50   ` Lee Jones
@ 2012-11-26 12:16   ` Lee Jones
  2012-11-26 16:47     ` Dmitry Torokhov
  1 sibling, 1 reply; 32+ messages in thread
From: Lee Jones @ 2012-11-26 12:16 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

On Wed, 14 Nov 2012, Lee Jones wrote:

> Currently the BU21013 Touch Screen driver requests a regulator by the
> name of 'V-TOUCH', which doesn't exist anywhere in the kernel. The
> correct name, as referenced in platform regulator code is 'avdd'. Here,
> when we request a regulator, we use the correct name instead.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/input/touchscreen/bu21013_ts.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> index 5c487d2..2fae682 100644
> --- a/drivers/input/touchscreen/bu21013_ts.c
> +++ b/drivers/input/touchscreen/bu21013_ts.c
> @@ -461,7 +461,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  	bu21013_data->chip = pdata;
>  	bu21013_data->client = client;
>  
> -	bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
> +	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
>  	if (IS_ERR(bu21013_data->regulator)) {
>  		dev_err(&client->dev, "regulator_get failed\n");
>  		error = PTR_ERR(bu21013_data->regulator);
> -- 
> 1.7.9.5

Did you see this one also Dmitry?

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

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

* Re: [PATCH 2/5 v2] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-26 12:01       ` [PATCH 2/5 v2] " Lee Jones
@ 2012-11-26 16:46         ` Dmitry Torokhov
  2012-11-27  9:07           ` Lee Jones
  0 siblings, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-26 16:46 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

Hi Lee,

On Mon, Nov 26, 2012 at 12:01:43PM +0000, Lee Jones wrote:
>  /**
> + * bu21013_gpio_board_init() - configures the touch panel
> + * @reset_pin: reset pin number
> + *
> + * This function is used to configure the voltage and
> + * reset the touch panel controller.
> + */
> +static int bu21013_gpio_board_init(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	retval = gpio_request_one(reset_pin, GPIOF_INIT_HIGH, "touchp_reset");

Also need to specify dircetion (even though it defaults to output).

> +	if (retval) {
> +		printk(KERN_ERR "Unable to request gpio reset_pin");
> +		return retval;
> +	}
> +
> +	return retval;
> +}
> +
> +/**
> + * bu21013_gpio_board_exit() - deconfigures the touch panel controller
> + * @reset_pin: reset pin number
> + *
> + * This function is used to deconfigure the chip selection
> + * for touch panel controller.
> + */
> +static int bu21013_gpio_board_exit(int reset_pin)
> +{
> +	int retval = 0;
> +
> +	retval = gpio_direction_output(reset_pin, 0);
> +	if (retval < 0) {
> +		printk(KERN_ERR "%s: gpio direction failed\n",
> +		       __func__);
> +		return retval;

You should not return here, as gpio has to be freed even if you unable
to toggle it.

> +	}
> +	gpio_set_value(reset_pin, 0);
> +	gpio_free(reset_pin);
> +
> +	return retval;
> +}
> +
> +/**
>   * bu21013_init_chip() - power on sequence for the bu21013 controller
>   * @data: device structure pointer
>   *
> @@ -449,6 +493,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
>  		return -EINVAL;
>  	}
>  
> +	pdata->irq = gpio_to_irq(pdata->touch_pin);
> +

No, you still can not do it since pdata is a const pointer. Does not
your compiler throw a warning here?

I already sent you a version of the patch that does not have these
issues, is there a particular reason why you needed to roll your own
instead of simply trying out the one I sent?

Thanks.

-- 
Dmitry

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

* Re: [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists
  2012-11-26 12:16   ` Lee Jones
@ 2012-11-26 16:47     ` Dmitry Torokhov
  2012-11-27  9:05       ` Lee Jones
  0 siblings, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2012-11-26 16:47 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input

On Mon, Nov 26, 2012 at 12:16:18PM +0000, Lee Jones wrote:
> On Wed, 14 Nov 2012, Lee Jones wrote:
> 
> > Currently the BU21013 Touch Screen driver requests a regulator by the
> > name of 'V-TOUCH', which doesn't exist anywhere in the kernel. The
> > correct name, as referenced in platform regulator code is 'avdd'. Here,
> > when we request a regulator, we use the correct name instead.
> > 
> > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > Cc: linux-input@vger.kernel.org
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  drivers/input/touchscreen/bu21013_ts.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> > index 5c487d2..2fae682 100644
> > --- a/drivers/input/touchscreen/bu21013_ts.c
> > +++ b/drivers/input/touchscreen/bu21013_ts.c
> > @@ -461,7 +461,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
> >  	bu21013_data->chip = pdata;
> >  	bu21013_data->client = client;
> >  
> > -	bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
> > +	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
> >  	if (IS_ERR(bu21013_data->regulator)) {
> >  		dev_err(&client->dev, "regulator_get failed\n");
> >  		error = PTR_ERR(bu21013_data->regulator);
> > -- 
> > 1.7.9.5
> 
> Did you see this one also Dmitry?

Yes, I have it, I am waiting for the other 2 patches in series to
settle.

-- 
Dmitry

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

* Re: [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists
  2012-11-26 16:47     ` Dmitry Torokhov
@ 2012-11-27  9:05       ` Lee Jones
  0 siblings, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-27  9:05 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

On Mon, 26 Nov 2012, Dmitry Torokhov wrote:

> On Mon, Nov 26, 2012 at 12:16:18PM +0000, Lee Jones wrote:
> > On Wed, 14 Nov 2012, Lee Jones wrote:
> > 
> > > Currently the BU21013 Touch Screen driver requests a regulator by the
> > > name of 'V-TOUCH', which doesn't exist anywhere in the kernel. The
> > > correct name, as referenced in platform regulator code is 'avdd'. Here,
> > > when we request a regulator, we use the correct name instead.
> > > 
> > > Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > Cc: linux-input@vger.kernel.org
> > > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > > Acked-by: Linus Walleij <linus.walleij@linaro.org>
> > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > ---
> > >  drivers/input/touchscreen/bu21013_ts.c |    2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
> > > index 5c487d2..2fae682 100644
> > > --- a/drivers/input/touchscreen/bu21013_ts.c
> > > +++ b/drivers/input/touchscreen/bu21013_ts.c
> > > @@ -461,7 +461,7 @@ static int __devinit bu21013_probe(struct i2c_client *client,
> > >  	bu21013_data->chip = pdata;
> > >  	bu21013_data->client = client;
> > >  
> > > -	bu21013_data->regulator = regulator_get(&client->dev, "V-TOUCH");
> > > +	bu21013_data->regulator = regulator_get(&client->dev, "avdd");
> > >  	if (IS_ERR(bu21013_data->regulator)) {
> > >  		dev_err(&client->dev, "regulator_get failed\n");
> > >  		error = PTR_ERR(bu21013_data->regulator);
> > > -- 
> > > 1.7.9.5
> > 
> > Did you see this one also Dmitry?
> 
> Yes, I have it, I am waiting for the other 2 patches in series to
> settle.

This patch is unrelated to the others and fixes a bug. Would you
be kind enough to take it in right away please?

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

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

* Re: [PATCH 2/5 v2] Input: bu21013_ts - Move GPIO init and exit functions into the driver
  2012-11-26 16:46         ` Dmitry Torokhov
@ 2012-11-27  9:07           ` Lee Jones
  0 siblings, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-27  9:07 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input

On Mon, 26 Nov 2012, Dmitry Torokhov wrote:

> Hi Lee,
> 
> On Mon, Nov 26, 2012 at 12:01:43PM +0000, Lee Jones wrote:
> >  /**
> > + * bu21013_gpio_board_init() - configures the touch panel
> > + * @reset_pin: reset pin number
> > + *
> > + * This function is used to configure the voltage and
> > + * reset the touch panel controller.
> > + */
> > +static int bu21013_gpio_board_init(int reset_pin)
> > +{
> > +	int retval = 0;
> > +
> > +	retval = gpio_request_one(reset_pin, GPIOF_INIT_HIGH, "touchp_reset");
> 
> Also need to specify dircetion (even though it defaults to output).

You do? Okay, I'll do that.

> > +	if (retval) {
> > +		printk(KERN_ERR "Unable to request gpio reset_pin");
> > +		return retval;
> > +	}
> > +
> > +	return retval;
> > +}
> > +
> > +/**
> > + * bu21013_gpio_board_exit() - deconfigures the touch panel controller
> > + * @reset_pin: reset pin number
> > + *
> > + * This function is used to deconfigure the chip selection
> > + * for touch panel controller.
> > + */
> > +static int bu21013_gpio_board_exit(int reset_pin)
> > +{
> > +	int retval = 0;
> > +
> > +	retval = gpio_direction_output(reset_pin, 0);
> > +	if (retval < 0) {
> > +		printk(KERN_ERR "%s: gpio direction failed\n",
> > +		       __func__);
> > +		return retval;
> 
> You should not return here, as gpio has to be freed even if you unable
> to toggle it.

You're right.

> > +	}
> > +	gpio_set_value(reset_pin, 0);
> > +	gpio_free(reset_pin);
> > +
> > +	return retval;
> > +}
> > +
> > +/**
> >   * bu21013_init_chip() - power on sequence for the bu21013 controller
> >   * @data: device structure pointer
> >   *
> > @@ -449,6 +493,8 @@ static int __devinit bu21013_probe(struct i2c_client *client,
> >  		return -EINVAL;
> >  	}
> >  
> > +	pdata->irq = gpio_to_irq(pdata->touch_pin);
> > +
> 
> No, you still can not do it since pdata is a const pointer. Does not
> your compiler throw a warning here?
> 
> I already sent you a version of the patch that does not have these
> issues, is there a particular reason why you needed to roll your own
> instead of simply trying out the one I sent?

I didn't see the other patch, sorry.

I'll check my mail and apply it.

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

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

* Re: [PATCH 3/5 v3] Input: bu21013_ts - Add support for Device Tree booting
  2012-11-14 13:47 ` [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting Lee Jones
  2012-11-23 15:52   ` Lee Jones
@ 2012-11-27 11:38   ` Lee Jones
  1 sibling, 0 replies; 32+ messages in thread
From: Lee Jones @ 2012-11-27 11:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

Author: Lee Jones <lee.jones@linaro.org>
Date:   Fri Sep 28 14:35:43 2012 +0100

    Input: bu21013_ts - Add support for Device Tree booting
    
    Now we can register the BU21013_ts touch screen when booting with
    Device Tree enabled. Here we parse all the necessary components
    previously expected to be passed from platform data.
    
    Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Cc: linux-input@vger.kernel.org
    Acked-by: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Lee Jones <lee.jones@linaro.org>

diff --git a/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt
new file mode 100644
index 0000000..ca5a2c8
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/bu21013.txt
@@ -0,0 +1,28 @@
+* Rohm BU21013 Touch Screen
+
+Required properties:
+ - compatible              : "rohm,bu21013_tp"
+ - reg                     :  I2C device address
+
+Optional properties:
+ - touch-gpio              : GPIO pin registering a touch event
+ - <supply_name>-supply    : Phandle to a regulator supply
+ - rohm,touch-max-x        : Maximum outward permitted limit in the X axis
+ - rohm,touch-max-y        : Maximum outward permitted limit in the Y axis
+ - rohm,flip-x             : Flip touch coordinates on the X axis
+ - rohm,flip-y             : Flip touch coordinates on the Y axis
+
+Example:
+
+	i2c@80110000 {
+		bu21013_tp@0x5c {
+			compatible = "rohm,bu21013_tp";
+			reg = <0x5c>;
+			touch-gpio = <&gpio2 20 0x4>;
+			avdd-supply = <&ab8500_ldo_aux1_reg>;
+
+			rohm,touch-max-x = <384>;
+			rohm,touch-max-y = <704>;
+			rohm,flip-y;
+		};
+	};
diff --git a/drivers/input/touchscreen/bu21013_ts.c b/drivers/input/touchscreen/bu21013_ts.c
index 16f29d6..07335ac 100644
--- a/drivers/input/touchscreen/bu21013_ts.c
+++ b/drivers/input/touchscreen/bu21013_ts.c
@@ -15,6 +15,8 @@
 #include <linux/regulator/consumer.h>
 #include <linux/module.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #define PEN_DOWN_INTR	0
 #define MAX_FINGERS	2
@@ -473,13 +475,30 @@ static void bu21013_free_irq(struct bu21013_ts_data *bu21013_data)
  * This function used to initializes the i2c-client touchscreen
  * driver and returns integer.
  */
+static void __devinit bu21013_of_probe(struct device_node *np,
+				struct bu21013_platform_device *pdata)
+{
+	pdata->y_flip = pdata->x_flip = false;
+
+	pdata->x_flip = of_property_read_bool(np, "rohm,flip-x");
+	pdata->y_flip = of_property_read_bool(np, "rohm,flip-y");
+
+	of_property_read_u32(np, "rohm,touch-max-x", &pdata->touch_x_max);
+	of_property_read_u32(np, "rohm,touch-max-y", &pdata->touch_y_max);
+
+	pdata->touch_pin = of_get_named_gpio(np, "touch-gpio", 0);
+	pdata->cs_pin = of_get_named_gpio(np, "reset-gpio", 0);
+
+	pdata->ext_clk = false;
+}
+
 static int __devinit bu21013_probe(struct i2c_client *client,
 					const struct i2c_device_id *id)
 {
 	struct bu21013_ts_data *bu21013_data;
 	struct input_dev *in_dev;
-	const struct bu21013_platform_device *pdata =
-					client->dev.platform_data;
+	struct device_node *np = client->dev.of_node;
+	struct bu21013_platform_device *pdata = client->dev.platform_data;
 	int error;
 
 	if (!i2c_check_functionality(client->adapter,
@@ -489,8 +508,17 @@ static int __devinit bu21013_probe(struct i2c_client *client,
 	}
 
 	if (!pdata) {
-		dev_err(&client->dev, "platform data not defined\n");
-		return -EINVAL;
+		if (np) {
+			pdata = devm_kzalloc(&client->dev, sizeof(*pdata),
+					GFP_KERNEL);
+			if (!pdata)
+				return -ENOMEM;
+
+			bu21013_of_probe(np, pdata);
+		} else {
+			dev_err(&client->dev, "no device tree or platform data\n");
+			return -EINVAL;
+		}
 	}
 
 	pdata->irq = gpio_to_irq(pdata->touch_pin);

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

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

* Re: [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree
  2012-11-14 13:47 ` [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree Lee Jones
  2012-11-23 15:53   ` Lee Jones
@ 2013-01-08  8:38   ` Lee Jones
  2013-01-08  9:26     ` Dmitry Torokhov
  1 sibling, 1 reply; 32+ messages in thread
From: Lee Jones @ 2013-01-08  8:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input, linus.walleij, arnd

Dmitry,

> This patch allows the STMPE driver to be successfully probed and
> initialised when Device Tree support is enabled. Besides the usual
> platform data changes, we also separate the process of filling in
> the 'in use' pin bitmap, as we have to extract the information from
> Device Tree in the DT boot case.
> 
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Acked-by: Linus Walleij <linus.walleij@linaro.org>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/input/keyboard/stmpe-keypad.c |   67 ++++++++++++++++++++++++++++-----
>  drivers/mfd/stmpe.c                   |    1 +
>  2 files changed, 59 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
> index 470a877..4ae01d5 100644
> --- a/drivers/input/keyboard/stmpe-keypad.c
> +++ b/drivers/input/keyboard/stmpe-keypad.c
> @@ -257,19 +257,73 @@ static int __devinit stmpe_keypad_chip_init(struct stmpe_keypad *keypad)
>  			      (plat->debounce_ms << 1));
>  }
>  
> +static int stmpe_keypad_fill_used_pins(struct platform_device *pdev,
> +				struct stmpe_keypad *keypad,
> +				struct stmpe_keypad_platform_data *plat)
> +{
> +	struct device_node *np = pdev->dev.of_node;
> +	unsigned int proplen;
> +	const __be32 *prop;
> +	int i;
> +
> +	if (np) {
> +		prop = of_get_property(np, "linux,keymap", &proplen);
> +		if (!prop) {
> +			dev_err(&pdev->dev,
> +				"linux,keymap property not defined\n");
> +			return -EINVAL;
> +		}
> +
> +		for (i = 0; i < proplen / sizeof(u32); i++) {
> +			unsigned int key = be32_to_cpup(prop + i);
> +
> +			keypad->cols |= 1 << KEY_COL(key);
> +			keypad->rows |= 1 << KEY_ROW(key);
> +		}
> +	} else {
> +		for (i = 0; i < plat->keymap_data->keymap_size; i++) {
> +			unsigned int key = plat->keymap_data->keymap[i];
> +
> +			keypad->cols |= 1 << KEY_COL(key);
> +			keypad->rows |= 1 << KEY_ROW(key);
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +static void __devinit stmpe_keypad_of_probe(struct device_node *np,
> +				struct stmpe_keypad_platform_data *plat)
> +{
> +	of_property_read_u32(np, "debounce-interval", &plat->debounce_ms);
> +	of_property_read_u32(np, "st,scan-count", &plat->scan_count);
> +
> +	if (of_get_property(np, "st,no-autorepeat", NULL))
> +		plat->no_autorepeat = true;
> +}
> +
>  static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  {
>  	struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
>  	struct stmpe_keypad_platform_data *plat;
> +	struct device_node *np = pdev->dev.of_node;
>  	struct stmpe_keypad *keypad;
>  	struct input_dev *input;
>  	int ret;
>  	int irq;
> -	int i;
>  
>  	plat = stmpe->pdata->keypad;
> -	if (!plat)
> -		return -ENODEV;
> +	if (!plat) {
> +		if (np) {
> +			plat = devm_kzalloc(&pdev->dev,
> +					sizeof(*plat), GFP_KERNEL);
> +			if (!plat)
> +				return -ENOMEM;
> +
> +			stmpe_keypad_of_probe(np, plat);
> +		} else
> +			return -ENODEV;
> +	}
>  
>  	irq = platform_get_irq(pdev, 0);
>  	if (irq < 0)
> @@ -300,12 +354,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>  	if (!plat->no_autorepeat)
>  		__set_bit(EV_REP, input->evbit);
>  
> -	for (i = 0; i < plat->keymap_data->keymap_size; i++) {
> -		unsigned int key = plat->keymap_data->keymap[i];
> -
> -		keypad->cols |= 1 << KEY_COL(key);
> -		keypad->rows |= 1 << KEY_ROW(key);
> -	}
> +	stmpe_keypad_fill_used_pins(pdev, keypad, plat);
>  
>  	keypad->stmpe = stmpe;
>  	keypad->plat = plat;
> diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
> index ba157d4..b03cc64 100644
> --- a/drivers/mfd/stmpe.c
> +++ b/drivers/mfd/stmpe.c
> @@ -321,6 +321,7 @@ static struct resource stmpe_keypad_resources[] = {
>  
>  static struct mfd_cell stmpe_keypad_cell = {
>  	.name		= "stmpe-keypad",
> +	.of_compatible  = "st,stmpe-keypad",
>  	.resources	= stmpe_keypad_resources,
>  	.num_resources	= ARRAY_SIZE(stmpe_keypad_resources),
>  };
> -- 
> 1.7.9.5
> 

I'm less than pleased that you _stole_ authorship of this patch!

Especially, as I've been asking you to review it for some time.

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

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

* Re: [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree
  2013-01-08  8:38   ` Lee Jones
@ 2013-01-08  9:26     ` Dmitry Torokhov
  2013-01-08  9:30       ` Dmitry Torokhov
  0 siblings, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2013-01-08  9:26 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input, linus.walleij, arnd

Hi Lee,

On Tue, Jan 08, 2013 at 08:38:03AM +0000, Lee Jones wrote:
> 
> I'm less than pleased that you _stole_ authorship of this patch!
> 
> Especially, as I've been asking you to review it for some time.

My sincere apologies, it was never my intention to claim anyones work as
my own.

It appears that "stg squash" command (I use stacked git to manage my WIP
queue) produces result with authorship changed to the committer and if
you check the thread you will see that I explicitly mentioned that I
folded the device tree binding documentation (that was also authored by
you) into this patch.

Now that I am looking it appears that sysrq keyreset patch by Mathieu
Poirier was also committed as authored by me, and on that patch I aslo
used "stg squash".

OK, I'll now be aware of this behavior and I will rewind my 'next'
branch and correct the authorship on the commits.

Again, I apologize.

-- 
Dmitry

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

* Re: [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree
  2013-01-08  9:26     ` Dmitry Torokhov
@ 2013-01-08  9:30       ` Dmitry Torokhov
  2013-01-08  9:53         ` Lee Jones
  0 siblings, 1 reply; 32+ messages in thread
From: Dmitry Torokhov @ 2013-01-08  9:30 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel, linux-input, linus.walleij, arnd

On Tue, Jan 08, 2013 at 01:26:54AM -0800, Dmitry Torokhov wrote:
> Hi Lee,
> 
> On Tue, Jan 08, 2013 at 08:38:03AM +0000, Lee Jones wrote:
> > 
> > I'm less than pleased that you _stole_ authorship of this patch!
> > 
> > Especially, as I've been asking you to review it for some time.
> 
> My sincere apologies, it was never my intention to claim anyones work as
> my own.
> 
> It appears that "stg squash" command (I use stacked git to manage my WIP
> queue) produces result with authorship changed to the committer and if
> you check the thread you will see that I explicitly mentioned that I
> folded the device tree binding documentation (that was also authored by
> you) into this patch.
> 
> Now that I am looking it appears that sysrq keyreset patch by Mathieu
> Poirier was also committed as authored by me, and on that patch I aslo
> used "stg squash".
> 
> OK, I'll now be aware of this behavior and I will rewind my 'next'
> branch and correct the authorship on the commits.

*sigh* It looks like the stmpe patch is already in mainline, so I will
not be able to correct it.

I am very sorry.

-- 
Dmitry

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

* Re: [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree
  2013-01-08  9:30       ` Dmitry Torokhov
@ 2013-01-08  9:53         ` Lee Jones
  0 siblings, 0 replies; 32+ messages in thread
From: Lee Jones @ 2013-01-08  9:53 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-kernel, linux-input, linus.walleij, arnd

On Tue, 08 Jan 2013, Dmitry Torokhov wrote:

> On Tue, Jan 08, 2013 at 01:26:54AM -0800, Dmitry Torokhov wrote:
> > Hi Lee,
> > 
> > On Tue, Jan 08, 2013 at 08:38:03AM +0000, Lee Jones wrote:
> > > 
> > > I'm less than pleased that you _stole_ authorship of this patch!
> > > 
> > > Especially, as I've been asking you to review it for some time.
> > 
> > My sincere apologies, it was never my intention to claim anyones work as
> > my own.
> > 
> > It appears that "stg squash" command (I use stacked git to manage my WIP
> > queue) produces result with authorship changed to the committer and if
> > you check the thread you will see that I explicitly mentioned that I
> > folded the device tree binding documentation (that was also authored by
> > you) into this patch.
> > 
> > Now that I am looking it appears that sysrq keyreset patch by Mathieu
> > Poirier was also committed as authored by me, and on that patch I aslo
> > used "stg squash".
> > 
> > OK, I'll now be aware of this behavior and I will rewind my 'next'
> > branch and correct the authorship on the commits.
> 
> *sigh* It looks like the stmpe patch is already in mainline, so I will
> not be able to correct it.
> 
> I am very sorry.

Okay, as long as it was a genuine mistake, I will bear no grudges.

Apology graciously accepted. :)

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

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

end of thread, other threads:[~2013-01-08  9:53 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-14 13:47 [PATCH 0/5] Input related patches Lee Jones
2012-11-14 13:47 ` [PATCH 1/5] Input: bu21013_ts - Request a regulator that actually exists Lee Jones
2012-11-23 15:50   ` Lee Jones
2012-11-26 12:16   ` Lee Jones
2012-11-26 16:47     ` Dmitry Torokhov
2012-11-27  9:05       ` Lee Jones
2012-11-14 13:47 ` [PATCH 2/5] Input: bu21013_ts - Move GPIO init and exit functions into the driver Lee Jones
2012-11-21 18:42   ` Dmitry Torokhov
2012-11-22 11:28     ` Lee Jones
2012-11-22 12:10   ` Lee Jones
2012-11-23 15:52     ` Lee Jones
2012-11-24  7:43     ` Dmitry Torokhov
2012-11-26 10:43       ` Lee Jones
2012-11-26 12:01       ` [PATCH 2/5 v2] " Lee Jones
2012-11-26 16:46         ` Dmitry Torokhov
2012-11-27  9:07           ` Lee Jones
2012-11-14 13:47 ` [PATCH 3/5] Input: bu21013_ts - Add support for Device Tree booting Lee Jones
2012-11-23 15:52   ` Lee Jones
2012-11-24  7:50     ` Dmitry Torokhov
2012-11-26  9:07       ` Lee Jones
2012-11-26  9:31         ` Dmitry Torokhov
2012-11-26 10:50       ` [PATCH 3/5 v2] " Lee Jones
2012-11-27 11:38   ` [PATCH 3/5 v3] " Lee Jones
2012-11-14 13:47 ` [PATCH 4/5] Input: Enable STMPE keypad driver for Device Tree Lee Jones
2012-11-23 15:53   ` Lee Jones
2013-01-08  8:38   ` Lee Jones
2013-01-08  9:26     ` Dmitry Torokhov
2013-01-08  9:30       ` Dmitry Torokhov
2013-01-08  9:53         ` Lee Jones
2012-11-14 13:47 ` [PATCH 5/5] Documentation: Describe bindings for STMPE Keypad driver Lee Jones
2012-11-23 15:54   ` Lee Jones
2012-11-24  8:23   ` Dmitry Torokhov

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