diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-06 19:50:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-06 19:50:35 -0500 |
commit | 3c0cb7c31c206aaedb967e44b98442bbeb17a6c4 (patch) | |
tree | 3ecba45d7ffae4fba4a5aafaef4af5b0b1105bde /arch/arm/mach-pxa/clock-pxa3xx.c | |
parent | f70f5b9dc74ca7d0a64c4ead3fb28da09dc1b234 (diff) | |
parent | 404a02cbd2ae8bf256a2fa1169bdfe86bb5ebb34 (diff) |
Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
* 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm: (416 commits)
ARM: DMA: add support for DMA debugging
ARM: PL011: add DMA burst threshold support for ST variants
ARM: PL011: Add support for transmit DMA
ARM: PL011: Ensure IRQs are disabled in UART interrupt handler
ARM: PL011: Separate hardware FIFO size from TTY FIFO size
ARM: PL011: Allow better handling of vendor data
ARM: PL011: Ensure error flags are clear at startup
ARM: PL011: include revision number in boot-time port printk
ARM: vexpress: add sched_clock() for Versatile Express
ARM i.MX53: Make MX53 EVK bootable
ARM i.MX53: Some bug fix about MX53 MSL code
ARM: 6607/1: sa1100: Update platform device registration
ARM: 6606/1: sa1100: Fix platform device registration
ARM i.MX51: rename IPU irqs
ARM i.MX51: Add ipu clock support
ARM: imx/mx27_3ds: Add PMIC support
ARM: DMA: Replace page_to_dma()/dma_to_page() with pfn_to_dma()/dma_to_pfn()
mx51: fix usb clock support
MX51: Add support for usb host 2
arch/arm/plat-mxc/ehci.c: fix errors/typos
...
Diffstat (limited to 'arch/arm/mach-pxa/clock-pxa3xx.c')
-rw-r--r-- | arch/arm/mach-pxa/clock-pxa3xx.c | 218 |
1 files changed, 218 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/clock-pxa3xx.c b/arch/arm/mach-pxa/clock-pxa3xx.c new file mode 100644 index 000000000000..1b08a34ab234 --- /dev/null +++ b/arch/arm/mach-pxa/clock-pxa3xx.c | |||
@@ -0,0 +1,218 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-pxa/clock-pxa3xx.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/module.h> | ||
10 | #include <linux/kernel.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/io.h> | ||
13 | |||
14 | #include <mach/smemc.h> | ||
15 | #include <mach/pxa3xx-regs.h> | ||
16 | |||
17 | #include "clock.h" | ||
18 | |||
19 | /* Crystal clock: 13MHz */ | ||
20 | #define BASE_CLK 13000000 | ||
21 | |||
22 | /* Ring Oscillator Clock: 60MHz */ | ||
23 | #define RO_CLK 60000000 | ||
24 | |||
25 | #define ACCR_D0CS (1 << 26) | ||
26 | #define ACCR_PCCE (1 << 11) | ||
27 | |||
28 | /* crystal frequency to HSIO bus frequency multiplier (HSS) */ | ||
29 | static unsigned char hss_mult[4] = { 8, 12, 16, 24 }; | ||
30 | |||
31 | /* | ||
32 | * Get the clock frequency as reflected by CCSR and the turbo flag. | ||
33 | * We assume these values have been applied via a fcs. | ||
34 | * If info is not 0 we also display the current settings. | ||
35 | */ | ||
36 | unsigned int pxa3xx_get_clk_frequency_khz(int info) | ||
37 | { | ||
38 | unsigned long acsr, xclkcfg; | ||
39 | unsigned int t, xl, xn, hss, ro, XL, XN, CLK, HSS; | ||
40 | |||
41 | /* Read XCLKCFG register turbo bit */ | ||
42 | __asm__ __volatile__("mrc\tp14, 0, %0, c6, c0, 0" : "=r"(xclkcfg)); | ||
43 | t = xclkcfg & 0x1; | ||
44 | |||
45 | acsr = ACSR; | ||
46 | |||
47 | xl = acsr & 0x1f; | ||
48 | xn = (acsr >> 8) & 0x7; | ||
49 | hss = (acsr >> 14) & 0x3; | ||
50 | |||
51 | XL = xl * BASE_CLK; | ||
52 | XN = xn * XL; | ||
53 | |||
54 | ro = acsr & ACCR_D0CS; | ||
55 | |||
56 | CLK = (ro) ? RO_CLK : ((t) ? XN : XL); | ||
57 | HSS = (ro) ? RO_CLK : hss_mult[hss] * BASE_CLK; | ||
58 | |||
59 | if (info) { | ||
60 | pr_info("RO Mode clock: %d.%02dMHz (%sactive)\n", | ||
61 | RO_CLK / 1000000, (RO_CLK % 1000000) / 10000, | ||
62 | (ro) ? "" : "in"); | ||
63 | pr_info("Run Mode clock: %d.%02dMHz (*%d)\n", | ||
64 | XL / 1000000, (XL % 1000000) / 10000, xl); | ||
65 | pr_info("Turbo Mode clock: %d.%02dMHz (*%d, %sactive)\n", | ||
66 | XN / 1000000, (XN % 1000000) / 10000, xn, | ||
67 | (t) ? "" : "in"); | ||
68 | pr_info("HSIO bus clock: %d.%02dMHz\n", | ||
69 | HSS / 1000000, (HSS % 1000000) / 10000); | ||
70 | } | ||
71 | |||
72 | return CLK / 1000; | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * Return the current AC97 clock frequency. | ||
77 | */ | ||
78 | static unsigned long clk_pxa3xx_ac97_getrate(struct clk *clk) | ||
79 | { | ||
80 | unsigned long rate = 312000000; | ||
81 | unsigned long ac97_div; | ||
82 | |||
83 | ac97_div = AC97_DIV; | ||
84 | |||
85 | /* This may loose precision for some rates but won't for the | ||
86 | * standard 24.576MHz. | ||
87 | */ | ||
88 | rate /= (ac97_div >> 12) & 0x7fff; | ||
89 | rate *= (ac97_div & 0xfff); | ||
90 | |||
91 | return rate; | ||
92 | } | ||
93 | |||
94 | /* | ||
95 | * Return the current HSIO bus clock frequency | ||
96 | */ | ||
97 | static unsigned long clk_pxa3xx_hsio_getrate(struct clk *clk) | ||
98 | { | ||
99 | unsigned long acsr; | ||
100 | unsigned int hss, hsio_clk; | ||
101 | |||
102 | acsr = ACSR; | ||
103 | |||
104 | hss = (acsr >> 14) & 0x3; | ||
105 | hsio_clk = (acsr & ACCR_D0CS) ? RO_CLK : hss_mult[hss] * BASE_CLK; | ||
106 | |||
107 | return hsio_clk; | ||
108 | } | ||
109 | |||
110 | /* crystal frequency to static memory controller multiplier (SMCFS) */ | ||
111 | static unsigned int smcfs_mult[8] = { 6, 0, 8, 0, 0, 16, }; | ||
112 | static unsigned int df_clkdiv[4] = { 1, 2, 4, 1 }; | ||
113 | |||
114 | static unsigned long clk_pxa3xx_smemc_getrate(struct clk *clk) | ||
115 | { | ||
116 | unsigned long acsr = ACSR; | ||
117 | unsigned long memclkcfg = __raw_readl(MEMCLKCFG); | ||
118 | unsigned int smcfs = (acsr >> 23) & 0x7; | ||
119 | |||
120 | return BASE_CLK * smcfs_mult[(acsr >> 23) & 0x7] / | ||
121 | df_clkdiv[(memclkcfg >> 16) & 0x3]; | ||
122 | } | ||
123 | |||
124 | void clk_pxa3xx_cken_enable(struct clk *clk) | ||
125 | { | ||
126 | unsigned long mask = 1ul << (clk->cken & 0x1f); | ||
127 | |||
128 | if (clk->cken < 32) | ||
129 | CKENA |= mask; | ||
130 | else | ||
131 | CKENB |= mask; | ||
132 | } | ||
133 | |||
134 | void clk_pxa3xx_cken_disable(struct clk *clk) | ||
135 | { | ||
136 | unsigned long mask = 1ul << (clk->cken & 0x1f); | ||
137 | |||
138 | if (clk->cken < 32) | ||
139 | CKENA &= ~mask; | ||
140 | else | ||
141 | CKENB &= ~mask; | ||
142 | } | ||
143 | |||
144 | const struct clkops clk_pxa3xx_cken_ops = { | ||
145 | .enable = clk_pxa3xx_cken_enable, | ||
146 | .disable = clk_pxa3xx_cken_disable, | ||
147 | }; | ||
148 | |||
149 | const struct clkops clk_pxa3xx_hsio_ops = { | ||
150 | .enable = clk_pxa3xx_cken_enable, | ||
151 | .disable = clk_pxa3xx_cken_disable, | ||
152 | .getrate = clk_pxa3xx_hsio_getrate, | ||
153 | }; | ||
154 | |||
155 | const struct clkops clk_pxa3xx_ac97_ops = { | ||
156 | .enable = clk_pxa3xx_cken_enable, | ||
157 | .disable = clk_pxa3xx_cken_disable, | ||
158 | .getrate = clk_pxa3xx_ac97_getrate, | ||
159 | }; | ||
160 | |||
161 | const struct clkops clk_pxa3xx_smemc_ops = { | ||
162 | .enable = clk_pxa3xx_cken_enable, | ||
163 | .disable = clk_pxa3xx_cken_disable, | ||
164 | .getrate = clk_pxa3xx_smemc_getrate, | ||
165 | }; | ||
166 | |||
167 | static void clk_pout_enable(struct clk *clk) | ||
168 | { | ||
169 | OSCC |= OSCC_PEN; | ||
170 | } | ||
171 | |||
172 | static void clk_pout_disable(struct clk *clk) | ||
173 | { | ||
174 | OSCC &= ~OSCC_PEN; | ||
175 | } | ||
176 | |||
177 | const struct clkops clk_pxa3xx_pout_ops = { | ||
178 | .enable = clk_pout_enable, | ||
179 | .disable = clk_pout_disable, | ||
180 | }; | ||
181 | |||
182 | #ifdef CONFIG_PM | ||
183 | static uint32_t cken[2]; | ||
184 | static uint32_t accr; | ||
185 | |||
186 | static int pxa3xx_clock_suspend(struct sys_device *d, pm_message_t state) | ||
187 | { | ||
188 | cken[0] = CKENA; | ||
189 | cken[1] = CKENB; | ||
190 | accr = ACCR; | ||
191 | return 0; | ||
192 | } | ||
193 | |||
194 | static int pxa3xx_clock_resume(struct sys_device *d) | ||
195 | { | ||
196 | ACCR = accr; | ||
197 | CKENA = cken[0]; | ||
198 | CKENB = cken[1]; | ||
199 | return 0; | ||
200 | } | ||
201 | #else | ||
202 | #define pxa3xx_clock_suspend NULL | ||
203 | #define pxa3xx_clock_resume NULL | ||
204 | #endif | ||
205 | |||
206 | struct sysdev_class pxa3xx_clock_sysclass = { | ||
207 | .name = "pxa3xx-clock", | ||
208 | .suspend = pxa3xx_clock_suspend, | ||
209 | .resume = pxa3xx_clock_resume, | ||
210 | }; | ||
211 | |||
212 | static int __init pxa3xx_clock_init(void) | ||
213 | { | ||
214 | if (cpu_is_pxa3xx() || cpu_is_pxa95x()) | ||
215 | return sysdev_class_register(&pxa3xx_clock_sysclass); | ||
216 | return 0; | ||
217 | } | ||
218 | postcore_initcall(pxa3xx_clock_init); | ||