rk3368: support cpu suspend to wfi
authorchenjh <chenjh@rock-chips.com>
Wed, 18 Mar 2015 07:30:32 +0000 (15:30 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 18 Mar 2015 12:46:25 +0000 (20:46 +0800)
Signed-off-by: chenjh <chenjh@rock-chips.com>
arch/arm/mach-rockchip/rockchip_pm.c
arch/arm64/boot/dts/rk3368.dtsi

index d3e8a1ead7f9e0b200141d3db689db8109cba2ce..9a9ce3c6419729f7d6d3f040e13e02a6e0f88a67 100755 (executable)
@@ -11,7 +11,6 @@
 #include <asm/io.h>
 #include "pm.h"
 
 #include <asm/io.h>
 #include "pm.h"
 
-#ifdef CONFIG_ARM
 /*************************dump reg********************************************/
 
 void rkpm_ddr_reg_offset_dump(void __iomem * base_addr,u32 _offset)
 /*************************dump reg********************************************/
 
 void rkpm_ddr_reg_offset_dump(void __iomem * base_addr,u32 _offset)
@@ -403,6 +402,8 @@ void  rkpm_ddr_printhex(unsigned int hex)
                hex <<= 4;
        }
 }
                hex <<= 4;
        }
 }
+
+#ifdef CONFIG_ARM
 void rk_sram_suspend(void)
 {
        RKPM_DDR_FUN(regs_pread);
 void rk_sram_suspend(void)
 {
        RKPM_DDR_FUN(regs_pread);
@@ -438,6 +439,8 @@ static int rk_lpmode_enter(unsigned long arg)
 }
 
 int cpu_suspend(unsigned long arg, int (*fn)(unsigned long));
 }
 
 int cpu_suspend(unsigned long arg, int (*fn)(unsigned long));
+#endif /* CONFIG_ARM */
+
 static int rkpm_enter(suspend_state_t state)
 {
        //static u32 test_count=0;
 static int rkpm_enter(suspend_state_t state)
 {
        //static u32 test_count=0;
@@ -478,6 +481,7 @@ static int rkpm_enter(suspend_state_t state)
 
         rkpm_ddr_printch('5');
 
 
         rkpm_ddr_printch('5');
 
+#ifdef CONFIG_ARM
         if(rkpm_chk_jdg_ctrbits(RKPM_CTRBITS_SOC_DLPMD))
         {   
             if(cpu_suspend(0,rk_lpmode_enter)==0)
         if(rkpm_chk_jdg_ctrbits(RKPM_CTRBITS_SOC_DLPMD))
         {   
             if(cpu_suspend(0,rk_lpmode_enter)==0)
@@ -497,6 +501,10 @@ static int rkpm_enter(suspend_state_t state)
             dsb();
             wfi();
         }
             dsb();
             wfi();
         }
+#else
+       flush_cache_all();
+       cpu_suspend(1);
+#endif
 
         rkpm_ddr_printch('5');
 
 
         rkpm_ddr_printch('5');
 
@@ -568,6 +576,14 @@ void __init rockchip_suspend_init(void)
     suspend_set_ops(&rockchip_suspend_ops);
     return;
 }
     suspend_set_ops(&rockchip_suspend_ops);
     return;
 }
+
+#ifndef CONFIG_ARM
+static int __init rockchip_init_suspend(void)
+{
+       suspend_set_ops(&rockchip_suspend_ops);
+       return 0;
+}
+late_initcall_sync(rockchip_init_suspend);
 #endif /* CONFIG_ARM */
 
 static enum rockchip_pm_policy pm_policy;
 #endif /* CONFIG_ARM */
 
 static enum rockchip_pm_policy pm_policy;
index 151298c3223849352c371b3db71904d25e565f10..8fb60ed7caa627fc7e57b106a9a00c87fe11afe4 100755 (executable)
                #address-cells = <2>;
                #size-cells = <0>;
 
                #address-cells = <2>;
                #size-cells = <0>;
 
+               idle-states {
+                       entry-method = "arm,psci";
+                       CPU_SLEEP_0: cpu-sleep-0 {
+                               compatible = "arm,idle-state";
+                               arm,psci-suspend-param = <0x0000000>;
+                               entry-latency-us = <10000000>;
+                               exit-latency-us = <10000000>;
+                               min-residency-us = <25000>;
+                       };
+               };
+
                little0: cpu@100 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x100>;
                        enable-method = "psci";
                little0: cpu@100 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x100>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                little1: cpu@101 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x101>;
                        enable-method = "psci";
                };
                little1: cpu@101 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x101>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                little2: cpu@102 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x102>;
                        enable-method = "psci";
                };
                little2: cpu@102 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x102>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                little3: cpu@103 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x103>;
                        enable-method = "psci";
                };
                little3: cpu@103 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x103>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                big0: cpu@0 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x0>;
                        enable-method = "psci";
                };
                big0: cpu@0 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x0>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                big1: cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x1>;
                        enable-method = "psci";
                };
                big1: cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x1>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                big2: cpu@2 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x2>;
                        enable-method = "psci";
                };
                big2: cpu@2 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x2>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
                big3: cpu@3 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x3>;
                        enable-method = "psci";
                };
                big3: cpu@3 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x0 0x3>;
                        enable-method = "psci";
+                       cpu-idle-states = <&CPU_SLEEP_0>;
                };
 
                cpu-map {
                };
 
                cpu-map {
                compatible = "arm,psci";
                method = "smc";
                cpu_on = <0xC4000003>;
                compatible = "arm,psci";
                method = "smc";
                cpu_on = <0xC4000003>;
+               cpu_suspend = <0x84000001>;
+               cpu_off = <0x84000002>;
        };
 
        gic: interrupt-controller@ffb70000 {
        };
 
        gic: interrupt-controller@ffb70000 {
                        <&clk_gates12 5>,/*aclk_intmem0*/
                        <&clk_gates12 4>,/*aclk_intmem*/
                        <&clk_gates13 9>,/*aclk_gic400*/
                        <&clk_gates12 5>,/*aclk_intmem0*/
                        <&clk_gates12 4>,/*aclk_intmem*/
                        <&clk_gates13 9>,/*aclk_gic400*/
+                       <&clk_gates12 9>,/*hclk_rom*/
 
                        /*PD_ALIVE*/
                        <&clk_gates22 13>,/*pclk_timer1*/
 
                        /*PD_ALIVE*/
                        <&clk_gates22 13>,/*pclk_timer1*/