aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenu Byravarasu <vbyravarasu@nvidia.com>2013-01-15 22:30:20 -0500
committerStephen Warren <swarren@nvidia.com>2013-01-28 13:20:05 -0500
commit3a55c6a8b96f055783a1b9d5497f66b56a9ea0d7 (patch)
treeb0561c09cad4137bedb7b2626a60422462f50999
parent540fc9d971a6b38339dfcccb5364640b907ae423 (diff)
USB: PHY: tegra: get rid of instance number to differentiate legacy controller
Tegra20 USB has 3 PHY instances. Instance 0 is based on legacy PHY interface and other two are standard interfaces. As instance number was used to differentiate legacy from standard interfaces, used DT param to get this info and processed accordingly. Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com> Acked-by: Felipe Balbi <balbi@ti.com> Signed-off-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r--drivers/usb/phy/tegra_usb_phy.c32
-rw-r--r--include/linux/usb/tegra_usb_phy.h1
2 files changed, 16 insertions, 17 deletions
diff --git a/drivers/usb/phy/tegra_usb_phy.c b/drivers/usb/phy/tegra_usb_phy.c
index 3059384326b6..79280fe90893 100644
--- a/drivers/usb/phy/tegra_usb_phy.c
+++ b/drivers/usb/phy/tegra_usb_phy.c
@@ -24,6 +24,7 @@
24#include <linux/platform_device.h> 24#include <linux/platform_device.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/gpio.h> 26#include <linux/gpio.h>
27#include <linux/of.h>
27#include <linux/of_gpio.h> 28#include <linux/of_gpio.h>
28#include <linux/usb/otg.h> 29#include <linux/usb/otg.h>
29#include <linux/usb/ulpi.h> 30#include <linux/usb/ulpi.h>
@@ -221,7 +222,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
221 return PTR_ERR(phy->pad_clk); 222 return PTR_ERR(phy->pad_clk);
222 } 223 }
223 224
224 if (phy->instance == 0) { 225 if (phy->is_legacy_phy) {
225 phy->pad_regs = phy->regs; 226 phy->pad_regs = phy->regs;
226 } else { 227 } else {
227 phy->pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE); 228 phy->pad_regs = ioremap(TEGRA_USB_BASE, TEGRA_USB_SIZE);
@@ -236,7 +237,7 @@ static int utmip_pad_open(struct tegra_usb_phy *phy)
236 237
237static void utmip_pad_close(struct tegra_usb_phy *phy) 238static void utmip_pad_close(struct tegra_usb_phy *phy)
238{ 239{
239 if (phy->instance != 0) 240 if (!phy->is_legacy_phy)
240 iounmap(phy->pad_regs); 241 iounmap(phy->pad_regs);
241 clk_put(phy->pad_clk); 242 clk_put(phy->pad_clk);
242} 243}
@@ -305,7 +306,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
305 unsigned long val; 306 unsigned long val;
306 void __iomem *base = phy->regs; 307 void __iomem *base = phy->regs;
307 308
308 if (phy->instance == 0) { 309 if (phy->is_legacy_phy) {
309 val = readl(base + USB_SUSP_CTRL); 310 val = readl(base + USB_SUSP_CTRL);
310 val |= USB_SUSP_SET; 311 val |= USB_SUSP_SET;
311 writel(val, base + USB_SUSP_CTRL); 312 writel(val, base + USB_SUSP_CTRL);
@@ -315,9 +316,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy)
315 val = readl(base + USB_SUSP_CTRL); 316 val = readl(base + USB_SUSP_CTRL);
316 val &= ~USB_SUSP_SET; 317 val &= ~USB_SUSP_SET;
317 writel(val, base + USB_SUSP_CTRL); 318 writel(val, base + USB_SUSP_CTRL);
318 } 319 } else {
319
320 if (phy->instance == 2) {
321 val = readl(base + USB_PORTSC1); 320 val = readl(base + USB_PORTSC1);
322 val |= USB_PORTSC1_PHCD; 321 val |= USB_PORTSC1_PHCD;
323 writel(val, base + USB_PORTSC1); 322 writel(val, base + USB_PORTSC1);
@@ -332,7 +331,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
332 unsigned long val; 331 unsigned long val;
333 void __iomem *base = phy->regs; 332 void __iomem *base = phy->regs;
334 333
335 if (phy->instance == 0) { 334 if (phy->is_legacy_phy) {
336 val = readl(base + USB_SUSP_CTRL); 335 val = readl(base + USB_SUSP_CTRL);
337 val |= USB_SUSP_CLR; 336 val |= USB_SUSP_CLR;
338 writel(val, base + USB_SUSP_CTRL); 337 writel(val, base + USB_SUSP_CTRL);
@@ -342,9 +341,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy)
342 val = readl(base + USB_SUSP_CTRL); 341 val = readl(base + USB_SUSP_CTRL);
343 val &= ~USB_SUSP_CLR; 342 val &= ~USB_SUSP_CLR;
344 writel(val, base + USB_SUSP_CTRL); 343 writel(val, base + USB_SUSP_CTRL);
345 } 344 } else {
346
347 if (phy->instance == 2) {
348 val = readl(base + USB_PORTSC1); 345 val = readl(base + USB_PORTSC1);
349 val &= ~USB_PORTSC1_PHCD; 346 val &= ~USB_PORTSC1_PHCD;
350 writel(val, base + USB_PORTSC1); 347 writel(val, base + USB_PORTSC1);
@@ -365,7 +362,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
365 val |= UTMIP_RESET; 362 val |= UTMIP_RESET;
366 writel(val, base + USB_SUSP_CTRL); 363 writel(val, base + USB_SUSP_CTRL);
367 364
368 if (phy->instance == 0) { 365 if (phy->is_legacy_phy) {
369 val = readl(base + USB1_LEGACY_CTRL); 366 val = readl(base + USB1_LEGACY_CTRL);
370 val |= USB1_NO_LEGACY_MODE; 367 val |= USB1_NO_LEGACY_MODE;
371 writel(val, base + USB1_LEGACY_CTRL); 368 writel(val, base + USB1_LEGACY_CTRL);
@@ -440,16 +437,14 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
440 val |= UTMIP_BIAS_PDTRK_COUNT(0x5); 437 val |= UTMIP_BIAS_PDTRK_COUNT(0x5);
441 writel(val, base + UTMIP_BIAS_CFG1); 438 writel(val, base + UTMIP_BIAS_CFG1);
442 439
443 if (phy->instance == 0) { 440 if (phy->is_legacy_phy) {
444 val = readl(base + UTMIP_SPARE_CFG0); 441 val = readl(base + UTMIP_SPARE_CFG0);
445 if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE) 442 if (phy->mode == TEGRA_USB_PHY_MODE_DEVICE)
446 val &= ~FUSE_SETUP_SEL; 443 val &= ~FUSE_SETUP_SEL;
447 else 444 else
448 val |= FUSE_SETUP_SEL; 445 val |= FUSE_SETUP_SEL;
449 writel(val, base + UTMIP_SPARE_CFG0); 446 writel(val, base + UTMIP_SPARE_CFG0);
450 } 447 } else {
451
452 if (phy->instance == 2) {
453 val = readl(base + USB_SUSP_CTRL); 448 val = readl(base + USB_SUSP_CTRL);
454 val |= UTMIP_PHY_ENABLE; 449 val |= UTMIP_PHY_ENABLE;
455 writel(val, base + USB_SUSP_CTRL); 450 writel(val, base + USB_SUSP_CTRL);
@@ -459,7 +454,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
459 val &= ~UTMIP_RESET; 454 val &= ~UTMIP_RESET;
460 writel(val, base + USB_SUSP_CTRL); 455 writel(val, base + USB_SUSP_CTRL);
461 456
462 if (phy->instance == 0) { 457 if (phy->is_legacy_phy) {
463 val = readl(base + USB1_LEGACY_CTRL); 458 val = readl(base + USB1_LEGACY_CTRL);
464 val &= ~USB1_VBUS_SENSE_CTL_MASK; 459 val &= ~USB1_VBUS_SENSE_CTL_MASK;
465 val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD; 460 val |= USB1_VBUS_SENSE_CTL_A_SESS_VLD;
@@ -472,7 +467,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy)
472 467
473 utmi_phy_clk_enable(phy); 468 utmi_phy_clk_enable(phy);
474 469
475 if (phy->instance == 2) { 470 if (!phy->is_legacy_phy) {
476 val = readl(base + USB_PORTSC1); 471 val = readl(base + USB_PORTSC1);
477 val &= ~USB_PORTSC1_PTS(~0); 472 val &= ~USB_PORTSC1_PTS(~0);
478 writel(val, base + USB_PORTSC1); 473 writel(val, base + USB_PORTSC1);
@@ -739,6 +734,7 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
739 unsigned long parent_rate; 734 unsigned long parent_rate;
740 int i; 735 int i;
741 int err; 736 int err;
737 struct device_node *np = dev->of_node;
742 738
743 phy = kzalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL); 739 phy = kzalloc(sizeof(struct tegra_usb_phy), GFP_KERNEL);
744 if (!phy) 740 if (!phy)
@@ -749,6 +745,8 @@ struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,
749 phy->config = config; 745 phy->config = config;
750 phy->mode = phy_mode; 746 phy->mode = phy_mode;
751 phy->dev = dev; 747 phy->dev = dev;
748 phy->is_legacy_phy =
749 of_property_read_bool(np, "nvidia,has-legacy-mode");
752 750
753 if (!phy->config) { 751 if (!phy->config) {
754 if (phy_is_ulpi(phy)) { 752 if (phy_is_ulpi(phy)) {
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h
index 34e6355a15e3..f03e157abaa8 100644
--- a/include/linux/usb/tegra_usb_phy.h
+++ b/include/linux/usb/tegra_usb_phy.h
@@ -59,6 +59,7 @@ struct tegra_usb_phy {
59 struct usb_phy *ulpi; 59 struct usb_phy *ulpi;
60 struct usb_phy u_phy; 60 struct usb_phy u_phy;
61 struct device *dev; 61 struct device *dev;
62 bool is_legacy_phy;
62}; 63};
63 64
64struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance, 65struct tegra_usb_phy *tegra_usb_phy_open(struct device *dev, int instance,