From: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
To: <balbi@ti.com>
Cc: <linux-tegra@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-usb@vger.kernel.org>, <swarren@wwwdotorg.org>,
<gregkh@linuxfoundation.org>,
Tuomas Tynkkynen <ttynkkynen@nvidia.com>
Subject: [PATCH v3 9/9] usb: phy: tegra: Use DT helpers for dr_mode
Date: Thu, 25 Jul 2013 21:38:09 +0300 [thread overview]
Message-ID: <1374777489-13093-10-git-send-email-ttynkkynen@nvidia.com> (raw)
In-Reply-To: <1374777489-13093-1-git-send-email-ttynkkynen@nvidia.com>
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>
---
v2 diff: Default to host mode if the property didn't exist
drivers/usb/phy/phy-tegra-usb.c | 24 ++++++++++++------------
include/linux/usb/tegra_usb_phy.h | 8 +-------
2 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c
index fb469f1..01c30ff 100644
--- a/drivers/usb/phy/phy-tegra-usb.c
+++ b/drivers/usb/phy/phy-tegra-usb.c
@@ -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)) {
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index a095c98..d3db274 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -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;
--
1.8.1.5
prev parent reply other threads:[~2013-07-25 18:38 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 18:38 [PATCH v3 0/9] Tegra USB cleanup series Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 1/9] usb: phy: tegra: Remove unnecessary 'dev' field Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 2/9] usb: host: tegra: Remove leftover code Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 3/9] usb: tegra: host: Remove references to plat data Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 4/9] ARM: tegra: Remove USB platform data Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 5/9] usb: phy: tegra: Register as an USB PHY Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 6/9] usb: host: tegra: Locate a PHY via standard API Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 7/9] usb: phy: tegra: Remove custom PHY locating APIs Tuomas Tynkkynen
2013-07-25 18:38 ` [PATCH v3 8/9] usb: phy: tegra: Use DT helpers for phy_type Tuomas Tynkkynen
2013-07-25 19:00 ` Felipe Balbi
2013-07-25 19:11 ` Tuomas Tynkkynen
2013-07-25 19:17 ` Felipe Balbi
2013-07-25 19:24 ` [PATCH] usb: phy: tegra: Use switch instead of if-else Tuomas Tynkkynen
2013-07-25 18:38 ` Tuomas Tynkkynen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1374777489-13093-10-git-send-email-ttynkkynen@nvidia.com \
--to=ttynkkynen@nvidia.com \
--cc=balbi@ti.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=swarren@wwwdotorg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®