• Linus Walleij's avatar
    usb: gadget: pch_udc: Convert to use GPIO descriptors · e20849a8
    Linus Walleij authored
    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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
    Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
    Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
    e20849a8
pch_udc.c 86.2 KB