Skip to content

Commit 0f7566c

Browse files
committed
Merge branch 'for-6.3/i2c-hid' into for-linus
- dev_dbg cleanup (Thomas Weißschuh) - cleanup i2c-hid-acpi (Andy Shevchenko) - goodix: revert/fixes for an actual production device compared to the manufacturer sample (Douglas Anderson)
2 parents 2818ccb + eb16f59 commit 0f7566c

File tree

4 files changed

+43
-103
lines changed

4 files changed

+43
-103
lines changed

Documentation/devicetree/bindings/input/goodix,gt7375p.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ properties:
3636
vdd-supply:
3737
description: The 3.3V supply to the touchscreen.
3838

39+
mainboard-vddio-supply:
40+
description:
41+
The supply on the main board needed to power up IO signals going
42+
to the touchscreen. This supply need not go to the touchscreen
43+
itself as long as it allows the main board to make signals compatible
44+
with what the touchscreen is expecting for its IO rails.
45+
3946
required:
4047
- compatible
4148
- reg

drivers/hid/i2c-hid/i2c-hid-acpi.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@ static const struct acpi_device_id i2c_hid_acpi_blacklist[] = {
3939
* The CHPN0001 ACPI device, which is used to describe the Chipone
4040
* ICN8505 controller, has a _CID of PNP0C50 but is not HID compatible.
4141
*/
42-
{"CHPN0001", 0 },
43-
{ },
42+
{ "CHPN0001" },
43+
{ }
4444
};
4545

4646
/* HID I²C Device: 3cdff6f7-4267-4555-ad05-b30a3d8938de */
4747
static guid_t i2c_hid_guid =
4848
GUID_INIT(0x3CDFF6F7, 0x4267, 0x4555,
4949
0xAD, 0x05, 0xB3, 0x0A, 0x3D, 0x89, 0x38, 0xDE);
5050

51-
static int i2c_hid_acpi_get_descriptor(struct acpi_device *adev)
51+
static int i2c_hid_acpi_get_descriptor(struct i2c_hid_acpi *ihid_acpi)
5252
{
53+
struct acpi_device *adev = ihid_acpi->adev;
5354
acpi_handle handle = acpi_device_handle(adev);
5455
union acpi_object *obj;
5556
u16 hid_descriptor_address;
@@ -81,38 +82,31 @@ static int i2c_hid_acpi_probe(struct i2c_client *client)
8182
{
8283
struct device *dev = &client->dev;
8384
struct i2c_hid_acpi *ihid_acpi;
84-
struct acpi_device *adev;
8585
u16 hid_descriptor_address;
8686
int ret;
8787

88-
adev = ACPI_COMPANION(dev);
89-
if (!adev) {
90-
dev_err(&client->dev, "Error could not get ACPI device\n");
91-
return -ENODEV;
92-
}
93-
9488
ihid_acpi = devm_kzalloc(&client->dev, sizeof(*ihid_acpi), GFP_KERNEL);
9589
if (!ihid_acpi)
9690
return -ENOMEM;
9791

98-
ihid_acpi->adev = adev;
92+
ihid_acpi->adev = ACPI_COMPANION(dev);
9993
ihid_acpi->ops.shutdown_tail = i2c_hid_acpi_shutdown_tail;
10094

101-
ret = i2c_hid_acpi_get_descriptor(adev);
95+
ret = i2c_hid_acpi_get_descriptor(ihid_acpi);
10296
if (ret < 0)
10397
return ret;
10498
hid_descriptor_address = ret;
10599

106-
acpi_device_fix_up_power(adev);
100+
acpi_device_fix_up_power(ihid_acpi->adev);
107101

108102
return i2c_hid_core_probe(client, &ihid_acpi->ops,
109103
hid_descriptor_address, 0);
110104
}
111105

112106
static const struct acpi_device_id i2c_hid_acpi_match[] = {
113-
{"ACPI0C50", 0 },
114-
{"PNP0C50", 0 },
115-
{ },
107+
{ "ACPI0C50" },
108+
{ "PNP0C50" },
109+
{ }
116110
};
117111
MODULE_DEVICE_TABLE(acpi, i2c_hid_acpi_match);
118112

drivers/hid/i2c-hid/i2c-hid-core.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,7 @@
6767
#define I2C_HID_PWR_ON 0x00
6868
#define I2C_HID_PWR_SLEEP 0x01
6969

70-
/* debug option */
71-
static bool debug;
72-
module_param(debug, bool, 0444);
73-
MODULE_PARM_DESC(debug, "print a lot of debug information");
74-
75-
#define i2c_hid_dbg(ihid, fmt, arg...) \
76-
do { \
77-
if (debug) \
78-
dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \
79-
} while (0)
70+
#define i2c_hid_dbg(ihid, ...) dev_dbg(&(ihid)->client->dev, __VA_ARGS__)
8071

8172
struct i2c_hid_desc {
8273
__le16 wHIDDescLength;
@@ -858,7 +849,7 @@ static int i2c_hid_init_irq(struct i2c_client *client)
858849
unsigned long irqflags = 0;
859850
int ret;
860851

861-
dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq);
852+
i2c_hid_dbg(ihid, "Requesting IRQ: %d\n", client->irq);
862853

863854
if (!irq_get_trigger_type(client->irq))
864855
irqflags = IRQF_TRIGGER_LOW;
@@ -1002,7 +993,7 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
1002993
/* Make sure there is something at this address */
1003994
ret = i2c_smbus_read_byte(client);
1004995
if (ret < 0) {
1005-
dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
996+
i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret);
1006997
ret = -ENXIO;
1007998
goto err_powered;
1008999
}

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

