Skip to content

Commit 5c1724c

Browse files
committed
Merge tag 'extcon-fixes-for-4.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-linus
Chanwoo writes: Update extcon for v4.11-rc3 This patch fixes issues for Intel INT3496 ACPI device as following: - Propagate error code of gpiod_to_irq(). - Set the ID pin as the input direction if firmware has the bug - Rename the gpio name for bining according to the documentation. - Add gpio acpi mapping table and the dependency on X86. - Use the devm_gpiod_get() instead of gpiod_get_index because of acpi mapping table.
2 parents c342356 + 70216fd commit 5c1724c

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

Documentation/extcon/intel-int3496.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,8 @@ Index 1: The output gpio for enabling Vbus output from the device to the otg
2020
Index 2: The output gpio for muxing of the data pins between the USB host and
2121
the USB peripheral controller, write 1 to mux to the peripheral
2222
controller
23+
24+
There is a mapping between indices and GPIO connection IDs as follows
25+
id index 0
26+
vbus index 1
27+
mux index 2

drivers/extcon/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ config EXTCON_GPIO
4444

4545
config EXTCON_INTEL_INT3496
4646
tristate "Intel INT3496 ACPI device extcon driver"
47-
depends on GPIOLIB && ACPI
47+
depends on GPIOLIB && ACPI && (X86 || COMPILE_TEST)
4848
help
4949
Say Y here to enable extcon support for USB OTG ports controlled by
5050
an Intel INT3496 ACPI device.

drivers/extcon/extcon-intel-int3496.c

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = {
4545
EXTCON_NONE,
4646
};
4747

48+
static const struct acpi_gpio_params id_gpios = { INT3496_GPIO_USB_ID, 0, false };
49+
static const struct acpi_gpio_params vbus_gpios = { INT3496_GPIO_VBUS_EN, 0, false };
50+
static const struct acpi_gpio_params mux_gpios = { INT3496_GPIO_USB_MUX, 0, false };
51+
52+
static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = {
53+
{ "id-gpios", &id_gpios, 1 },
54+
{ "vbus-gpios", &vbus_gpios, 1 },
55+
{ "mux-gpios", &mux_gpios, 1 },
56+
{ },
57+
};
58+
4859
static void int3496_do_usb_id(struct work_struct *work)
4960
{
5061
struct int3496_data *data =
@@ -83,37 +94,41 @@ static int int3496_probe(struct platform_device *pdev)
8394
struct int3496_data *data;
8495
int ret;
8596

97+
ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
98+
acpi_int3496_default_gpios);
99+
if (ret) {
100+
dev_err(dev, "can't add GPIO ACPI mapping\n");
101+
return ret;
102+
}
103+
86104
data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
87105
if (!data)
88106
return -ENOMEM;
89107

90108
data->dev = dev;
91109
INIT_DELAYED_WORK(&data->work, int3496_do_usb_id);
92110

93-
data->gpio_usb_id = devm_gpiod_get_index(dev, "id",
94-
INT3496_GPIO_USB_ID,
95-
GPIOD_IN);
111+
data->gpio_usb_id = devm_gpiod_get(dev, "id", GPIOD_IN);
96112
if (IS_ERR(data->gpio_usb_id)) {
97113
ret = PTR_ERR(data->gpio_usb_id);
98114
dev_err(dev, "can't request USB ID GPIO: %d\n", ret);
99115
return ret;
116+
} else if (gpiod_get_direction(data->gpio_usb_id) != GPIOF_DIR_IN) {
117+
dev_warn(dev, FW_BUG "USB ID GPIO not in input mode, fixing\n");
118+
gpiod_direction_input(data->gpio_usb_id);
100119
}
101120

102121
data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id);
103-
if (data->usb_id_irq <= 0) {
122+
if (data->usb_id_irq < 0) {
104123
dev_err(dev, "can't get USB ID IRQ: %d\n", data->usb_id_irq);
105-
return -EINVAL;
124+
return data->usb_id_irq;
106125
}
107126

108-
data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
109-
INT3496_GPIO_VBUS_EN,
110-
GPIOD_ASIS);
127+
data->gpio_vbus_en = devm_gpiod_get(dev, "vbus", GPIOD_ASIS);
111128
if (IS_ERR(data->gpio_vbus_en))
112129
dev_info(dev, "can't request VBUS EN GPIO\n");
113130

114-
data->gpio_usb_mux = devm_gpiod_get_index(dev, "usb mux",
115-
INT3496_GPIO_USB_MUX,
116-
GPIOD_ASIS);
131+
data->gpio_usb_mux = devm_gpiod_get(dev, "mux", GPIOD_ASIS);
117132
if (IS_ERR(data->gpio_usb_mux))
118133
dev_info(dev, "can't request USB MUX GPIO\n");
119134

@@ -154,6 +169,8 @@ static int int3496_remove(struct platform_device *pdev)
154169
devm_free_irq(&pdev->dev, data->usb_id_irq, data);
155170
cancel_delayed_work_sync(&data->work);
156171

172+
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
173+
157174
return 0;
158175
}
159176

0 commit comments

Comments
 (0)