]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: phy: tegra: use phy type directly
authorSvyatoslav Ryhel <clamor95@gmail.com>
Thu, 22 Jan 2026 15:11:24 +0000 (17:11 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Jan 2026 16:18:11 +0000 (17:18 +0100)
Refactor to directly use enum usb_phy_interface to determine the PHY mode.
This change is in preparation for adding support for HSIC mode.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Link: https://patch.msgid.link/20260122151125.7367-2-clamor95@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/phy/phy-tegra-usb.c
include/linux/usb/tegra_usb_phy.h

index fb9031628d39736cd13bc42fa2ee31ede6a72167..3fb082c98d99f293bd9a47250fc90dedc71c409c 100644 (file)
@@ -805,15 +805,24 @@ static int ulpi_phy_power_off(struct tegra_usb_phy *phy)
 
 static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
 {
-       int err;
+       int err = 0;
 
        if (phy->powered_on)
                return 0;
 
-       if (phy->is_ulpi_phy)
-               err = ulpi_phy_power_on(phy);
-       else
+       switch (phy->phy_type) {
+       case USBPHY_INTERFACE_MODE_UTMI:
                err = utmi_phy_power_on(phy);
+               break;
+
+       case USBPHY_INTERFACE_MODE_ULPI:
+               err = ulpi_phy_power_on(phy);
+               break;
+
+       default:
+               break;
+       }
+
        if (err)
                return err;
 
@@ -827,15 +836,24 @@ static int tegra_usb_phy_power_on(struct tegra_usb_phy *phy)
 
 static int tegra_usb_phy_power_off(struct tegra_usb_phy *phy)
 {
-       int err;
+       int err = 0;
 
        if (!phy->powered_on)
                return 0;
 
-       if (phy->is_ulpi_phy)
-               err = ulpi_phy_power_off(phy);
-       else
+       switch (phy->phy_type) {
+       case USBPHY_INTERFACE_MODE_UTMI:
                err = utmi_phy_power_off(phy);
+               break;
+
+       case USBPHY_INTERFACE_MODE_ULPI:
+               err = ulpi_phy_power_off(phy);
+               break;
+
+       default:
+               break;
+       }
+
        if (err)
                return err;
 
@@ -854,7 +872,7 @@ static void tegra_usb_phy_shutdown(struct usb_phy *u_phy)
        usb_phy_set_wakeup(u_phy, false);
        tegra_usb_phy_power_off(phy);
 
-       if (!phy->is_ulpi_phy)
+       if (phy->phy_type == USBPHY_INTERFACE_MODE_UTMI)
                utmip_pad_close(phy);
 
        regulator_disable(phy->vbus);
@@ -1040,7 +1058,7 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy)
                goto disable_clk;
        }
 
-       if (!phy->is_ulpi_phy) {
+       if (phy->phy_type == USBPHY_INTERFACE_MODE_UTMI) {
                err = utmip_pad_open(phy);
                if (err)
                        goto disable_vbus;
@@ -1057,7 +1075,7 @@ static int tegra_usb_phy_init(struct usb_phy *u_phy)
        return 0;
 
 close_phy:
-       if (!phy->is_ulpi_phy)
+       if (phy->phy_type == USBPHY_INTERFACE_MODE_UTMI)
                utmip_pad_close(phy);
 
 disable_vbus:
@@ -1095,8 +1113,6 @@ static int utmi_phy_probe(struct tegra_usb_phy *tegra_phy,
        struct resource *res;
        int err;
 
-       tegra_phy->is_ulpi_phy = false;
-
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
        if (!res) {
                dev_err(&pdev->dev, "Failed to get UTMI pad regs\n");
@@ -1252,7 +1268,6 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct tegra_usb_phy *tegra_phy;
-       enum usb_phy_interface phy_type;
        struct reset_control *reset;
        struct gpio_desc *gpiod;
        struct resource *res;
@@ -1314,8 +1329,8 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
                return err;
        }
 
-       phy_type = of_usb_get_phy_mode(np);
-       switch (phy_type) {
+       tegra_phy->phy_type = of_usb_get_phy_mode(np);
+       switch (tegra_phy->phy_type) {
        case USBPHY_INTERFACE_MODE_UTMI:
                err = utmi_phy_probe(tegra_phy, pdev);
                if (err)
@@ -1341,8 +1356,6 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
                break;
 
        case USBPHY_INTERFACE_MODE_ULPI:
-               tegra_phy->is_ulpi_phy = true;
-
                tegra_phy->clk = devm_clk_get(&pdev->dev, "ulpi-link");
                err = PTR_ERR_OR_ZERO(tegra_phy->clk);
                if (err) {
@@ -1382,7 +1395,7 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
 
        default:
                dev_err(&pdev->dev, "phy_type %u is invalid or unsupported\n",
-                       phy_type);
+                       tegra_phy->phy_type);
                return -EINVAL;
        }
 
index 40afcee8b4f5dbc89bd724b4dc0f46fe88ab739e..fb5227353d3bb550af92dd66f2f5e21737e20715 100644 (file)
@@ -72,7 +72,7 @@ struct tegra_usb_phy {
        struct usb_phy *ulpi;
        struct usb_phy u_phy;
        bool is_legacy_phy;
-       bool is_ulpi_phy;
+       enum usb_phy_interface phy_type;
        struct gpio_desc *reset_gpio;
        struct reset_control *pad_rst;
        bool wakeup_enabled;