aboutsummaryrefslogtreecommitdiff
path: root/arch/arm/mach-pnx4008/core.c
blob: 4cfb40b2ec19f2b866da3e9e3b24b7a3451bcc66 (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
/*
 * arch/arm/mach-pnx4008/core.c
 *
 * PNX4008 core startup code
 *
 * Authors: Vitaly Wool, Dmitry Chigirev,
 * Grigory Tolstolytkin, Dmitry Pervushin <source@mvista.com>
 *
 * Based on reference code received from Philips:
 * Copyright (C) 2003 Philips Semiconductors
 *
 * 2005 (c) MontaVista Software, Inc. 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/types.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/serial_8250.h>
#include <linux/device.h>
#include <linux/spi/spi.h>
#include <linux/io.h>

#include <mach/hardware.h>
#include <asm/setup.h>
#include <asm/mach-types.h>
#include <asm/pgtable.h>
#include <asm/page.h>
#include <asm/system.h>

#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/time.h>

#include <mach/irq.h>
#include <mach/clock.h>
#include <mach/dma.h>

struct resource spipnx_0_resources[] = {
	{
		.start = PNX4008_SPI1_BASE,
		.end = PNX4008_SPI1_BASE + SZ_4K,
		.flags = IORESOURCE_MEM,
	}, {
		.start = PER_SPI1_REC_XMIT,
		.flags = IORESOURCE_DMA,
	}, {
		.start = SPI1_INT,
		.flags = IORESOURCE_IRQ,
	}, {
		.flags = 0,
	},
};

struct resource spipnx_1_resources[] = {
	{
		.start = PNX4008_SPI2_BASE,
		.end = PNX4008_SPI2_BASE + SZ_4K,
		.flags = IORESOURCE_MEM,
	}, {
		.start = PER_SPI2_REC_XMIT,
		.flags = IORESOURCE_DMA,
	}, {
		.start = SPI2_INT,
		.flags = IORESOURCE_IRQ,
	}, {
		.flags = 0,
	}
};

static struct spi_board_info spi_board_info[] __initdata = {
	{
		.modalias	= "m25p80",
		.max_speed_hz	= 1000000,
		.bus_num	= 1,
		.chip_select	= 0,
	},
};

static struct platform_device spipnx_1 = {
	.name = "spipnx",
	.id = 1,
	.num_resources = ARRAY_SIZE(spipnx_0_resources),
	.resource = spipnx_0_resources,
	.dev = {
		.coherent_dma_mask = 0xFFFFFFFF,
		},
};

static struct platform_device spipnx_2 = {
	.name = "spipnx",
	.id = 2,
	.num_resources = ARRAY_SIZE(spipnx_1_resources),
	.resource = spipnx_1_resources,
	.dev = {
		.coherent_dma_mask = 0xFFFFFFFF,
		},
};

static struct plat_serial8250_port platform_serial_ports[] = {
	{
		.membase = (void *)__iomem(IO_ADDRESS(PNX4008_UART5_BASE)),
		.mapbase = (unsigned long)PNX4008_UART5_BASE,
		.irq = IIR5_INT,
		.uartclk = PNX4008_UART_CLK,
		.regshift = 2,
		.iotype = UPIO_MEM,
		.flags = UPF_BOOT_AUTOCONF | UPF_BUGGY_UART | UPF_SKIP_TEST,
	},
	{
		.membase = (void *)__iomem(IO_ADDRESS(PNX4008_UART3_BASE)),
		.mapbase = (unsigned long)PNX4008_UART3_BASE,
		.irq = IIR3_INT,
		.uartclk = PNX4008_UART_CLK,
		.regshift = 2,
		.iotype = UPIO_MEM,
		.flags = UPF_BOOT_AUTOCONF | UPF_BUGGY_UART | UPF_SKIP_TEST,
	 },
	{}
};

static struct platform_device serial_device = {
	.name = "serial8250",
	.id = PLAT8250_DEV_PLATFORM,
	.dev = {
		.platform_data = &platform_serial_ports,
	},
};

static struct platform_device nand_flash_device = {
	.name = "pnx4008-flash",
	.id = -1,
	.dev = {
		.coherent_dma_mask = 0xFFFFFFFF,
	},
};

/* The dmamask must be set for OHCI to work */
static u64 ohci_dmamask = ~(u32) 0;

static struct resource ohci_resources[] = {
	{
		.start = IO_ADDRESS(PNX4008_USB_CONFIG_BASE),
		.end = IO_ADDRESS(PNX4008_USB_CONFIG_BASE + 0x100),
		.flags = IORESOURCE_MEM,
	}, {
		.start = USB_HOST_INT,
		.flags = IORESOURCE_IRQ,
	},
};

static struct platform_device ohci_device = {
	.name = "pnx4008-usb-ohci",
	.id = -1,
	.dev = {
		.dma_mask = &ohci_dmamask,
		.coherent_dma_mask = 0xffffffff,
		},
	.num_resources = ARRAY_SIZE(ohci_resources),
	.resource = ohci_resources,
};

static struct platform_device sdum_device = {
	.name = "pnx4008-sdum",
	.id = 0,
	.dev = {
		.coherent_dma_mask = 0xffffffff,
	},
};

static struct platform_device rgbfb_device = {
	.name = "pnx4008-rgbfb",
	.id = 0,
	.dev = {
		.coherent_dma_mask = 0xffffffff,
	}
};

struct resource watchdog_resources[] = {
	{
		.start = PNX4008_WDOG_BASE,
		.end = PNX4008_WDOG_BASE + SZ_4K - 1,
		.flags = IORESOURCE_MEM,
	},
};

static struct platform_device watchdog_device = {
	.name = "pnx4008-watchdog",
	.id = -1,
	.num_resources = ARRAY_SIZE(watchdog_resources),
	.resource = watchdog_resources,
};

static struct platform_device *devices[] __initdata = {
	&spipnx_1,
	&spipnx_2,
	&serial_device,
	&ohci_device,
	&nand_flash_device,
	&sdum_device,
	&rgbfb_device,
	&watchdog_device,
};


extern void pnx4008_uart_init(void);

static void __init pnx4008_init(void)
{
	/*disable all START interrupt sources,
	   and clear all START interrupt flags */
	__raw_writel(0, START_INT_ER_REG(SE_PIN_BASE_INT));
	__raw_writel(0, START_INT_ER_REG(SE_INT_BASE_INT));
	__raw_writel(0xffffffff, START_INT_RSR_REG(SE_PIN_BASE_INT));
	__raw_writel(0xffffffff, START_INT_RSR_REG(SE_INT_BASE_INT));

	platform_add_devices(devices, ARRAY_SIZE(devices));
	spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
	/* Switch on the UART clocks */
	pnx4008_uart_init();
}

static struct map_desc pnx4008_io_desc[] __initdata = {
	{
		.virtual 	= IO_ADDRESS(PNX4008_IRAM_BASE),
		.pfn 		= __phys_to_pfn(PNX4008_IRAM_BASE),
		.length		= SZ_64K,
		.type 		= MT_DEVICE,
	}, {
		.virtual 	= IO_ADDRESS(PNX4008_NDF_FLASH_BASE),
		.pfn 		= __phys_to_pfn(PNX4008_NDF_FLASH_BASE),
		.length		= SZ_1M - SZ_128K,
		.type 		= MT_DEVICE,
	}, {
		.virtual 	= IO_ADDRESS(PNX4008_JPEG_CONFIG_BASE),
		.pfn 		= __phys_to_pfn(PNX4008_JPEG_CONFIG_BASE),
		.length		= SZ_128K * 3,
		.type 		= MT_DEVICE,
	}, {
		.virtual 	= IO_ADDRESS(PNX4008_DMA_CONFIG_BASE),
		.pfn 		= __phys_to_pfn(PNX4008_DMA_CONFIG_BASE),
		.length		= SZ_1M,
		.type 		= MT_DEVICE,
	}, {
		.virtual 	= IO_ADDRESS(PNX4008_AHB2FAB_BASE),
		.pfn 		= __phys_to_pfn(PNX4008_AHB2FAB_BASE),
		.length		= SZ_1M,
		.type 		= MT_DEVICE,
	},
};

void __init pnx4008_map_io(void)
{
	iotable_init(pnx4008_io_desc, ARRAY_SIZE(pnx4008_io_desc));
}

static void pnx4008_restart(char mode, const char *cmd)
{
	soft_restart(0);
}

extern struct sys_timer pnx4008_timer;

MACHINE_START(PNX4008, "Philips PNX4008")
	/* Maintainer: MontaVista Software Inc. */
	.atag_offset		= 0x100,
	.map_io 		= pnx4008_map_io,
	.init_irq 		= pnx4008_init_irq,
	.init_machine 		= pnx4008_init,
	.timer 			= &pnx4008_timer,
	.restart		= pnx4008_restart,
MACHINE_END