Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH 4/5] input: tc3589x-keypad: support probing from device tree
From: Linus Walleij @ 2013-10-15 21:21 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input, devicetree
  Cc: linux-kernel, Samuel Ortiz, Lee Jones, Linus Walleij

Implement device tree probing for the tc3589x keypad driver.
This is modeled on the STMPE keypad driver and tested on the
Ux500 TVK1281618 UIB.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/input/keyboard/tc3589x-keypad.c | 63 +++++++++++++++++++++++++++++++--
 1 file changed, 61 insertions(+), 2 deletions(-)

diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
index 208de7c..f6ec0d7 100644
--- a/drivers/input/keyboard/tc3589x-keypad.c
+++ b/drivers/input/keyboard/tc3589x-keypad.c
@@ -297,6 +297,62 @@ static void tc3589x_keypad_close(struct input_dev *input)
 	tc3589x_keypad_disable(keypad);
 }
 
+#ifdef CONFIG_OF
+static const struct tc3589x_keypad_platform_data *
+tc3589x_keypad_of_probe(struct device *dev)
+{
+	struct device_node *np = dev->of_node;
+	struct tc3589x_keypad_platform_data *plat;
+	u32 debounce_ms;
+	int proplen;
+
+	if (!np)
+		return ERR_PTR(-ENODEV);
+
+	plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
+	if (!plat)
+		return ERR_PTR(-ENOMEM);
+
+	of_property_read_u8(np, "keypad,num-columns", &plat->kcol);
+	of_property_read_u8(np, "keypad,num-rows", &plat->krow);
+	if (!plat->krow || !plat->kcol ||
+	     plat->krow > TC_KPD_ROWS || plat->kcol > TC_KPD_COLUMNS) {
+		dev_err(dev,
+			"keypad columns/rows not properly specified (%ux%u)\n",
+			plat->kcol, plat->krow);
+		return ERR_PTR(-EINVAL);
+	}
+
+	if (!of_get_property(np, "linux,keymap", &proplen)) {
+		dev_err(dev, "property linux,keymap not found\n");
+		return ERR_PTR(-ENOENT);
+	}
+
+	plat->no_autorepeat = of_property_read_bool(np, "linux,no-autorepeat");
+	plat->enable_wakeup = of_property_read_bool(np, "linux,wakeup");
+
+	/* The custom delay format is ms/16 */
+	of_property_read_u32(np, "debounce-delay-ms", &debounce_ms);
+	if (debounce_ms)
+		plat->debounce_period = debounce_ms * 16;
+	else
+		plat->debounce_period = TC_KPD_DEBOUNCE_PERIOD;
+
+	plat->settle_time = TC_KPD_SETTLE_TIME;
+	/* FIXME: should be property of the IRQ resource? */
+	plat->irqtype = IRQF_TRIGGER_FALLING;
+
+	return plat;
+}
+#else
+static inline const struct tc3589x_keypad_platform_data *
+tc3589x_keypad_of_probe(struct device *dev)
+{
+	return ERR_PTR(-ENODEV);
+}
+#endif
+
+
 static int tc3589x_keypad_probe(struct platform_device *pdev)
 {
 	struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent);
@@ -307,8 +363,11 @@ static int tc3589x_keypad_probe(struct platform_device *pdev)
 
 	plat = tc3589x->pdata->keypad;
 	if (!plat) {
-		dev_err(&pdev->dev, "invalid keypad platform data\n");
-		return -EINVAL;
+		plat = tc3589x_keypad_of_probe(&pdev->dev);
+		if (IS_ERR(plat)) {
+			dev_err(&pdev->dev, "invalid keypad platform data\n");
+			return PTR_ERR(plat);
+		}
 	}
 
 	irq = platform_get_irq(pdev, 0);
-- 
1.8.3.1


^ permalink raw reply related

* Re: WPC8769L (WEC1020) support in winbond-cir?
From: David Härdeman @ 2013-10-15 21:59 UTC (permalink / raw)
  To: Tom Gundersen
  Cc: Juan J. Garcia de Soria, Sean Young, linux-input@vger.kernel.org,
	linux-media
In-Reply-To: <CAG-2HqX-TO7h8zJ6F01r2LfRVjQtb0pK_1wKGsYVKzB0zC7TQA@mail.gmail.com>

On Mon, Oct 14, 2013 at 03:16:20PM +0200, Tom Gundersen wrote:
>Hi David and Juan,
>
>I'm going through the various out-of-tree LIRC drivers to see if we
>can stop shipping them in Arch Linux [0]. So far it appears we can
>drop all except for lirc_wpc8769l [1] (PnP id WEC1020).
>
>I noticed the comment in windownd-cir [2]:
>
> *  Currently supports the Winbond WPCD376i chip (PNP id WEC1022), but
> *  could probably support others (Winbond WEC102X, NatSemi, etc)
> *  with minor modifications.
>
>What are your thoughts on adding support for WEC1020 upstream? Is
>anyone interested in doing this work (I sadly don't have the correct
>device, so can't really do it myself)?

IIRC, Juan had a hacked-up version of the winbond-cir driver working on
his hardware back in March (the hardware seems similar enough, basically
the WEC1022 adds some additional Wake-On-IR functionality...I seem to
recall).

But I think Juan is the one to talk to. I don't have the WEC1020
hardware and I don't have his experience of adding support for it...

-- 
David Härdeman

^ permalink raw reply

* Re: [PATCH] Input: usbtouchscreen - separate report and transmit buffer size handling
From: Dmitry Torokhov @ 2013-10-16  6:29 UTC (permalink / raw)
  To: Christian Engelmayer; +Cc: Forest Bond, Daniel Ritz, linux-input, linux-usb
In-Reply-To: <20131015165000.5987a916@frequentis.com>

Hi Christian,

On Tue, Oct 15, 2013 at 04:50:00PM +0200, Christian Engelmayer wrote:
> This patch supports the separate handling of the USB transfer buffer length
> and the length of the buffer used for multi packet support. The USB transfer
> size can now be explicitly configured via the device_info record. Otherwise
> it defaults to the configured report packet size as before. For devices
> supporting multiple report or diagnostic packets, the USB transfer size is
> now reduced to the USB endpoints wMaxPacketSize if not explicitly set.
> 
> This fixes an issue where event reporting can be delayed for an arbitrary
> time for multi packet devices. For instance the report size for eGalax devices
> is defined to the 16 byte maximum diagnostic packet size as opposed to the 5
> byte report packet size. In case the driver requests 16 byte from the USB
> interrupt endpoint, the USB host controller driver needs to split up the
> request into 2 accesses according to the endpoints wMaxPacketSize of 8 byte.
> When the first transfer is answered by the eGalax device with not less than
> the full 8 byte requested, the host controller has got no way of knowing
> whether the touch controller has got additional data queued and will issue
> the second transfer. If per example a liftoff event finishes at such a
> wMaxPacketSize boundary, the data will not be available to the usbtouch driver
> until a further event is triggered and transfered to the host. From user
> perspective the BTN_TOUCH release event in this case is stuck until the next
> touch down event.
> 
> Signed-off-by: Christian Engelmayer <christian.engelmayer@frequentis.com>
> ---
>  drivers/input/touchscreen/usbtouchscreen.c |   16 ++++++++++++----
>  1 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
> index 721fdb3..aa1f6a7 100644
> --- a/drivers/input/touchscreen/usbtouchscreen.c
> +++ b/drivers/input/touchscreen/usbtouchscreen.c
> @@ -76,6 +76,7 @@ struct usbtouch_device_info {
>  	int min_yc, max_yc;
>  	int min_press, max_press;
>  	int rept_size;
> +	int xmit_size;
>  
>  	/*
>  	 * Always service the USB devices irq not just when the input device is
> @@ -1523,7 +1524,7 @@ static int usbtouch_reset_resume(struct usb_interface *intf)
>  static void usbtouch_free_buffers(struct usb_device *udev,
>  				  struct usbtouch_usb *usbtouch)
>  {
> -	usb_free_coherent(udev, usbtouch->type->rept_size,
> +	usb_free_coherent(udev, usbtouch->type->xmit_size,
>  			  usbtouch->data, usbtouch->data_dma);
>  	kfree(usbtouch->buffer);
>  }
> @@ -1567,8 +1568,15 @@ static int usbtouch_probe(struct usb_interface *intf,
>  	usbtouch->type = type;
>  	if (!type->process_pkt)
>  		type->process_pkt = usbtouch_process_pkt;
> +	if (!type->xmit_size) {
> +		if ((type->get_pkt_len) &&
> +		    (type->rept_size > le16_to_cpu(endpoint->wMaxPacketSize)))
> +			type->xmit_size = le16_to_cpu(endpoint->wMaxPacketSize);
> +		else
> +			type->xmit_size = type->rept_size;

'type' points to a shared data structure and should not be modified. It
looks like we already violating this so a cleanup patch would be
appreciated as well.

BTW, maybe we should do:

	u16 wMaxPaxetSize = le16_to_cpu(endpoint->wMaxPacketSize);
	xmit_size = min(type->rept_size, wMaxPaxetSize);

?

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] input: qt1070: add power management ops
From: Dmitry Torokhov @ 2013-10-16  6:31 UTC (permalink / raw)
  To: Bo Shen; +Cc: Nicolas Ferre, Wenyou.Yang, linux-arm-kernel, linux-input
In-Reply-To: <525B84F4.4000405@atmel.com>

Hi Bo,

On Mon, Oct 14, 2013 at 01:45:24PM +0800, Bo Shen wrote:
> Hi Dmitry,
> 
> On 8/14/2013 14:52, Nicolas Ferre wrote:
> >On 13/08/2013 09:43, Bo Shen :
> >>Add power management ops for qt1070, it maybe a wakeup source
> >>
> >>Signed-off-by: Bo Shen <voice.shen@atmel.com>
> >
> >Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
> 
> Would this patch be applied with Nicolas' ACK?

This patch is already in mainline:

commit 3719b54bc62318db7dd8ac7c39a09dfb991a208f
Author: Bo Shen <voice.shen@atmel.com>
Date:   Tue Aug 13 09:46:40 2013 -0700

    Input: qt1070 - add power management ops

    Add power management ops for qt1070, it may be a wakeup source.

    Signed-off-by: Bo Shen <voice.shen@atmel.com>
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: wacom - Export battery scope
From: Dmitry Torokhov @ 2013-10-16  6:36 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-input, peter.hutterer, chris, killertofu
In-Reply-To: <1381693762.21482.2.camel@nuvo>

On Sun, Oct 13, 2013 at 09:49:22PM +0200, Bastien Nocera wrote:
> 
> This will stop UPower from detecting the tablet as a power supply,
> and using its battery status to hibernate or switch off the machine.
> 
> https://bugs.freedesktop.org/show_bug.cgi?id=70321
> 
> Signed-off-by: Bastien Nocera <hadess@hadess.net>


Applied, thank you.

> ---
>  drivers/input/tablet/wacom_sys.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
> index 79b69ea..e53416a 100644
> --- a/drivers/input/tablet/wacom_sys.c
> +++ b/drivers/input/tablet/wacom_sys.c
> @@ -1031,6 +1031,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
>  }
>  
>  static enum power_supply_property wacom_battery_props[] = {
> +	POWER_SUPPLY_PROP_SCOPE,
>  	POWER_SUPPLY_PROP_CAPACITY
>  };
>  
> @@ -1042,6 +1043,9 @@ static int wacom_battery_get_property(struct power_supply *psy,
>  	int ret = 0;
>  
>  	switch (psp) {
> +		case POWER_SUPPLY_PROP_SCOPE:
> +			val->intval = POWER_SUPPLY_SCOPE_DEVICE;
> +			break;
>  		case POWER_SUPPLY_PROP_CAPACITY:
>  			val->intval =
>  				wacom->wacom_wac.battery_capacity * 100 / 31;
> -- 
> 1.8.3.1
> 
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 4/5] input: tc3589x-keypad: support probing from device tree
From: Dmitry Torokhov @ 2013-10-16  6:39 UTC (permalink / raw)
  To: Linus Walleij
  Cc: linux-input, devicetree, linux-kernel, Samuel Ortiz, Lee Jones
In-Reply-To: <1381872071-23455-1-git-send-email-linus.walleij@linaro.org>

On Tue, Oct 15, 2013 at 11:21:11PM +0200, Linus Walleij wrote:
> Implement device tree probing for the tc3589x keypad driver.
> This is modeled on the STMPE keypad driver and tested on the
> Ux500 TVK1281618 UIB.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

Looks good, should I merge it or you want to take it through another
tree??

> ---
>  drivers/input/keyboard/tc3589x-keypad.c | 63 +++++++++++++++++++++++++++++++--
>  1 file changed, 61 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/input/keyboard/tc3589x-keypad.c b/drivers/input/keyboard/tc3589x-keypad.c
> index 208de7c..f6ec0d7 100644
> --- a/drivers/input/keyboard/tc3589x-keypad.c
> +++ b/drivers/input/keyboard/tc3589x-keypad.c
> @@ -297,6 +297,62 @@ static void tc3589x_keypad_close(struct input_dev *input)
>  	tc3589x_keypad_disable(keypad);
>  }
>  
> +#ifdef CONFIG_OF
> +static const struct tc3589x_keypad_platform_data *
> +tc3589x_keypad_of_probe(struct device *dev)
> +{
> +	struct device_node *np = dev->of_node;
> +	struct tc3589x_keypad_platform_data *plat;
> +	u32 debounce_ms;
> +	int proplen;
> +
> +	if (!np)
> +		return ERR_PTR(-ENODEV);
> +
> +	plat = devm_kzalloc(dev, sizeof(*plat), GFP_KERNEL);
> +	if (!plat)
> +		return ERR_PTR(-ENOMEM);
> +
> +	of_property_read_u8(np, "keypad,num-columns", &plat->kcol);
> +	of_property_read_u8(np, "keypad,num-rows", &plat->krow);
> +	if (!plat->krow || !plat->kcol ||
> +	     plat->krow > TC_KPD_ROWS || plat->kcol > TC_KPD_COLUMNS) {
> +		dev_err(dev,
> +			"keypad columns/rows not properly specified (%ux%u)\n",
> +			plat->kcol, plat->krow);
> +		return ERR_PTR(-EINVAL);
> +	}
> +
> +	if (!of_get_property(np, "linux,keymap", &proplen)) {
> +		dev_err(dev, "property linux,keymap not found\n");
> +		return ERR_PTR(-ENOENT);
> +	}
> +
> +	plat->no_autorepeat = of_property_read_bool(np, "linux,no-autorepeat");
> +	plat->enable_wakeup = of_property_read_bool(np, "linux,wakeup");
> +
> +	/* The custom delay format is ms/16 */
> +	of_property_read_u32(np, "debounce-delay-ms", &debounce_ms);
> +	if (debounce_ms)
> +		plat->debounce_period = debounce_ms * 16;
> +	else
> +		plat->debounce_period = TC_KPD_DEBOUNCE_PERIOD;
> +
> +	plat->settle_time = TC_KPD_SETTLE_TIME;
> +	/* FIXME: should be property of the IRQ resource? */
> +	plat->irqtype = IRQF_TRIGGER_FALLING;
> +
> +	return plat;
> +}
> +#else
> +static inline const struct tc3589x_keypad_platform_data *
> +tc3589x_keypad_of_probe(struct device *dev)
> +{
> +	return ERR_PTR(-ENODEV);
> +}
> +#endif
> +
> +
>  static int tc3589x_keypad_probe(struct platform_device *pdev)
>  {
>  	struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent);
> @@ -307,8 +363,11 @@ static int tc3589x_keypad_probe(struct platform_device *pdev)
>  
>  	plat = tc3589x->pdata->keypad;
>  	if (!plat) {
> -		dev_err(&pdev->dev, "invalid keypad platform data\n");
> -		return -EINVAL;
> +		plat = tc3589x_keypad_of_probe(&pdev->dev);
> +		if (IS_ERR(plat)) {
> +			dev_err(&pdev->dev, "invalid keypad platform data\n");
> +			return PTR_ERR(plat);
> +		}
>  	}
>  
>  	irq = platform_get_irq(pdev, 0);
> -- 
> 1.8.3.1
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v2 1/2] Input - wacom: Not all multi-interface devices support touch
From: Dmitry Torokhov @ 2013-10-16  6:48 UTC (permalink / raw)
  To: Ping Cheng; +Cc: linux-input, peter.hutterer, chris, Ping Cheng
