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>
16 #include <linux/regulator/machine.h>
18 #include <linux/dm9000.h>
19 #include <linux/leds.h>
21 #include <asm/mach/arch.h>
22 #include <asm/mach-types.h>
23 #include <asm/mach/map.h>
26 #undef GPIO24_SSP1_SFRM
32 #undef GPIO24_SSP1_SFRM
37 #include <mach/audio.h>
38 #include <linux/platform_data/video-pxafb.h>
39 #include <mach/smemc.h>
41 #include <asm/hardware/it8152.h>
44 #include "cm-x2xx-pci.h"
46 extern void cmx255_init(void);
47 extern void cmx270_init(void);
49 /* reserve IRQs for IT8152 */
50 #define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
52 /* virtual addresses for statically mapped regions */
53 #define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
54 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
56 /* physical address if local-bus attached devices */
57 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
58 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
61 #define CMX255_GPIO_RED (27)
62 #define CMX255_GPIO_GREEN (32)
63 #define CMX270_GPIO_RED (93)
64 #define CMX270_GPIO_GREEN (94)
67 #define GPIO22_ETHIRQ (22)
68 #define GPIO10_ETHIRQ (10)
69 #define CMX255_GPIO_IT8152_IRQ (0)
70 #define CMX270_GPIO_IT8152_IRQ (22)
72 #define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
73 #define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
75 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
76 static struct resource cmx255_dm9000_resource
[] = {
78 .start
= CMX255_DM9000_PHYS_BASE
,
79 .end
= CMX255_DM9000_PHYS_BASE
+ 3,
80 .flags
= IORESOURCE_MEM
,
83 .start
= CMX255_DM9000_PHYS_BASE
+ 4,
84 .end
= CMX255_DM9000_PHYS_BASE
+ 4 + 500,
85 .flags
= IORESOURCE_MEM
,
88 .start
= CMX255_ETHIRQ
,
90 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
94 static struct resource cmx270_dm9000_resource
[] = {
96 .start
= CMX270_DM9000_PHYS_BASE
,
97 .end
= CMX270_DM9000_PHYS_BASE
+ 3,
98 .flags
= IORESOURCE_MEM
,
101 .start
= CMX270_DM9000_PHYS_BASE
+ 8,
102 .end
= CMX270_DM9000_PHYS_BASE
+ 8 + 500,
103 .flags
= IORESOURCE_MEM
,
106 .start
= CMX270_ETHIRQ
,
107 .end
= CMX270_ETHIRQ
,
108 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
112 static struct dm9000_plat_data cmx270_dm9000_platdata
= {
113 .flags
= DM9000_PLATF_32BITONLY
| DM9000_PLATF_NO_EEPROM
,
116 static struct platform_device cmx2xx_dm9000_device
= {
119 .num_resources
= ARRAY_SIZE(cmx270_dm9000_resource
),
121 .platform_data
= &cmx270_dm9000_platdata
,
125 static void __init
cmx2xx_init_dm9000(void)
128 cmx2xx_dm9000_device
.resource
= cmx255_dm9000_resource
;
130 cmx2xx_dm9000_device
.resource
= cmx270_dm9000_resource
;
131 platform_device_register(&cmx2xx_dm9000_device
);
134 static inline void cmx2xx_init_dm9000(void) {}
137 /* UCB1400 touchscreen controller */
138 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
139 static struct platform_device cmx2xx_ts_device
= {
140 .name
= "ucb1400_core",
144 static void __init
cmx2xx_init_touchscreen(void)
146 platform_device_register(&cmx2xx_ts_device
);
149 static inline void cmx2xx_init_touchscreen(void) {}
153 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
154 static struct gpio_led cmx2xx_leds
[] = {
156 .name
= "cm-x2xx:red",
157 .default_trigger
= "nand-disk",
161 .name
= "cm-x2xx:green",
162 .default_trigger
= "heartbeat",
167 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata
= {
168 .num_leds
= ARRAY_SIZE(cmx2xx_leds
),
172 static struct platform_device cmx2xx_led_device
= {
176 .platform_data
= &cmx2xx_gpio_led_pdata
,
180 static void __init
cmx2xx_init_leds(void)
182 if (cpu_is_pxa25x()) {
183 cmx2xx_leds
[0].gpio
= CMX255_GPIO_RED
;
184 cmx2xx_leds
[1].gpio
= CMX255_GPIO_GREEN
;
186 cmx2xx_leds
[0].gpio
= CMX270_GPIO_RED
;
187 cmx2xx_leds
[1].gpio
= CMX270_GPIO_GREEN
;
189 platform_device_register(&cmx2xx_led_device
);
192 static inline void cmx2xx_init_leds(void) {}
195 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
198 keep these for backwards compatibility, although symbolic names (as
199 e.g. in lpd270.c) looks better
201 #define MTYPE_STN320x240 0
202 #define MTYPE_TFT640x480 1
203 #define MTYPE_CRT640x480 2
204 #define MTYPE_CRT800x600 3
205 #define MTYPE_TFT320x240 6
206 #define MTYPE_STN640x480 7
208 static struct pxafb_mode_info generic_stn_320x240_mode
= {
219 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
220 FB_SYNC_VERT_HIGH_ACT
),
224 static struct pxafb_mach_info generic_stn_320x240
= {
225 .modes
= &generic_stn_320x240_mode
,
227 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_PCLK_EDGE_FALL
|\
228 LCD_AC_BIAS_FREQ(0xff),
233 static struct pxafb_mode_info generic_tft_640x480_mode
= {
248 static struct pxafb_mach_info generic_tft_640x480
= {
249 .modes
= &generic_tft_640x480_mode
,
251 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_PCLK_EDGE_FALL
|\
252 LCD_AC_BIAS_FREQ(0xff),
257 static struct pxafb_mode_info generic_crt_640x480_mode
= {
268 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
269 FB_SYNC_VERT_HIGH_ACT
),
273 static struct pxafb_mach_info generic_crt_640x480
= {
274 .modes
= &generic_crt_640x480_mode
,
276 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
281 static struct pxafb_mode_info generic_crt_800x600_mode
= {
292 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
293 FB_SYNC_VERT_HIGH_ACT
),
297 static struct pxafb_mach_info generic_crt_800x600
= {
298 .modes
= &generic_crt_800x600_mode
,
300 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
305 static struct pxafb_mode_info generic_tft_320x240_mode
= {
320 static struct pxafb_mach_info generic_tft_320x240
= {
321 .modes
= &generic_tft_320x240_mode
,
323 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_AC_BIAS_FREQ(0xff),
328 static struct pxafb_mode_info generic_stn_640x480_mode
= {
339 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
340 FB_SYNC_VERT_HIGH_ACT
),
344 static struct pxafb_mach_info generic_stn_640x480
= {
345 .modes
= &generic_stn_640x480_mode
,
347 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_AC_BIAS_FREQ(0xff),
352 static struct pxafb_mach_info
*cmx2xx_display
= &generic_crt_640x480
;
354 static int __init
cmx2xx_set_display(char *str
)
356 int disp_type
= simple_strtol(str
, NULL
, 0);
358 case MTYPE_STN320x240
:
359 cmx2xx_display
= &generic_stn_320x240
;
361 case MTYPE_TFT640x480
:
362 cmx2xx_display
= &generic_tft_640x480
;
364 case MTYPE_CRT640x480
:
365 cmx2xx_display
= &generic_crt_640x480
;
367 case MTYPE_CRT800x600
:
368 cmx2xx_display
= &generic_crt_800x600
;
370 case MTYPE_TFT320x240
:
371 cmx2xx_display
= &generic_tft_320x240
;
373 case MTYPE_STN640x480
:
374 cmx2xx_display
= &generic_stn_640x480
;
376 default: /* fallback to CRT 640x480 */
377 cmx2xx_display
= &generic_crt_640x480
;
384 This should be done really early to get proper configuration for
386 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
387 has limitied line length for kernel command line, and also it will
388 break compatibitlty with proprietary releases already in field.
390 __setup("monitor=", cmx2xx_set_display
);
392 static void __init
cmx2xx_init_display(void)
394 pxa_set_fb_info(NULL
, cmx2xx_display
);
397 static inline void cmx2xx_init_display(void) {}
401 static unsigned long sleep_save_msc
[10];
403 static int cmx2xx_suspend(void)
405 cmx2xx_pci_suspend();
407 /* save MSC registers */
408 sleep_save_msc
[0] = __raw_readl(MSC0
);
409 sleep_save_msc
[1] = __raw_readl(MSC1
);
410 sleep_save_msc
[2] = __raw_readl(MSC2
);
412 /* setup power saving mode registers */
427 static void cmx2xx_resume(void)
431 /* restore MSC registers */
432 __raw_writel(sleep_save_msc
[0], MSC0
);
433 __raw_writel(sleep_save_msc
[1], MSC1
);
434 __raw_writel(sleep_save_msc
[2], MSC2
);
437 static struct syscore_ops cmx2xx_pm_syscore_ops
= {
438 .resume
= cmx2xx_resume
,
439 .suspend
= cmx2xx_suspend
,
442 static int __init
cmx2xx_pm_init(void)
444 register_syscore_ops(&cmx2xx_pm_syscore_ops
);
449 static int __init
cmx2xx_pm_init(void) { return 0; }
452 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
453 static void __init
cmx2xx_init_ac97(void)
455 pxa_set_ac97_info(NULL
);
458 static inline void cmx2xx_init_ac97(void) {}
461 static void __init
cmx2xx_init(void)
463 pxa_set_ffuart_info(NULL
);
464 pxa_set_btuart_info(NULL
);
465 pxa_set_stuart_info(NULL
);
474 cmx2xx_init_dm9000();
475 cmx2xx_init_display();
477 cmx2xx_init_touchscreen();
480 regulator_has_full_constraints();
483 static void __init
cmx2xx_init_irq(void)
485 if (cpu_is_pxa25x()) {
487 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ
);
490 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ
);
495 /* Map PCI companion statically */
496 static struct map_desc cmx2xx_io_desc
[] __initdata
= {
497 [0] = { /* PCI bridge */
498 .virtual = (unsigned long)CMX2XX_IT8152_VIRT
,
499 .pfn
= __phys_to_pfn(PXA_CS4_PHYS
),
505 static void __init
cmx2xx_map_io(void)
513 iotable_init(cmx2xx_io_desc
, ARRAY_SIZE(cmx2xx_io_desc
));
515 it8152_base_address
= CMX2XX_IT8152_VIRT
;
518 static void __init
cmx2xx_map_io(void)
528 MACHINE_START(ARMCORE
, "Compulab CM-X2XX")
529 .atag_offset
= 0x100,
530 .map_io
= cmx2xx_map_io
,
531 .nr_irqs
= CMX2XX_NR_IRQS
,
532 .init_irq
= cmx2xx_init_irq
,
533 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
534 .handle_irq
= pxa25x_handle_irq
,
535 .init_time
= pxa_timer_init
,
536 .init_machine
= cmx2xx_init
,
538 .dma_zone_size
= SZ_64M
,
540 .restart
= pxa_restart
,