Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Chanwoo Choi
8cb2cbae 90400c58

+25
+5
Documentation/extcon/intel-int3496.txt
··· 20 20 Index 2: The output gpio for muxing of the data pins between the USB host and 21 21 the USB peripheral controller, write 1 to mux to the peripheral 22 22 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
+20
drivers/extcon/extcon-intel-int3496.c
··· 45 45 EXTCON_NONE, 46 46 }; 47 47 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 + 48 59 static void int3496_do_usb_id(struct work_struct *work) 49 60 { 50 61 struct int3496_data *data = ··· 93 82 struct device *dev = &pdev->dev; 94 83 struct int3496_data *data; 95 84 int ret; 85 + 86 + ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(dev), 87 + acpi_int3496_default_gpios); 88 + if (ret) { 89 + dev_err(dev, "can't add GPIO ACPI mapping\n"); 90 + return ret; 91 + } 96 92 97 93 data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); 98 94 if (!data) ··· 171 153 172 154 devm_free_irq(&pdev->dev, data->usb_id_irq, data); 173 155 cancel_delayed_work_sync(&data->work); 156 + 157 + acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev)); 174 158 175 159 return 0; 176 160 }