aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394
diff options
context:
space:
mode:
authorBernhard Kaindl <bk@fsfe.org>2006-09-06 08:58:30 -0400
committerStefan Richter <stefanr@s5r6.in-berlin.de>2006-12-07 15:28:13 -0500
commitf011bf085cd41ee40c2c8e530f801ac6cb6e00d0 (patch)
tree6170cf32d4ea038dc0b23f52b9387a758b30960b /drivers/ieee1394
parentf9edc4f5c1dd9fab5ceedd69e77d20e508e41e8d (diff)
ohci1394: steps to implement suspend/resume
I did a quick shot on what I described and the appended patch does the first thing needed for working suspend/resume in ohci1394 which is HW de- and re-initialisation. It works with suspend2disk on my Ricoh R5C552 IEEE 1394 Controller with the 2.6.17 kernel to the extent that if I call dvgrab --interactive after suspend2disk without unloading ohci1394, it does not lock up dvgrab with 100% CPU but properly connects to the camera, given that I first unplug and plug the camera after coming back from suspend. I guess that could be fixed by forcing a bus reset in the resume function. I cannot test suspend to RAM here at the moment and should follow the guidelines in Documentation/power/pci.txt also, so this is rather a quick report than a finished patch and there are some rough edges: However, with this patch, I have to unload at least some in-kernel users of ohci1394 like dv1394 or video1394 before suspending. Not doing that caused an Oops and a bad tasklet error, probably from not handling ISO tasklets during suspend/resume properly. Maybe these can be temporarily cleared or unregistered and re-registered for suspend/resume with help from the other layers or from the highlevel 1394 core, but I do not really know what these do. But this patch provides a useful base to start from and is already of much help for people which do not need dv1394 and video1394 or can unload them at least during suspend. I cannot test function with sbp2 at the moment, but raw1394 seems to work fine. Signed-off-by: Bernhard Kaindl <bk@fsfe.org> Update 1: merge with previous two ohci1394 suspend/resume patches Update 2: version for application on top of Linux 2.6.19-rc4 Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/ieee1394')
-rw-r--r--drivers/ieee1394/ohci1394.c92
1 files changed, 78 insertions, 14 deletions
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c
index eae97d8dcf03..b98b9934b92d 100644
--- a/drivers/ieee1394/ohci1394.c
+++ b/drivers/ieee1394/ohci1394.c
@@ -3531,6 +3531,9 @@ static void ohci1394_pci_remove(struct pci_dev *pdev)
3531#ifdef CONFIG_PM 3531#ifdef CONFIG_PM
3532static int ohci1394_pci_resume (struct pci_dev *pdev) 3532static int ohci1394_pci_resume (struct pci_dev *pdev)
3533{ 3533{
3534 int err;
3535 struct ti_ohci *ohci;
3536
3534/* PowerMac resume code comes first */ 3537/* PowerMac resume code comes first */
3535#ifdef CONFIG_PPC_PMAC 3538#ifdef CONFIG_PPC_PMAC
3536 if (machine_is(powermac)) { 3539 if (machine_is(powermac)) {
@@ -3545,28 +3548,89 @@ static int ohci1394_pci_resume (struct pci_dev *pdev)
3545 3548
3546 pci_set_power_state(pdev, PCI_D0); 3549 pci_set_power_state(pdev, PCI_D0);
3547 pci_restore_state(pdev); 3550 pci_restore_state(pdev);
3548 return pci_enable_device(pdev); 3551 err = pci_enable_device(pdev);
3552 if (err)
3553 return err;
3554
3555 ohci = pci_get_drvdata(pdev);
3556 if (!ohci)
3557 return -1; /* or which exit status to use? */
3558
3559 PRINT(KERN_DEBUG, "resume called");
3560
3561 /* The following lines are copied from ohci1394_pci_probe(): */
3562
3563 /* Start off with a soft reset, to clear everything to a sane
3564 * state. */
3565 ohci_soft_reset(ohci);
3566
3567 /* Now enable LPS, which we need in order to start accessing
3568 * most of the registers. In fact, on some cards (ALI M5251),
3569 * accessing registers in the SClk domain without LPS enabled
3570 * will lock up the machine. Wait 50msec to make sure we have
3571 * full link enabled. */
3572 reg_write(ohci, OHCI1394_HCControlSet, OHCI1394_HCControl_LPS);
3573
3574 /* Disable and clear interrupts */
3575 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
3576 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
3577
3578 mdelay(50);
3579
3580 ohci_initialize(ohci);
3581
3582 return 0;
3549} 3583}
3550 3584
3551static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state) 3585static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3552{ 3586{
3553 int err; 3587 int err;
3588 struct ti_ohci *ohci;
3589
3590 ohci = pci_get_drvdata(pdev);
3591 if (!ohci)
3592 return -1; /* Not sure if this is the correct return code */
3593
3594 PRINT(KERN_DEBUG, "suspend called");
3595
3596 /* clear the async DMA contexts and stop using the controller: */
3597 hpsb_bus_reset(ohci->host);
3598
3599 /* The following calls are from ohci1394_pci_remove(): */
3554 3600
3555 printk(KERN_INFO "%s does not fully support suspend and resume yet\n", 3601 /* Clear out BUS Options */
3556 OHCI1394_DRIVER_NAME); 3602 reg_write(ohci, OHCI1394_ConfigROMhdr, 0);
3603 reg_write(ohci, OHCI1394_BusOptions,
3604 (reg_read(ohci, OHCI1394_BusOptions) & 0x0000f007) |
3605 0x00ff0000);
3606
3607 /* Clear interrupt registers */
3608 reg_write(ohci, OHCI1394_IntMaskClear, 0xffffffff);
3609 reg_write(ohci, OHCI1394_IntEventClear, 0xffffffff);
3610 reg_write(ohci, OHCI1394_IsoXmitIntMaskClear, 0xffffffff);
3611 reg_write(ohci, OHCI1394_IsoXmitIntEventClear, 0xffffffff);
3612 reg_write(ohci, OHCI1394_IsoRecvIntMaskClear, 0xffffffff);
3613 reg_write(ohci, OHCI1394_IsoRecvIntEventClear, 0xffffffff);
3614
3615 /* Disable IRM Contender */
3616 set_phy_reg(ohci, 4, ~0xc0 & get_phy_reg(ohci, 4));
3617
3618 /* Clear link control register */
3619 reg_write(ohci, OHCI1394_LinkControlClear, 0xffffffff);
3620
3621 /* Let all other nodes know to ignore us */
3622 ohci_devctl(ohci->host, RESET_BUS, LONG_RESET_NO_FORCE_ROOT);
3623
3624 /* This stops all DMA contexts, disables interrupts,
3625 * and clears linkEnable and LPS: */
3626 ohci_soft_reset(ohci);
3557 3627
3558 err = pci_save_state(pdev); 3628 err = pci_save_state(pdev);
3559 if (err) { 3629 if (err)
3560 printk(KERN_ERR "%s: pci_save_state failed with %d\n", 3630 goto out;
3561 OHCI1394_DRIVER_NAME, err);
3562 return err;
3563 }
3564 err = pci_set_power_state(pdev, pci_choose_state(pdev, state)); 3631 err = pci_set_power_state(pdev, pci_choose_state(pdev, state));
3565#ifdef OHCI1394_DEBUG
3566 if (err) 3632 if (err)
3567 printk(KERN_DEBUG "%s: pci_set_power_state failed with %d\n", 3633 goto out;
3568 OHCI1394_DRIVER_NAME, err);
3569#endif /* OHCI1394_DEBUG */
3570 3634
3571/* PowerMac suspend code comes last */ 3635/* PowerMac suspend code comes last */
3572#ifdef CONFIG_PPC_PMAC 3636#ifdef CONFIG_PPC_PMAC
@@ -3579,8 +3643,8 @@ static int ohci1394_pci_suspend (struct pci_dev *pdev, pm_message_t state)
3579 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0); 3643 pmac_call_feature(PMAC_FTR_1394_ENABLE, of_node, 0, 0);
3580 } 3644 }
3581#endif /* CONFIG_PPC_PMAC */ 3645#endif /* CONFIG_PPC_PMAC */
3582 3646out:
3583 return 0; 3647 return err;
3584} 3648}
3585#endif /* CONFIG_PM */ 3649#endif /* CONFIG_PM */
3586 3650