Skip to contentSkip to conversation

twl: usb: Add the resume() and suspend() methods to twl4030-usb.c

PATCH In review Kim Kyuwon 5 participants 5 messages Feb 25, 2009 – Feb 26, 2009 2 messages not in the archive USB

lore
Share & tools
lore

Kim Kyuwon

author
#0 lore raw

PATCH 2/2 twl: usb: Add the resume() and suspend() methods to twl4030-usb.c

From: Minkyu Kang <[email protected]>

The MPU module can be waked up by the unexpected USB interrupt(HSUSB_MC_NINT). For instance, if the MUSB is working as peripheral mode and connected to a host PC, it can never enter the low power mode due to interrupts from the host PC. This patch added the feature that a board specific file can determines that TWL4030 supplies the USB power or not in the low power mode. Disabling the USB power may save the power consumption.

---
 drivers/usb/otg/twl4030-usb.c |   25 +++++++++++++++++++++++++
 include/linux/i2c/twl4030.h   |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/usb/otg/twl4030-usb.c +1 -0
index 416e441..0d65a8d 100644
@@ -256,6 +256,7 @@ struct twl4030_usb {
 	u8			linkstat;
 	u8			asleep;
 	bool			irq_enabled;
+	bool			suspend_enabled;
 };
 
 /* internal define on top of container_of */
@@ -618,6 +619,7 @@ static int __init twl4030_usb_probe(struct

platform_device *pdev)
twl->otg.set_suspend = twl4030_set_suspend;
twl->usb_mode = pdata->usb_mode;
twl->asleep = 1;
+ twl->suspend_enabled = pdata->suspend_enabled;

/* init spinlock for workqueue */ spin_lock_init(&twl->lock);
@@ -694,9 +696,32 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)
return 0;
}

