~ubuntu-branches/ubuntu/trusty/linux-linaro-u8500/trusty

« back to all changes in this revision

Viewing changes to drivers/usb/core/hcd-pci.c

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

Show diffs side-by-side

added added

removed removed

Lines of Context:
192
192
                        "Found HC with no IRQ.  Check BIOS/PCI %s setup!\n",
193
193
                        pci_name(dev));
194
194
                retval = -ENODEV;
195
 
                goto err1;
 
195
                goto disable_pci;
196
196
        }
197
197
 
198
198
        hcd = usb_create_hcd(driver, &dev->dev, pci_name(dev));
199
199
        if (!hcd) {
200
200
                retval = -ENOMEM;
201
 
                goto err1;
 
201
                goto disable_pci;
202
202
        }
203
203
 
204
204
        if (driver->flags & HCD_MEMORY) {
209
209
                                driver->description)) {
210
210
                        dev_dbg(&dev->dev, "controller already in use\n");
211
211
                        retval = -EBUSY;
212
 
                        goto err2;
 
212
                        goto clear_companion;
213
213
                }
214
214
                hcd->regs = ioremap_nocache(hcd->rsrc_start, hcd->rsrc_len);
215
215
                if (hcd->regs == NULL) {
216
216
                        dev_dbg(&dev->dev, "error mapping memory\n");
217
217
                        retval = -EFAULT;
218
 
                        goto err3;
 
218
                        goto release_mem_region;
219
219
                }
220
220
 
221
221
        } else {
236
236
                if (region == PCI_ROM_RESOURCE) {
237
237
                        dev_dbg(&dev->dev, "no i/o regions available\n");
238
238
                        retval = -EBUSY;
239
 
                        goto err2;
 
239
                        goto clear_companion;
240
240
                }
241
241
        }
242
242
 
244
244
 
245
245
        retval = usb_add_hcd(hcd, dev->irq, IRQF_DISABLED | IRQF_SHARED);
246
246
        if (retval != 0)
247
 
                goto err4;
 
247
                goto unmap_registers;
248
248
        set_hs_companion(dev, hcd);
249
249
 
250
250
        if (pci_dev_run_wake(dev))
251
251
                pm_runtime_put_noidle(&dev->dev);
252
252
        return retval;
253
253
 
254
 
 err4:
 
254
unmap_registers:
255
255
        if (driver->flags & HCD_MEMORY) {
256
256
                iounmap(hcd->regs);
257
 
 err3:
 
257
release_mem_region:
258
258
                release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
259
259
        } else
260
260
                release_region(hcd->rsrc_start, hcd->rsrc_len);
261
 
 err2:
 
261
clear_companion:
262
262
        clear_hs_companion(dev, hcd);
263
263
        usb_put_hcd(hcd);
264
 
 err1:
 
264
disable_pci:
265
265
        pci_disable_device(dev);
266
266
        dev_err(&dev->dev, "init %s fail, %d\n", pci_name(dev), retval);
267
267
        return retval;
363
363
        struct pci_dev          *pci_dev = to_pci_dev(dev);
364
364
        struct usb_hcd          *hcd = pci_get_drvdata(pci_dev);
365
365
 
366
 
        if (!(hcd->state == HC_STATE_SUSPENDED ||
367
 
                        hcd->state == HC_STATE_HALT)) {
 
366
        if (HCD_RH_RUNNING(hcd)) {
368
367
                dev_warn(dev, "Root hub is not suspended\n");
369
368
                return -EBUSY;
370
369
        }
 
370
        if (hcd->shared_hcd) {
 
371
                hcd = hcd->shared_hcd;
 
372
                if (HCD_RH_RUNNING(hcd)) {
 
373
                        dev_warn(dev, "Secondary root hub is not suspended\n");
 
374
                        return -EBUSY;
 
375
                }
 
376
        }
371
377
        return 0;
372
378
}
373
379
 
386
392
        if (retval)
387
393
                return retval;
388
394
 
389
 
        if (hcd->driver->pci_suspend) {
 
395
        if (hcd->driver->pci_suspend && !HCD_DEAD(hcd)) {
390
396
                /* Optimization: Don't suspend if a root-hub wakeup is
391
397
                 * pending and it would cause the HCD to wake up anyway.
392
398
                 */
393
399
                if (do_wakeup && HCD_WAKEUP_PENDING(hcd))
394
400
                        return -EBUSY;
 
401
                if (do_wakeup && hcd->shared_hcd &&
 
402
                                HCD_WAKEUP_PENDING(hcd->shared_hcd))
 
403
                        return -EBUSY;
395
404
                retval = hcd->driver->pci_suspend(hcd, do_wakeup);
396
405
                suspend_report_result(hcd->driver->pci_suspend, retval);
397
406
 
398
407
                /* Check again in case wakeup raced with pci_suspend */
399
 
                if (retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) {
 
408
                if ((retval == 0 && do_wakeup && HCD_WAKEUP_PENDING(hcd)) ||
 
409
                                (retval == 0 && do_wakeup && hcd->shared_hcd &&
 
410
                                 HCD_WAKEUP_PENDING(hcd->shared_hcd))) {
400
411
                        if (hcd->driver->pci_resume)
401
412
                                hcd->driver->pci_resume(hcd, false);
402
413
                        retval = -EBUSY;
427
438
        struct usb_hcd          *hcd = pci_get_drvdata(pci_dev);
428
439
        int                     retval;
429
440
 
430
 
        if (hcd->state != HC_STATE_SUSPENDED) {
 
441
        if (HCD_RH_RUNNING(hcd) ||
 
442
                        (hcd->shared_hcd &&
 
443
                         HCD_RH_RUNNING(hcd->shared_hcd))) {
431
444
                dev_dbg(dev, "can't resume, not suspended!\n");
432
445
                return 0;
433
446
        }
441
454
        pci_set_master(pci_dev);
442
455
 
443
456
        clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags);
 
457
        if (hcd->shared_hcd)
 
458
                clear_bit(HCD_FLAG_SAW_IRQ, &hcd->shared_hcd->flags);
444
459
 
445
 
        if (hcd->driver->pci_resume) {
 
460
        if (hcd->driver->pci_resume && !HCD_DEAD(hcd)) {
446
461
                if (event != PM_EVENT_AUTO_RESUME)
447
462
                        wait_for_companions(pci_dev, hcd);
448
463
 
450
465
                                event == PM_EVENT_RESTORE);
451
466
                if (retval) {
452
467
                        dev_err(dev, "PCI post-resume error %d!\n", retval);
 
468
                        if (hcd->shared_hcd)
 
469
                                usb_hc_died(hcd->shared_hcd);
453
470
                        usb_hc_died(hcd);
454
471
                }
455
472
        }
475
492
 
476
493
        pci_save_state(pci_dev);
477
494
 
478
 
        /* If the root hub is HALTed rather than SUSPENDed,
479
 
         * disallow remote wakeup.
 
495
        /* If the root hub is dead rather than suspended, disallow remote
 
496
         * wakeup.  usb_hc_died() should ensure that both hosts are marked as
 
497
         * dying, so we only need to check the primary roothub.
480
498
         */
481
 
        if (hcd->state == HC_STATE_HALT)
 
499
        if (HCD_DEAD(hcd))
482
500
                device_set_wakeup_enable(dev, 0);
483
501
        dev_dbg(dev, "wakeup: %d\n", device_may_wakeup(dev));
484
502