linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] input: touchscreen: add OF match table for ads7846
@ 2011-06-10  2:28 Barry Song
  2011-06-13  5:15 ` Grant Likely
  0 siblings, 1 reply; 4+ messages in thread
From: Barry Song @ 2011-06-10  2:28 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, Barry Song, Grant Likely, Thomas Chou

The current ads7846 has no OF match table. The method used is by applying a heuristic (of_modalias_node) which tries to name the device in a way that will match an existing device driver.
This patch adds explicit OF match table for ads7846, then the normal device tree match behaviour will always work.
It has been tested on PRIMA2 EVB board of CSR with a SPI's child node like the below:
ts@0 {
	compatible = "ti,ads7845";
	reg = <0x0>;
	spi-max-frequency = <31250>;
        interrupts = <90>;
};

Signed-off-by: Barry Song <21cnbao@gmail.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
cc: Thomas Chou <thomas@wytron.com.tw>
---
 drivers/input/touchscreen/ads7846.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
index 5196861..643138b 100644
--- a/drivers/input/touchscreen/ads7846.c
+++ b/drivers/input/touchscreen/ads7846.c
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/pm.h>
 #include <linux/gpio.h>
+#include <linux/of.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 #include <linux/regulator/consumer.h>
@@ -1425,12 +1426,25 @@ static int __devexit ads7846_remove(struct spi_device *spi)
 	return 0;
 }
 
+#if defined(CONFIG_OF)
+static struct of_device_id ads7846_spi_of_match_table[] __devinitdata = {
+	{ .compatible = "ti,ads7846", },
+	{ .compatible = "ti,ads7845", },
+	{ .compatible = "ti,ads7843", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, ads7846_spi_of_match_table);
+#endif
+
 static struct spi_driver ads7846_driver = {
 	.driver = {
 		.name	= "ads7846",
 		.bus	= &spi_bus_type,
 		.owner	= THIS_MODULE,
 		.pm	= &ads7846_pm,
+#if defined(CONFIG_OF)
+		.of_match_table = ads7846_spi_of_match_table,
+#endif
 	},
 	.probe		= ads7846_probe,
 	.remove		= __devexit_p(ads7846_remove),
-- 
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog

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

* Re: [PATCH] input: touchscreen: add OF match table for ads7846
  2011-06-10  2:28 [PATCH] input: touchscreen: add OF match table for ads7846 Barry Song
@ 2011-06-13  5:15 ` Grant Likely
  2011-06-13  8:15   ` Barry Song
  0 siblings, 1 reply; 4+ messages in thread
From: Grant Likely @ 2011-06-13  5:15 UTC (permalink / raw)
  To: Barry Song; +Cc: dmitry.torokhov, linux-input, Barry Song, Thomas Chou

On Thu, Jun 9, 2011 at 8:28 PM, Barry Song <Baohua.Song@csr.com> wrote:
> The current ads7846 has no OF match table. The method used is by applying a heuristic (of_modalias_node) which tries to name the device in a way that will match an existing device driver.
> This patch adds explicit OF match table for ads7846, then the normal device tree match behaviour will always work.
> It has been tested on PRIMA2 EVB board of CSR with a SPI's child node like the below:
> ts@0 {
>        compatible = "ti,ads7845";
>        reg = <0x0>;
>        spi-max-frequency = <31250>;
>        interrupts = <90>;
> };
>
> Signed-off-by: Barry Song <21cnbao@gmail.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> cc: Thomas Chou <thomas@wytron.com.tw>
> ---
>  drivers/input/touchscreen/ads7846.c |   14 ++++++++++++++

There should also be documentation for the new binding added to
Documentation/devicetree/bindings for the new compatible strings.

>  1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
> index 5196861..643138b 100644
> --- a/drivers/input/touchscreen/ads7846.c
> +++ b/drivers/input/touchscreen/ads7846.c
> @@ -28,6 +28,7 @@
>  #include <linux/slab.h>
>  #include <linux/pm.h>
>  #include <linux/gpio.h>
> +#include <linux/of.h>
>  #include <linux/spi/spi.h>
>  #include <linux/spi/ads7846.h>
>  #include <linux/regulator/consumer.h>
> @@ -1425,12 +1426,25 @@ static int __devexit ads7846_remove(struct spi_device *spi)
>        return 0;
>  }
>
> +#if defined(CONFIG_OF)
> +static struct of_device_id ads7846_spi_of_match_table[] __devinitdata = {
> +       { .compatible = "ti,ads7846", },
> +       { .compatible = "ti,ads7845", },
> +       { .compatible = "ti,ads7843", },
> +       {},
> +};
> +MODULE_DEVICE_TABLE(of, ads7846_spi_of_match_table);

#else
#define ads7846_spi_of_match_table NULL

> +#endif
> +
>  static struct spi_driver ads7846_driver = {
>        .driver = {
>                .name   = "ads7846",
>                .bus    = &spi_bus_type,
>                .owner  = THIS_MODULE,
>                .pm     = &ads7846_pm,
> +#if defined(CONFIG_OF)
> +               .of_match_table = ads7846_spi_of_match_table,
> +#endif

With the #else  block added above, you can drop the #if/#endif
protection around of_match_table.

Otherwise:

Acked-by: Grant Likely <grant.likely@secretlab.ca>
--
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	[flat|nested] 4+ messages in thread

* Re: [PATCH] input: touchscreen: add OF match table for ads7846
  2011-06-13  5:15 ` Grant Likely
@ 2011-06-13  8:15   ` Barry Song
  2011-06-13 13:24     ` Grant Likely
  0 siblings, 1 reply; 4+ messages in thread
