Commit 4435b577 authored by Jiri Kosina's avatar Jiri Kosina

Merge branch 'for-4.19/i2c-hid' into for-linus

Low voltage support for i2c-hid
parents 5a12d86c 6136f97c
...@@ -26,7 +26,8 @@ device-specific compatible properties, which should be used in addition to the ...@@ -26,7 +26,8 @@ device-specific compatible properties, which should be used in addition to the
- compatible: - compatible:
* "wacom,w9013" (Wacom W9013 digitizer). Supports: * "wacom,w9013" (Wacom W9013 digitizer). Supports:
- vdd-supply - vdd-supply (3.3V)
- vddl-supply (1.8V)
- post-power-on-delay-ms - post-power-on-delay-ms
- vdd-supply: phandle of the regulator that provides the supply voltage. - vdd-supply: phandle of the regulator that provides the supply voltage.
......
...@@ -1002,18 +1002,18 @@ static int i2c_hid_probe(struct i2c_client *client, ...@@ -1002,18 +1002,18 @@ static int i2c_hid_probe(struct i2c_client *client,
return client->irq; return client->irq;
} }
ihid = kzalloc(sizeof(struct i2c_hid), GFP_KERNEL); ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL);
if (!ihid) if (!ihid)
return -ENOMEM; return -ENOMEM;
if (client->dev.of_node) { if (client->dev.of_node) {
ret = i2c_hid_of_probe(client, &ihid->pdata); ret = i2c_hid_of_probe(client, &ihid->pdata);
if (ret) if (ret)
goto err; return ret;
} else if (!platform_data) { } else if (!platform_data) {
ret = i2c_hid_acpi_pdata(client, &ihid->pdata); ret = i2c_hid_acpi_pdata(client, &ihid->pdata);
if (ret) if (ret)
goto err; return ret;
} else { } else {
ihid->pdata = *platform_data; ihid->pdata = *platform_data;
} }
...@@ -1021,21 +1021,20 @@ static int i2c_hid_probe(struct i2c_client *client, ...@@ -1021,21 +1021,20 @@ static int i2c_hid_probe(struct i2c_client *client,
/* Parse platform agnostic common properties from ACPI / device tree */ /* Parse platform agnostic common properties from ACPI / device tree */
i2c_hid_fwnode_probe(client, &ihid->pdata); i2c_hid_fwnode_probe(client, &ihid->pdata);
ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd"); ihid->pdata.supplies[0].supply = "vdd";
if (IS_ERR(ihid->pdata.supply)) { ihid->pdata.supplies[1].supply = "vddl";
ret = PTR_ERR(ihid->pdata.supply);
if (ret != -EPROBE_DEFER) ret = devm_regulator_bulk_get(&client->dev,
dev_err(&client->dev, "Failed to get regulator: %d\n", ARRAY_SIZE(ihid->pdata.supplies),
ret); ihid->pdata.supplies);
goto err; if (ret)
} return ret;
ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies),
ihid->pdata.supplies);
if (ret < 0)
return ret;
ret = regulator_enable(ihid->pdata.supply);
if (ret < 0) {
dev_err(&client->dev, "Failed to enable regulator: %d\n",
ret);
goto err;
}
if (ihid->pdata.post_power_delay_ms) if (ihid->pdata.post_power_delay_ms)
msleep(ihid->pdata.post_power_delay_ms); msleep(ihid->pdata.post_power_delay_ms);
...@@ -1122,11 +1121,9 @@ static int i2c_hid_probe(struct i2c_client *client, ...@@ -1122,11 +1121,9 @@ static int i2c_hid_probe(struct i2c_client *client,
pm_runtime_disable(&client->dev); pm_runtime_disable(&client->dev);
err_regulator: err_regulator:
regulator_disable(ihid->pdata.supply); regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
ihid->pdata.supplies);
err:
i2c_hid_free_buffers(ihid); i2c_hid_free_buffers(ihid);
kfree(ihid);
return ret; return ret;
} }
...@@ -1148,9 +1145,8 @@ static int i2c_hid_remove(struct i2c_client *client) ...@@ -1148,9 +1145,8 @@ static int i2c_hid_remove(struct i2c_client *client)
if (ihid->bufsize) if (ihid->bufsize)
i2c_hid_free_buffers(ihid); i2c_hid_free_buffers(ihid);
regulator_disable(ihid->pdata.supply); regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
ihid->pdata.supplies);
kfree(ihid);
return 0; return 0;
} }
...@@ -1201,9 +1197,8 @@ static int i2c_hid_suspend(struct device *dev) ...@@ -1201,9 +1197,8 @@ static int i2c_hid_suspend(struct device *dev)
hid_warn(hid, "Failed to enable irq wake: %d\n", hid_warn(hid, "Failed to enable irq wake: %d\n",
wake_status); wake_status);
} else { } else {
ret = regulator_disable(ihid->pdata.supply); regulator_bulk_disable(ARRAY_SIZE(ihid->pdata.supplies),
if (ret < 0) ihid->pdata.supplies);
hid_warn(hid, "Failed to disable supply: %d\n", ret);
} }
return 0; return 0;
...@@ -1218,9 +1213,11 @@ static int i2c_hid_resume(struct device *dev) ...@@ -1218,9 +1213,11 @@ static int i2c_hid_resume(struct device *dev)
int wake_status; int wake_status;
if (!device_may_wakeup(&client->dev)) { if (!device_may_wakeup(&client->dev)) {
ret = regulator_enable(ihid->pdata.supply); ret = regulator_bulk_enable(ARRAY_SIZE(ihid->pdata.supplies),
if (ret < 0) ihid->pdata.supplies);
hid_warn(hid, "Failed to enable supply: %d\n", ret); if (ret)
hid_warn(hid, "Failed to enable supplies: %d\n", ret);
if (ihid->pdata.post_power_delay_ms) if (ihid->pdata.post_power_delay_ms)
msleep(ihid->pdata.post_power_delay_ms); msleep(ihid->pdata.post_power_delay_ms);
} else if (ihid->irq_wake_enabled) { } else if (ihid->irq_wake_enabled) {
......
...@@ -12,14 +12,13 @@ ...@@ -12,14 +12,13 @@
#ifndef __LINUX_I2C_HID_H #ifndef __LINUX_I2C_HID_H
#define __LINUX_I2C_HID_H #define __LINUX_I2C_HID_H
#include <linux/regulator/consumer.h>
#include <linux/types.h> #include <linux/types.h>
struct regulator;
/** /**
* struct i2chid_platform_data - used by hid over i2c implementation. * struct i2chid_platform_data - used by hid over i2c implementation.
* @hid_descriptor_address: i2c register where the HID descriptor is stored. * @hid_descriptor_address: i2c register where the HID descriptor is stored.
* @supply: regulator for powering on the device. * @supplies: regulators for powering on the device.
* @post_power_delay_ms: delay after powering on before device is usable. * @post_power_delay_ms: delay after powering on before device is usable.
* *
* Note that it is the responsibility of the platform driver (or the acpi 5.0 * Note that it is the responsibility of the platform driver (or the acpi 5.0
...@@ -35,7 +34,7 @@ struct regulator; ...@@ -35,7 +34,7 @@ struct regulator;
*/ */
struct i2c_hid_platform_data { struct i2c_hid_platform_data {
u16 hid_descriptor_address; u16 hid_descriptor_address;
struct regulator *supply; struct regulator_bulk_data supplies[2];
int post_power_delay_ms; int post_power_delay_ms;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment