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>
39 #include <mach/regs-ldm.h>
40 #include <mach/w90p910_keypad.h>
44 /*NUC900 evb norflash driver data */
46 #define NUC900_FLASH_BASE 0xA0000000
47 #define NUC900_FLASH_SIZE 0x400000
48 #define SPIOFFSET 0x200
49 #define SPIOREG_SIZE 0x100
51 static struct mtd_partition nuc900_flash_partitions
[] = {
53 .name
= "NOR Partition 1 for kernel (960K)",
58 .name
= "NOR Partition 2 for image (1M)",
63 .name
= "NOR Partition 3 for user (2M)",
69 static struct physmap_flash_data nuc900_flash_data
= {
71 .parts
= nuc900_flash_partitions
,
72 .nr_parts
= ARRAY_SIZE(nuc900_flash_partitions
),
75 static struct resource nuc900_flash_resources
[] = {
77 .start
= NUC900_FLASH_BASE
,
78 .end
= NUC900_FLASH_BASE
+ NUC900_FLASH_SIZE
- 1,
79 .flags
= IORESOURCE_MEM
,
83 static struct platform_device nuc900_flash_device
= {
84 .name
= "physmap-flash",
87 .platform_data
= &nuc900_flash_data
,
89 .resource
= nuc900_flash_resources
,
90 .num_resources
= ARRAY_SIZE(nuc900_flash_resources
),
93 /* USB EHCI Host Controller */
95 static struct resource nuc900_usb_ehci_resource
[] = {
97 .start
= W90X900_PA_USBEHCIHOST
,
98 .end
= W90X900_PA_USBEHCIHOST
+ W90X900_SZ_USBEHCIHOST
- 1,
99 .flags
= IORESOURCE_MEM
,
104 .flags
= IORESOURCE_IRQ
,
108 static u64 nuc900_device_usb_ehci_dmamask
= 0xffffffffUL
;
110 static struct platform_device nuc900_device_usb_ehci
= {
111 .name
= "nuc900-ehci",
113 .num_resources
= ARRAY_SIZE(nuc900_usb_ehci_resource
),
114 .resource
= nuc900_usb_ehci_resource
,
116 .dma_mask
= &nuc900_device_usb_ehci_dmamask
,
117 .coherent_dma_mask
= 0xffffffffUL
121 /* USB OHCI Host Controller */
123 static struct resource nuc900_usb_ohci_resource
[] = {
125 .start
= W90X900_PA_USBOHCIHOST
,
126 .end
= W90X900_PA_USBOHCIHOST
+ W90X900_SZ_USBOHCIHOST
- 1,
127 .flags
= IORESOURCE_MEM
,
132 .flags
= IORESOURCE_IRQ
,
136 static u64 nuc900_device_usb_ohci_dmamask
= 0xffffffffUL
;
137 static struct platform_device nuc900_device_usb_ohci
= {
138 .name
= "nuc900-ohci",
140 .num_resources
= ARRAY_SIZE(nuc900_usb_ohci_resource
),
141 .resource
= nuc900_usb_ohci_resource
,
143 .dma_mask
= &nuc900_device_usb_ohci_dmamask
,
144 .coherent_dma_mask
= 0xffffffffUL
148 /* USB Device (Gadget)*/
150 static struct resource nuc900_usbgadget_resource
[] = {
152 .start
= W90X900_PA_USBDEV
,
153 .end
= W90X900_PA_USBDEV
+ W90X900_SZ_USBDEV
- 1,
154 .flags
= IORESOURCE_MEM
,
159 .flags
= IORESOURCE_IRQ
,
163 static struct platform_device nuc900_device_usbgadget
= {
164 .name
= "nuc900-usbgadget",
166 .num_resources
= ARRAY_SIZE(nuc900_usbgadget_resource
),
167 .resource
= nuc900_usbgadget_resource
,
172 static struct resource nuc900_emc_resource
[] = {
174 .start
= W90X900_PA_EMC
,
175 .end
= W90X900_PA_EMC
+ W90X900_SZ_EMC
- 1,
176 .flags
= IORESOURCE_MEM
,
181 .flags
= IORESOURCE_IRQ
,
186 .flags
= IORESOURCE_IRQ
,
190 static u64 nuc900_device_emc_dmamask
= 0xffffffffUL
;
191 static struct platform_device nuc900_device_emc
= {
192 .name
= "nuc900-emc",
194 .num_resources
= ARRAY_SIZE(nuc900_emc_resource
),
195 .resource
= nuc900_emc_resource
,
197 .dma_mask
= &nuc900_device_emc_dmamask
,
198 .coherent_dma_mask
= 0xffffffffUL
204 static struct nuc900_spi_info nuc900_spiflash_data
= {
216 static struct resource nuc900_spi_resource
[] = {
218 .start
= W90X900_PA_I2C
+ SPIOFFSET
,
219 .end
= W90X900_PA_I2C
+ SPIOFFSET
+ SPIOREG_SIZE
- 1,
220 .flags
= IORESOURCE_MEM
,
225 .flags
= IORESOURCE_IRQ
,
229 static struct platform_device nuc900_device_spi
= {
230 .name
= "nuc900-spi",
232 .num_resources
= ARRAY_SIZE(nuc900_spi_resource
),
233 .resource
= nuc900_spi_resource
,
235 .platform_data
= &nuc900_spiflash_data
,
239 /* spi device, spi flash info */
241 static struct mtd_partition nuc900_spi_flash_partitions
[] = {
243 .name
= "bootloader(spi)",
249 static struct flash_platform_data nuc900_spi_flash_data
= {
251 .parts
= nuc900_spi_flash_partitions
,
252 .nr_parts
= ARRAY_SIZE(nuc900_spi_flash_partitions
),
256 static struct spi_board_info nuc900_spi_board_info
[] __initdata
= {
258 .modalias
= "m25p80",
259 .max_speed_hz
= 20000000,
262 .platform_data
= &nuc900_spi_flash_data
,
269 static struct resource nuc900_wdt_resource
[] = {
271 .start
= W90X900_PA_TIMER
,
272 .end
= W90X900_PA_TIMER
+ W90X900_SZ_TIMER
- 1,
273 .flags
= IORESOURCE_MEM
,
278 .flags
= IORESOURCE_IRQ
,
282 static struct platform_device nuc900_device_wdt
= {
283 .name
= "nuc900-wdt",
285 .num_resources
= ARRAY_SIZE(nuc900_wdt_resource
),
286 .resource
= nuc900_wdt_resource
,
290 * public device definition between 910 and 920, or 910
291 * and 950 or 950 and 960...,their dev platform register
292 * should be in specific file such as nuc950, nuc960 c
293 * files rather than the public dev.c file here. so the
294 * corresponding platform_device definition should not be
300 static struct resource nuc900_rtc_resource
[] = {
302 .start
= W90X900_PA_RTC
,
303 .end
= W90X900_PA_RTC
+ 0xff,
304 .flags
= IORESOURCE_MEM
,
309 .flags
= IORESOURCE_IRQ
,
313 struct platform_device nuc900_device_rtc
= {
314 .name
= "nuc900-rtc",
316 .num_resources
= ARRAY_SIZE(nuc900_rtc_resource
),
317 .resource
= nuc900_rtc_resource
,
320 /*TouchScreen controller*/
322 static struct resource nuc900_ts_resource
[] = {
324 .start
= W90X900_PA_ADC
,
325 .end
= W90X900_PA_ADC
+ W90X900_SZ_ADC
-1,
326 .flags
= IORESOURCE_MEM
,
331 .flags
= IORESOURCE_IRQ
,
335 struct platform_device nuc900_device_ts
= {
338 .resource
= nuc900_ts_resource
,
339 .num_resources
= ARRAY_SIZE(nuc900_ts_resource
),
344 static struct resource nuc900_fmi_resource
[] = {
346 .start
= W90X900_PA_FMI
,
347 .end
= W90X900_PA_FMI
+ W90X900_SZ_FMI
- 1,
348 .flags
= IORESOURCE_MEM
,
353 .flags
= IORESOURCE_IRQ
,
357 struct platform_device nuc900_device_fmi
= {
358 .name
= "nuc900-fmi",
360 .num_resources
= ARRAY_SIZE(nuc900_fmi_resource
),
361 .resource
= nuc900_fmi_resource
,
366 static int nuc900_keymap
[] = {
388 static struct matrix_keymap_data nuc900_map_data
= {
389 .keymap
= nuc900_keymap
,
390 .keymap_size
= ARRAY_SIZE(nuc900_keymap
),
393 struct w90p910_keypad_platform_data nuc900_keypad_info
= {
394 .keymap_data
= &nuc900_map_data
,
399 static struct resource nuc900_kpi_resource
[] = {
401 .start
= W90X900_PA_KPI
,
402 .end
= W90X900_PA_KPI
+ W90X900_SZ_KPI
- 1,
403 .flags
= IORESOURCE_MEM
,
408 .flags
= IORESOURCE_IRQ
,
413 struct platform_device nuc900_device_kpi
= {
414 .name
= "nuc900-kpi",
416 .num_resources
= ARRAY_SIZE(nuc900_kpi_resource
),
417 .resource
= nuc900_kpi_resource
,
419 .platform_data
= &nuc900_keypad_info
,
425 static struct nuc900fb_display nuc900_lcd_info
[] = {
426 /* Giantplus Technology GPM1040A0 320x240 Color TFT LCD */
428 .type
= LCM_DCCS_VA_SRC_RGB565
,
442 .devctl
= 0x060800c0,
443 .fbctrl
= 0x00a000a0,
448 static struct nuc900fb_mach_info nuc900_fb_info
= {
449 #if defined(CONFIG_GPM1040A0_320X240)
450 .displays
= &nuc900_lcd_info
[0],
452 .displays
= nuc900_lcd_info
,
454 .num_displays
= ARRAY_SIZE(nuc900_lcd_info
),
455 .default_display
= 0,
456 .gpio_dir
= 0x00000004,
457 .gpio_dir_mask
= 0xFFFFFFFD,
458 .gpio_data
= 0x00000004,
459 .gpio_data_mask
= 0xFFFFFFFD,
462 static struct resource nuc900_lcd_resource
[] = {
464 .start
= W90X900_PA_LCD
,
465 .end
= W90X900_PA_LCD
+ W90X900_SZ_LCD
- 1,
466 .flags
= IORESOURCE_MEM
,
471 .flags
= IORESOURCE_IRQ
,
475 static u64 nuc900_device_lcd_dmamask
= -1;
476 struct platform_device nuc900_device_lcd
= {
477 .name
= "nuc900-lcd",
479 .num_resources
= ARRAY_SIZE(nuc900_lcd_resource
),
480 .resource
= nuc900_lcd_resource
,
482 .dma_mask
= &nuc900_device_lcd_dmamask
,
483 .coherent_dma_mask
= -1,
484 .platform_data
= &nuc900_fb_info
,
488 /* AUDIO controller*/
489 static u64 nuc900_device_audio_dmamask
= -1;
490 static struct resource nuc900_ac97_resource
[] = {
492 .start
= W90X900_PA_ACTL
,
493 .end
= W90X900_PA_ACTL
+ W90X900_SZ_ACTL
- 1,
494 .flags
= IORESOURCE_MEM
,
499 .flags
= IORESOURCE_IRQ
,
504 struct platform_device nuc900_device_audio
= {
505 .name
= "nuc900-audio",
507 .num_resources
= ARRAY_SIZE(nuc900_ac97_resource
),
508 .resource
= nuc900_ac97_resource
,
510 .dma_mask
= &nuc900_device_audio_dmamask
,
511 .coherent_dma_mask
= -1,
515 /*Here should be your evb resourse,such as LCD*/
517 static struct platform_device
*nuc900_public_dev
[] __initdata
= {
518 &nuc900_serial_device
,
519 &nuc900_flash_device
,
520 &nuc900_device_usb_ehci
,
521 &nuc900_device_usb_ohci
,
522 &nuc900_device_usbgadget
,
526 &nuc900_device_audio
,
529 /* Provide adding specific CPU platform devices API */
531 void __init
nuc900_board_init(struct platform_device
**device
, int size
)
533 platform_add_devices(device
, size
);
534 platform_add_devices(nuc900_public_dev
, ARRAY_SIZE(nuc900_public_dev
));
535 spi_register_board_info(nuc900_spi_board_info
,
536 ARRAY_SIZE(nuc900_spi_board_info
));