blob: 73b3ecaf81c1fe31a200607c05103ef91bac814b [file] [log] [blame]
wanzongshun35c92212009-08-21 07:07:46 +01001/*
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>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090021#include <linux/slab.h>
wanzongshun35c92212009-08-21 07:07:46 +010022
23#include <linux/mtd/physmap.h>
24#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h>
26
27#include <linux/spi/spi.h>
28#include <linux/spi/flash.h>
29
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32#include <asm/mach/irq.h>
33#include <asm/mach-types.h>
34
35#include <mach/regs-serial.h>
wanzongshun39986ca2009-12-01 14:01:55 +010036#include <mach/nuc900_spi.h>
wanzongshun35c92212009-08-21 07:07:46 +010037#include <mach/map.h>
Wang Qiang86619702010-03-10 15:21:47 -080038#include <mach/fb.h>
wanzongshun6a446b902010-07-18 15:15:11 +010039#include <mach/regs-ldm.h>
wanzongshun35c92212009-08-21 07:07:46 +010040
41#include "cpu.h"
42
43/*NUC900 evb norflash driver data */
44
45#define NUC900_FLASH_BASE 0xA0000000
46#define NUC900_FLASH_SIZE 0x400000
47#define SPIOFFSET 0x200
48#define SPIOREG_SIZE 0x100
49
50static struct mtd_partition nuc900_flash_partitions[] = {
51 {
52 .name = "NOR Partition 1 for kernel (960K)",
53 .size = 0xF0000,
54 .offset = 0x10000,
55 },
56 {
57 .name = "NOR Partition 2 for image (1M)",
58 .size = 0x100000,
59 .offset = 0x100000,
60 },
61 {
62 .name = "NOR Partition 3 for user (2M)",
63 .size = 0x200000,
64 .offset = 0x00200000,
65 }
66};
67
68static struct physmap_flash_data nuc900_flash_data = {
69 .width = 2,
70 .parts = nuc900_flash_partitions,
71 .nr_parts = ARRAY_SIZE(nuc900_flash_partitions),
72};
73
74static struct resource nuc900_flash_resources[] = {
75 {
76 .start = NUC900_FLASH_BASE,
77 .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
78 .flags = IORESOURCE_MEM,
79 }
80};
81
82static struct platform_device nuc900_flash_device = {
83 .name = "physmap-flash",
84 .id = 0,
85 .dev = {
86 .platform_data = &nuc900_flash_data,
87 },
88 .resource = nuc900_flash_resources,
89 .num_resources = ARRAY_SIZE(nuc900_flash_resources),
90};
91
92/* USB EHCI Host Controller */
93
94static struct resource nuc900_usb_ehci_resource[] = {
95 [0] = {
96 .start = W90X900_PA_USBEHCIHOST,
97 .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
98 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
101 .start = IRQ_USBH,
102 .end = IRQ_USBH,
103 .flags = IORESOURCE_IRQ,
104 }
105};
106
107static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
108
109static struct platform_device nuc900_device_usb_ehci = {
110 .name = "nuc900-ehci",
111 .id = -1,
112 .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
113 .resource = nuc900_usb_ehci_resource,
114 .dev = {
115 .dma_mask = &nuc900_device_usb_ehci_dmamask,
116 .coherent_dma_mask = 0xffffffffUL
117 }
118};
119
120/* USB OHCI Host Controller */
121
122static struct resource nuc900_usb_ohci_resource[] = {
123 [0] = {
124 .start = W90X900_PA_USBOHCIHOST,
125 .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
126 .flags = IORESOURCE_MEM,
127 },
128 [1] = {
129 .start = IRQ_USBH,
130 .end = IRQ_USBH,
131 .flags = IORESOURCE_IRQ,
132 }
133};
134
135static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
136static struct platform_device nuc900_device_usb_ohci = {
137 .name = "nuc900-ohci",
138 .id = -1,
139 .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
140 .resource = nuc900_usb_ohci_resource,
141 .dev = {
142 .dma_mask = &nuc900_device_usb_ohci_dmamask,
143 .coherent_dma_mask = 0xffffffffUL
144 }
145};
146
147/* USB Device (Gadget)*/
148
149static struct resource nuc900_usbgadget_resource[] = {
150 [0] = {
151 .start = W90X900_PA_USBDEV,
152 .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
153 .flags = IORESOURCE_MEM,
154 },
155 [1] = {
156 .start = IRQ_USBD,
157 .end = IRQ_USBD,
158 .flags = IORESOURCE_IRQ,
159 }
160};
161
162static struct platform_device nuc900_device_usbgadget = {
163 .name = "nuc900-usbgadget",
164 .id = -1,
165 .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
166 .resource = nuc900_usbgadget_resource,
167};
168
169/* MAC device */
170
171static struct resource nuc900_emc_resource[] = {
172 [0] = {
173 .start = W90X900_PA_EMC,
174 .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
175 .flags = IORESOURCE_MEM,
176 },
177 [1] = {
178 .start = IRQ_EMCTX,
179 .end = IRQ_EMCTX,
180 .flags = IORESOURCE_IRQ,
181 },
182 [2] = {
183 .start = IRQ_EMCRX,
184 .end = IRQ_EMCRX,
185 .flags = IORESOURCE_IRQ,
186 }
187};
188
189static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
190static struct platform_device nuc900_device_emc = {
191 .name = "nuc900-emc",
192 .id = -1,
193 .num_resources = ARRAY_SIZE(nuc900_emc_resource),
194 .resource = nuc900_emc_resource,
195 .dev = {
196 .dma_mask = &nuc900_device_emc_dmamask,
197 .coherent_dma_mask = 0xffffffffUL
198 }
199};
200
201/* SPI device */
202
wanzongshund76cdf22009-12-18 17:58:58 +0100203static struct nuc900_spi_info nuc900_spiflash_data = {
wanzongshun39986ca2009-12-01 14:01:55 +0100204 .num_cs = 1,
205 .lsb = 0,
206 .txneg = 1,
207 .rxneg = 0,
208 .divider = 24,
209 .sleep = 0,
210 .txnum = 0,
211 .txbitlen = 1,
212 .bus_num = 0,
213};
214
wanzongshun35c92212009-08-21 07:07:46 +0100215static struct resource nuc900_spi_resource[] = {
216 [0] = {
217 .start = W90X900_PA_I2C + SPIOFFSET,
218 .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
219 .flags = IORESOURCE_MEM,
220 },
221 [1] = {
222 .start = IRQ_SSP,
223 .end = IRQ_SSP,
224 .flags = IORESOURCE_IRQ,
225 }
226};
227
228static struct platform_device nuc900_device_spi = {
229 .name = "nuc900-spi",
230 .id = -1,
231 .num_resources = ARRAY_SIZE(nuc900_spi_resource),
232 .resource = nuc900_spi_resource,
wanzongshun39986ca2009-12-01 14:01:55 +0100233 .dev = {
234 .platform_data = &nuc900_spiflash_data,
235 }
wanzongshun35c92212009-08-21 07:07:46 +0100236};
237
238/* spi device, spi flash info */
239
240static struct mtd_partition nuc900_spi_flash_partitions[] = {
241 {
242 .name = "bootloader(spi)",
243 .size = 0x0100000,
244 .offset = 0,
245 },
246};
247
248static struct flash_platform_data nuc900_spi_flash_data = {
249 .name = "m25p80",
250 .parts = nuc900_spi_flash_partitions,
251 .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
252 .type = "w25x16",
253};
254
255static struct spi_board_info nuc900_spi_board_info[] __initdata = {
256 {
257 .modalias = "m25p80",
258 .max_speed_hz = 20000000,
259 .bus_num = 0,
260 .chip_select = 1,
261 .platform_data = &nuc900_spi_flash_data,
262 .mode = SPI_MODE_0,
263 },
264};
265
266/* WDT Device */
267
268static struct resource nuc900_wdt_resource[] = {
269 [0] = {
270 .start = W90X900_PA_TIMER,
271 .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
272 .flags = IORESOURCE_MEM,
273 },
274 [1] = {
275 .start = IRQ_WDT,
276 .end = IRQ_WDT,
277 .flags = IORESOURCE_IRQ,
278 }
279};
280
281static struct platform_device nuc900_device_wdt = {
282 .name = "nuc900-wdt",
283 .id = -1,
284 .num_resources = ARRAY_SIZE(nuc900_wdt_resource),
285 .resource = nuc900_wdt_resource,
286};
287
288/*
289 * public device definition between 910 and 920, or 910
290 * and 950 or 950 and 960...,their dev platform register
291 * should be in specific file such as nuc950, nuc960 c
292 * files rather than the public dev.c file here. so the
293 * corresponding platform_device definition should not be
294 * static.
295*/
296
297/* RTC controller*/
298
299static struct resource nuc900_rtc_resource[] = {
300 [0] = {
301 .start = W90X900_PA_RTC,
302 .end = W90X900_PA_RTC + 0xff,
303 .flags = IORESOURCE_MEM,
304 },
305 [1] = {
306 .start = IRQ_RTC,
307 .end = IRQ_RTC,
308 .flags = IORESOURCE_IRQ,
309 },
310};
311
312struct platform_device nuc900_device_rtc = {
313 .name = "nuc900-rtc",
314 .id = -1,
315 .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
316 .resource = nuc900_rtc_resource,
317};
318
319/*TouchScreen controller*/
320
321static struct resource nuc900_ts_resource[] = {
322 [0] = {
323 .start = W90X900_PA_ADC,
324 .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
325 .flags = IORESOURCE_MEM,
326 },
327 [1] = {
328 .start = IRQ_ADC,
329 .end = IRQ_ADC,
330 .flags = IORESOURCE_IRQ,
331 },
332};
333
334struct platform_device nuc900_device_ts = {
335 .name = "nuc900-ts",
336 .id = -1,
337 .resource = nuc900_ts_resource,
338 .num_resources = ARRAY_SIZE(nuc900_ts_resource),
339};
340
341/* FMI Device */
342
343static struct resource nuc900_fmi_resource[] = {
344 [0] = {
345 .start = W90X900_PA_FMI,
346 .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
347 .flags = IORESOURCE_MEM,
348 },
349 [1] = {
350 .start = IRQ_FMI,
351 .end = IRQ_FMI,
352 .flags = IORESOURCE_IRQ,
353 }
354};
355
356struct platform_device nuc900_device_fmi = {
357 .name = "nuc900-fmi",
358 .id = -1,
359 .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
360 .resource = nuc900_fmi_resource,
361};
362
363/* KPI controller*/
364
365static struct resource nuc900_kpi_resource[] = {
366 [0] = {
367 .start = W90X900_PA_KPI,
368 .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
369 .flags = IORESOURCE_MEM,
370 },
371 [1] = {
372 .start = IRQ_KPI,
373 .end = IRQ_KPI,
374 .flags = IORESOURCE_IRQ,
375 }
376
377};
378
379struct platform_device nuc900_device_kpi = {
380 .name = "nuc900-kpi",
381 .id = -1,
382 .num_resources = ARRAY_SIZE(nuc900_kpi_resource),
383 .resource = nuc900_kpi_resource,
384};
385
wanzongshun6a446b902010-07-18 15:15:11 +0100386/* LCD controller*/
387
388static struct nuc900fb_display __initdata nuc900_lcd_info[] = {
389 /* Giantplus Technology GPM1040A0 320x240 Color TFT LCD */
390 [0] = {
391 .type = LCM_DCCS_VA_SRC_RGB565,
392 .width = 320,
393 .height = 240,
394 .xres = 320,
395 .yres = 240,
396 .bpp = 16,
397 .pixclock = 200000,
398 .left_margin = 34,
399 .right_margin = 54,
400 .hsync_len = 10,
401 .upper_margin = 18,
402 .lower_margin = 4,
403 .vsync_len = 1,
404 .dccs = 0x8e00041a,
405 .devctl = 0x060800c0,
406 .fbctrl = 0x00a000a0,
407 .scale = 0x04000400,
408 },
409};
410
411static struct nuc900fb_mach_info nuc900_fb_info __initdata = {
412#if defined(CONFIG_GPM1040A0_320X240)
413 .displays = &nuc900_lcd_info[0],
414#else
415 .displays = nuc900_lcd_info,
416#endif
417 .num_displays = ARRAY_SIZE(nuc900_lcd_info),
418 .default_display = 0,
419 .gpio_dir = 0x00000004,
420 .gpio_dir_mask = 0xFFFFFFFD,
421 .gpio_data = 0x00000004,
422 .gpio_data_mask = 0xFFFFFFFD,
423};
Wang Qiang86619702010-03-10 15:21:47 -0800424
425static struct resource nuc900_lcd_resource[] = {
426 [0] = {
427 .start = W90X900_PA_LCD,
428 .end = W90X900_PA_LCD + W90X900_SZ_LCD - 1,
429 .flags = IORESOURCE_MEM,
430 },
431 [1] = {
432 .start = IRQ_LCD,
433 .end = IRQ_LCD,
434 .flags = IORESOURCE_IRQ,
435 }
436};
437
438static u64 nuc900_device_lcd_dmamask = -1;
439struct platform_device nuc900_device_lcd = {
440 .name = "nuc900-lcd",
441 .id = -1,
442 .num_resources = ARRAY_SIZE(nuc900_lcd_resource),
443 .resource = nuc900_lcd_resource,
444 .dev = {
445 .dma_mask = &nuc900_device_lcd_dmamask,
446 .coherent_dma_mask = -1,
wanzongshun6a446b902010-07-18 15:15:11 +0100447 .platform_data = &nuc900_fb_info,
Wang Qiang86619702010-03-10 15:21:47 -0800448 }
449};
450
wanzongshun3d34a0d2010-05-22 15:23:23 +0100451/* AUDIO controller*/
452static u64 nuc900_device_audio_dmamask = -1;
453static struct resource nuc900_ac97_resource[] = {
454 [0] = {
455 .start = W90X900_PA_ACTL,
456 .end = W90X900_PA_ACTL + W90X900_SZ_ACTL - 1,
457 .flags = IORESOURCE_MEM,
458 },
459 [1] = {
460 .start = IRQ_ACTL,
461 .end = IRQ_ACTL,
462 .flags = IORESOURCE_IRQ,
463 }
464
465};
466
467struct platform_device nuc900_device_audio = {
468 .name = "nuc900-audio",
469 .id = -1,
470 .num_resources = ARRAY_SIZE(nuc900_ac97_resource),
471 .resource = nuc900_ac97_resource,
472 .dev = {
473 .dma_mask = &nuc900_device_audio_dmamask,
474 .coherent_dma_mask = -1,
475 }
476};
477
wanzongshun35c92212009-08-21 07:07:46 +0100478/*Here should be your evb resourse,such as LCD*/
479
480static struct platform_device *nuc900_public_dev[] __initdata = {
481 &nuc900_serial_device,
482 &nuc900_flash_device,
483 &nuc900_device_usb_ehci,
484 &nuc900_device_usb_ohci,
485 &nuc900_device_usbgadget,
486 &nuc900_device_emc,
487 &nuc900_device_spi,
488 &nuc900_device_wdt,
wanzongshun3d34a0d2010-05-22 15:23:23 +0100489 &nuc900_device_audio,
wanzongshun35c92212009-08-21 07:07:46 +0100490};
491
492/* Provide adding specific CPU platform devices API */
493
494void __init nuc900_board_init(struct platform_device **device, int size)
495{
496 platform_add_devices(device, size);
497 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
498 spi_register_board_info(nuc900_spi_board_info,
499 ARRAY_SIZE(nuc900_spi_board_info));
500}
501