diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-02-24 07:35:55 -0500 |
---|---|---|
committer | Chanwoo Choi <cw00.choi@samsung.com> | 2017-03-22 05:29:46 -0400 |
commit | 8cb2cbae45ae46b1e1be16950670d5c5d4408474 (patch) | |
tree | 89c51bfb02568a4e3d749281fb6089bfb41677b2 | |
parent | 90400c5884b89a5db232049721ef4dc1ab2f1f1c (diff) |
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>
-rw-r--r-- | Documentation/extcon/intel-int3496.txt | 5 | ||||
-rw-r--r-- | drivers/extcon/extcon-intel-int3496.c | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/Documentation/extcon/intel-int3496.txt b/Documentation/extcon/intel-int3496.txt index af0b366c25b7..8155dbc7fad3 100644 --- a/Documentation/extcon/intel-int3496.txt +++ b/Documentation/extcon/intel-int3496.txt | |||
@@ -20,3 +20,8 @@ Index 1: The output gpio for enabling Vbus output from the device to the otg | |||
20 | Index 2: The output gpio for muxing of the data pins between the USB host and | 20 | Index 2: The output gpio for muxing of the data pins between the USB host and |
21 | the USB peripheral controller, write 1 to mux to the peripheral | 21 | the USB peripheral controller, write 1 to mux to the peripheral |
22 | controller | 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 | ||
diff --git a/drivers/extcon/extcon-intel-int3496.c b/drivers/extcon/extcon-intel-int3496.c index 81713bf7487e..22a529eb1b1a 100644 --- a/drivers/extcon/extcon-intel-int3496.c +++ b/drivers/extcon/extcon-intel-int3496.c | |||
@@ -45,6 +45,17 @@ static const unsigned int int3496_cable[] = { | |||
45 | EXTCON_NONE, | 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 | static void int3496_do_usb_id(struct work_struct *work) | 59 | static void int3496_do_usb_id(struct work_struct *work) |
49 | { | 60 | { |
50 | struct int3496_data *data = | 61 | struct int3496_data *data = |
@@ -83,6 +94,13 @@ static int int3496_probe(struct platform_device *pdev) | |||
83 | struct int3496_data *data; | 94 | struct int3496_data *data; |
84 | int ret; | 95 | int ret; |
85 | 96 | ||
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 | |||
86 | data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); | 104 | data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); |
87 | if (!data) | 105 | if (!data) |
88 | return -ENOMEM; | 106 | return -ENOMEM; |
@@ -154,6 +172,8 @@ static int int3496_remove(struct platform_device *pdev) | |||
154 | devm_free_irq(&pdev->dev, data->usb_id_irq, data); | 172 | devm_free_irq(&pdev->dev, data->usb_id_irq, data); |
155 | cancel_delayed_work_sync(&data->work); | 173 | cancel_delayed_work_sync(&data->work); |
156 | 174 | ||
175 | acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev)); | ||
176 | |||
157 | return 0; | 177 | return 0; |
158 | } | 178 | } |
159 | 179 | ||