summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-loki/common.c
blob: c0d2d9d12e743bccb39644c713a0e6661c538078 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
/*
 * arch/arm/mach-loki/common.c
 *
 * Core functions for Marvell Loki (88RC8480) SoCs
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/serial_8250.h>
#include <linux/mbus.h>
#include <linux/mv643xx_eth.h>
#include <asm/page.h>
#include <asm/timex.h>
#include <asm/mach/map.h>
#include <asm/mach/time.h>
#include <mach/loki.h>
#include <plat/orion_nand.h>
#include <plat/time.h>
#include "common.h"

/*****************************************************************************
 * I/O Address Mapping
 ****************************************************************************/
static struct map_desc loki_io_desc[] __initdata = {
	{
		.virtual	= LOKI_REGS_VIRT_BASE,
		.pfn		= __phys_to_pfn(LOKI_REGS_PHYS_BASE),
		.length		= LOKI_REGS_SIZE,
		.type		= MT_DEVICE,
	},
};

void __init loki_map_io(void)
{
	iotable_init(loki_io_desc, ARRAY_SIZE(loki_io_desc));
}


/*****************************************************************************
 * GE0
 ****************************************************************************/
struct mv643xx_eth_shared_platform_data loki_ge0_shared_data = {
	.t_clk		= LOKI_TCLK,
	.dram		= &loki_mbus_dram_info,
};

