From: Thierry Reding <thierry.reding@gmail.com>
To: "Lothar Waßmann" <LW@KARO-electronics.de>
Cc: "Rob Herring" <robherring2@gmail.com>,
"Denis Carikli" <denis@eukrea.com>,
"Sascha Hauer" <kernel@pengutronix.de>,
"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>,
"Eric Bénard" <eric@eukrea.com>,
linux-input@vger.kernel.org, "Shawn Guo" <shawn.guo@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCHv5][ 1/4] Input: tsc2007: Add device tree support.
Date: Thu, 24 Oct 2013 09:46:16 +0200 [thread overview]
Message-ID: <20131024074615.GC9403@ulmo.nvidia.com> (raw)
In-Reply-To: <20131024085150.11a81974@ipc1.ka-ro>
[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]
On Thu, Oct 24, 2013 at 08:51:50AM +0200, Lothar Waßmann wrote:
> Hi,
>
> Rob Herring wrote:
> > On 10/23/2013 07:10 AM, Denis Carikli wrote:
> [...]
> > > 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?
> >
> for the pendetect GPIO.
Shouldn't that be done transparently to users of the GPIO API? I was
under the impression that gpio_request() would set everything up (or
return an error if unable to do so) so that the GPIO can be used,
including any required pinmuxing.
> [...]
> > > 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;
> [...]
> > > @@ -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.
> >
> Not quite. Since max_rt is an u16 you can't pass it to
> of_property_read_u32(). And using of_property_read_u16() requires the
> abominable DT notation: "/bits/ 16 <value>;"
In that case perhaps you need to check that whatever u32 value you read
from DT is actually in the expected range before assigning to u16?
Thierry
[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: thierry.reding@gmail.com (Thierry Reding)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv5][ 1/4] Input: tsc2007: Add device tree support.
Date: Thu, 24 Oct 2013 09:46:16 +0200 [thread overview]
Message-ID: <20131024074615.GC9403@ulmo.nvidia.com> (raw)
In-Reply-To: <20131024085150.11a81974@ipc1.ka-ro>
On Thu, Oct 24, 2013 at 08:51:50AM +0200, Lothar Wa?mann wrote:
> Hi,
>
> Rob Herring wrote:
> > On 10/23/2013 07:10 AM, Denis Carikli wrote:
> [...]
> > > 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?
> >
> for the pendetect GPIO.
Shouldn't that be done transparently to users of the GPIO API? I was
under the impression that gpio_request() would set everything up (or
return an error if unable to do so) so that the GPIO can be used,
including any required pinmuxing.
> [...]
> > > 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;
> [...]
> > > @@ -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.
> >
> Not quite. Since max_rt is an u16 you can't pass it to
> of_property_read_u32(). And using of_property_read_u16() requires the
> abominable DT notation: "/bits/ 16 <value>;"
In that case perhaps you need to check that whatever u32 value you read
from DT is actually in the expected range before assigning to u16?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131024/b4fd58a4/attachment-0001.sig>
next prev parent reply other threads:[~2013-10-24 7:46 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 ` [PATCHv5][ 1/4] Input: tsc2007: Add device tree support Rob Herring
2013-10-23 22:18 ` 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 [this message]
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=20131024074615.GC9403@ulmo.nvidia.com \
--to=thierry.reding@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=robherring2@gmail.com \
--cc=shawn.guo@linaro.org \
--cc=swarren@wwwdotorg.org \
/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.