blob: c07180492bf03065af9c02de59b4b7bf36bc50d7 [file] [log] [blame]
Lennert Buytenhek777f9be2008-06-22 22:45:02 +02001/*
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>
Andrew Lunn5c602552011-05-15 13:32:40 +020017#include <linux/dma-mapping.h>
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020018#include <asm/page.h>
19#include <asm/timex.h>
20#include <asm/mach/map.h>
21#include <asm/mach/time.h>
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +020022#include <mach/bridge-regs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/loki.h>
Lennert Buytenhek6f088f12008-08-09 13:44:58 +020024#include <plat/orion_nand.h>
25#include <plat/time.h>
Andrew Lunn28a2b452011-05-15 13:32:41 +020026#include <plat/common.h>
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020027#include "common.h"
28
29/*****************************************************************************
30 * I/O Address Mapping
31 ****************************************************************************/
32static 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
41void __init loki_map_io(void)
42{
43 iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
44}
45
46
47/*****************************************************************************
48 * GE0
49 ****************************************************************************/
50struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
51 .t_clk = LOKI_TCLK,
52 .dram = &loki_mbus_dram_info,
53};
54
55static struct resource loki_ge0_shared_resources[] = {
56 {
57 .name = "ge0 base",
58 .start = GE0_PHYS_BASE + 0x2000,
Andrew Lunn5c602552011-05-15 13:32:40 +020059 .end = GE0_PHYS_BASE + SZ_16K - 1,
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020060 .flags = IORESOURCE_MEM,
61 },
62};
63
64static 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
74static 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
83static struct platform_device loki_ge0 = {
84 .name = MV643XX_ETH_NAME,
85 .id = 0,
86 .num_resources = 1,
87 .resource = loki_ge0_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -040088 .dev = {
Andrew Lunn5c602552011-05-15 13:32:40 +020089 .coherent_dma_mask = DMA_BIT_MASK(32),
Nicolas Pitrea49a0182009-05-22 16:53:40 -040090 },
Lennert Buytenhek777f9be2008-06-22 22:45:02 +020091};
92
93void __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 ****************************************************************************/
107struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
108 .t_clk = LOKI_TCLK,
109 .dram = &loki_mbus_dram_info,
110};
111
112static struct resource loki_ge1_shared_resources[] = {
113 {
114 .name = "ge1 base",
115 .start = GE1_PHYS_BASE + 0x2000,
Andrew Lunn5c602552011-05-15 13:32:40 +0200116 .end = GE1_PHYS_BASE + SZ_16K - 1,
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200117 .flags = IORESOURCE_MEM,
118 },
119};
120
121static 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
131static 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
140static struct platform_device loki_ge1 = {
141 .name = MV643XX_ETH_NAME,
142 .id = 1,
143 .num_resources = 1,
144 .resource = loki_ge1_resources,
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400145 .dev = {
Andrew Lunn5c602552011-05-15 13:32:40 +0200146 .coherent_dma_mask = DMA_BIT_MASK(32),
Nicolas Pitrea49a0182009-05-22 16:53:40 -0400147 },
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200148};
149
150void __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 ****************************************************************************/
164static 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
188static struct platform_device loki_sas = {
189 .name = "mvsas",
190 .id = 0,
191 .dev = {
Andrew Lunn5c602552011-05-15 13:32:40 +0200192 .coherent_dma_mask = DMA_BIT_MASK(32),
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200193 },
194 .num_resources = ARRAY_SIZE(loki_sas_resources),
195 .resource = loki_sas_resources,
196};
197
198void __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 ****************************************************************************/
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200208void __init loki_uart0_init(void)
209{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200210 orion_uart0_init(UART0_VIRT_BASE, UART0_PHYS_BASE,
211 IRQ_LOKI_UART0, LOKI_TCLK);
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200212}
213
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200214/*****************************************************************************
215 * UART1
216 ****************************************************************************/
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200217void __init loki_uart1_init(void)
218{
Andrew Lunn28a2b452011-05-15 13:32:41 +0200219 orion_uart1_init(UART1_VIRT_BASE, UART1_PHYS_BASE,
220 IRQ_LOKI_UART1, LOKI_TCLK);
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200221}
222
223
224/*****************************************************************************
225 * Time handling
226 ****************************************************************************/
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200227void __init loki_init_early(void)
228{
229 orion_time_set_base(TIMER_VIRT_BASE);
230}
231
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200232static void loki_timer_init(void)
233{
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200234 orion_time_init(BRIDGE_VIRT_BASE, BRIDGE_INT_TIMER1_CLR,
235 IRQ_LOKI_BRIDGE, LOKI_TCLK);
Lennert Buytenhek777f9be2008-06-22 22:45:02 +0200236}
237
238struct sys_timer loki_timer = {
239 .init = loki_timer_init,
240};
241
242
243/*****************************************************************************
244 * General
245 ****************************************************************************/
246void __init loki_init(void)
247{
248 printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);
249
250 loki_setup_cpu_mbus();
251}