From 85cc82635ac1f27693dcf71cdedff79791499681 Mon Sep 17 00:00:00 2001 From: "xsf@rock-chips.com" Date: Tue, 14 Jun 2011 15:22:04 +0800 Subject: [PATCH] A22 and phonesdk: make wm831x enter sleep in suspend, change vdd voltage to 1.0V --- arch/arm/mach-rk29/Makefile | 1 + arch/arm/mach-rk29/board-rk29-a22.c | 16 +++++++++++++++- arch/arm/mach-rk29/board-rk29-phonesdk.c | 16 +++++++++++++++- arch/arm/mach-rk29/pm.c | 8 +++++++- arch/arm/mach-rk29/spi_sram.c | 2 +- drivers/regulator/core.c | 16 ++++++++++++++++ include/linux/regulator/consumer.h | 9 +++++++++ 7 files changed, 64 insertions(+), 4 deletions(-) mode change 100644 => 100755 arch/arm/mach-rk29/pm.c mode change 100644 => 100755 arch/arm/mach-rk29/spi_sram.c mode change 100644 => 100755 drivers/regulator/core.c mode change 100644 => 100755 include/linux/regulator/consumer.h diff --git a/arch/arm/mach-rk29/Makefile b/arch/arm/mach-rk29/Makefile index 39a6a7e66e20..1471fb2353d2 100644 --- a/arch/arm/mach-rk29/Makefile +++ b/arch/arm/mach-rk29/Makefile @@ -1,6 +1,7 @@ obj-y += timer.o io.o devices.o iomux.o clock.o rk29-pl330.o dma.o gpio.o ddr.o sram.o memcpy_dma.o reset.o obj-y += tests.o memtester.o obj-y += early_printk.o +obj-y += pm-gpio.o ifndef CONFIG_DEBUG_LL obj-y += ../kernel/debug.o endif diff --git a/arch/arm/mach-rk29/board-rk29-a22.c b/arch/arm/mach-rk29/board-rk29-a22.c index c776c25961db..eac9ede0c0d8 100755 --- a/arch/arm/mach-rk29/board-rk29-a22.c +++ b/arch/arm/mach-rk29/board-rk29-a22.c @@ -625,6 +625,7 @@ int wm831x_post_init(struct wm831x *parm) dcdc = regulator_get(NULL, "dcdc3"); // 1th IO regulator_set_voltage(dcdc,3000000,3000000); + regulator_set_suspend_voltage(dcdc, 3000000); regulator_enable(dcdc); printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -632,6 +633,7 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo10"); // 1th modem IO regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); @@ -639,6 +641,7 @@ int wm831x_post_init(struct wm831x *parm) dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE regulator_set_voltage(dcdc,1300000,1300000); + regulator_set_suspend_voltage(dcdc,1000000); regulator_enable(dcdc); printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -646,6 +649,7 @@ int wm831x_post_init(struct wm831x *parm) dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr regulator_set_voltage(dcdc,1800000,1800000); + regulator_set_suspend_voltage(dcdc,1800000); regulator_enable(dcdc); printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -653,6 +657,7 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo1"); // 3th nand regulator_set_voltage(ldo,1800000,1800000); + regulator_set_suspend_voltage(ldo,1800000); regulator_enable(ldo); printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); @@ -660,6 +665,7 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo4"); // 4th usb regulator_set_voltage(ldo,2500000,2500000); + regulator_set_suspend_voltage(ldo,2500000); regulator_enable(ldo); printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); @@ -667,13 +673,15 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo7"); // 5th usb regulator_set_voltage(ldo,3300000,3300000); + regulator_set_suspend_voltage(ldo,3300000); regulator_enable(ldo); printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); udelay(100); dcdc = regulator_get(NULL, "dcdc4"); // backlight - regulator_set_voltage(dcdc,20000000,20000000); + regulator_set_voltage(dcdc,20000000,20000000); + regulator_set_suspend_voltage(dcdc, 20000000); regulator_enable(dcdc); printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -682,36 +690,42 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo2"); //lcd regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo3"); //sram regulator_set_voltage(ldo,1800000,1800000); + regulator_set_suspend_voltage(ldo,1800000); regulator_enable(ldo); printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo5"); //tf regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo6"); //camera regulator_set_voltage(ldo,1800000,1800000); + regulator_set_suspend_voltage(ldo,1800000); regulator_enable(ldo); printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo8"); //tp regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo9"); //cmmb regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); diff --git a/arch/arm/mach-rk29/board-rk29-phonesdk.c b/arch/arm/mach-rk29/board-rk29-phonesdk.c index 84604ed82fd9..b8a0d1e7f1d9 100755 --- a/arch/arm/mach-rk29/board-rk29-phonesdk.c +++ b/arch/arm/mach-rk29/board-rk29-phonesdk.c @@ -678,6 +678,7 @@ int wm831x_post_init(struct wm831x *parm) dcdc = regulator_get(NULL, "dcdc3"); // 1th IO regulator_set_voltage(dcdc,3000000,3000000); + regulator_set_suspend_voltage(dcdc, 3000000); regulator_enable(dcdc); printk("%s set dcdc3=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -685,6 +686,7 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo10"); // 1th modem IO regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo10=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); @@ -692,6 +694,7 @@ int wm831x_post_init(struct wm831x *parm) dcdc = regulator_get(NULL, "dcdc2"); // 2th CORE regulator_set_voltage(dcdc,1300000,1300000); + regulator_set_suspend_voltage(dcdc,1000000); regulator_enable(dcdc); printk("%s set dcdc2=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -699,6 +702,7 @@ int wm831x_post_init(struct wm831x *parm) dcdc = regulator_get(NULL, "dcdc1"); // 3th ddr regulator_set_voltage(dcdc,1800000,1800000); + regulator_set_suspend_voltage(ldo, 1800000); regulator_enable(dcdc); printk("%s set dcdc1=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -706,6 +710,7 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo1"); // 3th nand regulator_set_voltage(ldo,1800000,1800000); + regulator_set_suspend_voltage(ldo,1800000); regulator_enable(ldo); printk("%s set ldo1=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); @@ -713,6 +718,7 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo4"); // 4th usb regulator_set_voltage(ldo,2500000,2500000); + regulator_set_suspend_voltage(ldo,2500000); regulator_enable(ldo); printk("%s set ldo4=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); @@ -720,13 +726,15 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo7"); // 5th usb regulator_set_voltage(ldo,3300000,3300000); + regulator_set_suspend_voltage(ldo,3300000); regulator_enable(ldo); printk("%s set ldo7=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); udelay(100); dcdc = regulator_get(NULL, "dcdc4"); // backlight - regulator_set_voltage(dcdc,20000000,20000000); + regulator_set_voltage(dcdc,20000000,20000000); + regulator_set_suspend_voltage(dcdc, 20000000); regulator_enable(dcdc); printk("%s set dcdc4=%dmV end\n", __FUNCTION__, regulator_get_voltage(dcdc)); regulator_put(dcdc); @@ -735,36 +743,42 @@ int wm831x_post_init(struct wm831x *parm) ldo = regulator_get(NULL, "ldo2"); //lcd regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo2=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo3"); //sram regulator_set_voltage(ldo,1800000,1800000); + regulator_set_suspend_voltage(ldo,1800000); regulator_enable(ldo); printk("%s set ldo3=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo5"); //tf regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo5=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo6"); //camera regulator_set_voltage(ldo,1800000,1800000); + regulator_set_suspend_voltage(ldo,1800000); regulator_enable(ldo); printk("%s set ldo6=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo8"); //cmmb regulator_set_voltage(ldo,1200000,1200000); + regulator_set_suspend_voltage(ldo,1200000); regulator_enable(ldo); printk("%s set ldo8=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); ldo = regulator_get(NULL, "ldo9"); //cmmb regulator_set_voltage(ldo,3000000,3000000); + regulator_set_suspend_voltage(ldo,3000000); regulator_enable(ldo); printk("%s set ldo9=%dmV end\n", __FUNCTION__, regulator_get_voltage(ldo)); regulator_put(ldo); diff --git a/arch/arm/mach-rk29/pm.c b/arch/arm/mach-rk29/pm.c old mode 100644 new mode 100755 index db55f2f27a9f..e59a6f5f657f --- a/arch/arm/mach-rk29/pm.c +++ b/arch/arm/mach-rk29/pm.c @@ -225,6 +225,8 @@ void __sramfunc ddr_testmode(void) {} #endif +void __sramfunc pm_spi_gpio_suspend(void); +void __sramfunc pm_spi_gpio_resume(void); static void __sramfunc rk29_sram_suspend(void) { u32 clksel0; @@ -238,6 +240,9 @@ static void __sramfunc rk29_sram_suspend(void) printch('6'); vol=rk29_suspend_voltage_set(1000000); + pm_spi_gpio_suspend(); + + printch('7'); clksel0 = cru_readl(CRU_CLKSEL0_CON); /* set arm clk 24MHz/32 = 750KHz */ @@ -251,7 +256,8 @@ static void __sramfunc rk29_sram_suspend(void) /* resume arm clk */ cru_writel(clksel0, CRU_CLKSEL0_CON); printch('7'); - + + pm_spi_gpio_resume(); rk29_suspend_voltage_resume(vol); diff --git a/arch/arm/mach-rk29/spi_sram.c b/arch/arm/mach-rk29/spi_sram.c old mode 100644 new mode 100755 index 7052d3675569..6496aeecede4 --- a/arch/arm/mach-rk29/spi_sram.c +++ b/arch/arm/mach-rk29/spi_sram.c @@ -272,7 +272,7 @@ static unsigned short __sramfunc sram_spi_read(unsigned short add,unsigned short unsigned int __sramfunc rk29_suspend_voltage_set(unsigned int vol) { -#if 1 //test +#if 0 //test unsigned short addr_4003=0x4003,addr_405d=0x405d, addr_4059=0x4059,addr_405e=0x405e,addr_4063=0x4063; unsigned short data_4003,data_405d, diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c old mode 100644 new mode 100755 index 1836053c919d..365ef0292612 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1543,7 +1543,23 @@ out: return ret; } EXPORT_SYMBOL_GPL(regulator_set_voltage); +int regulator_set_suspend_voltage(struct regulator *regulator, int uV) +{ + struct regulator_dev *rdev = regulator->rdev; + int ret = 0; + + if (rdev->desc->ops->set_suspend_voltage && uV > 0) { + ret = rdev->desc->ops->set_suspend_voltage(rdev, uV); + if (ret < 0) { + printk(KERN_ERR "%s: failed to set voltage\n", + __func__); + return ret; + } + } + return ret; +} +EXPORT_SYMBOL_GPL(regulator_set_suspend_voltage); static int _regulator_get_voltage(struct regulator_dev *rdev) { /* sanity check */ diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h old mode 100644 new mode 100755 index 490c5b37b6d7..73286b2b29eb --- a/include/linux/regulator/consumer.h +++ b/include/linux/regulator/consumer.h @@ -149,6 +149,9 @@ int regulator_list_voltage(struct regulator *regulator, unsigned selector); int regulator_is_supported_voltage(struct regulator *regulator, int min_uV, int max_uV); int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV); + +int regulator_set_suspend_voltage(struct regulator *regulator, int uV); + int regulator_get_voltage(struct regulator *regulator); int regulator_set_current_limit(struct regulator *regulator, int min_uA, int max_uA); @@ -230,6 +233,12 @@ static inline int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) { return 0; +} +static int regulator_set_suspend_voltage(struct regulator *regulator, int uV) +{ + + + } static inline int regulator_get_voltage(struct regulator *regulator) -- 2.34.1