ARM: tegra20: flowctrl: add support for cpu_suspend_enter/exit
authorJoseph Lo <josephl@nvidia.com>
Tue, 15 Jan 2013 22:11:01 +0000 (22:11 +0000)
committerStephen Warren <swarren@nvidia.com>
Mon, 28 Jan 2013 18:20:38 +0000 (11:20 -0700)
The flow controller can help CPU to go into suspend mode (powered-down
state). When CPU go into powered-down state, it needs some careful
settings before getting into and after leaving. The enter and exit
functions do that by configuring appropriate mode for flow controller.

Signed-off-by: Joseph Lo <josephl@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
arch/arm/mach-tegra/flowctrl.c
arch/arm/mach-tegra/flowctrl.h

index 5393eb2cae216767b7fe5b3fdab33a551ffd3531..b477ef310dcd1781cab7df8b3c51eba950342e06 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "flowctrl.h"
 #include "iomap.h"
+#include "fuse.h"
 
 static u8 flowctrl_offset_halt_cpu[] = {
        FLOW_CTRL_HALT_CPU0_EVENTS,
@@ -75,11 +76,26 @@ void flowctrl_cpu_suspend_enter(unsigned int cpuid)
        int i;
 
        reg = flowctrl_read_cpu_csr(cpuid);
-       reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP;       /* clear wfe bitmap */
-       reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP;       /* clear wfi bitmap */
+       switch (tegra_chip_id) {
+       case TEGRA20:
+               /* clear wfe bitmap */
+               reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP;
+               /* clear wfi bitmap */
+               reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP;
+               /* pwr gating on wfe */
+               reg |= TEGRA20_FLOW_CTRL_CSR_WFE_CPU0 << cpuid;
+               break;
+       case TEGRA30:
+               /* clear wfe bitmap */
+               reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP;
+               /* clear wfi bitmap */
+               reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP;
+               /* pwr gating on wfi */
+               reg |= TEGRA30_FLOW_CTRL_CSR_WFI_CPU0 << cpuid;
+               break;
+       }
        reg |= FLOW_CTRL_CSR_INTR_FLAG;                 /* clear intr flag */
        reg |= FLOW_CTRL_CSR_EVENT_FLAG;                /* clear event flag */
-       reg |= TEGRA30_FLOW_CTRL_CSR_WFI_CPU0 << cpuid; /* pwr gating on wfi */
        reg |= FLOW_CTRL_CSR_ENABLE;                    /* pwr gating */
        flowctrl_write_cpu_csr(cpuid, reg);
 
@@ -99,8 +115,20 @@ void flowctrl_cpu_suspend_exit(unsigned int cpuid)
 
        /* Disable powergating via flow controller for CPU0 */
        reg = flowctrl_read_cpu_csr(cpuid);
-       reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP;       /* clear wfe bitmap */
-       reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP;       /* clear wfi bitmap */
+       switch (tegra_chip_id) {
+       case TEGRA20:
+               /* clear wfe bitmap */
+               reg &= ~TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP;
+               /* clear wfi bitmap */
+               reg &= ~TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP;
+               break;
+       case TEGRA30:
+               /* clear wfe bitmap */
+               reg &= ~TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP;
+               /* clear wfi bitmap */
+               reg &= ~TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP;
+               break;
+       }
        reg &= ~FLOW_CTRL_CSR_ENABLE;                   /* clear enable */
        reg |= FLOW_CTRL_CSR_INTR_FLAG;                 /* clear intr */
        reg |= FLOW_CTRL_CSR_EVENT_FLAG;                /* clear event */
index 0798dec1832d5d8aa7e066e5afcb40e0876dbc39..67eab56699bd49f66925b66ed4c5b8d5922de037 100644 (file)
 #define FLOW_CTRL_HALT_CPU1_EVENTS     0x14
 #define FLOW_CTRL_CPU1_CSR             0x18
 
+#define TEGRA20_FLOW_CTRL_CSR_WFE_CPU0         (1 << 4)
+#define TEGRA20_FLOW_CTRL_CSR_WFE_BITMAP       (3 << 4)
+#define TEGRA20_FLOW_CTRL_CSR_WFI_BITMAP       0
+
 #define TEGRA30_FLOW_CTRL_CSR_WFI_CPU0         (1 << 8)
 #define TEGRA30_FLOW_CTRL_CSR_WFE_BITMAP       (0xF << 4)
 #define TEGRA30_FLOW_CTRL_CSR_WFI_BITMAP       (0xF << 8)