ARM: 5849/1: ARMv7: fix Oprofile events count
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-w90x900 / dev.c
CommitLineData
35c9221a 1/*
2 * linux/arch/arm/mach-w90x900/dev.c
3 *
4 * Copyright (C) 2009 Nuvoton corporation.
5 *
6 * Wan ZongShun <mcuos.com@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation;version 2 of the License.
11 *
12 */
13
14#include <linux/kernel.h>
15#include <linux/types.h>
16#include <linux/interrupt.h>
17#include <linux/list.h>
18#include <linux/timer.h>
19#include <linux/init.h>
20#include <linux/platform_device.h>
21
22#include <linux/mtd/physmap.h>
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/partitions.h>
25
26#include <linux/spi/spi.h>
27#include <linux/spi/flash.h>
28
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/irq.h>
32#include <asm/mach-types.h>
33
34#include <mach/regs-serial.h>
39986ca6 35#include <mach/nuc900_spi.h>
35c9221a 36#include <mach/map.h>
37
38#include "cpu.h"
39
40/*NUC900 evb norflash driver data */
41
42#define NUC900_FLASH_BASE 0xA0000000
43#define NUC900_FLASH_SIZE 0x400000
44#define SPIOFFSET 0x200
45#define SPIOREG_SIZE 0x100
46
47static struct mtd_partition nuc900_flash_partitions[] = {
48 {
49 .name = "NOR Partition 1 for kernel (960K)",
50 .size = 0xF0000,
51 .offset = 0x10000,
52 },
53 {
54 .name = "NOR Partition 2 for image (1M)",
55 .size = 0x100000,
56 .offset = 0x100000,
57 },
58 {
59 .name = "NOR Partition 3 for user (2M)",
60 .size = 0x200000,
61 .offset = 0x00200000,
62 }
63};
64
65static struct physmap_flash_data nuc900_flash_data = {
66 .width = 2,
67 .parts = nuc900_flash_partitions,
68 .nr_parts = ARRAY_SIZE(nuc900_flash_partitions),
69};
70
71static struct resource nuc900_flash_resources[] = {
72 {
73 .start = NUC900_FLASH_BASE,
74 .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
75 .flags = IORESOURCE_MEM,
76 }
77};
78
79static struct platform_device nuc900_flash_device = {
80 .name = "physmap-flash",
81 .id = 0,
82 .dev = {
83 .platform_data = &nuc900_flash_data,
84 },
85 .resource = nuc900_flash_resources,
86 .num_resources = ARRAY_SIZE(nuc900_flash_resources),
87};
88
89/* USB EHCI Host Controller */
90
91static struct resource nuc900_usb_ehci_resource[] = {
92 [0] = {
93 .start = W90X900_PA_USBEHCIHOST,
94 .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
95 .flags = IORESOURCE_MEM,
96 },
97 [1] = {
98 .start = IRQ_USBH,
99 .end = IRQ_USBH,
100 .flags = IORESOURCE_IRQ,
101 }
102};
103
104static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
105
106static struct platform_device nuc900_device_usb_ehci = {
107 .name = "nuc900-ehci",
108 .id = -1,
109 .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
110 .resource = nuc900_usb_ehci_resource,
111 .dev = {
112 .dma_mask = &nuc900_device_usb_ehci_dmamask,
113 .coherent_dma_mask = 0xffffffffUL
114 }
115};
116
117/* USB OHCI Host Controller */
118
119static struct resource nuc900_usb_ohci_resource[] = {
120 [0] = {
121 .start = W90X900_PA_USBOHCIHOST,
122 .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
123 .flags = IORESOURCE_MEM,
124 },
125 [1] = {
126 .start = IRQ_USBH,
127 .end = IRQ_USBH,
128 .flags = IORESOURCE_IRQ,
129 }
130};
131
132static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
133static struct platform_device nuc900_device_usb_ohci = {
134 .name = "nuc900-ohci",
135 .id = -1,
136 .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
137 .resource = nuc900_usb_ohci_resource,
138 .dev = {
139 .dma_mask = &nuc900_device_usb_ohci_dmamask,
140 .coherent_dma_mask = 0xffffffffUL
141 }
142};
143
144/* USB Device (Gadget)*/
145
146static struct resource nuc900_usbgadget_resource[] = {
147 [0] = {
148 .start = W90X900_PA_USBDEV,
149 .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
150 .flags = IORESOURCE_MEM,
151 },
152 [1] = {
153 .start = IRQ_USBD,
154 .end = IRQ_USBD,
155 .flags = IORESOURCE_IRQ,
156 }
157};
158
159static struct platform_device nuc900_device_usbgadget = {
160 .name = "nuc900-usbgadget",
161 .id = -1,
162 .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
163 .resource = nuc900_usbgadget_resource,
164};
165
166/* MAC device */
167
168static struct resource nuc900_emc_resource[] = {
169 [0] = {
170 .start = W90X900_PA_EMC,
171 .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
172 .flags = IORESOURCE_MEM,
173 },
174 [1] = {
175 .start = IRQ_EMCTX,
176 .end = IRQ_EMCTX,
177 .flags = IORESOURCE_IRQ,
178 },
179 [2] = {
180 .start = IRQ_EMCRX,
181 .end = IRQ_EMCRX,
182 .flags = IORESOURCE_IRQ,
183 }
184};
185
186static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
187static struct platform_device nuc900_device_emc = {
188 .name = "nuc900-emc",
189 .id = -1,
190 .num_resources = ARRAY_SIZE(nuc900_emc_resource),
191 .resource = nuc900_emc_resource,
192 .dev = {
193 .dma_mask = &nuc900_device_emc_dmamask,
194 .coherent_dma_mask = 0xffffffffUL
195 }
196};
197
198/* SPI device */
199
39986ca6 200static struct w90p910_spi_info nuc900_spiflash_data = {
201 .num_cs = 1,
202 .lsb = 0,
203 .txneg = 1,
204 .rxneg = 0,
205 .divider = 24,
206 .sleep = 0,
207 .txnum = 0,
208 .txbitlen = 1,
209 .bus_num = 0,
210};
211
35c9221a 212static struct resource nuc900_spi_resource[] = {
213 [0] = {
214 .start = W90X900_PA_I2C + SPIOFFSET,
215 .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
216 .flags = IORESOURCE_MEM,
217 },
218 [1] = {
219 .start = IRQ_SSP,
220 .end = IRQ_SSP,
221 .flags = IORESOURCE_IRQ,
222 }
223};
224
225static struct platform_device nuc900_device_spi = {
226 .name = "nuc900-spi",
227 .id = -1,
228 .num_resources = ARRAY_SIZE(nuc900_spi_resource),
229 .resource = nuc900_spi_resource,
39986ca6 230 .dev = {
231 .platform_data = &nuc900_spiflash_data,
232 }
35c9221a 233};
234
235/* spi device, spi flash info */
236
237static struct mtd_partition nuc900_spi_flash_partitions[] = {
238 {
239 .name = "bootloader(spi)",
240 .size = 0x0100000,
241 .offset = 0,
242 },
243};
244
245static struct flash_platform_data nuc900_spi_flash_data = {
246 .name = "m25p80",
247 .parts = nuc900_spi_flash_partitions,
248 .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
249 .type = "w25x16",
250};
251
252static struct spi_board_info nuc900_spi_board_info[] __initdata = {
253 {
254 .modalias = "m25p80",
255 .max_speed_hz = 20000000,
256 .bus_num = 0,
257 .chip_select = 1,
258 .platform_data = &nuc900_spi_flash_data,
259 .mode = SPI_MODE_0,
260 },
261};
262
263/* WDT Device */
264
265static struct resource nuc900_wdt_resource[] = {
266 [0] = {
267 .start = W90X900_PA_TIMER,
268 .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
269 .flags = IORESOURCE_MEM,
270 },
271 [1] = {
272 .start = IRQ_WDT,
273 .end = IRQ_WDT,
274 .flags = IORESOURCE_IRQ,
275 }
276};
277
278static struct platform_device nuc900_device_wdt = {
279 .name = "nuc900-wdt",
280 .id = -1,
281 .num_resources = ARRAY_SIZE(nuc900_wdt_resource),
282 .resource = nuc900_wdt_resource,
283};
284
285/*
286 * public device definition between 910 and 920, or 910
287 * and 950 or 950 and 960...,their dev platform register
288 * should be in specific file such as nuc950, nuc960 c
289 * files rather than the public dev.c file here. so the
290 * corresponding platform_device definition should not be
291 * static.
292*/
293
294/* RTC controller*/
295
296static struct resource nuc900_rtc_resource[] = {
297 [0] = {
298 .start = W90X900_PA_RTC,
299 .end = W90X900_PA_RTC + 0xff,
300 .flags = IORESOURCE_MEM,
301 },
302 [1] = {
303 .start = IRQ_RTC,
304 .end = IRQ_RTC,
305 .flags = IORESOURCE_IRQ,
306 },
307};
308
309struct platform_device nuc900_device_rtc = {
310 .name = "nuc900-rtc",
311 .id = -1,
312 .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
313 .resource = nuc900_rtc_resource,
314};
315
316/*TouchScreen controller*/
317
318static struct resource nuc900_ts_resource[] = {
319 [0] = {
320 .start = W90X900_PA_ADC,
321 .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
322 .flags = IORESOURCE_MEM,
323 },
324 [1] = {
325 .start = IRQ_ADC,
326 .end = IRQ_ADC,
327 .flags = IORESOURCE_IRQ,
328 },
329};
330
331struct platform_device nuc900_device_ts = {
332 .name = "nuc900-ts",
333 .id = -1,
334 .resource = nuc900_ts_resource,
335 .num_resources = ARRAY_SIZE(nuc900_ts_resource),
336};
337
338/* FMI Device */
339
340static struct resource nuc900_fmi_resource[] = {
341 [0] = {
342 .start = W90X900_PA_FMI,
343 .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
344 .flags = IORESOURCE_MEM,
345 },
346 [1] = {
347 .start = IRQ_FMI,
348 .end = IRQ_FMI,
349 .flags = IORESOURCE_IRQ,
350 }
351};
352
353struct platform_device nuc900_device_fmi = {
354 .name = "nuc900-fmi",
355 .id = -1,
356 .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
357 .resource = nuc900_fmi_resource,
358};
359
360/* KPI controller*/
361
362static struct resource nuc900_kpi_resource[] = {
363 [0] = {
364 .start = W90X900_PA_KPI,
365 .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
366 .flags = IORESOURCE_MEM,
367 },
368 [1] = {
369 .start = IRQ_KPI,
370 .end = IRQ_KPI,
371 .flags = IORESOURCE_IRQ,
372 }
373
374};
375
376struct platform_device nuc900_device_kpi = {
377 .name = "nuc900-kpi",
378 .id = -1,
379 .num_resources = ARRAY_SIZE(nuc900_kpi_resource),
380 .resource = nuc900_kpi_resource,
381};
382
383/*Here should be your evb resourse,such as LCD*/
384
385static struct platform_device *nuc900_public_dev[] __initdata = {
386 &nuc900_serial_device,
387 &nuc900_flash_device,
388 &nuc900_device_usb_ehci,
389 &nuc900_device_usb_ohci,
390 &nuc900_device_usbgadget,
391 &nuc900_device_emc,
392 &nuc900_device_spi,
393 &nuc900_device_wdt,
394};
395
396/* Provide adding specific CPU platform devices API */
397
398void __init nuc900_board_init(struct platform_device **device, int size)
399{
400 platform_add_devices(device, size);
401 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
402 spi_register_board_info(nuc900_spi_board_info,
403 ARRAY_SIZE(nuc900_spi_board_info));
404}
405