diff options
-rw-r--r-- | drivers/usb/host/ehci-tegra.c | 36 | ||||
-rw-r--r-- | drivers/usb/phy/phy-tegra-usb.c | 39 | ||||
-rw-r--r-- | include/linux/usb/tegra_usb_phy.h | 4 |
3 files changed, 36 insertions, 43 deletions
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index dde518969798..80634292efee 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -34,11 +34,6 @@ | |||
34 | #define TEGRA_USB2_BASE 0xC5004000 | 34 | #define TEGRA_USB2_BASE 0xC5004000 |
35 | #define TEGRA_USB3_BASE 0xC5008000 | 35 | #define TEGRA_USB3_BASE 0xC5008000 |
36 | 36 | ||
37 | /* PORTSC registers */ | ||
38 | #define TEGRA_USB_PORTSC1 0x184 | ||
39 | #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) | ||
40 | #define TEGRA_USB_PORTSC1_PHCD (1 << 23) | ||
41 | |||
42 | #define TEGRA_USB_DMA_ALIGN 32 | 37 | #define TEGRA_USB_DMA_ALIGN 32 |
43 | 38 | ||
44 | struct tegra_ehci_hcd { | 39 | struct tegra_ehci_hcd { |
@@ -380,37 +375,6 @@ static int setup_vbus_gpio(struct platform_device *pdev, | |||
380 | return err; | 375 | return err; |
381 | } | 376 | } |
382 | 377 | ||
383 | /* Bits of PORTSC1, which will get cleared by writing 1 into them */ | ||
384 | #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) | ||
385 | |||
386 | void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val) | ||
387 | { | ||
388 | unsigned long val; | ||
389 | struct usb_hcd *hcd = bus_to_hcd(x->otg->host); | ||
390 | void __iomem *base = hcd->regs; | ||
391 | |||
392 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | ||
393 | val &= ~TEGRA_USB_PORTSC1_PTS(3); | ||
394 | val |= TEGRA_USB_PORTSC1_PTS(pts_val & 3); | ||
395 | writel(val, base + TEGRA_USB_PORTSC1); | ||
396 | } | ||
397 | EXPORT_SYMBOL_GPL(tegra_ehci_set_pts); | ||
398 | |||
399 | void tegra_ehci_set_phcd(struct usb_phy *x, bool enable) | ||
400 | { | ||
401 | unsigned long val; | ||
402 | struct usb_hcd *hcd = bus_to_hcd(x->otg->host); | ||
403 | void __iomem *base = hcd->regs; | ||
404 | |||
405 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | ||
406 | if (enable) | ||
407 | val |= TEGRA_USB_PORTSC1_PHCD; | ||
408 | else | ||
409 | val &= ~TEGRA_USB_PORTSC1_PHCD; | ||
410 | writel(val, base + TEGRA_USB_PORTSC1); | ||
411 | } | ||
412 | EXPORT_SYMBOL_GPL(tegra_ehci_set_phcd); | ||
413 | |||
414 | static int tegra_ehci_probe(struct platform_device *pdev) | 378 | static int tegra_ehci_probe(struct platform_device *pdev) |
415 | { | 379 | { |
416 | struct resource *res; | 380 | struct resource *res; |
diff --git a/drivers/usb/phy/phy-tegra-usb.c b/drivers/usb/phy/phy-tegra-usb.c index f0727f20e803..3446245e932b 100644 --- a/drivers/usb/phy/phy-tegra-usb.c +++ b/drivers/usb/phy/phy-tegra-usb.c | |||
@@ -32,11 +32,20 @@ | |||
32 | #include <linux/usb/otg.h> | 32 | #include <linux/usb/otg.h> |
33 | #include <linux/usb/ulpi.h> | 33 | #include <linux/usb/ulpi.h> |
34 | #include <asm/mach-types.h> | 34 | #include <asm/mach-types.h> |
35 | #include <linux/usb/ehci_def.h> | ||
35 | #include <linux/usb/tegra_usb_phy.h> | 36 | #include <linux/usb/tegra_usb_phy.h> |
36 | #include <linux/module.h> | 37 | #include <linux/module.h> |
37 | 38 | ||
38 | #define ULPI_VIEWPORT 0x170 | 39 | #define ULPI_VIEWPORT 0x170 |
39 | 40 | ||
41 | /* PORTSC registers */ | ||
42 | #define TEGRA_USB_PORTSC1 0x184 | ||
43 | #define TEGRA_USB_PORTSC1_PTS(x) (((x) & 0x3) << 30) | ||
44 | #define TEGRA_USB_PORTSC1_PHCD (1 << 23) | ||
45 | |||
46 | /* Bits of PORTSC1, which will get cleared by writing 1 into them */ | ||
47 | #define TEGRA_PORTSC1_RWC_BITS (PORT_CSC | PORT_PEC | PORT_OCC) | ||
48 | |||
40 | #define USB_SUSP_CTRL 0x400 | 49 | #define USB_SUSP_CTRL 0x400 |
41 | #define USB_WAKE_ON_CNNT_EN_DEV (1 << 3) | 50 | #define USB_WAKE_ON_CNNT_EN_DEV (1 << 3) |
42 | #define USB_WAKE_ON_DISCON_EN_DEV (1 << 4) | 51 | #define USB_WAKE_ON_DISCON_EN_DEV (1 << 4) |
@@ -197,6 +206,30 @@ static struct tegra_utmip_config utmip_default[] = { | |||
197 | }, | 206 | }, |
198 | }; | 207 | }; |
199 | 208 | ||
209 | static void set_pts(struct tegra_usb_phy *phy, u8 pts_val) | ||
210 | { | ||
211 | void __iomem *base = phy->regs; | ||
212 | unsigned long val; | ||
213 | |||
214 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | ||
215 | val &= ~TEGRA_USB_PORTSC1_PTS(3); | ||
216 | val |= TEGRA_USB_PORTSC1_PTS(pts_val & 3); | ||
217 | writel(val, base + TEGRA_USB_PORTSC1); | ||
218 | } | ||
219 | |||
220 | static void set_phcd(struct tegra_usb_phy *phy, bool enable) | ||
221 | { | ||
222 | void __iomem *base = phy->regs; | ||
223 | unsigned long val; | ||
224 | |||
225 | val = readl(base + TEGRA_USB_PORTSC1) & ~TEGRA_PORTSC1_RWC_BITS; | ||
226 | if (enable) | ||
227 | val |= TEGRA_USB_PORTSC1_PHCD; | ||
228 | else | ||
229 | val &= ~TEGRA_USB_PORTSC1_PHCD; | ||
230 | writel(val, base + TEGRA_USB_PORTSC1); | ||
231 | } | ||
232 | |||
200 | static int utmip_pad_open(struct tegra_usb_phy *phy) | 233 | static int utmip_pad_open(struct tegra_usb_phy *phy) |
201 | { | 234 | { |
202 | phy->pad_clk = devm_clk_get(phy->dev, "utmi-pads"); | 235 | phy->pad_clk = devm_clk_get(phy->dev, "utmi-pads"); |
@@ -283,7 +316,7 @@ static void utmi_phy_clk_disable(struct tegra_usb_phy *phy) | |||
283 | val &= ~USB_SUSP_SET; | 316 | val &= ~USB_SUSP_SET; |
284 | writel(val, base + USB_SUSP_CTRL); | 317 | writel(val, base + USB_SUSP_CTRL); |
285 | } else | 318 | } else |
286 | tegra_ehci_set_phcd(&phy->u_phy, true); | 319 | set_phcd(phy, true); |
287 | 320 | ||
288 | if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) < 0) | 321 | if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, 0) < 0) |
289 | pr_err("%s: timeout waiting for phy to stabilize\n", __func__); | 322 | pr_err("%s: timeout waiting for phy to stabilize\n", __func__); |
@@ -305,7 +338,7 @@ static void utmi_phy_clk_enable(struct tegra_usb_phy *phy) | |||
305 | val &= ~USB_SUSP_CLR; | 338 | val &= ~USB_SUSP_CLR; |
306 | writel(val, base + USB_SUSP_CTRL); | 339 | writel(val, base + USB_SUSP_CTRL); |
307 | } else | 340 | } else |
308 | tegra_ehci_set_phcd(&phy->u_phy, false); | 341 | set_phcd(phy, false); |
309 | 342 | ||
310 | if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, | 343 | if (utmi_wait_register(base + USB_SUSP_CTRL, USB_PHY_CLK_VALID, |
311 | USB_PHY_CLK_VALID)) | 344 | USB_PHY_CLK_VALID)) |
@@ -428,7 +461,7 @@ static int utmi_phy_power_on(struct tegra_usb_phy *phy) | |||
428 | utmi_phy_clk_enable(phy); | 461 | utmi_phy_clk_enable(phy); |
429 | 462 | ||
430 | if (!phy->is_legacy_phy) | 463 | if (!phy->is_legacy_phy) |
431 | tegra_ehci_set_pts(&phy->u_phy, 0); | 464 | set_pts(phy, 0); |
432 | 465 | ||
433 | return 0; | 466 | return 0; |
434 | } | 467 | } |
diff --git a/include/linux/usb/tegra_usb_phy.h b/include/linux/usb/tegra_usb_phy.h index 0cd15d2df53d..d2ca919a5b73 100644 --- a/include/linux/usb/tegra_usb_phy.h +++ b/include/linux/usb/tegra_usb_phy.h | |||
@@ -76,8 +76,4 @@ void tegra_ehci_phy_restore_start(struct usb_phy *phy, | |||
76 | 76 | ||
77 | void tegra_ehci_phy_restore_end(struct usb_phy *phy); | 77 | void tegra_ehci_phy_restore_end(struct usb_phy *phy); |
78 | 78 | ||
79 | void tegra_ehci_set_pts(struct usb_phy *x, u8 pts_val); | ||
80 | |||
81 | void tegra_ehci_set_phcd(struct usb_phy *x, bool enable); | ||
82 | |||
83 | #endif /* __TEGRA_USB_PHY_H */ | 79 | #endif /* __TEGRA_USB_PHY_H */ |