2 * linux/arch/arm/mach-w90x900/dev.c
4 * Copyright (C) 2009 Nuvoton corporation.
6 * Wan ZongShun <mcuos.com@gmail.com>
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.
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 #include <linux/slab.h>
22 #include <linux/cpu.h>
24 #include <linux/mtd/physmap.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/partitions.h>
28 #include <linux/spi/spi.h>
29 #include <linux/spi/flash.h>
31 #include <asm/system_misc.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/irq.h>
35 #include <asm/mach-types.h>
37 #include <mach/regs-serial.h>
38 #include <linux/platform_data/spi-nuc900.h>
40 #include <linux/platform_data/video-nuc900fb.h>
41 #include <mach/regs-ldm.h>
42 #include <linux/platform_data/keypad-w90p910.h>
46 /*NUC900 evb norflash driver data */
48 #define NUC900_FLASH_BASE 0xA0000000
49 #define NUC900_FLASH_SIZE 0x400000
50 #define SPIOFFSET 0x200
51 #define SPIOREG_SIZE 0x100
53 static struct mtd_partition nuc900_flash_partitions[] = {
55 .name = "NOR Partition 1 for kernel (960K)",
60 .name = "NOR Partition 2 for image (1M)",
65 .name = "NOR Partition 3 for user (2M)",
71 static struct physmap_flash_data nuc900_flash_data = {
73 .parts = nuc900_flash_partitions,
74 .nr_parts = ARRAY_SIZE(nuc900_flash_partitions),
77 static struct resource nuc900_flash_resources[] = {
79 .start = NUC900_FLASH_BASE,
80 .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
81 .flags = IORESOURCE_MEM,
85 static struct platform_device nuc900_flash_device = {
86 .name = "physmap-flash",
89 .platform_data = &nuc900_flash_data,
91 .resource = nuc900_flash_resources,
92 .num_resources = ARRAY_SIZE(nuc900_flash_resources),
95 /* USB EHCI Host Controller */
97 static struct resource nuc900_usb_ehci_resource[] = {
99 .start = W90X900_PA_USBEHCIHOST,
100 .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
101 .flags = IORESOURCE_MEM,
106 .flags = IORESOURCE_IRQ,
110 static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
112 static struct platform_device nuc900_device_usb_ehci = {
113 .name = "nuc900-ehci",
115 .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
116 .resource = nuc900_usb_ehci_resource,
118 .dma_mask = &nuc900_device_usb_ehci_dmamask,
119 .coherent_dma_mask = 0xffffffffUL
123 /* USB OHCI Host Controller */
125 static struct resource nuc900_usb_ohci_resource[] = {
127 .start = W90X900_PA_USBOHCIHOST,
128 .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
129 .flags = IORESOURCE_MEM,
134 .flags = IORESOURCE_IRQ,
138 static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
139 static struct platform_device nuc900_device_usb_ohci = {
140 .name = "nuc900-ohci",
142 .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
143 .resource = nuc900_usb_ohci_resource,
145 .dma_mask = &nuc900_device_usb_ohci_dmamask,
146 .coherent_dma_mask = 0xffffffffUL
150 /* USB Device (Gadget)*/
152 static struct resource nuc900_usbgadget_resource[] = {
154 .start = W90X900_PA_USBDEV,
155 .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
156 .flags = IORESOURCE_MEM,
161 .flags = IORESOURCE_IRQ,
165 static struct platform_device nuc900_device_usbgadget = {
166 .name = "nuc900-usbgadget",
168 .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
169 .resource = nuc900_usbgadget_resource,
174 static struct resource nuc900_emc_resource[] = {
176 .start = W90X900_PA_EMC,
177 .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
178 .flags = IORESOURCE_MEM,
183 .flags = IORESOURCE_IRQ,
188 .flags = IORESOURCE_IRQ,
192 static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
193 static struct platform_device nuc900_device_emc = {
194 .name = "nuc900-emc",
196 .num_resources = ARRAY_SIZE(nuc900_emc_resource),
197 .resource = nuc900_emc_resource,
199 .dma_mask = &nuc900_device_emc_dmamask,
200 .coherent_dma_mask = 0xffffffffUL
206 static struct nuc900_spi_info nuc900_spiflash_data = {
218 static struct resource nuc900_spi_resource[] = {
220 .start = W90X900_PA_I2C + SPIOFFSET,
221 .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
222 .flags = IORESOURCE_MEM,
227 .flags = IORESOURCE_IRQ,
231 static struct platform_device nuc900_device_spi = {
232 .name = "nuc900-spi",
234 .num_resources = ARRAY_SIZE(nuc900_spi_resource),
235 .resource = nuc900_spi_resource,
237 .platform_data = &nuc900_spiflash_data,
241 /* spi device, spi flash info */
243 static struct mtd_partition nuc900_spi_flash_partitions[] = {
245 .name = "bootloader(spi)",
251 static struct flash_platform_data nuc900_spi_flash_data = {
253 .parts = nuc900_spi_flash_partitions,
254 .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
258 static struct spi_board_info nuc900_spi_board_info[] __initdata = {
260 .modalias = "m25p80",
261 .max_speed_hz = 20000000,
264 .platform_data = &nuc900_spi_flash_data,
271 static struct resource nuc900_wdt_resource[] = {
273 .start = W90X900_PA_TIMER,
274 .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
275 .flags = IORESOURCE_MEM,
280 .flags = IORESOURCE_IRQ,
284 static struct platform_device nuc900_device_wdt = {
285 .name = "nuc900-wdt",
287 .num_resources = ARRAY_SIZE(nuc900_wdt_resource),
288 .resource = nuc900_wdt_resource,
292 * public device definition between 910 and 920, or 910
293 * and 950 or 950 and 960...,their dev platform register
294 * should be in specific file such as nuc950, nuc960 c
295 * files rather than the public dev.c file here. so the
296 * corresponding platform_device definition should not be
302 static struct resource nuc900_rtc_resource[] = {
304 .start = W90X900_PA_RTC,
305 .end = W90X900_PA_RTC + 0xff,
306 .flags = IORESOURCE_MEM,
311 .flags = IORESOURCE_IRQ,
315 struct platform_device nuc900_device_rtc = {
316 .name = "nuc900-rtc",
318 .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
319 .resource = nuc900_rtc_resource,
322 /*TouchScreen controller*/
324 static struct resource nuc900_ts_resource[] = {
326 .start = W90X900_PA_ADC,
327 .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
328 .flags = IORESOURCE_MEM,
333 .flags = IORESOURCE_IRQ,
337 struct platform_device nuc900_device_ts = {
340 .resource = nuc900_ts_resource,
341 .num_resources = ARRAY_SIZE(nuc900_ts_resource),
346 static struct resource nuc900_fmi_resource[] = {
348 .start = W90X900_PA_FMI,
349 .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
350 .flags = IORESOURCE_MEM,
355 .flags = IORESOURCE_IRQ,
359 struct platform_device nuc900_device_fmi = {
360 .name = "nuc900-fmi",
362 .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
363 .resource = nuc900_fmi_resource,
368 static int nuc900_keymap[] = {
390 static struct matrix_keymap_data nuc900_map_data = {
391 .keymap = nuc900_keymap,
392 .keymap_size = ARRAY_SIZE(nuc900_keymap),
395 struct w90p910_keypad_platform_data nuc900_keypad_info = {
396 .keymap_data = &nuc900_map_data,
401 static struct resource nuc900_kpi_resource[] = {
403 .start = W90X900_PA_KPI,
404 .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
405 .flags = IORESOURCE_MEM,
410 .flags = IORESOURCE_IRQ,
415 struct platform_device nuc900_device_kpi = {
416 .name = "nuc900-kpi",
418 .num_resources = ARRAY_SIZE(nuc900_kpi_resource),
419 .resource = nuc900_kpi_resource,
421 .platform_data = &nuc900_keypad_info,
427 static struct nuc900fb_display nuc900_lcd_info[] = {
428 /* Giantplus Technology GPM1040A0 320x240 Color TFT LCD */
430 .type = LCM_DCCS_VA_SRC_RGB565,
444 .devctl = 0x060800c0,
445 .fbctrl = 0x00a000a0,
450 static struct nuc900fb_mach_info nuc900_fb_info = {
451 #if defined(CONFIG_GPM1040A0_320X240)
452 .displays = &nuc900_lcd_info[0],
454 .displays = nuc900_lcd_info,
456 .num_displays = ARRAY_SIZE(nuc900_lcd_info),
457 .default_display = 0,
458 .gpio_dir = 0x00000004,
459 .gpio_dir_mask = 0xFFFFFFFD,
460 .gpio_data = 0x00000004,
461 .gpio_data_mask = 0xFFFFFFFD,
464 static struct resource nuc900_lcd_resource[] = {
466 .start = W90X900_PA_LCD,
467 .end = W90X900_PA_LCD + W90X900_SZ_LCD - 1,
468 .flags = IORESOURCE_MEM,
473 .flags = IORESOURCE_IRQ,
477 static u64 nuc900_device_lcd_dmamask = -1;
478 struct platform_device nuc900_device_lcd = {
479 .name = "nuc900-lcd",
481 .num_resources = ARRAY_SIZE(nuc900_lcd_resource),
482 .resource = nuc900_lcd_resource,
484 .dma_mask = &nuc900_device_lcd_dmamask,
485 .coherent_dma_mask = -1,
486 .platform_data = &nuc900_fb_info,
490 /* AUDIO controller*/
491 static u64 nuc900_device_audio_dmamask = -1;
492 static struct resource nuc900_ac97_resource[] = {
494 .start = W90X900_PA_ACTL,
495 .end = W90X900_PA_ACTL + W90X900_SZ_ACTL - 1,
496 .flags = IORESOURCE_MEM,
501 .flags = IORESOURCE_IRQ,
506 struct platform_device nuc900_device_ac97 = {
507 .name = "nuc900-ac97",
509 .num_resources = ARRAY_SIZE(nuc900_ac97_resource),
510 .resource = nuc900_ac97_resource,
512 .dma_mask = &nuc900_device_audio_dmamask,
513 .coherent_dma_mask = -1,
517 /*Here should be your evb resourse,such as LCD*/
519 static struct platform_device *nuc900_public_dev[] __initdata = {
520 &nuc900_serial_device,
521 &nuc900_flash_device,
522 &nuc900_device_usb_ehci,
523 &nuc900_device_usb_ohci,
524 &nuc900_device_usbgadget,
531 /* Provide adding specific CPU platform devices API */
533 void __init nuc900_board_init(struct platform_device **device, int size)
535 cpu_idle_poll_ctrl(true);
536 platform_add_devices(device, size);
537 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
538 spi_register_board_info(nuc900_spi_board_info,
539 ARRAY_SIZE(nuc900_spi_board_info));