Commit | Line | Data |
---|---|---|
b886d83c | 1 | // SPDX-License-Identifier: GPL-2.0-only |
35c9221a | 2 | /* |
3 | * linux/arch/arm/mach-w90x900/dev.c | |
4 | * | |
5 | * Copyright (C) 2009 Nuvoton corporation. | |
6 | * | |
7 | * Wan ZongShun <mcuos.com@gmail.com> | |
35c9221a | 8 | */ |
9 | ||
10 | #include <linux/kernel.h> | |
11 | #include <linux/types.h> | |
12 | #include <linux/interrupt.h> | |
13 | #include <linux/list.h> | |
14 | #include <linux/timer.h> | |
15 | #include <linux/init.h> | |
16 | #include <linux/platform_device.h> | |
5a0e3ad6 | 17 | #include <linux/slab.h> |
f7b861b7 | 18 | #include <linux/cpu.h> |
35c9221a | 19 | |
20 | #include <linux/mtd/physmap.h> | |
21 | #include <linux/mtd/mtd.h> | |
22 | #include <linux/mtd/partitions.h> | |
23 | ||
24 | #include <linux/spi/spi.h> | |
25 | #include <linux/spi/flash.h> | |
26 | ||
86dfe446 | 27 | #include <asm/system_misc.h> |
35c9221a | 28 | #include <asm/mach/arch.h> |
29 | #include <asm/mach/map.h> | |
30 | #include <asm/mach/irq.h> | |
31 | #include <asm/mach-types.h> | |
32 | ||
33 | #include <mach/regs-serial.h> | |
54ecf4f0 | 34 | #include <linux/platform_data/spi-nuc900.h> |
35c9221a | 35 | #include <mach/map.h> |
54ecf4f0 | 36 | #include <linux/platform_data/video-nuc900fb.h> |
6a446b90 | 37 | #include <mach/regs-ldm.h> |
54ecf4f0 | 38 | #include <linux/platform_data/keypad-w90p910.h> |
35c9221a | 39 | |
40 | #include "cpu.h" | |
41 | ||
42 | /*NUC900 evb norflash driver data */ | |
43 | ||
44 | #define NUC900_FLASH_BASE 0xA0000000 | |
45 | #define NUC900_FLASH_SIZE 0x400000 | |
46 | #define SPIOFFSET 0x200 | |
47 | #define SPIOREG_SIZE 0x100 | |
48 | ||
49 | static struct mtd_partition nuc900_flash_partitions[] = { | |
50 | { | |
51 | .name = "NOR Partition 1 for kernel (960K)", | |
52 | .size = 0xF0000, | |
53 | .offset = 0x10000, | |
54 | }, | |
55 | { | |
56 | .name = "NOR Partition 2 for image (1M)", | |
57 | .size = 0x100000, | |
58 | .offset = 0x100000, | |
59 | }, | |
60 | { | |
61 | .name = "NOR Partition 3 for user (2M)", | |
62 | .size = 0x200000, | |
63 | .offset = 0x00200000, | |
64 | } | |
65 | }; | |
66 | ||
67 | static struct physmap_flash_data nuc900_flash_data = { | |
68 | .width = 2, | |
69 | .parts = nuc900_flash_partitions, | |
70 | .nr_parts = ARRAY_SIZE(nuc900_flash_partitions), | |
71 | }; | |
72 | ||
73 | static struct resource nuc900_flash_resources[] = { | |
74 | { | |
75 | .start = NUC900_FLASH_BASE, | |
76 | .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1, | |
77 | .flags = IORESOURCE_MEM, | |
78 | } | |
79 | }; | |
80 | ||
81 | static struct platform_device nuc900_flash_device = { | |
82 | .name = "physmap-flash", | |
83 | .id = 0, | |
84 | .dev = { | |
85 | .platform_data = &nuc900_flash_data, | |
86 | }, | |
87 | .resource = nuc900_flash_resources, | |
88 | .num_resources = ARRAY_SIZE(nuc900_flash_resources), | |
89 | }; | |
90 | ||
91 | /* USB EHCI Host Controller */ | |
92 | ||
93 | static struct resource nuc900_usb_ehci_resource[] = { | |
94 | [0] = { | |
95 | .start = W90X900_PA_USBEHCIHOST, | |
96 | .end = W90X900_PA_USBEHCIHOST + W90X900_SZ_USBEHCIHOST - 1, | |
97 | .flags = IORESOURCE_MEM, | |
98 | }, | |
99 | [1] = { | |
100 | .start = IRQ_USBH, | |
101 | .end = IRQ_USBH, | |
102 | .flags = IORESOURCE_IRQ, | |
103 | } | |
104 | }; | |
105 | ||
106 | static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL; | |
107 | ||
108 | static struct platform_device nuc900_device_usb_ehci = { | |
109 | .name = "nuc900-ehci", | |
110 | .id = -1, | |
111 | .num_resources = ARRAY_SIZE(nuc900_usb_ehci_resource), | |
112 | .resource = nuc900_usb_ehci_resource, | |
113 | .dev = { | |
114 | .dma_mask = &nuc900_device_usb_ehci_dmamask, | |
115 | .coherent_dma_mask = 0xffffffffUL | |
116 | } | |
117 | }; | |
118 | ||
119 | /* USB OHCI Host Controller */ | |
120 | ||
121 | static struct resource nuc900_usb_ohci_resource[] = { | |
122 | [0] = { | |
123 | .start = W90X900_PA_USBOHCIHOST, | |
124 | .end = W90X900_PA_USBOHCIHOST + W90X900_SZ_USBOHCIHOST - 1, | |
125 | .flags = IORESOURCE_MEM, | |
126 | }, | |
127 | [1] = { | |
128 | .start = IRQ_USBH, | |
129 | .end = IRQ_USBH, | |
130 | .flags = IORESOURCE_IRQ, | |
131 | } | |
132 | }; | |
133 | ||
134 | static u64 nuc900_device_usb_ohci_dmamask = 0xffffffffUL; | |
135 | static struct platform_device nuc900_device_usb_ohci = { | |
136 | .name = "nuc900-ohci", | |
137 | .id = -1, | |
138 | .num_resources = ARRAY_SIZE(nuc900_usb_ohci_resource), | |
139 | .resource = nuc900_usb_ohci_resource, | |
140 | .dev = { | |
141 | .dma_mask = &nuc900_device_usb_ohci_dmamask, | |
142 | .coherent_dma_mask = 0xffffffffUL | |
143 | } | |
144 | }; | |
145 | ||
146 | /* USB Device (Gadget)*/ | |
147 | ||
148 | static struct resource nuc900_usbgadget_resource[] = { | |
149 | [0] = { | |
150 | .start = W90X900_PA_USBDEV, | |
151 | .end = W90X900_PA_USBDEV + W90X900_SZ_USBDEV - 1, | |
152 | .flags = IORESOURCE_MEM, | |
153 | }, | |
154 | [1] = { | |
155 | .start = IRQ_USBD, | |
156 | .end = IRQ_USBD, | |
157 | .flags = IORESOURCE_IRQ, | |
158 | } | |
159 | }; | |
160 | ||
161 | static struct platform_device nuc900_device_usbgadget = { | |
162 | .name = "nuc900-usbgadget", | |
163 | .id = -1, | |
164 | .num_resources = ARRAY_SIZE(nuc900_usbgadget_resource), | |
165 | .resource = nuc900_usbgadget_resource, | |
166 | }; | |
167 | ||
168 | /* MAC device */ | |
169 | ||
170 | static struct resource nuc900_emc_resource[] = { | |
171 | [0] = { | |
172 | .start = W90X900_PA_EMC, | |
173 | .end = W90X900_PA_EMC + W90X900_SZ_EMC - 1, | |
174 | .flags = IORESOURCE_MEM, | |
175 | }, | |
176 | [1] = { | |
177 | .start = IRQ_EMCTX, | |
178 | .end = IRQ_EMCTX, | |
179 | .flags = IORESOURCE_IRQ, | |
180 | }, | |
181 | [2] = { | |
182 | .start = IRQ_EMCRX, | |
183 | .end = IRQ_EMCRX, | |
184 | .flags = IORESOURCE_IRQ, | |
185 | } | |
186 | }; | |
187 | ||
188 | static u64 nuc900_device_emc_dmamask = 0xffffffffUL; | |
189 | static struct platform_device nuc900_device_emc = { | |
190 | .name = "nuc900-emc", | |
191 | .id = -1, | |
192 | .num_resources = ARRAY_SIZE(nuc900_emc_resource), | |
193 | .resource = nuc900_emc_resource, | |
194 | .dev = { | |
195 | .dma_mask = &nuc900_device_emc_dmamask, | |
196 | .coherent_dma_mask = 0xffffffffUL | |
197 | } | |
198 | }; | |
199 | ||
200 | /* SPI device */ | |
201 | ||
d76cdf23 | 202 | static struct nuc900_spi_info nuc900_spiflash_data = { |
39986ca6 | 203 | .num_cs = 1, |
204 | .lsb = 0, | |
205 | .txneg = 1, | |
206 | .rxneg = 0, | |
207 | .divider = 24, | |
208 | .sleep = 0, | |
209 | .txnum = 0, | |
c6ca2e46 | 210 | .txbitlen = 8, |
39986ca6 | 211 | .bus_num = 0, |
212 | }; | |
213 | ||
35c9221a | 214 | static struct resource nuc900_spi_resource[] = { |
215 | [0] = { | |
216 | .start = W90X900_PA_I2C + SPIOFFSET, | |
217 | .end = W90X900_PA_I2C + SPIOFFSET + SPIOREG_SIZE - 1, | |
218 | .flags = IORESOURCE_MEM, | |
219 | }, | |
220 | [1] = { | |
221 | .start = IRQ_SSP, | |
222 | .end = IRQ_SSP, | |
223 | .flags = IORESOURCE_IRQ, | |
224 | } | |
225 | }; | |
226 | ||
227 | static struct platform_device nuc900_device_spi = { | |
228 | .name = "nuc900-spi", | |
229 | .id = -1, | |
230 | .num_resources = ARRAY_SIZE(nuc900_spi_resource), | |
231 | .resource = nuc900_spi_resource, | |
39986ca6 | 232 | .dev = { |
233 | .platform_data = &nuc900_spiflash_data, | |
234 | } | |
35c9221a | 235 | }; |
236 | ||
237 | /* spi device, spi flash info */ | |
238 | ||
239 | static struct mtd_partition nuc900_spi_flash_partitions[] = { | |
240 | { | |
241 | .name = "bootloader(spi)", | |
242 | .size = 0x0100000, | |
243 | .offset = 0, | |
244 | }, | |
245 | }; | |
246 | ||
247 | static struct flash_platform_data nuc900_spi_flash_data = { | |
248 | .name = "m25p80", | |
249 | .parts = nuc900_spi_flash_partitions, | |
250 | .nr_parts = ARRAY_SIZE(nuc900_spi_flash_partitions), | |
251 | .type = "w25x16", | |
252 | }; | |
253 | ||
254 | static struct spi_board_info nuc900_spi_board_info[] __initdata = { | |
255 | { | |
256 | .modalias = "m25p80", | |
257 | .max_speed_hz = 20000000, | |
258 | .bus_num = 0, | |
c6ca2e46 | 259 | .chip_select = 0, |
35c9221a | 260 | .platform_data = &nuc900_spi_flash_data, |
261 | .mode = SPI_MODE_0, | |
262 | }, | |
263 | }; | |
264 | ||
265 | /* WDT Device */ | |
266 | ||
267 | static struct resource nuc900_wdt_resource[] = { | |
268 | [0] = { | |
269 | .start = W90X900_PA_TIMER, | |
270 | .end = W90X900_PA_TIMER + W90X900_SZ_TIMER - 1, | |
271 | .flags = IORESOURCE_MEM, | |
272 | }, | |
273 | [1] = { | |
274 | .start = IRQ_WDT, | |
275 | .end = IRQ_WDT, | |
276 | .flags = IORESOURCE_IRQ, | |
277 | } | |
278 | }; | |
279 | ||
280 | static struct platform_device nuc900_device_wdt = { | |
281 | .name = "nuc900-wdt", | |
282 | .id = -1, | |
283 | .num_resources = ARRAY_SIZE(nuc900_wdt_resource), | |
284 | .resource = nuc900_wdt_resource, | |
285 | }; | |
286 | ||
287 | /* | |
288 | * public device definition between 910 and 920, or 910 | |
289 | * and 950 or 950 and 960...,their dev platform register | |
290 | * should be in specific file such as nuc950, nuc960 c | |
291 | * files rather than the public dev.c file here. so the | |
292 | * corresponding platform_device definition should not be | |
293 | * static. | |
294 | */ | |
295 | ||
296 | /* RTC controller*/ | |
297 | ||
298 | static struct resource nuc900_rtc_resource[] = { | |
299 | [0] = { | |
300 | .start = W90X900_PA_RTC, | |
301 | .end = W90X900_PA_RTC + 0xff, | |
302 | .flags = IORESOURCE_MEM, | |
303 | }, | |
304 | [1] = { | |
305 | .start = IRQ_RTC, | |
306 | .end = IRQ_RTC, | |
307 | .flags = IORESOURCE_IRQ, | |
308 | }, | |
309 | }; | |
310 | ||
311 | struct platform_device nuc900_device_rtc = { | |
312 | .name = "nuc900-rtc", | |
313 | .id = -1, | |
314 | .num_resources = ARRAY_SIZE(nuc900_rtc_resource), | |
315 | .resource = nuc900_rtc_resource, | |
316 | }; | |
317 | ||
318 | /*TouchScreen controller*/ | |
319 | ||
320 | static struct resource nuc900_ts_resource[] = { | |
321 | [0] = { | |
322 | .start = W90X900_PA_ADC, | |
323 | .end = W90X900_PA_ADC + W90X900_SZ_ADC-1, | |
324 | .flags = IORESOURCE_MEM, | |
325 | }, | |
326 | [1] = { | |
327 | .start = IRQ_ADC, | |
328 | .end = IRQ_ADC, | |
329 | .flags = IORESOURCE_IRQ, | |
330 | }, | |
331 | }; | |
332 | ||
333 | struct platform_device nuc900_device_ts = { | |
334 | .name = "nuc900-ts", | |
335 | .id = -1, | |
336 | .resource = nuc900_ts_resource, | |
337 | .num_resources = ARRAY_SIZE(nuc900_ts_resource), | |
338 | }; | |
339 | ||
340 | /* FMI Device */ | |
341 | ||
342 | static struct resource nuc900_fmi_resource[] = { | |
343 | [0] = { | |
344 | .start = W90X900_PA_FMI, | |
345 | .end = W90X900_PA_FMI + W90X900_SZ_FMI - 1, | |
346 | .flags = IORESOURCE_MEM, | |
347 | }, | |
348 | [1] = { | |
349 | .start = IRQ_FMI, | |
350 | .end = IRQ_FMI, | |
351 | .flags = IORESOURCE_IRQ, | |
352 | } | |
353 | }; | |
354 | ||
355 | struct platform_device nuc900_device_fmi = { | |
356 | .name = "nuc900-fmi", | |
357 | .id = -1, | |
358 | .num_resources = ARRAY_SIZE(nuc900_fmi_resource), | |
359 | .resource = nuc900_fmi_resource, | |
360 | }; | |
361 | ||
362 | /* KPI controller*/ | |
363 | ||
9e3aaac3 | 364 | static int nuc900_keymap[] = { |
365 | KEY(0, 0, KEY_A), | |
366 | KEY(0, 1, KEY_B), | |
367 | KEY(0, 2, KEY_C), | |
368 | KEY(0, 3, KEY_D), | |
369 | ||
370 | KEY(1, 0, KEY_E), | |
371 | KEY(1, 1, KEY_F), | |
372 | KEY(1, 2, KEY_G), | |
373 | KEY(1, 3, KEY_H), | |
374 | ||
375 | KEY(2, 0, KEY_I), | |
376 | KEY(2, 1, KEY_J), | |
377 | KEY(2, 2, KEY_K), | |
378 | KEY(2, 3, KEY_L), | |
379 | ||
380 | KEY(3, 0, KEY_M), | |
381 | KEY(3, 1, KEY_N), | |
382 | KEY(3, 2, KEY_O), | |
383 | KEY(3, 3, KEY_P), | |
384 | }; | |
385 | ||
386 | static struct matrix_keymap_data nuc900_map_data = { | |
387 | .keymap = nuc900_keymap, | |
388 | .keymap_size = ARRAY_SIZE(nuc900_keymap), | |
389 | }; | |
390 | ||
391 | struct w90p910_keypad_platform_data nuc900_keypad_info = { | |
392 | .keymap_data = &nuc900_map_data, | |
393 | .prescale = 0xfa, | |
394 | .debounce = 0x50, | |
395 | }; | |
396 | ||
35c9221a | 397 | static struct resource nuc900_kpi_resource[] = { |
398 | [0] = { | |
399 | .start = W90X900_PA_KPI, | |
400 | .end = W90X900_PA_KPI + W90X900_SZ_KPI - 1, | |
401 | .flags = IORESOURCE_MEM, | |
402 | }, | |
403 | [1] = { | |
404 | .start = IRQ_KPI, | |
405 | .end = IRQ_KPI, | |
406 | .flags = IORESOURCE_IRQ, | |
407 | } | |
408 | ||
409 | }; | |
410 | ||
411 | struct platform_device nuc900_device_kpi = { | |
412 | .name = "nuc900-kpi", | |
413 | .id = -1, | |
414 | .num_resources = ARRAY_SIZE(nuc900_kpi_resource), | |
415 | .resource = nuc900_kpi_resource, | |
9e3aaac3 | 416 | .dev = { |
417 | .platform_data = &nuc900_keypad_info, | |
418 | } | |
35c9221a | 419 | }; |
420 | ||
6a446b90 | 421 | /* LCD controller*/ |
422 | ||
a6dc5446 | 423 | static struct nuc900fb_display nuc900_lcd_info[] = { |
6a446b90 | 424 | /* Giantplus Technology GPM1040A0 320x240 Color TFT LCD */ |
425 | [0] = { | |
426 | .type = LCM_DCCS_VA_SRC_RGB565, | |
427 | .width = 320, | |
428 | .height = 240, | |
429 | .xres = 320, | |
430 | .yres = 240, | |
431 | .bpp = 16, | |
432 | .pixclock = 200000, | |
433 | .left_margin = 34, | |
434 | .right_margin = 54, | |
435 | .hsync_len = 10, | |
436 | .upper_margin = 18, | |
437 | .lower_margin = 4, | |
438 | .vsync_len = 1, | |
439 | .dccs = 0x8e00041a, | |
440 | .devctl = 0x060800c0, | |
441 | .fbctrl = 0x00a000a0, | |
442 | .scale = 0x04000400, | |
443 | }, | |
444 | }; | |
445 | ||
a6dc5446 | 446 | static struct nuc900fb_mach_info nuc900_fb_info = { |
6a446b90 | 447 | #if defined(CONFIG_GPM1040A0_320X240) |
448 | .displays = &nuc900_lcd_info[0], | |
449 | #else | |
450 | .displays = nuc900_lcd_info, | |
451 | #endif | |
452 | .num_displays = ARRAY_SIZE(nuc900_lcd_info), | |
453 | .default_display = 0, | |
454 | .gpio_dir = 0x00000004, | |
455 | .gpio_dir_mask = 0xFFFFFFFD, | |
456 | .gpio_data = 0x00000004, | |
457 | .gpio_data_mask = 0xFFFFFFFD, | |
458 | }; | |
86619708 WQ |
459 | |
460 | static struct resource nuc900_lcd_resource[] = { | |
461 | [0] = { | |
462 | .start = W90X900_PA_LCD, | |
463 | .end = W90X900_PA_LCD + W90X900_SZ_LCD - 1, | |
464 | .flags = IORESOURCE_MEM, | |
465 | }, | |
466 | [1] = { | |
467 | .start = IRQ_LCD, | |
468 | .end = IRQ_LCD, | |
469 | .flags = IORESOURCE_IRQ, | |
470 | } | |
471 | }; | |
472 | ||
473 | static u64 nuc900_device_lcd_dmamask = -1; | |
474 | struct platform_device nuc900_device_lcd = { | |
475 | .name = "nuc900-lcd", | |
476 | .id = -1, | |
477 | .num_resources = ARRAY_SIZE(nuc900_lcd_resource), | |
478 | .resource = nuc900_lcd_resource, | |
479 | .dev = { | |
480 | .dma_mask = &nuc900_device_lcd_dmamask, | |
481 | .coherent_dma_mask = -1, | |
6a446b90 | 482 | .platform_data = &nuc900_fb_info, |
86619708 WQ |
483 | } |
484 | }; | |
485 | ||
3d34a0d8 | 486 | /* AUDIO controller*/ |
487 | static u64 nuc900_device_audio_dmamask = -1; | |
488 | static struct resource nuc900_ac97_resource[] = { | |
489 | [0] = { | |
490 | .start = W90X900_PA_ACTL, | |
491 | .end = W90X900_PA_ACTL + W90X900_SZ_ACTL - 1, | |
492 | .flags = IORESOURCE_MEM, | |
493 | }, | |
494 | [1] = { | |
495 | .start = IRQ_ACTL, | |
496 | .end = IRQ_ACTL, | |
497 | .flags = IORESOURCE_IRQ, | |
498 | } | |
499 | ||
500 | }; | |
501 | ||
e37051dc AL |
502 | struct platform_device nuc900_device_ac97 = { |
503 | .name = "nuc900-ac97", | |
3d34a0d8 | 504 | .id = -1, |
505 | .num_resources = ARRAY_SIZE(nuc900_ac97_resource), | |
506 | .resource = nuc900_ac97_resource, | |
507 | .dev = { | |
508 | .dma_mask = &nuc900_device_audio_dmamask, | |
509 | .coherent_dma_mask = -1, | |
510 | } | |
511 | }; | |
512 | ||
35c9221a | 513 | /*Here should be your evb resourse,such as LCD*/ |
514 | ||
515 | static struct platform_device *nuc900_public_dev[] __initdata = { | |
516 | &nuc900_serial_device, | |
517 | &nuc900_flash_device, | |
518 | &nuc900_device_usb_ehci, | |
519 | &nuc900_device_usb_ohci, | |
520 | &nuc900_device_usbgadget, | |
521 | &nuc900_device_emc, | |
522 | &nuc900_device_spi, | |
523 | &nuc900_device_wdt, | |
e37051dc | 524 | &nuc900_device_ac97, |
35c9221a | 525 | }; |
526 | ||
527 | /* Provide adding specific CPU platform devices API */ | |
528 | ||
529 | void __init nuc900_board_init(struct platform_device **device, int size) | |
530 | { | |
f7b861b7 | 531 | cpu_idle_poll_ctrl(true); |
35c9221a | 532 | platform_add_devices(device, size); |
533 | platform_add_devices(nuc900_public_dev, ARRAY_SIZE(nuc900_public_dev)); | |
534 | spi_register_board_info(nuc900_spi_board_info, | |
535 | ARRAY_SIZE(nuc900_spi_board_info)); | |
536 | } | |
537 |