In-Reply-To: <1381439833-1116-1-git-send-email-pingc@wacom.com>

On Thu, Oct 10, 2013 at 02:17:13PM -0700, Ping Cheng wrote:
> Some multi-interface devices support expresskeys on a separate interface,
> such as Bamboo; some multi-interface devices do not support touch at all,
> such as Pen only Intuos5. Make sure we report the right device names.
> 
> Tested-by: Jason Gerecke <killertofu@gmail.com>
> Signed-off-by: Ping Cheng <pingc@wacom.com>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH v2 1/2] Add an additional argument for decode routine, change secondary device name
From: Dmitry Torokhov @ 2013-10-16  6:54 UTC (permalink / raw)
  To: Yunkang Tang; +Cc: yunkang.tang, linux-input
In-Reply-To: <1379045010-3347-2-git-send-email-yunkang.tang@cn.alps.com>

Hi Yunkang,

On Fri, Sep 13, 2013 at 12:03:29PM +0800, Yunkang Tang wrote:
> From: Yunkang Tang <yunkang.tang@cn.alps.com>
> 
> - Add an addition argument for decode routine, new devices need this info.
> - Change the dev2's name from "PS/2 Mouse" to "ALPS PS/2 Device".
> 

I carved the name change device out of this patch and applied to my
3.13 queue.

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] Input: nspire-keypad - add missing clk_disable_unprepare() on error path
From: Dmitry Torokhov @ 2013-10-16  6:55 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: grant.likely, rob.herring, dt.tangr, yongjun_wei, Julia.Lawall,
	viresh.kumar, linux-input
In-Reply-To: <CAPgLHd9f_4-mtxXKLcL+fiNJw8gdTjU8ZSJtJoSLTW2tSa-N_Q@mail.gmail.com>

On Sat, Oct 12, 2013 at 02:32:09PM +0800, Wei Yongjun wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> Add the missing clk_disable_unprepare() before return
> from nspire_keypad_open() in the error handling case.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Applied, thank you.

> ---
>  drivers/input/keyboard/nspire-keypad.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/nspire-keypad.c b/drivers/input/keyboard/nspire-keypad.c
> index b3e3eda..85e8d80 100644
> --- a/drivers/input/keyboard/nspire-keypad.c
> +++ b/drivers/input/keyboard/nspire-keypad.c
> @@ -143,8 +143,10 @@ static int nspire_keypad_open(struct input_dev *input)
>  		return error;
>  
>  	error = nspire_keypad_chip_init(keypad);
> -	if (error)
> +	if (error) {
> +		clk_disable_unprepare(keypad->clk);
>  		return error;
> +	}
>  
>  	return 0;
>  }
> 

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH 4/5] input: tc3589x-keypad: support probing from device tree
From: Linus Walleij @ 2013-10-16  7:50 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linux Input, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, Samuel Ortiz, Lee Jones
In-Reply-To: <20131016063947.GD4282@core.coreip.homeip.net>

On Wed, Oct 16, 2013 at 8:39 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Tue, Oct 15, 2013 at 11:21:11PM +0200, Linus Walleij wrote:
>> Implement device tree probing for the tc3589x keypad driver.
>> This is modeled on the STMPE keypad driver and tested on the
>> Ux500 TVK1281618 UIB.
>>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> Looks good, should I merge it or you want to take it through another
> tree??

As this one is only using old device tree bindings
(Documentation/devicetree/bindings/input/matrix-keymap.txt
and friends) I think you can just merge it.

Yours,
Linus Walleij

^ permalink raw reply

* Re: [PATCH v2 0/2] Improve the performance of alps v5-protocol's touchpad
From: Justin Clift @ 2013-10-16  9:37 UTC (permalink / raw)
  To: Yunkang Tang
  Cc: dmitry.torokhov, yunkang.tang, linux-input, Kevin Cernekee,
	Niels de Vos
In-Reply-To: <1379045010-3347-1-git-send-email-yunkang.tang@cn.alps.com>

On 13/09/2013, at 5:03 AM, Yunkang Tang wrote:
> Hi all,
> 
> Here is the v2 of improving ALPS v5 protocol device.
> 
> Change since v1:
> - fix the issue that previous patches were broken by mail system.
> - split the modification to 2 patches.
> - Change dev2's name to "ALPS PS/2 Device"

Thanks Tommy.  We've been trying to get recent ALPS touchpads
working through Red Hat Bugzilla issue 953211.

  https://bugzilla.redhat.com/show_bug.cgi?id=953211

Niels de Vos, CC'd, was kind enough to build a Fedora 19 kernel
with your patch added.  We've been testing it since yesterday.

Your patch works well for several models of laptop (confirmed
success):

 * Dell Inspiron 17R SE / Inspiron 7720
 * Dell Vostro 3360
 * Fujitsu Lifebook AH532

With your patches, the touchpad:

* is recognised as a touchpad
* both KDE and Gnome can control it
* 2 finger scrolling works

That being said, we have conflicting reports about 1 finger
vertical scrolling on the Inspiron 17R SE / Inspiron 7720.

* 1 finger scrolling works on my laptop (Inspiron 17R SE),
  if 2 finger scrolling is NOT enabled in Gnome3 mouse &
  touchpad settings. (seems mutually exclusive)
* 1 finger scrolling does NOT work in KDE (Inspiron 7720)
  * I'm following this up with the reporter, as it may
    turn out to be a KDE settings issue

From my point of view, I'm be happy to see these patches
be applied, and you're welcome to use:

  Tested-by: Justin Clift <jclift@redhat.com>

Side note - Thanks to the people who've tested this and
reported back. :)

* Stanislav Datskevich
* Özgür Gündoğan
* Pentarh Udi
* Arnaud Lacombe
* Gaspard Jankowiak
* myself ;>

Regards and best wishes,

Justin Clift


> Best Regards,
> Tommy

--
Open Source and Standards @ Red Hat

twitter.com/realjustinclift

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

^ permalink raw reply

* Re: WPC8769L (WEC1020) support in winbond-cir?
From: Juan Jesús García de Soria Lucena @ 2013-10-16 14:47 UTC (permalink / raw)
  To: David Härdeman
  Cc: Tom Gundersen, Sean Young, linux-input@vger.kernel.org,
	linux-media
In-Reply-To: <CAB+yVgCtvRHRLxP2SRgCAqkCKdyThgr48fOvBFe9YHfz3xArmQ@mail.gmail.com>

Resending, now making sure I use plain text for the email...

Hi there,

2013/10/15 David Härdeman <david@hardeman.nu>
>
> IIRC, Juan had a hacked-up version of the winbond-cir driver working on
> his hardware back in March (the hardware seems similar enough, basically
> the WEC1022 adds some additional Wake-On-IR functionality...I seem to
> recall).

I did indeed look at this at the time. I still have the hardware,
should have the hardware docs somewhere, and can look at where I left
that hacked code at the time...

I really would have liked to merge in the support for it into
winbond-cir, but real life took over.

> But I think Juan is the one to talk to. I don't have the WEC1020
> hardware and I don't have his experience of adding support for it...

