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>
23 #include <linux/mtd/physmap.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/partitions.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/flash.h>
30 #include <asm/system_misc.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/irq.h>
34 #include <asm/mach-types.h>
36 #include <mach/regs-serial.h>
37 #include <linux/platform_data/spi-nuc900.h>
39 #include <linux/platform_data/video-nuc900fb.h>
40 #include <mach/regs-ldm.h>
41 #include <linux/platform_data/keypad-w90p910.h>
45 /*NUC900 evb norflash driver data */
47 #define NUC900_FLASH_BASE 0xA0000000
48 #define NUC900_FLASH_SIZE 0x400000
49 #define SPIOFFSET 0x200
50 #define SPIOREG_SIZE 0x100
52 static struct mtd_partition nuc900_flash_partitions[] = {
54 .name = "NOR Partition 1 for kernel (960K)",
59 .name = "NOR Partition 2 for image (1M)",
64 .name = "NOR Partition 3 for user (2M)",
70 static struct physmap_flash_data nuc900_flash_data = {
72 .parts = nuc900_flash_partitions,
73 .nr_parts = ARRAY_SIZE(nuc900_flash_partitions),
76 static struct resource nuc900_flash_resources[] = {
78 .start = NUC900_FLASH_BASE,
79 .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
80 .flags = IORESOURCE_MEM,
84 static struct platform_device nuc900_flash_device = {
85 .name = "physmap-flash",
88 .platform_data = &nuc900_flash_data,
90 .resource = nuc900_flash_resources,
91 .num_resources = ARRAY_SIZE(nuc900_flash_resources),
94 /* USB EHCI Host Controller */
96 static struct resource nuc900_usb_ehci_resource[] = {
98 .start = W90X900_PA_USBEHCIHOST,
99 .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
100 .flags = IORESOURCE_MEM,
105 .flags = IORESOURCE_IRQ,
109 static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
111 static struct platform_device nuc900_device_usb_ehci = {
112 .name = "nuc900-ehci",
114 .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
115 .resource = nuc900_usb_ehci_resource,
117 .dma_mask = &nuc900_device_usb_ehci_dmamask,
118 .coherent_dma_mask = 0xffffffffUL
122 /* USB OHCI Host Controller */
124 static struct resource nuc900_usb_ohci_resource[] = {
126 .start = W90X900_PA_USBOHCIHOST,
127 .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
128 .flags = IORESOURCE_MEM,
133 .flags = IORESOURCE_IRQ,
137 static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
138 static struct platform_device nuc900_device_usb_ohci = {
139 .name = "nuc900-ohci",
141 .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
142 .resource = nuc900_usb_ohci_resource,
144 .dma_mask = &nuc900_device_usb_ohci_dmamask,
145 .coherent_dma_mask = 0xffffffffUL
149 /* USB Device (Gadget)*/
151 static struct resource nuc900_usbgadget_resource[] = {
153 .start = W90X900_PA_USBDEV,
154 .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
155 .flags = IORESOURCE_MEM,
160 .flags = IORESOURCE_IRQ,
164 static struct platform_device nuc900_device_usbgadget = {
165 .name = "nuc900-usbgadget",
167 .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
168 .resource = nuc900_usbgadget_resource,
173 static struct resource nuc900_emc_resource[] = {
175 .start = W90X900_PA_EMC,
176 .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
177 .flags = IORESOURCE_MEM,
182 .flags = IORESOURCE_IRQ,
187 .flags = IORESOURCE_IRQ,
191 static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
192 static struct platform_device nuc900_device_emc = {
193 .name = "nuc900-emc",
195 .num_resources = ARRAY_SIZE(nuc900_emc_resource),
196 .resource = nuc900_emc_resource,
198 .dma_mask = &nuc900_device_emc_dmamask,
199 .coherent_dma_mask = 0xffffffffUL
205 static struct nuc900_spi_info nuc900_spiflash_data = {
217 static struct resource nuc900_spi_resource[] = {
219 .start = W90X900_PA_I2C + SPIOFFSET,
220 .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
221 .flags = IORESOURCE_MEM,
226 .flags = IORESOURCE_IRQ,
230 static struct platform_device nuc900_device_spi = {
231 .name = "nuc900-spi",
233 .num_resources = ARRAY_SIZE(nuc900_spi_resource),
234 .resource = nuc900_spi_resource,
236 .platform_data = &nuc900_spiflash_data,
240 /* spi device, spi flash info */
242 static struct mtd_partition nuc900_spi_flash_partitions[] = {
244 .name = "bootloader(spi)",
250 static struct flash_platform_data nuc900_spi_flash_data = {
252 .parts = nuc900_spi_flash_partitions,
253 .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
257 static struct spi_board_info nuc900_spi_board_info[] __initdata = {
259 .modalias = "m25p80",
260 .max_speed_hz = 20000000,
263 .platform_data = &nuc900_spi_flash_data,
270 static struct resource nuc900_wdt_resource[] = {
272 .start = W90X900_PA_TIMER,
273 .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
274 .flags = IORESOURCE_MEM,
279 .flags = IORESOURCE_IRQ,
283 static struct platform_device nuc900_device_wdt = {
284 .name = "nuc900-wdt",
286 .num_resources = ARRAY_SIZE(nuc900_wdt_resource),
287 .resource = nuc900_wdt_resource,
291 * public device definition between 910 and 920, or 910
292 * and 950 or 950 and 960...,their dev platform register
293 * should be in specific file such as nuc950, nuc960 c
294 * files rather than the public dev.c file here. so the
295 * corresponding platform_device definition should not be
301 static struct resource nuc900_rtc_resource[] = {
303 .start = W90X900_PA_RTC,
304 .end = W90X900_PA_RTC + 0xff,
305 .flags = IORESOURCE_MEM,
310 .flags = IORESOURCE_IRQ,
314 struct platform_device nuc900_device_rtc = {
315 .name = "nuc900-rtc",
317 .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
318 .resource = nuc900_rtc_resource,
321 /*TouchScreen controller*/
323 static struct resource nuc900_ts_resource[] = {
325 .start = W90X900_PA_ADC,
326 .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
327 .flags = IORESOURCE_MEM,
332 .flags = IORESOURCE_IRQ,
336 struct platform_device nuc900_device_ts = {
339 .resource = nuc900_ts_resource,
340 .num_resources = ARRAY_SIZE(nuc900_ts_resource),
345 static struct resource nuc900_fmi_resource[] = {
347 .start = W90X900_PA_FMI,
348 .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
349 .flags = IORESOURCE_MEM,
354 .flags = IORESOURCE_IRQ,
358 struct platform_device nuc900_device_fmi = {
359 .name = "nuc900-fmi",
361 .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
362 .resource = nuc900_fmi_resource,
367 static int nuc900_keymap[] = {
389 static struct matrix_keymap_data nuc900_map_data = {
390 .keymap = nuc900_keymap,
391 .keymap_size = ARRAY_SIZE(nuc900_keymap),
394 struct w90p910_keypad_platform_data nuc900_keypad_info = {
395 .keymap_data = &nuc900_map_data,
400 static struct resource nuc900_kpi_resource[] = {
402 .start = W90X900_PA_KPI,
403 .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
404 .flags = IORESOURCE_MEM,
409 .flags = IORESOURCE_IRQ,
414 struct platform_device nuc900_device_kpi = {
415 .name = "nuc900-kpi",
417 .num_resources = ARRAY_SIZE(nuc900_kpi_resource),
418 .resource = nuc900_kpi_resource,
420 .platform_data = &nuc900_keypad_info,
426 static struct nuc900fb_display nuc900_lcd_info[] = {
427 /* Giantplus Technology GPM1040A0 320x240 Color TFT LCD */
429 .type = LCM_DCCS_VA_SRC_RGB565,
443 .devctl = 0x060800c0,
444 .fbctrl = 0x00a000a0,
449 static struct nuc900fb_mach_info nuc900_fb_info = {
450 #if defined(CONFIG_GPM1040A0_320X240)
451 .displays = &nuc900_lcd_info[0],
453 .displays = nuc900_lcd_info,
455 .num_displays = ARRAY_SIZE(nuc900_lcd_info),
456 .default_display = 0,
457 .gpio_dir = 0x00000004,
458 .gpio_dir_mask = 0xFFFFFFFD,
459 .gpio_data = 0x00000004,
460 .gpio_data_mask = 0xFFFFFFFD,
463 static struct resource nuc900_lcd_resource[] = {
465 .start = W90X900_PA_LCD,
466 .end = W90X900_PA_LCD + W90X900_SZ_LCD - 1,
467 .flags = IORESOURCE_MEM,
472 .flags = IORESOURCE_IRQ,
476 static u64 nuc900_device_lcd_dmamask = -1;
477 struct platform_device nuc900_device_lcd = {
478 .name = "nuc900-lcd",
480 .num_resources = ARRAY_SIZE(nuc900_lcd_resource),
481 .resource = nuc900_lcd_resource,
483 .dma_mask = &nuc900_device_lcd_dmamask,
484 .coherent_dma_mask = -1,
485 .platform_data = &nuc900_fb_info,
489 /* AUDIO controller*/
490 static u64 nuc900_device_audio_dmamask = -1;
491 static struct resource nuc900_ac97_resource[] = {
493 .start = W90X900_PA_ACTL,
494 .end = W90X900_PA_ACTL + W90X900_SZ_ACTL - 1,
495 .flags = IORESOURCE_MEM,
500 .flags = IORESOURCE_IRQ,
505 struct platform_device nuc900_device_ac97 = {
506 .name = "nuc900-ac97",
508 .num_resources = ARRAY_SIZE(nuc900_ac97_resource),
509 .resource = nuc900_ac97_resource,
511 .dma_mask = &nuc900_device_audio_dmamask,
512 .coherent_dma_mask = -1,
516 /*Here should be your evb resourse,such as LCD*/
518 static struct platform_device *nuc900_public_dev[] __initdata = {
519 &nuc900_serial_device,
520 &nuc900_flash_device,
521 &nuc900_device_usb_ehci,
522 &nuc900_device_usb_ohci,
523 &nuc900_device_usbgadget,
530 /* Provide adding specific CPU platform devices API */
532 void __init nuc900_board_init(struct platform_device **device, int size)
535 platform_add_devices(device, size);
536 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
537 spi_register_board_info(nuc900_spi_board_info,
538 ARRAY_SIZE(nuc900_spi_board_info));