From 704c946f70626d1640fc60f31f53acba2780f628 Mon Sep 17 00:00:00 2001 From: Jake Day Date: Fri, 3 Nov 2017 21:18:17 -0400 Subject: [PATCH] support power delay for acpi systems on i2c-hid --- .../devicetree/bindings/input/hid-over-i2c.txt | 2 +- kernel/drivers/hid/i2c-hid/i2c-hid.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/kernel/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/kernel/Documentation/devicetree/bindings/input/hid-over-i2c.txt index 28e8bd8b7..4d3da9d91 100644 --- a/kernel/Documentation/devicetree/bindings/input/hid-over-i2c.txt +++ b/kernel/Documentation/devicetree/bindings/input/hid-over-i2c.txt @@ -31,7 +31,7 @@ device-specific compatible properties, which should be used in addition to the - vdd-supply: phandle of the regulator that provides the supply voltage. - post-power-on-delay-ms: time required by the device after enabling its regulators - before it is ready for communication. Must be used with 'vdd-supply'. + or powering it on, before it is ready for communication. Example: diff --git a/kernel/drivers/hid/i2c-hid/i2c-hid.c b/kernel/drivers/hid/i2c-hid/i2c-hid.c index 9145c2129..71dbae5a5 100644 --- a/kernel/drivers/hid/i2c-hid/i2c-hid.c +++ b/kernel/drivers/hid/i2c-hid/i2c-hid.c @@ -929,11 +929,6 @@ static int i2c_hid_of_probe(struct i2c_client *client, } pdata->hid_descriptor_address = val; - ret = of_property_read_u32(dev->of_node, "post-power-on-delay-ms", - &val); - if (!ret) - pdata->post_power_delay_ms = val; - return 0; } @@ -950,6 +945,16 @@ static inline int i2c_hid_of_probe(struct i2c_client *client, } #endif +static void i2c_hid_fwnode_probe(struct i2c_client *client, + struct i2c_hid_platform_data *pdata) +{ + u32 val; + + if (!device_property_read_u32(&client->dev, "post-power-on-delay-ms", + &val)) + pdata->post_power_delay_ms = val; +} + static int i2c_hid_probe(struct i2c_client *client, const struct i2c_device_id *dev_id) { @@ -993,6 +998,9 @@ static int i2c_hid_probe(struct i2c_client *client, ihid->pdata = *platform_data; } + /* Parse platform agnostic common properties from ACPI / device tree */ + i2c_hid_fwnode_probe(client, &ihid->pdata); + ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd"); if (IS_ERR(ihid->pdata.supply)) { ret = PTR_ERR(ihid->pdata.supply);