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/module.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
18 #include <linux/platform_device.h>
20 #include <asm/hardware.h>
22 #include <asm/arch/irqs.h>
23 #include <asm/arch/pxa-regs.h>
24 #include <asm/arch/ohci.h>
25 #include <asm/arch/pm.h>
26 #include <asm/arch/dma.h>
31 /* Crystal clock: 13MHz */
32 #define BASE_CLK 13000000
35 * Get the clock frequency as reflected by CCSR and the turbo flag.
36 * We assume these values have been applied via a fcs.
37 * If info is not 0 we also display the current settings.
39 unsigned int get_clk_frequency_khz( int info)
41 unsigned long ccsr, clkcfg;
42 unsigned int l, L, m, M, n2, N, S;
46 cccr_a = CCCR & (1 << 25);
48 /* Read clkcfg register: it has turbo, b, half-turbo (and f) */
49 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) );
50 t = clkcfg & (1 << 0);
51 ht = clkcfg & (1 << 2);
52 b = clkcfg & (1 << 3);
56 m = (l <= 10) ? 1 : (l <= 20) ? 2 : 4;
60 M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2));
64 printk( KERN_INFO "Run Mode clock: %d.%02dMHz (*%d)\n",
65 L / 1000000, (L % 1000000) / 10000, l );
66 printk( KERN_INFO "Turbo Mode clock: %d.%02dMHz (*%d.%d, %sactive)\n",
67 N / 1000000, (N % 1000000)/10000, n2 / 2, (n2 % 2)*5,
69 printk( KERN_INFO "Memory clock: %d.%02dMHz (/%d)\n",
70 M / 1000000, (M % 1000000) / 10000, m );
71 printk( KERN_INFO "System bus clock: %d.%02dMHz \n",
72 S / 1000000, (S % 1000000) / 10000 );
75 return (t) ? (N/1000) : (L/1000);
79 * Return the current mem clock frequency in units of 10kHz as
80 * reflected by CCCR[A], B, and L
82 unsigned int get_memclk_frequency_10khz(void)
84 unsigned long ccsr, clkcfg;
85 unsigned int l, L, m, M;
89 cccr_a = CCCR & (1 << 25);
91 /* Read clkcfg register: it has turbo, b, half-turbo (and f) */
92 asm( "mrc\tp14, 0, %0, c6, c0, 0" : "=r" (clkcfg) );
93 b = clkcfg & (1 << 3);
96 m = (l <= 10) ? 1 : (l <= 20) ? 2 : 4;
99 M = (!cccr_a) ? (L/m) : ((b) ? L : (L/2));
105 * Return the current LCD clock frequency in units of 10kHz as
107 unsigned int get_lcdclk_frequency_10khz(void)
110 unsigned int l, L, k, K;
115 k = (l <= 7) ? 1 : (l <= 16) ? 2 : 4;
123 EXPORT_SYMBOL(get_clk_frequency_khz);
124 EXPORT_SYMBOL(get_memclk_frequency_10khz);
125 EXPORT_SYMBOL(get_lcdclk_frequency_10khz);
129 void pxa_cpu_pm_enter(suspend_state_t state)
131 extern void pxa_cpu_standby(void);
132 extern void pxa_cpu_suspend(unsigned int);
133 extern void pxa_cpu_resume(void);
135 if (state == PM_SUSPEND_STANDBY)
136 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER) | (1 << CKEN_LCD) | (1 << CKEN_PWM0);
138 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER);
140 /* ensure voltage-change sequencer not initiated, which hangs */
143 /* Clear edge-detect status register. */
147 case PM_SUSPEND_STANDBY:
151 /* set resume return address */
152 PSPR = virt_to_phys(pxa_cpu_resume);
153 pxa_cpu_suspend(PWRMODE_SLEEP);
158 static int pxa27x_pm_valid(suspend_state_t state)
160 return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY;
163 static struct pm_ops pxa27x_pm_ops = {
164 .enter = pxa_pm_enter,
165 .valid = pxa27x_pm_valid,
170 * device registration specific to PXA27x.
173 static u64 pxa27x_dmamask = 0xffffffffUL;
175 static struct resource pxa27x_ohci_resources[] = {
179 .flags = IORESOURCE_MEM,
184 .flags = IORESOURCE_IRQ,
188 static struct platform_device pxaohci_device = {
189 .name = "pxa27x-ohci",
192 .dma_mask = &pxa27x_dmamask,
193 .coherent_dma_mask = 0xffffffff,
195 .num_resources = ARRAY_SIZE(pxa27x_ohci_resources),
196 .resource = pxa27x_ohci_resources,
199 void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
201 pxaohci_device.dev.platform_data = info;
204 static struct resource i2c_power_resources[] = {
208 .flags = IORESOURCE_MEM,
212 .flags = IORESOURCE_IRQ,
216 static struct platform_device pxai2c_power_device = {
217 .name = "pxa2xx-i2c",
219 .resource = i2c_power_resources,
220 .num_resources = ARRAY_SIZE(i2c_power_resources),
223 static struct platform_device *devices[] __initdata = {
231 &pxai2c_power_device,
238 void __init pxa27x_init_irq(void)
242 pxa_init_irq_gpio(128);
245 static int __init pxa27x_init(void)
248 if (cpu_is_pxa27x()) {
249 if ((ret = pxa_init_dma(32)))
252 pm_set_ops(&pxa27x_pm_ops);
254 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
259 subsys_initcall(pxa27x_init);