From 10df11bb736c8166e53b41f96688b2e6bd53773b Mon Sep 17 00:00:00 2001 From: Richard Zhu Date: Fri, 16 Dec 2011 10:08:04 +0800 Subject: [PATCH] ENGR00170244-1 ARM: AHCI: Enable PDDQ mode when no disk is attached In order to save the power consumption, enable the PDDQ mode of AHCI PHY when there is no sata disk on the port Signed-off-by: Richard Zhu (cherry picked from commit a53c29d7e484a3562e3a4f24d952485fbeb4c933) --- arch/arm/plat-mxc/ahci_sata.c | 30 ++++++++++++++++++++------- arch/arm/plat-mxc/include/mach/ahci_sata.h | 1 + 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c index 466636b..76a2747 100644 --- a/arch/arm/plat-mxc/ahci_sata.c +++ b/arch/arm/plat-mxc/ahci_sata.c @@ -156,7 +156,7 @@ static int sata_init(struct device *dev) { void __iomem *mmio; u32 tmpdata; - int ret = 0; + int ret = 0, iterations = 20; struct clk *clk; sata_clk = clk_get(dev, "imx_sata_clk"); @@ -281,14 +281,28 @@ static int sata_init(struct device *dev) if (AHCI_SAVE_PWR_WITHOUT_HOTPLUG) { /* Release resources when there is no device on the port */ - if ((readl(mmio + PORT_SATA_SR) & 0xF) == 0) { - ret = -ENODEV; - if (machine_is_mx53_smd() || machine_is_mx53_loco() - || board_is_mx53_ard_b()) - goto no_device; + do { + if ((readl(mmio + PORT_SATA_SR) & 0xF) == 0) + msleep(25); else - goto release_mem; - } + break; + + if (iterations == 0) { + pr_info("No sata disk.\n"); + ret = -ENODEV; + /* Enter into PDDQ mode, save power */ + tmpdata = readl(mmio + PORT_PHY_CTL); + writel(tmpdata | PORT_PHY_CTL_PDDQ_LOC, + mmio + PORT_PHY_CTL); + + if (machine_is_mx53_smd() + || machine_is_mx53_loco() + || board_is_mx53_ard_b()) + goto no_device; + else + goto release_mem; + } + } while (iterations-- > 0); } iounmap(mmio); diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h index ea68a19..e31797b 100644 --- a/arch/arm/plat-mxc/include/mach/ahci_sata.h +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h @@ -37,6 +37,7 @@ enum { PORT_PHY_CTL_CAP_DAT_LOC = 0x20000, PORT_PHY_CTL_WRITE_LOC = 0x40000, PORT_PHY_CTL_READ_LOC = 0x80000, + PORT_PHY_CTL_PDDQ_LOC = 0x100000, /* Port0 PHY Status */ PORT_PHY_SR = 0x17c, /* PORT_PHY_SR */ -- 1.5.4.4