rk2818_socpm_set_gpio(RK2818_PIN_PG7,0,0);
#endif
}
-void __tcmfunc rk2818_pm_set_vol(void)
+
+void __tcmfunc pmu_suspend(void)
+{
+ //struct regulator *ldo1,*ldo2,*ldo4,*ldo5;
+ struct regulator *lilo1,*lilo2;
+
+ /*ldo1 = regulator_get(NULL, "ldo1");
+ regulator_disable(ldo1);
+ ldo2 = regulator_get(NULL, "ldo2");
+ regulator_disable(ldo2);
+ ldo4 = regulator_get(NULL, "ldo4");
+ regulator_disable(ldo4);
+ ldo5 = regulator_get(NULL, "ldo5");
+ regulator_disable(ldo5);*/
+
+ lilo1 = regulator_get(NULL, "lilo1");
+ regulator_set_voltage(lilo1,2800000,2800000);
+ lilo2 = regulator_get(NULL, "lilo2");
+ regulator_set_voltage(lilo2,2800000,2800000);
+}
+
+void __tcmfunc pmu_resume(void)
+{
+ //struct regulator *ldo1,*ldo2,*ldo4,*ldo5;
+ struct regulator *lilo1,*lilo2;
+
+ /*ldo1 = regulator_get(NULL, "ldo1");
+ regulator_enable(ldo1);
+
+ ldo2 = regulator_get(NULL, "ldo2");
+ regulator_enable(ldo2);
+
+ ldo4 = regulator_get(NULL, "ldo4");
+ regulator_enable(ldo4);
+
+ ldo5 = regulator_get(NULL, "ldo5");
+ regulator_enable(ldo5);*/
+
+ lilo1 = regulator_get(NULL, "lilo1");
+ regulator_set_voltage(lilo1,3000000,3000000);
+ lilo2 = regulator_get(NULL, "lilo2");
+ regulator_set_voltage(lilo2,3000000,3000000);
+}
+
+void __tcmfunc rk2818_pm_suspend_ctr_pin(void)
{
+ pmu_suspend( );
rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,0);
+ //rk2818_socpm_set_gpio(RK2818_PIN_PC7,1,0);
}
-void __tcmfunc rk2818_pm_resume_vol(void)
+void __tcmfunc rk2818_pm_resume_ctr_pin(void)
{
+
rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,1);
+ //rk2818_socpm_set_gpio(RK2818_PIN_PC7,1,0);
+ pmu_resume( );
}
+
+static struct rk2818_pm_callback_st __tcmdata callback_init={
+.scu_suspend=(pm_scu_suspend)rk2818_pm_scu_suspend,
+.general_reg_suspend=(pm_general_reg_suspend)rk2818_soc_general_reg_suspend,
+.set_pin=(pm_general_reg_suspend)rk2818_pm_suspend_ctr_pin,
+.resume_pin=(pm_resume_ctr_pin)rk2818_pm_resume_ctr_pin,
+};
#else
-#define pm_set_general_cpu_reg(a)
-#define rk2818_pm_set_vol()
-#define rk2818_pm_resume_vol()
+static struct rk2818_pm_callback_st __tcmdata callback_init={
+.scu_suspend=NULL,
+.general_reg_suspend=NULL,
+.set_pin=NULL,
+.resume_pin=NULL,
+};
#endif
static void __init machine_rk2818_init_irq(void)
{
{
printk("3x machine_rk2818_board_init\n");
- rk2818_socpm_int( (pm_scu_suspend) rk2818_pm_scu_suspend,(pm_general_reg_suspend) rk2818_soc_general_reg_suspend,
- (pm_set_suspendvol) rk2818_pm_set_vol,(pm_resume_vol) rk2818_pm_resume_vol);
+ rk2818_socpm_init(&callback_init);
rk2818_power_on();
pm_power_off = rk2818_power_off;
#ifdef CONFIG_SPI_FPGA_FW
rk2818_socpm_set_gpio(RK2818_PIN_PG7,0,0);
#endif
}
-void __tcmfunc rk2818_pm_set_vol(void)
+
+void __tcmfunc pmu_suspend(void)
+{
+ //struct regulator *ldo1,*ldo2,*ldo4,*ldo5;
+ struct regulator *lilo1,*lilo2;
+
+ /*ldo1 = regulator_get(NULL, "ldo1");
+ regulator_disable(ldo1);
+ ldo2 = regulator_get(NULL, "ldo2");
+ regulator_disable(ldo2);
+ ldo4 = regulator_get(NULL, "ldo4");
+ regulator_disable(ldo4);
+ ldo5 = regulator_get(NULL, "ldo5");
+ regulator_disable(ldo5);*/
+
+ lilo1 = regulator_get(NULL, "lilo1");
+ regulator_set_voltage(lilo1,2800000,2800000);
+ lilo2 = regulator_get(NULL, "lilo2");
+ regulator_set_voltage(lilo2,2800000,2800000);
+}
+
+void __tcmfunc pmu_resume(void)
+{
+ //struct regulator *ldo1,*ldo2,*ldo4,*ldo5;
+ struct regulator *lilo1,*lilo2;
+
+ /*ldo1 = regulator_get(NULL, "ldo1");
+ regulator_enable(ldo1);
+
+ ldo2 = regulator_get(NULL, "ldo2");
+ regulator_enable(ldo2);
+
+ ldo4 = regulator_get(NULL, "ldo4");
+ regulator_enable(ldo4);
+
+ ldo5 = regulator_get(NULL, "ldo5");
+ regulator_enable(ldo5);*/
+
+ lilo1 = regulator_get(NULL, "lilo1");
+ regulator_set_voltage(lilo1,3000000,3000000);
+ lilo2 = regulator_get(NULL, "lilo2");
+ regulator_set_voltage(lilo2,3000000,3000000);
+}
+
+void __tcmfunc rk2818_pm_suspend_ctr_pin(void)
{
+ pmu_suspend( );
rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,0);
+ //rk2818_socpm_set_gpio(RK2818_PIN_PC7,1,0);
}
-void __tcmfunc rk2818_pm_resume_vol(void)
+void __tcmfunc rk2818_pm_resume_ctr_pin(void)
{
+
rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,1);
+ //rk2818_socpm_set_gpio(RK2818_PIN_PC7,1,0);
+ pmu_resume( );
}
+
+static struct rk2818_pm_callback_st __tcmdata callback_init={
+.scu_suspend=(pm_scu_suspend)rk2818_pm_scu_suspend,
+.general_reg_suspend=(pm_general_reg_suspend)rk2818_soc_general_reg_suspend,
+.set_pin=(pm_general_reg_suspend)rk2818_pm_suspend_ctr_pin,
+.resume_pin=(pm_resume_ctr_pin)rk2818_pm_resume_ctr_pin,
+};
#else
-#define pm_set_general_cpu_reg(a)
-#define rk2818_pm_set_vol()
-#define rk2818_pm_resume_vol()
+static struct rk2818_pm_callback_st __tcmdata callback_init={
+.scu_suspend=NULL,
+.general_reg_suspend=NULL,
+.set_pin=NULL,
+.resume_pin=NULL,
+};
#endif
static void __init machine_rk2818_init_irq(void)
{
{
printk("3x machine_rk2818_board_init\n");
- rk2818_socpm_int( (pm_scu_suspend) rk2818_pm_scu_suspend,(pm_general_reg_suspend) rk2818_soc_general_reg_suspend,
- (pm_set_suspendvol) rk2818_pm_set_vol,(pm_resume_vol) rk2818_pm_resume_vol);
+ rk2818_socpm_init(&callback_init);
rk2818_power_on();
pm_power_off = rk2818_power_off;
#define ASM_LOOP_INSTRUCTION_NUM 4
-/*static noinline void __tcmlocalfunc tcm_udelay(unsigned long usecs, u32 arm_freq_mhz)
-{
- volatile unsigned int cycle;
-
- cycle = usecs * arm_freq_mhz / ASM_LOOP_INSTRUCTION_NUM;
-
- while (cycle--) {}
-}*/
-
#define CLK_GATE_SDRAM_MASK ((1 << (CLK_GATE_SDRAM_COMMON & 31)) | (1 << (CLK_GATE_SDRAM_CONTROLLER & 31)))
#define CLK_GATE_MOBILESDRAM_MASK ((1 << (CLK_GATE_SDRAM_COMMON & 31)) | (1 << (CLK_GATE_MOBILE_SDRAM_CONTROLLER & 31)))
tcm_udelay(100, 24); //DRVDelayUs(100); 延时一下比较安全,保证退出后稳定
}
-#if 1
+#if 0
static void __tcmlocalfunc noinline tcm_printch(char byte)
{
unsigned int timeout;
}
#endif
-//#define RK2818_MOBLIE_PM_CON
-#ifdef RK2818_MOBLIE_PM_CON
-
-#define RK2818_MOBLIE_PM_PRT_ORIGINAL_REG
-//#define RK2818_MOBLIE_PM_PRT_CHANGED_REG
-
-#define PM_SAVE_REG_NUM 4
-struct rk2818_pm_st{
-unsigned int *pm_scu_reg;
-unsigned int *pm_cpu_reg;
-unsigned int *pm_gpio0_reg;
-unsigned int *pm_gpio1_reg;
-unsigned int *savereg;
-
-unsigned int *pm_scu_reg_ch;
-unsigned int *pm_cpu_reg_ch;
-unsigned int *pm_gpio0_reg_ch;
-unsigned int *pm_gpio1_reg_ch;
-unsigned int *save_ch;
-
-u16 scu_regbit;
-u16 cpu_regbit;
-u16 gpio0_regbit;
-u16 gpio1_regbit;
-};
-unsigned int __tcmdata pm_scu_reg_save[PM_SCU_REG_NUM];
-unsigned int __tcmdata pm_cpu_reg_save[PM_GENERAL_CPU_REG];
-unsigned int __tcmdata pm_gpio0_reg_save[PM_SCU_GPIO_SWPORTC_NUM];
-unsigned int __tcmdata pm_gpio1_reg_save[PM_SCU_GPIO_SWPORTC_NUM];
-unsigned int __tcmdata pm_savereg[PM_SAVE_REG_NUM];
-
-unsigned int __tcmdata pm_scu_reg_ch[PM_SCU_REG_NUM];
-unsigned int __tcmdata pm_cpu_reg_ch[PM_GENERAL_CPU_REG];
-unsigned int __tcmdata pm_gpio0_reg_save_ch[PM_SCU_GPIO_SWPORTC_NUM];
-unsigned int __tcmdata pm_gpio1_reg_save_ch[PM_SCU_GPIO_SWPORTC_NUM];
-unsigned int __tcmdata savereg_ch[PM_SAVE_REG_NUM];
-
-struct rk2818_pm_st __tcmdata pm_save={
-.pm_scu_reg=&pm_scu_reg_save[0],
-.pm_cpu_reg=&pm_cpu_reg_save[0],
-.pm_gpio0_reg=&pm_gpio0_reg_save[0],
-.pm_gpio1_reg=&pm_gpio1_reg_save[0],
-.savereg=&pm_savereg[0],
-
-.pm_scu_reg_ch=&pm_scu_reg_ch[0],
-.pm_cpu_reg_ch=&pm_cpu_reg_ch[0],
-.pm_gpio0_reg_ch=&pm_gpio0_reg_save_ch[0],
-.pm_gpio1_reg_ch=&pm_gpio1_reg_save_ch[0],
-.save_ch=&savereg_ch[0],
-};
-
-#if 0
-#define rk2818_define_value \
-unsigned int pm_scu_reg_save[PM_SCU_REG_NUM];\
-unsigned int pm_cpu_reg_save[PM_GENERAL_CPU_REG];\
-unsigned int pm_gpio0_reg_save[PM_SCU_GPIO_SWPORTC_NUM];\
-unsigned int pm_gpio1_reg_save[PM_SCU_GPIO_SWPORTC_NUM];\
-unsigned int save[4];\
-unsigned int pm_scu_reg_ch[PM_SCU_REG_NUM];\
-unsigned int pm_cpu_reg_ch[PM_GENERAL_CPU_REG];\
-struct rk2818_pm_st pm_save={&pm_scu_reg_save[0],&pm_cpu_reg_save[0],&pm_gpio0_reg_save[0],&pm_gpio1_reg_save[0],&save[0]\
-,&pm_scu_reg_ch[0],&pm_cpu_reg_ch[0]\
-};\
-struct regulator *buck1
-
-#endif
-static int __tcmfunc pm_set_gpio_pinstate(unsigned int gpio,unsigned int output,unsigned int level)
-{
- unsigned int *rk2818_gpio_reg;
- unsigned int regoff;
-
- if(gpio>=RK2818GPIO_TOTAL)
- return -1;
-
- if(gpio<32)
- rk2818_gpio_reg=(unsigned int *)RK2818_GPIO0_BASE;
- else
- {
- rk2818_gpio_reg=(unsigned int *)RK2818_GPIO1_BASE;
- gpio-=32;
- }
-
- regoff=PM_GPIO_SWPORTA_DR+(gpio/8)*3;
- gpio%=8;
-
- if(output)
- {
- rk2818_gpio_reg[regoff+1]|=(1<<gpio);//ddr set dir
- if(level==0)
- rk2818_gpio_reg[regoff]&=(~(1<<gpio));//ddr set value
- else
- rk2818_gpio_reg[regoff]|=(1<<gpio);
- }
- else
- rk2818_gpio_reg[regoff+1]&=(~(1<<gpio));//ddr set dir
- return 0;
-}
-static void __tcmfunc rk2818_pm_save_reg(unsigned int *save,unsigned int *source,int num)
-{
- int i;
- if(save&&source)
- for(i=0;i<num;i++)
- {
- save[i]=source[i];
- }
-
-}
-static void __tcmfunc rk2818_pm_suspend_first(void)
-{
- unsigned int *rk2818_scu_reg=(unsigned int *)RK2818_SCU_BASE;
- unsigned int *rk2818_cpu_reg=(unsigned int *)RK2818_REGFILE_BASE;
- unsigned int *rk2818_gpio0_reg=(unsigned int *)RK2818_GPIO0_BASE;
- unsigned int *rk2818_gpio1_reg=(unsigned int *)RK2818_GPIO1_BASE;
- //unsigned int *rk2818_ddr_reg=(unsigned int *)RK2818_SDRAMC_BASE;
-
- rk2818_pm_save_reg(pm_save.pm_scu_reg,rk2818_scu_reg,PM_SCU_REG_NUM);
- rk2818_pm_save_reg(pm_save.pm_cpu_reg,rk2818_cpu_reg,PM_GENERAL_CPU_REG);
- rk2818_pm_save_reg(pm_save.pm_gpio0_reg,rk2818_gpio0_reg,PM_SCU_GPIO_SWPORTC_NUM);
- rk2818_pm_save_reg(pm_save.pm_gpio1_reg,rk2818_gpio1_reg,PM_SCU_GPIO_SWPORTC_NUM);
- pm_save.scu_regbit=0;
- pm_save.cpu_regbit=0;
- pm_save.gpio0_regbit=0x6db;
- pm_save.gpio1_regbit=0x6db;
- //pm_save.savereg[0]=rk2818_ddr_reg[82];
- //rk2818_ddr_reg[82]=rk2818_ddr_reg[82]&(~(0xffff))&(~(0xf<<20));
- pm_set_gpio_pinstate(RK2818_PIN_PC2,1,0);
- tcm_printascii("suspend frist\n");
-}
-
-static void __tcmfunc rk2818_pm_resume_first(void)
-{
- //unsigned int *rk2818_ddr_reg=(unsigned int *)RK2818_SDRAMC_BASE;
- pm_set_gpio_pinstate(RK2818_PIN_PC2,1,1);
- //rk2818_ddr_reg[82]=pm_save.savereg[0];
-}
-static void __tcmfunc rk2818_soc_scu_suspend(void)
-{
-
- unsigned int *rk2818_scu_reg=(unsigned int *)RK2818_SCU_BASE;
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_CLKGATE0_CON);
- rk2818_scu_reg[PM_SCU_CLKGATE0_CON] = SCU_GATE0CLK_ALL_DIS&(~DIS_ARM_CLK)&(~DIS_TIMER_CLK)&(~DIS_GPIO0_CLK)&(~DIS_GPIO1_CLK)&(~DIS_INTC_CLK)&(~DIS_UART1_CLK);
- //&(~DIS_UART0_CLK)&(~DIS_UART1_CLK);
-
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_CLKGATE1_CON);
- rk2818_scu_reg[PM_SCU_CLKGATE1_CON] =SCU_GATE1CLK_BASE_SET|EN_AXI_CLK/*&(~DIS_DDR_CLK)&(~DIS_DDR_HCLK)*/;
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_CLKGATE2_CON);
- rk2818_scu_reg[PM_SCU_CLKGATE2_CON] =SCU_GATE2CLK_BASE_SET&(~DIS_ITCMBUS_CLK)
- &(~DIS_DTCM0BUS_CLK)&(~DIS_DTCM1BUS_CLK);
-
- //pm_save.scu_regbit|=(0x1<<PM_SCU_CLKSEL0_CON);
- //rk2818_scu_reg[PM_SCU_CLKSEL0_CON] |=(rk2818_scu_reg[PM_SCU_CLKSEL0_CON]&PM_BIT_CLEAR(CLKSEL0_HCLK,2)&PM_BIT_CLEAR(CLKSEL0_PCLK,2))
- // |CLKSEL0_HCLK21;
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_DPLL_CON);
- rk2818_scu_reg[PM_SCU_DPLL_CON] |= DSPPLL_POERDOWN; //dsp pll power down
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_CPLL_CON);
- rk2818_scu_reg[PM_SCU_CPLL_CON] |= CPLL_POERDOWN; //dsp pll power down
-
- tcm_udelay(1, 24);
- //tcm_printascii("dsp pll power down\n");
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_PMU_CON);
- rk2818_scu_reg[PM_SCU_PMU_CON] |=LCDC_POWER_DOWN;
- rk2818_scu_reg[PM_SCU_PMU_CON] |=DSP_POWER_DOWN;
-
- tcm_udelay(1, 24);
- //tcm_printascii("dsp power down\n");
-
- pm_save.scu_regbit|=(0x1<<PM_CLKSEL2_CON);
- rk2818_scu_reg[PM_CLKSEL2_CON] =(rk2818_scu_reg[PM_CLKSEL2_CON]&(~0xf))|0x7;
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_MODE_CON);
- rk2818_scu_reg[PM_SCU_MODE_CON] &= CPU_SLOW_MODE; //cpu slow mode
-
- pm_save.scu_regbit|=(0x1<<PM_SCU_APLL_CON);
- //rk2818_scu_reg[PM_SCU_APLL_CON] |= ARMPLL_BYPASSMODE;//enable arm pll bypass
- rk2818_scu_reg[PM_SCU_APLL_CON] |= ARMPLL_POERDOWN; //arm pll power down
-
- //tcm_printascii("arm pll power down\n");
-
- //rk2818_scu_reg[PM_SCU_PMU_CON] |=DDR_POWER_DOWN;
- //pm_save.scu_regbit|=(0x1<<PM_SCU_SOFTRST_CON);
- //rk2818_scu_reg[PM_SCU_SOFTRST_CON]|=RST_DDR_CORE_LOGIC;//RST_DDR_BUS/RST_DDR_CORE_LOGIC
-
- #ifdef RK2818_MOBLIE_PM_PRT_CHANGED_REG
- rk2818_pm_save_reg(pm_save.pm_scu_reg_ch,rk2818_scu_reg,PM_SCU_REG_NUM);
- #endif
-}
-
-/*static void __tcmfunc rk2818_soc_general_cpu_suspend(void)
-{
-
- unsigned int *rk2818_cpu_reg=(unsigned int *)RK2818_REGFILE_BASE;
- //unsigned int *rk2818_gpio0_reg=(unsigned int *)RK2818_GPIO0_BASE;
- //unsigned int *rk2818_gpio1_reg=(unsigned int *)RK2818_GPIO1_BASE;
-
- #if 0
- pm_save.cpu_regbit|=(0x1<<PM_GPIO0_AB_PU_CON);
- rk2818_cpu_reg[PM_GPIO0_AB_PU_CON] =GPIO0_AB_NORMAL|PMGPIO_DN(GPIO0_A3);
-
- pm_save.cpu_regbit|=(0x1<<PM_GPIO0_CD_PU_CON);
- rk2818_cpu_reg[PM_GPIO0_CD_PU_CON] = GPIO0_CD_NORMAL;
-
- pm_save.cpu_regbit|=(0x1<<PM_GPIO1_AB_PU_CON);
- rk2818_cpu_reg[PM_GPIO1_AB_PU_CON] = GPIO1_AB_NORMAL;
-
- pm_save.cpu_regbit|=(0x1<<PM_GPIO1_CD_PU_CON);
- rk2818_cpu_reg[PM_GPIO1_CD_PU_CON] = GPIO1_CD_NORMAL;
- #endif
-
- pm_save.cpu_regbit|=(0x1<<PM_IOMUX_A_CON);
- pm_save.cpu_regbit|=(0x1<<PM_IOMUX_B_CON);
-
- #if 1 //set uart0 pin
- rk2818_cpu_reg[PM_IOMUX_A_CON] &=(~(0x3<<PM_UART0_OUT))&(~(0x3<<PM_UART0_IN));// 00 gpio 01uart
- rk2818_cpu_reg[PM_IOMUX_B_CON] &=(~(0x1<<PM_UART0_RTS))&(~(0x1<<PM_UART0_CTS));//
- pm_set_gpio_pinstate(RK2818_PIN_PG0,0,0);//uart0 sin pin
- pm_set_gpio_pinstate(RK2818_PIN_PG1,0,0);//uart0 sout pin
- pm_set_gpio_pinstate(RK2818_PIN_PG0,0,0);//uart0 sin pin
- pm_set_gpio_pinstate(RK2818_PIN_PG1,0,0);//uart0 sout pin
- pm_set_gpio_pinstate(RK2818_PIN_PB2,0,0);//uart0 cts pin
- pm_set_gpio_pinstate(RK2818_PIN_PB3,0,0);//uart0 rts pin
- pm_set_gpio_pinstate(RK2818_PIN_PF7,0,0);//uart0 dtr pin
- //pm_set_gpio_pinstate(RK2818_PIN_PE0,0,0);//uart0 dsr pin
- #endif
-
- #if 0 //set uart1 pin
- rk2818_cpu_reg[PM_IOMUX_A_CON] &=(~(0x3<<PM_UART1_OUT))&(~(0x3<<PM_UART1_IN));// 00 gpio 01uart
- pm_set_gpio_pinstate(RK2818_PIN_PF0,0,0);//uart0 sin pin
- pm_set_gpio_pinstate(RK2818_PIN_PG1,0,0);//uart0 sout pin
- #endif
-
- #if 0 //set i2c0 pin
- rk2818_cpu_reg[PM_IOMUX_A_CON] |=(0x1<<PM_I2C0);// 1 gpio;0 i2c
- pm_set_gpio_pinstate(RK2818_PIN_PE4,0,0);//sda pin
- pm_set_gpio_pinstate(RK2818_PIN_PE5,0,0);//scl dsr pin
- #endif
-
- #if 0 //set i2c1 pin
- rk2818_cpu_reg[PM_IOMUX_A_CON] &=(~(0x3<<PM_I2C1));// 1 gpio;0 i2c
- pm_set_gpio_pinstate(RK2818_PIN_PE6,0,0);//sda pin
- pm_set_gpio_pinstate(RK2818_PIN_PE7,0,0);//scl dsr pin
- #endif
-
- #if 1 // sdio0
- rk2818_cpu_reg[PM_IOMUX_A_CON] &=(~(0x1<<PM_SDIO0_CMD))&(~(0x1<<PM_SDIO0_DATA));// 1 gpio;0 i2c
- pm_set_gpio_pinstate(RK2818_PIN_PH0,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PH1,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PH2,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PH3,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PH4,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PH5,0,0);
- //pm_set_gpio_pinstate(RK2818_PIN_PF3,0,0);
- #endif
-
- #if 0 // sdio1
- rk2818_cpu_reg[PM_IOMUX_A_CON] &=(~(0x1<<PM_SDIO1_CMD))&(~(0x1<<PM_SDIO1_DATA));// 1 gpio;0 i2c
- pm_set_gpio_pinstate(RK2818_PIN_PG2,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PG3,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PG4,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PG5,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PG6,0,0);
- pm_set_gpio_pinstate(RK2818_PIN_PG7,0,0);
- #endif
-
-#ifdef RK2818_MOBLIE_PM_PRT_CHANGED_REG
- rk2818_pm_save_reg(pm_save.pm_cpu_reg_ch,rk2818_cpu_reg,PM_GENERAL_CPU_REG);
- rk2818_pm_save_reg(pm_save.pm_gpio0_reg_ch,rk2818_gpio0_reg,PM_SCU_GPIO_SWPORTC_NUM);
- rk2818_pm_save_reg(pm_save.pm_gpio1_reg_ch,rk2818_gpio1_reg,PM_SCU_GPIO_SWPORTC_NUM);
-#endif
-
-}*/
-
-static void __tcmfunc rk2818_soc_resume(unsigned int *pm_save_reg,unsigned int *base_add,u16 regbit,int num)
-{
- int i;
- tcm_printascii("rk2818_soc_resume\n");
- for(i=0;i<num;i++)
- {
- if((regbit>>i)&0x0001)
- base_add[i]=pm_save_reg[i];
- }
-}
-static void __tcmfunc rk2818_pm_soc_suspend(void)
-{
- rk2818_soc_scu_suspend( );
- //rk2818_soc_general_cpu_suspend( );
-}
-static void __tcmfunc rk2818_pm_soc_resume(void)
-{
- rk2818_soc_resume(pm_save.pm_scu_reg,(unsigned int *)RK2818_SCU_BASE,pm_save.scu_regbit,PM_SCU_REG_NUM);
- //rk2818_soc_resume(pm_save.pm_cpu_reg,(unsigned int *)RK2818_REGFILE_BASE,pm_save.cpu_regbit,PM_GENERAL_CPU_REG);
-}
-
-/*void rk2818_pm_print(void)
-{
- //rk2818_pm_reg_print(pm_save.pm_scu_reg,pm_save.pm_scu_reg_ch,PM_SCU_REG_NUM,"scu");
- //rk2818_pm_reg_print(pm_save.pm_cpu_reg,pm_save.pm_cpu_reg,PM_GENERAL_CPU_REG,"general_cpu");
- //rk2818_pm_reg_print(pm_save.pm_gpio0_reg,pm_save.pm_gpio0_reg,PM_SCU_GPIO_SWPORTC_NUM,"gpio0");
-}
-
-static void rk2818_pm_reg_print(unsigned int *pm_save_reg,unsigned int *pm_ch_reg,int num,char *name)
-{
- int i;
-
-#ifdef RK2818_MOBLIE_PM_PRT_ORIGINAL_REG
- printk("***the follow inf is %s original reg***\n",name);
- for(i=0;i<num;i++)
- {
- printk(" %d,%x",i,pm_save_reg[i]);
- }
- printk("\n");
-#endif
-
-#ifdef RK2818_MOBLIE_PM_PRT_CHANGED_REG
- printk("***the follow inf is %s changed reg***\n",name);
- for(i=0;i<num;i++)
- {
- printk(" %d,%x",i,pm_ch_reg[i]);
- }
- printk("\n");
-#endif
-}*/
-
-#else
-#define rk2818_pm_suspend_first(a)
-#define rk2818_pm_resume_first(b)
-#define rk2818_pm_soc_suspend(a)
-#define rk2818_pm_soc_resume(a)
-#define rk2818_define_value
-
-#endif
-
-static void pmu_suspend(void)
-{
- //struct regulator *ldo1,*ldo2,*ldo4,*ldo5;
- struct regulator *lilo1,*lilo2;
-
- /*ldo1 = regulator_get(NULL, "ldo1");
- regulator_disable(ldo1);
- ldo2 = regulator_get(NULL, "ldo2");
- regulator_disable(ldo2);
- ldo4 = regulator_get(NULL, "ldo4");
- regulator_disable(ldo4);
- ldo5 = regulator_get(NULL, "ldo5");
- regulator_disable(ldo5);
- lilo2 = regulator_get(NULL, "lilo2");
- regulator_disable(lilo2);*/
-
- lilo1 = regulator_get(NULL, "lilo1");
- regulator_set_voltage(lilo1,2800000,2800000);
- lilo2 = regulator_get(NULL, "lilo2");
- regulator_set_voltage(lilo2,2800000,2800000);
-}
-
-static void pmu_resume(void)
-{
- //struct regulator *ldo1,*ldo2,*ldo4,*ldo5;
- struct regulator *lilo1,*lilo2;
- //int tmp = 0;
-
- /*ldo1 = regulator_get(NULL, "ldo1");
- regulator_enable(ldo1);
- tmp = regulator_get_voltage(ldo1);
-
- ldo2 = regulator_get(NULL, "ldo2");
- regulator_enable(ldo2);
- tmp = regulator_get_voltage(ldo2);
-
- ldo4 = regulator_get(NULL, "ldo4");
- regulator_enable(ldo4);
- tmp = regulator_get_voltage(ldo4);
-
- ldo5 = regulator_get(NULL, "ldo5");
- regulator_enable(ldo5);
- tmp = regulator_get_voltage(ldo5);
-
- lilo2 = regulator_get(NULL, "lilo2");
- regulator_enable(lilo2);
- tmp = regulator_get_voltage(lilo2);*/
-
- lilo1 = regulator_get(NULL, "lilo1");
- regulator_set_voltage(lilo1,3000000,3000000);
- lilo2 = regulator_get(NULL, "lilo2");
- regulator_set_voltage(lilo2,3000000,3000000);
-}
-
static int __tcmfunc rk2818_tcm_idle(void)
{
- //rk2818_define_value;
volatile u32 unit;
u32 ctrl_reg_62;
asm("b 1f; .align 5; 1:");
asm("mcr p15, 0, r0, c7, c10, 4"); /* drain write buffer */
-
scu_writel(scu_mode & ~(3 << 2), SCU_MODE_CON); // slow
scu_writel(scu_apll | PLL_PD, SCU_APLL_CON); // powerdown
-
- //tcm_printascii("3x pm ddr refresh\n");
//rk28_ddr_enter_self_refresh();
tcm_udelay(5, 24); //DRVDelayUs(100);
ctrl_reg_62=sdram_enter_self_refresh();
asm("mcr p15, 0, r0, c7, c0, 4"); /* wait for interrupt */
tcm_udelay(1, 24); //DRVDelayUs(100);
- rk2818_socpm_resume_first();
rk2818_socpm_resume();
+ rk2818_socpm_resume_last();
tcm_udelay(1, 24); //DRVDelayUs(100);
sdram_exit_self_refresh(ctrl_reg_62);
- //rk28_ddr_exit_self_refresh();
- //tcm_printascii("3x pm re\n");
+
tcm_udelay(10, 24);
scu_writel(scu_apll, SCU_APLL_CON); // powerup
scu_writel(scu_clksel0 & (~3), SCU_CLKSEL0_CON);
tcm_udelay(20, 24);
- //tcm_printascii("3x pm re1\n");
unit = 7200; /* 24m,0.3ms , 24*300*/
while (unit-- > 0) {
if (regfile_readl(CPU_APB_REG0) & 0x80)
break;
}
- ///tcm_printascii("3x pm re2\n");
tcm_udelay(5 << 8, 24);
scu_writel(scu_clksel0, SCU_CLKSEL0_CON);
tcm_udelay(5, 24);
- //tcm_printascii("3x pm re3\n");
scu_writel(scu_mode, SCU_MODE_CON); // normal
-
- //tcm_printascii("3x pm re4\n");
-
return unit;
}
asm volatile ("mov sp, %0" :: "r" (tcm_sp));
rk2818_tcm_idle();
asm volatile ("mov sp, %0" :: "r" (old_sp));
-
- //printk("rk2818_idle\n");
-
}
#if 1
struct clk *arm_clk = clk_get(NULL, "arm");
unsigned long arm_rate = clk_get_rate(arm_clk);
- printk(KERN_DEBUG "before core halt\n");
-
- #if defined(CONFIG_MACH_RAHO)||defined(CONFIG_MACH_RAHOSDK)
- pmu_suspend( );
- #endif
clk_set_rate(arm_clk, 24000000);
dump_register();
rockchip_timer_clocksource_suspend_resume(0);
#endif
- #if defined(CONFIG_MACH_RAHO)||defined(CONFIG_MACH_RAHOSDK)
- pmu_resume( );
- #endif
dump_register();
clk_set_rate(arm_clk, arm_rate);
//rk2818_socpm_print();
static unsigned int __tcmdata pm_gpio0_reg_save[PM_SCU_GPIO_SWPORTC_NUM];
-
-
static struct rk2818_pm_soc_st __tcmdata pm_gpio0_ctr={
.reg_save=&pm_gpio0_reg_save[0],
.reg_base_addr=(unsigned int *)RK2818_GPIO0_BASE,
.gpio1=(struct rk2818_pm_soc_st *)&pm_gpio1_ctr.reg_save,
.save_reg=&pm_savereg[0],
.save_ch=&savereg_ch[0],
-.scu_suspend=NULL,
-.general_reg_suspend=NULL,
-.set_suspendvol=NULL,
-.resume_vol=NULL,
};
+static struct rk2818_pm_callback_st __tcmdata *pm_ctr_callback=NULL;
+
int __tcmfunc rk2818_socpm_set_gpio(unsigned int gpio,unsigned int output,unsigned int level)
{
unsigned int *rk2818_gpio_reg;
static void __tcmfunc rk2818_soc_updata_scureg(unsigned int *tempdata,int regoff,int flag)
{
- if(rk2818_soc_pm.scu_suspend&&flag)
+ if(pm_ctr_callback->scu_suspend&&flag)
{
- rk2818_soc_pm.scu_suspend(tempdata,regoff);
+ pm_ctr_callback->scu_suspend(tempdata,regoff);
}
rk2818_soc_pm.scu->reg_base_addr[regoff]=*tempdata;
rk2818_soc_pm.scu->reg_ctrbit|=(0x1<<regoff);
rk2818_soc_updata_scureg(tempdata,PM_SCU_CLKGATE1_CON,1);
tcm_udelay(1, 24);
-
*tempdata=SCU_GATE2CLK_BASE_SET&(~DIS_ITCMBUS_CLK)&(~DIS_DTCM0BUS_CLK)&(~DIS_DTCM1BUS_CLK);
rk2818_soc_updata_scureg(tempdata,PM_SCU_CLKGATE2_CON,1);
tcm_udelay(1, 24);
*tempdata=rk2818_scu_reg[PM_SCU_CPLL_CON] |CPLL_POERDOWN; //dsp pll power down
rk2818_soc_updata_scureg(tempdata,PM_SCU_CPLL_CON,1);
tcm_udelay(1, 24);
-
-
+
rk2818_scu_reg[PM_SCU_PMU_CON] |=LCDC_POWER_DOWN;
*tempdata=rk2818_scu_reg[PM_SCU_PMU_CON] |DSP_POWER_DOWN;
rk2818_soc_updata_scureg(tempdata,PM_SCU_PMU_CON,1);
-
-
*tempdata=rk2818_scu_reg[PM_SCU_MODE_CON] &CPU_SLOW_MODE; //general slow mode
rk2818_soc_updata_scureg(tempdata,PM_SCU_MODE_CON,1);
rk2818_soc_updata_scureg(tempdata,PM_SCU_CLKSEL0_CON,1);
tcm_udelay(2, 24);
-
*tempdata=(rk2818_scu_reg[PM_CLKSEL2_CON]&(~0xf))|0xF;
rk2818_soc_updata_scureg(tempdata,PM_CLKSEL2_CON,1);
//*tempdata=rk2818_scu_reg[PM_SCU_PMU_CON] |DDR_POWER_DOWN;
//rk2818_soc_updata_scureg(tempdata,PM_SCU_PMU_CON,0);
-
//*tempdata=rk2818_scu_reg[PM_SCU_SOFTRST_CON]|(1<<RST_DDR_BUS)|(1<<RST_DDR_CORE_LOGIC);//RST_ALL&(~(1<<RST_ARM));
//rk2818_soc_updata_scureg(tempdata,PM_SCU_SOFTRST_CON,1);
}
rk2818_soc_scu_suspend();
tcm_udelay(1, 24); //DRVDelayUs(100);
- if(rk2818_soc_pm.general_reg_suspend)
+ if(pm_ctr_callback&&pm_ctr_callback->general_reg_suspend)
{
- rk2818_soc_pm.general_reg_suspend();
+ pm_ctr_callback->general_reg_suspend();
}
#ifdef RK2818_PM_PRT_CHANGED_REG
rk2818_soc_resume(rk2818_soc_pm.scu->reg_save,rk2818_soc_pm.scu->reg_base_addr,
rk2818_soc_pm.scu->reg_ctrbit,rk2818_soc_pm.scu->reg_num);
tcm_udelay(2, 24);
- if(rk2818_soc_pm.general_reg_suspend)
+ if(pm_ctr_callback->general_reg_suspend)
{
rk2818_soc_resume(rk2818_soc_pm.general->reg_save,rk2818_soc_pm.general->reg_base_addr,
rk2818_soc_pm.general->reg_ctrbit=0;
rk2818_soc_pm.gpio0->reg_ctrbit=0x6db;
rk2818_soc_pm.gpio1->reg_ctrbit=0x6db;
- rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,0);
+
//rk2818_soc_pm.save_reg[0]=rk2818_ddr_reg[82];
//rk2818_ddr_reg[82]=rk2818_ddr_reg[82]&(~(0xffff))&(~(0xf<<20));
- if(rk2818_soc_pm.set_suspendvol)
- rk2818_soc_pm.set_suspendvol();
+ if(pm_ctr_callback&&pm_ctr_callback->set_pin)
+ pm_ctr_callback->set_pin();
}
-void __tcmfunc rk2818_socpm_resume_first(void)
+void __tcmfunc rk2818_socpm_resume_last(void)
{
//unsigned int *rk2818_ddr_reg=(unsigned int *)RK2818_SDRAMC_BASE;
- rk2818_socpm_set_gpio(RK2818_PIN_PC2,1,1);
- if(rk2818_soc_pm.resume_vol)
- rk2818_soc_pm.resume_vol();
-}
+ if(pm_ctr_callback&&pm_ctr_callback->resume_pin)
+ pm_ctr_callback->resume_pin();
+}
void rk2818_socpm_print(void)
{
}
-
-void rk2818_socpm_int(pm_scu_suspend scu,pm_general_reg_suspend general,
- pm_set_suspendvol setvol,pm_resume_vol resumevol)
+int rk2818_socpm_init(struct rk2818_pm_callback_st *call_back)
{
- rk2818_soc_pm.scu_suspend=scu;
- rk2818_soc_pm.general_reg_suspend=general;
- rk2818_soc_pm.set_suspendvol=setvol;
- rk2818_soc_pm.resume_vol=resumevol;
+ if(call_back==NULL)
+ return -1;
+ pm_ctr_callback = call_back;
+ return 0;
}
-
-
-
-
#if defined (CONFIG_RK2818_SOC_PM_DBG)
static bool check_attr_dbg_value(struct rk2818_pm_attr_dbg_st *attr)