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 #include <linux/module.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/delay.h>
17 #include <linux/cpufreq.h>
18 #include <linux/ioport.h>
19 #include <linux/sched.h> /* just for sched_clock() - funny that */
20 #include <linux/platform_device.h>
22 #include <asm/div64.h>
23 #include <asm/hardware.h>
24 #include <asm/system.h>
25 #include <asm/pgtable.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/flash.h>
35 * This table is setup for a 3.6864MHz Crystal.
37 static const unsigned short cclk_frequency_100khz[NR_FREQS] = {
56 #if defined(CONFIG_CPU_FREQ_SA1100) || defined(CONFIG_CPU_FREQ_SA1110)
58 unsigned int sa11x0_freq_to_ppcr(unsigned int khz)
64 for (i = 0; i < NR_FREQS; i++)
65 if (cclk_frequency_100khz[i] >= khz)
71 unsigned int sa11x0_ppcr_to_freq(unsigned int idx)
73 unsigned int freq = 0;
75 freq = cclk_frequency_100khz[idx] * 100;
80 /* make sure that only the "userspace" governor is run -- anything else wouldn't make sense on
81 * this platform, anyway.
83 int sa11x0_verify_speed(struct cpufreq_policy *policy)
89 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
91 /* make sure that at least one frequency is within the policy */
92 tmp = cclk_frequency_100khz[sa11x0_freq_to_ppcr(policy->min)] * 100;
93 if (tmp > policy->max)
96 cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, policy->cpuinfo.max_freq);
101 unsigned int sa11x0_getspeed(unsigned int cpu)
105 return cclk_frequency_100khz[PPCR & 0xf] * 100;
110 * We still need to provide this so building without cpufreq works.
112 unsigned int cpufreq_get(unsigned int cpu)
114 return cclk_frequency_100khz[PPCR & 0xf] * 100;
116 EXPORT_SYMBOL(cpufreq_get);
120 * This is the SA11x0 sched_clock implementation. This has
121 * a resolution of 271ns, and a maximum value of 1165s.
122 * ( * 1E9 / 3686400 => * 78125 / 288)
124 unsigned long long sched_clock(void)
126 unsigned long long v;
128 v = (unsigned long long)OSCR * 78125;
135 * Default power-off for SA1100
137 static void sa1100_power_off(void)
141 /* disable internal oscillator, float CS lines */
142 PCFR = (PCFR_OPDE | PCFR_FP | PCFR_FS);
143 /* enable wake-up on GPIO0 (Assabet...) */
144 PWER = GFER = GRER = 1;
146 * set scratchpad to zero, just in case it is used as a
147 * restart address by the bootloader.
150 /* enter sleep mode */
154 static struct resource sa11x0udc_resources[] = {
158 .flags = IORESOURCE_MEM,
162 static u64 sa11x0udc_dma_mask = 0xffffffffUL;
164 static struct platform_device sa11x0udc_device = {
165 .name = "sa11x0-udc",
168 .dma_mask = &sa11x0udc_dma_mask,
169 .coherent_dma_mask = 0xffffffff,
171 .num_resources = ARRAY_SIZE(sa11x0udc_resources),
172 .resource = sa11x0udc_resources,
175 static struct resource sa11x0uart1_resources[] = {
179 .flags = IORESOURCE_MEM,
183 static struct platform_device sa11x0uart1_device = {
184 .name = "sa11x0-uart",
186 .num_resources = ARRAY_SIZE(sa11x0uart1_resources),
187 .resource = sa11x0uart1_resources,
190 static struct resource sa11x0uart3_resources[] = {
194 .flags = IORESOURCE_MEM,
198 static struct platform_device sa11x0uart3_device = {
199 .name = "sa11x0-uart",
201 .num_resources = ARRAY_SIZE(sa11x0uart3_resources),
202 .resource = sa11x0uart3_resources,
205 static struct resource sa11x0mcp_resources[] = {
209 .flags = IORESOURCE_MEM,
213 static u64 sa11x0mcp_dma_mask = 0xffffffffUL;
215 static struct platform_device sa11x0mcp_device = {
216 .name = "sa11x0-mcp",
219 .dma_mask = &sa11x0mcp_dma_mask,
220 .coherent_dma_mask = 0xffffffff,
222 .num_resources = ARRAY_SIZE(sa11x0mcp_resources),
223 .resource = sa11x0mcp_resources,
226 void sa11x0_set_mcp_data(struct mcp_plat_data *data)
228 sa11x0mcp_device.dev.platform_data = data;
231 static struct resource sa11x0ssp_resources[] = {
235 .flags = IORESOURCE_MEM,
239 static u64 sa11x0ssp_dma_mask = 0xffffffffUL;
241 static struct platform_device sa11x0ssp_device = {
242 .name = "sa11x0-ssp",
245 .dma_mask = &sa11x0ssp_dma_mask,
246 .coherent_dma_mask = 0xffffffff,
248 .num_resources = ARRAY_SIZE(sa11x0ssp_resources),
249 .resource = sa11x0ssp_resources,
252 static struct resource sa11x0fb_resources[] = {
256 .flags = IORESOURCE_MEM,
261 .flags = IORESOURCE_IRQ,
265 static struct platform_device sa11x0fb_device = {
269 .coherent_dma_mask = 0xffffffff,
271 .num_resources = ARRAY_SIZE(sa11x0fb_resources),
272 .resource = sa11x0fb_resources,
275 static struct platform_device sa11x0pcmcia_device = {
276 .name = "sa11x0-pcmcia",
280 static struct platform_device sa11x0mtd_device = {
285 void sa11x0_set_flash_data(struct flash_platform_data *flash,
286 struct resource *res, int nr)
288 flash->name = "sa1100";
289 sa11x0mtd_device.dev.platform_data = flash;
290 sa11x0mtd_device.resource = res;
291 sa11x0mtd_device.num_resources = nr;
294 static struct resource sa11x0ir_resources[] = {
296 .start = __PREG(Ser2UTCR0),
297 .end = __PREG(Ser2UTCR0) + 0x24 - 1,
298 .flags = IORESOURCE_MEM,
300 .start = __PREG(Ser2HSCR0),
301 .end = __PREG(Ser2HSCR0) + 0x1c - 1,
302 .flags = IORESOURCE_MEM,
304 .start = __PREG(Ser2HSCR2),
305 .end = __PREG(Ser2HSCR2) + 0x04 - 1,
306 .flags = IORESOURCE_MEM,
308 .start = IRQ_Ser2ICP,
310 .flags = IORESOURCE_IRQ,
314 static struct platform_device sa11x0ir_device = {
317 .num_resources = ARRAY_SIZE(sa11x0ir_resources),
318 .resource = sa11x0ir_resources,
321 void sa11x0_set_irda_data(struct irda_platform_data *irda)
323 sa11x0ir_device.dev.platform_data = irda;
326 static struct platform_device sa11x0rtc_device = {
327 .name = "sa1100-rtc",
331 static struct platform_device *sa11x0_devices[] __initdata = {
337 &sa11x0pcmcia_device,
343 static int __init sa1100_init(void)
345 pm_power_off = sa1100_power_off;
347 if (sa11x0ir_device.dev.platform_data)
348 platform_device_register(&sa11x0ir_device);
350 return platform_add_devices(sa11x0_devices, ARRAY_SIZE(sa11x0_devices));
353 arch_initcall(sa1100_init);
355 void (*sa1100fb_backlight_power)(int on);
356 void (*sa1100fb_lcd_power)(int on);
358 EXPORT_SYMBOL(sa1100fb_backlight_power);
359 EXPORT_SYMBOL(sa1100fb_lcd_power);
363 * Common I/O mapping:
365 * Typically, static virtual address mappings are as follow:
367 * 0xf0000000-0xf3ffffff: miscellaneous stuff (CPLDs, etc.)
368 * 0xf4000000-0xf4ffffff: SA-1111
369 * 0xf5000000-0xf5ffffff: reserved (used by cache flushing area)
370 * 0xf6000000-0xfffeffff: reserved (internal SA1100 IO defined above)
371 * 0xffff0000-0xffff0fff: SA1100 exception vectors
372 * 0xffff2000-0xffff2fff: Minicache copy_user_page area
374 * Below 0xe8000000 is reserved for vm allocation.
376 * The machine specific code must provide the extra mapping beside the
377 * default mapping provided here.
380 static struct map_desc standard_io_desc[] __initdata = {
382 .virtual = 0xf8000000,
383 .pfn = __phys_to_pfn(0x80000000),
384 .length = 0x00100000,
387 .virtual = 0xfa000000,
388 .pfn = __phys_to_pfn(0x90000000),
389 .length = 0x00100000,
392 .virtual = 0xfc000000,
393 .pfn = __phys_to_pfn(0xa0000000),
394 .length = 0x00100000,
397 .virtual = 0xfe000000,
398 .pfn = __phys_to_pfn(0xb0000000),
399 .length = 0x00200000,
404 void __init sa1100_map_io(void)
406 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
410 * Disable the memory bus request/grant signals on the SA1110 to
411 * ensure that we don't receive spurious memory requests. We set
412 * the MBGNT signal false to ensure the SA1111 doesn't own the
415 void __init sa1110_mb_disable(void)
419 local_irq_save(flags);
423 GPDR = (GPDR & ~GPIO_MBREQ) | GPIO_MBGNT;
425 GAFR &= ~(GPIO_MBGNT | GPIO_MBREQ);
427 local_irq_restore(flags);
431 * If the system is going to use the SA-1111 DMA engines, set up
432 * the memory bus request/grant pins.
434 void __init sa1110_mb_enable(void)
438 local_irq_save(flags);
442 GPDR = (GPDR & ~GPIO_MBREQ) | GPIO_MBGNT;
444 GAFR |= (GPIO_MBGNT | GPIO_MBREQ);
447 local_irq_restore(flags);