Skip to content

Commit

Permalink
extcon: int3496: Add GPIO ACPI mapping table
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko authored and Chanwoo Choi committed Mar 22, 2017
1 parent 90400c5 commit 8cb2cba
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Documentation/extcon/intel-int3496.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,8 @@ Index 1: The output gpio for enabling Vbus output from the device to the otg
Index 2: The output gpio for muxing of the data pins between the USB host and
the USB peripheral controller, write 1 to mux to the peripheral
controller

There is a mapping between indices and GPIO connection IDs as follows
id index 0
vbus index 1
mux index 2
20 changes: 20 additions & 0 deletions drivers/extcon/extcon-intel-int3496.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = {
EXTCON_NONE,
};

static const struct acpi_gpio_params id_gpios = { INT3496_GPIO_USB_ID, 0, false };
static const struct acpi_gpio_params vbus_gpios = { INT3496_GPIO_VBUS_EN, 0, false };
static const struct acpi_gpio_params mux_gpios = { INT3496_GPIO_USB_MUX, 0, false };

static const struct acpi_gpio_mapping acpi_int3496_default_gpios[] = {
{ "id-gpios", &id_gpios, 1 },
{ "vbus-gpios", &vbus_gpios, 1 },
{ "mux-gpios", &mux_gpios, 1 },
{ },
};

static void int3496_do_usb_id(struct work_struct *work)
{
struct int3496_data *data =
Expand Down Expand Up @@ -83,6 +94,13 @@ static int int3496_probe(struct platform_device *pdev)
struct int3496_data *data;
int ret;

ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev),
acpi_int3496_default_gpios);
if (ret) {
dev_err(dev, "can't add GPIO ACPI mapping\n");
return ret;
}

data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
Expand Down Expand Up @@ -154,6 +172,8 @@ static int int3496_remove(struct platform_device *pdev)
devm_free_irq(&pdev->dev, data->usb_id_irq, data);
cancel_delayed_work_sync(&data->work);

acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));

return 0;
}

Expand Down

0 comments on commit 8cb2cba

Please sign in to comment.