7ec80ddf |
1 | /* |
2 | * linux/arch/arm/mach-w90x900/w90p910.c |
3 | * |
4 | * Based on linux/arch/arm/plat-s3c24xx/s3c244x.c by Ben Dooks |
5 | * |
6 | * Copyright (c) 2008 Nuvoton technology corporation |
7 | * All rights reserved. |
8 | * |
9 | * Wan ZongShun <mcuos.com@gmail.com> |
10 | * |
11 | * W90P910 cpu support |
12 | * |
13 | * This program is free software; you can redistribute it and/or modify |
14 | * it under the terms of the GNU General Public License as published by |
15 | * the Free Software Foundation; either version 2 of the License, or |
16 | * (at your option) any later version. |
17 | * |
18 | */ |
19 | |
20 | #include <linux/kernel.h> |
21 | #include <linux/types.h> |
22 | #include <linux/interrupt.h> |
23 | #include <linux/list.h> |
24 | #include <linux/timer.h> |
25 | #include <linux/init.h> |
26 | #include <linux/platform_device.h> |
27 | #include <linux/io.h> |
28 | |
29 | #include <asm/mach/arch.h> |
30 | #include <asm/mach/map.h> |
31 | #include <asm/mach/irq.h> |
32 | #include <asm/irq.h> |
33 | |
34 | #include <mach/hardware.h> |
35 | #include <mach/regs-serial.h> |
36 | |
37 | #include "cpu.h" |
38 | |
39 | /*W90P910 has five uarts*/ |
40 | |
41 | #define MAX_UART_COUNT 5 |
42 | static int uart_count; |
43 | static struct platform_device *uart_devs[MAX_UART_COUNT-1]; |
44 | |
45 | /* Initial IO mappings */ |
46 | |
47 | static struct map_desc w90p910_iodesc[] __initdata = { |
48 | IODESC_ENT(IRQ), |
49 | IODESC_ENT(GCR), |
50 | IODESC_ENT(UART), |
51 | IODESC_ENT(TIMER), |
52 | IODESC_ENT(EBI), |
53 | /*IODESC_ENT(LCD),*/ |
54 | }; |
55 | |
56 | /*Init the dev resource*/ |
57 | |
58 | static W90X900_RES(UART0); |
59 | static W90X900_RES(UART1); |
60 | static W90X900_RES(UART2); |
61 | static W90X900_RES(UART3); |
62 | static W90X900_RES(UART4); |
63 | static W90X900_DEVICE(uart0, UART0, 0, "w90x900-uart"); |
64 | static W90X900_DEVICE(uart1, UART1, 1, "w90x900-uart"); |
65 | static W90X900_DEVICE(uart2, UART2, 2, "w90x900-uart"); |
66 | static W90X900_DEVICE(uart3, UART3, 3, "w90x900-uart"); |
67 | static W90X900_DEVICE(uart4, UART4, 4, "w90x900-uart"); |
68 | |
69 | static struct platform_device *uart_devices[] __initdata = { |
70 | &w90x900_uart0, |
71 | &w90x900_uart1, |
72 | &w90x900_uart2, |
73 | &w90x900_uart3, |
74 | &w90x900_uart4 |
75 | }; |
76 | |
77 | /*Init W90P910 uart device*/ |
78 | |
79 | void __init w90p910_init_uarts(struct w90x900_uartcfg *cfg, int no) |
80 | { |
81 | struct platform_device *platdev; |
82 | int uart, uartdev; |
83 | |
84 | /*By min() to judge count of uart be used indeed*/ |
85 | |
86 | uartdev = ARRAY_SIZE(uart_devices); |
87 | no = min(uartdev, no); |
88 | |
89 | for (uart = 0; uart < no; uart++, cfg++) { |
90 | if (cfg->hwport != uart) |
91 | printk(KERN_ERR "w90x900_uartcfg[%d] error\n", uart); |
92 | platdev = uart_devices[cfg->hwport]; |
93 | uart_devs[uart] = platdev; |
94 | platdev->dev.platform_data = cfg; |
95 | } |
96 | uart_count = uart; |
97 | } |
98 | |
99 | /*Init W90P910 evb io*/ |
100 | |
101 | void __init w90p910_map_io(struct map_desc *mach_desc, int mach_size) |
102 | { |
103 | unsigned long idcode = 0x0; |
104 | |
105 | iotable_init(w90p910_iodesc, ARRAY_SIZE(w90p910_iodesc)); |
106 | |
107 | idcode = __raw_readl(W90X900PDID); |
108 | if (idcode != W90P910_CPUID) |
109 | printk(KERN_ERR "CPU type 0x%08lx is not W90P910\n", idcode); |
110 | } |
111 | |
112 | /*Init W90P910 clock*/ |
113 | |
114 | void __init w90p910_init_clocks(int xtal) |
115 | { |
116 | } |
117 | |
118 | static int __init w90p910_init_cpu(void) |
119 | { |
120 | return 0; |
121 | } |
122 | |
123 | static int __init w90x900_arch_init(void) |
124 | { |
125 | int ret; |
126 | |
127 | ret = w90p910_init_cpu(); |
128 | if (ret != 0) |
129 | return ret; |
130 | |
131 | return platform_add_devices(uart_devs, uart_count); |
132 | |
133 | } |
134 | arch_initcall(w90x900_arch_init); |