1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/arch/arm/mach-w90x900/dev.c
5 * Copyright (C) 2009 Nuvoton corporation.
7 * Wan ZongShun <mcuos.com@gmail.com>
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>
36 #include <linux/platform_data/video-nuc900fb.h>
37 #include <mach/regs-ldm.h>
38 #include <linux/platform_data/keypad-w90p910.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)",
56 .name
= "NOR Partition 2 for image (1M)",
61 .name
= "NOR Partition 3 for user (2M)",
67 static struct physmap_flash_data nuc900_flash_data
= {
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",
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
[] = {
95 .start
= W90X900_PA_USBEHCIHOST
,
96 .end
= W90X900_PA_USBEHCIHOST
+ W90X900_SZ_USBEHCIHOST
- 1,
97 .flags
= IORESOURCE_MEM
,
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",
111 .num_resources
= ARRAY_SIZE(nuc900_usb_ehci_resource
),
112 .resource
= nuc900_usb_ehci_resource
,
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
[] = {
123 .start
= W90X900_PA_USBOHCIHOST
,
124 .end
= W90X900_PA_USBOHCIHOST
+ W90X900_SZ_USBOHCIHOST
- 1,
125 .flags
= IORESOURCE_MEM
,
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",
138 .num_resources
= ARRAY_SIZE(nuc900_usb_ohci_resource
),
139 .resource
= nuc900_usb_ohci_resource
,
141 .dma_mask
= &nuc900_device_usb_ohci_dmamask
,
142 .coherent_dma_mask
= 0xffffffffUL
146 /* USB Device (Gadget)*/
148 static struct resource nuc900_usbgadget_resource
[] = {
150 .start
= W90X900_PA_USBDEV
,
151 .end
= W90X900_PA_USBDEV
+ W90X900_SZ_USBDEV
- 1,
152 .flags
= IORESOURCE_MEM
,
157 .flags
= IORESOURCE_IRQ
,
161 static struct platform_device nuc900_device_usbgadget
= {
162 .name
= "nuc900-usbgadget",
164 .num_resources
= ARRAY_SIZE(nuc900_usbgadget_resource
),
165 .resource
= nuc900_usbgadget_resource
,
170 static struct resource nuc900_emc_resource
[] = {
172 .start
= W90X900_PA_EMC
,
173 .end
= W90X900_PA_EMC
+ W90X900_SZ_EMC
- 1,
174 .flags
= IORESOURCE_MEM
,
179 .flags
= IORESOURCE_IRQ
,
184 .flags
= IORESOURCE_IRQ
,
188 static u64 nuc900_device_emc_dmamask
= 0xffffffffUL
;
189 static struct platform_device nuc900_device_emc
= {
190 .name
= "nuc900-emc",
192 .num_resources
= ARRAY_SIZE(nuc900_emc_resource
),
193 .resource
= nuc900_emc_resource
,
195 .dma_mask
= &nuc900_device_emc_dmamask
,
196 .coherent_dma_mask
= 0xffffffffUL
202 static struct nuc900_spi_info nuc900_spiflash_data
= {
214 static struct resource nuc900_spi_resource
[] = {
216 .start
= W90X900_PA_I2C
+ SPIOFFSET
,
217 .end
= W90X900_PA_I2C
+ SPIOFFSET
+ SPIOREG_SIZE
- 1,
218 .flags
= IORESOURCE_MEM
,
223 .flags
= IORESOURCE_IRQ
,
227 static struct platform_device nuc900_device_spi
= {
228 .name
= "nuc900-spi",
230 .num_resources
= ARRAY_SIZE(nuc900_spi_resource
),
231 .resource
= nuc900_spi_resource
,
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)",
247 static struct flash_platform_data nuc900_spi_flash_data
= {
249 .parts
= nuc900_spi_flash_partitions
,
250 .nr_parts
= ARRAY_SIZE(nuc900_spi_flash_partitions
),
254 static struct spi_board_info nuc900_spi_board_info
[] __initdata
= {
256 .modalias
= "m25p80",
257 .max_speed_hz
= 20000000,
260 .platform_data
= &nuc900_spi_flash_data
,
267 static struct resource nuc900_wdt_resource
[] = {
269 .start
= W90X900_PA_TIMER
,
270 .end
= W90X900_PA_TIMER
+ W90X900_SZ_TIMER
- 1,
271 .flags
= IORESOURCE_MEM
,
276 .flags
= IORESOURCE_IRQ
,
280 static struct platform_device nuc900_device_wdt
= {
281 .name
= "nuc900-wdt",
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
298 static struct resource nuc900_rtc_resource
[] = {
300 .start
= W90X900_PA_RTC
,
301 .end
= W90X900_PA_RTC
+ 0xff,
302 .flags
= IORESOURCE_MEM
,
307 .flags
= IORESOURCE_IRQ
,
311 struct platform_device nuc900_device_rtc
= {
312 .name
= "nuc900-rtc",
314 .num_resources
= ARRAY_SIZE(nuc900_rtc_resource
),
315 .resource
= nuc900_rtc_resource
,
318 /*TouchScreen controller*/
320 static struct resource nuc900_ts_resource
[] = {
322 .start
= W90X900_PA_ADC
,
323 .end
= W90X900_PA_ADC
+ W90X900_SZ_ADC
-1,
324 .flags
= IORESOURCE_MEM
,
329 .flags
= IORESOURCE_IRQ
,
333 struct platform_device nuc900_device_ts
= {
336 .resource
= nuc900_ts_resource
,
337 .num_resources
= ARRAY_SIZE(nuc900_ts_resource
),
342 static struct resource nuc900_fmi_resource
[] = {
344 .start
= W90X900_PA_FMI
,
345 .end
= W90X900_PA_FMI
+ W90X900_SZ_FMI
- 1,
346 .flags
= IORESOURCE_MEM
,
351 .flags
= IORESOURCE_IRQ
,
355 struct platform_device nuc900_device_fmi
= {
356 .name
= "nuc900-fmi",
358 .num_resources
= ARRAY_SIZE(nuc900_fmi_resource
),
359 .resource
= nuc900_fmi_resource
,
364 static int nuc900_keymap
[] = {
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
,
397 static struct resource nuc900_kpi_resource
[] = {
399 .start
= W90X900_PA_KPI
,
400 .end
= W90X900_PA_KPI
+ W90X900_SZ_KPI
- 1,
401 .flags
= IORESOURCE_MEM
,
406 .flags
= IORESOURCE_IRQ
,
411 struct platform_device nuc900_device_kpi
= {
412 .name
= "nuc900-kpi",
414 .num_resources
= ARRAY_SIZE(nuc900_kpi_resource
),
415 .resource
= nuc900_kpi_resource
,
417 .platform_data
= &nuc900_keypad_info
,
423 static struct nuc900fb_display nuc900_lcd_info
[] = {
424 /* Giantplus Technology GPM1040A0 320x240 Color TFT LCD */
426 .type
= LCM_DCCS_VA_SRC_RGB565
,
440 .devctl
= 0x060800c0,
441 .fbctrl
= 0x00a000a0,
446 static struct nuc900fb_mach_info nuc900_fb_info
= {
447 #if defined(CONFIG_GPM1040A0_320X240)
448 .displays
= &nuc900_lcd_info
[0],
450 .displays
= nuc900_lcd_info
,
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
[] = {
462 .start
= W90X900_PA_LCD
,
463 .end
= W90X900_PA_LCD
+ W90X900_SZ_LCD
- 1,
464 .flags
= IORESOURCE_MEM
,
469 .flags
= IORESOURCE_IRQ
,
473 static u64 nuc900_device_lcd_dmamask
= -1;
474 struct platform_device nuc900_device_lcd
= {
475 .name
= "nuc900-lcd",
477 .num_resources
= ARRAY_SIZE(nuc900_lcd_resource
),
478 .resource
= nuc900_lcd_resource
,
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
[] = {
490 .start
= W90X900_PA_ACTL
,
491 .end
= W90X900_PA_ACTL
+ W90X900_SZ_ACTL
- 1,
492 .flags
= IORESOURCE_MEM
,
497 .flags
= IORESOURCE_IRQ
,
502 struct platform_device nuc900_device_ac97
= {
503 .name
= "nuc900-ac97",
505 .num_resources
= ARRAY_SIZE(nuc900_ac97_resource
),
506 .resource
= nuc900_ac97_resource
,
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
,
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
));