From: Rob Herring <robherring2@gmail.com>
To: Denis Carikli <denis@eukrea.com>, Sascha Hauer <kernel@pengutronix.de>
Cc: "Mark Rutland" <mark.rutland@arm.com>,
devicetree@vger.kernel.org,
"Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Pawel Moll" <pawel.moll@arm.com>,
"Stephen Warren" <swarren@wwwdotorg.org>,
"Ian Campbell" <ijc+devicetree@hellion.org.uk>,
"Rob Herring" <rob.herring@calxeda.com>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Eric Bénard" <eric@eukrea.com>,
linux-input@vger.kernel.org, "Shawn Guo" <shawn.guo@linaro.org>,
linux-arm-kernel@lists.infradead.org,
"Lothar Waßmann" <LW@KARO-electronics.de>
Subject: Re: [PATCHv5][ 1/4] Input: tsc2007: Add device tree support.
Date: Wed, 23 Oct 2013 17:18:27 -0500 [thread overview]
Message-ID: <52684B33.6040109@gmail.com> (raw)
In-Reply-To: <1382530220-27881-1-git-send-email-denis@eukrea.com>
On 10/23/2013 07:10 AM, Denis Carikli wrote:
> 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: Lothar Waßmann <LW@KARO-electronics.de>
> Cc: Eric Bénard <eric@eukrea.com>
> Signed-off-by: Denis Carikli <denis@eukrea.com>
> ---
> ChangeLog v4->v5:
> - Most of the "if (ts->of)" were replaced by wrapping them in the
> tsc2007_is_pen_down_valid and tsc2007_is_pen_down functions.
> - Some whitespace cleanups.
> - The devm_kzalloc call was fixed to make it compile.
> ---
> .../bindings/input/touchscreen/tsc2007.txt | 44 +++++
> drivers/input/touchscreen/tsc2007.c | 194 +++++++++++++++-----
> 2 files changed, 197 insertions(+), 41 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..fadd3f6
> --- /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]).
I'm confused why an i2c slave needs pinctl binding?
> +- interrupt-parent: the phandle for the interrupt controller
> + (see interrupt binding[1]).
> +- interrupts: interrupt to which the chip is connected
> + (see interrupt binding[1]).
> +- ti,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>;
> + ti,x-plate-ohms = <180>;
> + };
> +
> + /* ... */
> + };
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 0b67ba4..0625fe1 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,11 @@ struct tsc2007 {
> void (*clear_penirq)(void);
> };
>
> +static int tsc2007_get_pendown_state_dt(struct tsc2007 *ts)
> +{
> + return !gpio_get_value(ts->gpio);
> +}
> +
> static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
> {
> s32 data;
> @@ -142,6 +153,14 @@ static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
> return rt;
> }
>
> +static bool tsc2007_is_pen_down_valid(struct tsc2007 *ts)
> +{
> + if (ts->of)
> + return gpio_is_valid(ts->gpio);
> + else
> + return ts->get_pendown_state ? true : false;
> +}
> +
> static bool tsc2007_is_pen_down(struct tsc2007 *ts)
> {
> /*
> @@ -158,10 +177,13 @@ static bool tsc2007_is_pen_down(struct tsc2007 *ts)
> * to fall back on the pressure reading.
> */
>
> - if (!ts->get_pendown_state)
> + if (!tsc2007_is_pen_down_valid(ts))
> return true;
>
> - return ts->get_pendown_state();
> + if (ts->of)
> + return tsc2007_get_pendown_state_dt(ts);
> + else
> + return ts->get_pendown_state();
> }
>
> static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
> @@ -178,7 +200,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>
> rt = tsc2007_calculate_pressure(ts, &tc);
>
> - if (rt == 0 && !ts->get_pendown_state) {
> + if(!rt && !tsc2007_is_pen_down_valid(ts)) {
> /*
> * If pressure reported is 0 and we don't have
> * callback to check pendown state, we have to
> @@ -228,7 +250,7 @@ static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
> {
> struct tsc2007 *ts = handle;
>
> - if (!ts->get_pendown_state || likely(ts->get_pendown_state()))
> + if (tsc2007_is_pen_down(ts))
> return IRQ_WAKE_THREAD;
>
> if (ts->clear_penirq)
> @@ -273,34 +295,65 @@ 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;
These functions don't overwrite the value if the property isn't present.
So you can set the values to the defaults and just pass the variable
(i.e. ts->max_rt) to of_property_read_u32 directly.
Rob
--
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
WARNING: multiple messages have this Message-ID (diff)
From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5][ 1/4] Input: tsc2007: Add device tree support.
Date: Wed, 23 Oct 2013 17:18:27 -0500 [thread overview]
Message-ID: <52684B33.6040109@gmail.com> (raw)
In-Reply-To: <1382530220-27881-1-git-send-email-denis@eukrea.com>
On 10/23/2013 07:10 AM, Denis Carikli wrote:
> 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 at vger.kernel.org
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input at vger.kernel.org
> Cc: Sascha Hauer <kernel@pengutronix.de>
> Cc: linux-arm-kernel at lists.infradead.org
> Cc: Lothar Wa?mann <LW@KARO-electronics.de>
> Cc: Eric B?nard <eric@eukrea.com>
> Signed-off-by: Denis Carikli <denis@eukrea.com>
> ---
> ChangeLog v4->v5:
> - Most of the "if (ts->of)" were replaced by wrapping them in the
> tsc2007_is_pen_down_valid and tsc2007_is_pen_down functions.
> - Some whitespace cleanups.
> - The devm_kzalloc call was fixed to make it compile.
> ---
> .../bindings/input/touchscreen/tsc2007.txt | 44 +++++
> drivers/input/touchscreen/tsc2007.c | 194 +++++++++++++++-----
> 2 files changed, 197 insertions(+), 41 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..fadd3f6
> --- /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]).
I'm confused why an i2c slave needs pinctl binding?
> +- interrupt-parent: the phandle for the interrupt controller
> + (see interrupt binding[1]).
> +- interrupts: interrupt to which the chip is connected
> + (see interrupt binding[1]).
> +- ti,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 at 49 {
> + compatible = "ti,tsc2007";
> + reg = <0x49>;
> + pinctrl-names = "default";
> + pinctrl-0 = <&pinctrl_tsc2007_1>;
> + interrupt-parent = <&gpio4>;
> + interrupts = <0x0 0x8>;
> + gpios = <&gpio4 0 0>;
> + ti,x-plate-ohms = <180>;
> + };
> +
> + /* ... */
> + };
> diff --git a/drivers/input/touchscreen/tsc2007.c b/drivers/input/touchscreen/tsc2007.c
> index 0b67ba4..0625fe1 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,11 @@ struct tsc2007 {
> void (*clear_penirq)(void);
> };
>
> +static int tsc2007_get_pendown_state_dt(struct tsc2007 *ts)
> +{
> + return !gpio_get_value(ts->gpio);
> +}
> +
> static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
> {
> s32 data;
> @@ -142,6 +153,14 @@ static u32 tsc2007_calculate_pressure(struct tsc2007 *tsc, struct ts_event *tc)
> return rt;
> }
>
> +static bool tsc2007_is_pen_down_valid(struct tsc2007 *ts)
> +{
> + if (ts->of)
> + return gpio_is_valid(ts->gpio);
> + else
> + return ts->get_pendown_state ? true : false;
> +}
> +
> static bool tsc2007_is_pen_down(struct tsc2007 *ts)
> {
> /*
> @@ -158,10 +177,13 @@ static bool tsc2007_is_pen_down(struct tsc2007 *ts)
> * to fall back on the pressure reading.
> */
>
> - if (!ts->get_pendown_state)
> + if (!tsc2007_is_pen_down_valid(ts))
> return true;
>
> - return ts->get_pendown_state();
> + if (ts->of)
> + return tsc2007_get_pendown_state_dt(ts);
> + else
> + return ts->get_pendown_state();
> }
>
> static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
> @@ -178,7 +200,7 @@ static irqreturn_t tsc2007_soft_irq(int irq, void *handle)
>
> rt = tsc2007_calculate_pressure(ts, &tc);
>
> - if (rt == 0 && !ts->get_pendown_state) {
> + if(!rt && !tsc2007_is_pen_down_valid(ts)) {
> /*
> * If pressure reported is 0 and we don't have
> * callback to check pendown state, we have to
> @@ -228,7 +250,7 @@ static irqreturn_t tsc2007_hard_irq(int irq, void *handle)
> {
> struct tsc2007 *ts = handle;
>
> - if (!ts->get_pendown_state || likely(ts->get_pendown_state()))
> + if (tsc2007_is_pen_down(ts))
> return IRQ_WAKE_THREAD;
>
> if (ts->clear_penirq)
> @@ -273,34 +295,65 @@ 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;
These functions don't overwrite the value if the property isn't present.
So you can set the values to the defaults and just pass the variable
(i.e. ts->max_rt) to of_property_read_u32 directly.
Rob
next prev parent reply other threads:[~2013-10-23 22:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-23 12:10 [PATCHv5][ 1/4] Input: tsc2007: Add device tree support Denis Carikli
2013-10-23 12:10 ` Denis Carikli
[not found] ` <1382530220-27881-1-git-send-email-denis-fO0SIAKYzcbQT0dZR+AlfA@public.gmane.org>
2013-10-23 12:10 ` [PATCHv5][ 2/4] ARM: dts: cpuimx51 Add touchscreen support Denis Carikli
2013-10-23 12:10 ` Denis Carikli
2013-10-23 12:10 ` [PATCHv5][ 3/4] ARM: dts: cpuimx35 " Denis Carikli
2013-10-23 12:10 ` Denis Carikli
2013-10-23 12:10 ` [PATCHv5][ 4/4] ARM: imx_v6_v7_defconfig: Enable tsc2007 support Denis Carikli
2013-10-23 12:10 ` Denis Carikli
2013-10-23 22:18 ` Rob Herring [this message]
2013-10-23 22:18 ` [PATCHv5][ 1/4] Input: tsc2007: Add device tree support Rob Herring
2013-10-24 6:51 ` Lothar Waßmann
2013-10-24 6:51 ` Lothar Waßmann
2013-10-24 7:46 ` Thierry Reding
2013-10-24 7:46 ` Thierry Reding
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52684B33.6040109@gmail.com \
--to=robherring2@gmail.com \
--cc=LW@KARO-electronics.de \
--cc=denis@eukrea.com \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=eric@eukrea.com \
--cc=ijc+devicetree@hellion.org.uk \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=rob.herring@calxeda.com \
--cc=shawn.guo@linaro.org \
--cc=swarren@wwwdotorg.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.