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/sysdev.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/pxa2xx-regs.h>
25 #include <mach/mfp-pxa27x.h>
26 #include <mach/pxa-regs.h>
27 #include <mach/audio.h>
28 #include <mach/pxafb.h>
30 #include <asm/hardware/it8152.h>
33 #include "cm-x2xx-pci.h"
35 extern void cmx255_init(void);
36 extern void cmx270_init(void);
38 /* virtual addresses for statically mapped regions */
39 #define CMX2XX_VIRT_BASE (0xe8000000)
40 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
42 /* physical address if local-bus attached devices */
43 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
44 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
47 #define CMX255_GPIO_RED (27)
48 #define CMX255_GPIO_GREEN (32)
49 #define CMX270_GPIO_RED (93)
50 #define CMX270_GPIO_GREEN (94)
53 #define GPIO22_ETHIRQ (22)
54 #define GPIO10_ETHIRQ (10)
55 #define CMX255_GPIO_IT8152_IRQ (0)
56 #define CMX270_GPIO_IT8152_IRQ (22)
58 #define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
59 #define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
61 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
62 static struct resource cmx255_dm9000_resource[] = {
64 .start = CMX255_DM9000_PHYS_BASE,
65 .end = CMX255_DM9000_PHYS_BASE + 3,
66 .flags = IORESOURCE_MEM,
69 .start = CMX255_DM9000_PHYS_BASE + 4,
70 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
71 .flags = IORESOURCE_MEM,
74 .start = CMX255_ETHIRQ,
76 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
80 static struct resource cmx270_dm9000_resource[] = {
82 .start = CMX270_DM9000_PHYS_BASE,
83 .end = CMX270_DM9000_PHYS_BASE + 3,
84 .flags = IORESOURCE_MEM,
87 .start = CMX270_DM9000_PHYS_BASE + 8,
88 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
89 .flags = IORESOURCE_MEM,
92 .start = CMX270_ETHIRQ,
94 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
98 static struct dm9000_plat_data cmx270_dm9000_platdata = {
99 .flags = DM9000_PLATF_32BITONLY,
102 static struct platform_device cmx2xx_dm9000_device = {
105 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
107 .platform_data = &cmx270_dm9000_platdata,
111 static void __init cmx2xx_init_dm9000(void)
114 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
116 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
117 platform_device_register(&cmx2xx_dm9000_device);
120 static inline void cmx2xx_init_dm9000(void) {}
123 /* UCB1400 touchscreen controller */
124 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
125 static struct platform_device cmx2xx_ts_device = {
126 .name = "ucb1400_ts",
130 static void __init cmx2xx_init_touchscreen(void)
132 platform_device_register(&cmx2xx_ts_device);
135 static inline void cmx2xx_init_touchscreen(void) {}
139 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
140 static struct gpio_led cmx2xx_leds[] = {
142 .name = "cm-x2xx:red",
143 .default_trigger = "nand-disk",
147 .name = "cm-x2xx:green",
148 .default_trigger = "heartbeat",
153 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
154 .num_leds = ARRAY_SIZE(cmx2xx_leds),
158 static struct platform_device cmx2xx_led_device = {
162 .platform_data = &cmx2xx_gpio_led_pdata,
166 static void __init cmx2xx_init_leds(void)
168 if (cpu_is_pxa25x()) {
169 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
170 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
172 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
173 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
175 platform_device_register(&cmx2xx_led_device);
178 static inline void cmx2xx_init_leds(void) {}
181 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
184 keep these for backwards compatibility, although symbolic names (as
185 e.g. in lpd270.c) looks better
187 #define MTYPE_STN320x240 0
188 #define MTYPE_TFT640x480 1
189 #define MTYPE_CRT640x480 2
190 #define MTYPE_CRT800x600 3
191 #define MTYPE_TFT320x240 6
192 #define MTYPE_STN640x480 7
194 static struct pxafb_mode_info generic_stn_320x240_mode = {
205 .sync = (FB_SYNC_HOR_HIGH_ACT |
206 FB_SYNC_VERT_HIGH_ACT),
210 static struct pxafb_mach_info generic_stn_320x240 = {
211 .modes = &generic_stn_320x240_mode,
213 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
214 LCD_AC_BIAS_FREQ(0xff),
219 static struct pxafb_mode_info generic_tft_640x480_mode = {
234 static struct pxafb_mach_info generic_tft_640x480 = {
235 .modes = &generic_tft_640x480_mode,
237 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
238 LCD_AC_BIAS_FREQ(0xff),
243 static struct pxafb_mode_info generic_crt_640x480_mode = {
254 .sync = (FB_SYNC_HOR_HIGH_ACT |
255 FB_SYNC_VERT_HIGH_ACT),
259 static struct pxafb_mach_info generic_crt_640x480 = {
260 .modes = &generic_crt_640x480_mode,
262 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
267 static struct pxafb_mode_info generic_crt_800x600_mode = {
278 .sync = (FB_SYNC_HOR_HIGH_ACT |
279 FB_SYNC_VERT_HIGH_ACT),
283 static struct pxafb_mach_info generic_crt_800x600 = {
284 .modes = &generic_crt_800x600_mode,
286 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
291 static struct pxafb_mode_info generic_tft_320x240_mode = {
306 static struct pxafb_mach_info generic_tft_320x240 = {
307 .modes = &generic_tft_320x240_mode,
309 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
314 static struct pxafb_mode_info generic_stn_640x480_mode = {
325 .sync = (FB_SYNC_HOR_HIGH_ACT |
326 FB_SYNC_VERT_HIGH_ACT),
330 static struct pxafb_mach_info generic_stn_640x480 = {
331 .modes = &generic_stn_640x480_mode,
333 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
338 static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
340 static int __init cmx2xx_set_display(char *str)
342 int disp_type = simple_strtol(str, NULL, 0);
344 case MTYPE_STN320x240:
345 cmx2xx_display = &generic_stn_320x240;
347 case MTYPE_TFT640x480:
348 cmx2xx_display = &generic_tft_640x480;
350 case MTYPE_CRT640x480:
351 cmx2xx_display = &generic_crt_640x480;
353 case MTYPE_CRT800x600:
354 cmx2xx_display = &generic_crt_800x600;
356 case MTYPE_TFT320x240:
357 cmx2xx_display = &generic_tft_320x240;
359 case MTYPE_STN640x480:
360 cmx2xx_display = &generic_stn_640x480;
362 default: /* fallback to CRT 640x480 */
363 cmx2xx_display = &generic_crt_640x480;
370 This should be done really early to get proper configuration for
372 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
373 has limitied line length for kernel command line, and also it will
374 break compatibitlty with proprietary releases already in field.
376 __setup("monitor=", cmx2xx_set_display);
378 static void __init cmx2xx_init_display(void)
380 set_pxa_fb_info(cmx2xx_display);
383 static inline void cmx2xx_init_display(void) {}
387 static unsigned long sleep_save_msc[10];
389 static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
391 cmx2xx_pci_suspend();
393 /* save MSC registers */
394 sleep_save_msc[0] = MSC0;
395 sleep_save_msc[1] = MSC1;
396 sleep_save_msc[2] = MSC2;
398 /* setup power saving mode registers */
413 static int cmx2xx_resume(struct sys_device *dev)
417 /* restore MSC registers */
418 MSC0 = sleep_save_msc[0];
419 MSC1 = sleep_save_msc[1];
420 MSC2 = sleep_save_msc[2];
425 static struct sysdev_class cmx2xx_pm_sysclass = {
427 .resume = cmx2xx_resume,
428 .suspend = cmx2xx_suspend,
431 static struct sys_device cmx2xx_pm_device = {
432 .cls = &cmx2xx_pm_sysclass,
435 static int __init cmx2xx_pm_init(void)
438 error = sysdev_class_register(&cmx2xx_pm_sysclass);
440 error = sysdev_register(&cmx2xx_pm_device);
444 static int __init cmx2xx_pm_init(void) { return 0; }
447 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
448 static void __init cmx2xx_init_ac97(void)
450 pxa_set_ac97_info(NULL);
453 static inline void cmx2xx_init_ac97(void) {}
456 static void __init cmx2xx_init(void)
465 cmx2xx_init_dm9000();
466 cmx2xx_init_display();
468 cmx2xx_init_touchscreen();
472 static void __init cmx2xx_init_irq(void)
476 if (cpu_is_pxa25x()) {
478 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
481 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
486 /* Map PCI companion statically */
487 static struct map_desc cmx2xx_io_desc[] __initdata = {
488 [0] = { /* PCI bridge */
489 .virtual = CMX2XX_IT8152_VIRT,
490 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
496 static void __init cmx2xx_map_io(void)
499 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
501 it8152_base_address = CMX2XX_IT8152_VIRT;
504 static void __init cmx2xx_map_io(void)
510 MACHINE_START(ARMCORE, "Compulab CM-X2XX")
511 .boot_params = 0xa0000100,
512 .phys_io = 0x40000000,
513 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
514 .map_io = cmx2xx_map_io,
515 .init_irq = cmx2xx_init_irq,
517 .init_machine = cmx2xx_init,