Merge branch 'sh/dwarf-unwinder'
[pandora-kernel.git] / arch / arm / mach-w90x900 / dev.c
1 /*
2  * linux/arch/arm/mach-w90x900/dev.c
3  *
4  * Copyright (C) 2009 Nuvoton corporation.
5  *
6  * Wan ZongShun <mcuos.com@gmail.com>
7  *
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.
11  *
12  */
13
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
22 #include <linux/mtd/physmap.h>
23 #include <linux/mtd/mtd.h>
24 #include <linux/mtd/partitions.h>
25
26 #include <linux/spi/spi.h>
27 #include <linux/spi/flash.h>
28
29 #include <asm/mach/arch.h>
30 #include <asm/mach/map.h>
31 #include <asm/mach/irq.h>
32 #include <asm/mach-types.h>
33
34 #include <mach/regs-serial.h>
35 #include <mach/map.h>
36
37 #include "cpu.h"
38
39 /*NUC900 evb norflash driver data */
40
41 #define NUC900_FLASH_BASE       0xA0000000
42 #define NUC900_FLASH_SIZE       0x400000
43 #define SPIOFFSET               0x200
44 #define SPIOREG_SIZE            0x100
45
46 static struct mtd_partition nuc900_flash_partitions[] = {
47         {
48                 .name   =       "NOR Partition 1 for kernel (960K)",
49                 .size   =       0xF0000,
50                 .offset =       0x10000,
51         },
52         {
53                 .name   =       "NOR Partition 2 for image (1M)",
54                 .size   =       0x100000,
55                 .offset =       0x100000,
56         },
57         {
58                 .name   =       "NOR Partition 3 for user (2M)",
59                 .size   =       0x200000,
60                 .offset =       0x00200000,
61         }
62 };
63
64 static struct physmap_flash_data nuc900_flash_data = {
65         .width          =       2,
66         .parts          =       nuc900_flash_partitions,
67         .nr_parts       =       ARRAY_SIZE(nuc900_flash_partitions),
68 };
69
70 static struct resource nuc900_flash_resources[] = {
71         {
72                 .start  =       NUC900_FLASH_BASE,
73                 .end    =       NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
74                 .flags  =       IORESOURCE_MEM,
75         }
76 };
77
78 static struct platform_device nuc900_flash_device = {
79         .name           =       "physmap-flash",
80         .id             =       0,
81         .dev            = {
82                                 .platform_data = &nuc900_flash_data,
83                         },
84         .resource       =       nuc900_flash_resources,
85         .num_resources  =       ARRAY_SIZE(nuc900_flash_resources),
86 };
87
88 /* USB EHCI Host Controller */
89
90 static struct resource nuc900_usb_ehci_resource[] = {
91         [0] = {
92                 .start = W90X900_PA_USBEHCIHOST,
93                 .end   = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1,
94                 .flags = IORESOURCE_MEM,
95         },
96         [1] = {
97                 .start = IRQ_USBH,
98                 .end   = IRQ_USBH,
99                 .flags = IORESOURCE_IRQ,
100         }
101 };
102
103 static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
104
105 static struct platform_device nuc900_device_usb_ehci = {
106         .name             = "nuc900-ehci",
107         .id               = -1,
108         .num_resources    = ARRAY_SIZE(nuc900_usb_ehci_resource),
109         .resource         = nuc900_usb_ehci_resource,
110         .dev              = {
111                 .dma_mask = &nuc900_device_usb_ehci_dmamask,
112                 .coherent_dma_mask = 0xffffffffUL
113         }
114 };
115
116 /* USB OHCI Host Controller */
117
118 static struct resource nuc900_usb_ohci_resource[] = {
119         [0] = {
120                 .start = W90X900_PA_USBOHCIHOST,
121                 .end   = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1,
122                 .flags = IORESOURCE_MEM,
123         },
124         [1] = {
125                 .start = IRQ_USBH,
126                 .end   = IRQ_USBH,
127                 .flags = IORESOURCE_IRQ,
128         }
129 };
130
131 static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL;
132 static struct platform_device nuc900_device_usb_ohci = {
133         .name             = "nuc900-ohci",
134         .id               = -1,
135         .num_resources    = ARRAY_SIZE(nuc900_usb_ohci_resource),
136         .resource         = nuc900_usb_ohci_resource,
137         .dev              = {
138                 .dma_mask = &nuc900_device_usb_ohci_dmamask,
139                 .coherent_dma_mask = 0xffffffffUL
140         }
141 };
142
143 /* USB Device (Gadget)*/
144
145 static struct resource nuc900_usbgadget_resource[] = {
146         [0] = {
147                 .start = W90X900_PA_USBDEV,
148                 .end   = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1,
149                 .flags = IORESOURCE_MEM,
150         },
151         [1] = {
152                 .start = IRQ_USBD,
153                 .end   = IRQ_USBD,
154                 .flags = IORESOURCE_IRQ,
155         }
156 };
157
158 static struct platform_device nuc900_device_usbgadget = {
159         .name           = "nuc900-usbgadget",
160         .id             = -1,
161         .num_resources  = ARRAY_SIZE(nuc900_usbgadget_resource),
162         .resource       = nuc900_usbgadget_resource,
163 };
164
165 /* MAC device */
166
167 static struct resource nuc900_emc_resource[] = {
168         [0] = {
169                 .start = W90X900_PA_EMC,
170                 .end   = W90X900_PA_EMC + W90X900_SZ_EMC - 1,
171                 .flags = IORESOURCE_MEM,
172         },
173         [1] = {
174                 .start = IRQ_EMCTX,
175                 .end   = IRQ_EMCTX,
176                 .flags = IORESOURCE_IRQ,
177         },
178         [2] = {
179                 .start = IRQ_EMCRX,
180                 .end   = IRQ_EMCRX,
181                 .flags = IORESOURCE_IRQ,
182         }
183 };
184
185 static u64 nuc900_device_emc_dmamask = 0xffffffffUL;
186 static struct platform_device nuc900_device_emc = {
187         .name           = "nuc900-emc",
188         .id             = -1,
189         .num_resources  = ARRAY_SIZE(nuc900_emc_resource),
190         .resource       = nuc900_emc_resource,
191         .dev              = {
192                 .dma_mask = &nuc900_device_emc_dmamask,
193                 .coherent_dma_mask = 0xffffffffUL
194         }
195 };
196
197 /* SPI device */
198
199 static struct resource nuc900_spi_resource[] = {
200         [0] = {
201                 .start = W90X900_PA_I2C + SPIOFFSET,
202                 .end   = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1,
203                 .flags = IORESOURCE_MEM,
204         },
205         [1] = {
206                 .start = IRQ_SSP,
207                 .end   = IRQ_SSP,
208                 .flags = IORESOURCE_IRQ,
209         }
210 };
211
212 static struct platform_device nuc900_device_spi = {
213         .name           = "nuc900-spi",
214         .id             = -1,
215         .num_resources  = ARRAY_SIZE(nuc900_spi_resource),
216         .resource       = nuc900_spi_resource,
217 };
218
219 /* spi device, spi flash info */
220
221 static struct mtd_partition nuc900_spi_flash_partitions[] = {
222         {
223                 .name = "bootloader(spi)",
224                 .size = 0x0100000,
225                 .offset = 0,
226         },
227 };
228
229 static struct flash_platform_data nuc900_spi_flash_data = {
230         .name = "m25p80",
231         .parts =  nuc900_spi_flash_partitions,
232         .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions),
233         .type = "w25x16",
234 };
235
236 static struct spi_board_info nuc900_spi_board_info[] __initdata = {
237         {
238                 .modalias = "m25p80",
239                 .max_speed_hz = 20000000,
240                 .bus_num = 0,
241                 .chip_select = 1,
242                 .platform_data = &nuc900_spi_flash_data,
243                 .mode = SPI_MODE_0,
244         },
245 };
246
247 /* WDT Device */
248
249 static struct resource nuc900_wdt_resource[] = {
250         [0] = {
251                 .start = W90X900_PA_TIMER,
252                 .end   = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1,
253                 .flags = IORESOURCE_MEM,
254         },
255         [1] = {
256                 .start = IRQ_WDT,
257                 .end   = IRQ_WDT,
258                 .flags = IORESOURCE_IRQ,
259         }
260 };
261
262 static struct platform_device nuc900_device_wdt = {
263         .name           = "nuc900-wdt",
264         .id             = -1,
265         .num_resources  = ARRAY_SIZE(nuc900_wdt_resource),
266         .resource       = nuc900_wdt_resource,
267 };
268
269 /*
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
275  * static.
276 */
277
278 /* RTC controller*/
279
280 static struct resource nuc900_rtc_resource[] = {
281         [0] = {
282                 .start = W90X900_PA_RTC,
283                 .end   = W90X900_PA_RTC + 0xff,
284                 .flags = IORESOURCE_MEM,
285         },
286         [1] = {
287                 .start = IRQ_RTC,
288                 .end   = IRQ_RTC,
289                 .flags = IORESOURCE_IRQ,
290         },
291 };
292
293 struct platform_device nuc900_device_rtc = {
294         .name           = "nuc900-rtc",
295         .id             = -1,
296         .num_resources  = ARRAY_SIZE(nuc900_rtc_resource),
297         .resource       = nuc900_rtc_resource,
298 };
299
300 /*TouchScreen controller*/
301
302 static struct resource nuc900_ts_resource[] = {
303         [0] = {
304                 .start = W90X900_PA_ADC,
305                 .end   = W90X900_PA_ADC + W90X900_SZ_ADC-1,
306                 .flags = IORESOURCE_MEM,
307         },
308         [1] = {
309                 .start = IRQ_ADC,
310                 .end   = IRQ_ADC,
311                 .flags = IORESOURCE_IRQ,
312         },
313 };
314
315 struct platform_device nuc900_device_ts = {
316         .name           = "nuc900-ts",
317         .id             = -1,
318         .resource       = nuc900_ts_resource,
319         .num_resources  = ARRAY_SIZE(nuc900_ts_resource),
320 };
321
322 /* FMI Device */
323
324 static struct resource nuc900_fmi_resource[] = {
325         [0] = {
326                 .start = W90X900_PA_FMI,
327                 .end   = W90X900_PA_FMI + W90X900_SZ_FMI - 1,
328                 .flags = IORESOURCE_MEM,
329         },
330         [1] = {
331                 .start = IRQ_FMI,
332                 .end   = IRQ_FMI,
333                 .flags = IORESOURCE_IRQ,
334         }
335 };
336
337 struct platform_device nuc900_device_fmi = {
338         .name           = "nuc900-fmi",
339         .id             = -1,
340         .num_resources  = ARRAY_SIZE(nuc900_fmi_resource),
341         .resource       = nuc900_fmi_resource,
342 };
343
344 /* KPI controller*/
345
346 static struct resource nuc900_kpi_resource[] = {
347         [0] = {
348                 .start = W90X900_PA_KPI,
349                 .end   = W90X900_PA_KPI + W90X900_SZ_KPI - 1,
350                 .flags = IORESOURCE_MEM,
351         },
352         [1] = {
353                 .start = IRQ_KPI,
354                 .end   = IRQ_KPI,
355                 .flags = IORESOURCE_IRQ,
356         }
357
358 };
359
360 struct platform_device nuc900_device_kpi = {
361         .name           = "nuc900-kpi",
362         .id             = -1,
363         .num_resources  = ARRAY_SIZE(nuc900_kpi_resource),
364         .resource       = nuc900_kpi_resource,
365 };
366
367 /*Here should be your evb resourse,such as LCD*/
368
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,
375         &nuc900_device_emc,
376         &nuc900_device_spi,
377         &nuc900_device_wdt,
378 };
379
380 /* Provide adding specific CPU platform devices API */
381
382 void __init nuc900_board_init(struct platform_device **device, int size)
383 {
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));
388 }
389