From: Barry Song @ 2011-06-13  8:15 UTC (permalink / raw)
  To: Grant Likely
  Cc: dmitry.torokhov, linux-input, Thomas Chou, devicetree-discuss,
	Zhiwu Song, uclinux-dist-devel

Hi Grant,
Thanks.

2011/6/13 Grant Likely <grant.likely@secretlab.ca>:
> On Thu, Jun 9, 2011 at 8:28 PM, Barry Song <Baohua.Song@csr.com> wrote:
>> The current ads7846 has no OF match table. The method used is by applying a heuristic (of_modalias_node) which tries to name the device in a way that will match an existing device driver.
>> This patch adds explicit OF match table for ads7846, then the normal device tree match behaviour will always work.
>> It has been tested on PRIMA2 EVB board of CSR with a SPI's child node like the below:
>> ts@0 {
>>        compatible = "ti,ads7845";
>>        reg = <0x0>;
>>        spi-max-frequency = <31250>;
>>        interrupts = <90>;
>> };
>>
>> Signed-off-by: Barry Song <21cnbao@gmail.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> cc: Thomas Chou <thomas@wytron.com.tw>
>> ---
>>  drivers/input/touchscreen/ads7846.c |   14 ++++++++++++++
>
> There should also be documentation for the new binding added to
> Documentation/devicetree/bindings for the new compatible strings.

Which directory do you think is the best to place this document? or do
we build a new diretory named
Documentation/devicetree/bindings/input/touchscreen/ ?
The dir Documentation/devicetree/bindings seems to be for spi host,
not for spi clients.

>
>>  1 files changed, 14 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c
>> index 5196861..643138b 100644
>> --- a/drivers/input/touchscreen/ads7846.c
>> +++ b/drivers/input/touchscreen/ads7846.c
>> @@ -28,6 +28,7 @@
>>  #include <linux/slab.h>
>>  #include <linux/pm.h>
>>  #include <linux/gpio.h>
>> +#include <linux/of.h>
>>  #include <linux/spi/spi.h>
>>  #include <linux/spi/ads7846.h>
>>  #include <linux/regulator/consumer.h>
>> @@ -1425,12 +1426,25 @@ static int __devexit ads7846_remove(struct spi_device *spi)
>>        return 0;
>>  }
>>
>> +#if defined(CONFIG_OF)
>> +static struct of_device_id ads7846_spi_of_match_table[] __devinitdata = {
>> +       { .compatible = "ti,ads7846", },
>> +       { .compatible = "ti,ads7845", },
>> +       { .compatible = "ti,ads7843", },
>> +       {},
>> +};
>> +MODULE_DEVICE_TABLE(of, ads7846_spi_of_match_table);
>
> #else
> #define ads7846_spi_of_match_table NULL
>
>> +#endif
>> +
>>  static struct spi_driver ads7846_driver = {
>>        .driver = {
>>                .name   = "ads7846",
>>                .bus    = &spi_bus_type,
>>                .owner  = THIS_MODULE,
>>                .pm     = &ads7846_pm,
>> +#if defined(CONFIG_OF)
>> +               .of_match_table = ads7846_spi_of_match_table,
>> +#endif
>
> With the #else  block added above, you can drop the #if/#endif
> protection around of_match_table.

ok. thanks

>
> Otherwise:
>
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
>
--
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	[flat|nested] 4+ messages in thread

* Re: [PATCH] input: touchscreen: add OF match table for ads7846
  2011-06-13  8:15   ` Barry Song
@ 2011-06-13 13:24     ` Grant Likely
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Likely @ 2011-06-13 13:24 UTC (permalink / raw)
  To: Barry Song
  Cc: dmitry.torokhov, linux-input, Thomas Chou, devicetree-discuss,
	Zhiwu Song, uclinux-dist-devel

On Mon, Jun 13, 2011 at 2:15 AM, Barry Song <21cnbao@gmail.com> wrote:
> Hi Grant,
> Thanks.
>
> 2011/6/13 Grant Likely <grant.likely@secretlab.ca>:
>> On Thu, Jun 9, 2011 at 8:28 PM, Barry Song <Baohua.Song@csr.com> wrote:
>>> The current ads7846 has no OF match table. The method used is by applying a heuristic (of_modalias_node) which tries to name the device in a way that will match an existing device driver.
>>> This patch adds explicit OF match table for ads7846, then the normal device tree match behaviour will always work.
>>> It has been tested on PRIMA2 EVB board of CSR with a SPI's child node like the below:
>>> ts@0 {
>>>        compatible = "ti,ads7845";
>>>        reg = <0x0>;
>>>        spi-max-frequency = <31250>;
>>>        interrupts = <90>;
>>> };
>>>
>>> Signed-off-by: Barry Song <21cnbao@gmail.com>
>>> Cc: Grant Likely <grant.likely@secretlab.ca>
>>> cc: Thomas Chou <thomas@wytron.com.tw>
>>> ---
>>>  drivers/input/touchscreen/ads7846.c |   14 ++++++++++++++
>>
>> There should also be documentation for the new binding added to
>> Documentation/devicetree/bindings for the new compatible strings.
>
> Which directory do you think is the best to place this document? or do
> we build a new diretory named
> Documentation/devicetree/bindings/input/touchscreen/ ?
> The dir Documentation/devicetree/bindings seems to be for spi host,
> not for spi clients.

Documentation/devicetree/bindings/input sounds appropriate.

g.
--
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	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-13 13:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-10  2:28 [PATCH] input: touchscreen: add OF match table for ads7846 Barry Song
2011-06-13  5:15 ` Grant Likely
2011-06-13  8:15   ` Barry Song
2011-06-13 13:24     ` Grant Likely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).