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:
pgpV6GL1BQODg.pgp
Description: PGP signature