diff options
author | David Lechner <david@lechnology.com> | 2016-10-12 21:44:46 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-10-24 09:17:51 -0400 |
commit | 6110c425d98b7ed036bba3670e635a9363dd072e (patch) | |
tree | 7e13cb2311dada24f834d33b76f0605156e990a7 | |
parent | 6fbbcf38730210dc00123ad0188002189716169d (diff) |
usb: ohci-da8xx: Remove code that references mach
Including mach/* is frowned upon in device drivers, so get rid of it.
This replaces usb20_clk and code that pokes CFGCHIP2 with a proper phy
driver.
Signed-off-by: David Lechner <david@lechnology.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/host/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/host/ohci-da8xx.c | 102 |
2 files changed, 56 insertions, 47 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index 0b80cee30da4..83b6cec20b33 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -482,6 +482,7 @@ config USB_OHCI_HCD_DAVINCI | |||
482 | bool "OHCI support for TI DaVinci DA8xx" | 482 | bool "OHCI support for TI DaVinci DA8xx" |
483 | depends on ARCH_DAVINCI_DA8XX | 483 | depends on ARCH_DAVINCI_DA8XX |
484 | depends on USB_OHCI_HCD=y | 484 | depends on USB_OHCI_HCD=y |
485 | select PHY_DA8XX_USB | ||
485 | default y | 486 | default y |
486 | help | 487 | help |
487 | Enables support for the DaVinci DA8xx integrated OHCI | 488 | Enables support for the DaVinci DA8xx integrated OHCI |
diff --git a/drivers/usb/host/ohci-da8xx.c b/drivers/usb/host/ohci-da8xx.c index e5c33bc98ea4..3656d7cea58c 100644 --- a/drivers/usb/host/ohci-da8xx.c +++ b/drivers/usb/host/ohci-da8xx.c | |||
@@ -15,58 +15,50 @@ | |||
15 | #include <linux/jiffies.h> | 15 | #include <linux/jiffies.h> |
16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
17 | #include <linux/clk.h> | 17 | #include <linux/clk.h> |
18 | 18 | #include <linux/phy/phy.h> | |
19 | #include <mach/da8xx.h> | ||
20 | #include <linux/platform_data/usb-davinci.h> | 19 | #include <linux/platform_data/usb-davinci.h> |
21 | 20 | ||
22 | #ifndef CONFIG_ARCH_DAVINCI_DA8XX | 21 | #ifndef CONFIG_ARCH_DAVINCI_DA8XX |
23 | #error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX." | 22 | #error "This file is DA8xx bus glue. Define CONFIG_ARCH_DAVINCI_DA8XX." |
24 | #endif | 23 | #endif |
25 | 24 | ||
26 | #define CFGCHIP2 DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG) | ||
27 | |||
28 | static struct clk *usb11_clk; | 25 | static struct clk *usb11_clk; |
29 | static struct clk *usb20_clk; | 26 | static struct phy *usb11_phy; |
30 | 27 | ||
31 | /* Over-current indicator change bitmask */ | 28 | /* Over-current indicator change bitmask */ |
32 | static volatile u16 ocic_mask; | 29 | static volatile u16 ocic_mask; |
33 | 30 | ||
34 | static void ohci_da8xx_clock(int on) | 31 | static int ohci_da8xx_enable(void) |
35 | { | 32 | { |
36 | u32 cfgchip2; | 33 | int ret; |
37 | |||
38 | cfgchip2 = __raw_readl(CFGCHIP2); | ||
39 | if (on) { | ||
40 | clk_enable(usb11_clk); | ||
41 | |||
42 | /* | ||
43 | * If USB 1.1 reference clock is sourced from USB 2.0 PHY, we | ||
44 | * need to enable the USB 2.0 module clocking, start its PHY, | ||
45 | * and not allow it to stop the clock during USB 2.0 suspend. | ||
46 | */ | ||
47 | if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) { | ||
48 | clk_enable(usb20_clk); | ||
49 | |||
50 | cfgchip2 &= ~(CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN); | ||
51 | cfgchip2 |= CFGCHIP2_PHY_PLLON; | ||
52 | __raw_writel(cfgchip2, CFGCHIP2); | ||
53 | |||
54 | pr_info("Waiting for USB PHY clock good...\n"); | ||
55 | while (!(__raw_readl(CFGCHIP2) & CFGCHIP2_PHYCLKGD)) | ||
56 | cpu_relax(); | ||
57 | } | ||
58 | 34 | ||
59 | /* Enable USB 1.1 PHY */ | 35 | ret = clk_prepare_enable(usb11_clk); |
60 | cfgchip2 |= CFGCHIP2_USB1SUSPENDM; | 36 | if (ret) |
61 | } else { | 37 | return ret; |
62 | clk_disable(usb11_clk); | ||
63 | if (!(cfgchip2 & CFGCHIP2_USB1PHYCLKMUX)) | ||
64 | clk_disable(usb20_clk); | ||
65 | 38 | ||
66 | /* Disable USB 1.1 PHY */ | 39 | ret = phy_init(usb11_phy); |
67 | cfgchip2 &= ~CFGCHIP2_USB1SUSPENDM; | 40 | if (ret) |
68 | } | 41 | goto err_phy_init; |
69 | __raw_writel(cfgchip2, CFGCHIP2); | 42 | |
43 | ret = phy_power_on(usb11_phy); | ||
44 | if (ret) | ||
45 | goto err_phy_power_on; | ||
46 | |||
47 | return 0; | ||
48 | |||
49 | err_phy_power_on: | ||
50 | phy_exit(usb11_phy); | ||
51 | err_phy_init: | ||
52 | clk_disable_unprepare(usb11_clk); | ||
53 | |||
54 | return ret; | ||
55 | } | ||
56 | |||
57 | static void ohci_da8xx_disable(void) | ||
58 | { | ||
59 | phy_power_off(usb11_phy); | ||
60 | phy_exit(usb11_phy); | ||
61 | clk_disable_unprepare(usb11_clk); | ||
70 | } | 62 | } |
71 | 63 | ||
72 | /* | 64 | /* |
@@ -92,7 +84,9 @@ static int ohci_da8xx_init(struct usb_hcd *hcd) | |||
92 | 84 | ||
93 | dev_dbg(dev, "starting USB controller\n"); | 85 | dev_dbg(dev, "starting USB controller\n"); |
94 | 86 | ||
95 | ohci_da8xx_clock(1); | 87 | result = ohci_da8xx_enable(); |
88 | if (result < 0) | ||
89 | return result; | ||
96 | 90 | ||
97 | /* | 91 | /* |
98 | * DA8xx only have 1 port connected to the pins but the HC root hub | 92 | * DA8xx only have 1 port connected to the pins but the HC root hub |
@@ -101,8 +95,10 @@ static int ohci_da8xx_init(struct usb_hcd *hcd) | |||
101 | ohci->num_ports = 1; | 95 | ohci->num_ports = 1; |
102 | 96 | ||
103 | result = ohci_init(ohci); | 97 | result = ohci_init(ohci); |
104 | if (result < 0) | 98 | if (result < 0) { |
99 | ohci_da8xx_disable(); | ||
105 | return result; | 100 | return result; |
101 | } | ||
106 | 102 | ||
107 | /* | 103 | /* |
108 | * Since we're providing a board-specific root hub port power control | 104 | * Since we're providing a board-specific root hub port power control |
@@ -129,7 +125,7 @@ static int ohci_da8xx_init(struct usb_hcd *hcd) | |||
129 | static void ohci_da8xx_stop(struct usb_hcd *hcd) | 125 | static void ohci_da8xx_stop(struct usb_hcd *hcd) |
130 | { | 126 | { |
131 | ohci_stop(hcd); | 127 | ohci_stop(hcd); |
132 | ohci_da8xx_clock(0); | 128 | ohci_da8xx_disable(); |
133 | } | 129 | } |
134 | 130 | ||
135 | static int ohci_da8xx_start(struct usb_hcd *hcd) | 131 | static int ohci_da8xx_start(struct usb_hcd *hcd) |
@@ -301,12 +297,18 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, | |||
301 | return -ENODEV; | 297 | return -ENODEV; |
302 | 298 | ||
303 | usb11_clk = devm_clk_get(&pdev->dev, "usb11"); | 299 | usb11_clk = devm_clk_get(&pdev->dev, "usb11"); |
304 | if (IS_ERR(usb11_clk)) | 300 | if (IS_ERR(usb11_clk)) { |
301 | if (PTR_ERR(usb11_clk) != -EPROBE_DEFER) | ||
302 | dev_err(&pdev->dev, "Failed to get clock.\n"); | ||
305 | return PTR_ERR(usb11_clk); | 303 | return PTR_ERR(usb11_clk); |
304 | } | ||
306 | 305 | ||
307 | usb20_clk = devm_clk_get(&pdev->dev, "usb20"); | 306 | usb11_phy = devm_phy_get(&pdev->dev, "usb-phy"); |
308 | if (IS_ERR(usb20_clk)) | 307 | if (IS_ERR(usb11_phy)) { |
309 | return PTR_ERR(usb20_clk); | 308 | if (PTR_ERR(usb11_phy) != -EPROBE_DEFER) |
309 | dev_err(&pdev->dev, "Failed to get phy.\n"); | ||
310 | return PTR_ERR(usb11_phy); | ||
311 | } | ||
310 | 312 | ||
311 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); | 313 | hcd = usb_create_hcd(driver, &pdev->dev, dev_name(&pdev->dev)); |
312 | if (!hcd) | 314 | if (!hcd) |
@@ -316,6 +318,7 @@ static int usb_hcd_da8xx_probe(const struct hc_driver *driver, | |||
316 | hcd->regs = devm_ioremap_resource(&pdev->dev, mem); | 318 | hcd->regs = devm_ioremap_resource(&pdev->dev, mem); |
317 | if (IS_ERR(hcd->regs)) { | 319 | if (IS_ERR(hcd->regs)) { |
318 | error = PTR_ERR(hcd->regs); | 320 | error = PTR_ERR(hcd->regs); |
321 | dev_err(&pdev->dev, "failed to map ohci.\n"); | ||
319 | goto err; | 322 | goto err; |
320 | } | 323 | } |
321 | hcd->rsrc_start = mem->start; | 324 | hcd->rsrc_start = mem->start; |
@@ -397,7 +400,7 @@ static int ohci_da8xx_suspend(struct platform_device *pdev, | |||
397 | if (ret) | 400 | if (ret) |
398 | return ret; | 401 | return ret; |
399 | 402 | ||
400 | ohci_da8xx_clock(0); | 403 | ohci_da8xx_disable(); |
401 | hcd->state = HC_STATE_SUSPENDED; | 404 | hcd->state = HC_STATE_SUSPENDED; |
402 | 405 | ||
403 | return ret; | 406 | return ret; |
@@ -407,14 +410,19 @@ static int ohci_da8xx_resume(struct platform_device *dev) | |||
407 | { | 410 | { |
408 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 411 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
409 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 412 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
413 | int ret; | ||
410 | 414 | ||
411 | if (time_before(jiffies, ohci->next_statechange)) | 415 | if (time_before(jiffies, ohci->next_statechange)) |
412 | msleep(5); | 416 | msleep(5); |
413 | ohci->next_statechange = jiffies; | 417 | ohci->next_statechange = jiffies; |
414 | 418 | ||
415 | ohci_da8xx_clock(1); | 419 | ret = ohci_da8xx_enable(); |
420 | if (ret) | ||
421 | return ret; | ||
422 | |||
416 | dev->dev.power.power_state = PMSG_ON; | 423 | dev->dev.power.power_state = PMSG_ON; |
417 | usb_hcd_resume_root_hub(hcd); | 424 | usb_hcd_resume_root_hub(hcd); |
425 | |||
418 | return 0; | 426 | return 0; |
419 | } | 427 | } |
420 | #endif | 428 | #endif |