devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] HID: i2c-hid: add DT bindings
@ 2013-06-13  7:50 Benjamin Tissoires
  2013-06-18  9:51 ` Jiri Kosina
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2013-06-13  7:50 UTC (permalink / raw)
  To: Benjamin Tissoires, Jiri Kosina, Grant Likely, Rob Herring,
	devicetree-discuss, linux-input, linux-kernel

Add device tree based support for HID over I2C devices.

Tested on an Odroid-X board with a Synaptics touchpad.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---

Hi guys,

well, as the commit message says, this is the DT binding for HID over I2C.
I honestly don't know if it will be used besides me, but it may help others
with a DT based board.
As the spec is for ACPI only, I had no specifications regarding the DT names. So
these names can be changed if you think they are bad.

I also created a new bindings directory in the devicetree doc to reflect the
split we have between input and hid. However, if the DT experts prefer having
it under input, I'm fine with that.

Cheers,
Benjamin

 .../devicetree/bindings/hid/hid-over-i2c.txt       | 28 ++++++++++++++
 drivers/hid/i2c-hid/i2c-hid.c                      | 44 +++++++++++++++++++++-
 include/linux/i2c/i2c-hid.h                        |  3 +-
 3 files changed, 73 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/hid/hid-over-i2c.txt

diff --git a/Documentation/devicetree/bindings/hid/hid-over-i2c.txt b/Documentation/devicetree/bindings/hid/hid-over-i2c.txt
new file mode 100644
index 0000000..488edcb
--- /dev/null
+++ b/Documentation/devicetree/bindings/hid/hid-over-i2c.txt
@@ -0,0 +1,28 @@
+* HID over I2C Device-Tree bindings
+
+HID over I2C provides support for various Human Interface Devices over the
+I2C bus. These devices can be for example touchpads, keyboards, touch screens
+or sensors.
+
+The specification has been written by Microsoft and is currently available here:
+http://msdn.microsoft.com/en-us/library/windows/hardware/hh852380.aspx
+
+If this binding is used, the kernel module i2c-hid will handle the communication
+with the device and the generic hid core layer will handle the protocol.
+
+Required properties:
+- compatible: must be "hid-over-i2c"
+- reg: i2c slave address
+- hid-descr-addr: HID descriptor address
+- interrupt-parent: the phandle for the interrupt controller
+- interrupts: interrupt line
+
+Example:
+
+	i2c-hid-dev@2c {
+		compatible = "hid-over-i2c";
+		reg = <0x2c>;
+		hid-descr-addr = <0x0020>;
+		interrupt-parent = <&gpx3>;
+		interrupts = <3 2>;
+	};
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 2b1799a..85b15a8 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -35,6 +35,7 @@
 #include <linux/hid.h>
 #include <linux/mutex.h>
 #include <linux/acpi.h>
+#include <linux/of.h>
 
 #include <linux/i2c/i2c-hid.h>
 
@@ -919,6 +920,42 @@ static inline int i2c_hid_acpi_pdata(struct i2c_client *client,
 }
 #endif
 
+#ifdef CONFIG_OF
+static int i2c_hid_of_probe(struct i2c_client *client,
+		struct i2c_hid_platform_data *pdata)
+{
+	struct device *dev = &client->dev;
+	u32 val;
+	int ret;
+
+	ret = of_property_read_u32(dev->of_node, "hid-descr-addr", &val);
+	if (ret) {
+		dev_err(&client->dev, "HID register address not provided\n");
+		return -ENODEV;
+	}
+	if (val >> 16) {
+		dev_err(&client->dev, "Bad HID register address: 0x%08x\n",
+			val);
+		return -EINVAL;
+	}
+	pdata->hid_descriptor_address = val;
+
+	return 0;
+}
+
+static const struct of_device_id i2c_hid_of_match[] = {
+	{ .compatible = "hid-over-i2c" },
+	{},
+};
+MODULE_DEVICE_TABLE(of, i2c_hid_of_match);
+#else
+static inline int i2c_hid_of_probe(struct i2c_client *client,
+		struct i2c_hid_platform_data *pdata)
+{
+	return -ENODEV;
+}
+#endif
+
 static int i2c_hid_probe(struct i2c_client *client,
 			 const struct i2c_device_id *dev_id)
 {
@@ -940,7 +977,11 @@ static int i2c_hid_probe(struct i2c_client *client,
 	if (!ihid)
 		return -ENOMEM;
 
-	if (!platform_data) {
+	if (client->dev.of_node) {
+		ret = i2c_hid_of_probe(client, &ihid->pdata);
+		if (ret)
+			goto err;
+	} else if (!platform_data) {
 		ret = i2c_hid_acpi_pdata(client, &ihid->pdata);
 		if (ret) {
 			dev_err(&client->dev,
@@ -1081,6 +1122,7 @@ static struct i2c_driver i2c_hid_driver = {
 		.owner	= THIS_MODULE,
 		.pm	= &i2c_hid_pm,
 		.acpi_match_table = ACPI_PTR(i2c_hid_acpi_match),
+		.of_match_table = of_match_ptr(i2c_hid_of_match),
 	},
 
 	.probe		= i2c_hid_probe,
diff --git a/include/linux/i2c/i2c-hid.h b/include/linux/i2c/i2c-hid.h
index 60e411d..7aa901d 100644
--- a/include/linux/i2c/i2c-hid.h
+++ b/include/linux/i2c/i2c-hid.h
@@ -19,7 +19,8 @@
  * @hid_descriptor_address: i2c register where the HID descriptor is stored.
  *
  * Note that it is the responsibility of the platform driver (or the acpi 5.0
- * driver) to setup the irq related to the gpio in the struct i2c_board_info.
+ * driver, or the flattened device tree) to setup the irq related to the gpio in
+ * the struct i2c_board_info.
  * The platform driver should also setup the gpio according to the device:
  *
  * A typical example is the following:
-- 
1.8.2.1


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

* Re: [PATCH] HID: i2c-hid: add DT bindings
  2013-06-13  7:50 [PATCH] HID: i2c-hid: add DT bindings Benjamin Tissoires
@ 2013-06-18  9:51 ` Jiri Kosina
  2013-07-24 15:39   ` Benjamin Tissoires
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2013-06-18  9:51 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Benjamin Tissoires, Grant Likely, Rob Herring, devicetree-discuss,
	linux-input, linux-kernel

On Thu, 13 Jun 2013, Benjamin Tissoires wrote:

> Add device tree based support for HID over I2C devices.
> 
> Tested on an Odroid-X board with a Synaptics touchpad.
> 
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
> 
> Hi guys,
> 
> well, as the commit message says, this is the DT binding for HID over I2C.
> I honestly don't know if it will be used besides me, but it may help others
> with a DT based board.
> As the spec is for ACPI only, I had no specifications regarding the DT names. So
> these names can be changed if you think they are bad.
> 
> I also created a new bindings directory in the devicetree doc to reflect the
> split we have between input and hid. However, if the DT experts prefer having
> it under input, I'm fine with that.
> 
> Cheers,
> Benjamin
> 
>  .../devicetree/bindings/hid/hid-over-i2c.txt       | 28 ++++++++++++++
>  drivers/hid/i2c-hid/i2c-hid.c                      | 44 +++++++++++++++++++++-
>  include/linux/i2c/i2c-hid.h                        |  3 +-
>  3 files changed, 73 insertions(+), 2 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/hid/hid-over-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/hid/hid-over-i2c.txt b/Documentation/devicetree/bindings/hid/hid-over-i2c.txt

DT folks, any objections to this, please?

If not, I'd like to apply this for 3.11 into my tree.

Thanks.

-- 
Jiri Kosina
SUSE Labs

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

* Re: [PATCH] HID: i2c-hid: add DT bindings
  2013-06-18  9:51 ` Jiri Kosina
