diff options
Diffstat (limited to 'drivers/usb/host/ehci-pci.c')
-rw-r--r-- | drivers/usb/host/ehci-pci.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 441c26064b44..13f73a836e45 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -121,8 +121,8 @@ static int ehci_pci_reinit(struct ehci_hcd *ehci, struct pci_dev *pdev) | |||
121 | return 0; | 121 | return 0; |
122 | } | 122 | } |
123 | 123 | ||
124 | /* called by khubd or root hub (re)init threads; leaves HC in halt state */ | 124 | /* called during probe() after chip reset completes */ |
125 | static int ehci_pci_reset(struct usb_hcd *hcd) | 125 | static int ehci_pci_setup(struct usb_hcd *hcd) |
126 | { | 126 | { |
127 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 127 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
128 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); | 128 | struct pci_dev *pdev = to_pci_dev(hcd->self.controller); |
@@ -141,6 +141,11 @@ static int ehci_pci_reset(struct usb_hcd *hcd) | |||
141 | if (retval) | 141 | if (retval) |
142 | return retval; | 142 | return retval; |
143 | 143 | ||
144 | /* data structure init */ | ||
145 | retval = ehci_init(hcd); | ||
146 | if (retval) | ||
147 | return retval; | ||
148 | |||
144 | /* NOTE: only the parts below this line are PCI-specific */ | 149 | /* NOTE: only the parts below this line are PCI-specific */ |
145 | 150 | ||
146 | switch (pdev->vendor) { | 151 | switch (pdev->vendor) { |
@@ -154,7 +159,8 @@ static int ehci_pci_reset(struct usb_hcd *hcd) | |||
154 | /* AMD8111 EHCI doesn't work, according to AMD errata */ | 159 | /* AMD8111 EHCI doesn't work, according to AMD errata */ |
155 | if (pdev->device == 0x7463) { | 160 | if (pdev->device == 0x7463) { |
156 | ehci_info(ehci, "ignoring AMD8111 (errata)\n"); | 161 | ehci_info(ehci, "ignoring AMD8111 (errata)\n"); |
157 | return -EIO; | 162 | retval = -EIO; |
163 | goto done; | ||
158 | } | 164 | } |
159 | break; | 165 | break; |
160 | case PCI_VENDOR_ID_NVIDIA: | 166 | case PCI_VENDOR_ID_NVIDIA: |
@@ -207,9 +213,8 @@ static int ehci_pci_reset(struct usb_hcd *hcd) | |||
207 | /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ | 213 | /* REVISIT: per-port wake capability (PCI 0x62) currently unused */ |
208 | 214 | ||
209 | retval = ehci_pci_reinit(ehci, pdev); | 215 | retval = ehci_pci_reinit(ehci, pdev); |
210 | 216 | done: | |
211 | /* finish init */ | 217 | return retval; |
212 | return ehci_init(hcd); | ||
213 | } | 218 | } |
214 | 219 | ||
215 | /*-------------------------------------------------------------------------*/ | 220 | /*-------------------------------------------------------------------------*/ |
@@ -228,14 +233,36 @@ static int ehci_pci_reset(struct usb_hcd *hcd) | |||
228 | static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) | 233 | static int ehci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) |
229 | { | 234 | { |
230 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | 235 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); |
236 | unsigned long flags; | ||
237 | int rc = 0; | ||
231 | 238 | ||
232 | if (time_before(jiffies, ehci->next_statechange)) | 239 | if (time_before(jiffies, ehci->next_statechange)) |
233 | msleep(10); | 240 | msleep(10); |
234 | 241 | ||
242 | /* Root hub was already suspended. Disable irq emission and | ||
243 | * mark HW unaccessible, bail out if RH has been resumed. Use | ||
244 | * the spinlock to properly synchronize with possible pending | ||
245 | * RH suspend or resume activity. | ||
246 | * | ||
247 | * This is still racy as hcd->state is manipulated outside of | ||
248 | * any locks =P But that will be a different fix. | ||
249 | */ | ||
250 | spin_lock_irqsave (&ehci->lock, flags); | ||
251 | if (hcd->state != HC_STATE_SUSPENDED) { | ||
252 | rc = -EINVAL; | ||
253 | goto bail; | ||
254 | } | ||
255 | writel (0, &ehci->regs->intr_enable); | ||
256 | (void)readl(&ehci->regs->intr_enable); | ||
257 | |||
258 | clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
259 | bail: | ||
260 | spin_unlock_irqrestore (&ehci->lock, flags); | ||
261 | |||
235 | // could save FLADJ in case of Vaux power loss | 262 | // could save FLADJ in case of Vaux power loss |
236 | // ... we'd only use it to handle clock skew | 263 | // ... we'd only use it to handle clock skew |
237 | 264 | ||
238 | return 0; | 265 | return rc; |
239 | } | 266 | } |
240 | 267 | ||
241 | static int ehci_pci_resume(struct usb_hcd *hcd) | 268 | static int ehci_pci_resume(struct usb_hcd *hcd) |
@@ -251,6 +278,9 @@ static int ehci_pci_resume(struct usb_hcd *hcd) | |||
251 | if (time_before(jiffies, ehci->next_statechange)) | 278 | if (time_before(jiffies, ehci->next_statechange)) |
252 | msleep(100); | 279 | msleep(100); |
253 | 280 | ||
281 | /* Mark hardware accessible again as we are out of D3 state by now */ | ||
282 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | ||
283 | |||
254 | /* If CF is clear, we lost PCI Vaux power and need to restart. */ | 284 | /* If CF is clear, we lost PCI Vaux power and need to restart. */ |
255 | if (readl(&ehci->regs->configured_flag) != FLAG_CF) | 285 | if (readl(&ehci->regs->configured_flag) != FLAG_CF) |
256 | goto restart; | 286 | goto restart; |
@@ -319,7 +349,7 @@ static const struct hc_driver ehci_pci_hc_driver = { | |||
319 | /* | 349 | /* |
320 | * basic lifecycle operations | 350 | * basic lifecycle operations |
321 | */ | 351 | */ |
322 | .reset = ehci_pci_reset, | 352 | .reset = ehci_pci_setup, |
323 | .start = ehci_run, | 353 | .start = ehci_run, |
324 | #ifdef CONFIG_PM | 354 | #ifdef CONFIG_PM |
325 | .suspend = ehci_pci_suspend, | 355 | .suspend = ehci_pci_suspend, |