Skip to content

Commit 8cb2cba

Browse files
andy-shevchanwoochoi
authored andcommitted
extcon: int3496: Add GPIO ACPI mapping table
In order to make GPIO ACPI library stricter prepare users of gpiod_get_index() to correctly behave when there no mapping is provided by firmware. Here we add explicit mapping between _CRS GpioIo() resources and their names used in the driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
1 parent 90400c5 commit 8cb2cba

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

‎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/extcon-intel-int3496.c‎

Lines changed: 20 additions & 0 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,6 +94,13 @@ 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;
@@ -154,6 +172,8 @@ static int int3496_remove(struct platform_device *pdev)
154172
devm_free_irq(&pdev->dev, data->usb_id_irq, data);
155173
cancel_delayed_work_sync(&data->work);
156174

175+
acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
176+
157177
return 0;
158178
}
159179

0 commit comments

Comments
 (0)