Input: synaptics-rmi4: Add device tree support for RMI4 I2C devices
Subsystems (3)
PATCH v2 3/10 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. Parameters for function drivers are defined in child nodes for each of the functions.
--- .../devicetree/bindings/input/rmi4/rmi_f01.txt | 39 ++++++++++++++++ .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 53 ++++++++++++++++++++++ .../devicetree/bindings/vendor-prefixes.txt | 1 + drivers/input/rmi4/rmi_bus.c | 35 ++++++++++++++ drivers/input/rmi4/rmi_bus.h | 4 -- drivers/input/rmi4/rmi_driver.c | 28 ++++++++++++ drivers/input/rmi4/rmi_f01.c | 50 ++++++++++++++++++++ drivers/input/rmi4/rmi_i2c.c | 12 ++++- 8 files changed, 217 insertions(+), 5 deletions(-) create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt create mode 100644 Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt
Documentation/devicetree/bindings/input/rmi4/rmi_f01.txt new file +39 -0
@@ -0,0 +1,39 @@ +Synaptics RMI4 F01 Device Binding + +The Synaptics RMI4 core is able to support RMI4 devices using different +transports and different 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,nosleep-mode: If set the device will run at full power without sleeping. + nosleep has 3 modes, 0 will not change the default + setting, 1 will disable nosleep (allow sleeping), + and 2 will enable nosleep (disabling sleep). +- syna,wakeup-threshold: Defines the amplitude of the disturbance to the + background capacitance that will cause the + device to wake from dozing. +- syna,doze-holdoff-msec: The delay to wait after the last finger lift and the + first doze cycle. +- syna,doze-interval-msec: The time period that the device sleeps between finger + activity. + + +Example of a RMI4 I2C device with F01: + Example: + &i2c1 { + rmi4-i2c-dev@2c { + compatible = "syna,rmi4-i2c"; + + ... + + rmi4-f01@1 { + reg = <0x1>; + syna,nosleep-mode = <1>; + }; + }; + };
Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt new file +53 -0
53 lines not on this page · raw message
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
@@ -220,6 +220,7 @@ sprd Spreadtrum Communications Inc. st STMicroelectronics ste ST-Ericsson stericsson ST-Ericsson +syna Synaptics Inc. synology Synology, Inc. tbs TBS Technologies tcl Toby Churchill Ltd.
drivers/input/rmi4/rmi_bus.c +35 -0
@@ -153,6 +153,21 @@ static int rmi_function_match(struct device *dev, struct device_driver *drv)return fn->fd.function_number == handler->func; } +#ifdef CONFIG_OF +static void rmi_function_of_probe (struct rmi_function *fn) +{ +char of_name[8 ]; + +snprintf (of_name,sizeof (of_name),"rmi4-f%02x" , + fn->fd.function_number); + fn->dev.of_node =of_find_node_by_name ( + fn->rmi_dev->xport->dev->of_node, of_name); +} +#else +static inline void rmi_function_of_probe (struct rmi_function *fn) +{} +#endif +static int rmi_function_probe (struct device *dev) {struct rmi_function *fn =to_rmi_function (dev);
@@ -160,6 +175,8 @@ static int rmi_function_probe(struct device *dev)to_rmi_function_handler (dev->driver);int error; +rmi_function_of_probe (fn); +if (handler->probe) { error = handler->probe (fn);return error;
@@ -328,6 +345,24 @@ err_unregister_function_handlers:return ret; } +int rmi_of_property_read_u32 (struct device *dev,u32 *result, +const char *prop,bool optional) +{ +int retval; +u32 val =0 ; + + retval =of_property_read_u32 (dev->of_node, prop, &val); +if (retval && (!optional && retval == -EINVAL )) { +dev_err (dev,"Failed to get %s value: %d\n" , + prop, retval); +return retval; + } + *result = val; + +return 0 ; +} +EXPORT_SYMBOL_GPL (rmi_of_property_read_u32); +static int __init rmi_bus_init (void ) {int error;
drivers/input/rmi4/rmi_bus.h +0 -4
@@ -175,10 +175,6 @@ 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);#define RMI_DEBUG_CORE BIT(0)#define RMI_DEBUG_XPORT BIT(1)
drivers/input/rmi4/rmi_driver.c +28 -0
@@ -20,6 +20,7 @@#include <linux/kconfig.h> #include <linux/pm.h> #include <linux/slab.h> +#include <linux/of.h> #include <uapi/linux/input.h> #include <linux/rmi.h> #include "rmi_bus.h"
@@ -818,6 +819,27 @@ static int rmi_driver_remove(struct device *dev)return 0 ; } +#ifdef CONFIG_OF +static int rmi_driver_of_probe (struct device *dev, +struct rmi_device_platform_data *pdata) +{ +int retval; + + retval =rmi_of_property_read_u32 (dev, &pdata->reset_delay_ms, +"syna,reset-delay-msec" ,1 ); +if (retval) +return retval; + +return 0 ; +} +#else +static inline int rmi_driver_of_probe (struct device *dev, +struct rmi_device_platform_data *pdata) +{ +return -ENODEV ; +} +#endif +static int rmi_driver_probe (struct device *dev) {struct rmi_driver *rmi_driver;
@@ -843,6 +865,12 @@ static int rmi_driver_probe(struct device *dev) pdata =rmi_get_platform_data (rmi_dev); +if (rmi_dev->xport->dev->of_node) { + retval =rmi_driver_of_probe (rmi_dev->xport->dev, pdata); +if (retval) +return retval; + } + data =devm_kzalloc (dev,sizeof (struct rmi_driver_data ),GFP_KERNEL );if (!data)return -ENOMEM ;
drivers/input/rmi4/rmi_f01.c +50 -0
62 lines not on this page · raw message
drivers/input/rmi4/rmi_i2c.c +11 -1
@@ -9,6 +9,7 @@#include <linux/i2c.h> #include <linux/rmi.h> +#include <linux/of.h> #include "rmi_driver.h" #define BUFFER_SIZE_INCREMENT 32
@@ -205,6 +206,14 @@ static int rmi_i2c_init_irq(struct i2c_client *client)return 0 ; } +#ifdef CONFIG_OF +static const struct of_device_id rmi_i2c_of_match[] = { + { .compatible ="syna,rmi4-i2c" }, + {}, +}; +MODULE_DEVICE_TABLE (of, rmi_i2c_of_match); +#endif +static int rmi_i2c_probe (struct i2c_client *client,const struct i2c_device_id *id) {
@@ -221,7 +230,7 @@ static int rmi_i2c_probe(struct i2c_client *client, pdata = &rmi_i2c->xport.pdata; -if (client_pdata) +if (!client->dev.of_node && client_pdata) *pdata = *client_pdata;if (client->irq >0 )
@@ -371,6 +380,7 @@ static struct i2c_driver rmi_i2c_driver = { .owner = THIS_MODULE, .name = "rmi4_i2c", .pm = &rmi_i2c_pm, + .of_match_table = of_match_ptr(rmi_i2c_of_match), }, .id_table = rmi_id, .probe = rmi_i2c_probe,
Signature · 1 line
2.5.0
Hi
Quoted 6 lines · Andrew Duggan
Add devicetree binding for I2C devices and add bindings for optional parameters in the function drivers. Parameters for function drivers are defined in child nodes for each of the functions.
Signed-off-by Andrew Duggan <[email protected]>
...
Quoted 12 lines
drivers/input/rmi4/rmi_bus.c +10
-0+#ifdef CONFIG_OF +static void rmi_function_of_probe (struct rmi_function *fn) +{ +char of_name[8 ]; + +snprintf (of_name,sizeof (of_name),"rmi4-f%02x" , + fn->fd.function_number); + fn->dev.of_node =of_find_node_by_name ( + fn->rmi_dev->xport->dev->of_node, of_name); +}
Quoted 1 line
Name like "rmi4-f11" including 0 terminator does not fit in 8 chars.
This leads to the inability to find the correct OF node and get settings.
Quoted 6 lines · Andrew Duggan
Add devicetree binding for I2C devices and add bindings for optional parameters in the function drivers. Parameters for function drivers are defined in child nodes for each of the functions.
Signed-off-by Andrew Duggan <[email protected]>
...
drivers/input/rmi4/rmi_bus.c static int rmi_function_match(struct device *dev, struct device_driver *drv) · line 165
Quoted 11 lines
drivers/input/rmi4/rmi_bus.c +10
-0+#ifdef CONFIG_OF +static void rmi_function_of_probe (struct rmi_function *fn) +{ +char of_name[8 ]; + +snprintf (of_name,sizeof (of_name),"rmi4-f%02x" , + fn->fd.function_number); + fn->dev.of_node =of_find_node_by_name ( + fn->rmi_dev->xport->dev->of_node, of_name); +}
Name like "rmi4-f11" including 0 terminator does not fit in 8 chars. This leads to the inability to find the correct OF node and get settings.
Sorry for previous HTML noise.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Audrey,
Quoted 7 lines · Andrey Gusakov
Quoted 5 lines · Andrew Duggan
Add devicetree binding for I2C devices and add bindings for optional parameters in the function drivers. Parameters for function drivers are defined in child nodes for each of the functions.
Signed-off-by Andrew Duggan <[email protected]>...
Quoted 13 lines
drivers/input/rmi4/rmi_bus.c static int rmi_function_match(struct device *dev, struct device_driver *drv) · line 165
Quoted 11 lines
drivers/input/rmi4/rmi_bus.c +10
-0+#ifdef CONFIG_OF +static void rmi_function_of_probe (struct rmi_function *fn) +{ +char of_name[8 ]; + +snprintf (of_name,sizeof (of_name),"rmi4-f%02x" , + fn->fd.function_number); + fn->dev.of_node =of_find_node_by_name ( + fn->rmi_dev->xport->dev->of_node, of_name); +}Name like "rmi4-f11" including 0 terminator does not fit in 8 chars. This leads to the inability to find the correct OF node and get settings.
Oh, I missed that! I'll fix it in the next patch series.
Thanks,
Andrew
Quoted 1 line
Sorry for previous HTML noise.