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>
39 /*NUC900 evb norflash driver data */
41 #define NUC900_FLASH_BASE 0xA0000000
42 #define NUC900_FLASH_SIZE 0x400000
43 #define SPIOFFSET 0x200
44 #define SPIOREG_SIZE 0x100
46 static struct mtd_partition nuc900_flash_partitions
[] = {
48 .name
= "NOR Partition 1 for kernel (960K)",
53 .name
= "NOR Partition 2 for image (1M)",
58 .name
= "NOR Partition 3 for user (2M)",
64 static struct physmap_flash_data nuc900_flash_data
= {
66 .parts
= nuc900_flash_partitions
,
67 .nr_parts
= ARRAY_SIZE(nuc900_flash_partitions
),
70 static struct resource nuc900_flash_resources
[] = {
72 .start
= NUC900_FLASH_BASE
,
73 .end
= NUC900_FLASH_BASE
+ NUC900_FLASH_SIZE
- 1,
74 .flags
= IORESOURCE_MEM
,
78 static struct platform_device nuc900_flash_device
= {
79 .name
= "physmap-flash",
82 .platform_data
= &nuc900_flash_data
,
84 .resource
= nuc900_flash_resources
,
85 .num_resources
= ARRAY_SIZE(nuc900_flash_resources
),
88 /* USB EHCI Host Controller */
90 static struct resource nuc900_usb_ehci_resource
[] = {
92 .start
= W90X900_PA_USBEHCIHOST
,
93 .end
= W90X900_PA_USBEHCIHOST
+ W90X900_SZ_USBEHCIHOST
- 1,
94 .flags
= IORESOURCE_MEM
,
99 .flags
= IORESOURCE_IRQ
,
103 static u64 nuc900_device_usb_ehci_dmamask
= 0xffffffffUL
;
105 static struct platform_device nuc900_device_usb_ehci
= {
106 .name
= "nuc900-ehci",
108 .num_resources
= ARRAY_SIZE(nuc900_usb_ehci_resource
),
109 .resource
= nuc900_usb_ehci_resource
,
111 .dma_mask
= &nuc900_device_usb_ehci_dmamask
,
112 .coherent_dma_mask
= 0xffffffffUL
116 /* USB OHCI Host Controller */
118 static struct resource nuc900_usb_ohci_resource
[] = {
120 .start
= W90X900_PA_USBOHCIHOST
,
121 .end
= W90X900_PA_USBOHCIHOST
+ W90X900_SZ_USBOHCIHOST
- 1,
122 .flags
= IORESOURCE_MEM
,
127 .flags
= IORESOURCE_IRQ
,
131 static u64 nuc900_device_usb_ohci_dmamask
= 0xffffffffUL
;
132 static struct platform_device nuc900_device_usb_ohci
= {
133 .name
= "nuc900-ohci",
135 .num_resources
= ARRAY_SIZE(nuc900_usb_ohci_resource
),
136 .resource
= nuc900_usb_ohci_resource
,
138 .dma_mask
= &nuc900_device_usb_ohci_dmamask
,
139 .coherent_dma_mask
= 0xffffffffUL
143 /* USB Device (Gadget)*/
145 static struct resource nuc900_usbgadget_resource
[] = {
147 .start
= W90X900_PA_USBDEV
,
148 .end
= W90X900_PA_USBDEV
+ W90X900_SZ_USBDEV
- 1,
149 .flags
= IORESOURCE_MEM
,
154 .flags
= IORESOURCE_IRQ
,
158 static struct platform_device nuc900_device_usbgadget
= {
159 .name
= "nuc900-usbgadget",
161 .num_resources
= ARRAY_SIZE(nuc900_usbgadget_resource
),
162 .resource
= nuc900_usbgadget_resource
,
167 static struct resource nuc900_emc_resource
[] = {
169 .start
= W90X900_PA_EMC
,
170 .end
= W90X900_PA_EMC
+ W90X900_SZ_EMC
- 1,
171 .flags
= IORESOURCE_MEM
,
176 .flags
= IORESOURCE_IRQ
,
181 .flags
= IORESOURCE_IRQ
,
185 static u64 nuc900_device_emc_dmamask
= 0xffffffffUL
;
186 static struct platform_device nuc900_device_emc
= {
187 .name
= "nuc900-emc",
189 .num_resources
= ARRAY_SIZE(nuc900_emc_resource
),
190 .resource
= nuc900_emc_resource
,
192 .dma_mask
= &nuc900_device_emc_dmamask
,
193 .coherent_dma_mask
= 0xffffffffUL
199 static struct resource nuc900_spi_resource
[] = {
201 .start
= W90X900_PA_I2C
+ SPIOFFSET
,
202 .end
= W90X900_PA_I2C
+ SPIOFFSET
+ SPIOREG_SIZE
- 1,
203 .flags
= IORESOURCE_MEM
,
208 .flags
= IORESOURCE_IRQ
,
212 static struct platform_device nuc900_device_spi
= {
213 .name
= "nuc900-spi",
215 .num_resources
= ARRAY_SIZE(nuc900_spi_resource
),
216 .resource
= nuc900_spi_resource
,
219 /* spi device, spi flash info */
221 static struct mtd_partition nuc900_spi_flash_partitions
[] = {
223 .name
= "bootloader(spi)",
229 static struct flash_platform_data nuc900_spi_flash_data
= {
231 .parts
= nuc900_spi_flash_partitions
,
232 .nr_parts
= ARRAY_SIZE(nuc900_spi_flash_partitions
),
236 static struct spi_board_info nuc900_spi_board_info
[] __initdata
= {
238 .modalias
= "m25p80",
239 .max_speed_hz
= 20000000,
242 .platform_data
= &nuc900_spi_flash_data
,
249 static struct resource nuc900_wdt_resource
[] = {
251 .start
= W90X900_PA_TIMER
,
252 .end
= W90X900_PA_TIMER
+ W90X900_SZ_TIMER
- 1,
253 .flags
= IORESOURCE_MEM
,
258 .flags
= IORESOURCE_IRQ
,
262 static struct platform_device nuc900_device_wdt
= {
263 .name
= "nuc900-wdt",
265 .num_resources
= ARRAY_SIZE(nuc900_wdt_resource
),
266 .resource
= nuc900_wdt_resource
,
270 * public device definition between 910 and 920, or 910
271 * and 950 or 950 and 960...,their dev platform register
272 * should be in specific file such as nuc950, nuc960 c
273 * files rather than the public dev.c file here. so the
274 * corresponding platform_device definition should not be
280 static struct resource nuc900_rtc_resource
[] = {
282 .start
= W90X900_PA_RTC
,
283 .end
= W90X900_PA_RTC
+ 0xff,
284 .flags
= IORESOURCE_MEM
,
289 .flags
= IORESOURCE_IRQ
,
293 struct platform_device nuc900_device_rtc
= {
294 .name
= "nuc900-rtc",
296 .num_resources
= ARRAY_SIZE(nuc900_rtc_resource
),
297 .resource
= nuc900_rtc_resource
,
300 /*TouchScreen controller*/
302 static struct resource nuc900_ts_resource
[] = {
304 .start
= W90X900_PA_ADC
,
305 .end
= W90X900_PA_ADC
+ W90X900_SZ_ADC
-1,
306 .flags
= IORESOURCE_MEM
,
311 .flags
= IORESOURCE_IRQ
,
315 struct platform_device nuc900_device_ts
= {
318 .resource
= nuc900_ts_resource
,
319 .num_resources
= ARRAY_SIZE(nuc900_ts_resource
),
324 static struct resource nuc900_fmi_resource
[] = {
326 .start
= W90X900_PA_FMI
,
327 .end
= W90X900_PA_FMI
+ W90X900_SZ_FMI
- 1,
328 .flags
= IORESOURCE_MEM
,
333 .flags
= IORESOURCE_IRQ
,
337 struct platform_device nuc900_device_fmi
= {
338 .name
= "nuc900-fmi",
340 .num_resources
= ARRAY_SIZE(nuc900_fmi_resource
),
341 .resource
= nuc900_fmi_resource
,
346 static struct resource nuc900_kpi_resource
[] = {
348 .start
= W90X900_PA_KPI
,
349 .end
= W90X900_PA_KPI
+ W90X900_SZ_KPI
- 1,
350 .flags
= IORESOURCE_MEM
,
355 .flags
= IORESOURCE_IRQ
,
360 struct platform_device nuc900_device_kpi
= {
361 .name
= "nuc900-kpi",
363 .num_resources
= ARRAY_SIZE(nuc900_kpi_resource
),
364 .resource
= nuc900_kpi_resource
,
367 /*Here should be your evb resourse,such as LCD*/
369 static struct platform_device
*nuc900_public_dev
[] __initdata
= {
370 &nuc900_serial_device
,
371 &nuc900_flash_device
,
372 &nuc900_device_usb_ehci
,
373 &nuc900_device_usb_ohci
,
374 &nuc900_device_usbgadget
,
380 /* Provide adding specific CPU platform devices API */
382 void __init
nuc900_board_init(struct platform_device
**device
, int size
)
384 platform_add_devices(device
, size
);
385 platform_add_devices(nuc900_public_dev
, ARRAY_SIZE(nuc900_public_dev
));
386 spi_register_board_info(nuc900_spi_board_info
,
387 ARRAY_SIZE(nuc900_spi_board_info
));