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>
40 /*NUC900 evb norflash driver data */
42 #define NUC900_FLASH_BASE 0xA0000000
43 #define NUC900_FLASH_SIZE 0x400000
44 #define SPIOFFSET 0x200
45 #define SPIOREG_SIZE 0x100
47 static struct mtd_partition nuc900_flash_partitions
[] = {
49 .name
= "NOR Partition 1 for kernel (960K)",
54 .name
= "NOR Partition 2 for image (1M)",
59 .name
= "NOR Partition 3 for user (2M)",
65 static struct physmap_flash_data nuc900_flash_data
= {
67 .parts
= nuc900_flash_partitions
,
68 .nr_parts
= ARRAY_SIZE(nuc900_flash_partitions
),
71 static struct resource nuc900_flash_resources
[] = {
73 .start
= NUC900_FLASH_BASE
,
74 .end
= NUC900_FLASH_BASE
+ NUC900_FLASH_SIZE
- 1,
75 .flags
= IORESOURCE_MEM
,
79 static struct platform_device nuc900_flash_device
= {
80 .name
= "physmap-flash",
83 .platform_data
= &nuc900_flash_data
,
85 .resource
= nuc900_flash_resources
,
86 .num_resources
= ARRAY_SIZE(nuc900_flash_resources
),
89 /* USB EHCI Host Controller */
91 static struct resource nuc900_usb_ehci_resource
[] = {
93 .start
= W90X900_PA_USBEHCIHOST
,
94 .end
= W90X900_PA_USBEHCIHOST
+ W90X900_SZ_USBEHCIHOST
- 1,
95 .flags
= IORESOURCE_MEM
,
100 .flags
= IORESOURCE_IRQ
,
104 static u64 nuc900_device_usb_ehci_dmamask
= 0xffffffffUL
;
106 static struct platform_device nuc900_device_usb_ehci
= {
107 .name
= "nuc900-ehci",
109 .num_resources
= ARRAY_SIZE(nuc900_usb_ehci_resource
),
110 .resource
= nuc900_usb_ehci_resource
,
112 .dma_mask
= &nuc900_device_usb_ehci_dmamask
,
113 .coherent_dma_mask
= 0xffffffffUL
117 /* USB OHCI Host Controller */
119 static struct resource nuc900_usb_ohci_resource
[] = {
121 .start
= W90X900_PA_USBOHCIHOST
,
122 .end
= W90X900_PA_USBOHCIHOST
+ W90X900_SZ_USBOHCIHOST
- 1,
123 .flags
= IORESOURCE_MEM
,
128 .flags
= IORESOURCE_IRQ
,
132 static u64 nuc900_device_usb_ohci_dmamask
= 0xffffffffUL
;
133 static struct platform_device nuc900_device_usb_ohci
= {
134 .name
= "nuc900-ohci",
136 .num_resources
= ARRAY_SIZE(nuc900_usb_ohci_resource
),
137 .resource
= nuc900_usb_ohci_resource
,
139 .dma_mask
= &nuc900_device_usb_ohci_dmamask
,
140 .coherent_dma_mask
= 0xffffffffUL
144 /* USB Device (Gadget)*/
146 static struct resource nuc900_usbgadget_resource
[] = {
148 .start
= W90X900_PA_USBDEV
,
149 .end
= W90X900_PA_USBDEV
+ W90X900_SZ_USBDEV
- 1,
150 .flags
= IORESOURCE_MEM
,
155 .flags
= IORESOURCE_IRQ
,
159 static struct platform_device nuc900_device_usbgadget
= {
160 .name
= "nuc900-usbgadget",
162 .num_resources
= ARRAY_SIZE(nuc900_usbgadget_resource
),
163 .resource
= nuc900_usbgadget_resource
,
168 static struct resource nuc900_emc_resource
[] = {
170 .start
= W90X900_PA_EMC
,
171 .end
= W90X900_PA_EMC
+ W90X900_SZ_EMC
- 1,
172 .flags
= IORESOURCE_MEM
,
177 .flags
= IORESOURCE_IRQ
,
182 .flags
= IORESOURCE_IRQ
,
186 static u64 nuc900_device_emc_dmamask
= 0xffffffffUL
;
187 static struct platform_device nuc900_device_emc
= {
188 .name
= "nuc900-emc",
190 .num_resources
= ARRAY_SIZE(nuc900_emc_resource
),
191 .resource
= nuc900_emc_resource
,
193 .dma_mask
= &nuc900_device_emc_dmamask
,
194 .coherent_dma_mask
= 0xffffffffUL
200 static struct nuc900_spi_info nuc900_spiflash_data
= {
212 static struct resource nuc900_spi_resource
[] = {
214 .start
= W90X900_PA_I2C
+ SPIOFFSET
,
215 .end
= W90X900_PA_I2C
+ SPIOFFSET
+ SPIOREG_SIZE
- 1,
216 .flags
= IORESOURCE_MEM
,
221 .flags
= IORESOURCE_IRQ
,
225 static struct platform_device nuc900_device_spi
= {
226 .name
= "nuc900-spi",
228 .num_resources
= ARRAY_SIZE(nuc900_spi_resource
),
229 .resource
= nuc900_spi_resource
,
231 .platform_data
= &nuc900_spiflash_data
,
235 /* spi device, spi flash info */
237 static struct mtd_partition nuc900_spi_flash_partitions
[] = {
239 .name
= "bootloader(spi)",
245 static struct flash_platform_data nuc900_spi_flash_data
= {
247 .parts
= nuc900_spi_flash_partitions
,
248 .nr_parts
= ARRAY_SIZE(nuc900_spi_flash_partitions
),
252 static struct spi_board_info nuc900_spi_board_info
[] __initdata
= {
254 .modalias
= "m25p80",
255 .max_speed_hz
= 20000000,
258 .platform_data
= &nuc900_spi_flash_data
,
265 static struct resource nuc900_wdt_resource
[] = {
267 .start
= W90X900_PA_TIMER
,
268 .end
= W90X900_PA_TIMER
+ W90X900_SZ_TIMER
- 1,
269 .flags
= IORESOURCE_MEM
,
274 .flags
= IORESOURCE_IRQ
,
278 static struct platform_device nuc900_device_wdt
= {
279 .name
= "nuc900-wdt",
281 .num_resources
= ARRAY_SIZE(nuc900_wdt_resource
),
282 .resource
= nuc900_wdt_resource
,
286 * public device definition between 910 and 920, or 910
287 * and 950 or 950 and 960...,their dev platform register
288 * should be in specific file such as nuc950, nuc960 c
289 * files rather than the public dev.c file here. so the
290 * corresponding platform_device definition should not be
296 static struct resource nuc900_rtc_resource
[] = {
298 .start
= W90X900_PA_RTC
,
299 .end
= W90X900_PA_RTC
+ 0xff,
300 .flags
= IORESOURCE_MEM
,
305 .flags
= IORESOURCE_IRQ
,
309 struct platform_device nuc900_device_rtc
= {
310 .name
= "nuc900-rtc",
312 .num_resources
= ARRAY_SIZE(nuc900_rtc_resource
),
313 .resource
= nuc900_rtc_resource
,
316 /*TouchScreen controller*/
318 static struct resource nuc900_ts_resource
[] = {
320 .start
= W90X900_PA_ADC
,
321 .end
= W90X900_PA_ADC
+ W90X900_SZ_ADC
-1,
322 .flags
= IORESOURCE_MEM
,
327 .flags
= IORESOURCE_IRQ
,
331 struct platform_device nuc900_device_ts
= {
334 .resource
= nuc900_ts_resource
,
335 .num_resources
= ARRAY_SIZE(nuc900_ts_resource
),
340 static struct resource nuc900_fmi_resource
[] = {
342 .start
= W90X900_PA_FMI
,
343 .end
= W90X900_PA_FMI
+ W90X900_SZ_FMI
- 1,
344 .flags
= IORESOURCE_MEM
,
349 .flags
= IORESOURCE_IRQ
,
353 struct platform_device nuc900_device_fmi
= {
354 .name
= "nuc900-fmi",
356 .num_resources
= ARRAY_SIZE(nuc900_fmi_resource
),
357 .resource
= nuc900_fmi_resource
,
362 static struct resource nuc900_kpi_resource
[] = {
364 .start
= W90X900_PA_KPI
,
365 .end
= W90X900_PA_KPI
+ W90X900_SZ_KPI
- 1,
366 .flags
= IORESOURCE_MEM
,
371 .flags
= IORESOURCE_IRQ
,
376 struct platform_device nuc900_device_kpi
= {
377 .name
= "nuc900-kpi",
379 .num_resources
= ARRAY_SIZE(nuc900_kpi_resource
),
380 .resource
= nuc900_kpi_resource
,
383 /*Here should be your evb resourse,such as LCD*/
385 static struct platform_device
*nuc900_public_dev
[] __initdata
= {
386 &nuc900_serial_device
,
387 &nuc900_flash_device
,
388 &nuc900_device_usb_ehci
,
389 &nuc900_device_usb_ohci
,
390 &nuc900_device_usbgadget
,
396 /* Provide adding specific CPU platform devices API */
398 void __init
nuc900_board_init(struct platform_device
**device
, int size
)
400 platform_add_devices(device
, size
);
401 platform_add_devices(nuc900_public_dev
, ARRAY_SIZE(nuc900_public_dev
));
402 spi_register_board_info(nuc900_spi_board_info
,
403 ARRAY_SIZE(nuc900_spi_board_info
));