[Meego-kernel] [PATCH 7/10] usb: penwell_otg: enable PHY low power mode.

Wu, Hao hao.wu
Mon Sep 27 03:46:27 PDT 2010


>From 54652da2524705f825b9dddebad8722190f77f6b Mon Sep 17 00:00:00 2001
From: Hao Wu <hao.wu at intel.com>
Date: Mon, 27 Sep 2010 15:56:06 +0800
Subject: [PATCH] usb: penwell_otg: enable PHY low power mode.

This patch enables the PHY Low power mode when OTG state machine
is in IDLE state to save power.

Signed-off-by: Hao Wu <hao.wu at intel.com>
---
 drivers/usb/otg/penwell_otg.c   |   32 ++++++++++++++++++++------------
 include/linux/usb/penwell_otg.h |    2 +-
 2 files changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/otg/penwell_otg.c b/drivers/usb/otg/penwell_otg.c
index 47ead31..3366c95 100644
--- a/drivers/usb/otg/penwell_otg.c
+++ b/drivers/usb/otg/penwell_otg.c
@@ -566,26 +566,32 @@ static void penwell_otg_loc_sof(int on)
 
 static void penwell_otg_phy_low_power(int on)
 {
-#if 0 /* Disable PHY low power */
 	struct	penwell_otg	*pnw = the_transceiver;
-	u8			val, phcd;
+	u32			val;
 
 	dev_dbg(pnw->dev, "%s ---> %s\n", __func__, on ? "on" : "off");
 
-	phcd = 0x40;
-
-	val = readb(pnw->iotg.base + CI_HOSTPC1 + 2);
+	val = readl(pnw->iotg.base + CI_HOSTPC1);
+	dev_dbg(pnw->dev, "---> Register CI_HOSTPC1 = %x\n", val);
 
-	if (on)
-		writeb(val | phcd, pnw->iotg.base + CI_HOSTPC1 + 2);
-	else
-		writeb(val & ~phcd, pnw->iotg.base + CI_HOSTPC1 + 2);
+	if (on) {
+		if (val & HOSTPC1_PHCD) {
+			dev_dbg(pnw->dev, "already in Low power mode\n");
+			return;
+		}
+		writel(val | HOSTPC1_PHCD, pnw->iotg.base + CI_HOSTPC1);
+	} else {
+		if (!(val & HOSTPC1_PHCD)) {
+			dev_dbg(pnw->dev, "already in Normal mode\n");
+			return;
+		}
+		writel(val & ~HOSTPC1_PHCD, pnw->iotg.base + CI_HOSTPC1);
+	}
 
-	val = readb(pnw->iotg.base + CI_HOSTPC1 + 2);
+	val = readl(pnw->iotg.base + CI_HOSTPC1);
 
-	dev_dbg(pnw->dev, "CI_HOSTPC1 byte2 = %x\n", val);
+	dev_dbg(pnw->dev, "<--- Register CI_HOSTPC1 = %x\n", val);
 	dev_dbg(pnw->dev, "%s <---\n", __func__);
-#endif
 }
 
 /* Enable/Disable OTG interrupt */
@@ -1476,6 +1482,7 @@ static void penwell_otg_work(struct work_struct *work)
 			/* Notify EM charger remove event */
 			penwell_otg_update_chrg_cap(CHRG_UNKNOWN,
 						CHRG_CURR_DISCONN);
+			penwell_otg_phy_low_power(1);
 		}
 		break;
 
@@ -1745,6 +1752,7 @@ static void penwell_otg_work(struct work_struct *work)
 							CHRG_CURR_ACA);
 
 			set_client_mode();
+			msleep(5);
 			penwell_otg_phy_low_power(1);
 
 			hsm->b_ssend_srp = 1;
diff --git a/include/linux/usb/penwell_otg.h b/include/linux/usb/penwell_otg.h
index 23a004e..2471192 100644
--- a/include/linux/usb/penwell_otg.h
+++ b/include/linux/usb/penwell_otg.h
@@ -232,7 +232,7 @@ enum penwell_otg_timer_type {
 #define TA_WAIT_BCON		30000
 #define TA_AIDL_BDIS		1500
 #define TA_BIDL_ADIS		300
-#define TA_WAIT_VFALL		100
+#define TA_WAIT_VFALL		950
 #define TB_ASE0_BRST		300
 #define TB_SE0_SRP		1800
 #define TB_SSEND_SRP		1800
-- 
1.5.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0007-usb-penwell_otg-enable-PHY-low-power-mode.patch
Type: application/octet-stream
Size: 2853 bytes
Desc: 0007-usb-penwell_otg-enable-PHY-low-power-mode.patch
URL: <http://lists.meego.com/pipermail/meego-kernel/attachments/20100927/b7edd66d/attachment.obj>




More information about the Meego-kernel mailing list