1 #include <linux/kernel.h>
2 #include <linux/init.h>
3 #include <linux/suspend.h>
7 /*************************dump reg********************************************/
9 static void __sramfunc rkpm_sram_regs_dump(u32 base_addr,u32 start_offset,u32 end_offset)
13 rkpm_sram_printch('\n');
14 rkpm_sram_printhex(base_addr);
15 rkpm_sram_printch(':');
16 rkpm_sram_printch('\n');
18 for(i=start_offset;i<=end_offset;)
20 rkpm_sram_printhex(i);
21 rkpm_sram_printch('-');
22 rkpm_sram_printhex(readl_relaxed((void *)(base_addr + i)));
24 rkpm_sram_printch('\n');
28 rkpm_sram_printch('\n');
33 struct rkpm_sram_ops DEFINE_PIE_DATA(pm_sram_ops);
35 static __sramdata u32 rkpm_sram_ctrbits;
37 /****************** for pm.c and in sram***************************************/
38 //only usr in sram function
39 #define rkpm_chk_sram_ctrbit(bit) (rkpm_sram_ctrbits&(bit))
40 #define rkpm_chk_sram_ctrbits(bits) (rkpm_sram_ctrbits&(bits))
42 #define RKPM_SRAM_FUN(fun) \
43 if(DATA(pm_sram_ops).fun)\
44 (DATA(pm_sram_ops).fun)()
46 #define RKPM_BITCTR_SRAM_FUN(ctr,fun) \
47 if(rkpm_chk_sram_ctrbit(RKPM_CTR_##ctr)&&DATA(pm_sram_ops).fun)\
48 (DATA(pm_sram_ops).fun)()
51 #define RKPM_BITSCTR_SRAM_PFUN(bits,fun,fun_p) \
52 if(rkpm_chk_sram_ctrbits(bits)&&DATA(pm_sram_ops).fun_p) \
53 {DATA(pm_sram_ops).fun;} while(0)
55 /********************************sram print**********************************/
57 void PIE_FUNC(rkpm_sram_printch_pie)(char byte)
59 if(DATA(pm_sram_ops).printch)
60 DATA(pm_sram_ops).printch(byte);
63 //FUNC(rkpm_sram_printch_pie)('\r');
65 EXPORT_PIE_SYMBOL(FUNC(rkpm_sram_printch_pie));
68 void PIE_FUNC(rkpm_sram_printhex_pie)(unsigned int hex)
71 FUNC(rkpm_sram_printch_pie)('0');
72 FUNC(rkpm_sram_printch_pie)('x');
74 unsigned char c = (hex & 0xF0000000) >> 28;
75 FUNC(rkpm_sram_printch_pie)(c < 0xa ? c + '0' : c - 0xa + 'a');
79 EXPORT_PIE_SYMBOL(FUNC(rkpm_sram_printhex_pie));
82 /******************************************pm main function******************************************/
83 #define RKPM_CTR_SYSCLK RKPM_OR_3BITS(SYSCLK_DIV,SYSCLK_32K,SYSCLK_OSC_DIS)
85 static void __sramfunc rkpm_sram_suspend(u32 ctrbits)
88 rkpm_sram_printch('7');
89 RKPM_BITCTR_SRAM_FUN(DDR,ddr);
91 rkpm_sram_printch('8');
92 RKPM_BITCTR_SRAM_FUN(VOLTS,volts);
94 rkpm_sram_printch('9');
96 RKPM_BITCTR_SRAM_FUN(GTCLKS,gtclks);
98 RKPM_BITSCTR_SRAM_PFUN(RKPM_CTR_SYSCLK,sysclk(rkpm_sram_ctrbits),sysclk);
100 RKPM_BITCTR_SRAM_FUN(PMIC,pmic);
102 // if(rkpm_chk_sram_ctrbit(RKPM_CTR_SRAM_NO_WFI))
108 RKPM_BITCTR_SRAM_FUN(PMIC,re_pmic);
110 RKPM_BITSCTR_SRAM_PFUN(RKPM_CTR_SYSCLK,re_sysclk(rkpm_sram_ctrbits),re_sysclk);
112 RKPM_BITCTR_SRAM_FUN(GTCLKS,re_gtclks);
114 rkpm_sram_printch('9');
115 RKPM_BITCTR_SRAM_FUN(VOLTS,re_volts);
117 rkpm_sram_printch('8');
118 RKPM_BITCTR_SRAM_FUN(DDR,re_ddr);
120 rkpm_sram_printch('7');
123 void PIE_FUNC(rkpm_sram_suspend_arg)(void *arg)
125 rkpm_sram_ctrbits=*((u32 *)arg);
127 // rkpm_sram_printhex(rkpm_sram_ctrbits);
128 //rkpm_sram_printhex(*((u32 *)arg));
129 rkpm_sram_suspend(rkpm_sram_ctrbits);
131 EXPORT_PIE_SYMBOL(FUNC(rkpm_sram_suspend_arg));
134 static void rkpm_pie_init(void)
136 if(rockchip_pie_chunk)
138 rkpm_set_pie_info(kern_to_pie(rockchip_pie_chunk, &DATA(pm_sram_ops))
139 ,fn_to_pie(rockchip_pie_chunk, &FUNC(rkpm_sram_suspend_arg)));