2 * linux/arch/arm/mach-pxa/cm-x2xx.c
4 * Copyright (C) 2008 CompuLab, Ltd.
5 * Mike Rapoport <mike@compulab.co.il>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/platform_device.h>
13 #include <linux/syscore_ops.h>
14 #include <linux/irq.h>
15 #include <linux/gpio.h>
17 #include <linux/dm9000.h>
18 #include <linux/leds.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach-types.h>
22 #include <asm/mach/map.h>
24 #include <mach/pxa25x.h>
25 #undef GPIO24_SSP1_SFRM
26 #include <mach/pxa27x.h>
27 #include <mach/audio.h>
28 #include <linux/platform_data/video-pxafb.h>
29 #include <mach/smemc.h>
31 #include <asm/hardware/it8152.h>
34 #include "cm-x2xx-pci.h"
36 extern void cmx255_init(void);
37 extern void cmx270_init(void);
39 /* reserve IRQs for IT8152 */
40 #define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
42 /* virtual addresses for statically mapped regions */
43 #define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
44 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
46 /* physical address if local-bus attached devices */
47 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
48 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
51 #define CMX255_GPIO_RED (27)
52 #define CMX255_GPIO_GREEN (32)
53 #define CMX270_GPIO_RED (93)
54 #define CMX270_GPIO_GREEN (94)
57 #define GPIO22_ETHIRQ (22)
58 #define GPIO10_ETHIRQ (10)
59 #define CMX255_GPIO_IT8152_IRQ (0)
60 #define CMX270_GPIO_IT8152_IRQ (22)
62 #define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
63 #define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
65 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
66 static struct resource cmx255_dm9000_resource[] = {
68 .start = CMX255_DM9000_PHYS_BASE,
69 .end = CMX255_DM9000_PHYS_BASE + 3,
70 .flags = IORESOURCE_MEM,
73 .start = CMX255_DM9000_PHYS_BASE + 4,
74 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
75 .flags = IORESOURCE_MEM,
78 .start = CMX255_ETHIRQ,
80 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
84 static struct resource cmx270_dm9000_resource[] = {
86 .start = CMX270_DM9000_PHYS_BASE,
87 .end = CMX270_DM9000_PHYS_BASE + 3,
88 .flags = IORESOURCE_MEM,
91 .start = CMX270_DM9000_PHYS_BASE + 8,
92 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
93 .flags = IORESOURCE_MEM,
96 .start = CMX270_ETHIRQ,
98 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
102 static struct dm9000_plat_data cmx270_dm9000_platdata = {
103 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
106 static struct platform_device cmx2xx_dm9000_device = {
109 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
111 .platform_data = &cmx270_dm9000_platdata,
115 static void __init cmx2xx_init_dm9000(void)
118 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
120 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
121 platform_device_register(&cmx2xx_dm9000_device);
124 static inline void cmx2xx_init_dm9000(void) {}
127 /* UCB1400 touchscreen controller */
128 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
129 static struct platform_device cmx2xx_ts_device = {
130 .name = "ucb1400_core",
134 static void __init cmx2xx_init_touchscreen(void)
136 platform_device_register(&cmx2xx_ts_device);
139 static inline void cmx2xx_init_touchscreen(void) {}
143 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
144 static struct gpio_led cmx2xx_leds[] = {
146 .name = "cm-x2xx:red",
147 .default_trigger = "nand-disk",
151 .name = "cm-x2xx:green",
152 .default_trigger = "heartbeat",
157 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
158 .num_leds = ARRAY_SIZE(cmx2xx_leds),
162 static struct platform_device cmx2xx_led_device = {
166 .platform_data = &cmx2xx_gpio_led_pdata,
170 static void __init cmx2xx_init_leds(void)
172 if (cpu_is_pxa25x()) {
173 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
174 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
176 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
177 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
179 platform_device_register(&cmx2xx_led_device);
182 static inline void cmx2xx_init_leds(void) {}
185 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
188 keep these for backwards compatibility, although symbolic names (as
189 e.g. in lpd270.c) looks better
191 #define MTYPE_STN320x240 0
192 #define MTYPE_TFT640x480 1
193 #define MTYPE_CRT640x480 2
194 #define MTYPE_CRT800x600 3
195 #define MTYPE_TFT320x240 6
196 #define MTYPE_STN640x480 7
198 static struct pxafb_mode_info generic_stn_320x240_mode = {
209 .sync = (FB_SYNC_HOR_HIGH_ACT |
210 FB_SYNC_VERT_HIGH_ACT),
214 static struct pxafb_mach_info generic_stn_320x240 = {
215 .modes = &generic_stn_320x240_mode,
217 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
218 LCD_AC_BIAS_FREQ(0xff),
223 static struct pxafb_mode_info generic_tft_640x480_mode = {
238 static struct pxafb_mach_info generic_tft_640x480 = {
239 .modes = &generic_tft_640x480_mode,
241 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
242 LCD_AC_BIAS_FREQ(0xff),
247 static struct pxafb_mode_info generic_crt_640x480_mode = {
258 .sync = (FB_SYNC_HOR_HIGH_ACT |
259 FB_SYNC_VERT_HIGH_ACT),
263 static struct pxafb_mach_info generic_crt_640x480 = {
264 .modes = &generic_crt_640x480_mode,
266 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
271 static struct pxafb_mode_info generic_crt_800x600_mode = {
282 .sync = (FB_SYNC_HOR_HIGH_ACT |
283 FB_SYNC_VERT_HIGH_ACT),
287 static struct pxafb_mach_info generic_crt_800x600 = {
288 .modes = &generic_crt_800x600_mode,
290 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
295 static struct pxafb_mode_info generic_tft_320x240_mode = {
310 static struct pxafb_mach_info generic_tft_320x240 = {
311 .modes = &generic_tft_320x240_mode,
313 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
318 static struct pxafb_mode_info generic_stn_640x480_mode = {
329 .sync = (FB_SYNC_HOR_HIGH_ACT |
330 FB_SYNC_VERT_HIGH_ACT),
334 static struct pxafb_mach_info generic_stn_640x480 = {
335 .modes = &generic_stn_640x480_mode,
337 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
342 static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
344 static int __init cmx2xx_set_display(char *str)
346 int disp_type = simple_strtol(str, NULL, 0);
348 case MTYPE_STN320x240:
349 cmx2xx_display = &generic_stn_320x240;
351 case MTYPE_TFT640x480:
352 cmx2xx_display = &generic_tft_640x480;
354 case MTYPE_CRT640x480:
355 cmx2xx_display = &generic_crt_640x480;
357 case MTYPE_CRT800x600:
358 cmx2xx_display = &generic_crt_800x600;
360 case MTYPE_TFT320x240:
361 cmx2xx_display = &generic_tft_320x240;
363 case MTYPE_STN640x480:
364 cmx2xx_display = &generic_stn_640x480;
366 default: /* fallback to CRT 640x480 */
367 cmx2xx_display = &generic_crt_640x480;
374 This should be done really early to get proper configuration for
376 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
377 has limitied line length for kernel command line, and also it will
378 break compatibitlty with proprietary releases already in field.
380 __setup("monitor=", cmx2xx_set_display);
382 static void __init cmx2xx_init_display(void)
384 pxa_set_fb_info(NULL, cmx2xx_display);
387 static inline void cmx2xx_init_display(void) {}
391 static unsigned long sleep_save_msc[10];
393 static int cmx2xx_suspend(void)
395 cmx2xx_pci_suspend();
397 /* save MSC registers */
398 sleep_save_msc[0] = __raw_readl(MSC0);
399 sleep_save_msc[1] = __raw_readl(MSC1);
400 sleep_save_msc[2] = __raw_readl(MSC2);
402 /* setup power saving mode registers */
417 static void cmx2xx_resume(void)
421 /* restore MSC registers */
422 __raw_writel(sleep_save_msc[0], MSC0);
423 __raw_writel(sleep_save_msc[1], MSC1);
424 __raw_writel(sleep_save_msc[2], MSC2);
427 static struct syscore_ops cmx2xx_pm_syscore_ops = {
428 .resume = cmx2xx_resume,
429 .suspend = cmx2xx_suspend,
432 static int __init cmx2xx_pm_init(void)
434 register_syscore_ops(&cmx2xx_pm_syscore_ops);
439 static int __init cmx2xx_pm_init(void) { return 0; }
442 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
443 static void __init cmx2xx_init_ac97(void)
445 pxa_set_ac97_info(NULL);
448 static inline void cmx2xx_init_ac97(void) {}
451 static void __init cmx2xx_init(void)
453 pxa_set_ffuart_info(NULL);
454 pxa_set_btuart_info(NULL);
455 pxa_set_stuart_info(NULL);
464 cmx2xx_init_dm9000();
465 cmx2xx_init_display();
467 cmx2xx_init_touchscreen();
471 static void __init cmx2xx_init_irq(void)
473 if (cpu_is_pxa25x()) {
475 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
478 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
483 /* Map PCI companion statically */
484 static struct map_desc cmx2xx_io_desc[] __initdata = {
485 [0] = { /* PCI bridge */
486 .virtual = (unsigned long)CMX2XX_IT8152_VIRT,
487 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
493 static void __init cmx2xx_map_io(void)
501 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
503 it8152_base_address = CMX2XX_IT8152_VIRT;
506 static void __init cmx2xx_map_io(void)
516 MACHINE_START(ARMCORE, "Compulab CM-X2XX")
517 .atag_offset = 0x100,
518 .map_io = cmx2xx_map_io,
519 .nr_irqs = CMX2XX_NR_IRQS,
520 .init_irq = cmx2xx_init_irq,
521 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
522 .handle_irq = pxa25x_handle_irq,
523 .init_time = pxa_timer_init,
524 .init_machine = cmx2xx_init,
526 .dma_zone_size = SZ_64M,
528 .restart = pxa_restart,