Skip to content

Commit 2be4044

Browse files
jwrdegoedebentiss
authored andcommitted
HID: i2c-hid-of: Add reset GPIO support to i2c-hid-of
Add reset GPIO support to the generic i2c-hid-of driver This is necessary to make the Wacom digitizer on the Lenovo Yoga Book 1 (yb1-x90f/l) work and this will also allow consolidating the 2 specialized i2c-hid-of-elan.c and i2c-hid-of-goodix.c drivers into the generic i2c-hid-of driver. For now the new "post-reset-deassert-delay-ms" property is only used on x86/ACPI (non devicetree) devs. IOW it is not used in actual devicetree files and the same goes for the reset GPIO. The devicetree-bindings maintainers have requested properties like these to not be added to the devicetree-bindings, so the new property + GPIO are deliberately not added to the existing devicetree-bindings. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20230413093625.71146-4-hdegoede@redhat.com Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
1 parent 728ec8b commit 2be4044

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

drivers/hid/i2c-hid/i2c-hid-of.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <linux/delay.h>
2323
#include <linux/device.h>
24+
#include <linux/gpio/consumer.h>
2425
#include <linux/hid.h>
2526
#include <linux/i2c.h>
2627
#include <linux/kernel.h>
@@ -35,8 +36,10 @@ struct i2c_hid_of {
3536
struct i2chid_ops ops;
3637

3738
struct i2c_client *client;
39+
struct gpio_desc *reset_gpio;
3840
struct regulator_bulk_data supplies[2];
3941
int post_power_delay_ms;
42+
int post_reset_delay_ms;
4043
};
4144

4245
static int i2c_hid_of_power_up(struct i2chid_ops *ops)
@@ -55,13 +58,18 @@ static int i2c_hid_of_power_up(struct i2chid_ops *ops)
5558
if (ihid_of->post_power_delay_ms)
5659
msleep(ihid_of->post_power_delay_ms);
5760

61+
gpiod_set_value_cansleep(ihid_of->reset_gpio, 0);
62+
if (ihid_of->post_reset_delay_ms)
63+
msleep(ihid_of->post_reset_delay_ms);
64+
5865
return 0;
5966
}
6067

6168
static void i2c_hid_of_power_down(struct i2chid_ops *ops)
6269
{
6370
struct i2c_hid_of *ihid_of = container_of(ops, struct i2c_hid_of, ops);
6471

72+
gpiod_set_value_cansleep(ihid_of->reset_gpio, 1);
6573
regulator_bulk_disable(ARRAY_SIZE(ihid_of->supplies),
6674
ihid_of->supplies);
6775
}
@@ -96,6 +104,19 @@ static int i2c_hid_of_probe(struct i2c_client *client)
96104
if (!device_property_read_u32(dev, "post-power-on-delay-ms", &val))
97105
ihid_of->post_power_delay_ms = val;
98106

107+
/*
108+
* Note this is a kernel internal device-property set by x86 platform code,
109+
* this MUST not be used in devicetree files without first adding it to
110+
* the DT bindings.
111+
*/
112+
if (!device_property_read_u32(dev, "post-reset-deassert-delay-ms", &val))
113+
ihid_of->post_reset_delay_ms = val;
114+
115+
/* Start out with reset asserted */
116+
ihid_of->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
117+
if (IS_ERR(ihid_of->reset_gpio))
118+
return PTR_ERR(ihid_of->reset_gpio);
119+
99120
ihid_of->supplies[0].supply = "vdd";
100121
ihid_of->supplies[1].supply = "vddl";
101122
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ihid_of->supplies),

0 commit comments

Comments
 (0)