Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1476049 > unrolled thread
| Started by | Caesar Wang <wxt@rock-chips.com> |
|---|---|
| First post | 2016-09-05 00:20 +0200 |
| Last post | 2016-09-05 00:20 +0200 |
| Articles | 2 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 1/2] dt-bindings: add the regulator optional properties Caesar Wang <wxt@rock-chips.com> - 2016-09-05 00:20 +0200
[PATCH 2/2] HID: i2c-hid: support the regulator Caesar Wang <wxt@rock-chips.com> - 2016-09-05 00:20 +0200
| From | Caesar Wang <wxt@rock-chips.com> |
|---|---|
| Date | 2016-09-05 00:20 +0200 |
| Subject | [PATCH 1/2] dt-bindings: add the regulator optional properties |
| Message-ID | <sdNVD-3nb-1@gated-at.bofh.it> |
Add the regulator properties that will be used to power on/off
the regulator.
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: linux-input@vger.kernel.org
---
Documentation/devicetree/bindings/input/hid-over-i2c.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/input/hid-over-i2c.txt b/Documentation/devicetree/bindings/input/hid-over-i2c.txt
index 488edcb..e648e44 100644
--- a/Documentation/devicetree/bindings/input/hid-over-i2c.txt
+++ b/Documentation/devicetree/bindings/input/hid-over-i2c.txt
@@ -17,6 +17,9 @@ Required properties:
- interrupt-parent: the phandle for the interrupt controller
- interrupts: interrupt line
+Optional properties:
+- power-supply: phandle of the regulator that provides the supply voltage.
+
Example:
i2c-hid-dev@2c {
--
1.9.1
[toc] | [next] | [standalone]
| From | Caesar Wang <wxt@rock-chips.com> |
|---|---|
| Date | 2016-09-05 00:20 +0200 |
| Subject | [PATCH 2/2] HID: i2c-hid: support the regulator |
| Message-ID | <sdNVE-3nb-3@gated-at.bofh.it> |
| In reply to | #1476049 |
From: Brian Norris <briannorris@chromium.org>
In order to allow supporting the HID based devices that need power on/off
the regulator. We try to get a power-supply property from the
device tree.
Signed-off-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: linux-input@vger.kernel.org
---
drivers/hid/i2c-hid/i2c-hid.c | 31 ++++++++++++++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index b3ec4f2..07cc7aa 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -38,6 +38,7 @@
#include <linux/acpi.h>
#include <linux/of.h>
#include <linux/gpio/consumer.h>
+#include <linux/regulator/consumer.h>
#include <linux/i2c/i2c-hid.h>
@@ -152,6 +153,7 @@ struct i2c_hid {
bool irq_wake_enabled;
struct mutex reset_lock;
+ struct regulator *supply;
};
static int __i2c_hid_command(struct i2c_client *client,
@@ -968,6 +970,21 @@ static int i2c_hid_probe(struct i2c_client *client,
if (!ihid)
return -ENOMEM;
+ ihid->supply = devm_regulator_get(&client->dev, "power");
+ if (IS_ERR(ihid->supply)) {
+ ret = PTR_ERR(ihid->supply);
+ dev_err(&client->dev, "Failed to get power regulator: %d\n",
+ ret);
+ return ret;
+ }
+
+ ret = regulator_enable(ihid->supply);
+ if (ret < 0) {
+ dev_err(&client->dev, "Failed to enable power regulator: %d\n",
+ ret);
+ return ret;
+ }
+
if (client->dev.of_node) {
ret = i2c_hid_of_probe(client, &ihid->pdata);
if (ret)
@@ -1100,6 +1117,8 @@ static int i2c_hid_remove(struct i2c_client *client)
if (ihid->desc)
gpiod_put(ihid->desc);
+ regulator_disable(ihid->supply);
+
kfree(ihid);
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&client->dev));
@@ -1152,6 +1171,11 @@ static int i2c_hid_suspend(struct device *dev)
else
hid_warn(hid, "Failed to enable irq wake: %d\n",
wake_status);
+ } else {
+ ret = regulator_disable(ihid->supply);
+ if (ret < 0)
+ hid_warn(hid, "Failed to disable power supply: %d\n",
+ ret);
}
return 0;
@@ -1165,7 +1189,12 @@ static int i2c_hid_resume(struct device *dev)
struct hid_device *hid = ihid->hid;
int wake_status;
- if (device_may_wakeup(&client->dev) && ihid->irq_wake_enabled) {
+ if (!device_may_wakeup(&client->dev)) {
+ ret = regulator_enable(ihid->supply);
+ if (ret < 0)
+ hid_warn(hid, "Failed to enable power supply: %d\n",
+ ret);
+ } else if (ihid->irq_wake_enabled) {
wake_status = disable_irq_wake(ihid->irq);
if (!wake_status)
ihid->irq_wake_enabled = false;
--
1.9.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web