[PATCH v2 1/8] usb: cdns3: Set USB PHY mode in cdns3_core_init_role()
Roger Quadros
rogerq at kernel.org
Thu Jul 4 15:30:04 CEST 2024
Hi,
On 04/07/2024 08:50, 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 | 25 +++++++++++++++++++++++++
> 1 file changed, 25 insertions(+)
>
> diff --git a/drivers/usb/cdns3/core.c b/drivers/usb/cdns3/core.c
> index 12a741c6ea..1e863bed89 100644
> --- a/drivers/usb/cdns3/core.c
> +++ b/drivers/usb/cdns3/core.c
> @@ -107,6 +107,7 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
> {
> struct udevice *dev = cdns->dev;
> enum usb_dr_mode best_dr_mode;
> + int mode = PHY_MODE_INVALID;
> enum usb_dr_mode dr_mode;
> int ret = 0;
>
> @@ -173,6 +174,30 @@ static int cdns3_core_init_role(struct cdns3 *cdns)
>
> cdns->dr_mode = dr_mode;
>
> + 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;
> + } else {
> + dev_err(dev, "Unknown dr mode %d\n", cdns->dr_mode);
> + ret = -EINVAL;
> + goto err;
> + }
> +
> + ret = generic_phy_set_mode(&cdns->usb2_phy, mode, 0);
> + if (ret) {
> + dev_err(dev, "Set usb 2.0 PHY mode failed %d\n", ret);
> + goto err;
> + }
> +
> + ret = generic_phy_set_mode(&cdns->usb3_phy, mode, 0);
> + if (ret) {
> + dev_err(dev, "Set usb 3.0 PHY mode failed %d\n", ret);
> + goto err;
> + }
> +
Should we be doing the above inside cdns3_drd_update_mode() so that the
PHY can be put in the correct state even during role switches?
> ret = cdns3_drd_update_mode(cdns);
> if (ret)
> goto err;
--
cheers,
-roger
More information about the U-Boot
mailing list