static struct resource loki_ge0_shared_resources[] = {
	{
		.name	= "ge0 base",
		.start	= GE0_PHYS_BASE + 0x2000,
		.end	= GE0_PHYS_BASE + 0x3fff,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device loki_ge0_shared = {
	.name		= MV643XX_ETH_SHARED_NAME,
	.id		= 0,
	.dev		= {
		.platform_data	= &loki_ge0_shared_data,
	},
	.num_resources	= 1,
	.resource	= loki_ge0_shared_resources,
};

static struct resource loki_ge0_resources[] = {
	{
		.name	= "ge0 irq",
		.start	= IRQ_LOKI_GBE_A_INT,
		.end	= IRQ_LOKI_GBE_A_INT,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device loki_ge0 = {
	.name		= MV643XX_ETH_NAME,
	.id		= 0,
	.num_resources	= 1,
	.resource	= loki_ge0_resources,
};

void __init loki_ge0_init(struct mv643xx_eth_platform_data *eth_data)
{
	eth_data->shared = &loki_ge0_shared;
	loki_ge0.dev.platform_data = eth_data;

	writel(0x00079220, GE0_VIRT_BASE + 0x20b0);
	platform_device_register(&loki_ge0_shared);
	platform_device_register(&loki_ge0);
}


/*****************************************************************************
 * GE1
 ****************************************************************************/
struct mv643xx_eth_shared_platform_data loki_ge1_shared_data = {
	.t_clk		= LOKI_TCLK,
	.dram		= &loki_mbus_dram_info,
};

static struct resource loki_ge1_shared_resources[] = {
	{
		.name	= "ge1 base",
		.start	= GE1_PHYS_BASE + 0x2000,
		.end	= GE1_PHYS_BASE + 0x3fff,
		.flags	= IORESOURCE_MEM,
	},
};

static struct platform_device loki_ge1_shared = {
	.name		= MV643XX_ETH_SHARED_NAME,
	.id		= 1,
	.dev		= {
		.platform_data	= &loki_ge1_shared_data,
	},
	.num_resources	= 1,
	.resource	= loki_ge1_shared_resources,
};

static struct resource loki_ge1_resources[] = {
	{
		.name	= "ge1 irq",
		.start	= IRQ_LOKI_GBE_B_INT,
		.end	= IRQ_LOKI_GBE_B_INT,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device loki_ge1 = {
	.name		= MV643XX_ETH_NAME,
	.id		= 1,
	.num_resources	= 1,
	.resource	= loki_ge1_resources,
};

void __init loki_ge1_init(struct mv643xx_eth_platform_data *eth_data)
{
	eth_data->shared = &loki_ge1_shared;
	loki_ge1.dev.platform_data = eth_data;

	writel(0x00079220, GE1_VIRT_BASE + 0x20b0);
	platform_device_register(&loki_ge1_shared);
	platform_device_register(&loki_ge1);
}


/*****************************************************************************
 * SAS/SATA
 ****************************************************************************/
static struct resource loki_sas_resources[] = {
	{
		.name	= "mvsas0 mem",
		.start	= SAS0_PHYS_BASE,
		.end	= SAS0_PHYS_BASE + 0x01ff,
		.flags	= IORESOURCE_MEM,
	}, {
		.name	= "mvsas0 irq",
		.start	= IRQ_LOKI_SAS_A,
		.end	= IRQ_LOKI_SAS_A,
		.flags	= IORESOURCE_IRQ,
	}, {
		.name	= "mvsas1 mem",
		.start	= SAS1_PHYS_BASE,
		.end	= SAS1_PHYS_BASE + 0x01ff,
		.flags	= IORESOURCE_MEM,
	}, {
		.name	= "mvsas1 irq",
		.start	= IRQ_LOKI_SAS_B,
		.end	= IRQ_LOKI_SAS_B,
		.flags	= IORESOURCE_IRQ,
	},
};

static struct platform_device loki_sas = {
	.name		= "mvsas",
	.id		= 0,
	.dev		= {
		.coherent_dma_mask	= 0xffffffff,
	},
	.num_resources	= ARRAY_SIZE(loki_sas_resources),
	.resource	= loki_sas_resources,
};

void __init loki_sas_init(void)
{
	writel(0x8300f707, DDR_REG(0x1424));
	platform_device_register(&loki_sas);
}


/*****************************************************************************
 * UART0
 ****************************************************************************/
static struct plat_serial8250_port loki_uart0_data[] = {
	{
		.mapbase	= UART0_PHYS_BASE,
		.membase	= (char *)UART0_VIRT_BASE,
		.irq		= IRQ_LOKI_UART0,
		.flags		= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
		.iotype		= UPIO_MEM,
		.regshift	= 2,
		.uartclk	= LOKI_TCLK,
	}, {
	},
};

static struct resource loki_uart0_resources[] = {
	{
		.start		= UART0_PHYS_BASE,
		.end		= UART0_PHYS_BASE + 0xff,
		.flags		= IORESOURCE_MEM,
	}, {
		.start		= IRQ_LOKI_UART0,
		.end		= IRQ_LOKI_UART0,
		.flags		= IORESOURCE_IRQ,
	},
};

static struct platform_device loki_uart0 = {
	.name			= "serial8250",
	.id			= 0,
	.dev			= {
		.platform_data	= loki_uart0_data,
	},
	.resource		= loki_uart0_resources,
	.num_resources		= ARRAY_SIZE(loki_uart0_resources),
};

void __init loki_uart0_init(void)
{
	platform_device_register(&loki_uart0);
}


/*****************************************************************************
 * UART1
 ****************************************************************************/
static struct plat_serial8250_port loki_uart1_data[] = {
	{
		.mapbase	= UART1_PHYS_BASE,
		.membase	= (char *)UART1_VIRT_BASE,
		.irq		= IRQ_LOKI_UART1,
		.flags		= UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
		.iotype		= UPIO_MEM,
		.regshift	= 2,
		.uartclk	= LOKI_TCLK,
	}, {
	},
};

static struct resource loki_uart1_resources[] = {
	{
		.start		= UART1_PHYS_BASE,
		.end		= UART1_PHYS_BASE + 0xff,
		.flags		= IORESOURCE_MEM,
	}, {
		.start		= IRQ_LOKI_UART1,
		.end		= IRQ_LOKI_UART1,
		.flags		= IORESOURCE_IRQ,
	},
};

static struct platform_device loki_uart1 = {
	.name			= "serial8250",
	.id			= 1,
	.dev			= {
		.platform_data	= loki_uart1_data,
	},
	.resource		= loki_uart1_resources,
	.num_resources		= ARRAY_SIZE(loki_uart1_resources),
};

void __init loki_uart1_init(void)
{
	platform_device_register(&loki_uart1);
}


/*****************************************************************************
 * Time handling
 ****************************************************************************/
static void loki_timer_init(void)
{
	orion_time_init(IRQ_LOKI_BRIDGE, LOKI_TCLK);
}

struct sys_timer loki_timer = {
	.init = loki_timer_init,
};


/*****************************************************************************
 * General
 ****************************************************************************/
void __init loki_init(void)
{
	printk(KERN_INFO "Loki ID: 88RC8480. TCLK=%d.\n", LOKI_TCLK);

	loki_setup_cpu_mbus();
}
OpenPOWER on IntegriCloud