acpiphp: Execute ACPI _REG method for hotadded devices
[linux/fpc-iii.git] / arch / arm / mach-w90x900 / cpu.c
blob20dc0c96214dcae4e93bb67910e5c0027eb6cf8f
1 /*
2 * linux/arch/arm/mach-w90x900/cpu.c
4 * Copyright (c) 2009 Nuvoton corporation.
6 * Wan ZongShun <mcuos.com@gmail.com>
8 * NUC900 series cpu common support
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation;version 2 of the License.
16 #include <linux/kernel.h>
17 #include <linux/types.h>
18 #include <linux/interrupt.h>
19 #include <linux/list.h>
20 #include <linux/timer.h>
21 #include <linux/init.h>
22 #include <linux/platform_device.h>
23 #include <linux/io.h>
24 #include <linux/serial_8250.h>
25 #include <linux/delay.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
30 #include <asm/irq.h>
32 #include <mach/hardware.h>
33 #include <mach/regs-serial.h>
34 #include <mach/regs-clock.h>
35 #include <mach/regs-ebi.h>
37 #include "cpu.h"
38 #include "clock.h"
40 /* Initial IO mappings */
42 static struct map_desc nuc900_iodesc[] __initdata = {
43 IODESC_ENT(IRQ),
44 IODESC_ENT(GCR),
45 IODESC_ENT(UART),
46 IODESC_ENT(TIMER),
47 IODESC_ENT(EBI),
50 /* Initial clock declarations. */
51 static DEFINE_CLK(lcd, 0);
52 static DEFINE_CLK(audio, 1);
53 static DEFINE_CLK(fmi, 4);
54 static DEFINE_SUBCLK(ms, 0);
55 static DEFINE_SUBCLK(sd, 1);
56 static DEFINE_CLK(dmac, 5);
57 static DEFINE_CLK(atapi, 6);
58 static DEFINE_CLK(emc, 7);
59 static DEFINE_SUBCLK(rmii, 2);
60 static DEFINE_CLK(usbd, 8);
61 static DEFINE_CLK(usbh, 9);
62 static DEFINE_CLK(g2d, 10);;
63 static DEFINE_CLK(pwm, 18);
64 static DEFINE_CLK(ps2, 24);
65 static DEFINE_CLK(kpi, 25);
66 static DEFINE_CLK(wdt, 26);
67 static DEFINE_CLK(gdma, 27);
68 static DEFINE_CLK(adc, 28);
69 static DEFINE_CLK(usi, 29);
70 static DEFINE_CLK(ext, 0);
72 static struct clk_lookup nuc900_clkregs[] = {
73 DEF_CLKLOOK(&clk_lcd, "nuc900-lcd", NULL),
74 DEF_CLKLOOK(&clk_audio, "nuc900-audio", NULL),
75 DEF_CLKLOOK(&clk_fmi, "nuc900-fmi", NULL),
76 DEF_CLKLOOK(&clk_ms, "nuc900-fmi", "MS"),
77 DEF_CLKLOOK(&clk_sd, "nuc900-fmi", "SD"),
78 DEF_CLKLOOK(&clk_dmac, "nuc900-dmac", NULL),
79 DEF_CLKLOOK(&clk_atapi, "nuc900-atapi", NULL),
80 DEF_CLKLOOK(&clk_emc, "nuc900-emc", NULL),
81 DEF_CLKLOOK(&clk_rmii, "nuc900-emc", "RMII"),
82 DEF_CLKLOOK(&clk_usbd, "nuc900-usbd", NULL),
83 DEF_CLKLOOK(&clk_usbh, "nuc900-usbh", NULL),
84 DEF_CLKLOOK(&clk_g2d, "nuc900-g2d", NULL),
85 DEF_CLKLOOK(&clk_pwm, "nuc900-pwm", NULL),
86 DEF_CLKLOOK(&clk_ps2, "nuc900-ps2", NULL),
87 DEF_CLKLOOK(&clk_kpi, "nuc900-kpi", NULL),
88 DEF_CLKLOOK(&clk_wdt, "nuc900-wdt", NULL),
89 DEF_CLKLOOK(&clk_gdma, "nuc900-gdma", NULL),
90 DEF_CLKLOOK(&clk_adc, "nuc900-adc", NULL),
91 DEF_CLKLOOK(&clk_usi, "nuc900-spi", NULL),
92 DEF_CLKLOOK(&clk_ext, NULL, "ext"),
95 /* Initial serial platform data */
97 struct plat_serial8250_port nuc900_uart_data[] = {
98 NUC900_8250PORT(UART0),
99 {},
102 struct platform_device nuc900_serial_device = {
103 .name = "serial8250",
104 .id = PLAT8250_DEV_PLATFORM,
105 .dev = {
106 .platform_data = nuc900_uart_data,
110 /*Set NUC900 series cpu frequence*/
111 static int __init nuc900_set_clkval(unsigned int cpufreq)
113 unsigned int pllclk, ahbclk, apbclk, val;
115 pllclk = 0;
116 ahbclk = 0;
117 apbclk = 0;
119 switch (cpufreq) {
120 case 66:
121 pllclk = PLL_66MHZ;
122 ahbclk = AHB_CPUCLK_1_1;
123 apbclk = APB_AHB_1_2;
124 break;
126 case 100:
127 pllclk = PLL_100MHZ;
128 ahbclk = AHB_CPUCLK_1_1;
129 apbclk = APB_AHB_1_2;
130 break;
132 case 120:
133 pllclk = PLL_120MHZ;
134 ahbclk = AHB_CPUCLK_1_2;
135 apbclk = APB_AHB_1_2;
136 break;
138 case 166:
139 pllclk = PLL_166MHZ;
140 ahbclk = AHB_CPUCLK_1_2;
141 apbclk = APB_AHB_1_2;
142 break;
144 case 200:
145 pllclk = PLL_200MHZ;
146 ahbclk = AHB_CPUCLK_1_2;
147 apbclk = APB_AHB_1_2;
148 break;
151 __raw_writel(pllclk, REG_PLLCON0);
153 val = __raw_readl(REG_CLKDIV);
154 val &= ~(0x03 << 24 | 0x03 << 26);
155 val |= (ahbclk << 24 | apbclk << 26);
156 __raw_writel(val, REG_CLKDIV);
158 return 0;
160 static int __init nuc900_set_cpufreq(char *str)
162 unsigned long cpufreq, val;
164 if (!*str)
165 return 0;
167 strict_strtoul(str, 0, &cpufreq);
169 nuc900_clock_source(NULL, "ext");
171 nuc900_set_clkval(cpufreq);
173 mdelay(1);
175 val = __raw_readl(REG_CKSKEW);
176 val &= ~0xff;
177 val |= DEFAULTSKEW;
178 __raw_writel(val, REG_CKSKEW);
180 nuc900_clock_source(NULL, "pll0");
182 return 1;
185 __setup("cpufreq=", nuc900_set_cpufreq);
187 /*Init NUC900 evb io*/
189 void __init nuc900_map_io(struct map_desc *mach_desc, int mach_size)
191 unsigned long idcode = 0x0;
193 iotable_init(mach_desc, mach_size);
194 iotable_init(nuc900_iodesc, ARRAY_SIZE(nuc900_iodesc));
196 idcode = __raw_readl(NUC900PDID);
197 if (idcode == NUC910_CPUID)
198 printk(KERN_INFO "CPU type 0x%08lx is NUC910\n", idcode);
199 else if (idcode == NUC920_CPUID)
200 printk(KERN_INFO "CPU type 0x%08lx is NUC920\n", idcode);
201 else if (idcode == NUC950_CPUID)
202 printk(KERN_INFO "CPU type 0x%08lx is NUC950\n", idcode);
203 else if (idcode == NUC960_CPUID)
204 printk(KERN_INFO "CPU type 0x%08lx is NUC960\n", idcode);
207 /*Init NUC900 clock*/
209 void __init nuc900_init_clocks(void)
211 clks_register(nuc900_clkregs, ARRAY_SIZE(nuc900_clkregs));