diff options
author | Ranjani Vaidyanathan <ra5478@freescale.com> | 2011-07-29 14:30:19 -0500 |
---|---|---|
committer | Jason Liu <r64343@freescale.com> | 2012-01-09 20:23:28 +0800 |
commit | 99f545ad55771449c251129a73407948ca0e34d6 (patch) | |
tree | a925562f7cac59d92cc28da64d75a69109b1ec2b /arch/arm/mach-mx5 | |
parent | 4e1520dc1cf236afecc423cdbc8c683521c17fc1 (diff) |
ENGR00139280: MX6: Add CPUFREQ support
Add support for CPUFREQ for SMP system.
Added support for 1GHz, 800MHz, 400MHz and 160MHz.
Added support for scaling the voltage along with frequency.
Signed-off-by: Ranjani Vaidyanathan <ra5478@freescale.com>
Diffstat (limited to 'arch/arm/mach-mx5')
-rwxr-xr-x | arch/arm/mach-mx5/board-mx50_rdp.c | 23 | ||||
-rwxr-xr-x | arch/arm/mach-mx5/board-mx51_babbage.c | 24 | ||||
-rwxr-xr-x | arch/arm/mach-mx5/board-mx53_ard.c | 23 | ||||
-rwxr-xr-x | arch/arm/mach-mx5/board-mx53_evk.c | 23 | ||||
-rwxr-xr-x | arch/arm/mach-mx5/board-mx53_loco.c | 24 | ||||
-rwxr-xr-x | arch/arm/mach-mx5/board-mx53_smd.c | 23 | ||||
-rwxr-xr-x | arch/arm/mach-mx5/cpu.c | 18 |
7 files changed, 78 insertions, 80 deletions
diff --git a/arch/arm/mach-mx5/board-mx50_rdp.c b/arch/arm/mach-mx5/board-mx50_rdp.c index e533370fa0fd..26b04ab8b1f3 100755 --- a/arch/arm/mach-mx5/board-mx50_rdp.c +++ b/arch/arm/mach-mx5/board-mx50_rdp.c @@ -93,14 +93,14 @@ #define MX50_RDP_SD3_WP IMX_GPIO_NR(5, 28) /*GPIO_5_28 */ #define MX50_RDP_USB_OTG_PWR IMX_GPIO_NR(6, 25) /*GPIO_6_25*/ -extern struct regulator *(*get_cpu_regulator)(void); -extern void (*put_cpu_regulator)(void); +extern int (*set_cpu_voltage)(u32 volt); +extern int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt); extern int mx50_rdp_init_mc13892(void); -extern char *gp_reg_id; extern char *lp_reg_id; +static char *gp_reg_id; static struct regulator *cpu_regulator; static int max17135_regulator_init(struct max17135 *max17135); @@ -755,18 +755,16 @@ static struct mxc_regulator_platform_data rdp_regulator_data = { .vcc_reg_id = "lp_vcc", }; -static struct regulator *mx50_rdp_get_cpu_regulator(void) +static int mx50_rdp_set_cpu_voltage(u32 cpu_volt) { + int ret = -EINVAL; + if (cpu_regulator == NULL) cpu_regulator = regulator_get(NULL, gp_reg_id); - return cpu_regulator; -} + if (!IS_ERR(cpu_regulator)) + ret = mx5_set_cpu_voltage(cpu_regulator, cpu_volt); -static void mx50_rdp_put_cpu_regulator(void) -{ - if (cpu_regulator != NULL) - regulator_put(cpu_regulator); - cpu_regulator = NULL; + return ret; } static const struct esdhc_platform_data mx50_rdp_sd1_data __initconst = { @@ -787,8 +785,7 @@ static const struct esdhc_platform_data mx50_rdp_sd3_data __initconst = { static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { - get_cpu_regulator = mx50_rdp_get_cpu_regulator; - put_cpu_regulator = mx50_rdp_put_cpu_regulator; + set_cpu_voltage = mx50_rdp_set_cpu_voltage; } static void mx50_rdp_usbotg_vbus(bool on) diff --git a/arch/arm/mach-mx5/board-mx51_babbage.c b/arch/arm/mach-mx5/board-mx51_babbage.c index 0db1fdacf236..8a7d8af56073 100755 --- a/arch/arm/mach-mx5/board-mx51_babbage.c +++ b/arch/arm/mach-mx5/board-mx51_babbage.c @@ -83,12 +83,12 @@ #define MX51_USB_PLL_DIV_19_2_MHZ 0x01 #define MX51_USB_PLL_DIV_24_MHZ 0x02 -extern char *gp_reg_id; extern char *lp_reg_id; -extern struct regulator *(*get_cpu_regulator)(void); -extern void (*put_cpu_regulator)(void); +extern int (*set_cpu_voltage)(u32 volt); +extern int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt); static struct regulator *cpu_regulator; +static char *gp_reg_id; static struct gpio_keys_button babbage_buttons[] = { { @@ -562,18 +562,17 @@ static struct i2c_board_info mxc_i2c_hs_board_info[] __initdata = { static struct mxc_gpu_platform_data gpu_data __initdata; -static struct regulator *mx51_bbg_get_cpu_regulator(void) +static int mx51_bbg_set_cpu_voltage(u32 cpu_volt) { + int ret = -EINVAL; + if (cpu_regulator == NULL) cpu_regulator = regulator_get(NULL, gp_reg_id); - return cpu_regulator; -} + if (!IS_ERR(cpu_regulator)) + ret = mx5_set_cpu_voltage(cpu_regulator, cpu_volt); + + return ret; -static void mx51_bbg_put_cpu_regulator(void) -{ - if (cpu_regulator != NULL) - regulator_put(cpu_regulator); - cpu_regulator = NULL; } static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, @@ -587,8 +586,7 @@ static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, int fb_mem = 0; char *str; - get_cpu_regulator = mx51_bbg_get_cpu_regulator; - put_cpu_regulator = mx51_bbg_put_cpu_regulator; + set_cpu_voltage = mx51_bbg_set_cpu_voltage; for_each_tag(mem_tag, tags) { if (mem_tag->hdr.tag == ATAG_MEM) { diff --git a/arch/arm/mach-mx5/board-mx53_ard.c b/arch/arm/mach-mx5/board-mx53_ard.c index dd6b16d071cf..8f0cb9c7d4dd 100755 --- a/arch/arm/mach-mx5/board-mx53_ard.c +++ b/arch/arm/mach-mx5/board-mx53_ard.c @@ -62,11 +62,11 @@ #define ARD_GPS_RST_B (MAX7310_BASE_ADDR + 7) static struct regulator *cpu_regulator; +static char *gp_reg_id; -extern char *gp_reg_id; extern char *lp_reg_id; -extern struct regulator *(*get_cpu_regulator)(void); -extern void (*put_cpu_regulator)(void); +extern void (*set_cpu_voltage)(u32 volt); +extern int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt); static iomux_v3_cfg_t mx53_ard_pads[] = { /* UART */ @@ -351,25 +351,22 @@ static struct mxc_regulator_platform_data ard_regulator_data = { .cpu_reg_id = "SW1", }; -static struct regulator *mx53_ard_get_cpu_regulator(void) +static int mx53_ard_set_cpu_voltage(u32 cpu_volt) { + int ret = -EINVAL; + if (cpu_regulator == NULL) cpu_regulator = regulator_get(NULL, gp_reg_id); - return cpu_regulator; -} + if (!IS_ERR(cpu_regulator)) + ret = mx5_set_cpu_voltage(cpu_regulator, cpu_volt); -static void mx53_ard_put_cpu_regulator(void) -{ - if (cpu_regulator != NULL) - regulator_put(cpu_regulator); - cpu_regulator = NULL; + return ret; } static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { - get_cpu_regulator = mx53_ard_get_cpu_regulator; - put_cpu_regulator = mx53_ard_put_cpu_regulator; + set_cpu_voltage = mx53_ard_set_cpu_voltage; } static inline void mx53_ard_init_uart(void) diff --git a/arch/arm/mach-mx5/board-mx53_evk.c b/arch/arm/mach-mx5/board-mx53_evk.c index 8a8d305e7612..81aa39755f90 100755 --- a/arch/arm/mach-mx5/board-mx53_evk.c +++ b/arch/arm/mach-mx5/board-mx53_evk.c @@ -79,12 +79,12 @@ #define ARM2_OTG_VBUS IMX_GPIO_NR(3, 22) /* GPIO_3_22 */ #define ARM2_LCD_CONTRAST IMX_GPIO_NR(4, 20) /* GPIO_4_20 */ -extern char *gp_reg_id; extern char *lp_reg_id; -extern struct regulator *(*get_cpu_regulator)(void); -extern void (*put_cpu_regulator)(void); +extern int (*set_cpu_voltage)(u32 volt); +extern int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt); static struct regulator *cpu_regulator; +static char *gp_reg_id; static iomux_v3_cfg_t mx53common_pads[] = { MX53_PAD_EIM_WAIT__GPIO5_0, @@ -725,25 +725,22 @@ static struct mxc_regulator_platform_data evk_regulator_data = { .vcc_reg_id = "SW2", }; -static struct regulator *mx53_evk_get_cpu_regulator(void) +static int mx53_evk_set_cpu_voltage(u32 cpu_volt) { + int ret = -EINVAL; + if (cpu_regulator == NULL) cpu_regulator = regulator_get(NULL, gp_reg_id); - return cpu_regulator; -} + if (!IS_ERR(cpu_regulator)) + ret = mx5_set_cpu_voltage(cpu_regulator, cpu_volt); -static void mx53_evk_put_cpu_regulator(void) -{ - if (cpu_regulator != NULL) - regulator_put(cpu_regulator); - cpu_regulator = NULL; + return ret; } static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { - get_cpu_regulator = mx53_evk_get_cpu_regulator; - put_cpu_regulator = mx53_evk_put_cpu_regulator; + set_cpu_voltage = mx53_evk_set_cpu_voltage; } static void __init mx53_evk_board_init(void) diff --git a/arch/arm/mach-mx5/board-mx53_loco.c b/arch/arm/mach-mx5/board-mx53_loco.c index 01b7b6170986..b9a8a8ebf0dc 100755 --- a/arch/arm/mach-mx5/board-mx53_loco.c +++ b/arch/arm/mach-mx5/board-mx53_loco.c @@ -67,14 +67,14 @@ extern void __iomem *arm_plat_base; extern void __iomem *gpc_base; extern void __iomem *ccm_base; extern void __iomem *imx_otg_base; -extern char *gp_reg_id; extern char *lp_reg_id; -extern struct regulator *(*get_cpu_regulator)(void); -extern void (*put_cpu_regulator)(void); +extern int (*set_cpu_voltage)(u32 volt); +extern int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt); extern int __init mx53_loco_init_da9052(void); static struct regulator *cpu_regulator; +static char *gp_reg_id; static iomux_v3_cfg_t mx53_loco_pads[] = { /* FEC */ @@ -593,18 +593,15 @@ static struct mxc_regulator_platform_data loco_regulator_data = { .cpu_reg_id = "cpu_vddgp", }; -static struct regulator *mx53_loco_get_cpu_regulator(void) +static int mx53_loco_set_cpu_voltage(u32 cpu_volt) { + int ret = -EINVAL; + if (cpu_regulator == NULL) cpu_regulator = regulator_get(NULL, gp_reg_id); - return cpu_regulator; -} - -static void mx53_loco_put_cpu_regulator(void) -{ - if (cpu_regulator != NULL) - regulator_put(cpu_regulator); - cpu_regulator = NULL; + if (!IS_ERR(cpu_regulator)) + ret = mx5_set_cpu_voltage(cpu_regulator, cpu_volt); + return ret; } static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, @@ -618,8 +615,7 @@ static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, int fb_mem = SZ_32M; char *str; - get_cpu_regulator = mx53_loco_get_cpu_regulator; - put_cpu_regulator = mx53_loco_put_cpu_regulator; + set_cpu_voltage = mx53_loco_set_cpu_voltage; for_each_tag(mem_tag, tags) { if (mem_tag->hdr.tag == ATAG_MEM) { diff --git a/arch/arm/mach-mx5/board-mx53_smd.c b/arch/arm/mach-mx5/board-mx53_smd.c index c18d8408a8c8..79d0c76b7b62 100755 --- a/arch/arm/mach-mx5/board-mx53_smd.c +++ b/arch/arm/mach-mx5/board-mx53_smd.c @@ -83,14 +83,14 @@ static struct clk *sata_clk, *sata_ref_clk; -extern char *gp_reg_id; extern char *lp_reg_id; -extern struct regulator *(*get_cpu_regulator)(void); -extern void (*put_cpu_regulator)(void); +extern int (*set_cpu_voltage)(u32 volt); +extern int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt); extern int mx53_smd_init_da9052(void); static struct regulator *cpu_regulator; +static char *gp_reg_id; static iomux_v3_cfg_t mx53_smd_pads[] = { MX53_PAD_CSI0_DAT10__UART1_TXD_MUX, @@ -742,25 +742,22 @@ static struct mxc_regulator_platform_data smd_regulator_data = { .cpu_reg_id = "DA9052_BUCK_CORE", }; -static struct regulator *mx53_smd_get_cpu_regulator(void) +static int mx53_smd_set_cpu_voltage(u32 cpu_volt) { + int ret = -EINVAL; + if (cpu_regulator == NULL) cpu_regulator = regulator_get(NULL, gp_reg_id); - return cpu_regulator; -} + if (!IS_ERR(cpu_regulator)) + ret = mx5_set_cpu_voltage(cpu_regulator, cpu_volt); -static void mx53_smd_put_cpu_regulator(void) -{ - if (cpu_regulator != NULL) - regulator_put(cpu_regulator); - cpu_regulator = NULL; + return ret; } static void __init fixup_mxc_board(struct machine_desc *desc, struct tag *tags, char **cmdline, struct meminfo *mi) { - get_cpu_regulator = mx53_smd_get_cpu_regulator; - put_cpu_regulator = mx53_smd_put_cpu_regulator; + set_cpu_voltage = mx53_smd_set_cpu_voltage; } static void __init mx53_smd_board_init(void) diff --git a/arch/arm/mach-mx5/cpu.c b/arch/arm/mach-mx5/cpu.c index eab15144df45..4d36655d44f9 100755 --- a/arch/arm/mach-mx5/cpu.c +++ b/arch/arm/mach-mx5/cpu.c @@ -17,6 +17,9 @@ #include <linux/clk.h> #include <linux/module.h> #include <linux/iram_alloc.h> +#include <linux/regulator/consumer.h> +#include <linux/err.h> + #include <mach/hardware.h> #include <asm/io.h> @@ -33,10 +36,11 @@ void __iomem *arm_plat_base; void __iomem *gpc_base; void __iomem *ccm_base; +struct cpu_op *(*get_cpu_op)(int *op); + extern void init_ddr_settings(void); static int cpu_silicon_rev = -1; -void (*set_num_cpu_op)(int num); #define IIM_SREV 0x24 #define MX50_HW_ADADIG_DIGPROG 0xB0 @@ -168,6 +172,18 @@ static int get_mx50_srev(void) return 0; } +int mx5_set_cpu_voltage(struct regulator *gp_reg, u32 cpu_volt) +{ + u32 ret = 0; + + if (!IS_ERR(gp_reg)) { + ret = regulator_set_voltage(gp_reg, cpu_volt, cpu_volt); + if (ret < 0) + printk(KERN_DEBUG "COULD NOT SET GP VOLTAGE!!!!\n"); + } + return ret; +} + /* * Returns: * the silicon revision of the cpu |