diff options
| -rw-r--r-- | drivers/usb/host/ohci-ep93xx.c | 128 |
1 files changed, 52 insertions, 76 deletions
diff --git a/drivers/usb/host/ohci-ep93xx.c b/drivers/usb/host/ohci-ep93xx.c index 28fa6b8b5acd..84a20d5223b9 100644 --- a/drivers/usb/host/ohci-ep93xx.c +++ b/drivers/usb/host/ohci-ep93xx.c | |||
| @@ -30,74 +30,6 @@ | |||
| 30 | 30 | ||
| 31 | static struct clk *usb_host_clock; | 31 | static struct clk *usb_host_clock; |
| 32 | 32 | ||
| 33 | static void ep93xx_start_hc(struct device *dev) | ||
| 34 | { | ||
| 35 | clk_enable(usb_host_clock); | ||
| 36 | } | ||
| 37 | |||
| 38 | static void ep93xx_stop_hc(struct device *dev) | ||
| 39 | { | ||
| 40 | clk_disable(usb_host_clock); | ||
| 41 | } | ||
| 42 | |||
| 43 | static int usb_hcd_ep93xx_probe(const struct hc_driver *driver, | ||
| 44 | struct platform_device *pdev) | ||
| 45 | { | ||
| 46 | struct usb_hcd *hcd; | ||
| 47 | struct resource *res; | ||
| 48 | int irq; | ||
| 49 | int retval; | ||
| 50 | |||
| 51 | irq = platform_get_irq(pdev, 0); | ||
| 52 | if (irq < 0) | ||
| 53 | return irq; | ||
| 54 | |||
| 55 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 56 | if (!res) | ||
| 57 | return -ENXIO; | ||
| 58 | |||
| 59 | hcd = usb_create_hcd(driver, &pdev->dev, "ep93xx"); | ||
| 60 | if (hcd == NULL) | ||
| 61 | return -ENOMEM; | ||
| 62 | |||
| 63 | hcd->rsrc_start = res->start; | ||
| 64 | hcd->rsrc_len = resource_size(res); | ||
| 65 | |||
| 66 | hcd->regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 67 | if (IS_ERR(hcd->regs)) { | ||
| 68 | retval = PTR_ERR(hcd->regs); | ||
| 69 | goto err_put_hcd; | ||
| 70 | } | ||
| 71 | |||
| 72 | usb_host_clock = devm_clk_get(&pdev->dev, NULL); | ||
| 73 | if (IS_ERR(usb_host_clock)) { | ||
| 74 | retval = PTR_ERR(usb_host_clock); | ||
| 75 | goto err_put_hcd; | ||
| 76 | } | ||
| 77 | |||
| 78 | ep93xx_start_hc(&pdev->dev); | ||
| 79 | |||
| 80 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
| 81 | |||
| 82 | retval = usb_add_hcd(hcd, irq, 0); | ||
| 83 | if (retval == 0) | ||
| 84 | return retval; | ||
| 85 | |||
| 86 | ep93xx_stop_hc(&pdev->dev); | ||
| 87 | err_put_hcd: | ||
| 88 | usb_put_hcd(hcd); | ||
| 89 | |||
| 90 | return retval; | ||
| 91 | } | ||
| 92 | |||
| 93 | static void usb_hcd_ep93xx_remove(struct usb_hcd *hcd, | ||
| 94 | struct platform_device *pdev) | ||
| 95 | { | ||
| 96 | usb_remove_hcd(hcd); | ||
| 97 | ep93xx_stop_hc(&pdev->dev); | ||
| 98 | usb_put_hcd(hcd); | ||
| 99 | } | ||
| 100 | |||
| 101 | static int ohci_ep93xx_start(struct usb_hcd *hcd) | 33 | static int ohci_ep93xx_start(struct usb_hcd *hcd) |
| 102 | { | 34 | { |
| 103 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 35 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
| @@ -138,15 +70,57 @@ static struct hc_driver ohci_ep93xx_hc_driver = { | |||
| 138 | .start_port_reset = ohci_start_port_reset, | 70 | .start_port_reset = ohci_start_port_reset, |
| 139 | }; | 71 | }; |
| 140 | 72 | ||
| 141 | extern int usb_disabled(void); | ||
| 142 | |||
| 143 | static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev) | 73 | static int ohci_hcd_ep93xx_drv_probe(struct platform_device *pdev) |
| 144 | { | 74 | { |
| 75 | struct usb_hcd *hcd; | ||
| 76 | struct resource *res; | ||
| 77 | int irq; | ||
| 145 | int ret; | 78 | int ret; |
| 146 | 79 | ||
| 147 | ret = -ENODEV; | 80 | if (usb_disabled()) |
| 148 | if (!usb_disabled()) | 81 | return -ENODEV; |
| 149 | ret = usb_hcd_ep93xx_probe(&ohci_ep93xx_hc_driver, pdev); | 82 | |
| 83 | irq = platform_get_irq(pdev, 0); | ||
| 84 | if (irq < 0) | ||
| 85 | return irq; | ||
| 86 | |||
| 87 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 88 | if (!res) | ||
| 89 | return -ENXIO; | ||
| 90 | |||
| 91 | hcd = usb_create_hcd(&ohci_ep93xx_hc_driver, &pdev->dev, "ep93xx"); | ||
| 92 | if (!hcd) | ||
| 93 | return -ENOMEM; | ||
| 94 | |||
| 95 | hcd->rsrc_start = res->start; | ||
| 96 | hcd->rsrc_len = resource_size(res); | ||
| 97 | |||
| 98 | hcd->regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 99 | if (IS_ERR(hcd->regs)) { | ||
| 100 | ret = PTR_ERR(hcd->regs); | ||
| 101 | goto err_put_hcd; | ||
| 102 | } | ||
| 103 | |||
| 104 | usb_host_clock = devm_clk_get(&pdev->dev, NULL); | ||
| 105 | if (IS_ERR(usb_host_clock)) { | ||
| 106 | ret = PTR_ERR(usb_host_clock); | ||
| 107 | goto err_put_hcd; | ||
| 108 | } | ||
| 109 | |||
| 110 | clk_enable(usb_host_clock); | ||
| 111 | |||
| 112 | ohci_hcd_init(hcd_to_ohci(hcd)); | ||
| 113 | |||
| 114 | ret = usb_add_hcd(hcd, irq, 0); | ||
| 115 | if (ret) | ||
| 116 | goto err_clk_disable; | ||
| 117 | |||
| 118 | return 0; | ||
| 119 | |||
| 120 | err_clk_disable: | ||
| 121 | clk_disable(usb_host_clock); | ||
| 122 | err_put_hcd: | ||
| 123 | usb_put_hcd(hcd); | ||
| 150 | 124 | ||
| 151 | return ret; | 125 | return ret; |
| 152 | } | 126 | } |
| @@ -155,7 +129,9 @@ static int ohci_hcd_ep93xx_drv_remove(struct platform_device *pdev) | |||
| 155 | { | 129 | { |
| 156 | struct usb_hcd *hcd = platform_get_drvdata(pdev); | 130 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
| 157 | 131 | ||
| 158 | usb_hcd_ep93xx_remove(hcd, pdev); | 132 | usb_remove_hcd(hcd); |
| 133 | clk_disable(usb_host_clock); | ||
| 134 | usb_put_hcd(hcd); | ||
| 159 | 135 | ||
| 160 | return 0; | 136 | return 0; |
| 161 | } | 137 | } |
| @@ -170,7 +146,7 @@ static int ohci_hcd_ep93xx_drv_suspend(struct platform_device *pdev, pm_message_ | |||
| 170 | msleep(5); | 146 | msleep(5); |
| 171 | ohci->next_statechange = jiffies; | 147 | ohci->next_statechange = jiffies; |
| 172 | 148 | ||
| 173 | ep93xx_stop_hc(&pdev->dev); | 149 | clk_disable(usb_host_clock); |
| 174 | return 0; | 150 | return 0; |
| 175 | } | 151 | } |
| 176 | 152 | ||
| @@ -183,7 +159,7 @@ static int ohci_hcd_ep93xx_drv_resume(struct platform_device *pdev) | |||
| 183 | msleep(5); | 159 | msleep(5); |
| 184 | ohci->next_statechange = jiffies; | 160 | ohci->next_statechange = jiffies; |
| 185 | 161 | ||
| 186 | ep93xx_start_hc(&pdev->dev); | 162 | clk_enable(usb_host_clock); |
| 187 | 163 | ||
| 188 | ohci_resume(hcd, false); | 164 | ohci_resume(hcd, false); |
| 189 | return 0; | 165 | return 0; |
