1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/suspend.h>
7 /*************************dump reg********************************************/
11 static void __sramfunc rkpm_sram_regs_dump(u32 base_addr,u32 start_offset,u32 end_offset)
15 rkpm_sram_printch('\n');
16 rkpm_sram_printhex(base_addr);
17 rkpm_sram_printch(':');
18 rkpm_sram_printch('\n');
20 for(i=start_offset;i<=end_offset;)
22 rkpm_sram_printhex(i);
23 rkpm_sram_printch('-');
24 rkpm_sram_printhex(readl_relaxed((void *)(base_addr + i)));
26 rkpm_sram_printch('\n');
30 rkpm_sram_printch('\n');
35 struct rkpm_sram_ops DEFINE_PIE_DATA(pm_sram_ops);
37 static __sramdata u32 rkpm_sram_ctrbits;
39 /****************** for pm.c and in sram***************************************/
40 //only usr in sram function
41 #define rkpm_chk_sram_ctrbit(bit) (rkpm_sram_ctrbits&(bit))
42 #define rkpm_chk_sram_ctrbits(bits) (rkpm_sram_ctrbits&(bits))
44 #define RKPM_SRAM_FUN(fun) \
45 if(DATA(pm_sram_ops).fun)\
46 (DATA(pm_sram_ops).fun)()
48 #define RKPM_BITCTR_SRAM_FUN(ctr,fun) \
49 if(rkpm_chk_sram_ctrbit(RKPM_CTR_##ctr)&&DATA(pm_sram_ops).fun)\
50 (DATA(pm_sram_ops).fun)()
53 #define RKPM_BITSCTR_SRAM_PFUN(bits,fun,fun_p) \
54 if(rkpm_chk_sram_ctrbits(bits)&&DATA(pm_sram_ops).fun_p) \
55 {DATA(pm_sram_ops).fun;} while(0)
56 /********************************sram print**********************************/
58 void PIE_FUNC(rkpm_sram_printch_pie)(char byte)
60 if(DATA(pm_sram_ops).printch)
61 DATA(pm_sram_ops).printch(byte);
64 //FUNC(rkpm_sram_printch_pie)('\r');
66 EXPORT_PIE_SYMBOL(FUNC(rkpm_sram_printch_pie));
69 void PIE_FUNC(rkpm_sram_printhex_pie)(unsigned int hex)
72 FUNC(rkpm_sram_printch_pie)('0');
73 FUNC(rkpm_sram_printch_pie)('x');
75 unsigned char c = (hex & 0xF0000000) >> 28;
76 FUNC(rkpm_sram_printch_pie)(c < 0xa ? c + '0' : c - 0xa + 'a');
80 EXPORT_PIE_SYMBOL(FUNC(rkpm_sram_printhex_pie));
83 /******************************************pm main function******************************************/
84 #define RKPM_CTR_SYSCLK RKPM_OR_3BITS(SYSCLK_DIV,SYSCLK_32K,SYSCLK_OSC_DIS)
86 static void __sramfunc rkpm_sram_suspend(u32 ctrbits)
88 rkpm_sram_printch('7');
89 RKPM_BITCTR_SRAM_FUN(VOLTS, volts);
90 rkpm_sram_printch('8');
91 RKPM_BITCTR_SRAM_FUN(BUS_IDLE, bus_idle_request);
92 RKPM_BITCTR_SRAM_FUN(DDR, ddr);
94 /*rkpm_sram_printch('8');*/
95 /*RKPM_BITCTR_SRAM_FUN(VOLTS,volts);*/
96 /*rkpm_sram_printch('9');*/
97 /* RKPM_BITCTR_SRAM_FUN(GTCLKS,gtclks);*/
99 RKPM_BITSCTR_SRAM_PFUN(RKPM_CTR_SYSCLK,sysclk(rkpm_sram_ctrbits),sysclk);
101 RKPM_BITCTR_SRAM_FUN(PMIC,pmic);
103 // if(rkpm_chk_sram_ctrbit(RKPM_CTR_SRAM_NO_WFI))
109 RKPM_BITCTR_SRAM_FUN(PMIC,re_pmic);
111 RKPM_BITSCTR_SRAM_PFUN(RKPM_CTR_SYSCLK,re_sysclk(rkpm_sram_ctrbits),re_sysclk);
113 /*RKPM_BITCTR_SRAM_FUN(GTCLKS,re_gtclks);*/
115 rkpm_sram_printch('9');
116 RKPM_BITCTR_SRAM_FUN(VOLTS,re_volts);
118 rkpm_sram_printch('8');
119 RKPM_BITCTR_SRAM_FUN(DDR,re_ddr);
121 rkpm_sram_printch('7');
124 void PIE_FUNC(rkpm_sram_suspend_arg)(void *arg)
126 rkpm_sram_ctrbits=*((u32 *)arg);
128 // rkpm_sram_printhex(rkpm_sram_ctrbits);
129 //rkpm_sram_printhex(*((u32 *)arg));
130 rkpm_sram_suspend(rkpm_sram_ctrbits);
132 EXPORT_PIE_SYMBOL(FUNC(rkpm_sram_suspend_arg));
133 static void rkpm_pie_init(void)
135 if(rockchip_pie_chunk)
137 rkpm_set_pie_info(kern_to_pie(rockchip_pie_chunk, &DATA(pm_sram_ops))
138 ,fn_to_pie(rockchip_pie_chunk, &FUNC(rkpm_sram_suspend_arg)));