On Fri, Jun 12, 2015 at 09:10:19AM +0200, Uwe Kleine-König wrote:
> Since 39b2bbe3d715 (gpio: add flags argument to gpiod_get*() functions)
> which appeared in v3.17-rc1, the gpiod_get* functions take an additional
> parameter that allows to specify direction and initial value for output.
> 
> Furthermore there is devm_gpiod_get_optional which is designed to get
> optional gpios. Also use devm_gpiod_get* because otherwise the gpio
> might be grabbed by a different driver.

These gpios are later given to the phy driver. We handle them in this
quirk separately because otherwise the phy can not be probed as it
may still be in reset.

So we are just turning the phy "on" here, and then releasing the gpios
so the phy driver can take over.

> diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
> index 27e4fc896e9d..7e308730f955 100644
> --- a/drivers/usb/dwc3/dwc3-pci.c
> +++ b/drivers/usb/dwc3/dwc3-pci.c
> @@ -84,18 +84,19 @@ static int dwc3_pci_quirks(struct pci_dev *pdev)
>                                         acpi_dwc3_byt_gpios);
>  
>               /* These GPIOs will turn on the USB2 PHY */
> -             gpio = gpiod_get(&pdev->dev, "cs");
> -             if (!IS_ERR(gpio)) {
> -                     gpiod_direction_output(gpio, 0);
> -                     gpiod_set_value_cansleep(gpio, 1);
> -                     gpiod_put(gpio);
> -             }
> +             gpio = devm_gpiod_get_optional(&pdev->dev, "cs", GPIOD_OUT_LOW);
> +             if (IS_ERR(gpio))
> +                     return PTR_ERR(gpio);
> +
> +             gpiod_set_value_cansleep(gpio, 1);
> +
> +             gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
> +                                            GPIOD_OUT_LOW);
> +             if (IS_ERR(gpio))
> +                     return PTR_ERR(gpio);
>  
> -             gpio = gpiod_get(&pdev->dev, "reset");
> -             if (!IS_ERR(gpio)) {
> -                     gpiod_direction_output(gpio, 0);
> +             if (gpio) {
>                       gpiod_set_value_cansleep(gpio, 1);
> -                     gpiod_put(gpio);

So we still need to release the gpio here, or we break the platforms
where we have these gpios.


Thanks,

-- 
heikki
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to