ARM: orion: Consolidate the creation of the uart platform data.
[pandora-kernel.git] / 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 <linux/dma-mapping.h>
18 #include <asm/page.h>
19 #include <asm/timex.h>
20 #include <asm/mach/map.h>
21 #include <asm/mach/time.h>
22 #include <mach/bridge-regs.h>
23 #include <mach/loki.h>
24 #include <plat/orion_nand.h>
25 #include <plat/time.h>
26 #include <plat/common.h>
27 #include "common.h"
28
29 /*****************************************************************************
30  * I/O Address Mapping
31  ****************************************************************************/
32 static struct map_desc loki_io_desc[] __initdata = {
33         {
34                 .virtual        = LOKI_REGS_VIRT_BASE,
35                 .pfn            = __phys_to_pfn(LOKI_REGS_PHYS_BASE),
36                 .length         = LOKI_REGS_SIZE,
37                 .type           = MT_DEVICE,
38         },
39 };
40
41 void __init loki_map_io(void)
42 {
43         iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
44 }
45
46
47 /*****************************************************************************
48  * GE0
49  ****************************************************************************/
50 struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
51         .t_clk          = LOKI_TCLK,
52         .dram           = &loki_mbus_dram_info,
53 };
54
55 static struct resource loki_ge0_shared_resources[] = {
56         {
57                 .name   = "ge0 base",
58                 .start  = GE0_PHYS_BASE + 0x2000,
59                 .end    = GE0_PHYS_BASE + SZ_16K - 1,
60                 .flags  = IORESOURCE_MEM,
61         },
62 };
63
64 static struct platform_device loki_ge0_shared = {
65         .name           = MV643XX_ETH_SHARED_NAME,
66         .id             = 0,
67         .dev            = {
68                 .platform_data  = &loki_ge0_shared_data,
69         },
70         .num_resources  = 1,
71         .resource       = loki_ge0_shared_resources,
72 };
73
74 static struct resource loki_ge0_resources[] = {
75         {
76                 .name   = "ge0 irq",
77                 .start  = IRQ_LOKI_GBE_A_INT,
78                 .end    = IRQ_LOKI_GBE_A_INT,
79                 .flags  = IORESOURCE_IRQ,
80         },
81 };
82
83 static struct platform_device loki_ge0 = {
84         .name           = MV643XX_ETH_NAME,
85         .id             = 0,
86         .num_resources  = 1,
87         .resource       = loki_ge0_resources,
88         .dev            = {
89                 .coherent_dma_mask      = DMA_BIT_MASK(32),
90         },
91 };
92
93 void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
94 {
95         eth_data->shared = &loki_ge0_shared;
96         loki_ge0.dev.platform_data = eth_data;
97
98         writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
99         platform_device_register(&loki_ge0_shared);
100         platform_device_register(&loki_ge0);
101 }
102
103
104 /*****************************************************************************
105  * GE1
106  ****************************************************************************/
107 struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
108         .t_clk          = LOKI_TCLK,
109         .dram           = &loki_mbus_dram_info,
110 };
111
112 static struct resource loki_ge1_shared_resources[] = {
113         {
114                 .name   = "ge1 base",
115                 .start  = GE1_PHYS_BASE + 0x2000,
116                 .end    = GE1_PHYS_BASE + SZ_16K - 1,
117                 .flags  = IORESOURCE_MEM,
118         },
119 };
120
121 static struct platform_device loki_ge1_shared = {
122         .name           = MV643XX_ETH_SHARED_NAME,
123         .id             = 1,
124         .dev            = {
125                 .platform_data  = &loki_ge1_shared_data,
126         },
127         .num_resources  = 1,
128         .resource       = loki_ge1_shared_resources,
129 };
130
131 static struct resource loki_ge1_resources[] = {
132         {
133                 .name   = "ge1 irq",
134                 .start  = IRQ_LOKI_GBE_B_INT,
135                 .end    = IRQ_LOKI_GBE_B_INT,
136                 .flags  = IORESOURCE_IRQ,
137         },
138 };
139
140 static struct platform_device loki_ge1 = {
141         .name           = MV643XX_ETH_NAME,
142         .id             = 1,
143         .num_resources  = 1,
144         .resource       = loki_ge1_resources,
145         .dev            = {
146                 .coherent_dma_mask      = DMA_BIT_MASK(32),
147         },
148 };
149
150 void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
151 {
152         eth_data->shared = &loki_ge1_shared;
153         loki_ge1.dev.platform_data = eth_data;
154
155         writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
156         platform_device_register(&loki_ge1_shared);
157         platform_device_register(&loki_ge1);
158 }
159
160
161 /*****************************************************************************
162  * SAS/SATA
163  ****************************************************************************/
164 static struct resource loki_sas_resources[] = {
165         {
166                 .name   = "mvsas0 mem",
167                 .start  = SAS0_PHYS_BASE,
168                 .end    = SAS0_PHYS_BASE + 0x01ff,
169                 .flags  = IORESOURCE_MEM,
170         }, {
171                 .name   = "mvsas0 irq",
172                 .start  = IRQ_LOKI_SAS_A,
173                 .end    = IRQ_LOKI_SAS_A,
174                 .flags  = IORESOURCE_IRQ,
175         }, {
176                 .name   = "mvsas1 mem",
177                 .start  = SAS1_PHYS_BASE,
178                 .end    = SAS1_PHYS_BASE + 0x01ff,
179                 .flags  = IORESOURCE_MEM,
180         }, {
181                 .name   = "mvsas1 irq",
182                 .start  = IRQ_LOKI_SAS_B,
183                 .end    = IRQ_LOKI_SAS_B,
184                 .flags  = IORESOURCE_IRQ,
185         },
186 };
187
188 static struct platform_device loki_sas = {
189         .name           = "mvsas",
190         .id             = 0,
191         .dev            = {
192                 .coherent_dma_mask      = DMA_BIT_MASK(32),
193         },
194         .num_resources  = ARRAY_SIZE(loki_sas_resources),
195         .resource       = loki_sas_resources,
196 };
197
198 void __init loki_sas_init(void)
199 {
200         writel(0x8300f707, DDR_REG(0x1424));
201         platform_device_register(&loki_sas);
202 }
203
204
205 /*****************************************************************************
206  * UART0
207  ****************************************************************************/
208 void __init loki_uart0_init(void)
209 {
210         orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
211                          IRQ_LOKI_UART0, LOKI_TCLK);
212 }
213
214 /*****************************************************************************
215  * UART1
216  ****************************************************************************/
217 void __init loki_uart1_init(void)
218 {
219         orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
220                          IRQ_LOKI_UART1, LOKI_TCLK);
221 }
222
223
224 /*****************************************************************************
225  * Time handling
226  ****************************************************************************/
227 void __init loki_init_early(void)
228 {
229         orion_time_set_base(TIMER_VIRT_BASE);
230 }
231
232 static void loki_timer_init(void)
233 {
234         orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
235                         IRQ_LOKI_BRIDGE, LOKI_TCLK);
236 }
237
238 struct sys_timer loki_timer = {
239         .init = loki_timer_init,
240 };
241
242
243 /*****************************************************************************
244  * General
245  ****************************************************************************/
246 void __init loki_init(void)
247 {
248         printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
249
250         loki_setup_cpu_mbus();
251 }