@ 2013-07-24 15:39   ` Benjamin Tissoires
  2013-07-31 10:12     ` Jiri Kosina
  0 siblings, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2013-07-24 15:39 UTC (permalink / raw)
  To: Jiri Kosina
  Cc: Benjamin Tissoires, Grant Likely, Rob Herring, devicetree-discuss,
	linux-input, linux-kernel@vger.kernel.org

On Tue, Jun 18, 2013 at 11:51 AM, Jiri Kosina <jkosina@suse.cz> wrote:
> On Thu, 13 Jun 2013, Benjamin Tissoires wrote:
>
>> Add device tree based support for HID over I2C devices.
>>
>> Tested on an Odroid-X board with a Synaptics touchpad.
>>
>> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>> ---
>>
>> Hi guys,
>>
>> well, as the commit message says, this is the DT binding for HID over I2C.
>> I honestly don't know if it will be used besides me, but it may help others
>> with a DT based board.
>> As the spec is for ACPI only, I had no specifications regarding the DT names. So
>> these names can be changed if you think they are bad.
>>
>> I also created a new bindings directory in the devicetree doc to reflect the
>> split we have between input and hid. However, if the DT experts prefer having
>> it under input, I'm fine with that.
>>
>> Cheers,
>> Benjamin
>>
>>  .../devicetree/bindings/hid/hid-over-i2c.txt       | 28 ++++++++++++++
>>  drivers/hid/i2c-hid/i2c-hid.c                      | 44 +++++++++++++++++++++-
>>  include/linux/i2c/i2c-hid.h                        |  3 +-
>>  3 files changed, 73 insertions(+), 2 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/hid/hid-over-i2c.txt
>>
>> diff --git a/Documentation/devicetree/bindings/hid/hid-over-i2c.txt b/Documentation/devicetree/bindings/hid/hid-over-i2c.txt
>
> DT folks, any objections to this, please?
>
> If not, I'd like to apply this for 3.11 into my tree.
>

