diff options
author | Michael Hennerich <michael.hennerich@analog.com> | 2008-05-06 23:41:26 -0400 |
---|---|---|
committer | Bryan Wu <cooloney@kernel.org> | 2008-05-06 23:41:26 -0400 |
commit | 14b03204c8060d036b04cbb18bbd6f6f311f4fed (patch) | |
tree | e4ac8f5e2a74fc63dd811aac9e349ac890670134 /arch/blackfin/mach-common | |
parent | 19d6d7d53c8ff809182a1f092d2c6918146414e9 (diff) |
[Blackfin] arch: Functional power management support: Add CPU and platform voltage scaling support
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
Diffstat (limited to 'arch/blackfin/mach-common')
-rw-r--r-- | arch/blackfin/mach-common/Makefile | 5 | ||||
-rw-r--r-- | arch/blackfin/mach-common/dpmc.c | 137 | ||||
-rw-r--r-- | arch/blackfin/mach-common/dpmc_modes.S (renamed from arch/blackfin/mach-common/dpmc.S) | 27 |
3 files changed, 142 insertions, 27 deletions
diff --git a/arch/blackfin/mach-common/Makefile b/arch/blackfin/mach-common/Makefile index 393081e9b680..422bfee34adc 100644 --- a/arch/blackfin/mach-common/Makefile +++ b/arch/blackfin/mach-common/Makefile | |||
@@ -6,5 +6,6 @@ obj-y := \ | |||
6 | cache.o cacheinit.o entry.o \ | 6 | cache.o cacheinit.o entry.o \ |
7 | interrupt.o lock.o irqpanic.o arch_checks.o ints-priority.o | 7 | interrupt.o lock.o irqpanic.o arch_checks.o ints-priority.o |
8 | 8 | ||
9 | obj-$(CONFIG_PM) += pm.o dpmc.o | 9 | obj-$(CONFIG_PM) += pm.o dpmc_modes.o |
10 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o | 10 | obj-$(CONFIG_CPU_FREQ) += cpufreq.o |
11 | obj-$(CONFIG_CPU_VOLTAGE) += dpmc.o | ||
diff --git a/arch/blackfin/mach-common/dpmc.c b/arch/blackfin/mach-common/dpmc.c new file mode 100644 index 000000000000..02c7efd1bcf4 --- /dev/null +++ b/arch/blackfin/mach-common/dpmc.c | |||
@@ -0,0 +1,137 @@ | |||
1 | /* | ||
2 | * Copyright 2008 Analog Devices Inc. | ||
3 | * | ||
4 | * Licensed under the GPL-2 or later. | ||
5 | */ | ||
6 | |||
7 | #include <linux/cdev.h> | ||
8 | #include <linux/device.h> | ||
9 | #include <linux/errno.h> | ||
10 | #include <linux/fs.h> | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/module.h> | ||
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/types.h> | ||
15 | #include <linux/cpufreq.h> | ||
16 | |||
17 | #include <asm/delay.h> | ||
18 | #include <asm/dpmc.h> | ||
19 | |||
20 | #define DRIVER_NAME "bfin dpmc" | ||
21 | |||
22 | #define dprintk(msg...) \ | ||
23 | cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, DRIVER_NAME, msg) | ||
24 | |||
25 | struct bfin_dpmc_platform_data *pdata; | ||
26 | |||
27 | /** | ||
28 | * bfin_set_vlev - Update VLEV field in VR_CTL Reg. | ||
29 | * Avoid BYPASS sequence | ||
30 | */ | ||
31 | static void bfin_set_vlev(unsigned int vlev) | ||
32 | { | ||
33 | unsigned pll_lcnt; | ||
34 | |||
35 | pll_lcnt = bfin_read_PLL_LOCKCNT(); | ||
36 | |||
37 | bfin_write_PLL_LOCKCNT(1); | ||
38 | bfin_write_VR_CTL((bfin_read_VR_CTL() & ~VLEV) | vlev); | ||
39 | bfin_write_PLL_LOCKCNT(pll_lcnt); | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * bfin_get_vlev - Get CPU specific VLEV from platform device data | ||
44 | */ | ||
45 | static unsigned int bfin_get_vlev(unsigned int freq) | ||
46 | { | ||
47 | int i; | ||
48 | |||
49 | if (!pdata) | ||
50 | goto err_out; | ||
51 | |||
52 | freq >>= 16; | ||
53 | |||
54 | for (i = 0; i < pdata->tabsize; i++) | ||
55 | if (freq <= (pdata->tuple_tab[i] & 0xFFFF)) | ||
56 | return pdata->tuple_tab[i] >> 16; | ||
57 | |||
58 | err_out: | ||
59 | printk(KERN_WARNING "DPMC: No suitable CCLK VDDINT voltage pair found\n"); | ||
60 | return VLEV_120; | ||
61 | } | ||
62 | |||
63 | #ifdef CONFIG_CPU_FREQ | ||
64 | static int | ||
65 | vreg_cpufreq_notifier(struct notifier_block *nb, unsigned long val, void *data) | ||
66 | { | ||
67 | struct cpufreq_freqs *freq = data; | ||
68 | |||
69 | if (val == CPUFREQ_PRECHANGE && freq->old < freq->new) { | ||
70 | bfin_set_vlev(bfin_get_vlev(freq->new)); | ||
71 | udelay(pdata->vr_settling_time); /* Wait until Volatge settled */ | ||
72 | |||
73 | } else if (val == CPUFREQ_POSTCHANGE && freq->old > freq->new) | ||
74 | bfin_set_vlev(bfin_get_vlev(freq->new)); | ||
75 | |||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static struct notifier_block vreg_cpufreq_notifier_block = { | ||
80 | .notifier_call = vreg_cpufreq_notifier | ||
81 | }; | ||
82 | #endif /* CONFIG_CPU_FREQ */ | ||
83 | |||
84 | /** | ||
85 | * bfin_dpmc_probe - | ||
86 | * | ||
87 | */ | ||
88 | static int __devinit bfin_dpmc_probe(struct platform_device *pdev) | ||
89 | { | ||
90 | if (pdev->dev.platform_data) | ||
91 | pdata = pdev->dev.platform_data; | ||
92 | else | ||
93 | return -EINVAL; | ||
94 | |||
95 | return cpufreq_register_notifier(&vreg_cpufreq_notifier_block, | ||
96 | CPUFREQ_TRANSITION_NOTIFIER); | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * bfin_dpmc_remove - | ||
101 | */ | ||
102 | static int __devexit bfin_dpmc_remove(struct platform_device *pdev) | ||
103 | { | ||
104 | pdata = NULL; | ||
105 | return cpufreq_unregister_notifier(&vreg_cpufreq_notifier_block, | ||
106 | CPUFREQ_TRANSITION_NOTIFIER); | ||
107 | } | ||
108 | |||
109 | struct platform_driver bfin_dpmc_device_driver = { | ||
110 | .probe = bfin_dpmc_probe, | ||
111 | .remove = __devexit_p(bfin_dpmc_remove), | ||
112 | .driver = { | ||
113 | .name = DRIVER_NAME, | ||
114 | } | ||
115 | }; | ||
116 | |||
117 | /** | ||
118 | * bfin_dpmc_init - Init driver | ||
119 | */ | ||
120 | static int __init bfin_dpmc_init(void) | ||
121 | { | ||
122 | return platform_driver_register(&bfin_dpmc_device_driver); | ||
123 | } | ||
124 | module_init(bfin_dpmc_init); | ||
125 | |||
126 | /** | ||
127 | * bfin_dpmc_exit - break down driver | ||
128 | */ | ||
129 | static void __exit bfin_dpmc_exit(void) | ||
130 | { | ||
131 | platform_driver_unregister(&bfin_dpmc_device_driver); | ||
132 | } | ||
133 | module_exit(bfin_dpmc_exit); | ||
134 | |||
135 | MODULE_AUTHOR("Michael Hennerich <hennerich@blackfin.uclinux.org>"); | ||
136 | MODULE_DESCRIPTION("cpu power management driver for Blackfin"); | ||
137 | MODULE_LICENSE("GPL"); | ||
diff --git a/arch/blackfin/mach-common/dpmc.S b/arch/blackfin/mach-common/dpmc_modes.S index 9d45aa3265b1..b7981d31c392 100644 --- a/arch/blackfin/mach-common/dpmc.S +++ b/arch/blackfin/mach-common/dpmc_modes.S | |||
@@ -1,30 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * File: arch/blackfin/mach-common/dpmc.S | 2 | * Copyright 2004-2008 Analog Devices Inc. |
3 | * Based on: | ||
4 | * Author: LG Soft India | ||
5 | * | 3 | * |
6 | * Created: ? | 4 | * Licensed under the GPL-2 or later. |
7 | * Description: Watchdog Timer APIs | ||
8 | * | ||
9 | * Modified: | ||
10 | * Copyright 2004-2006 Analog Devices Inc. | ||
11 | * | ||
12 | * Bugs: Enter bugs at http://blackfin.uclinux.org/ | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License as published by | ||
16 | * the Free Software Foundation; either version 2 of the License, or | ||
17 | * (at your option) any later version. | ||
18 | * | ||
19 | * This program is distributed in the hope that it will be useful, | ||
20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
22 | * GNU General Public License for more details. | ||
23 | * | ||
24 | * You should have received a copy of the GNU General Public License | ||
25 | * along with this program; if not, see the file COPYING, or write | ||
26 | * to the Free Software Foundation, Inc., | ||
27 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
28 | */ | 5 | */ |
29 | 6 | ||
30 | #include <linux/linkage.h> | 7 | #include <linux/linkage.h> |