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.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJY0kZcAAoJEJzN3yze689ToukP/0wSRpobMgasb32fwmP5nEPp
 GP2b0reeLUMU44u3XTooGi/+88O2krCekyA98cmpFzgX/v1FE5q7lpUSmxq9ZqhK
 Djrpb1hwhoe9cC8r87ytwlgVjFUYdwhEAhuE9vi1D/RNZWnbxTyxKe7F3O4O0SOg
 5uiSvvSIldLUuv6l/Zyn3cdCZyAQ0SwCqGcWdRIMo9tEmpIZ1oqKHGFbradQVi3Y
 6OMvjInbB6n3a0PxVP4ZMPyHW6En9KY/KgwQkc9u6nZSbFL810kEQn1/kTqG767h
 ZkKsys/JM4RHGXOK/BP9JgxiuW3t18gApOA6hV48bYRMHUzJB8AU9YHek7WnAdDE
 ZldOWMJz7wa/6mrvmaN0zaL0RLtaCbK+Afo2yGCb60ZIaawA8hrhLQtRaRYfTR1Y
 MrdZ3iaagbi76oqZMcjHOfPCAZp+V5OiWEJ0OuUO0WJzamNjEwZeLXA2HkgCshK/
 d8Ce2Y9heg6PMPfvEO9TmWJCtpXY4wOqi8iUlqr1EzL1ydXspIOVaPOJP8WWR2fG
 HNYksvDjAvJP311GoIY+tKNwOhnBAPxQ6QzCslr4ft7My1PMniuO6jeLVuvqDb2Q
 AH2ZhsTXA1QXIKhQySes00ldGmY8EuFDbDmtoybcvxUGDEprkvJlFntknM8vS6+x
 h4iN+MEm14aa5urIxhlg
 =agkm
 -----END PGP SIGNATURE-----

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.
This commit is contained in:
Greg Kroah-Hartman 2017-03-22 12:03:17 +01:00
commit 5c1724c42d
3 changed files with 34 additions and 12 deletions

View file

@ -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

View file

@ -44,7 +44,7 @@ config EXTCON_GPIO
config EXTCON_INTEL_INT3496
tristate "Intel INT3496 ACPI device extcon driver"
depends on GPIOLIB && ACPI
depends on GPIOLIB && ACPI && (X86 || COMPILE_TEST)
help
Say Y here to enable extcon support for USB OTG ports controlled by
an Intel INT3496 ACPI device.

View file

@ -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 =
@ -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;
@ -90,30 +108,27 @@ static int int3496_probe(struct platform_device *pdev)
data->dev = dev;
INIT_DELAYED_WORK(&data->work, int3496_do_usb_id);
data->gpio_usb_id = devm_gpiod_get_index(dev, "id",
INT3496_GPIO_USB_ID,
GPIOD_IN);
data->gpio_usb_id = devm_gpiod_get(dev, "id", GPIOD_IN);
if (IS_ERR(data->gpio_usb_id)) {
ret = PTR_ERR(data->gpio_usb_id);
dev_err(dev, "can't request USB ID GPIO: %d\n", ret);
return ret;
} else if (gpiod_get_direction(data->gpio_usb_id) != GPIOF_DIR_IN) {
dev_warn(dev, FW_BUG "USB ID GPIO not in input mode, fixing\n");
gpiod_direction_input(data->gpio_usb_id);
}
data->usb_id_irq = gpiod_to_irq(data->gpio_usb_id);
if (data->usb_id_irq <= 0) {
if (data->usb_id_irq < 0) {
dev_err(dev, "can't get USB ID IRQ: %d\n", data->usb_id_irq);
return -EINVAL;
return data->usb_id_irq;
}
data->gpio_vbus_en = devm_gpiod_get_index(dev, "vbus en",
INT3496_GPIO_VBUS_EN,
GPIOD_ASIS);
data->gpio_vbus_en = devm_gpiod_get(dev, "vbus", GPIOD_ASIS);
if (IS_ERR(data->gpio_vbus_en))
dev_info(dev, "can't request VBUS EN GPIO\n");
data->gpio_usb_mux = devm_gpiod_get_index(dev, "usb mux",
INT3496_GPIO_USB_MUX,
GPIOD_ASIS);
data->gpio_usb_mux = devm_gpiod_get(dev, "mux", GPIOD_ASIS);
if (IS_ERR(data->gpio_usb_mux))
dev_info(dev, "can't request USB MUX GPIO\n");
@ -154,6 +169,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;
}