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/audio.h>
26 #include <mach/pxafb.h>
28 #include <asm/hardware/it8152.h>
31 #include "cm-x2xx-pci.h"
33 extern void cmx255_init(void);
34 extern void cmx270_init(void);
36 /* virtual addresses for statically mapped regions */
37 #define CMX2XX_VIRT_BASE (0xe8000000)
38 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
40 /* physical address if local-bus attached devices */
41 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
42 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
45 #define CMX255_GPIO_RED (27)
46 #define CMX255_GPIO_GREEN (32)
47 #define CMX270_GPIO_RED (93)
48 #define CMX270_GPIO_GREEN (94)
51 #define GPIO22_ETHIRQ (22)
52 #define GPIO10_ETHIRQ (10)
53 #define CMX255_GPIO_IT8152_IRQ (0)
54 #define CMX270_GPIO_IT8152_IRQ (22)
56 #define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
57 #define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
59 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
60 static struct resource cmx255_dm9000_resource
[] = {
62 .start
= CMX255_DM9000_PHYS_BASE
,
63 .end
= CMX255_DM9000_PHYS_BASE
+ 3,
64 .flags
= IORESOURCE_MEM
,
67 .start
= CMX255_DM9000_PHYS_BASE
+ 4,
68 .end
= CMX255_DM9000_PHYS_BASE
+ 4 + 500,
69 .flags
= IORESOURCE_MEM
,
72 .start
= CMX255_ETHIRQ
,
74 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
78 static struct resource cmx270_dm9000_resource
[] = {
80 .start
= CMX270_DM9000_PHYS_BASE
,
81 .end
= CMX270_DM9000_PHYS_BASE
+ 3,
82 .flags
= IORESOURCE_MEM
,
85 .start
= CMX270_DM9000_PHYS_BASE
+ 8,
86 .end
= CMX270_DM9000_PHYS_BASE
+ 8 + 500,
87 .flags
= IORESOURCE_MEM
,
90 .start
= CMX270_ETHIRQ
,
92 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
96 static struct dm9000_plat_data cmx270_dm9000_platdata
= {
97 .flags
= DM9000_PLATF_32BITONLY
| DM9000_PLATF_NO_EEPROM
,
100 static struct platform_device cmx2xx_dm9000_device
= {
103 .num_resources
= ARRAY_SIZE(cmx270_dm9000_resource
),
105 .platform_data
= &cmx270_dm9000_platdata
,
109 static void __init
cmx2xx_init_dm9000(void)
112 cmx2xx_dm9000_device
.resource
= cmx255_dm9000_resource
;
114 cmx2xx_dm9000_device
.resource
= cmx270_dm9000_resource
;
115 platform_device_register(&cmx2xx_dm9000_device
);
118 static inline void cmx2xx_init_dm9000(void) {}
121 /* UCB1400 touchscreen controller */
122 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
123 static struct platform_device cmx2xx_ts_device
= {
124 .name
= "ucb1400_core",
128 static void __init
cmx2xx_init_touchscreen(void)
130 platform_device_register(&cmx2xx_ts_device
);
133 static inline void cmx2xx_init_touchscreen(void) {}
137 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
138 static struct gpio_led cmx2xx_leds
[] = {
140 .name
= "cm-x2xx:red",
141 .default_trigger
= "nand-disk",
145 .name
= "cm-x2xx:green",
146 .default_trigger
= "heartbeat",
151 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata
= {
152 .num_leds
= ARRAY_SIZE(cmx2xx_leds
),
156 static struct platform_device cmx2xx_led_device
= {
160 .platform_data
= &cmx2xx_gpio_led_pdata
,
164 static void __init
cmx2xx_init_leds(void)
166 if (cpu_is_pxa25x()) {
167 cmx2xx_leds
[0].gpio
= CMX255_GPIO_RED
;
168 cmx2xx_leds
[1].gpio
= CMX255_GPIO_GREEN
;
170 cmx2xx_leds
[0].gpio
= CMX270_GPIO_RED
;
171 cmx2xx_leds
[1].gpio
= CMX270_GPIO_GREEN
;
173 platform_device_register(&cmx2xx_led_device
);
176 static inline void cmx2xx_init_leds(void) {}
179 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
182 keep these for backwards compatibility, although symbolic names (as
183 e.g. in lpd270.c) looks better
185 #define MTYPE_STN320x240 0
186 #define MTYPE_TFT640x480 1
187 #define MTYPE_CRT640x480 2
188 #define MTYPE_CRT800x600 3
189 #define MTYPE_TFT320x240 6
190 #define MTYPE_STN640x480 7
192 static struct pxafb_mode_info generic_stn_320x240_mode
= {
203 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
204 FB_SYNC_VERT_HIGH_ACT
),
208 static struct pxafb_mach_info generic_stn_320x240
= {
209 .modes
= &generic_stn_320x240_mode
,
211 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_PCLK_EDGE_FALL
|\
212 LCD_AC_BIAS_FREQ(0xff),
217 static struct pxafb_mode_info generic_tft_640x480_mode
= {
232 static struct pxafb_mach_info generic_tft_640x480
= {
233 .modes
= &generic_tft_640x480_mode
,
235 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_PCLK_EDGE_FALL
|\
236 LCD_AC_BIAS_FREQ(0xff),
241 static struct pxafb_mode_info generic_crt_640x480_mode
= {
252 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
253 FB_SYNC_VERT_HIGH_ACT
),
257 static struct pxafb_mach_info generic_crt_640x480
= {
258 .modes
= &generic_crt_640x480_mode
,
260 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
265 static struct pxafb_mode_info generic_crt_800x600_mode
= {
276 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
277 FB_SYNC_VERT_HIGH_ACT
),
281 static struct pxafb_mach_info generic_crt_800x600
= {
282 .modes
= &generic_crt_800x600_mode
,
284 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
289 static struct pxafb_mode_info generic_tft_320x240_mode
= {
304 static struct pxafb_mach_info generic_tft_320x240
= {
305 .modes
= &generic_tft_320x240_mode
,
307 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_AC_BIAS_FREQ(0xff),
312 static struct pxafb_mode_info generic_stn_640x480_mode
= {
323 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
324 FB_SYNC_VERT_HIGH_ACT
),
328 static struct pxafb_mach_info generic_stn_640x480
= {
329 .modes
= &generic_stn_640x480_mode
,
331 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_AC_BIAS_FREQ(0xff),
336 static struct pxafb_mach_info
*cmx2xx_display
= &generic_crt_640x480
;
338 static int __init
cmx2xx_set_display(char *str
)
340 int disp_type
= simple_strtol(str
, NULL
, 0);
342 case MTYPE_STN320x240
:
343 cmx2xx_display
= &generic_stn_320x240
;
345 case MTYPE_TFT640x480
:
346 cmx2xx_display
= &generic_tft_640x480
;
348 case MTYPE_CRT640x480
:
349 cmx2xx_display
= &generic_crt_640x480
;
351 case MTYPE_CRT800x600
:
352 cmx2xx_display
= &generic_crt_800x600
;
354 case MTYPE_TFT320x240
:
355 cmx2xx_display
= &generic_tft_320x240
;
357 case MTYPE_STN640x480
:
358 cmx2xx_display
= &generic_stn_640x480
;
360 default: /* fallback to CRT 640x480 */
361 cmx2xx_display
= &generic_crt_640x480
;
368 This should be done really early to get proper configuration for
370 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
371 has limitied line length for kernel command line, and also it will
372 break compatibitlty with proprietary releases already in field.
374 __setup("monitor=", cmx2xx_set_display
);
376 static void __init
cmx2xx_init_display(void)
378 set_pxa_fb_info(cmx2xx_display
);
381 static inline void cmx2xx_init_display(void) {}
385 static unsigned long sleep_save_msc
[10];
387 static int cmx2xx_suspend(struct sys_device
*dev
, pm_message_t state
)
389 cmx2xx_pci_suspend();
391 /* save MSC registers */
392 sleep_save_msc
[0] = MSC0
;
393 sleep_save_msc
[1] = MSC1
;
394 sleep_save_msc
[2] = MSC2
;
396 /* setup power saving mode registers */
411 static int cmx2xx_resume(struct sys_device
*dev
)
415 /* restore MSC registers */
416 MSC0
= sleep_save_msc
[0];
417 MSC1
= sleep_save_msc
[1];
418 MSC2
= sleep_save_msc
[2];
423 static struct sysdev_class cmx2xx_pm_sysclass
= {
425 .resume
= cmx2xx_resume
,
426 .suspend
= cmx2xx_suspend
,
429 static struct sys_device cmx2xx_pm_device
= {
430 .cls
= &cmx2xx_pm_sysclass
,
433 static int __init
cmx2xx_pm_init(void)
436 error
= sysdev_class_register(&cmx2xx_pm_sysclass
);
438 error
= sysdev_register(&cmx2xx_pm_device
);
442 static int __init
cmx2xx_pm_init(void) { return 0; }
445 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
446 static void __init
cmx2xx_init_ac97(void)
448 pxa_set_ac97_info(NULL
);
451 static inline void cmx2xx_init_ac97(void) {}
454 static void __init
cmx2xx_init(void)
463 cmx2xx_init_dm9000();
464 cmx2xx_init_display();
466 cmx2xx_init_touchscreen();
470 static void __init
cmx2xx_init_irq(void)
474 if (cpu_is_pxa25x()) {
476 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ
);
479 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ
);
484 /* Map PCI companion statically */
485 static struct map_desc cmx2xx_io_desc
[] __initdata
= {
486 [0] = { /* PCI bridge */
487 .virtual = CMX2XX_IT8152_VIRT
,
488 .pfn
= __phys_to_pfn(PXA_CS4_PHYS
),
494 static void __init
cmx2xx_map_io(void)
497 iotable_init(cmx2xx_io_desc
, ARRAY_SIZE(cmx2xx_io_desc
));
499 it8152_base_address
= CMX2XX_IT8152_VIRT
;
502 static void __init
cmx2xx_map_io(void)
508 MACHINE_START(ARMCORE
, "Compulab CM-X2XX")
509 .boot_params
= 0xa0000100,
510 .phys_io
= 0x40000000,
511 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
512 .map_io
= cmx2xx_map_io
,
513 .init_irq
= cmx2xx_init_irq
,
515 .init_machine
= cmx2xx_init
,