DT folks, ping???

Cheers,
Benjamin

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

* Re: [PATCH] HID: i2c-hid: add DT bindings
  2013-07-24 15:39   ` Benjamin Tissoires
@ 2013-07-31 10:12     ` Jiri Kosina
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2013-07-31 10:12 UTC (permalink / raw)
  To: Benjamin Tissoires
  Cc: Benjamin Tissoires, Grant Likely, Rob Herring, devicetree-discuss,
	linux-input, linux-kernel@vger.kernel.org

On Wed, 24 Jul 2013, Benjamin Tissoires wrote:

> >> Add device tree based support for HID over I2C devices.
> >>
> >> Tested on an Odroid-X board with a Synaptics touchpad.
> >>
> >> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> >> ---
> >>
> >> Hi guys,
> >>
> >> well, as the commit message says, this is the DT binding for HID over I2C.
> >> I honestly don't know if it will be used besides me, but it may help others
> >> with a DT based board.
> >> As the spec is for ACPI only, I had no specifications regarding the DT names. So
> >> these names can be changed if you think they are bad.
> >>
> >> I also created a new bindings directory in the devicetree doc to reflect the
> >> split we have between input and hid. However, if the DT experts prefer having
> >> it under input, I'm fine with that.
> >>
> >> Cheers,
> >> Benjamin
> >>
> >>  .../devicetree/bindings/hid/hid-over-i2c.txt       | 28 ++++++++++++++
> >>  drivers/hid/i2c-hid/i2c-hid.c                      | 44 +++++++++++++++++++++-
> >>  include/linux/i2c/i2c-hid.h                        |  3 +-
> >>  3 files changed, 73 insertions(+), 2 deletions(-)
> >>  create mode 100644 Documentation/devicetree/bindings/hid/hid-over-i2c.txt
> >>
> >> diff --git a/Documentation/devicetree/bindings/hid/hid-over-i2c.txt b/Documentation/devicetree/bindings/hid/hid-over-i2c.txt
> >
> > DT folks, any objections to this, please?
> >
> > If not, I'd like to apply this for 3.11 into my tree.
> >
> 
> DT folks, ping???

As there have been no objections for more than one month, I am now queuing 
this up.

Thanks,

-- 
Jiri Kosina
SUSE Labs

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

end of thread, other threads:[~2013-07-31 10:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-13  7:50 [PATCH] HID: i2c-hid: add DT bindings Benjamin Tissoires
2013-06-18  9:51 ` Jiri Kosina
2013-07-24 15:39   ` Benjamin Tissoires
2013-07-31 10:12     ` Jiri Kosina

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).