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>
22 #include <linux/mtd/physmap.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
26 #include <linux/spi/spi.h>
27 #include <linux/spi/flash.h>
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 #include <asm/mach/irq.h>
32 #include <asm/mach-types.h>
34 #include <mach/regs-serial.h>
35 #include <mach/nuc900_spi.h>
41 /*NUC900 evb norflash driver data */
43 #define NUC900_FLASH_BASE 0xA0000000
44 #define NUC900_FLASH_SIZE 0x400000
45 #define SPIOFFSET 0x200
46 #define SPIOREG_SIZE 0x100
48 static struct mtd_partition nuc900_flash_partitions
[] = {
50 .name
= "NOR Partition 1 for kernel (960K)",
55 .name
= "NOR Partition 2 for image (1M)",
60 .name
= "NOR Partition 3 for user (2M)",
66 static struct physmap_flash_data nuc900_flash_data
= {
68 .parts
= nuc900_flash_partitions
,
69 .nr_parts
= ARRAY_SIZE(nuc900_flash_partitions
),
72 static struct resource nuc900_flash_resources
[] = {
74 .start
= NUC900_FLASH_BASE
,
75 .end
= NUC900_FLASH_BASE
+ NUC900_FLASH_SIZE
- 1,
76 .flags
= IORESOURCE_MEM
,
80 static struct platform_device nuc900_flash_device
= {
81 .name
= "physmap-flash",
84 .platform_data
= &nuc900_flash_data
,
86 .resource
= nuc900_flash_resources
,
87 .num_resources
= ARRAY_SIZE(nuc900_flash_resources
),
90 /* USB EHCI Host Controller */
92 static struct resource nuc900_usb_ehci_resource
[] = {
94 .start
= W90X900_PA_USBEHCIHOST
,
95 .end
= W90X900_PA_USBEHCIHOST
+ W90X900_SZ_USBEHCIHOST
- 1,
96 .flags
= IORESOURCE_MEM
,
101 .flags
= IORESOURCE_IRQ
,
105 static u64 nuc900_device_usb_ehci_dmamask
= 0xffffffffUL
;
107 static struct platform_device nuc900_device_usb_ehci
= {
108 .name
= "nuc900-ehci",
110 .num_resources
= ARRAY_SIZE(nuc900_usb_ehci_resource
),
111 .resource
= nuc900_usb_ehci_resource
,
113 .dma_mask
= &nuc900_device_usb_ehci_dmamask
,
114 .coherent_dma_mask
= 0xffffffffUL
118 /* USB OHCI Host Controller */
120 static struct resource nuc900_usb_ohci_resource
[] = {
122 .start
= W90X900_PA_USBOHCIHOST
,
123 .end
= W90X900_PA_USBOHCIHOST
+ W90X900_SZ_USBOHCIHOST
- 1,
124 .flags
= IORESOURCE_MEM
,
129 .flags
= IORESOURCE_IRQ
,
133 static u64 nuc900_device_usb_ohci_dmamask
= 0xffffffffUL
;
134 static struct platform_device nuc900_device_usb_ohci
= {
135 .name
= "nuc900-ohci",
137 .num_resources
= ARRAY_SIZE(nuc900_usb_ohci_resource
),
138 .resource
= nuc900_usb_ohci_resource
,
140 .dma_mask
= &nuc900_device_usb_ohci_dmamask
,
141 .coherent_dma_mask
= 0xffffffffUL
145 /* USB Device (Gadget)*/
147 static struct resource nuc900_usbgadget_resource
[] = {
149 .start
= W90X900_PA_USBDEV
,
150 .end
= W90X900_PA_USBDEV
+ W90X900_SZ_USBDEV
- 1,
151 .flags
= IORESOURCE_MEM
,
156 .flags
= IORESOURCE_IRQ
,
160 static struct platform_device nuc900_device_usbgadget
= {
161 .name
= "nuc900-usbgadget",
163 .num_resources
= ARRAY_SIZE(nuc900_usbgadget_resource
),
164 .resource
= nuc900_usbgadget_resource
,
169 static struct resource nuc900_emc_resource
[] = {
171 .start
= W90X900_PA_EMC
,
172 .end
= W90X900_PA_EMC
+ W90X900_SZ_EMC
- 1,
173 .flags
= IORESOURCE_MEM
,
178 .flags
= IORESOURCE_IRQ
,
183 .flags
= IORESOURCE_IRQ
,
187 static u64 nuc900_device_emc_dmamask
= 0xffffffffUL
;
188 static struct platform_device nuc900_device_emc
= {
189 .name
= "nuc900-emc",
191 .num_resources
= ARRAY_SIZE(nuc900_emc_resource
),
192 .resource
= nuc900_emc_resource
,
194 .dma_mask
= &nuc900_device_emc_dmamask
,
195 .coherent_dma_mask
= 0xffffffffUL
201 static struct nuc900_spi_info nuc900_spiflash_data
= {
213 static struct resource nuc900_spi_resource
[] = {
215 .start
= W90X900_PA_I2C
+ SPIOFFSET
,
216 .end
= W90X900_PA_I2C
+ SPIOFFSET
+ SPIOREG_SIZE
- 1,
217 .flags
= IORESOURCE_MEM
,
222 .flags
= IORESOURCE_IRQ
,
226 static struct platform_device nuc900_device_spi
= {
227 .name
= "nuc900-spi",
229 .num_resources
= ARRAY_SIZE(nuc900_spi_resource
),
230 .resource
= nuc900_spi_resource
,
232 .platform_data
= &nuc900_spiflash_data
,
236 /* spi device, spi flash info */
238 static struct mtd_partition nuc900_spi_flash_partitions
[] = {
240 .name
= "bootloader(spi)",
246 static struct flash_platform_data nuc900_spi_flash_data
= {
248 .parts
= nuc900_spi_flash_partitions
,
249 .nr_parts
= ARRAY_SIZE(nuc900_spi_flash_partitions
),
253 static struct spi_board_info nuc900_spi_board_info
[] __initdata
= {
255 .modalias
= "m25p80",
256 .max_speed_hz
= 20000000,
259 .platform_data
= &nuc900_spi_flash_data
,
266 static struct resource nuc900_wdt_resource
[] = {
268 .start
= W90X900_PA_TIMER
,
269 .end
= W90X900_PA_TIMER
+ W90X900_SZ_TIMER
- 1,
270 .flags
= IORESOURCE_MEM
,
275 .flags
= IORESOURCE_IRQ
,
279 static struct platform_device nuc900_device_wdt
= {
280 .name
= "nuc900-wdt",
282 .num_resources
= ARRAY_SIZE(nuc900_wdt_resource
),
283 .resource
= nuc900_wdt_resource
,
287 * public device definition between 910 and 920, or 910
288 * and 950 or 950 and 960...,their dev platform register
289 * should be in specific file such as nuc950, nuc960 c
290 * files rather than the public dev.c file here. so the
291 * corresponding platform_device definition should not be
297 static struct resource nuc900_rtc_resource
[] = {
299 .start
= W90X900_PA_RTC
,
300 .end
= W90X900_PA_RTC
+ 0xff,
301 .flags
= IORESOURCE_MEM
,
306 .flags
= IORESOURCE_IRQ
,
310 struct platform_device nuc900_device_rtc
= {
311 .name
= "nuc900-rtc",
313 .num_resources
= ARRAY_SIZE(nuc900_rtc_resource
),
314 .resource
= nuc900_rtc_resource
,
317 /*TouchScreen controller*/
319 static struct resource nuc900_ts_resource
[] = {
321 .start
= W90X900_PA_ADC
,
322 .end
= W90X900_PA_ADC
+ W90X900_SZ_ADC
-1,
323 .flags
= IORESOURCE_MEM
,
328 .flags
= IORESOURCE_IRQ
,
332 struct platform_device nuc900_device_ts
= {
335 .resource
= nuc900_ts_resource
,
336 .num_resources
= ARRAY_SIZE(nuc900_ts_resource
),
341 static struct resource nuc900_fmi_resource
[] = {
343 .start
= W90X900_PA_FMI
,
344 .end
= W90X900_PA_FMI
+ W90X900_SZ_FMI
- 1,
345 .flags
= IORESOURCE_MEM
,
350 .flags
= IORESOURCE_IRQ
,
354 struct platform_device nuc900_device_fmi
= {
355 .name
= "nuc900-fmi",
357 .num_resources
= ARRAY_SIZE(nuc900_fmi_resource
),
358 .resource
= nuc900_fmi_resource
,
363 static struct resource nuc900_kpi_resource
[] = {
365 .start
= W90X900_PA_KPI
,
366 .end
= W90X900_PA_KPI
+ W90X900_SZ_KPI
- 1,
367 .flags
= IORESOURCE_MEM
,
372 .flags
= IORESOURCE_IRQ
,
377 struct platform_device nuc900_device_kpi
= {
378 .name
= "nuc900-kpi",
380 .num_resources
= ARRAY_SIZE(nuc900_kpi_resource
),
381 .resource
= nuc900_kpi_resource
,
384 #ifdef CONFIG_FB_NUC900
386 static struct resource nuc900_lcd_resource
[] = {
388 .start
= W90X900_PA_LCD
,
389 .end
= W90X900_PA_LCD
+ W90X900_SZ_LCD
- 1,
390 .flags
= IORESOURCE_MEM
,
395 .flags
= IORESOURCE_IRQ
,
399 static u64 nuc900_device_lcd_dmamask
= -1;
400 struct platform_device nuc900_device_lcd
= {
401 .name
= "nuc900-lcd",
403 .num_resources
= ARRAY_SIZE(nuc900_lcd_resource
),
404 .resource
= nuc900_lcd_resource
,
406 .dma_mask
= &nuc900_device_lcd_dmamask
,
407 .coherent_dma_mask
= -1,
411 void nuc900_fb_set_platdata(struct nuc900fb_mach_info
*pd
)
413 struct nuc900fb_mach_info
*npd
;
415 npd
= kmalloc(sizeof(*npd
), GFP_KERNEL
);
417 memcpy(npd
, pd
, sizeof(*npd
));
418 nuc900_device_lcd
.dev
.platform_data
= npd
;
420 printk(KERN_ERR
"no memory for LCD platform data\n");
425 /*Here should be your evb resourse,such as LCD*/
427 static struct platform_device
*nuc900_public_dev
[] __initdata
= {
428 &nuc900_serial_device
,
429 &nuc900_flash_device
,
430 &nuc900_device_usb_ehci
,
431 &nuc900_device_usb_ohci
,
432 &nuc900_device_usbgadget
,
438 /* Provide adding specific CPU platform devices API */
440 void __init
nuc900_board_init(struct platform_device
**device
, int size
)
442 platform_add_devices(device
, size
);
443 platform_add_devices(nuc900_public_dev
, ARRAY_SIZE(nuc900_public_dev
));
444 spi_register_board_info(nuc900_spi_board_info
,
445 ARRAY_SIZE(nuc900_spi_board_info
));