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/config.h>
13 #include <linux/module.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
18 #include <linux/cpufreq.h>
19 #include <linux/ioport.h>
20 #include <linux/sched.h> /* just for sched_clock() - funny that */
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
*sa11x0_devices
[] __initdata
= {
332 &sa11x0pcmcia_device
,
337 static int __init
sa1100_init(void)
339 pm_power_off
= sa1100_power_off
;
341 if (sa11x0ir_device
.dev
.platform_data
)
342 platform_device_register(&sa11x0ir_device
);
344 return platform_add_devices(sa11x0_devices
, ARRAY_SIZE(sa11x0_devices
));
347 arch_initcall(sa1100_init
);
349 void (*sa1100fb_backlight_power
)(int on
);
350 void (*sa1100fb_lcd_power
)(int on
);
352 EXPORT_SYMBOL(sa1100fb_backlight_power
);
353 EXPORT_SYMBOL(sa1100fb_lcd_power
);
357 * Common I/O mapping:
359 * Typically, static virtual address mappings are as follow:
361 * 0xf0000000-0xf3ffffff: miscellaneous stuff (CPLDs, etc.)
362 * 0xf4000000-0xf4ffffff: SA-1111
363 * 0xf5000000-0xf5ffffff: reserved (used by cache flushing area)
364 * 0xf6000000-0xfffeffff: reserved (internal SA1100 IO defined above)
365 * 0xffff0000-0xffff0fff: SA1100 exception vectors
366 * 0xffff2000-0xffff2fff: Minicache copy_user_page area
368 * Below 0xe8000000 is reserved for vm allocation.
370 * The machine specific code must provide the extra mapping beside the
371 * default mapping provided here.
374 static struct map_desc standard_io_desc
[] __initdata
= {
376 .virtual = 0xf8000000,
377 .pfn
= __phys_to_pfn(0x80000000),
378 .length
= 0x00100000,
381 .virtual = 0xfa000000,
382 .pfn
= __phys_to_pfn(0x90000000),
383 .length
= 0x00100000,
386 .virtual = 0xfc000000,
387 .pfn
= __phys_to_pfn(0xa0000000),
388 .length
= 0x00100000,
391 .virtual = 0xfe000000,
392 .pfn
= __phys_to_pfn(0xb0000000),
393 .length
= 0x00200000,
398 void __init
sa1100_map_io(void)
400 iotable_init(standard_io_desc
, ARRAY_SIZE(standard_io_desc
));
404 * Disable the memory bus request/grant signals on the SA1110 to
405 * ensure that we don't receive spurious memory requests. We set
406 * the MBGNT signal false to ensure the SA1111 doesn't own the
409 void __init
sa1110_mb_disable(void)
413 local_irq_save(flags
);
417 GPDR
= (GPDR
& ~GPIO_MBREQ
) | GPIO_MBGNT
;
419 GAFR
&= ~(GPIO_MBGNT
| GPIO_MBREQ
);
421 local_irq_restore(flags
);
425 * If the system is going to use the SA-1111 DMA engines, set up
426 * the memory bus request/grant pins.
428 void __init
sa1110_mb_enable(void)
432 local_irq_save(flags
);
436 GPDR
= (GPDR
& ~GPIO_MBREQ
) | GPIO_MBGNT
;
438 GAFR
|= (GPIO_MBGNT
| GPIO_MBREQ
);
441 local_irq_restore(flags
);