acpiphp: Execute ACPI _REG method for hotadded devices
[linux/fpc-iii.git] / arch / arm / mach-w90x900 / dev.c
blobec711f4b40191affdef9fb1e021780e4b900747e
1 /*
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>
36 #include <mach/map.h>
38 #include "cpu.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)",
50 .size = 0xF0000,
51 .offset = 0x10000,
54 .name = "NOR Partition 2 for image (1M)",
55 .size = 0x100000,
56 .offset = 0x100000,
59 .name = "NOR Partition 3 for user (2M)",
60 .size = 0x200000,
61 .offset = 0x00200000,
65 static struct physmap_flash_data nuc900_flash_data = {
66 .width = 2,
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",
81 .id = 0,
82 .dev = {
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[] = {
92 [0] = {
93 .start = W90X900_PA_USBEHCIHOST,
94 .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
95 .flags = IORESOURCE_MEM,
97 [1] = {
98 .start = IRQ_USBH,
99 .end = IRQ_USBH,
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",
108 .id = -1,
109 .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource),
110 .resource = nuc900_usb_ehci_resource,
111 .dev = {
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[] = {
120 [0] = {
121 .start = W90X900_PA_USBOHCIHOST,
122 .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
123 .flags = IORESOURCE_MEM,
125 [1] = {
126 .start = IRQ_USBH,
127 .end = IRQ_USBH,
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",
135 .id = -1,
136 .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource),
137 .resource = nuc900_usb_ohci_resource,
138 .dev = {
139 .dma_mask = &nuc900_device_usb_ohci_dmamask,
140 .coherent_dma_mask = 0xffffffffUL
144 /* USB Device (Gadget)*/
146 static struct resource nuc900_usbgadget_resource[] = {
147 [0] = {
148 .start = W90X900_PA_USBDEV,
149 .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
150 .flags = IORESOURCE_MEM,
152 [1] = {
153 .start = IRQ_USBD,
154 .end = IRQ_USBD,
155 .flags = IORESOURCE_IRQ,
159 static struct platform_device nuc900_device_usbgadget = {
160 .name = "nuc900-usbgadget",
161 .id = -1,
162 .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource),
163 .resource = nuc900_usbgadget_resource,
166 /* MAC device */
168 static struct resource nuc900_emc_resource[] = {
169 [0] = {
170 .start = W90X900_PA_EMC,
171 .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
172 .flags = IORESOURCE_MEM,
174 [1] = {
175 .start = IRQ_EMCTX,
176 .end = IRQ_EMCTX,
177 .flags = IORESOURCE_IRQ,
179 [2] = {
180 .start = IRQ_EMCRX,
181 .end = IRQ_EMCRX,
182 .flags = IORESOURCE_IRQ,
186 static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
187 static struct platform_device nuc900_device_emc = {
188 .name = "nuc900-emc",
189 .id = -1,
190 .num_resources = ARRAY_SIZE(nuc900_emc_resource),
191 .resource = nuc900_emc_resource,
192 .dev = {
193 .dma_mask = &nuc900_device_emc_dmamask,
194 .coherent_dma_mask = 0xffffffffUL
198 /* SPI device */
200 static struct nuc900_spi_info nuc900_spiflash_data = {
201 .num_cs = 1,
202 .lsb = 0,
203 .txneg = 1,
204 .rxneg = 0,
205 .divider = 24,
206 .sleep = 0,
207 .txnum = 0,
208 .txbitlen = 1,
209 .bus_num = 0,
212 static struct resource nuc900_spi_resource[] = {
213 [0] = {
214 .start = W90X900_PA_I2C + SPIOFFSET,
215 .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
216 .flags = IORESOURCE_MEM,
218 [1] = {
219 .start = IRQ_SSP,
220 .end = IRQ_SSP,
221 .flags = IORESOURCE_IRQ,
225 static struct platform_device nuc900_device_spi = {
226 .name = "nuc900-spi",
227 .id = -1,
228 .num_resources = ARRAY_SIZE(nuc900_spi_resource),
229 .resource = nuc900_spi_resource,
230 .dev = {
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)",
240 .size = 0x0100000,
241 .offset = 0,
245 static struct flash_platform_data nuc900_spi_flash_data = {
246 .name = "m25p80",
247 .parts = nuc900_spi_flash_partitions,
248 .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
249 .type = "w25x16",
252 static struct spi_board_info nuc900_spi_board_info[] __initdata = {
254 .modalias = "m25p80",
255 .max_speed_hz = 20000000,
256 .bus_num = 0,
257 .chip_select = 1,
258 .platform_data = &nuc900_spi_flash_data,
259 .mode = SPI_MODE_0,
263 /* WDT Device */
265 static struct resource nuc900_wdt_resource[] = {
266 [0] = {
267 .start = W90X900_PA_TIMER,
268 .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
269 .flags = IORESOURCE_MEM,
271 [1] = {
272 .start = IRQ_WDT,
273 .end = IRQ_WDT,
274 .flags = IORESOURCE_IRQ,
278 static struct platform_device nuc900_device_wdt = {
279 .name = "nuc900-wdt",
280 .id = -1,
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
291 * static.
294 /* RTC controller*/
296 static struct resource nuc900_rtc_resource[] = {
297 [0] = {
298 .start = W90X900_PA_RTC,
299 .end = W90X900_PA_RTC + 0xff,
300 .flags = IORESOURCE_MEM,
302 [1] = {
303 .start = IRQ_RTC,
304 .end = IRQ_RTC,
305 .flags = IORESOURCE_IRQ,
309 struct platform_device nuc900_device_rtc = {
310 .name = "nuc900-rtc",
311 .id = -1,
312 .num_resources = ARRAY_SIZE(nuc900_rtc_resource),
313 .resource = nuc900_rtc_resource,
316 /*TouchScreen controller*/
318 static struct resource nuc900_ts_resource[] = {
319 [0] = {
320 .start = W90X900_PA_ADC,
321 .end = W90X900_PA_ADC + W90X900_SZ_ADC-1,
322 .flags = IORESOURCE_MEM,
324 [1] = {
325 .start = IRQ_ADC,
326 .end = IRQ_ADC,
327 .flags = IORESOURCE_IRQ,
331 struct platform_device nuc900_device_ts = {
332 .name = "nuc900-ts",
333 .id = -1,
334 .resource = nuc900_ts_resource,
335 .num_resources = ARRAY_SIZE(nuc900_ts_resource),
338 /* FMI Device */
340 static struct resource nuc900_fmi_resource[] = {
341 [0] = {
342 .start = W90X900_PA_FMI,
343 .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
344 .flags = IORESOURCE_MEM,
346 [1] = {
347 .start = IRQ_FMI,
348 .end = IRQ_FMI,
349 .flags = IORESOURCE_IRQ,
353 struct platform_device nuc900_device_fmi = {
354 .name = "nuc900-fmi",
355 .id = -1,
356 .num_resources = ARRAY_SIZE(nuc900_fmi_resource),
357 .resource = nuc900_fmi_resource,
360 /* KPI controller*/
362 static struct resource nuc900_kpi_resource[] = {
363 [0] = {
364 .start = W90X900_PA_KPI,
365 .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
366 .flags = IORESOURCE_MEM,
368 [1] = {
369 .start = IRQ_KPI,
370 .end = IRQ_KPI,
371 .flags = IORESOURCE_IRQ,
376 struct platform_device nuc900_device_kpi = {
377 .name = "nuc900-kpi",
378 .id = -1,
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,
391 &nuc900_device_emc,
392 &nuc900_device_spi,
393 &nuc900_device_wdt,
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));