usb: gadget: pch_udc: Convert to use GPIO descriptors
authorLinus Walleij <linus.walleij@linaro.org>
Fri, 28 Aug 2020 15:30:55 +0000 (17:30 +0200)
committerFelipe Balbi <balbi@kernel.org>
Fri, 2 Oct 2020 06:57:38 +0000 (09:57 +0300)
commite20849a8c883abfe4c075f72bf5538d63b7562c4
tree9d17284ef9090452b01b2b0a3d1f189979c28a6d
parentff6d6e6c6778da68a95074d6c2dda6db18c56888
usb: gadget: pch_udc: Convert to use GPIO descriptors

This switches the PCH UDC driver to use GPIO descriptors. The way
this is supposed to be used is confusing. The code contains the
following:

    /* GPIO port for VBUS detecting */
    static int vbus_gpio_port = -1; /* GPIO port number (-1:Not used) */

So a hardcoded GPIO number in the code. Further the probe() path
very clearly will exit if the GPIO is not found, so this driver
can only be configured by editing the code, hard-coding a GPIO
number into this variable.

This is simply not how we do things. My guess is that this is
used in products by patching a GPIO number into this variable and
shipping a kernel that is compile-time tailored for the target
system.

I switched this mechanism to using a GPIO descriptor associated
with the parent PCI device. This can be added by using the 16bit
subsystem ID or similar to identify which exact machine we are
running on and what GPIO is present on that machine, and then
add a GPIO descriptor using gpiod_add_lookup_table() from
<linux/gpio/machine.h>. Since I don't have any target systems
I cannot add this but I'm happy to help. I put in a FIXME so
the people actually using this driver knows what to do.

Cc: Felipe Balbi <balbi@kernel.org>
Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/gadget/udc/pch_udc.c