PATCH: ohci-s3c2410 suspend/resume support

"Matt Reimer" <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
Attached is a patch against 2.6.20 to implement suspend/resume support
for ohci-s3c2410, based on the suspend/resume support in ohci-pxa27x.c
and ohci-omap.c.

A question though: is the call to usb_hcd_resume_root_hub() in those
drivers necessary? My ohci-s3c2410.c patch seems to work fine without
it.

Matt

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
ohci-s3c2410.c.patch (application/octet-stream, 2.5 KB)
--- drivers/usb/host/ohci-s3c2410.c.orig	2007-02-08 11:51:45.000000000 -0800
+++ drivers/usb/host/ohci-s3c2410.c	2007-02-12 12:27:11.000000000 -0800
@@ -24,6 +24,7 @@
 
 #include <asm/hardware.h>
 #include <asm/arch/usb-control.h>
+#include <asm/arch/regs-gpio.h>
 
 #define valid_port(idx) ((idx) == 1 || (idx) == 2)
 
@@ -49,6 +50,13 @@ static void s3c2410_start_hc(struct plat
 
 	dev_dbg(&dev->dev, "s3c2410_start_hc:\n");
 
+	/* Put the USB port(s) in normal mode. */
+	if (info->port[0].flags & S3C_HCDFLG_USED)
+		s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND0, 0);
+
+	if (info->port[1].flags & S3C_HCDFLG_USED)
+		s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND1, 0);
+
 	clk_enable(usb_clk);
 	mdelay(2);			/* let the bus clock stabilise */
 
@@ -70,6 +78,15 @@ static void s3c2410_stop_hc(struct platf
 
 	dev_dbg(&dev->dev, "s3c2410_stop_hc:\n");
 
+	/* Put the USB port(s) in suspend mode. */
+	if (info->port[0].flags & S3C_HCDFLG_USED)
+		s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND0,
+				      S3C2410_MISCCR_USBSUSPND0);
+
+	if (info->port[1].flags & S3C_HCDFLG_USED)
+		s3c2410_modify_misccr(S3C2410_MISCCR_USBSUSPND1,
+				      S3C2410_MISCCR_USBSUSPND1);
+
 	if (info != NULL) {
 		info->report_oc = NULL;
 		info->hcd	= NULL;
@@ -489,12 +506,50 @@ static int ohci_hcd_s3c2410_drv_remove(s
 	return 0;
 }
 
+#ifdef CONFIG_PM
+
+static int ohci_hcd_s3c2410_drv_suspend(struct platform_device *pdev,
+					pm_message_t state)
+{
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+
+	if (time_before(jiffies, ohci->next_statechange))
+		msleep(5);
+	ohci->next_statechange = jiffies;
+
+	s3c2410_stop_hc(pdev);
+
+	hcd->state = HC_STATE_SUSPENDED;
+	pdev->dev.power.power_state = PMSG_SUSPEND;
+
+	return 0;
+}
+
+static int ohci_hcd_s3c2410_drv_resume(struct platform_device *pdev)
+{
+	struct usb_hcd *hcd = platform_get_drvdata(pdev);
+	struct ohci_hcd *ohci = hcd_to_ohci(hcd);
+
+	if (time_before(jiffies, ohci->next_statechange))
+		msleep(5);
+	ohci->next_statechange = jiffies;
+
+	s3c2410_start_hc(pdev, hcd);
+
+	pdev->dev.power.power_state = PMSG_ON;
+
+	return 0;
+}
+
+#endif
+
 static struct platform_driver ohci_hcd_s3c2410_driver = {
 	.probe		= ohci_hcd_s3c2410_drv_probe,
 	.remove		= ohci_hcd_s3c2410_drv_remove,
 	.shutdown	= usb_hcd_platform_shutdown,
-	/*.suspend	= ohci_hcd_s3c2410_drv_suspend, */
-	/*.resume	= ohci_hcd_s3c2410_drv_resume, */
+	.suspend	= ohci_hcd_s3c2410_drv_suspend,
+	.resume		= ohci_hcd_s3c2410_drv_resume,
 	.driver		= {
 		.owner	= THIS_MODULE,
 		.name	= "s3c2410-ohci",
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.