[PATCH v1 1/7] usb: cdns3: Set USB PHY mode in cdns3_probe()
Marek Vasut
marex at denx.de
Wed May 8 03:27:44 CEST 2024
On 5/4/24 5:03 PM, Minda Chen wrote:
> USB PHY maybe need to set PHY mode in different USB
> dr mode. So translate to generic PHY mode and call
> generic_phy_set_mode().
>
> Signed-off-by: Minda Chen <minda.chen at starfivetech.com>
> ---
> drivers/usb/cdns3/core.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> index 12a741c6ea..c1a61471f9 100644
> --- a/drivers/usb/cdns3/core.c
> +++ b/drivers/usb/cdns3/core.c
> @@ -321,6 +321,7 @@ static int cdns3_probe(struct cdns3 *cdns)
> {
> struct udevice *dev = cdns->dev;
> int ret;
> + int mode = PHY_MODE_INVALID;
Please swap ret and mode to keep this list sorted.
> cdns->xhci_regs = dev_remap_addr_name(dev, "xhci");
> if (!cdns->xhci_regs)
> @@ -372,6 +373,22 @@ static int cdns3_probe(struct cdns3 *cdns)
> if (ret)
> return ret;
>
> + if (cdns->dr_mode == USB_DR_MODE_HOST)
> + mode = PHY_MODE_USB_HOST;
> + else if (cdns->dr_mode == USB_DR_MODE_PERIPHERAL)
> + mode = PHY_MODE_USB_DEVICE;
> + else if (cdns->dr_mode == USB_DR_MODE_OTG)
> + mode = PHY_MODE_USB_OTG;
> +
> + if (mode != PHY_MODE_INVALID) {
Better invert the condition this way to reduce indent:
if (mode == PHY_MODE_INVALID) {
dev_err(...report the error...);
return ret;
}
ret = generic_phy_set...
> + ret = generic_phy_set_mode(&cdns->usb2_phy, mode, 0);
> + if (ret)
> + return ret;
> + ret = generic_phy_set_mode(&cdns->usb3_phy, mode, 0);
> + if (ret)
> + return ret;
> + }
> +
> dev_dbg(dev, "Cadence USB3 core: probe succeed\n");
>
> return 0;
More information about the U-Boot
mailing list