staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / arch / arm / mach-w90x900 / dev.c
blobce5fe400cb99d6487e42cebf4cd288814df26477
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * linux/arch/arm/mach-w90x900/dev.c
5 * Copyright (C) 2009 Nuvoton corporation.
7 * Wan ZongShun <mcuos.com@gmail.com>
8 */
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>
17 #include <linux/slab.h>
18 #include <linux/cpu.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/partitions.h>
24 #include <linux/spi/spi.h>
25 #include <linux/spi/flash.h>
27 #include <asm/system_misc.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/irq.h>
31 #include <asm/mach-types.h>
33 #include <mach/regs-serial.h>
34 #include <linux/platform_data/spi-nuc900.h>
35 #include <mach/map.h>
36 #include <linux/platform_data/video-nuc900fb.h>
37 #include <mach/regs-ldm.h>
38 #include <linux/platform_data/keypad-w90p910.h>
40 #include "cpu.h"
42 /*NUC900 evb norflash driver data */
44 #define NUC900_FLASH_BASE 0xA0000000
45 #define NUC900_FLASH_SIZE 0x400000
46 #define SPIOFFSET 0x200
47 #define SPIOREG_SIZE 0x100
49 static struct mtd_partition nuc900_flash_partitions[] = {
51 .name = "NOR Partition 1 for kernel (960K)",
52 .size = 0xF0000,
53 .offset = 0x10000,
56 .name = "NOR Partition 2 for image (1M)",
57 .size = 0x100000,
58 .offset = 0x100000,
61 .name = "NOR Partition 3 for user (2M)",
62 .size = 0x200000,
63 .offset = 0x00200000,
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),
73 static struct resource nuc900_flash_resources[] = {
75 .start = NUC900_FLASH_BASE,
76 .end = NUC900_FLASH_BASE + NUC900_FLASH_SIZE - 1,
77 .flags = IORESOURCE_MEM,
81 static struct platform_device nuc900_flash_device = {
82 .name = "physmap-flash",
83 .id = 0,
84 .dev = {
85 .platform_data = &nuc900_flash_data,
87 .resource = nuc900_flash_resources,
88 .num_resources = ARRAY_SIZE(nuc900_flash_resources),
91 /* USB EHCI Host Controller */
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,
99 [1] = {
100 .start = IRQ_USBH,
101 .end = IRQ_USBH,
102 .flags = IORESOURCE_IRQ,
106 static u64 nuc900_device_usb_ehci_dmamask = 0xffffffffUL;
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
119 /* USB OHCI Host Controller */
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,
127 [1] = {
128 .start = IRQ_USBH,
129 .end = IRQ_USBH,
130 .flags = IORESOURCE_IRQ,
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
146 /* USB Device (Gadget)*/
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,
154 [1] = {
155 .start = IRQ_USBD,
156 .end = IRQ_USBD,
157 .flags = IORESOURCE_IRQ,
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,
168 /* MAC device */
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,
176 [1] = {
177 .start = IRQ_EMCTX,
178 .end = IRQ_EMCTX,
179 .flags = IORESOURCE_IRQ,
181 [2] = {
182 .start = IRQ_EMCRX,
183 .end = IRQ_EMCRX,
184 .flags = IORESOURCE_IRQ,
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
200 /* SPI device */
202 static struct nuc900_spi_info nuc900_spiflash_data = {
203 .num_cs = 1,
204 .lsb = 0,
205 .txneg = 1,
206 .rxneg = 0,
207 .divider = 24,
208 .sleep = 0,
209 .txnum = 0,
210 .txbitlen = 8,
211 .bus_num = 0,
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,
220 [1] = {
221 .start = IRQ_SSP,
222 .end = IRQ_SSP,
223 .flags = IORESOURCE_IRQ,
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,
232 .dev = {
233 .platform_data = &nuc900_spiflash_data,
237 /* spi device, spi flash info */
239 static struct mtd_partition nuc900_spi_flash_partitions[] = {
241 .name = "bootloader(spi)",
242 .size = 0x0100000,
243 .offset = 0,
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",
254 static struct spi_board_info nuc900_spi_board_info[] __initdata = {
256 .modalias = "m25p80",
257 .max_speed_hz = 20000000,
258 .bus_num = 0,
259 .chip_select = 0,
260 .platform_data = &nuc900_spi_flash_data,
261 .mode = SPI_MODE_0,
265 /* WDT Device */
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,
273 [1] = {
274 .start = IRQ_WDT,
275 .end = IRQ_WDT,
276 .flags = IORESOURCE_IRQ,
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,
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.
296 /* RTC controller*/
298 static struct resource nuc900_rtc_resource[] = {
299 [0] = {
300 .start = W90X900_PA_RTC,
301 .end = W90X900_PA_RTC + 0xff,
302 .flags = IORESOURCE_MEM,
304 [1] = {
305 .start = IRQ_RTC,
306 .end = IRQ_RTC,
307 .flags = IORESOURCE_IRQ,
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,
318 /*TouchScreen controller*/
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,
326 [1] = {
327 .start = IRQ_ADC,
328 .end = IRQ_ADC,
329 .flags = IORESOURCE_IRQ,
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),
340 /* FMI Device */
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,
348 [1] = {
349 .start = IRQ_FMI,
350 .end = IRQ_FMI,
351 .flags = IORESOURCE_IRQ,
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,
362 /* KPI controller*/
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),
370 KEY(1, 0, KEY_E),
371 KEY(1, 1, KEY_F),
372 KEY(1, 2, KEY_G),
373 KEY(1, 3, KEY_H),
375 KEY(2, 0, KEY_I),
376 KEY(2, 1, KEY_J),
377 KEY(2, 2, KEY_K),
378 KEY(2, 3, KEY_L),
380 KEY(3, 0, KEY_M),
381 KEY(3, 1, KEY_N),
382 KEY(3, 2, KEY_O),
383 KEY(3, 3, KEY_P),
386 static struct matrix_keymap_data nuc900_map_data = {
387 .keymap = nuc900_keymap,
388 .keymap_size = ARRAY_SIZE(nuc900_keymap),
391 struct w90p910_keypad_platform_data nuc900_keypad_info = {
392 .keymap_data = &nuc900_map_data,
393 .prescale = 0xfa,
394 .debounce = 0x50,
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,
403 [1] = {
404 .start = IRQ_KPI,
405 .end = IRQ_KPI,
406 .flags = IORESOURCE_IRQ,
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,
416 .dev = {
417 .platform_data = &nuc900_keypad_info,
421 /* LCD controller*/
423 static struct nuc900fb_display nuc900_lcd_info[] = {
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,
446 static struct nuc900fb_mach_info nuc900_fb_info = {
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,
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,
466 [1] = {
467 .start = IRQ_LCD,
468 .end = IRQ_LCD,
469 .flags = IORESOURCE_IRQ,
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,
482 .platform_data = &nuc900_fb_info,
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,
494 [1] = {
495 .start = IRQ_ACTL,
496 .end = IRQ_ACTL,
497 .flags = IORESOURCE_IRQ,
502 struct platform_device nuc900_device_ac97 = {
503 .name = "nuc900-ac97",
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,
513 /*Here should be your evb resourse,such as LCD*/
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,
524 &nuc900_device_ac97,
527 /* Provide adding specific CPU platform devices API */
529 void __init nuc900_board_init(struct platform_device **device, int size)
531 cpu_idle_poll_ctrl(true);
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));