]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: phy: tegra: Use DT helpers for dr_mode
authorTuomas Tynkkynen <ttynkkynen@nvidia.com>
Thu, 25 Jul 2013 18:38:09 +0000 (21:38 +0300)
committerFelipe Balbi <balbi@ti.com>
Mon, 29 Jul 2013 10:58:27 +0000 (13:58 +0300)
Use the new of_usb_get_dr_mode helper function for parsing dr_mode
from the device tree. Also replace the usage of the custom
tegra_usb_phy_mode enum with the standard enum.

Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/phy/phy-tegra-usb.c
include/linux/usb/tegra_usb_phy.h

index fb469f1e8d10b136eb3bc966086e755b7ee6227f..01c30ff8874e62effb6a35b9a6fcb821d71b795c 100644 (file)
@@ -377,7 +377,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
                UTMIP_PLLU_ENABLE_DLY_COUNT(phy->freq->enable_delay);
        writel(val, base + UTMIP_PLL_CFG1);
 
-       if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) {
+       if (phy->mode == USB_DR_MODE_PERIPHERAL) {
                val = readl(base + USB_SUSP_CTRL);
                val &= ~(USB_WAKE_ON_CNNT_EN_DEV | USB_WAKE_ON_DISCON_EN_DEV);
                writel(val, base + USB_SUSP_CTRL);
@@ -412,7 +412,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
 
        if (phy->is_legacy_phy) {
                val = readl(base + UTMIP_SPARE_CFG0);
-               if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE)
+               if (phy->mode == USB_DR_MODE_PERIPHERAL)
                        val &= ~FUSE_SETUP_SEL;
                else
                        val |= FUSE_SETUP_SEL;
@@ -453,7 +453,7 @@ static int utmi_phy_power_off(struct tegra_usb_phy *phy)
 
        utmi_phy_clk_disable(phy);
 
-       if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) {
+       if (phy->mode == USB_DR_MODE_PERIPHERAL) {
                val = readl(base + USB_SUSP_CTRL);
                val &= ~USB_WAKEUP_DEBOUNCE_COUNT(~0);
                val |= USB_WAKE_ON_CNNT_EN_DEV | USB_WAKEUP_DEBOUNCE_COUNT(5);
@@ -907,15 +907,15 @@ static int tegra_usb_phy_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       err = of_property_match_string(np, "dr_mode", "otg");
-       if (err < 0) {
-               err = of_property_match_string(np, "dr_mode", "peripheral");
-               if (err < 0)
-                       tegra_phy->mode = TEGRA_USB_PHY_MODE_HOST;
-               else
-                       tegra_phy->mode = TEGRA_USB_PHY_MODE_DEVICE;
-       } else
-               tegra_phy->mode = TEGRA_USB_PHY_MODE_OTG;
+       if (of_find_property(np, "dr_mode", NULL))
+               tegra_phy->mode = of_usb_get_dr_mode(np);
+       else
+               tegra_phy->mode = USB_DR_MODE_HOST;
+
+       if (tegra_phy->mode == USB_DR_MODE_UNKNOWN) {
+               dev_err(&pdev->dev, "dr_mode is invalid\n");
+               return -EINVAL;
+       }
 
        /* On some boards, the VBUS regulator doesn't need to be controlled */
        if (of_find_property(np, "vbus-supply", NULL)) {
index a095c98184d0653ee1a4cef4ae0324567f847398..d3db274610a1fe066081b1992984803acab29bbb 100644 (file)
@@ -34,12 +34,6 @@ enum tegra_usb_phy_port_speed {
        TEGRA_USB_PHY_PORT_SPEED_HIGH,
 };
 
-enum tegra_usb_phy_mode {
-       TEGRA_USB_PHY_MODE_DEVICE,
-       TEGRA_USB_PHY_MODE_HOST,
-       TEGRA_USB_PHY_MODE_OTG,
-};
-
 struct tegra_xtal_freq;
 
 struct tegra_usb_phy {
@@ -51,7 +45,7 @@ struct tegra_usb_phy {
        struct clk *pll_u;
        struct clk *pad_clk;
        struct regulator *vbus;
-       enum tegra_usb_phy_mode mode;
+       enum usb_dr_mode mode;
        void *config;
        struct usb_phy *ulpi;
        struct usb_phy u_phy;