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/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/irq.h>
33 #include <asm/mach-types.h>
35 #include <mach/regs-serial.h>
36 #include <mach/nuc900_spi.h>
42 /*NUC900 evb norflash driver data */
44 #define NUC900_FLASH_BASE 0xA0000000
45 #define NUC900_FLASH_SIZE 0x400000
46 #define SPIOFFSET 0x200
47 #define SPIOREG_SIZE 0x100
49 static struct mtd_partition nuc900_flash_partitions[] = {
51 .name = "NOR Partition 1 for kernel (960K)",
56 .name = "NOR Partition 2 for image (1M)",
61 .name = "NOR Partition 3 for user (2M)",
67 static struct physmap_flash_data nuc900_flash_data = {
69 .parts = nuc900_flash_partitions,
70 .nr_parts = ARRAY_SIZE(nuc900_flash_partitions),
73 static struct resource nuc900_flash_resources[] = {
75 .start = NUC900_FLASH_BASE,
76 .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
77 .flags = IORESOURCE_MEM,
81 static struct platform_device nuc900_flash_device = {
82 .name = "physmap-flash",
85 .platform_data = &nuc900_flash_data,
87 .resource = nuc900_flash_resources,
88 .num_resources = ARRAY_SIZE(nuc900_flash_resources),
91 /* USB EHCI Host Controller */
93 static struct resource nuc900_usb_ehci_resource[] = {
95 .start = W90X900_PA_USBEHCIHOST,
96 .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
97 .flags = IORESOURCE_MEM,
102 .flags = IORESOURCE_IRQ,
106 static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
108 static struct platform_device nuc900_device_usb_ehci = {
109 .name = "nuc900-ehci",
111 .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
112 .resource = nuc900_usb_ehci_resource,
114 .dma_mask = &nuc900_device_usb_ehci_dmamask,
115 .coherent_dma_mask = 0xffffffffUL
119 /* USB OHCI Host Controller */
121 static struct resource nuc900_usb_ohci_resource[] = {
123 .start = W90X900_PA_USBOHCIHOST,
124 .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
125 .flags = IORESOURCE_MEM,
130 .flags = IORESOURCE_IRQ,
134 static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
135 static struct platform_device nuc900_device_usb_ohci = {
136 .name = "nuc900-ohci",
138 .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
139 .resource = nuc900_usb_ohci_resource,
141 .dma_mask = &nuc900_device_usb_ohci_dmamask,
142 .coherent_dma_mask = 0xffffffffUL
146 /* USB Device (Gadget)*/
148 static struct resource nuc900_usbgadget_resource[] = {
150 .start = W90X900_PA_USBDEV,
151 .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
152 .flags = IORESOURCE_MEM,
157 .flags = IORESOURCE_IRQ,
161 static struct platform_device nuc900_device_usbgadget = {
162 .name = "nuc900-usbgadget",
164 .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
165 .resource = nuc900_usbgadget_resource,
170 static struct resource nuc900_emc_resource[] = {
172 .start = W90X900_PA_EMC,
173 .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
174 .flags = IORESOURCE_MEM,
179 .flags = IORESOURCE_IRQ,
184 .flags = IORESOURCE_IRQ,
188 static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
189 static struct platform_device nuc900_device_emc = {
190 .name = "nuc900-emc",
192 .num_resources = ARRAY_SIZE(nuc900_emc_resource),
193 .resource = nuc900_emc_resource,
195 .dma_mask = &nuc900_device_emc_dmamask,
196 .coherent_dma_mask = 0xffffffffUL
202 static struct nuc900_spi_info nuc900_spiflash_data = {
214 static struct resource nuc900_spi_resource[] = {
216 .start = W90X900_PA_I2C + SPIOFFSET,
217 .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
218 .flags = IORESOURCE_MEM,
223 .flags = IORESOURCE_IRQ,
227 static struct platform_device nuc900_device_spi = {
228 .name = "nuc900-spi",
230 .num_resources = ARRAY_SIZE(nuc900_spi_resource),
231 .resource = nuc900_spi_resource,
233 .platform_data = &nuc900_spiflash_data,
237 /* spi device, spi flash info */
239 static struct mtd_partition nuc900_spi_flash_partitions[] = {
241 .name = "bootloader(spi)",
247 static struct flash_platform_data nuc900_spi_flash_data = {
249 .parts = nuc900_spi_flash_partitions,
250 .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
254 static struct spi_board_info nuc900_spi_board_info[] __initdata = {
256 .modalias = "m25p80",
257 .max_speed_hz = 20000000,
260 .platform_data = &nuc900_spi_flash_data,
267 static struct resource nuc900_wdt_resource[] = {
269 .start = W90X900_PA_TIMER,
270 .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
271 .flags = IORESOURCE_MEM,
276 .flags = IORESOURCE_IRQ,
280 static struct platform_device nuc900_device_wdt = {
281 .name = "nuc900-wdt",
283 .num_resources = ARRAY_SIZE(nuc900_wdt_resource),
284 .resource = nuc900_wdt_resource,
288 * public device definition between 910 and 920, or 910
289 * and 950 or 950 and 960...,their dev platform register
290 * should be in specific file such as nuc950, nuc960 c
291 * files rather than the public dev.c file here. so the
292 * corresponding platform_device definition should not be
298 static struct resource nuc900_rtc_resource[] = {
300 .start = W90X900_PA_RTC,
301 .end = W90X900_PA_RTC + 0xff,
302 .flags = IORESOURCE_MEM,
307 .flags = IORESOURCE_IRQ,
311 struct platform_device nuc900_device_rtc = {
312 .name = "nuc900-rtc",
314 .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
315 .resource = nuc900_rtc_resource,
318 /*TouchScreen controller*/
320 static struct resource nuc900_ts_resource[] = {
322 .start = W90X900_PA_ADC,
323 .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
324 .flags = IORESOURCE_MEM,
329 .flags = IORESOURCE_IRQ,
333 struct platform_device nuc900_device_ts = {
336 .resource = nuc900_ts_resource,
337 .num_resources = ARRAY_SIZE(nuc900_ts_resource),
342 static struct resource nuc900_fmi_resource[] = {
344 .start = W90X900_PA_FMI,
345 .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
346 .flags = IORESOURCE_MEM,
351 .flags = IORESOURCE_IRQ,
355 struct platform_device nuc900_device_fmi = {
356 .name = "nuc900-fmi",
358 .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
359 .resource = nuc900_fmi_resource,
364 static struct resource nuc900_kpi_resource[] = {
366 .start = W90X900_PA_KPI,
367 .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
368 .flags = IORESOURCE_MEM,
373 .flags = IORESOURCE_IRQ,
378 struct platform_device nuc900_device_kpi = {
379 .name = "nuc900-kpi",
381 .num_resources = ARRAY_SIZE(nuc900_kpi_resource),
382 .resource = nuc900_kpi_resource,
385 #ifdef CONFIG_FB_NUC900
387 static struct resource nuc900_lcd_resource[] = {
389 .start = W90X900_PA_LCD,
390 .end = W90X900_PA_LCD + W90X900_SZ_LCD - 1,
391 .flags = IORESOURCE_MEM,
396 .flags = IORESOURCE_IRQ,
400 static u64 nuc900_device_lcd_dmamask = -1;
401 struct platform_device nuc900_device_lcd = {
402 .name = "nuc900-lcd",
404 .num_resources = ARRAY_SIZE(nuc900_lcd_resource),
405 .resource = nuc900_lcd_resource,
407 .dma_mask = &nuc900_device_lcd_dmamask,
408 .coherent_dma_mask = -1,
412 void nuc900_fb_set_platdata(struct nuc900fb_mach_info *pd)
414 struct nuc900fb_mach_info *npd;
416 npd = kmalloc(sizeof(*npd), GFP_KERNEL);
418 memcpy(npd, pd, sizeof(*npd));
419 nuc900_device_lcd.dev.platform_data = npd;
421 printk(KERN_ERR "no memory for LCD platform data\n");
426 /* AUDIO controller*/
427 static u64 nuc900_device_audio_dmamask = -1;
428 static struct resource nuc900_ac97_resource[] = {
430 .start = W90X900_PA_ACTL,
431 .end = W90X900_PA_ACTL + W90X900_SZ_ACTL - 1,
432 .flags = IORESOURCE_MEM,
437 .flags = IORESOURCE_IRQ,
442 struct platform_device nuc900_device_audio = {
443 .name = "nuc900-audio",
445 .num_resources = ARRAY_SIZE(nuc900_ac97_resource),
446 .resource = nuc900_ac97_resource,
448 .dma_mask = &nuc900_device_audio_dmamask,
449 .coherent_dma_mask = -1,
453 /*Here should be your evb resourse,such as LCD*/
455 static struct platform_device *nuc900_public_dev[] __initdata = {
456 &nuc900_serial_device,
457 &nuc900_flash_device,
458 &nuc900_device_usb_ehci,
459 &nuc900_device_usb_ohci,
460 &nuc900_device_usbgadget,
464 &nuc900_device_audio,
467 /* Provide adding specific CPU platform devices API */
469 void __init nuc900_board_init(struct platform_device **device, int size)
471 platform_add_devices(device, size);
472 platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev));
473 spi_register_board_info(nuc900_spi_board_info,
474 ARRAY_SIZE(nuc900_spi_board_info));