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>
27 #include <mach/smemc.h>
29 #include <asm/hardware/it8152.h>
32 #include "cm-x2xx-pci.h"
34 extern void cmx255_init(void);
35 extern void cmx270_init(void);
37 /* reserve IRQs for IT8152 */
38 #define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
40 /* virtual addresses for statically mapped regions */
41 #define CMX2XX_VIRT_BASE (0xe8000000)
42 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
44 /* physical address if local-bus attached devices */
45 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
46 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
49 #define CMX255_GPIO_RED (27)
50 #define CMX255_GPIO_GREEN (32)
51 #define CMX270_GPIO_RED (93)
52 #define CMX270_GPIO_GREEN (94)
55 #define GPIO22_ETHIRQ (22)
56 #define GPIO10_ETHIRQ (10)
57 #define CMX255_GPIO_IT8152_IRQ (0)
58 #define CMX270_GPIO_IT8152_IRQ (22)
60 #define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
61 #define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
63 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
64 static struct resource cmx255_dm9000_resource
[] = {
66 .start
= CMX255_DM9000_PHYS_BASE
,
67 .end
= CMX255_DM9000_PHYS_BASE
+ 3,
68 .flags
= IORESOURCE_MEM
,
71 .start
= CMX255_DM9000_PHYS_BASE
+ 4,
72 .end
= CMX255_DM9000_PHYS_BASE
+ 4 + 500,
73 .flags
= IORESOURCE_MEM
,
76 .start
= CMX255_ETHIRQ
,
78 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
82 static struct resource cmx270_dm9000_resource
[] = {
84 .start
= CMX270_DM9000_PHYS_BASE
,
85 .end
= CMX270_DM9000_PHYS_BASE
+ 3,
86 .flags
= IORESOURCE_MEM
,
89 .start
= CMX270_DM9000_PHYS_BASE
+ 8,
90 .end
= CMX270_DM9000_PHYS_BASE
+ 8 + 500,
91 .flags
= IORESOURCE_MEM
,
94 .start
= CMX270_ETHIRQ
,
96 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
100 static struct dm9000_plat_data cmx270_dm9000_platdata
= {
101 .flags
= DM9000_PLATF_32BITONLY
| DM9000_PLATF_NO_EEPROM
,
104 static struct platform_device cmx2xx_dm9000_device
= {
107 .num_resources
= ARRAY_SIZE(cmx270_dm9000_resource
),
109 .platform_data
= &cmx270_dm9000_platdata
,
113 static void __init
cmx2xx_init_dm9000(void)
116 cmx2xx_dm9000_device
.resource
= cmx255_dm9000_resource
;
118 cmx2xx_dm9000_device
.resource
= cmx270_dm9000_resource
;
119 platform_device_register(&cmx2xx_dm9000_device
);
122 static inline void cmx2xx_init_dm9000(void) {}
125 /* UCB1400 touchscreen controller */
126 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
127 static struct platform_device cmx2xx_ts_device
= {
128 .name
= "ucb1400_core",
132 static void __init
cmx2xx_init_touchscreen(void)
134 platform_device_register(&cmx2xx_ts_device
);
137 static inline void cmx2xx_init_touchscreen(void) {}
141 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
142 static struct gpio_led cmx2xx_leds
[] = {
144 .name
= "cm-x2xx:red",
145 .default_trigger
= "nand-disk",
149 .name
= "cm-x2xx:green",
150 .default_trigger
= "heartbeat",
155 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata
= {
156 .num_leds
= ARRAY_SIZE(cmx2xx_leds
),
160 static struct platform_device cmx2xx_led_device
= {
164 .platform_data
= &cmx2xx_gpio_led_pdata
,
168 static void __init
cmx2xx_init_leds(void)
170 if (cpu_is_pxa25x()) {
171 cmx2xx_leds
[0].gpio
= CMX255_GPIO_RED
;
172 cmx2xx_leds
[1].gpio
= CMX255_GPIO_GREEN
;
174 cmx2xx_leds
[0].gpio
= CMX270_GPIO_RED
;
175 cmx2xx_leds
[1].gpio
= CMX270_GPIO_GREEN
;
177 platform_device_register(&cmx2xx_led_device
);
180 static inline void cmx2xx_init_leds(void) {}
183 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
186 keep these for backwards compatibility, although symbolic names (as
187 e.g. in lpd270.c) looks better
189 #define MTYPE_STN320x240 0
190 #define MTYPE_TFT640x480 1
191 #define MTYPE_CRT640x480 2
192 #define MTYPE_CRT800x600 3
193 #define MTYPE_TFT320x240 6
194 #define MTYPE_STN640x480 7
196 static struct pxafb_mode_info generic_stn_320x240_mode
= {
207 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
208 FB_SYNC_VERT_HIGH_ACT
),
212 static struct pxafb_mach_info generic_stn_320x240
= {
213 .modes
= &generic_stn_320x240_mode
,
215 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_PCLK_EDGE_FALL
|\
216 LCD_AC_BIAS_FREQ(0xff),
221 static struct pxafb_mode_info generic_tft_640x480_mode
= {
236 static struct pxafb_mach_info generic_tft_640x480
= {
237 .modes
= &generic_tft_640x480_mode
,
239 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_PCLK_EDGE_FALL
|\
240 LCD_AC_BIAS_FREQ(0xff),
245 static struct pxafb_mode_info generic_crt_640x480_mode
= {
256 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
257 FB_SYNC_VERT_HIGH_ACT
),
261 static struct pxafb_mach_info generic_crt_640x480
= {
262 .modes
= &generic_crt_640x480_mode
,
264 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
269 static struct pxafb_mode_info generic_crt_800x600_mode
= {
280 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
281 FB_SYNC_VERT_HIGH_ACT
),
285 static struct pxafb_mach_info generic_crt_800x600
= {
286 .modes
= &generic_crt_800x600_mode
,
288 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
293 static struct pxafb_mode_info generic_tft_320x240_mode
= {
308 static struct pxafb_mach_info generic_tft_320x240
= {
309 .modes
= &generic_tft_320x240_mode
,
311 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_AC_BIAS_FREQ(0xff),
316 static struct pxafb_mode_info generic_stn_640x480_mode
= {
327 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
328 FB_SYNC_VERT_HIGH_ACT
),
332 static struct pxafb_mach_info generic_stn_640x480
= {
333 .modes
= &generic_stn_640x480_mode
,
335 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_AC_BIAS_FREQ(0xff),
340 static struct pxafb_mach_info
*cmx2xx_display
= &generic_crt_640x480
;
342 static int __init
cmx2xx_set_display(char *str
)
344 int disp_type
= simple_strtol(str
, NULL
, 0);
346 case MTYPE_STN320x240
:
347 cmx2xx_display
= &generic_stn_320x240
;
349 case MTYPE_TFT640x480
:
350 cmx2xx_display
= &generic_tft_640x480
;
352 case MTYPE_CRT640x480
:
353 cmx2xx_display
= &generic_crt_640x480
;
355 case MTYPE_CRT800x600
:
356 cmx2xx_display
= &generic_crt_800x600
;
358 case MTYPE_TFT320x240
:
359 cmx2xx_display
= &generic_tft_320x240
;
361 case MTYPE_STN640x480
:
362 cmx2xx_display
= &generic_stn_640x480
;
364 default: /* fallback to CRT 640x480 */
365 cmx2xx_display
= &generic_crt_640x480
;
372 This should be done really early to get proper configuration for
374 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
375 has limitied line length for kernel command line, and also it will
376 break compatibitlty with proprietary releases already in field.
378 __setup("monitor=", cmx2xx_set_display
);
380 static void __init
cmx2xx_init_display(void)
382 set_pxa_fb_info(cmx2xx_display
);
385 static inline void cmx2xx_init_display(void) {}
389 static unsigned long sleep_save_msc
[10];
391 static int cmx2xx_suspend(struct sys_device
*dev
, pm_message_t state
)
393 cmx2xx_pci_suspend();
395 /* save MSC registers */
396 sleep_save_msc
[0] = __raw_readl(MSC0
);
397 sleep_save_msc
[1] = __raw_readl(MSC1
);
398 sleep_save_msc
[2] = __raw_readl(MSC2
);
400 /* setup power saving mode registers */
415 static int cmx2xx_resume(struct sys_device
*dev
)
419 /* restore MSC registers */
420 __raw_writel(sleep_save_msc
[0], MSC0
);
421 __raw_writel(sleep_save_msc
[1], MSC1
);
422 __raw_writel(sleep_save_msc
[2], MSC2
);
427 static struct sysdev_class cmx2xx_pm_sysclass
= {
429 .resume
= cmx2xx_resume
,
430 .suspend
= cmx2xx_suspend
,
433 static struct sys_device cmx2xx_pm_device
= {
434 .cls
= &cmx2xx_pm_sysclass
,
437 static int __init
cmx2xx_pm_init(void)
440 error
= sysdev_class_register(&cmx2xx_pm_sysclass
);
442 error
= sysdev_register(&cmx2xx_pm_device
);
446 static int __init
cmx2xx_pm_init(void) { return 0; }
449 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
450 static void __init
cmx2xx_init_ac97(void)
452 pxa_set_ac97_info(NULL
);
455 static inline void cmx2xx_init_ac97(void) {}
458 static void __init
cmx2xx_init(void)
460 pxa_set_ffuart_info(NULL
);
461 pxa_set_btuart_info(NULL
);
462 pxa_set_stuart_info(NULL
);
471 cmx2xx_init_dm9000();
472 cmx2xx_init_display();
474 cmx2xx_init_touchscreen();
478 static void __init
cmx2xx_init_irq(void)
480 if (cpu_is_pxa25x()) {
482 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ
);
485 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ
);
490 /* Map PCI companion statically */
491 static struct map_desc cmx2xx_io_desc
[] __initdata
= {
492 [0] = { /* PCI bridge */
493 .virtual = CMX2XX_IT8152_VIRT
,
494 .pfn
= __phys_to_pfn(PXA_CS4_PHYS
),
500 static void __init
cmx2xx_map_io(void)
508 iotable_init(cmx2xx_io_desc
, ARRAY_SIZE(cmx2xx_io_desc
));
510 it8152_base_address
= CMX2XX_IT8152_VIRT
;
513 static void __init
cmx2xx_map_io(void)
523 MACHINE_START(ARMCORE
, "Compulab CM-X2XX")
524 .boot_params
= 0xa0000100,
525 .map_io
= cmx2xx_map_io
,
526 .nr_irqs
= CMX2XX_NR_IRQS
,
527 .init_irq
= cmx2xx_init_irq
,
529 .init_machine
= cmx2xx_init
,