+int twl4030_usb_suspend(struct platform_device *pdev, pm_message_t state) +{
+ struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+ if (!twl->suspend_enabled)
+ return 0;
+
+ twl->otg.set_suspend(&twl->otg, 1);
+
+ return 0;
+}
+
+int twl4030_usb_resume(struct platform_device *pdev)
+{
+ struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+ twl->otg.set_suspend(&twl->otg, 0);
+
+ return 0;
+}
+
static struct platform_driver twl4030_usb_driver = {
.probe = twl4030_usb_probe,
.remove = __exit_p(twl4030_usb_remove),
+ .suspend = twl4030_usb_suspend,
+ .resume = twl4030_usb_resume,
.driver = {
.name = "twl4030_usb",
.owner = THIS_MODULE,

include/linux/i2c/twl4030.h +1 -0
index c89d33b..0b12509 100644
@@ -325,6 +325,7 @@ enum twl4030_usb_mode {
 
 struct twl4030_usb_data {
 	enum twl4030_usb_mode	usb_mode;
+	bool suspend_enabled;
 };
 
 struct twl4030_ins {
Signature · 9 lines
1.5.2.5


-- 
Kyuwon
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

Review

Quoted 8 lines · ext Kim Kyuwon
(quoted diff) +8 -0
+int twl4030_usb_suspend(struct platform_device *pdev, pm_message_t state)
+{
+       struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+       if (!twl->suspend_enabled)
+               return 0;
+
+       twl->otg.set_suspend(&twl->otg, 1);

otg_set_suspend(otg, 1);

Review

Quoted 9 lines
(quoted diff) +9 -0
+
+       return 0;
+}
+
+int twl4030_usb_resume(struct platform_device *pdev)
+{
+       struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+       twl->otg.set_suspend(&twl->otg, 0);

otg_set_suspend(otg, 0);

Signature · 1 line
balbi

A message that is not in the archive (sent off-list or not yet received): 4d34a0a70902250355q4b8c54e4rc9bbc1f40539e486-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#3 lore raw

PATCH 2/2 twl: usb: Add the resume() and suspend() methods to twl4030-usb.c (re)

The MPU module can be waked up by the unexpected USB interrupt(HSUSB_MC_NINT). For instance, if the MUSB is working as peripheral mode and connected to a host PC, it can never enter the low power mode due to interrupts from the host PC. This patch added the feature that a board specific file can determines that TWL4030 supplies the USB power or not in the low power mode. Disabling the USB power may save the power consumption.

---
 drivers/usb/otg/twl4030-usb.c |   25 +++++++++++++++++++++++++
 include/linux/i2c/twl4030.h   |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/usb/otg/twl4030-usb.c +25 -0
index 416e441..b725be2 100644
@@ -256,6 +256,7 @@ struct twl4030_usb {
 	u8			linkstat;
 	u8			asleep;
 	bool			irq_enabled;
+	bool			suspend_enabled;
 };
 
 /* internal define on top of container_of */
@@ -618,6 +619,7 @@ static int __init twl4030_usb_probe(struct platform_device *pdev)
 	twl->otg.set_suspend	= twl4030_set_suspend;
 	twl->usb_mode		= pdata->usb_mode;
 	twl->asleep		= 1;
+	twl->suspend_enabled	= pdata->suspend_enabled;
 
 	/* init spinlock for workqueue */
 	spin_lock_init(&twl->lock);
@@ -694,9 +696,32 @@ static int __exit twl4030_usb_remove(struct platform_device *pdev)
 	return 0;
 }
 
+int twl4030_usb_suspend(struct platform_device *pdev, pm_message_t state)
+{
+	struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+	if (!twl->suspend_enabled)
+		return 0;
+
+	otg_set_suspend(&twl->otg, 1);
+
+	return 0;
+}
+
+int twl4030_usb_resume(struct platform_device *pdev)
+{
+	struct twl4030_usb *twl = platform_get_drvdata(pdev);
+
+	otg_set_suspend(&twl->otg, 0);
+
+	return 0;
+}
+
 static struct platform_driver twl4030_usb_driver = {
 	.probe		= twl4030_usb_probe,
 	.remove		= __exit_p(twl4030_usb_remove),
+	.suspend	= twl4030_usb_suspend,
+	.resume		= twl4030_usb_resume,
 	.driver		= {
 		.name	= "twl4030_usb",
 		.owner	= THIS_MODULE,
include/linux/i2c/twl4030.h +1 -0
index c89d33b..0b12509 100644
@@ -325,6 +325,7 @@ enum twl4030_usb_mode {
 
 struct twl4030_usb_data {
 	enum twl4030_usb_mode	usb_mode;
+	bool suspend_enabled;
 };
 
 struct twl4030_ins {

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH 2/2] twl: usb: Add the resume() and suspend() methods to twl4030-usb.c (re)

Quoted 20 lines · Minkyu Kang

The MPU module can be waked up by the unexpected USB interrupt(HSUSB_MC_NINT). For instance, if the MUSB is working as peripheral mode and connected to a host PC, it can never enter the low power mode due to interrupts from the host PC. This patch added the feature that a board specific file can determines that TWL4030 supplies the USB power or not in the low power mode. Disabling the USB power may save the power consumption.

---
 drivers/usb/otg/twl4030-usb.c |   25 +++++++++++++++++++++++++
 include/linux/i2c/twl4030.h   |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/usb/otg/twl4030-usb.c +0 -0
index 416e441..b725be2 100644

drivers/usb/otg/twl4030-usb.c struct twl4030_usb { · line 259

Quoted 4 lines
drivers/usb/otg/twl4030-usb.c +1 -0
@@ -256,6 +256,7 @@ struct twl4030_usb {
 	u8			linkstat;
 	u8			asleep;
 	bool			irq_enabled;
+	bool			suspend_enabled;

before we ack it and let it go through, could you please explain a bit more the necessity of this ?

I mean, what you're doing here is that you would allow twl4030 to enter low power mode even though we're connected to host side, meaning we would never get awaken by the host side, right ?

Is that really wanted ? I mean, how would you then wake the device ?

Signature · 5 lines
balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

RE: [PATCH 2/2] twl: usb: Add the resume() and suspend() methods to twl4030-usb.c (re)

Quoted 3 lines

I mean, what you're doing here is that you would allow twl4030 to enter low power mode even though we're connected to host side, meaning we would never get awaken by the host side, right ?

Yes, right.
If usb is connected to host side, our system never sleep because of usb interrupts by host.
We don't want this.
We want to enter sleep mode quietly without any disturbance even if usb is connected to host side.(And we need to reduce power consumption) This patch gives option for these reasons.
If you don't want this option, please set suspend_enabled = false in the board specific configuration.

Quoted 1 line

Is that really wanted ? I mean, how would you then wake the device ?

Our system is waked when get wake-up interrupts such as IO pad wake-up events and other wake-up events from peripheral devices. When it wakes up devices, usb device will be waked too.

---
Minkyu Kang.

-----Original Message-----
From: Felipe Balbi [mailto:[email protected]]
Sent: Thursday, February 26, 2009 9:12 AM
To: Minkyu Kang
Cc: Kim Kyuwon; [email protected]; [email protected]; OMAP; David Brownell; [email protected]
Subject: Re: [PATCH 2/2] twl: usb: Add the resume() and suspend() methods to twl4030-usb.c (re)

Quoted 20 lines · Minkyu Kang

The MPU module can be waked up by the unexpected USB interrupt(HSUSB_MC_NINT). For instance, if the MUSB is working as peripheral mode and connected to a host PC, it can never enter the low power mode due to interrupts from the host PC. This patch added the feature that a board specific file can determines that TWL4030 supplies the USB power or not in the low power mode. Disabling the USB power may save the power consumption.

---
 drivers/usb/otg/twl4030-usb.c |   25 +++++++++++++++++++++++++
 include/linux/i2c/twl4030.h   |    1 +
 2 files changed, 26 insertions(+), 0 deletions(-)
drivers/usb/otg/twl4030-usb.c +0 -0
index 416e441..b725be2 100644

drivers/usb/otg/twl4030-usb.c struct twl4030_usb { · line 259

Quoted 4 lines
drivers/usb/otg/twl4030-usb.c +1 -0
@@ -256,6 +256,7 @@ struct twl4030_usb {
 	u8			linkstat;
 	u8			asleep;
 	bool			irq_enabled;
+	bool			suspend_enabled;

before we ack it and let it go through, could you please explain a bit more the necessity of this ?

I mean, what you're doing here is that you would allow twl4030 to enter low power mode even though we're connected to host side, meaning we would never get awaken by the host side, right ?

Is that really wanted ? I mean, how would you then wake the device ?

Signature · 1 line
balbi