From e9000b7978541f73a4bc100117fd417ab08a2a60 Mon Sep 17 00:00:00 2001 From: Nick Dyer Date: Thu, 19 May 2016 09:22:49 -0700 Subject: Input: synaptics-rmi4 - fix spelling in defines Signed-off-by: Nick Dyer Reviewed-by: Andrew Duggan Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f01.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/input/rmi4') diff --git a/drivers/input/rmi4/rmi_f01.c b/drivers/input/rmi4/rmi_f01.c index eb362bc71a4c..fac81fc9bcf6 100644 --- a/drivers/input/rmi4/rmi_f01.c +++ b/drivers/input/rmi4/rmi_f01.c @@ -81,26 +81,26 @@ struct f01_basic_properties { * This bit disables whatever sleep mode may be selected by the sleep_mode * field and forces the device to run at full power without sleeping. */ -#define RMI_F01_CRTL0_NOSLEEP_BIT BIT(2) +#define RMI_F01_CTRL0_NOSLEEP_BIT BIT(2) /* * When this bit is set, the touch controller employs a noise-filtering * algorithm designed for use with a connected battery charger. */ -#define RMI_F01_CRTL0_CHARGER_BIT BIT(5) +#define RMI_F01_CTRL0_CHARGER_BIT BIT(5) /* * Sets the report rate for the device. The effect of this setting is * highly product dependent. Check the spec sheet for your particular * touch sensor. */ -#define RMI_F01_CRTL0_REPORTRATE_BIT BIT(6) +#define RMI_F01_CTRL0_REPORTRATE_BIT BIT(6) /* * Written by the host as an indicator that the device has been * successfully configured. */ -#define RMI_F01_CRTL0_CONFIGURED_BIT BIT(7) +#define RMI_F01_CTRL0_CONFIGURED_BIT BIT(7) /** * @ctrl0 - see the bit definitions above. @@ -330,10 +330,10 @@ static int rmi_f01_probe(struct rmi_function *fn) case RMI_F01_NOSLEEP_DEFAULT: break; case RMI_F01_NOSLEEP_OFF: - f01->device_control.ctrl0 &= ~RMI_F01_CRTL0_NOSLEEP_BIT; + f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_NOSLEEP_BIT; break; case RMI_F01_NOSLEEP_ON: - f01->device_control.ctrl0 |= RMI_F01_CRTL0_NOSLEEP_BIT; + f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; break; } @@ -349,7 +349,7 @@ static int rmi_f01_probe(struct rmi_function *fn) f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; } - f01->device_control.ctrl0 |= RMI_F01_CRTL0_CONFIGURED_BIT; + f01->device_control.ctrl0 |= RMI_F01_CTRL0_CONFIGURED_BIT; error = rmi_write(rmi_dev, fn->fd.control_base_addr, f01->device_control.ctrl0); @@ -535,8 +535,8 @@ static int rmi_f01_suspend(struct rmi_function *fn) int error; f01->old_nosleep = - f01->device_control.ctrl0 & RMI_F01_CRTL0_NOSLEEP_BIT; - f01->device_control.ctrl0 &= ~RMI_F01_CRTL0_NOSLEEP_BIT; + f01->device_control.ctrl0 & RMI_F01_CTRL0_NOSLEEP_BIT; + f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_NOSLEEP_BIT; f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; if (device_may_wakeup(fn->rmi_dev->xport->dev)) @@ -549,7 +549,7 @@ static int rmi_f01_suspend(struct rmi_function *fn) if (error) { dev_err(&fn->dev, "Failed to write sleep mode: %d.\n", error); if (f01->old_nosleep) - f01->device_control.ctrl0 |= RMI_F01_CRTL0_NOSLEEP_BIT; + f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; f01->device_control.ctrl0 |= RMI_SLEEP_MODE_NORMAL; return error; @@ -564,7 +564,7 @@ static int rmi_f01_resume(struct rmi_function *fn) int error; if (f01->old_nosleep) - f01->device_control.ctrl0 |= RMI_F01_CRTL0_NOSLEEP_BIT; + f01->device_control.ctrl0 |= RMI_F01_CTRL0_NOSLEEP_BIT; f01->device_control.ctrl0 &= ~RMI_F01_CTRL0_SLEEP_MODE_MASK; f01->device_control.ctrl0 |= RMI_SLEEP_MODE_NORMAL; -- cgit v1.2.3 From 946c8432aab03feba14104aebcb3037636297eee Mon Sep 17 00:00:00 2001 From: Bjorn Andersson Date: Wed, 13 Jul 2016 17:15:38 -0700 Subject: Input: synaptics-rmi4 - support regulator supplies Support the two supplies - vdd and vio - to make it possible to control power to the Synaptics chip. Signed-off-by: Bjorn Andersson Signed-off-by: Bjorn Andersson Acked-by: Rob Herring Reviewed-by: Andrew Duggan Signed-off-by: Dmitry Torokhov --- .../devicetree/bindings/input/rmi4/rmi_i2c.txt | 9 +++++ drivers/input/rmi4/rmi_i2c.c | 46 ++++++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'drivers/input/rmi4') diff --git a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt index 95fa715c6046..ec908b91fd90 100644 --- a/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt +++ b/Documentation/devicetree/bindings/input/rmi4/rmi_i2c.txt @@ -22,6 +22,15 @@ See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - syna,reset-delay-ms: The number of milliseconds to wait after resetting the device. +- syna,startup-delay-ms: The number of milliseconds to wait after powering on + the device. + +- vdd-supply: VDD power supply. +See ../regulator/regulator.txt + +- vio-supply: VIO power supply +See ../regulator/regulator.txt + Function Parameters: Parameters specific to RMI functions are contained in child nodes of the rmi device node. Documentation for the parameters of each function can be found in: diff --git a/drivers/input/rmi4/rmi_i2c.c b/drivers/input/rmi4/rmi_i2c.c index a96a326b53bd..6f2e0e4f0296 100644 --- a/drivers/input/rmi4/rmi_i2c.c +++ b/drivers/input/rmi4/rmi_i2c.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "rmi_driver.h" #define BUFFER_SIZE_INCREMENT 32 @@ -37,6 +39,9 @@ struct rmi_i2c_xport { u8 *tx_buf; size_t tx_buf_size; + + struct regulator_bulk_data supplies[2]; + u32 startup_delay; }; #define RMI_PAGE_SELECT_REGISTER 0xff @@ -246,6 +251,24 @@ static int rmi_i2c_probe(struct i2c_client *client, return -ENODEV; } + rmi_i2c->supplies[0].supply = "vdd"; + rmi_i2c->supplies[1].supply = "vio"; + retval = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + if (retval < 0) + return retval; + + retval = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + if (retval < 0) + return retval; + + of_property_read_u32(client->dev.of_node, "syna,startup-delay-ms", + &rmi_i2c->startup_delay); + + msleep(rmi_i2c->startup_delay); + rmi_i2c->client = client; mutex_init(&rmi_i2c->page_mutex); @@ -286,6 +309,8 @@ static int rmi_i2c_remove(struct i2c_client *client) struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); rmi_unregister_transport_device(&rmi_i2c->xport); + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); return 0; } @@ -308,6 +333,10 @@ static int rmi_i2c_suspend(struct device *dev) dev_warn(dev, "Failed to enable irq for wake: %d\n", ret); } + + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + return ret; } @@ -317,6 +346,13 @@ static int rmi_i2c_resume(struct device *dev) struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + if (ret) + return ret; + + msleep(rmi_i2c->startup_delay); + enable_irq(rmi_i2c->irq); if (device_may_wakeup(&client->dev)) { ret = disable_irq_wake(rmi_i2c->irq); @@ -346,6 +382,9 @@ static int rmi_i2c_runtime_suspend(struct device *dev) disable_irq(rmi_i2c->irq); + regulator_bulk_disable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + return 0; } @@ -355,6 +394,13 @@ static int rmi_i2c_runtime_resume(struct device *dev) struct rmi_i2c_xport *rmi_i2c = i2c_get_clientdata(client); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(rmi_i2c->supplies), + rmi_i2c->supplies); + if (ret) + return ret; + + msleep(rmi_i2c->startup_delay); + enable_irq(rmi_i2c->irq); ret = rmi_driver_resume(rmi_i2c->xport.rmi_dev); -- cgit v1.2.3 From e21582956005bb1677b0c2f9caf1042020f45408 Mon Sep 17 00:00:00 2001 From: Andrew Duggan Date: Thu, 14 Jul 2016 09:37:11 -0700 Subject: Input: synaptics-rmi4 - remove pointer to rmi_function in f12_data The pointer to struct rmi_function in f12_data is never set and was never used. The fn pointer is also stored in rmi_2d_sensor which is a member of f12_data. Signed-off-by: Andrew Duggan Reviewed-by: Benjamin Tissoires Reviewed-by: Nick Dyer Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f12.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/input/rmi4') diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index 8dd3fb5e1f94..123f2b495673 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c @@ -27,7 +27,6 @@ enum rmi_f12_object_type { }; struct f12_data { - struct rmi_function *fn; struct rmi_2d_sensor sensor; struct rmi_2d_sensor_platform_data sensor_pdata; -- cgit v1.2.3 From 546ae1085b2772de47221c8780c000ee9829545d Mon Sep 17 00:00:00 2001 From: Andrew Duggan Date: Thu, 14 Jul 2016 09:38:04 -0700 Subject: Input: synaptics-rmi4 - remove unneeded variable Remove the data_base_addr_offset variable in rmi_f11_attention(). The f11 data is read as a single block so there is no need to store an offset to the data address. Signed-off-by: Andrew Duggan Reviewed-by: Benjamin Tissoires Reviewed-by: Nick Dyer Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f11.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/input/rmi4') diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index ec8a10d53288..c3672b983fc9 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c @@ -1241,7 +1241,6 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits) struct rmi_driver_data *drvdata = dev_get_drvdata(&rmi_dev->dev); struct f11_data *f11 = dev_get_drvdata(&fn->dev); u16 data_base_addr = fn->fd.data_base_addr; - u16 data_base_addr_offset = 0; int error; if (rmi_dev->xport->attn_data) { @@ -1251,8 +1250,7 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits) rmi_dev->xport->attn_size -= f11->sensor.attn_size; } else { error = rmi_read_block(rmi_dev, - data_base_addr + data_base_addr_offset, - f11->sensor.data_pkt, + data_base_addr, f11->sensor.data_pkt, f11->sensor.pkt_size); if (error < 0) return error; @@ -1260,7 +1258,6 @@ static int rmi_f11_attention(struct rmi_function *fn, unsigned long *irq_bits) rmi_f11_finger_handler(f11, &f11->sensor, irq_bits, drvdata->num_of_irq_regs); - data_base_addr_offset += f11->sensor.pkt_size; return 0; } -- cgit v1.2.3 From 345ded8ef489a888f6921c999f872848c96b5af8 Mon Sep 17 00:00:00 2001 From: Andrew Duggan Date: Thu, 14 Jul 2016 09:38:59 -0700 Subject: Input: synaptics-rmi4 - use the RMI_F11_REL_BYTES define in rmi_f11_rel_pos_report The size of relative data in F11 is already defined by RMI_F11_REL_BYTES. Use the define in rmi_f11_rel_pos_report() to be consistent. Signed-off-by: Andrew Duggan Reviewed-by: Nick Dyer Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f11.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/input/rmi4') diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index c3672b983fc9..20c7134b3d3b 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c @@ -530,8 +530,8 @@ static void rmi_f11_rel_pos_report(struct f11_data *f11, u8 n_finger) struct f11_2d_data *data = &f11->data; s8 x, y; - x = data->rel_pos[n_finger * 2]; - y = data->rel_pos[n_finger * 2 + 1]; + x = data->rel_pos[n_finger * RMI_F11_REL_BYTES]; + y = data->rel_pos[n_finger * RMI_F11_REL_BYTES + 1]; rmi_2d_sensor_rel_report(sensor, x, y); } -- cgit v1.2.3