2 * linux/arch/arm/mach-pxa/pxa27x.c
4 * Author: Nicolas Pitre
5 * Created: Nov 05, 2002
6 * Copyright: MontaVista Software Inc.
8 * Code specific to PXA27x aka Bulverde.
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.
14 #include <linux/config.h>
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/init.h>
19 #include <linux/platform_device.h>
21 #include <asm/hardware.h>
23 #include <asm/arch/pxa-regs.h>
24 #include <asm/arch/ohci.h>
28 /* Crystal clock: 13MHz */
29 #define BASE_CLK 13000000
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.
36 unsigned int get_clk_frequency_khz( int info)
38 unsigned long ccsr, clkcfg;
39 unsigned int l, L, m, M, n2, N, S;
43 cccr_a = CCCR & (1 << 25);
45 /* Read clkcfg register: it has turbo, b, half-turbo (and f) */
46 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) );
47 t = clkcfg & (1 << 1);
48 ht = clkcfg & (1 << 2);
49 b = clkcfg & (1 << 3);
53 m = (l <= 10) ? 1 : (l <= 20) ? 2 : 4;
57 M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2));
61 printk( KERN_INFO "Run Mode clock: %d.%02dMHz (*%d)\n",
62 L / 1000000, (L % 1000000) / 10000, l );
63 printk( KERN_INFO "Turbo Mode clock: %d.%02dMHz (*%d.%d, %sactive)\n",
64 N / 1000000, (N % 1000000)/10000, n2 / 2, (n2 % 2)*5,
66 printk( KERN_INFO "Memory clock: %d.%02dMHz (/%d)\n",
67 M / 1000000, (M % 1000000) / 10000, m );
68 printk( KERN_INFO "System bus clock: %d.%02dMHz \n",
69 S / 1000000, (S % 1000000) / 10000 );
72 return (t) ? (N/1000) : (L/1000);
76 * Return the current mem clock frequency in units of 10kHz as
77 * reflected by CCCR[A], B, and L
79 unsigned int get_memclk_frequency_10khz(void)
81 unsigned long ccsr, clkcfg;
82 unsigned int l, L, m, M;
86 cccr_a = CCCR & (1 << 25);
88 /* Read clkcfg register: it has turbo, b, half-turbo (and f) */
89 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) );
90 b = clkcfg & (1 << 3);
93 m = (l <= 10) ? 1 : (l <= 20) ? 2 : 4;
96 M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2));
102 * Return the current LCD clock frequency in units of 10kHz as
104 unsigned int get_lcdclk_frequency_10khz(void)
107 unsigned int l, L, k, K;
112 k = (l <= 7) ? 1 : (l <= 16) ? 2 : 4;
120 EXPORT_SYMBOL(get_clk_frequency_khz);
121 EXPORT_SYMBOL(get_memclk_frequency_10khz);
122 EXPORT_SYMBOL(get_lcdclk_frequency_10khz);
126 int pxa_cpu_pm_prepare(suspend_state_t state)
130 case PM_SUSPEND_STANDBY:
137 void pxa_cpu_pm_enter(suspend_state_t state)
139 extern void pxa_cpu_standby(void);
140 extern void pxa_cpu_suspend(unsigned int);
141 extern void pxa_cpu_resume(void);
143 if (state == PM_SUSPEND_STANDBY)
144 CKEN = CKEN22_MEMC | CKEN9_OSTIMER | CKEN16_LCD |CKEN0_PWM0;
146 CKEN = CKEN22_MEMC | CKEN9_OSTIMER;
148 /* ensure voltage-change sequencer not initiated, which hangs */
151 /* Clear edge-detect status register. */
155 case PM_SUSPEND_STANDBY:
159 /* set resume return address */
160 PSPR = virt_to_phys(pxa_cpu_resume);
161 pxa_cpu_suspend(PWRMODE_SLEEP);
169 * device registration specific to PXA27x.
172 static u64 pxa27x_dmamask = 0xffffffffUL;
174 static struct resource pxa27x_ohci_resources[] = {
178 .flags = IORESOURCE_MEM,
183 .flags = IORESOURCE_IRQ,
187 static struct platform_device ohci_device = {
188 .name = "pxa27x-ohci",
191 .dma_mask = &pxa27x_dmamask,
192 .coherent_dma_mask = 0xffffffff,
194 .num_resources = ARRAY_SIZE(pxa27x_ohci_resources),
195 .resource = pxa27x_ohci_resources,
198 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
200 ohci_device.dev.platform_data = info;
203 static struct platform_device *devices[] __initdata = {
207 static int __init pxa27x_init(void)
209 return platform_add_devices(devices, ARRAY_SIZE(devices));
212 subsys_initcall(pxa27x_init);