Lines changed: 23 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -26,71 +26,49 @@ struct i2c_hid_of_goodix {
2626
struct i2chid_ops ops;
2727

2828
struct regulator *vdd;
29-
struct notifier_block nb;
29+
struct regulator *vddio;
3030
struct gpio_desc *reset_gpio;
3131
const struct goodix_i2c_hid_timing_data *timings;
3232
};
3333

34-
static void goodix_i2c_hid_deassert_reset(struct i2c_hid_of_goodix *ihid_goodix,
35-
bool regulator_just_turned_on)
34+
static int goodix_i2c_hid_power_up(struct i2chid_ops *ops)
3635
{
37-
if (regulator_just_turned_on && ihid_goodix->timings->post_power_delay_ms)
36+
struct i2c_hid_of_goodix *ihid_goodix =
37+
container_of(ops, struct i2c_hid_of_goodix, ops);
38+
int ret;
39+
40+
ret = regulator_enable(ihid_goodix->vdd);
41+
if (ret)
42+
return ret;
43+
44+
ret = regulator_enable(ihid_goodix->vddio);
45+
if (ret)
46+
return ret;
47+
48+
if (ihid_goodix->timings->post_power_delay_ms)
3849
msleep(ihid_goodix->timings->post_power_delay_ms);
3950

4051
gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 0);
4152
if (ihid_goodix->timings->post_gpio_reset_delay_ms)
4253
msleep(ihid_goodix->timings->post_gpio_reset_delay_ms);
43-
}
44-
45-
static int goodix_i2c_hid_power_up(struct i2chid_ops *ops)
46-
{
47-
struct i2c_hid_of_goodix *ihid_goodix =
48-
container_of(ops, struct i2c_hid_of_goodix, ops);
4954

50-
return regulator_enable(ihid_goodix->vdd);
55+
return 0;
5156
}
5257

5358
static void goodix_i2c_hid_power_down(struct i2chid_ops *ops)
5459
{
5560
struct i2c_hid_of_goodix *ihid_goodix =
5661
container_of(ops, struct i2c_hid_of_goodix, ops);
5762

63+
gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 1);
64+
regulator_disable(ihid_goodix->vddio);
5865
regulator_disable(ihid_goodix->vdd);
5966
}
6067