As I said, I still have the hardware around. I might get some time
around this weekend to look at it and come back with at least an idea
of what is left to be done.

Best regards,

   Juan.

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

^ permalink raw reply

* Logitech G710+ unusable without quirk/driver
From: Kai Wasserbäch @ 2013-10-16 14:50 UTC (permalink / raw)
  To: linux-input

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

[Please CC me on all replys, I'm not subscribed to this list.]

Dear Kernel Devs,
I recently tried to use a Logitech G710+ (because of the nice mechanical keys)
with Linux, which is, outside of X (evdev seems to filter this), not possible.
The keyboard spams „6“ to the console. Some searching yielded, that this is a
known problem and based on that information it seems like the problem is, that
the device sends some key down events during initilisation but no key up event.

This means I can't use the device during boot, as I'm unable to enter the
passphrase for my encrypted filesystem. Or later, the non-graphical interface.

There is an out-of-tree driver
(<https://github.com/Wattos/logitech-g710-linux-driver>) which works for the
non-graphical interface; I haven't managed to convince my initrd to properly
load the driver, even though it is included. The author tried to get feedback
from this list, but didn't receive an answer
<http://article.gmane.org/gmane.linux.kernel.input/30258>, but maybe that's a
starting point for getting something working into the kernel.

Is there some kind of quirk flag that can be set during boot, that would make
the keyboard at least usable (obviously without the macro keys, but those aren't
that important to me, so that'd be fine)?

Thank you in advance for fixing this issue!

Kind regards,
Kai Wasserbäch


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 665 bytes --]

^ permalink raw reply

* [PATCH] drivers: input: mouse: Remove useless casting in cypress_ps2.c
From: Geyslan G. Bem @ 2013-10-16 16:05 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: dudl, kamal, mario_limonciello, git, linux-input, linux-kernel,
	kernel-br, Geyslan G. Bem

Casting (void *) value returned by kzalloc is useless
as mentioned in Documentation/CodingStyle, Chap 14.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
 drivers/input/mouse/cypress_ps2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
index f51765f..ef651cc 100644
--- a/drivers/input/mouse/cypress_ps2.c
+++ b/drivers/input/mouse/cypress_ps2.c
@@ -679,7 +679,7 @@ int cypress_init(struct psmouse *psmouse)
 {
 	struct cytp_data *cytp;
 
-	cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
+	cytp = kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
 	psmouse->private = (void *)cytp;
 	if (cytp == NULL)
 		return -ENOMEM;
-- 
1.8.4


^ permalink raw reply related

* Re: [PATCH 1/1][Resend] Input: cypress_ps2 - Return zero finger count if palm is detected.
From: Dmitry Torokhov @ 2013-10-16 18:35 UTC (permalink / raw)
  To: Joseph Salisbury
  Cc: rydberg, Kamal Mostafa, linux-kernel, dudl, git, tim.gardner,
	linux-input
In-Reply-To: <525827B3.9080003@canonical.com>

Hi Joe,

On Fri, Oct 11, 2013 at 12:30:43PM -0400, Joseph Salisbury wrote:
> On 09/30/2013 04:12 PM, Kamal Mostafa wrote:
> > On Tue, 2013-09-24 at 11:44 -0400, Joseph Salisbury wrote:
> >> BugLink: http://bugs.launchpad.net/bugs/1229361
> >>
> >> This patch sets the finger count to 0 in the case of palm contact.
> >>
> >> Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
> >> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> (maintainer:INPUT (KEYBOARD,...,commit_signer:2/2=100%)
> >> Cc: Henrik Rydberg <rydberg@euromail.se> (maintainer:INPUT MULTITOUCH...)
> >> Cc: Kamal Mostafa <kamal@canonical.com> (commit_signer:2/2=100%)
> >> Cc: Dudley Du <dudl@cypress.com> (commit_signer:2/2=100%)
> >> Cc: Kyle Fazzari <git@status.e4ward.com> (commit_signer:1/2=50%)
> >> Cc: Tim Gardner <tim.gardner@canonical.com> (commit_signer:1/2=50%)
> >> Cc: linux-input@vger.kernel.org (open list:INPUT (KEYBOARD,...)
> >> Cc: linux-kernel@vger.kernel.org (open list)
> >> Cc: stable@vger.kernel.org
> > This patch works fine: eliminates stream of junk driver messages with no
> > ill effects.
> >
> > Tested-by: Kamal Mostafa <kamal@canonical.com>
> >
> >  -Kamal
> >
> >
> >> ---
> >>  drivers/input/mouse/cypress_ps2.c |    4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
> >> index 45b3eda..95b2c40 100644
> >> --- a/drivers/input/mouse/cypress_ps2.c
> >> +++ b/drivers/input/mouse/cypress_ps2.c
> >> @@ -441,7 +441,7 @@ static int cypress_get_finger_count(unsigned char header_byte)
> >>  			case 2: return 5;
> >>  			default:
> >>  				/* Invalid contact (e.g. palm). Ignore it. */
> >> -				return -1;
> >> +				return 0;
> >>  		}
> >>  	}
> >>  
> >> @@ -460,7 +460,7 @@ static int cypress_parse_packet(struct psmouse *psmouse,
> >>  
> >>  	contact_cnt = cypress_get_finger_count(header_byte);
> >>  
> >> -	if (contact_cnt < 0) /* e.g. palm detect */
> >> +	if (contact_cnt < 0)
> >>  		return -EINVAL;
> >>  
> >>  	report_data->contact_cnt = contact_cnt;
> Hi Dmitry and Henrik,
> 
> Have you had a chance to review this patch to consider it for inclusion
> in mainline?

I think the main problem is that we were reporting PSMOUSE_BAD_DATA for
palm packets.

Could you try a slightly extended patch below to make sure it all still
works?

Thanks!

-- 
Dmitry

Input: cypress_ps2 - do not consider data bad if palm is detected

From: Joseph Salisbury <joseph.salisbury@canonical.com>

If hardware (or firmware) detects palm on the surface of the device it does
not mean that the data packet is bad from the protocol standpoint. Instead
of reporting PSMOUSE_BAD_DATA in this case simply threat it as if nothing
touches the surface.

BugLink: http://bugs.launchpad.net/bugs/1229361

Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com>
Tested-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/input/mouse/cypress_ps2.c |   20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
index ef651cc..e499e55 100644
--- a/drivers/input/mouse/cypress_ps2.c
+++ b/drivers/input/mouse/cypress_ps2.c
@@ -439,7 +439,7 @@ static int cypress_get_finger_count(unsigned char header_byte)
 			case 2: return 5;
 			default:
 				/* Invalid contact (e.g. palm). Ignore it. */
-				return -1;
+				return 0;
 		}
 	}
 
@@ -452,17 +452,10 @@ static int cypress_parse_packet(struct psmouse *psmouse,
 {
 	unsigned char *packet = psmouse->packet;
 	unsigned char header_byte = packet[0];
-	int contact_cnt;
 
 	memset(report_data, 0, sizeof(struct cytp_report_data));
 
-	contact_cnt = cypress_get_finger_count(header_byte);
-
-	if (contact_cnt < 0) /* e.g. palm detect */
-		return -EINVAL;
-
-	report_data->contact_cnt = contact_cnt;
-
+	report_data->contact_cnt = cypress_get_finger_count(header_byte);
 	report_data->tap = (header_byte & ABS_MULTIFINGER_TAP) ? 1 : 0;
 
 	if (report_data->contact_cnt == 1) {
@@ -535,11 +528,9 @@ static void cypress_process_packet(struct psmouse *psmouse, bool zero_pkt)
 	int slots[CYTP_MAX_MT_SLOTS];
 	int n;
 
-	if (cypress_parse_packet(psmouse, cytp, &report_data))
-		return;
+	cypress_parse_packet(psmouse, cytp, &report_data);
 
 	n = report_data.contact_cnt;
-
 	if (n > CYTP_MAX_MT_SLOTS)
 		n = CYTP_MAX_MT_SLOTS;
 
@@ -604,11 +595,6 @@ static psmouse_ret_t cypress_validate_byte(struct psmouse *psmouse)
 	if ((packet[0] & 0x08) == 0x08)
 		return PSMOUSE_BAD_DATA;
 
-	contact_cnt = cypress_get_finger_count(packet[0]);
-
-	if (contact_cnt < 0)
-		return PSMOUSE_BAD_DATA;
-
 	if (cytp->mode & CYTP_BIT_ABS_NO_PRESSURE)
 		cypress_set_packet_size(psmouse, contact_cnt == 2 ? 7 : 4);
 	else

^ permalink raw reply related

* Re: [PATCH] drivers: input: mouse: Remove useless casting in cypress_ps2.c
From: Dmitry Torokhov @ 2013-10-16 18:41 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: dudl, kamal, mario_limonciello, git, linux-input, linux-kernel,
	kernel-br
In-Reply-To: <1381939512-28534-1-git-send-email-geyslan@gmail.com>

Hi Geyslan,

On Wed, Oct 16, 2013 at 01:05:12PM -0300, Geyslan G. Bem wrote:
> Casting (void *) value returned by kzalloc is useless
> as mentioned in Documentation/CodingStyle, Chap 14.
> 
> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
> ---
>  drivers/input/mouse/cypress_ps2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
> index f51765f..ef651cc 100644
> --- a/drivers/input/mouse/cypress_ps2.c
> +++ b/drivers/input/mouse/cypress_ps2.c
> @@ -679,7 +679,7 @@ int cypress_init(struct psmouse *psmouse)
>  {
>  	struct cytp_data *cytp;
>  
> -	cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
> +	cytp = kzalloc(sizeof(struct cytp_data), GFP_KERNEL);

I already have a patch for this from Jingoo Han in my queue.

>  	psmouse->private = (void *)cytp;

But this cast is also not needed, so if you could send me a patch for it
I'd appreciate that.

>  	if (cytp == NULL)
>  		return -ENOMEM;
> -- 
> 1.8.4
> 

Thanks.

-- 
Dmitry

^ permalink raw reply

* Re: [PATCH] drivers: input: mouse: Remove useless casting in cypress_ps2.c
From: Geyslan Gregório Bem @ 2013-10-16 18:48 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: dudl, kamal, mario_limonciello, git, linux-input, LKML, kernel-br
In-Reply-To: <20131016184133.GB21932@core.coreip.homeip.net>

2013/10/16 Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> Hi Geyslan,
>
> On Wed, Oct 16, 2013 at 01:05:12PM -0300, Geyslan G. Bem wrote:
>> Casting (void *) value returned by kzalloc is useless
>> as mentioned in Documentation/CodingStyle, Chap 14.
>>
>> Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
>> ---
>>  drivers/input/mouse/cypress_ps2.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
>> index f51765f..ef651cc 100644
>> --- a/drivers/input/mouse/cypress_ps2.c
>> +++ b/drivers/input/mouse/cypress_ps2.c
>> @@ -679,7 +679,7 @@ int cypress_init(struct psmouse *psmouse)
>>  {
>>       struct cytp_data *cytp;
>>
>> -     cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
>> +     cytp = kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
>
> I already have a patch for this from Jingoo Han in my queue.

No problem.
>
>>       psmouse->private = (void *)cytp;
>
> But this cast is also not needed, so if you could send me a patch for it
> I'd appreciate that.

Sure, I can.
>
>>       if (cytp == NULL)
>>               return -ENOMEM;
>> --
>> 1.8.4
>>
>
> Thanks.
>
> --
> Dmitry

^ permalink raw reply

* Re: Fixing 0eef:0001 (eGalax) driver binding
From: Forest Bond @ 2013-10-16 20:03 UTC (permalink / raw)
  To: linux-input
  Cc: Sebastian Dalfuß, Jiri Kosina, Daniel Ritz, Max Weninger,
	Dmitry Torokhov, Christian Engelmayer
In-Reply-To: <20131015182701.GD14822@alittletooquiet.net>

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

Hi,

On Tue, Oct 15, 2013 at 02:27:01PM -0400, Forest Bond wrote:
> 3. Some devices with class HID, protocol None work fine with usbtouchscreen,
>    which is where they are currently bound.  Okay!
> 
>    Some of these also work with usbhid (using quirks=0x20000048 to prevent it
>    from being ignored).  All of the ones I have here are like this.  I'm not
>    sure if there is a reason to prefer one driver over the other (dual touch?).
> 
>    Others reportedly do *not* work with usbhid (this is Max):
> 
>    https://lkml.org/lkml/2009/1/25/127
> 
> 4. Some devices with class HID, protocol None do *not* work with usbtouchscreen,
>    which is where they are currently bound.  No bueno.  Here's one (this is
>    Sebastian):
> 
>    http://comments.gmane.org/gmane.linux.kernel.input/31710
> 
>    I suspect these are all multitouch devices, but I am not sure.
> 
> So we need to figure out the device driver mapping that supports the most
> devices (or regresses the fewest, although I think we've messed this up enough
> for that to be a secondary concern).
> 
> 
> What I'm hoping is that the report in #3 that led to class HID, protocol None
> devices being bound to usbtouchscreen is no longer accurate and these devices
> work fine with current usbhid.
> 
> Max, can you test this for us?  I.e. does your touch screen work with current
> usbhid using quirks=0x20000048?  The following modprobe snippet might be
> helpful:
> 
> options usbhid quirks=0x0eef:0x0001:0x40000048
> install usbtouchscreen /bin/false
> 
> If Max's touch screen works with current usbhid, I think we can drop the special
> case that binds it to usbtouchscreen and we're done!  If not, things will be
> more complicated (e.g. we may have to consider whether a device is multitouch to
> decide if we should bind usbhid or usbtouchscreen).

Max reported to me off-list that he no longer has his touch screen, so this
testing most likely will not be taking place.

Unless someone can identify an EETI/eGalax touch screen with class HID, protocol
None that does not work with current usbhid, I propose we bind these to usbhid
instead of usbtouchscreen and see if anything breaks.  This will fix one
regression (Sebastian's) at the risk of re-introducing another one (Max's).  But
I think we'll actually end up with both problems fixed.

I think I could also argue that if we're going to break a device, it should be
the one that says it's HID but isn't, not the one that actually is what it says
it is.  Hopefully it won't come down to that. ;)

Thoughts?

Thanks,
Forest
-- 
Forest Bond
http://www.forestbond.com/
http://www.rapidrollout.com/

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

^ permalink raw reply

* [PATCH v2] Input: usbtouchscreen - separate report and transmit buffer size handling
From: Christian Engelmayer @ 2013-10-16 21:15 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Forest Bond, Daniel Ritz, linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-usb-u79uwXL29TY76Z2rM5mHXA,
	christian.engelmayer-USXAA5bZaHGDvotElmWtJA
In-Reply-To: <20131016062902.GA4282-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>

This patch supports the separate handling of the USB transfer buffer length
and the length of the buffer used for multi packet support. For devices
supporting multiple report or diagnostic packets, the USB transfer size is now
limited to the USB endpoints wMaxPacketSize - otherwise it defaults to the
configured report packet size as before

This fixes an issue where event reporting can be delayed for an arbitrary
time for multi packet devices. For instance the report size for eGalax devices
is defined to the 16 byte maximum diagnostic packet size as opposed to the 5
byte report packet size. In case the driver requests 16 byte from the USB
interrupt endpoint, the USB host controller driver needs to split up the
request into 2 accesses according to the endpoints wMaxPacketSize of 8 byte.
When the first transfer is answered by the eGalax device with not less than
the full 8 byte requested, the host controller has got no way of knowing
whether the touch controller has got additional data queued and will issue
the second transfer. If per example a liftoff event finishes at such a
wMaxPacketSize boundary, the data will not be available to the usbtouch driver
until a further event is triggered and transfered to the host. From user
perspective the BTN_TOUCH release event in this case is stuck until the next
touch down event.

Signed-off-by: Christian Engelmayer <christian.engelmayer-USXAA5bZaHGDvotElmWtJA@public.gmane.org>
---
v2: Added changes suggested by Dmitry Torokhov:

    * Prefer a temporary variable over a multiple conversion of wMaxPaxetSize.
    * Avoid further modifiction of the shared device info structure.

The existing violation in the probe function

	if (!type->process_pkt)
		type->process_pkt = usbtouch_process_pkt;

seems to be conveniance triggered and while at least at the moment applicable
for all devices of a type, could be easily removed. For a complete cleanup and
eg. setting the shared device information 'const', we would have to adapt the
Nexio support first - nexio_read_data:

	if (!usbtouch->type->max_xc) {
		usbtouch->type->max_xc = 2 * x_len;
		input_set_abs_params(usbtouch->input, ABS_X,
				     0, usbtouch->type->max_xc, 0, 0);
		usbtouch->type->max_yc = 2 * y_len;
		input_set_abs_params(usbtouch->input, ABS_Y,
				     0, usbtouch->type->max_yc, 0, 0);
	}
---
 drivers/input/touchscreen/usbtouchscreen.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c
index 721fdb3..d632848 100644
--- a/drivers/input/touchscreen/usbtouchscreen.c
+++ b/drivers/input/touchscreen/usbtouchscreen.c
@@ -106,6 +106,7 @@ struct usbtouch_device_info {
 struct usbtouch_usb {
 	unsigned char *data;
 	dma_addr_t data_dma;
+	int data_size;
 	unsigned char *buffer;
 	int buf_len;
 	struct urb *irq;
@@ -1523,7 +1524,7 @@ static int usbtouch_reset_resume(struct usb_interface *intf)
 static void usbtouch_free_buffers(struct usb_device *udev,
 				  struct usbtouch_usb *usbtouch)
 {
-	usb_free_coherent(udev, usbtouch->type->rept_size,
+	usb_free_coherent(udev, usbtouch->data_size,
 			  usbtouch->data, usbtouch->data_dma);
 	kfree(usbtouch->buffer);
 }
@@ -1548,6 +1549,7 @@ static int usbtouch_probe(struct usb_interface *intf,
 	struct usb_endpoint_descriptor *endpoint;
 	struct usb_device *udev = interface_to_usbdev(intf);
 	struct usbtouch_device_info *type;
+	int wMaxPacketSize;
 	int err = -ENOMEM;
 
 	/* some devices are ignored */
@@ -1557,6 +1559,7 @@ static int usbtouch_probe(struct usb_interface *intf,
 	endpoint = usbtouch_get_input_endpoint(intf->cur_altsetting);
 	if (!endpoint)
 		return -ENXIO;
+	wMaxPacketSize = le16_to_cpu(endpoint->wMaxPacketSize);
 
 	usbtouch = kzalloc(sizeof(struct usbtouch_usb), GFP_KERNEL);
 	input_dev = input_allocate_device();
@@ -1568,7 +1571,9 @@ static int usbtouch_probe(struct usb_interface *intf,
 	if (!type->process_pkt)
 		type->process_pkt = usbtouch_process_pkt;
 
-	usbtouch->data = usb_alloc_coherent(udev, type->rept_size,
+	usbtouch->data_size = (type->get_pkt_len) ?
+			min(type->rept_size, wMaxPacketSize) : type->rept_size;
+	usbtouch->data = usb_alloc_coherent(udev, usbtouch->data_size,
 					    GFP_KERNEL, &usbtouch->data_dma);
 	if (!usbtouch->data)
 		goto out_free;
@@ -1628,12 +1633,12 @@ static int usbtouch_probe(struct usb_interface *intf,
 	if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT)
 		usb_fill_int_urb(usbtouch->irq, udev,
 			 usb_rcvintpipe(udev, endpoint->bEndpointAddress),
-			 usbtouch->data, type->rept_size,
+			 usbtouch->data, usbtouch->data_size,
 			 usbtouch_irq, usbtouch, endpoint->bInterval);
 	else
 		usb_fill_bulk_urb(usbtouch->irq, udev,
 			 usb_rcvbulkpipe(udev, endpoint->bEndpointAddress),
-			 usbtouch->data, type->rept_size,
+			 usbtouch->data, usbtouch->data_size,
 			 usbtouch_irq, usbtouch);
 
 	usbtouch->irq->dev = udev;
-- 
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH v2] drivers: input: mouse: Remove useless casting in cypress_ps2.c
From: Geyslan G. Bem @ 2013-10-16 22:31 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: dudl, kamal, mario_limonciello, git, linux-input, linux-kernel,
	kernel-br, Geyslan G. Bem

Get rid of unnecessary (void *) casting in 'cypress_init' function.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
---
 drivers/input/mouse/cypress_ps2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
index f51765f..b87d7ba 100644
--- a/drivers/input/mouse/cypress_ps2.c
+++ b/drivers/input/mouse/cypress_ps2.c
@@ -680,7 +680,7 @@ int cypress_init(struct psmouse *psmouse)
 	struct cytp_data *cytp;
 
 	cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
-	psmouse->private = (void *)cytp;
+	psmouse->private = cytp;
 	if (cytp == NULL)
 		return -ENOMEM;
 
-- 
1.8.4


^ permalink raw reply related

* Re: [PATCH v2] drivers: input: mouse: Remove useless casting in cypress_ps2.c
From: Joe Perches @ 2013-10-16 22:39 UTC (permalink / raw)
  To: Geyslan G. Bem
  Cc: dmitry.torokhov, dudl, kamal, mario_limonciello, git, linux-input,
	linux-kernel, kernel-br
In-Reply-To: <1381962675-26876-1-git-send-email-geyslan@gmail.com>

On Wed, 2013-10-16 at 19:31 -0300, Geyslan G. Bem wrote:
> Get rid of unnecessary (void *) casting in 'cypress_init' function.
[]
> diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
[]
> @@ -680,7 +680,7 @@ int cypress_init(struct psmouse *psmouse)
>  	struct cytp_data *cytp;
>  
>  	cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
> -	psmouse->private = (void *)cytp;
> +	psmouse->private = cytp;

If you are going to remove useless casts, please
also remove the unnecessary kzalloc cast too.

^ permalink raw reply

* Re: [PATCH v2] drivers: input: mouse: Remove useless casting in cypress_ps2.c
From: Geyslan Gregório Bem @ 2013-10-16 22:53 UTC (permalink / raw)
  To: Joe Perches
  Cc: dmitry.torokhov, dudl, kamal, mario_limonciello, git, linux-input,
	LKML, kernel-br
In-Reply-To: <1381963198.22110.73.camel@joe-AO722>

2013/10/16 Joe Perches <joe@perches.com>:
> On Wed, 2013-10-16 at 19:31 -0300, Geyslan G. Bem wrote:
>> Get rid of unnecessary (void *) casting in 'cypress_init' function.
> []
>> diff --git a/drivers/input/mouse/cypress_ps2.c b/drivers/input/mouse/cypress_ps2.c
> []
>> @@ -680,7 +680,7 @@ int cypress_init(struct psmouse *psmouse)
>>       struct cytp_data *cytp;
>>
>>       cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
>> -     psmouse->private = (void *)cytp;
>> +     psmouse->private = cytp;
>
> If you are going to remove useless casts, please
> also remove the unnecessary kzalloc cast too.
>
>

Joe, thanks for reply. Actually I did it and receive this reply from Dmitry:

       struct cytp_data *cytp;

 -     cytp = (struct cytp_data *)kzalloc(sizeof(struct cytp_data), GFP_KERNEL);
 +     cytp = kzalloc(sizeof(struct cytp_data), GFP_KERNEL);

I already have a patch for this from Jingoo Han in my queue.

       psmouse->private = (void *)cytp;

But this cast is also not needed, so if you could send me a patch for it
I'd appreciate that.

^ permalink raw reply

* [PATCH] input: wacom - make sure touch_max is set for touch devices
From: Ping Cheng @ 2013-10-17  0:06 UTC (permalink / raw)
  To: linux-input; +Cc: dmitry.torokhov, killertofu, Ping Cheng

Old single touch Tablet PCs do not have touch_max set at
wacom_features. Since touch device at lease supports one
finger, assign touch_max to 1 when touch usage is defined
in its HID Descriptor and touch_max is not pre-defined.

Signed-off-by: Ping Cheng <pingc@wacom.com>

--
This patch is based on last posted (unmerged) patch:

 "add support for three new Intuos devices"
---
 drivers/input/tablet/wacom_sys.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 81d5910..28066bc 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -304,7 +304,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
 	struct usb_device *dev = interface_to_usbdev(intf);
 	char limit = 0;
 	/* result has to be defined as int for some devices */
-	int result = 0;
+	int result = 0, touch_max = 0;
 	int i = 0, usage = WCM_UNDEFINED, finger = 0, pen = 0;
 	unsigned char *report;
 
@@ -351,7 +351,8 @@ static int wacom_parse_hid(struct usb_interface *intf,
 				if (usage == WCM_DESKTOP) {
 					if (finger) {
 						features->device_type = BTN_TOOL_FINGER;
-
+						/* touch device at least supports one touch point */
+						touch_max = 1;
 						switch (features->type) {
 						case TABLETPC2FG:
 							features->pktlen = WACOM_PKGLEN_TPC2FG;
@@ -504,6 +505,8 @@ static int wacom_parse_hid(struct usb_interface *intf,
 	}
 
  out:
+	if (!features->touch_max && touch_max)
+		features->touch_max = touch_max;
 	result = 0;
 	kfree(report);
 	return result;
-- 
1.8.1.2


^ permalink raw reply related

* Re: [PATCH 3/3] iio: at91: introduce touch screen support in iio adc driver
From: Josh Wu @ 2013-10-17  5:20 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: thomas.petazzoni, mark.rutland, devicetree, linux-iio,
	nicolas.ferre, b.brezillon, Jonathan Cameron, linux-input,
	maxime.ripard, plagnioj, linux-arm-kernel
In-Reply-To: <5255B918.2020705@kernel.org>

Hi, Dimitry

Could give some feedback for this v4  patch if you have time? Since It 
has been stuck for a while.
Thanks.

Best Regards,
Josh Wu

On 10/10/2013 4:14 AM, Jonathan Cameron wrote:
> On 10/08/13 04:48, Josh Wu wrote:
>> AT91 ADC hardware integrate touch screen support. So this patch add touch
>> screen support for at91 adc iio driver.
>> To enable touch screen support in adc, you need to add the dt parameters:
>>    1. which type of touch are used? (4 or 5 wires), sample period time.
>>    2. correct pressure detect threshold value.
>>
>> In the meantime, since touch screen will use a interal period trigger of adc,
>> so it is conflict to other hardware triggers. Driver will disable the hardware
>> trigger support if touch screen is enabled.
>>
>> This driver has been tested in AT91SAM9X5-EK and SAMA5D3x-EK.
>>
>> Signed-off-by: Josh Wu <josh.wu@atmel.com>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> CC: devicetree@vger.kernel.org
> Hi Josh.  I am not going to take this for now both because I want to have
> a close read of it when I have more time and because I want input from
> Dmitry on this one.
>
> Thanks,
>
> Jonathan
>> ---
>>   .../devicetree/bindings/arm/atmel-adc.txt          |    7 +
>>   arch/arm/mach-at91/include/mach/at91_adc.h         |   34 ++
>>   drivers/iio/adc/at91_adc.c                         |  388 ++++++++++++++++++--
>>   3 files changed, 405 insertions(+), 24 deletions(-)
>>
>> diff --git a/Documentation/devicetree/bindings/arm/atmel-adc.txt b/Documentation/devicetree/bindings/arm/atmel-adc.txt
>> index 0e65e01..d106146 100644
>> --- a/Documentation/devicetree/bindings/arm/atmel-adc.txt
>> +++ b/Documentation/devicetree/bindings/arm/atmel-adc.txt
>> @@ -23,6 +23,13 @@ Optional properties:
>>   		       resolution will be used.
>>     - atmel,adc-sleep-mode: Boolean to enable sleep mode when no conversion
>>     - atmel,adc-sample-hold-time: Sample and Hold Time in microseconds
>> +  - atmel,adc-ts-wires: Number of touch screen wires. Should be 4 or 5. If this
>> +                        value is set, then adc driver will enable touch screen
>> +                        support.
>> +    NOTE: when adc touch screen enabled, the adc hardware trigger will be
>> +          disabled. Since touch screen will occupied the trigger register.
>> +  - atmel,adc-ts-pressure-threshold: a pressure threshold for touchscreen. It
>> +                                     make touch detect more precision.
>>    
>>   Optional trigger Nodes:
>>     - Required properties:
>> diff --git a/arch/arm/mach-at91/include/mach/at91_adc.h b/arch/arm/mach-at91/include/mach/at91_adc.h
>> index 048a57f..c287307 100644
>> --- a/arch/arm/mach-at91/include/mach/at91_adc.h
>> +++ b/arch/arm/mach-at91/include/mach/at91_adc.h
>> @@ -60,14 +60,48 @@
>>   #define AT91_ADC_IER		0x24		/* Interrupt Enable Register */
>>   #define AT91_ADC_IDR		0x28		/* Interrupt Disable Register */
>>   #define AT91_ADC_IMR		0x2C		/* Interrupt Mask Register */
>> +#define		AT91_ADC_IER_PEN	(1 << 29)
>> +#define		AT91_ADC_IER_NOPEN	(1 << 30)
>> +#define		AT91_ADC_IER_XRDY	(1 << 20)
>> +#define		AT91_ADC_IER_YRDY	(1 << 21)
>> +#define		AT91_ADC_IER_PRDY	(1 << 22)
>> +#define		AT91_ADC_ISR_PENS	(1 << 31)
>>   
>>   #define AT91_ADC_CHR(n)		(0x30 + ((n) * 4))	/* Channel Data Register N */
>>   #define		AT91_ADC_DATA		(0x3ff)
>>   
>>   #define AT91_ADC_CDR0_9X5	(0x50)			/* Channel Data Register 0 for 9X5 */
>>   
>> +#define AT91_ADC_ACR		0x94	/* Analog Control Register */
>> +#define		AT91_ADC_ACR_PENDETSENS	(0x3 << 0)	/* pull-up resistor */
>> +
>> +#define AT91_ADC_TSMR		0xB0
>> +#define		AT91_ADC_TSMR_TSMODE	(3 << 0)	/* Touch Screen Mode */
>> +#define			AT91_ADC_TSMR_TSMODE_NONE		(0 << 0)
>> +#define			AT91_ADC_TSMR_TSMODE_4WIRE_NO_PRESS	(1 << 0)
>> +#define			AT91_ADC_TSMR_TSMODE_4WIRE_PRESS	(2 << 0)
>> +#define			AT91_ADC_TSMR_TSMODE_5WIRE		(3 << 0)
>> +#define		AT91_ADC_TSMR_TSAV	(3 << 4)	/* Averages samples */
>> +#define			AT91_ADC_TSMR_TSAV_(x)		((x) << 4)
>> +#define		AT91_ADC_TSMR_SCTIM	(0x0f << 16)	/* Switch closure time */
>> +#define		AT91_ADC_TSMR_PENDBC	(0x0f << 28)	/* Pen Debounce time */
>> +#define			AT91_ADC_TSMR_PENDBC_(x)	((x) << 28)
>> +#define		AT91_ADC_TSMR_NOTSDMA	(1 << 22)	/* No Touchscreen DMA */
>> +#define		AT91_ADC_TSMR_PENDET_DIS	(0 << 24)	/* Pen contact detection disable */
>> +#define		AT91_ADC_TSMR_PENDET_ENA	(1 << 24)	/* Pen contact detection enable */
>> +
>> +#define AT91_ADC_TSXPOSR	0xB4
>> +#define AT91_ADC_TSYPOSR	0xB8
>> +#define AT91_ADC_TSPRESSR	0xBC
>> +
>>   #define AT91_ADC_TRGR_9260	AT91_ADC_MR
>>   #define AT91_ADC_TRGR_9G45	0x08
>>   #define AT91_ADC_TRGR_9X5	0xC0
>>   
>> +/* Trigger Register bit field */
>> +#define		AT91_ADC_TRGR_TRGPER	(0xffff << 16)
>> +#define			AT91_ADC_TRGR_TRGPER_(x)	((x) << 16)
>> +#define		AT91_ADC_TRGR_TRGMOD	(0x7 << 0)
>> +#define			AT91_ADC_TRGR_MOD_PERIOD_TRIG	(5 << 0)
>> +
>>   #endif
>> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
>> index 22cf61d2..68ddd7f 100644
>> --- a/drivers/iio/adc/at91_adc.c
>> +++ b/drivers/iio/adc/at91_adc.c
>> @@ -11,6 +11,7 @@
>>   #include <linux/clk.h>
>>   #include <linux/err.h>
>>   #include <linux/io.h>
>> +#include <linux/input.h>
>>   #include <linux/interrupt.h>
>>   #include <linux/jiffies.h>
>>   #include <linux/kernel.h>
>> @@ -39,7 +40,23 @@
>>   #define at91_adc_writel(st, reg, val) \
>>   	(writel_relaxed(val, st->reg_base + reg))
>>   
>> +#define DRIVER_NAME		"at91_adc"
>> +#define MAX_POS_BITS		12
>> +
>> +#define TOUCH_SAMPLE_PERIOD_US		2000	/* 2ms */
>> +#define TOUCH_PEN_DETECT_DEBOUNCE_US	200
>> +
>>   struct at91_adc_caps {
>> +	bool	has_ts;		/* Support touch screen */
>> +	bool	has_tsmr;	/* only at91sam9x5, sama5d3 have TSMR reg */
>> +	/*
>> +	 * Numbers of sampling data will be averaged. Can be 0~3.
>> +	 * Hardware can average (2 ^ ts_filter_average) sample data.
>> +	 */
>> +	u8	ts_filter_average;
>> +	/* Pen Detection input pull-up resistor, can be 0~3 */
>> +	u8	ts_pen_detect_sensitivity;
>> +
>>   	/* startup time calculate function */
>>   	u32 (*calc_startup_ticks)(u8 startup_time, u32 adc_clk_khz);
>>   
>> @@ -47,6 +64,12 @@ struct at91_adc_caps {
>>   	struct at91_adc_reg_desc registers;
>>   };
>>   
>> +enum atmel_adc_ts_type {
>> +	ATMEL_ADC_TOUCHSCREEN_NONE = 0,
>> +	ATMEL_ADC_TOUCHSCREEN_4WIRE = 4,
>> +	ATMEL_ADC_TOUCHSCREEN_5WIRE = 5,
>> +};
>> +
>>   struct at91_adc_state {
>>   	struct clk		*adc_clk;
>>   	u16			*buffer;
>> @@ -71,6 +94,26 @@ struct at91_adc_state {
>>   	bool			low_res;	/* the resolution corresponds to the lowest one */
>>   	wait_queue_head_t	wq_data_avail;
>>   	struct at91_adc_caps	*caps;
>> +
>> +	/*
>> +	 * Following ADC channels are shared by touchscreen:
>> +	 *
>> +	 * CH0 -- Touch screen XP/UL
>> +	 * CH1 -- Touch screen XM/UR
>> +	 * CH2 -- Touch screen YP/LL
>> +	 * CH3 -- Touch screen YM/Sense
>> +	 * CH4 -- Touch screen LR(5-wire only)
>> +	 *
>> +	 * The bitfields below represents the reserved channel in the
>> +	 * touchscreen mode.
>> +	 */
>> +#define CHAN_MASK_TOUCHSCREEN_4WIRE	(0xf << 0)
>> +#define CHAN_MASK_TOUCHSCREEN_5WIRE	(0x1f << 0)
>> +	enum atmel_adc_ts_type	touchscreen_type;
>> +	struct input_dev	*ts_input;
>> +
>> +	u16			ts_sample_period_val;
>> +	u32			ts_pressure_threshold;
>>   };
>>   
>>   static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
>> @@ -105,14 +148,10 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p)
>>   	return IRQ_HANDLED;
>>   }
>>   
>> -static irqreturn_t at91_adc_eoc_trigger(int irq, void *private)
>> +/* Handler for classic adc channel eoc trigger */
>> +void handle_adc_eoc_trigger(int irq, struct iio_dev *idev)
>>   {
>> -	struct iio_dev *idev = private;
>>   	struct at91_adc_state *st = iio_priv(idev);
>> -	u32 status = at91_adc_readl(st, st->registers->status_register);
>> -
>> -	if (!(status & st->registers->drdy_mask))
>> -		return IRQ_HANDLED;
>>   
>>   	if (iio_buffer_enabled(idev)) {
>>   		disable_irq_nosync(irq);
>> @@ -122,6 +161,115 @@ static irqreturn_t at91_adc_eoc_trigger(int irq, void *private)
>>   		st->done = true;
>>   		wake_up_interruptible(&st->wq_data_avail);
>>   	}
>> +}
>> +
>> +static int at91_ts_sample(struct at91_adc_state *st)
>> +{
>> +	unsigned int xscale, yscale, reg, z1, z2;
>> +	unsigned int x, y, pres, xpos, ypos;
>> +	unsigned int rxp = 1;
>> +	unsigned int factor = 1000;
>> +	struct iio_dev *idev = iio_priv_to_dev(st);
>> +
>> +	unsigned int xyz_mask_bits = st->res;
>> +	unsigned int xyz_mask = (1 << xyz_mask_bits) - 1;
>> +
>> +	/* calculate position */
>> +	/* x position = (x / xscale) * max, max = 2^MAX_POS_BITS - 1 */
>> +	reg = at91_adc_readl(st, AT91_ADC_TSXPOSR);
>> +	xpos = reg & xyz_mask;
>> +	x = (xpos << MAX_POS_BITS) - xpos;
>> +	xscale = (reg >> 16) & xyz_mask;
>> +	if (xscale == 0) {
>> +		dev_err(&idev->dev, "Error: xscale == 0!\n");
>> +		return -1;
>> +	}
>> +	x /= xscale;
>> +
>> +	/* y position = (y / yscale) * max, max = 2^MAX_POS_BITS - 1 */
>> +	reg = at91_adc_readl(st, AT91_ADC_TSYPOSR);
>> +	ypos = reg & xyz_mask;
>> +	y = (ypos << MAX_POS_BITS) - ypos;
>> +	yscale = (reg >> 16) & xyz_mask;
>> +	if (yscale == 0) {
>> +		dev_err(&idev->dev, "Error: yscale == 0!\n");
>> +		return -1;
>> +	}
>> +	y /= yscale;
>> +
>> +	/* calculate the pressure */
>> +	reg = at91_adc_readl(st, AT91_ADC_TSPRESSR);
>> +	z1 = reg & xyz_mask;
>> +	z2 = (reg >> 16) & xyz_mask;
>> +
>> +	if (z1 != 0)
>> +		pres = rxp * (x * factor / 1024) * (z2 * factor / z1 - factor)
>> +			/ factor;
>> +	else
>> +		pres = st->ts_pressure_threshold;	/* no pen contacted */
>> +
>> +	dev_dbg(&idev->dev, "xpos = %d, xscale = %d, ypos = %d, yscale = %d, z1 = %d, z2 = %d, press = %d\n",
>> +				xpos, xscale, ypos, yscale, z1, z2, pres);
>> +
>> +	if (pres < st->ts_pressure_threshold) {
>> +		dev_dbg(&idev->dev, "x = %d, y = %d, pressure = %d\n",
>> +					x, y, pres / factor);
>> +		input_report_abs(st->ts_input, ABS_X, x);
>> +		input_report_abs(st->ts_input, ABS_Y, y);
>> +		input_report_abs(st->ts_input, ABS_PRESSURE, pres);
>> +		input_report_key(st->ts_input, BTN_TOUCH, 1);
>> +		input_sync(st->ts_input);
>> +	} else {
>> +		dev_dbg(&idev->dev, "pressure too low: not reporting\n");
>> +	}
>> +
>> +	return 0;
>> +}
>> +
>> +static irqreturn_t at91_adc_interrupt(int irq, void *private)
>> +{
>> +	struct iio_dev *idev = private;
>> +	struct at91_adc_state *st = iio_priv(idev);
>> +	u32 status = at91_adc_readl(st, st->registers->status_register);
>> +	const uint32_t ts_data_irq_mask =
>> +		AT91_ADC_IER_XRDY |
>> +		AT91_ADC_IER_YRDY |
>> +		AT91_ADC_IER_PRDY;
>> +
>> +	if (status & st->registers->drdy_mask)
>> +		handle_adc_eoc_trigger(irq, idev);
>> +
>> +	if (status & AT91_ADC_IER_PEN) {
>> +		at91_adc_writel(st, AT91_ADC_IDR, AT91_ADC_IER_PEN);
>> +		at91_adc_writel(st, AT91_ADC_IER, AT91_ADC_IER_NOPEN |
>> +			ts_data_irq_mask);
>> +		/* Set up period trigger for sampling */
>> +		at91_adc_writel(st, st->registers->trigger_register,
>> +			AT91_ADC_TRGR_MOD_PERIOD_TRIG |
>> +			AT91_ADC_TRGR_TRGPER_(st->ts_sample_period_val));
>> +	} else if (status & AT91_ADC_IER_NOPEN) {
>> +		at91_adc_writel(st, st->registers->trigger_register, 0);
>> +		at91_adc_writel(st, AT91_ADC_IDR, AT91_ADC_IER_NOPEN |
>> +			ts_data_irq_mask);
>> +		at91_adc_writel(st, AT91_ADC_IER, AT91_ADC_IER_PEN);
>> +
>> +		input_report_key(st->ts_input, BTN_TOUCH, 0);
>> +		input_sync(st->ts_input);
>> +	} else if ((status & ts_data_irq_mask) == ts_data_irq_mask) {
>> +		/* Now all touchscreen data is ready */
>> +
>> +		if (status & AT91_ADC_ISR_PENS) {
>> +			/* validate data by pen contact */
>> +			at91_ts_sample(st);
>> +		} else {
>> +			/* triggered by event that is no pen contact, just read
>> +			 * them to clean the interrupt and discard all.
>> +			 */
>> +			at91_adc_readl(st, AT91_ADC_TSXPOSR);
>> +			at91_adc_readl(st, AT91_ADC_TSYPOSR);
>> +			at91_adc_readl(st, AT91_ADC_TSPRESSR);
>> +		}
>> +	}
>>   
>>   	return IRQ_HANDLED;
>>   }
>> @@ -131,6 +279,16 @@ static int at91_adc_channel_init(struct iio_dev *idev)
>>   	struct at91_adc_state *st = iio_priv(idev);
>>   	struct iio_chan_spec *chan_array, *timestamp;
>>   	int bit, idx = 0;
>> +	unsigned long rsvd_mask = 0;
>> +
>> +	/* If touchscreen is enable, then reserve the adc channels */
>> +	if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
>> +		rsvd_mask = CHAN_MASK_TOUCHSCREEN_4WIRE;
>> +	else if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_5WIRE)
>> +		rsvd_mask = CHAN_MASK_TOUCHSCREEN_5WIRE;
>> +
>> +	/* set up the channel mask to reserve touchscreen channels */
>> +	st->channels_mask &= ~rsvd_mask;
>>   
>>   	idev->num_channels = bitmap_weight(&st->channels_mask,
>>   					   st->num_channels) + 1;
>> @@ -479,6 +637,39 @@ static u32 calc_startup_ticks_9x5(u8 startup_time, u32 adc_clk_khz)
>>   
>>   static const struct of_device_id at91_adc_dt_ids[];
>>   
>> +static int at91_adc_probe_dt_ts(struct device_node *node,
>> +	struct at91_adc_state *st, struct device *dev)
>> +{
>> +	int ret;
>> +	u32 prop;
>> +
>> +	ret = of_property_read_u32(node, "atmel,adc-ts-wires", &prop);
>> +	if (ret) {
>> +		dev_info(dev, "ADC Touch screen is disabled.\n");
>> +		return 0;
>> +	}
>> +
>> +	switch (prop) {
>> +	case 4:
>> +	case 5:
>> +		st->touchscreen_type = prop;
>> +		break;
>> +	default:
>> +		dev_err(dev, "Unsupported number of touchscreen wires (%d). Should be 4 or 5.\n", prop);
>> +		return -EINVAL;
>> +	}
>> +
>> +	prop = 0;
>> +	of_property_read_u32(node, "atmel,adc-ts-pressure-threshold", &prop);
>> +	st->ts_pressure_threshold = prop;
>> +	if (st->ts_pressure_threshold) {
>> +		return 0;
>> +	} else {
>> +		dev_err(dev, "Invalid pressure threshold for the touchscreen\n");
>> +		return -EINVAL;
>> +	}
>> +}
>> +
>>   static int at91_adc_probe_dt(struct at91_adc_state *st,
>>   			     struct platform_device *pdev)
>>   {
>> @@ -560,6 +751,12 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
>>   		i++;
>>   	}
>>   
>> +	/* Check if touchscreen is supported. */
>> +	if (st->caps->has_ts)
>> +		return at91_adc_probe_dt_ts(node, st, &idev->dev);
>> +	else
>> +		dev_info(&idev->dev, "not support touchscreen in the adc compatible string.\n");
>> +
>>   	return 0;
>>   
>>   error_ret:
>> @@ -591,6 +788,114 @@ static const struct iio_info at91_adc_info = {
>>   	.read_raw = &at91_adc_read_raw,
>>   };
>>   
>> +/* Touchscreen related functions */
>> +static int atmel_ts_open(struct input_dev *dev)
>> +{
>> +	struct at91_adc_state *st = input_get_drvdata(dev);
>> +
>> +	at91_adc_writel(st, AT91_ADC_IER, AT91_ADC_IER_PEN);
>> +	return 0;
>> +}
>> +
>> +static void atmel_ts_close(struct input_dev *dev)
>> +{
>> +	struct at91_adc_state *st = input_get_drvdata(dev);
>> +
>> +	at91_adc_writel(st, AT91_ADC_IDR, AT91_ADC_IER_PEN);
>> +}
>> +
>> +static int at91_ts_hw_init(struct at91_adc_state *st, u32 adc_clk_khz)
>> +{
>> +	u32 reg = 0, pendbc;
>> +	int i = 0;
>> +
>> +	if (st->touchscreen_type == ATMEL_ADC_TOUCHSCREEN_4WIRE)
>> +		reg = AT91_ADC_TSMR_TSMODE_4WIRE_PRESS;
>> +	else
>> +		reg = AT91_ADC_TSMR_TSMODE_5WIRE;
>> +
>> +	/* a Pen Detect Debounce Time is necessary for the ADC Touch to avoid
>> +	 * pen detect noise.
>> +	 * The formula is : Pen Detect Debounce Time = (2 ^ pendbc) / ADCClock
>> +	 */
>> +	pendbc = round_up(TOUCH_PEN_DETECT_DEBOUNCE_US * adc_clk_khz / 1000, 1);
>> +
>> +	while (pendbc >> ++i)
>> +		;	/* Empty! Find the shift offset */
>> +	if (abs(pendbc - (1 << i)) < abs(pendbc - (1 << (i - 1))))
>> +		pendbc = i;
>> +	else
>> +		pendbc = i - 1;
>> +
>> +	if (st->caps->has_tsmr) {
>> +		reg |= AT91_ADC_TSMR_TSAV_(st->caps->ts_filter_average)
>> +				& AT91_ADC_TSMR_TSAV;
>> +		reg |= AT91_ADC_TSMR_PENDBC_(pendbc) & AT91_ADC_TSMR_PENDBC;
>> +		reg |= AT91_ADC_TSMR_NOTSDMA;
>> +		reg |= AT91_ADC_TSMR_PENDET_ENA;
>> +		reg |= 0x03 << 8;	/* TSFREQ, need bigger than TSAV */
>> +
>> +		at91_adc_writel(st, AT91_ADC_TSMR, reg);
>> +	} else {
>> +		/* TODO: for 9g45 which has no TSMR */
>> +	}
>> +
>> +	/* Change adc internal resistor value for better pen detection,
>> +	 * default value is 100 kOhm.
>> +	 * 0 = 200 kOhm, 1 = 150 kOhm, 2 = 100 kOhm, 3 = 50 kOhm
>> +	 * option only available on ES2 and higher
>> +	 */
>> +	at91_adc_writel(st, AT91_ADC_ACR, st->caps->ts_pen_detect_sensitivity
>> +			& AT91_ADC_ACR_PENDETSENS);
>> +
>> +	/* Sample Peroid Time = (TRGPER + 1) / ADCClock */
>> +	st->ts_sample_period_val = round_up((TOUCH_SAMPLE_PERIOD_US *
>> +			adc_clk_khz / 1000) - 1, 1);
>> +
>> +	return 0;
>> +}
>> +
>> +static int at91_ts_register(struct at91_adc_state *st,
>> +		struct platform_device *pdev)
>> +{
>> +	struct input_dev *input;
>> +	struct iio_dev *idev = iio_priv_to_dev(st);
>> +	int ret;
>> +
>> +	input = input_allocate_device();
>> +	if (!input) {
>> +		dev_err(&idev->dev, "Failed to allocate TS device!\n");
>> +		return -ENOMEM;
>> +	}
>> +
>> +	input->name = DRIVER_NAME;
>> +	input->id.bustype = BUS_HOST;
>> +	input->dev.parent = &pdev->dev;
>> +	input->open = atmel_ts_open;
>> +	input->close = atmel_ts_close;
>> +
>> +	__set_bit(EV_ABS, input->evbit);
>> +	__set_bit(EV_KEY, input->evbit);
>> +	__set_bit(BTN_TOUCH, input->keybit);
>> +	input_set_abs_params(input, ABS_X, 0, (1 << MAX_POS_BITS) - 1, 0, 0);
>> +	input_set_abs_params(input, ABS_Y, 0, (1 << MAX_POS_BITS) - 1, 0, 0);
>> +	input_set_abs_params(input, ABS_PRESSURE, 0, 0xffffff, 0, 0);
>> +
>> +	st->ts_input = input;
>> +	input_set_drvdata(input, st);
>> +
>> +	ret = input_register_device(input);
>> +	if (ret)
>> +		input_free_device(st->ts_input);
>> +
>> +	return ret;
>> +}
>> +
>> +static void at91_ts_unregister(struct at91_adc_state *st)
>> +{
>> +	input_unregister_device(st->ts_input);
>> +}
>> +
>>   static int at91_adc_probe(struct platform_device *pdev)
>>   {
>>   	unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim;
>> @@ -642,7 +947,7 @@ static int at91_adc_probe(struct platform_device *pdev)
>>   	at91_adc_writel(st, AT91_ADC_CR, AT91_ADC_SWRST);
>>   	at91_adc_writel(st, AT91_ADC_IDR, 0xFFFFFFFF);
>>   	ret = request_irq(st->irq,
>> -			  at91_adc_eoc_trigger,
>> +			  at91_adc_interrupt,
>>   			  0,
>>   			  pdev->dev.driver->name,
>>   			  idev);
>> @@ -687,6 +992,10 @@ static int at91_adc_probe(struct platform_device *pdev)
>>   	mstrclk = clk_get_rate(st->clk);
>>   	adc_clk = clk_get_rate(st->adc_clk);
>>   	adc_clk_khz = adc_clk / 1000;
>> +
>> +	dev_dbg(&pdev->dev, "Master clock is set as: %d Hz, adc_clk should set as: %d Hz\n",
>> +		mstrclk, adc_clk);
>> +
>>   	prsc = (mstrclk / (2 * adc_clk)) - 1;
>>   
>>   	if (!st->startup_time) {
>> @@ -723,30 +1032,52 @@ static int at91_adc_probe(struct platform_device *pdev)
>>   	init_waitqueue_head(&st->wq_data_avail);
>>   	mutex_init(&st->lock);
>>   
>> -	ret = at91_adc_buffer_init(idev);
>> -	if (ret < 0) {
>> -		dev_err(&pdev->dev, "Couldn't initialize the buffer.\n");
>> -		goto error_disable_adc_clk;
>> -	}
>> +	/*
>> +	 * Since touch screen will set trigger register as period trigger. So
>> +	 * when touch screen is enabled, then we have to disable hardware
>> +	 * trigger for classic adc.
>> +	 */
>> +	if (!st->touchscreen_type) {
>> +		ret = at91_adc_buffer_init(idev);
>> +		if (ret < 0) {
>> +			dev_err(&pdev->dev, "Couldn't initialize the buffer.\n");
>> +			goto error_disable_adc_clk;
>> +		}
>>   
>> -	ret = at91_adc_trigger_init(idev);
>> -	if (ret < 0) {
>> -		dev_err(&pdev->dev, "Couldn't setup the triggers.\n");
>> -		goto error_unregister_buffer;
>> +		ret = at91_adc_trigger_init(idev);
>> +		if (ret < 0) {
>> +			dev_err(&pdev->dev, "Couldn't setup the triggers.\n");
>> +			at91_adc_buffer_remove(idev);
>> +			goto error_disable_adc_clk;
>> +		}
>> +	} else {
>> +		if (!st->caps->has_tsmr) {
>> +			dev_err(&pdev->dev, "We don't support non-TSMR adc\n");
>> +			goto error_disable_adc_clk;
>> +		}
>> +
>> +		ret = at91_ts_register(st, pdev);
>> +		if (ret)
>> +			goto error_disable_adc_clk;
>> +
>> +		at91_ts_hw_init(st, adc_clk_khz);
>>   	}
>>   
>>   	ret = iio_device_register(idev);
>>   	if (ret < 0) {
>>   		dev_err(&pdev->dev, "Couldn't register the device.\n");
>> -		goto error_remove_triggers;
>> +		goto error_iio_device_register;
>>   	}
>>   
>>   	return 0;
>>   
>> -error_remove_triggers:
>> -	at91_adc_trigger_remove(idev);
>> -error_unregister_buffer:
>> -	at91_adc_buffer_remove(idev);
>> +error_iio_device_register:
>> +	if (!st->touchscreen_type) {
>> +		at91_adc_trigger_remove(idev);
>> +		at91_adc_buffer_remove(idev);
>> +	} else {
>> +		at91_ts_unregister(st);
>> +	}
>>   error_disable_adc_clk:
>>   	clk_disable_unprepare(st->adc_clk);
>>   error_disable_clk:
>> @@ -762,8 +1093,12 @@ static int at91_adc_remove(struct platform_device *pdev)
>>   	struct at91_adc_state *st = iio_priv(idev);
>>   
>>   	iio_device_unregister(idev);
>> -	at91_adc_trigger_remove(idev);
>> -	at91_adc_buffer_remove(idev);
>> +	if (!st->touchscreen_type) {
>> +		at91_adc_trigger_remove(idev);
>> +		at91_adc_buffer_remove(idev);
>> +	} else {
>> +		at91_ts_unregister(st);
>> +	}
>>   	clk_disable_unprepare(st->adc_clk);
>>   	clk_disable_unprepare(st->clk);
>>   	free_irq(st->irq, idev);
>> @@ -786,6 +1121,7 @@ static struct at91_adc_caps at91sam9260_caps = {
>>   };
>>   
>>   static struct at91_adc_caps at91sam9g45_caps = {
>> +	.has_ts = true,
>>   	.calc_startup_ticks = calc_startup_ticks_9260,	/* same as 9260 */
>>   	.num_channels = 8,
>>   	.registers = {
>> @@ -799,6 +1135,10 @@ static struct at91_adc_caps at91sam9g45_caps = {
>>   };
>>   
>>   static struct at91_adc_caps at91sam9x5_caps = {
>> +	.has_ts = true,
>> +	.has_tsmr = true,
>> +	.ts_filter_average = 3,
>> +	.ts_pen_detect_sensitivity = 2,
>>   	.calc_startup_ticks = calc_startup_ticks_9x5,
>>   	.num_channels = 12,
>>   	.registers = {
>> @@ -825,7 +1165,7 @@ static struct platform_driver at91_adc_driver = {
>>   	.probe = at91_adc_probe,
>>   	.remove = at91_adc_remove,
>>   	.driver = {
>> -		   .name = "at91_adc",
>> +		   .name = DRIVER_NAME,
>>   		   .of_match_table = of_match_ptr(at91_adc_dt_ids),
>>   	},
>>   };
>>

^ permalink raw reply

* [Patch v2][ 15/37] Input: tsc2007: Add device tree support.
From: Denis Carikli @ 2013-10-17 15:02 UTC (permalink / raw)
  To: Sascha Hauer
  Cc: linux-arm-kernel, Eric Bénard, Denis Carikli, Rob Herring,
	Pawel Moll, Mark Rutland, Stephen Warren, Ian Campbell,
	devicetree, Dmitry Torokhov, linux-input
In-Reply-To: <1382022155-21954-1-git-send-email-denis@eukrea.com>

Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Ian Campbell <ijc+devicetree@hellion.org.uk>
Cc: devicetree@vger.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Cc: Sascha Hauer <kernel@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: Eric Bénard <eric@eukrea.com>
Signed-off-by: Denis Carikli <denis@eukrea.com>
---
 .../bindings/input/touchscreen/tsc2007.txt         |   44 +++++
 drivers/input/touchscreen/tsc2007.c                |  200 +++++++++++++++-----
 2 files changed, 201 insertions(+), 43 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt

diff --git a/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
new file mode 100644
index 0000000..d67b33f
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/tsc2007.txt
@@ -0,0 +1,44 @@
+* Texas Instruments tsc2007 touchscreen controller
+
+Required properties:
+- compatible: must be "ti,tsc2007".
+- reg: I2C address of the chip.
+- pinctrl-0: Should specify pin control groups used for this controller
+  (see pinctrl bindings[0]).
+- pinctrl-names: Should contain only one value - "default"
+  (see pinctrl bindings[0]).
+- interrupt-parent: the phandle for the interrupt controller
+  (see interrupt binding[1]).
+- interrupts: interrupt to which the chip is connected
+  (see interrupt binding[1]).
+- x-plate-ohms: X-plate resistance in ohms.
+
+Optional properties:
+- gpios: the interrupt gpio the chip is connected to (trough the penirq pin)
+  (see GPIO binding[2] for more details).
+- max-rt: maximum pressure.
+- fuzzy: specifies the fuzz value that is used to filter noise from the event
+  stream.
+- poll-period: how much time to wait(in millisecond) before reading again the
+  values from the tsc2007.
+
+[0]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
+[1]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt
+[2]: Documentation/devicetree/bindings/gpio/gpio.txt
+
+Example:
+	&i2c1 {
+		/* ... */
+		tsc2007@49 {
+			compatible = "ti,tsc2007";
+			reg = <0x49>;
+			pinctrl-names = "default";
+			pinctrl-0 = <&pinctrl_tsc2007_1>;
+			interrupt-parent = <&gpio4>;
+			interrupts = <0x0 0x8>;
+			gpios = <&gpio4 0 0>;
+			x-plate-ohms = <180>;
+		};
+
+		/* ... */
+	};
diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
index 0b67ba4..b1ab6c0 100644
--- a/drivers/input/touchscreen/tsc2007.c
+++ b/drivers/input/touchscreen/tsc2007.c
@@ -26,6 +26,9 @@
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
 #include <linux/i2c/tsc2007.h>
+#include <linux/of_device.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
 
 #define TSC2007_MEASURE_TEMP0		(0x0 << 4)
 #define TSC2007_MEASURE_AUX		(0x2 << 4)
@@ -74,7 +77,10 @@ struct tsc2007 {
 	u16			max_rt;
 	unsigned long		poll_delay;
 	unsigned long		poll_period;
+	int			fuzzy;
+	char			of;
 
+	unsigned		gpio;
 	int			irq;
 
 	wait_queue_head_t	wait;
@@ -84,6 +90,14 @@ struct tsc2007 {
 	void			(*clear_penirq)(void);
 };
 
+static int tsc2007_get_pendown_state_dt(struct tsc2007  *ts)
+{
+	if (gpio_is_valid(ts->gpio))
+		return !gpio_get_value(ts->gpio);
+	else
+		return true;
+}
+
 static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
 {
 	s32 data;
@@ -158,6 +172,9 @@ static bool tsc2007_is_pen_down(struct tsc2007 *ts)
 	 * to fall back on the pressure reading.
 	 */
 
+	if (ts->of)
+		return tsc2007_get_pendown_state_dt(ts);
+
 	if (!ts->get_pendown_state)
 		return true;
 
@@ -175,10 +192,10 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 
 		/* pen is down, continue with the measurement */
 		tsc2007_read_values(ts, &tc);
-
 		rt = tsc2007_calculate_pressure(ts, &tc);
 
-		if (rt == 0 && !ts->get_pendown_state) {
+		if ((ts->of && rt == 0 && ts->gpio < 0) ||
+			(!ts->of && rt == 0 && !ts->get_pendown_state)) {
 			/*
 			 * If pressure reported is 0 and we don't have
 			 * callback to check pendown state, we have to
@@ -198,7 +215,6 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 			input_report_abs(input, ABS_PRESSURE, rt);
 
 			input_sync(input);
-
 		} else {
 			/*
 			 * Sample found inconsistent by debouncing or pressure is
@@ -217,7 +233,6 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
 	input_report_key(input, BTN_TOUCH, 0);
 	input_report_abs(input, ABS_PRESSURE, 0);
 	input_sync(input);
-
 	if (ts->clear_penirq)
 		ts->clear_penirq();
 
@@ -228,11 +243,17 @@ static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
 {
 	struct tsc2007 *ts = handle;
 
-	if (!ts->get_pendown_state || likely(ts->get_pendown_state()))
-		return IRQ_WAKE_THREAD;
+	if (!ts->of) {
+		if (!ts->get_pendown_state || likely(ts->get_pendown_state()))
+			return IRQ_WAKE_THREAD;
 
-	if (ts->clear_penirq)
-		ts->clear_penirq();
+		if (ts->clear_penirq)
+			ts->clear_penirq();
+	} else {
+		if ((!gpio_is_valid(ts->gpio)) ||
+		    likely(tsc2007_get_pendown_state_dt(ts)))
+			return IRQ_WAKE_THREAD;
+	}
 
 	return IRQ_HANDLED;
 }
@@ -273,34 +294,64 @@ static void tsc2007_close(struct input_dev *input_dev)
 	tsc2007_stop(ts);
 }
 
-static int tsc2007_probe(struct i2c_client *client,
-				   const struct i2c_device_id *id)
+#ifdef CONFIG_OF
+static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts,
+			    struct device_node *np)
 {
-	struct tsc2007 *ts;
-	struct tsc2007_platform_data *pdata = client->dev.platform_data;
-	struct input_dev *input_dev;
-	int err;
-
-	if (!pdata) {
-		dev_err(&client->dev, "platform data is required!\n");
+	int err = 0;
+	u32 val32;
+	u64 val64;
+
+	if (!of_property_read_u32(np, "max-rt", &val32))
+		ts->max_rt = val32;
+	else
+		ts->max_rt = MAX_12BIT;
+
+	if (!of_property_read_u32(np, "fuzzy", &val32))
+		ts->fuzzy = val32;
+
+	if (!of_property_read_u64(np, "poll-period", &val64))
+		ts->poll_period = val64;
+	else
+		ts->poll_period = 1;
+
+	if (!of_property_read_u32(np, "x-plate-ohms", &val32)) {
+		ts->x_plate_ohms = val32;
+	} else {
+		dev_err(&client->dev,
+			"x-plate-ohms is not set up in the devicetree."
+			" (err %d).", err);
 		return -EINVAL;
 	}
 
-	if (!i2c_check_functionality(client->adapter,
-				     I2C_FUNC_SMBUS_READ_WORD_DATA))
-		return -EIO;
+	ts->gpio = of_get_gpio(np, 0);
+	if (!gpio_is_valid(ts->gpio))
+		dev_err(&client->dev, "GPIO not found "
+			"(of_get_gpio returned %d)\n", ts->gpio);
 
-	ts = kzalloc(sizeof(struct tsc2007), GFP_KERNEL);
-	input_dev = input_allocate_device();
-	if (!ts || !input_dev) {
-		err = -ENOMEM;
-		goto err_free_mem;
-	}
+	/* Used to detect if it is probed trough the device tree,
+	 * in order to be able to use that information in the IRQ handler.
+	 */
+	ts->of = 1;
 
-	ts->client = client;
-	ts->irq = client->irq;
-	ts->input = input_dev;
-	init_waitqueue_head(&ts->wait);
+	return 0;
+}
+#else
+static int tsc2007_probe_dt(struct i2c_client *client, struct tsc2007 *ts,
+			    struct device_node *np)
+{
+	return -ENODEV;
+}
+#endif
+
+static int tsc2007_probe_pdev(struct i2c_client *client, struct tsc2007 *ts,
+			      struct tsc2007_platform_data *pdata,
+			      const struct i2c_device_id *id)
+{
+	if (!pdata) {
+		dev_err(&client->dev, "platform data is required!\n");
+		return -EINVAL;
+	}
 
 	ts->model             = pdata->model;
 	ts->x_plate_ohms      = pdata->x_plate_ohms;
@@ -309,13 +360,59 @@ static int tsc2007_probe(struct i2c_client *client,
 	ts->poll_period       = pdata->poll_period ? : 1;
 	ts->get_pendown_state = pdata->get_pendown_state;
 	ts->clear_penirq      = pdata->clear_penirq;
+	ts->fuzzy             = pdata->fuzzy;
 
 	if (pdata->x_plate_ohms == 0) {
 		dev_err(&client->dev, "x_plate_ohms is not set up in platform data");
-		err = -EINVAL;
+		return -EINVAL;
+	}
+
+	/* Used to detect if it is probed trough the device tree,
+	 * in order to be able to use that information in the IRQ handler.
+	 */
+	ts->of = 0;
+
+	return 0;
+}
+
+static int tsc2007_probe(struct i2c_client *client,
+			 const struct i2c_device_id *id)
+{
+	struct device_node *np = client->dev.of_node;
+	struct tsc2007_platform_data *pdata = client->dev.platform_data;
+	struct tsc2007 *ts;
+	struct input_dev *input_dev;
+	int err = 0;
+
+	ts = kzalloc(sizeof(struct tsc2007), GFP_KERNEL);
+	if (!ts)
+		return -ENOMEM;
+
+	if (np)
+		err = tsc2007_probe_dt(client, ts, np);
+	else
+		err = tsc2007_probe_pdev(client, ts, pdata, id);
+
+	if (err)
+		goto err_free_mem;
+
+	if (!i2c_check_functionality(client->adapter,
+				     I2C_FUNC_SMBUS_READ_WORD_DATA)) {
+		err = -EIO;
 		goto err_free_mem;
 	}
 
+	input_dev = input_allocate_device();
+	if (!input_dev) {
+		err = -ENOMEM;
+		goto err_free_input;
+	};
+
+	ts->client = client;
+	ts->irq = client->irq;
+	ts->input = input_dev;
+	init_waitqueue_head(&ts->wait);
+
 	snprintf(ts->phys, sizeof(ts->phys),
 		 "%s/input0", dev_name(&client->dev));
 
@@ -331,19 +428,21 @@ static int tsc2007_probe(struct i2c_client *client,
 	input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 	input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
 
-	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, pdata->fuzzx, 0);
-	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, pdata->fuzzy, 0);
+	input_set_abs_params(input_dev, ABS_X, 0, MAX_12BIT, ts->fuzzy, 0);
+	input_set_abs_params(input_dev, ABS_Y, 0, MAX_12BIT, ts->fuzzy, 0);
 	input_set_abs_params(input_dev, ABS_PRESSURE, 0, MAX_12BIT,
-			pdata->fuzzz, 0);
+			     ts->fuzzy, 0);
 
-	if (pdata->init_platform_hw)
-		pdata->init_platform_hw();
+	if (!np) {
+		if (pdata->init_platform_hw)
+			pdata->init_platform_hw();
+	}
 
 	err = request_threaded_irq(ts->irq, tsc2007_hard_irq, tsc2007_soft_irq,
 				   IRQF_ONESHOT, client->dev.driver->name, ts);
 	if (err < 0) {
 		dev_err(&client->dev, "irq %d busy?\n", ts->irq);
-		goto err_free_mem;
+		goto err_free_input;
 	}
 
 	tsc2007_stop(ts);
@@ -358,23 +457,29 @@ static int tsc2007_probe(struct i2c_client *client,
 
  err_free_irq:
 	free_irq(ts->irq, ts);
-	if (pdata->exit_platform_hw)
-		pdata->exit_platform_hw();
- err_free_mem:
+	if (!np) {
+		if (pdata->exit_platform_hw)
+			pdata->exit_platform_hw();
+	}
+ err_free_input:
 	input_free_device(input_dev);
+ err_free_mem:
 	kfree(ts);
 	return err;
 }
 
 static int tsc2007_remove(struct i2c_client *client)
 {
+	struct device_node *np = client->dev.of_node;
 	struct tsc2007	*ts = i2c_get_clientdata(client);
 	struct tsc2007_platform_data *pdata = client->dev.platform_data;
 
 	free_irq(ts->irq, ts);
 
-	if (pdata->exit_platform_hw)
-		pdata->exit_platform_hw();
+	if (!np) {
+		if (pdata->exit_platform_hw)
+			pdata->exit_platform_hw();
+	}
 
 	input_unregister_device(ts->input);
 	kfree(ts);
@@ -389,10 +494,19 @@ static const struct i2c_device_id tsc2007_idtable[] = {
 
 MODULE_DEVICE_TABLE(i2c, tsc2007_idtable);
 
+#ifdef CONFIG_OF
+static const struct of_device_id tsc2007_of_match[] = {
+	{ .compatible = "ti,tsc2007" },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, tsc2007_of_match);
+#endif
+
 static struct i2c_driver tsc2007_driver = {
 	.driver = {
 		.owner	= THIS_MODULE,
-		.name	= "tsc2007"
+		.name	= "tsc2007",
+		.of_match_table = of_match_ptr(tsc2007_of_match),
 	},
 	.id_table	= tsc2007_idtable,
 	.probe		= tsc2007_probe,
-- 
1.7.9.5

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

^ permalink raw reply related


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