From 2b0c0692730bc801ccf1d84f5d91b1ea014d5271 Mon Sep 17 00:00:00 2001 From: xxx Date: Sat, 22 Mar 2014 22:12:44 +0800 Subject: [PATCH] fixed: rk3288 pm clkgating pll pd --- arch/arm/boot/dts/rk3288-clocks.dtsi | 20 +++++ arch/arm/boot/dts/rk3288.dtsi | 5 +- arch/arm/mach-rockchip/pm-pie.c | 7 +- arch/arm/mach-rockchip/pm-rk3288.c | 105 ++++++++++++++++----------- arch/arm/mach-rockchip/pm.c | 28 +++++-- arch/arm/mach-rockchip/pm.h | 12 ++- arch/arm/mach-rockchip/rk3288.c | 105 +++++++++++++++++++++++++-- 7 files changed, 219 insertions(+), 63 deletions(-) mode change 100644 => 100755 arch/arm/boot/dts/rk3288-clocks.dtsi mode change 100755 => 100644 arch/arm/mach-rockchip/pm-pie.c mode change 100755 => 100644 arch/arm/mach-rockchip/pm-rk3288.c mode change 100755 => 100644 arch/arm/mach-rockchip/pm.c mode change 100755 => 100644 arch/arm/mach-rockchip/pm.h mode change 100755 => 100644 arch/arm/mach-rockchip/rk3288.c diff --git a/arch/arm/boot/dts/rk3288-clocks.dtsi b/arch/arm/boot/dts/rk3288-clocks.dtsi old mode 100644 new mode 100755 index ff2399ef6c5f..36661c0b989c --- a/arch/arm/boot/dts/rk3288-clocks.dtsi +++ b/arch/arm/boot/dts/rk3288-clocks.dtsi @@ -180,6 +180,7 @@ compatible = "rockchip,rk-clock-regs"; #address-cells = <1>; #size-cells = <1>; + reg = <0x0000 0x3ff>; ranges; /* PLL control regs */ @@ -2006,6 +2007,7 @@ "clk_acc_efuse", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0fff 0x0fff>; #clock-cells = <1>; }; @@ -2039,6 +2041,7 @@ "clk_uart2_div", "uart2_frac", "clk_uart3_div", "uart3_frac"; + rockchip,suspend-clkgating-setting=<0x0 0x0>; #clock-cells = <1>; }; @@ -2070,6 +2073,7 @@ "clk_uart4_div", "uart4_frac", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x000f 0x000f>; #clock-cells = <1>; }; @@ -2103,6 +2107,7 @@ "clk_edp_24m", "clk_edp", "clk_isp", "clk_isp_jpe"; + rockchip,suspend-clkgating-setting=<0x0000 0x0000>; #clock-cells = <1>; }; @@ -2137,6 +2142,7 @@ "reserved", "reserved", /*"g_clk_ddrphy0", "g_clk_ddrphy1",*/ "clk_jtag", "reserved"; /*"testclk_gate_en";*/ + rockchip,suspend-clkgating-setting=<0x7000 0xf000>; #clock-cells = <1>; }; @@ -2168,6 +2174,7 @@ "g_hdmi_hdcp_clk", "g_ps2c_clk", "usbphy_480m", "g_mipidsi_24m"; + rockchip,suspend-clkgating-setting=<0x0000 0x0000>; #clock-cells = <1>; }; @@ -2200,6 +2207,7 @@ "g_pclk_uart4", "g_pclk_i2c2", "g_pclk_i2c3", "g_pclk_i2c4"; + rockchip,suspend-clkgating-setting=<0x0003 0x0003>; #clock-cells = <1>; }; @@ -2232,6 +2240,7 @@ "g_h_emem_peri", "g_hclk_mem_peri", "g_hclk_nandc0", "g_hclk_nandc1"; + rockchip,suspend-clkgating-setting=<0x0c00 0xc000>; #clock-cells = <1>; }; @@ -2265,6 +2274,7 @@ "g_aclk_peri_mmu", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0000 0x0000>; #clock-cells = <1>; }; @@ -2296,6 +2306,7 @@ "reserved", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0 0x0>; #clock-cells = <1>; }; @@ -2328,6 +2339,7 @@ "g_aclk_dmac1", "g_aclk_strc_sys", "g_p_ddrupctl0", "g_pclk_publ0"; + rockchip,suspend-clkgating-setting=<0xe0f0 0xe0f0>; #clock-cells = <1>; }; @@ -2360,6 +2372,7 @@ "reserved", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0033 0x0033>; #clock-cells = <1>; }; @@ -2392,6 +2405,7 @@ "reserved", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0ff1 0x0ff1>; #clock-cells = <1>; }; @@ -2424,6 +2438,7 @@ "g_clk_wifi", "aclk_hevc", "clk_hevc_cabac", "clk_hevc_core"; + rockchip,suspend-clkgating-setting=<0x0 0x0>; #clock-cells = <1>; }; @@ -2456,6 +2471,7 @@ "g_p_alive_niu", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0xffff 0xffff>; #clock-cells = <1>; }; @@ -2488,6 +2504,7 @@ "g_aclk_vio1_niu", "g_aclk_vio2_niu", "g_aclk_vip", "g_hclk_vip"; + rockchip,suspend-clkgating-setting=<0x0 0x0>; #clock-cells = <1>; }; @@ -2520,6 +2537,7 @@ "reserved", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0 0x0>; #clock-cells = <1>; }; @@ -2552,6 +2570,7 @@ "reserved", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x01f 0x01f>; #clock-cells = <1>; }; @@ -2585,6 +2604,7 @@ "reserved", "reserved", "reserved", "reserved"; + rockchip,suspend-clkgating-setting=<0x0 0x0>; #clock-cells = <1>; }; diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi index b5d45a6d5faf..6cccdb0e29f4 100755 --- a/arch/arm/boot/dts/rk3288.dtsi +++ b/arch/arm/boot/dts/rk3288.dtsi @@ -10,6 +10,7 @@ / { compatible = "rockchip,rk3288"; + rockchip,sram = <&sram>; interrupt-parent = <&gic>; aliases { @@ -1015,11 +1016,11 @@ rockchip_suspend { rockchip,ctrbits = < (0 - // RKPM_CTR_PWR_DMNS + //|RKPM_CTR_PWR_DMNS //|RKPM_CTR_GTCLKS //|RKPM_CTR_PLLS //|RKPM_CTR_SYSCLK_DIV - |RKPM_CTR_NORIDLE_MD + //|RKPM_CTR_NORIDLE_MD ) >; rockchip,pmic-gpios=< diff --git a/arch/arm/mach-rockchip/pm-pie.c b/arch/arm/mach-rockchip/pm-pie.c old mode 100755 new mode 100644 index fe3e806efa83..c5cb5eb81fd6 --- a/arch/arm/mach-rockchip/pm-pie.c +++ b/arch/arm/mach-rockchip/pm-pie.c @@ -59,8 +59,8 @@ void PIE_FUNC(rkpm_sram_printch_pie)(char byte) if(DATA(pm_sram_ops).printch) DATA(pm_sram_ops).printch(byte); - if (byte == '\n') - FUNC(rkpm_sram_printch_pie)('\r'); + // if (byte == '\n') + //FUNC(rkpm_sram_printch_pie)('\r'); } void PIE_FUNC(rkpm_sram_printhex_pie)(unsigned int hex) @@ -129,6 +129,9 @@ void PIE_FUNC(rkpm_sram_suspend_arg)(void *arg) } static void rkpm_pie_init(void) { + if(rockchip_pie_chunk) + { rkpm_set_pie_info(kern_to_pie(rockchip_pie_chunk, &DATA(pm_sram_ops)) ,fn_to_pie(rockchip_pie_chunk, &FUNC(rkpm_sram_suspend_arg))); + } } diff --git a/arch/arm/mach-rockchip/pm-rk3288.c b/arch/arm/mach-rockchip/pm-rk3288.c old mode 100755 new mode 100644 index 81dfda88dac8..6ff9839d8f3f --- a/arch/arm/mach-rockchip/pm-rk3288.c +++ b/arch/arm/mach-rockchip/pm-rk3288.c @@ -20,7 +20,7 @@ #include #include "pm.h" -//#define CPU 3288 +#define CPU 3288 //#include "sram.h" #include "pm-pie.c" @@ -269,7 +269,10 @@ static u32 slp_uart_data[RK3288_UART_NUM][10]; if(b_addr==NULL || ch>=RK3288_UART_NUM) return; if(ch==2) + { idx=RK3288_CLKGATE_PCLK_UART2; + b_addr=RK_DEBUG_UART_VIRT; + } gate_reg=cru_readl(RK3288_CRU_GATEID_CONS(idx)); @@ -1167,17 +1170,13 @@ static void gpio_get_dts_info(struct device_node *parent) } - - - - - /*******************************clk gating config*******************************************/ #define CLK_MSK_GATING(msk, con) cru_writel((msk << 16) | 0xffff, con) #define CLK_MSK_UNGATING(msk, con) cru_writel(((~msk) << 16) | 0xffff, con) static u32 clk_ungt_msk[RK3288_CRU_CLKGATES_CON_CNT];// first clk gating setting +static u32 clk_ungt_msk_1[RK3288_CRU_CLKGATES_CON_CNT];// first clk gating setting static u32 clk_ungt_save[RK3288_CRU_CLKGATES_CON_CNT]; //first clk gating value saveing @@ -1225,23 +1224,27 @@ void PIE_FUNC(gtclks_sram_resume)(void) static void gtclks_suspend(void) { int i; - + + // rkpm_ddr_regs_dump(RK_CRU_VIRT,RK3288_CRU_CLKGATES_CON(0) + // ,RK3288_CRU_CLKGATES_CON(RK3288_CRU_CLKGATES_CON_CNT-1)); for(i=0;i0x194) + { + CLK_MSK_UNGATING(clk_ungt_msk[i],RK3288_CRU_CLKGATES_CON(i)); + + } + #if 0 rkpm_ddr_printch('\n'); - #endif + rkpm_ddr_printhex(RK3288_CRU_CLKGATES_CON(i)); + rkpm_ddr_printch('-'); + rkpm_ddr_printhex(clk_ungt_msk[i]); + rkpm_ddr_printch('-'); + rkpm_ddr_printhex(cru_readl(RK3288_CRU_CLKGATES_CON(i))) ; + if(i==(RK3288_CRU_CLKGATES_CON_CNT-1)) + rkpm_ddr_printch('\n'); + #endif } } @@ -1251,8 +1254,10 @@ static void gtclks_resume(void) int i; for(i=0;i @@ -91,10 +91,16 @@ struct rkpm_gpios_info_st{ #define reg_readl(base) readl_relaxed(base) #define reg_writel(v, base) do { writel_relaxed(v, base); dsb(); } while (0) - +#if 0 #define PM_ERR(fmt, args...) printk(KERN_ERR fmt, ##args) #define PM_LOG(fmt, args...) printk(KERN_ERR fmt, ##args) #define PM_WARNING(fmt, args...) printk(KERN_WARNING fmt, ##args) +#else + +#define PM_ERR(fmt, args...) printk(fmt, ##args) +#define PM_LOG(fmt, args...) printk(fmt, ##args) +#define PM_WARNING(fmt, args...) printk(fmt, ##args) +#endif /*********************************pm control******************************************/ extern void rkpm_ddr_reg_offset_dump(void __iomem * base_addr,u32 _offset); diff --git a/arch/arm/mach-rockchip/rk3288.c b/arch/arm/mach-rockchip/rk3288.c old mode 100755 new mode 100644 index 1b4afaf981b3..a3173e0024f7 --- a/arch/arm/mach-rockchip/rk3288.c +++ b/arch/arm/mach-rockchip/rk3288.c @@ -388,17 +388,112 @@ static int __init rk3288_pie_init(void) rockchip_sram_virt = kern_to_pie(rockchip_pie_chunk, &__pie_common_start[0]); rockchip_sram_stack = kern_to_pie(rockchip_pie_chunk, (char *) DATA(sram_stack) + sizeof(DATA(sram_stack))); - return 0; } arch_initcall(rk3288_pie_init); #ifdef CONFIG_PM #include "pm-rk3288.c" +int rk3288_sys_set_power_domain(enum pmu_power_domain pd, bool on) +{ + u32 clks_ungating[RK3288_CRU_CLKGATES_CON_CNT]; + u32 clks_save[RK3288_CRU_CLKGATES_CON_CNT]; + u32 i,ret; + for(i=0;i