2 * linux/arch/arm/mach-sa1100/generic.c
4 * Author: Nicolas Pitre
6 * Code common to all SA11x0 machines.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Since this file should be linked before any other machine specific file,
13 * the __initcall() here will be executed first. This serves as default
14 * initialization stuff for SA1100 machines which can be overriden later if
17 #include <linux/config.h>
18 #include <linux/module.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/delay.h>
23 #include <linux/cpufreq.h>
25 #include <asm/hardware.h>
26 #include <asm/system.h>
27 #include <asm/pgtable.h>
28 #include <asm/mach/map.h>
35 * This table is setup for a 3.6864MHz Crystal.
37 static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
57 * Return the current CPU clock frequency in units of 100kHz
59 static inline unsigned short get_cclk_frequency(void)
61 return cclk_frequency_100khz[PPCR & 0xf];
64 #ifdef CONFIG_CPU_FREQ
65 unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
71 for (i = NR_FREQS - 1; i > 0; i--)
72 if (cclk_frequency_100khz[i] <= khz)
79 * Validate the speed in khz. If we can't generate the precise
80 * frequency requested, round it down (to be on the safe side).
82 unsigned int sa11x0_validatespeed(unsigned int khz)
84 return cclk_frequency_100khz[sa11x0_freq_to_ppcr(khz)] * 100;
87 static int __init sa11x0_init_clock(void)
89 cpufreq_init(cclk_frequency_100khz[PPCR & 0xf] * 100, 59000, 287000);
93 __initcall(sa11x0_init_clock);
96 * We still need to provide this so building without cpufreq works.
98 unsigned int cpufreq_get(int cpu)
100 return cclk_frequency_100khz[PPCR & 0xf] * 100;
102 EXPORT_SYMBOL(cpufreq_get);
106 * Default power-off for SA1100
108 static void sa1100_power_off(void)
112 /* disable internal oscillator, float CS lines */
113 PCFR = (PCFR_OPDE | PCFR_FP | PCFR_FS);
114 /* enable wake-up on GPIO0 (Assabet...) */
115 PWER = GFER = GRER = 1;
117 * set scratchpad to zero, just in case it is used as a
118 * restart address by the bootloader.
121 /* enter sleep mode */
125 static int __init sa1100_init(void)
127 pm_power_off = sa1100_power_off;
131 __initcall(sa1100_init);
135 * Common I/O mapping:
137 * Typically, static virtual address mappings are as follow:
139 * 0xe8000000-0xefffffff: flash memory (especially when multiple flash
140 * banks need to be mapped contigously)
141 * 0xf0000000-0xf3ffffff: miscellaneous stuff (CPLDs, etc.)
142 * 0xf4000000-0xf4ffffff: SA-1111
143 * 0xf5000000-0xf5ffffff: reserved (used by cache flushing area)
144 * 0xf6000000-0xfffeffff: reserved (internal SA1100 IO defined above)
145 * 0xffff0000-0xffff0fff: SA1100 exception vectors
147 * Below 0xe8000000 is reserved for vm allocation.
149 * The machine specific code must provide the extra mapping beside the
150 * default mapping provided here.
153 static struct map_desc standard_io_desc[] __initdata = {
154 /* virtual physical length domain r w c b */
155 { 0xf6000000, 0x20000000, 0x01000000, DOMAIN_IO, 0, 1, 0, 0 }, /* PCMCIA0 IO */
156 { 0xf7000000, 0x30000000, 0x01000000, DOMAIN_IO, 0, 1, 0, 0 }, /* PCMCIA1 IO */
157 { 0xf8000000, 0x80000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* PCM */
158 { 0xfa000000, 0x90000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* SCM */
159 { 0xfc000000, 0xa0000000, 0x00100000, DOMAIN_IO, 0, 1, 0, 0 }, /* MER */
160 { 0xfe000000, 0xb0000000, 0x00200000, DOMAIN_IO, 0, 1, 0, 0 }, /* LCD + DMA */
164 void __init sa1100_map_io(void)
166 iotable_init(standard_io_desc);