Skip to content

Commit 1e5d726

Browse files
author
Benjamin Tissoires
committed
Merge branch 'for-6.6/elan' into for-linus
Make use of panel follower for the Ilitek ili9882t driver by Cong Yang
2 parents 7d4de0d + f2f43bf commit 1e5d726

File tree

2 files changed

+105
-12
lines changed

2 files changed

+105
-12
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/input/ilitek,ili9882t.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Ilitek ili9882t touchscreen controller
8+
9+
maintainers:
10+
- Cong Yang <[email protected]>
11+
12+
description:
13+
Supports the Ilitek ili9882t touchscreen controller.
14+
This touchscreen controller uses the i2c-hid protocol with a reset GPIO.
15+
16+
allOf:
17+
- $ref: /schemas/input/touchscreen/touchscreen.yaml#
18+
19+
properties:
20+
compatible:
21+
const: ilitek,ili9882t
22+
23+
reg:
24+
const: 0x41
25+
26+
interrupts:
27+
maxItems: 1
28+
29+
panel: true
30+
31+
reset-gpios:
32+
maxItems: 1
33+
description: Reset GPIO.
34+
35+
vccio-supply:
36+
description: The 1.8V supply to the touchscreen.
37+
38+
required:
39+
- compatible
40+
- reg
41+
- interrupts
42+
- panel
43+
- vccio-supply
44+
45+
additionalProperties: false
46+
47+
examples:
48+
- |
49+
#include <dt-bindings/gpio/gpio.h>
50+
#include <dt-bindings/interrupt-controller/irq.h>
51+
52+
i2c {
53+
#address-cells = <1>;
54+
#size-cells = <0>;
55+
56+
touchscreen: touchscreen@41 {
57+
compatible = "ilitek,ili9882t";
58+
reg = <0x41>;
59+
60+
interrupt-parent = <&pio>;
61+
interrupts = <12 IRQ_TYPE_LEVEL_LOW>;
62+
63+
panel = <&panel>;
64+
reset-gpios = <&pio 60 GPIO_ACTIVE_LOW>;
65+
vccio-supply = <&mt6366_vio18_reg>;
66+
};
67+
};

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

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
#include "i2c-hid.h"
1919

2020
struct elan_i2c_hid_chip_data {
21-
unsigned int post_gpio_reset_delay_ms;
21+
unsigned int post_gpio_reset_on_delay_ms;
22+
unsigned int post_gpio_reset_off_delay_ms;
2223
unsigned int post_power_delay_ms;
2324
u16 hid_descriptor_address;
25+
const char *main_supply_name;
2426
};
2527

2628
struct i2c_hid_of_elan {
@@ -38,9 +40,11 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
3840
container_of(ops, struct i2c_hid_of_elan, ops);
3941
int ret;
4042

41-
ret = regulator_enable(ihid_elan->vcc33);
42-
if (ret)
43-
return ret;
43+
if (ihid_elan->vcc33) {
44+
ret = regulator_enable(ihid_elan->vcc33);
45+
if (ret)
46+
return ret;
47+
}
4448

4549
ret = regulator_enable(ihid_elan->vccio);
4650
if (ret) {
@@ -52,8 +56,8 @@ static int elan_i2c_hid_power_up(struct i2chid_ops *ops)
5256
msleep(ihid_elan->chip_data->post_power_delay_ms);
5357

5458
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 0);
55-
if (ihid_elan->chip_data->post_gpio_reset_delay_ms)
56-
msleep(ihid_elan->chip_data->post_gpio_reset_delay_ms);
59+
if (ihid_elan->chip_data->post_gpio_reset_on_delay_ms)
60+
msleep(ihid_elan->chip_data->post_gpio_reset_on_delay_ms);
5761

5862
return 0;
5963
}
@@ -64,8 +68,12 @@ static void elan_i2c_hid_power_down(struct i2chid_ops *ops)
6468
container_of(ops, struct i2c_hid_of_elan, ops);
6569

6670
gpiod_set_value_cansleep(ihid_elan->reset_gpio, 1);
71+
if (ihid_elan->chip_data->post_gpio_reset_off_delay_ms)
72+
msleep(ihid_elan->chip_data->post_gpio_reset_off_delay_ms);
73+
6774
regulator_disable(ihid_elan->vccio);
68-
regulator_disable(ihid_elan->vcc33);
75+
if (ihid_elan->vcc33)
76+
regulator_disable(ihid_elan->vcc33);
6977
}
7078

7179
static int i2c_hid_of_elan_probe(struct i2c_client *client)
@@ -89,24 +97,42 @@ static int i2c_hid_of_elan_probe(struct i2c_client *client)
8997
if (IS_ERR(ihid_elan->vccio))
9098
return PTR_ERR(ihid_elan->vccio);
9199

92-
ihid_elan->vcc33 = devm_regulator_get(&client->dev, "vcc33");
93-
if (IS_ERR(ihid_elan->vcc33))
94-
return PTR_ERR(ihid_elan->vcc33);
95-
96100
ihid_elan->chip_data = device_get_match_data(&client->dev);
97101

102+
if (ihid_elan->chip_data->main_supply_name) {
103+
ihid_elan->vcc33 = devm_regulator_get(&client->dev,
104+
ihid_elan->chip_data->main_supply_name);
105+
if (IS_ERR(ihid_elan->vcc33))
106+
return PTR_ERR(ihid_elan->vcc33);
107+
}
108+
98109
return i2c_hid_core_probe(client, &ihid_elan->ops,
99110
ihid_elan->chip_data->hid_descriptor_address, 0);
100111
}
101112

102113
static const struct elan_i2c_hid_chip_data elan_ekth6915_chip_data = {
103114
.post_power_delay_ms = 1,
104-
.post_gpio_reset_delay_ms = 300,
115+
.post_gpio_reset_on_delay_ms = 300,
116+
.hid_descriptor_address = 0x0001,
117+
.main_supply_name = "vcc33",
118+
};
119+
120+
static const struct elan_i2c_hid_chip_data ilitek_ili9882t_chip_data = {
121+
.post_power_delay_ms = 1,
122+
.post_gpio_reset_on_delay_ms = 200,
123+
.post_gpio_reset_off_delay_ms = 65,
105124
.hid_descriptor_address = 0x0001,
125+
/*
126+
* this touchscreen is tightly integrated with the panel and assumes
127+
* that the relevant power rails (other than the IO rail) have already
128+
* been turned on by the panel driver because we're a panel follower.
129+
*/
130+
.main_supply_name = NULL,
106131
};
107132

108133
static const struct of_device_id elan_i2c_hid_of_match[] = {
109134
{ .compatible = "elan,ekth6915", .data = &elan_ekth6915_chip_data },
135+
{ .compatible = "ilitek,ili9882t", .data = &ilitek_ili9882t_chip_data },
110136
{ }
111137
};
112138
MODULE_DEVICE_TABLE(of, elan_i2c_hid_of_match);

0 commit comments

Comments
 (0)