aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/pxa25x.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/arm/mach-pxa/pxa25x.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/arm/mach-pxa/pxa25x.c')
-rw-r--r--arch/arm/mach-pxa/pxa25x.c104
1 files changed, 104 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
new file mode 100644
index 000000000000..e887b7175ef3
--- /dev/null
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -0,0 +1,104 @@
1/*
2 * linux/arch/arm/mach-pxa/pxa25x.c
3 *
4 * Author: Nicolas Pitre
5 * Created: Jun 15, 2001
6 * Copyright: MontaVista Software Inc.
7 *
8 * Code specific to PXA21x/25x/26x variants.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Since this file should be linked before any other machine specific file,
15 * the __initcall() here will be executed first. This serves as default
16 * initialization stuff for PXA machines which can be overridden later if
17 * need be.
18 */
19#include <linux/module.h>
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/pm.h>
23
24#include <asm/hardware.h>
25#include <asm/arch/pxa-regs.h>
26
27#include "generic.h"
28
29/*
30 * Various clock factors driven by the CCCR register.
31 */
32
33/* Crystal Frequency to Memory Frequency Multiplier (L) */
34static unsigned char L_clk_mult[32] = { 0, 27, 32, 36, 40, 45, 0, };
35
36/* Memory Frequency to Run Mode Frequency Multiplier (M) */
37static unsigned char M_clk_mult[4] = { 0, 1, 2, 4 };
38
39/* Run Mode Frequency to Turbo Mode Frequency Multiplier (N) */
40/* Note: we store the value N * 2 here. */
41static unsigned char N2_clk_mult[8] = { 0, 0, 2, 3, 4, 0, 6, 0 };
42
43/* Crystal clock */
44#define BASE_CLK 3686400
45
46/*
47 * Get the clock frequency as reflected by CCCR and the turbo flag.
48 * We assume these values have been applied via a fcs.
49 * If info is not 0 we also display the current settings.
50 */
51unsigned int get_clk_frequency_khz(int info)
52{
53 unsigned long cccr, turbo;
54 unsigned int l, L, m, M, n2, N;
55
56 cccr = CCCR;
57 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (turbo) );
58
59 l = L_clk_mult[(cccr >> 0) & 0x1f];
60 m = M_clk_mult[(cccr >> 5) & 0x03];
61 n2 = N2_clk_mult[(cccr >> 7) & 0x07];
62
63 L = l * BASE_CLK;
64 M = m * L;
65 N = n2 * M / 2;
66
67 if(info)
68 {
69 L += 5000;
70 printk( KERN_INFO "Memory clock: %d.%02dMHz (*%d)\n",
71 L / 1000000, (L % 1000000) / 10000, l );
72 M += 5000;
73 printk( KERN_INFO "Run Mode clock: %d.%02dMHz (*%d)\n",
74 M / 1000000, (M % 1000000) / 10000, m );
75 N += 5000;
76 printk( KERN_INFO "Turbo Mode clock: %d.%02dMHz (*%d.%d, %sactive)\n",
77 N / 1000000, (N % 1000000) / 10000, n2 / 2, (n2 % 2) * 5,
78 (turbo & 1) ? "" : "in" );
79 }
80
81 return (turbo & 1) ? (N/1000) : (M/1000);
82}
83
84EXPORT_SYMBOL(get_clk_frequency_khz);
85
86/*
87 * Return the current memory clock frequency in units of 10kHz
88 */
89unsigned int get_memclk_frequency_10khz(void)
90{
91 return L_clk_mult[(CCCR >> 0) & 0x1f] * BASE_CLK / 10000;
92}
93
94EXPORT_SYMBOL(get_memclk_frequency_10khz);
95
96/*
97 * Return the current LCD clock frequency in units of 10kHz
98 */
99unsigned int get_lcdclk_frequency_10khz(void)
100{
101 return get_memclk_frequency_10khz();
102}
103
104EXPORT_SYMBOL(get_lcdclk_frequency_10khz);