]> code.ossystems Code Review - meta-freescale.git/blob
9a6def323428ecdc0f1f6776bbc3ce2912c97a35
[meta-freescale.git] /
1 From 10df11bb736c8166e53b41f96688b2e6bd53773b Mon Sep 17 00:00:00 2001
2 From: Richard Zhu <r65037@freescale.com>
3 Date: Fri, 16 Dec 2011 10:08:04 +0800
4 Subject: [PATCH] ENGR00170244-1 ARM: AHCI: Enable PDDQ mode when no disk is attached
5
6 In order to save the power consumption, enable the
7 PDDQ mode of AHCI PHY when there is no sata disk
8 on the port
9
10 Signed-off-by: Richard Zhu <r65037@freescale.com>
11 (cherry picked from commit a53c29d7e484a3562e3a4f24d952485fbeb4c933)
12 ---
13  arch/arm/plat-mxc/ahci_sata.c              |   30 ++++++++++++++++++++-------
14  arch/arm/plat-mxc/include/mach/ahci_sata.h |    1 +
15  2 files changed, 23 insertions(+), 8 deletions(-)
16
17 diff --git a/arch/arm/plat-mxc/ahci_sata.c b/arch/arm/plat-mxc/ahci_sata.c
18 index 466636b..76a2747 100644
19 --- a/arch/arm/plat-mxc/ahci_sata.c
20 +++ b/arch/arm/plat-mxc/ahci_sata.c
21 @@ -156,7 +156,7 @@ static int sata_init(struct device *dev)
22  {
23         void __iomem *mmio;
24         u32 tmpdata;
25 -       int ret = 0;
26 +       int ret = 0, iterations = 20;
27         struct clk *clk;
28  
29         sata_clk = clk_get(dev, "imx_sata_clk");
30 @@ -281,14 +281,28 @@ static int sata_init(struct device *dev)
31  
32         if (AHCI_SAVE_PWR_WITHOUT_HOTPLUG) {
33                 /* Release resources when there is no device on the port */
34 -               if ((readl(mmio + PORT_SATA_SR) & 0xF) == 0) {
35 -                       ret = -ENODEV;
36 -                       if (machine_is_mx53_smd() || machine_is_mx53_loco()
37 -                               || board_is_mx53_ard_b())
38 -                               goto no_device;
39 +               do {
40 +                       if ((readl(mmio + PORT_SATA_SR) & 0xF) == 0)
41 +                               msleep(25);
42                         else
43 -                               goto release_mem;
44 -               }
45 +                               break;
46 +
47 +                       if (iterations == 0) {
48 +                               pr_info("No sata disk.\n");
49 +                               ret = -ENODEV;
50 +                               /* Enter into PDDQ mode, save power */
51 +                               tmpdata = readl(mmio + PORT_PHY_CTL);
52 +                               writel(tmpdata | PORT_PHY_CTL_PDDQ_LOC,
53 +                                                       mmio + PORT_PHY_CTL);
54 +
55 +                               if (machine_is_mx53_smd()
56 +                                       || machine_is_mx53_loco()
57 +                                       || board_is_mx53_ard_b())
58 +                                       goto no_device;
59 +                               else
60 +                                       goto release_mem;
61 +                       }
62 +               } while (iterations-- > 0);
63         }
64  
65         iounmap(mmio);
66 diff --git a/arch/arm/plat-mxc/include/mach/ahci_sata.h b/arch/arm/plat-mxc/include/mach/ahci_sata.h
67 index ea68a19..e31797b 100644
68 --- a/arch/arm/plat-mxc/include/mach/ahci_sata.h
69 +++ b/arch/arm/plat-mxc/include/mach/ahci_sata.h
70 @@ -37,6 +37,7 @@ enum {
71         PORT_PHY_CTL_CAP_DAT_LOC = 0x20000,
72         PORT_PHY_CTL_WRITE_LOC = 0x40000,
73         PORT_PHY_CTL_READ_LOC = 0x80000,
74 +       PORT_PHY_CTL_PDDQ_LOC = 0x100000,
75         /* Port0 PHY Status */
76         PORT_PHY_SR = 0x17c,
77         /* PORT_PHY_SR */
78 -- 
79 1.5.4.4
80