Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6] / arch / arm / mach-loki / common.c
1 /*
2  * arch/arm/mach-loki/common.c
3  *
4  * Core functions for Marvell Loki (88RC8480) SoCs
5  *
6  * This file is licensed under the terms of the GNU General Public
7  * License version 2.  This program is licensed "as is" without any
8  * warranty of any kind, whether express or implied.
9  */
10
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/platform_device.h>
14 #include <linux/serial_8250.h>
15 #include <linux/mbus.h>
16 #include <linux/mv643xx_eth.h>
17 #include <asm/page.h>
18 #include <asm/timex.h>
19 #include <asm/mach/map.h>
20 #include <asm/mach/time.h>
21 #include <mach/loki.h>
22 #include <plat/orion_nand.h>
23 #include <plat/time.h>
24 #include "common.h"
25
26 /*****************************************************************************
27  * I/O Address Mapping
28  ****************************************************************************/
29 static struct map_desc loki_io_desc[] __initdata = {
30         {
31                 .virtual        = LOKI_REGS_VIRT_BASE,
32                 .pfn            = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
33                 .length         = LOKI_REGS_SIZE,
34                 .type           = MT_DEVICE,
35         },
36 };
37
38 void __init loki_map_io(void)
39 {
40         iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
41 }
42
43
44 /*****************************************************************************
45  * GE0
46  ****************************************************************************/
47 struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
48         .t_clk          = LOKI_TCLK,
49         .dram           = &loki_mbus_dram_info,
50 };
51
52 static struct resource loki_ge0_shared_resources[] = {
53         {
54                 .name   = "ge0 base",
55                 .start  = GE0_PHYS_BASE + 0x2000,
56                 .end    = GE0_PHYS_BASE + 0x3fff,
57                 .flags  = IORESOURCE_MEM,
58         },
59 };
60
61 static struct platform_device loki_ge0_shared = {
62         .name           = MV643XX_ETH_SHARED_NAME,
63         .id             = 0,
64         .dev            = {
65                 .platform_data  = &loki_ge0_shared_data,
66         },
67         .num_resources  = 1,
68         .resource       = loki_ge0_shared_resources,
69 };
70
71 static struct resource loki_ge0_resources[] = {
72         {
73                 .name   = "ge0 irq",
74                 .start  = IRQ_LOKI_GBE_A_INT,
75                 .end    = IRQ_LOKI_GBE_A_INT,
76                 .flags  = IORESOURCE_IRQ,
77         },
78 };
79
80 static struct platform_device loki_ge0 = {
81         .name           = MV643XX_ETH_NAME,
82         .id             = 0,
83         .num_resources  = 1,
84         .resource       = loki_ge0_resources,
85 };
86
87 void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
88 {
89         eth_data->shared = &loki_ge0_shared;
90         loki_ge0.dev.platform_data = eth_data;
91
92         writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
93         platform_device_register(&loki_ge0_shared);
94         platform_device_register(&loki_ge0);
95 }
96
97
98 /*****************************************************************************
99  * GE1
100  ****************************************************************************/
101 struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
102         .t_clk          = LOKI_TCLK,
103         .dram           = &loki_mbus_dram_info,
104 };
105
106 static struct resource loki_ge1_shared_resources[] = {
107         {
108                 .name   = "ge1 base",
109                 .start  = GE1_PHYS_BASE + 0x2000,
110                 .end    = GE1_PHYS_BASE + 0x3fff,
111                 .flags  = IORESOURCE_MEM,
112         },
113 };
114
115 static struct platform_device loki_ge1_shared = {
116         .name           = MV643XX_ETH_SHARED_NAME,
117         .id             = 1,
118         .dev            = {
119                 .platform_data  = &loki_ge1_shared_data,
120         },
121         .num_resources  = 1,
122         .resource       = loki_ge1_shared_resources,
123 };
124
125 static struct resource loki_ge1_resources[] = {
126         {
127                 .name   = "ge1 irq",
128                 .start  = IRQ_LOKI_GBE_B_INT,
129                 .end    = IRQ_LOKI_GBE_B_INT,
130                 .flags  = IORESOURCE_IRQ,
131         },
132 };
133
134 static struct platform_device loki_ge1 = {
135         .name           = MV643XX_ETH_NAME,
136         .id             = 1,
137         .num_resources  = 1,
138         .resource       = loki_ge1_resources,
139 };
140
141 void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
142 {
143         eth_data->shared = &loki_ge1_shared;
144         loki_ge1.dev.platform_data = eth_data;
145
146         writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
147         platform_device_register(&loki_ge1_shared);
148         platform_device_register(&loki_ge1);
149 }
150
151
152 /*****************************************************************************
153  * SAS/SATA
154  ****************************************************************************/
155 static struct resource loki_sas_resources[] = {
156         {
157                 .name   = "mvsas0 mem",
158                 .start  = SAS0_PHYS_BASE,
159                 .end    = SAS0_PHYS_BASE + 0x01ff,
160                 .flags  = IORESOURCE_MEM,
161         }, {
162                 .name   = "mvsas0 irq",
163                 .start  = IRQ_LOKI_SAS_A,
164                 .end    = IRQ_LOKI_SAS_A,
165                 .flags  = IORESOURCE_IRQ,
166         }, {
167                 .name   = "mvsas1 mem",
168                 .start  = SAS1_PHYS_BASE,
169                 .end    = SAS1_PHYS_BASE + 0x01ff,
170                 .flags  = IORESOURCE_MEM,
171         }, {
172                 .name   = "mvsas1 irq",
173                 .start  = IRQ_LOKI_SAS_B,
174                 .end    = IRQ_LOKI_SAS_B,
175                 .flags  = IORESOURCE_IRQ,
176         },
177 };
178
179 static struct platform_device loki_sas = {
180         .name           = "mvsas",
181         .id             = 0,
182         .dev            = {
183                 .coherent_dma_mask      = 0xffffffff,
184         },
185         .num_resources  = ARRAY_SIZE(loki_sas_resources),
186         .resource       = loki_sas_resources,
187 };
188
189 void __init loki_sas_init(void)
190 {
191         writel(0x8300f707, DDR_REG(0x1424));
192         platform_device_register(&loki_sas);
193 }
194
195
196 /*****************************************************************************
197  * UART0
198  ****************************************************************************/
199 static struct plat_serial8250_port loki_uart0_data[] = {
200         {
201                 .mapbase        = UART0_PHYS_BASE,
202                 .membase        = (char *)UART0_VIRT_BASE,
203                 .irq            = IRQ_LOKI_UART0,
204                 .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
205                 .iotype         = UPIO_MEM,
206                 .regshift       = 2,
207                 .uartclk        = LOKI_TCLK,
208         }, {
209         },
210 };
211
212 static struct resource loki_uart0_resources[] = {
213         {
214                 .start          = UART0_PHYS_BASE,
215                 .end            = UART0_PHYS_BASE + 0xff,
216                 .flags          = IORESOURCE_MEM,
217         }, {
218                 .start          = IRQ_LOKI_UART0,
219                 .end            = IRQ_LOKI_UART0,
220                 .flags          = IORESOURCE_IRQ,
221         },
222 };
223
224 static struct platform_device loki_uart0 = {
225         .name                   = "serial8250",
226         .id                     = 0,
227         .dev                    = {
228                 .platform_data  = loki_uart0_data,
229         },
230         .resource               = loki_uart0_resources,
231         .num_resources          = ARRAY_SIZE(loki_uart0_resources),
232 };
233
234 void __init loki_uart0_init(void)
235 {
236         platform_device_register(&loki_uart0);
237 }
238
239
240 /*****************************************************************************
241  * UART1
242  ****************************************************************************/
243 static struct plat_serial8250_port loki_uart1_data[] = {
244         {
245                 .mapbase        = UART1_PHYS_BASE,
246                 .membase        = (char *)UART1_VIRT_BASE,
247                 .irq            = IRQ_LOKI_UART1,
248                 .flags          = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
249                 .iotype         = UPIO_MEM,
250                 .regshift       = 2,
251                 .uartclk        = LOKI_TCLK,
252         }, {
253         },
254 };
255
256 static struct resource loki_uart1_resources[] = {
257         {
258                 .start          = UART1_PHYS_BASE,
259                 .end            = UART1_PHYS_BASE + 0xff,
260                 .flags          = IORESOURCE_MEM,
261         }, {
262                 .start          = IRQ_LOKI_UART1,
263                 .end            = IRQ_LOKI_UART1,
264                 .flags          = IORESOURCE_IRQ,
265         },
266 };
267
268 static struct platform_device loki_uart1 = {
269         .name                   = "serial8250",
270         .id                     = 1,
271         .dev                    = {
272                 .platform_data  = loki_uart1_data,
273         },
274         .resource               = loki_uart1_resources,
275         .num_resources          = ARRAY_SIZE(loki_uart1_resources),
276 };
277
278 void __init loki_uart1_init(void)
279 {
280         platform_device_register(&loki_uart1);
281 }
282
283
284 /*****************************************************************************
285  * Time handling
286  ****************************************************************************/
287 static void loki_timer_init(void)
288 {
289         orion_time_init(IRQ_LOKI_BRIDGE, LOKI_TCLK);
290 }
291
292 struct sys_timer loki_timer = {
293         .init = loki_timer_init,
294 };
295
296
297 /*****************************************************************************
298  * General
299  ****************************************************************************/
300 void __init loki_init(void)
301 {
302         printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
303
304         loki_setup_cpu_mbus();
305 }