61-
static int ihid_goodix_vdd_notify(struct notifier_block *nb,
62-
unsigned long event,
63-
void *ignored)
64-
{
65-
struct i2c_hid_of_goodix *ihid_goodix =
66-
container_of(nb, struct i2c_hid_of_goodix, nb);
67-
int ret = NOTIFY_OK;
68-
69-
switch (event) {
70-
case REGULATOR_EVENT_PRE_DISABLE:
71-
gpiod_set_value_cansleep(ihid_goodix->reset_gpio, 1);
72-
break;
73-
74-
case REGULATOR_EVENT_ENABLE:
75-
goodix_i2c_hid_deassert_reset(ihid_goodix, true);
76-
break;
77-
78-
case REGULATOR_EVENT_ABORT_DISABLE:
79-
goodix_i2c_hid_deassert_reset(ihid_goodix, false);
80-
break;
81-
82-
default:
83-
ret = NOTIFY_DONE;
84-
break;
85-
}
86-
87-
return ret;
88-
}
89-
9068
static int i2c_hid_of_goodix_probe(struct i2c_client *client)
9169
{
9270
struct i2c_hid_of_goodix *ihid_goodix;
93-
int ret;
71+
9472
ihid_goodix = devm_kzalloc(&client->dev, sizeof(*ihid_goodix),
9573
GFP_KERNEL);
9674
if (!ihid_goodix)
@@ -109,41 +87,11 @@ static int i2c_hid_of_goodix_probe(struct i2c_client *client)
10987
if (IS_ERR(ihid_goodix->vdd))
11088
return PTR_ERR(ihid_goodix->vdd);
11189

112-
ihid_goodix->timings = device_get_match_data(&client->dev);
90+
ihid_goodix->vddio = devm_regulator_get(&client->dev, "mainboard-vddio");
91+
if (IS_ERR(ihid_goodix->vddio))
92+
return PTR_ERR(ihid_goodix->vddio);
11393

114-
/*
115-
* We need to control the "reset" line in lockstep with the regulator
116-
* actually turning on an off instead of just when we make the request.
117-
* This matters if the regulator is shared with another consumer.
118-
* - If the regulator is off then we must assert reset. The reset
119-
* line is active low and on some boards it could cause a current
120-
* leak if left high.
121-
* - If the regulator is on then we don't want reset asserted for very
122-
* long. Holding the controller in reset apparently draws extra
123-
* power.
124-
*/
125-
ihid_goodix->nb.notifier_call = ihid_goodix_vdd_notify;
126-
ret = devm_regulator_register_notifier(ihid_goodix->vdd, &ihid_goodix->nb);
127-
if (ret)
128-
return dev_err_probe(&client->dev, ret,
129-
"regulator notifier request failed\n");
130-
131-
/*
132-
* If someone else is holding the regulator on (or the regulator is
133-
* an always-on one) we might never be told to deassert reset. Do it
134-
* now... and temporarily bump the regulator reference count just to
135-
* make sure it is impossible for this to race with our own notifier!
136-
* We also assume that someone else might have _just barely_ turned
137-
* the regulator on so we'll do the full "post_power_delay" just in
138-
* case.
139-
*/
140-
if (ihid_goodix->reset_gpio && regulator_is_enabled(ihid_goodix->vdd)) {
141-
ret = regulator_enable(ihid_goodix->vdd);
142-
if (ret)
143-
return ret;
144-
goodix_i2c_hid_deassert_reset(ihid_goodix, true);
145-
regulator_disable(ihid_goodix->vdd);
146-
}
94+
ihid_goodix->timings = device_get_match_data(&client->dev);
14795

14896
return i2c_hid_core_probe(client, &ihid_goodix->ops, 0x0001, 0);
14997
}

0 commit comments

Comments
 (0)