Input: synaptics-rmi4: Add device tree support for RMI4 I2C devices
Subsystems (3)
PATCH 1/1 Input: synaptics-rmi4: Add device tree support for RMI4 I2C devices
Add devicetree binding for I2C devices and add bindings for optional parameters in the function drivers.
---
I saw Benjamin Tissoires's email about the lack of a devicetree implementation for rmi_i2c.c. I decided to clean up and add documentation to the implementaion which I have been using and submit it for review.
This patch applies to the current implementation of Dmitry's synaptics-rmi4 branch in the input repository. If Benjamin's patchset gets applied before this I can rebase this patch.
Thanks,
Andrew
.../devicetree/bindings/input/rmi4/rmi_f01.txt | 34 ++++++ .../devicetree/bindings/input/rmi4/rmi_f11.txt | 51 ++++++++ .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 40 +++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/input/rmi4/rmi_bus.c | 49 ++++++++ drivers/input/rmi4/rmi_bus.h | 8 +- drivers/input/rmi4/rmi_driver.c | 46 ++++++- drivers/input/rmi4/rmi_f01.c | 50 +++++++- drivers/input/rmi4/rmi_f11.c | 133 ++++++++++++++++++++- drivers/input/rmi4/rmi_i2c.c | 60 +++++++++- include/linux/rmi.h | 2 +- 11 files changed, 465 insertions(+), 9 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt
Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt new file +34 -0
@@ -0,0 +1,34 @@ +Synaptics RMI4 F01 Device Binding + +The Synaptics RMI4 core is able to support RMI4 devices using differnet +transports and differnet functions. This file describes the device tree +bindings for devices which contain Function 1. Complete documentation +for transports and other functions can be found in: +Documentation/devicetree/bindings/input/rmi4. + +Additional documentation for F01 can be found at: +http://www.synaptics.com/sites/default/files/511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf + +Optional Properties: +- syna,f01-nosleep: If set the device will run at full power without sleeping. +- syna,f01-wakeup-threshold: Defines the amplitude of the disturbance to the + background capacitance that will cause the + device to wake from dozing. +- syna,f01-doze-holdoff: The delay to wait after the last finger lift and the + first doze cycle (in 0.1 second units). +- syna,f01-doze-interval: The time period that the device sleeps between finger + activity (in 10 ms units). + + +Example of a RMI4 I2C device with F01: + &i2c1 { + rmi-i2c-dev@2c { + compatible = "syna,rmi-i2c"; + reg = <0x2c>; + syna,sensor-name="TM1949"; + syna,attn-gpio = <4 2>; + syna,attn-polarity = <0>; + syna,level-triggered = <1>; + syna,f01-nosleep = <1>; + }; + };
Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt new file +51 -0
51 lines not on this page · raw message
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +40 -0
@@ -0,0 +1,40 @@ +Synaptics RMI4 I2C Device Binding + +The Synaptics RMI4 core is able to support RMI4 devices using differnet +transports and differnet functions. This file describes the device tree +bindings for devices using the I2C tranport driver. Complete documentation +for other transports and functions cen be found ini +Documentation/devicetree/bindings/input/rmi4. + +Required Properties: +- compatible: syna,rmi-i2c +- reg: I2C address + +Optional Properties: +- syna,sensor-name: The string containing the name of the sensor. +- syna,attn-gpio: The GPIO number used to assert attention. +- syna,attn-polarity: The polarity of the attention GPIO. +- syna,level-triggered: Set to 1 if attention GPIO is level triggered, 0 if + edge triggered. +- syna,poll-interval-ms: The interval in milliseconds to wait between reading + interrupts when the driver is polling. +- syna,reset-delay-ms: The number of milliseconds to wait after resetting the + device. +- syna,f01-*: Additional parameters specific to RMI4 function 1 + see Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt. +- syna,f11-*: Additional parameters specific to RMI4 function 11 + see Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt. + + +Example: + &i2c1 { + rmi-i2c-dev@2c { + compatible = "syna,rmi-i2c"; + reg = <0x2c>; + syna,sensor-name="TM1949"; + syna,attn-gpio = <4 2>; + syna,attn-polarity = <0>; + syna,level-triggered = <1>; + syna,f11-flip-y = <1>; + }; + };
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -85,6 +85,7 @@ spansion Spansion Inc. st STMicroelectronics ste ST-Ericsson stericsson ST-Ericsson +syna Synaptics Inc. ti Texas Instruments tlm Trusted Logic Mobility toshiba Toshiba Corporation
drivers/input/rmi4/rmi_bus.c +49 -0
61 lines not on this page · raw message
drivers/input/rmi4/rmi_bus.h +7 -1
@@ -223,7 +223,7 @@ struct rmi_device {#define to_rmi_device (d) container_of(d, struct rmi_device, dev) -static inline const struct rmi_device_platform_data * +static inline struct rmi_device_platform_data *rmi_get_platform_data (struct rmi_device *d) {return dev_get_platdata (d->xport->dev);
@@ -314,4 +314,10 @@ int rmi_for_each_dev(void *data, int (*func)(struct device *dev, void *data));extern struct bus_type rmi_bus_type; +int rmi_of_property_read_u32 (struct device *dev,u32 *result, +const char *prop,bool optional); +int rmi_of_property_read_u16 (struct device *dev,u16 *result, +const char *prop,bool optional); +int rmi_of_property_read_u8 (struct device *dev,u8 *result, +const char *prop,bool optional);#endif
drivers/input/rmi4/rmi_driver.c +45 -1
62 lines not on this page · raw message
drivers/input/rmi4/rmi_f01.c +49 -1
71 lines not on this page · raw message
drivers/input/rmi4/rmi_f11.c +132 -1
157 lines not on this page · raw message
drivers/input/rmi4/rmi_i2c.c +56 -4
86 lines not on this page · raw message
include/linux/rmi.h +1 -1
@@ -254,7 +254,7 @@ struct rmi_device_platform_data_spi {* functions. */ struct rmi_device_platform_data { -char *sensor_name;/* Used for diagnostics. */ +const char *sensor_name;/* Used for diagnostics. */ int attn_gpio;enum rmi_attn_polarity attn_polarity;
Signature · 1 line
2.1.4
Dmitry Torokhov
maintainerHi Andrew,
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt line 18
Quoted 6 lines · Andrew Duggan
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +6
-0+Optional Properties: +- syna,sensor-name: The string containing the name of the sensor. +- syna,attn-gpio: The GPIO number used to assert attention. +- syna,attn-polarity: The polarity of the attention GPIO. +- syna,level-triggered: Set to 1 if attention GPIO is level triggered, 0 if + edge triggered.
We already have generic bindings for i2c devices interrupt line, along with trigger type. We also have standard bindings for gpios, with the polarity. Interrupts are also parsed by the I2C core. There is no need to invent your own bindings.
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt line 26
Quoted 8 lines
+- syna,poll-interval-ms: The interval in milliseconds to wait between reading
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +7
-0+ interrupts when the driver is polling. +- syna,reset-delay-ms: The number of milliseconds to wait after resetting the + device. +- syna,f01-*: Additional parameters specific to RMI4 function 1 + see Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt. +- syna,f11-*: Additional parameters specific to RMI4 function 11 + see Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt.
For function parameters I wonder if they should not be modelled as subnodes with "reg" representing function number.
Thanks.
Signature · 1 line
Dmitry
Hi Dmitry,
Quoted 13 lines · Dmitry Torokhov
Hi Andrew,
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt line 18
Quoted 6 lines · Andrew Duggan
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +6
-0+Optional Properties: +- syna,sensor-name: The string containing the name of the sensor. +- syna,attn-gpio: The GPIO number used to assert attention. +- syna,attn-polarity: The polarity of the attention GPIO. +- syna,level-triggered: Set to 1 if attention GPIO is level triggered, 0 if + edge triggered.We already have generic bindings for i2c devices interrupt line, along with trigger type. We also have standard bindings for gpios, with the polarity. Interrupts are also parsed by the I2C core. There is no need to invent your own bindings.
In the current implementation rmi_driver expects an attention GPIO from the platform data and manages it internally. I just added those parameters to device tree. But, that essentially duplicates the generic I2C and device tree interrupt handling. I agree that rmi_driver should just use the irq provided in the I2C client and then we don't have to duplicate the GPIO handling and we can use the generic bindings.
One option is to check to see if there is an irq in the I2C client and skip the GPIO initialization if there is. I can provide a patch which does that and a v2 of this patch to use the generic bindings. But, this also brings up the question on whether or not we should still have the code for handling the GPIO in rmi_driver at all. The last time the GPIO code was discussed, Chris said it allowed for releasing the irq for certain diagnostic modes. But, there are cases when rmi_driver won't have access to the GPIO or when the device is directly connected to the IO_APIC (ie HID or SMBus devices) so the diagnostic mode won't be available for those devices. Also, I'm also not convinced that the diagnostic capabilities justify duplicating the GPIO handling. If most platforms are using device tree at this point I think it might be time to remove the GPIO code from rmi_driver and let the lower levels handle interrupts. Or, if there are major objections I can work around it and leave it as an option in the platform data for devices which still use board files.
http://marc.info/?l=linux-input&m=139155532321252&w=2
Quoted 10 lines
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt line 26
Quoted 8 lines
+- syna,poll-interval-ms: The interval in milliseconds to wait between reading
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +7
-0+ interrupts when the driver is polling. +- syna,reset-delay-ms: The number of milliseconds to wait after resetting the + device. +- syna,f01-*: Additional parameters specific to RMI4 function 1 + see Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt. +- syna,f11-*: Additional parameters specific to RMI4 function 11 + see Documentation/devicetree/bindings/input/rmi4/rmi_f11.txt.For function parameters I wonder if they should not be modelled as subnodes with "reg" representing function number.
I'll look in to doing this. Putting the function parameters into subnodes makes sense to me.
Quoted 2 lines
Thanks.
Thanks,
Andrew
Dmitry Torokhov
maintainerQuoted 42 lines · Andrew Duggan
Hi Dmitry,
Quoted 13 lines · Dmitry Torokhov
Hi Andrew,
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt line 18
Quoted 6 lines · Andrew Duggan
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +6
-0+Optional Properties: +- syna,sensor-name: The string containing the name of the sensor. +- syna,attn-gpio: The GPIO number used to assert attention. +- syna,attn-polarity: The polarity of the attention GPIO. +- syna,level-triggered: Set to 1 if attention GPIO is level triggered, 0 if + edge triggered.We already have generic bindings for i2c devices interrupt line, along with trigger type. We also have standard bindings for gpios, with the polarity. Interrupts are also parsed by the I2C core. There is no need to invent your own bindings.
In the current implementation
rmi_driverexpects an attention GPIO from the platform data and manages it internally. I just added those parameters to device tree. But, that essentially duplicates the generic I2C and device tree interrupt handling. I agree thatrmi_drivershould just use the irq provided in the I2C client and then we don't have to duplicate the GPIO handling and we can use the generic bindings.One option is to check to see if there is an irq in the I2C client and skip the GPIO initialization if there is. I can provide a patch which does that and a v2 of this patch to use the generic bindings. But, this also brings up the question on whether or not we should still have the code for handling the GPIO in
rmi_driverat all. The last time the GPIO code was discussed, Chris said it allowed for releasing the irq for certain diagnostic modes. But, there are cases whenrmi_driverwon't have access to the GPIO or when the device is directly connected to theIO_APIC(ie HID or SMBus devices) so the diagnostic mode won't be available for those devices. Also, I'm also not convinced that the diagnostic capabilities justify duplicating the GPIO handling. If most platforms are using device tree at this point I think it might be time to remove the GPIO code fromrmi_driverand let the lower levels handle interrupts. Or, if there are major objections I can work around it and leave it as an option in the platform data for devices which still use board files.
I am always happy with making things simpler so you would not hear me objecting to dropping gpio handling and relying on interrupts set up for I2C or SPI client.
That said if you absolutely want to also support GPIO you can make it optional and alter the behavior depending whether the platform presents you with GPIO or not. In any case we also have standard GPIO bindings that allow setting the polarity, etc. Just use gpiod API and it should work for devicetree, acpi and can be even plugged into static board code.
Thanks.
Signature · 1 line
Dmitry