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 #include <mach/pxa27x.h>
26 #include <mach/audio.h>
27 #include <mach/pxafb.h>
28 #include <mach/smemc.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 /* reserve IRQs for IT8152 */
39 #define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
41 /* virtual addresses for statically mapped regions */
42 #define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
43 #define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
45 /* physical address if local-bus attached devices */
46 #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
47 #define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
50 #define CMX255_GPIO_RED (27)
51 #define CMX255_GPIO_GREEN (32)
52 #define CMX270_GPIO_RED (93)
53 #define CMX270_GPIO_GREEN (94)
56 #define GPIO22_ETHIRQ (22)
57 #define GPIO10_ETHIRQ (10)
58 #define CMX255_GPIO_IT8152_IRQ (0)
59 #define CMX270_GPIO_IT8152_IRQ (22)
61 #define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
62 #define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
64 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
65 static struct resource cmx255_dm9000_resource
[] = {
67 .start
= CMX255_DM9000_PHYS_BASE
,
68 .end
= CMX255_DM9000_PHYS_BASE
+ 3,
69 .flags
= IORESOURCE_MEM
,
72 .start
= CMX255_DM9000_PHYS_BASE
+ 4,
73 .end
= CMX255_DM9000_PHYS_BASE
+ 4 + 500,
74 .flags
= IORESOURCE_MEM
,
77 .start
= CMX255_ETHIRQ
,
79 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
83 static struct resource cmx270_dm9000_resource
[] = {
85 .start
= CMX270_DM9000_PHYS_BASE
,
86 .end
= CMX270_DM9000_PHYS_BASE
+ 3,
87 .flags
= IORESOURCE_MEM
,
90 .start
= CMX270_DM9000_PHYS_BASE
+ 8,
91 .end
= CMX270_DM9000_PHYS_BASE
+ 8 + 500,
92 .flags
= IORESOURCE_MEM
,
95 .start
= CMX270_ETHIRQ
,
97 .flags
= IORESOURCE_IRQ
| IORESOURCE_IRQ_HIGHEDGE
,
101 static struct dm9000_plat_data cmx270_dm9000_platdata
= {
102 .flags
= DM9000_PLATF_32BITONLY
| DM9000_PLATF_NO_EEPROM
,
105 static struct platform_device cmx2xx_dm9000_device
= {
108 .num_resources
= ARRAY_SIZE(cmx270_dm9000_resource
),
110 .platform_data
= &cmx270_dm9000_platdata
,
114 static void __init
cmx2xx_init_dm9000(void)
117 cmx2xx_dm9000_device
.resource
= cmx255_dm9000_resource
;
119 cmx2xx_dm9000_device
.resource
= cmx270_dm9000_resource
;
120 platform_device_register(&cmx2xx_dm9000_device
);
123 static inline void cmx2xx_init_dm9000(void) {}
126 /* UCB1400 touchscreen controller */
127 #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
128 static struct platform_device cmx2xx_ts_device
= {
129 .name
= "ucb1400_core",
133 static void __init
cmx2xx_init_touchscreen(void)
135 platform_device_register(&cmx2xx_ts_device
);
138 static inline void cmx2xx_init_touchscreen(void) {}
142 #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
143 static struct gpio_led cmx2xx_leds
[] = {
145 .name
= "cm-x2xx:red",
146 .default_trigger
= "nand-disk",
150 .name
= "cm-x2xx:green",
151 .default_trigger
= "heartbeat",
156 static struct gpio_led_platform_data cmx2xx_gpio_led_pdata
= {
157 .num_leds
= ARRAY_SIZE(cmx2xx_leds
),
161 static struct platform_device cmx2xx_led_device
= {
165 .platform_data
= &cmx2xx_gpio_led_pdata
,
169 static void __init
cmx2xx_init_leds(void)
171 if (cpu_is_pxa25x()) {
172 cmx2xx_leds
[0].gpio
= CMX255_GPIO_RED
;
173 cmx2xx_leds
[1].gpio
= CMX255_GPIO_GREEN
;
175 cmx2xx_leds
[0].gpio
= CMX270_GPIO_RED
;
176 cmx2xx_leds
[1].gpio
= CMX270_GPIO_GREEN
;
178 platform_device_register(&cmx2xx_led_device
);
181 static inline void cmx2xx_init_leds(void) {}
184 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
187 keep these for backwards compatibility, although symbolic names (as
188 e.g. in lpd270.c) looks better
190 #define MTYPE_STN320x240 0
191 #define MTYPE_TFT640x480 1
192 #define MTYPE_CRT640x480 2
193 #define MTYPE_CRT800x600 3
194 #define MTYPE_TFT320x240 6
195 #define MTYPE_STN640x480 7
197 static struct pxafb_mode_info generic_stn_320x240_mode
= {
208 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
209 FB_SYNC_VERT_HIGH_ACT
),
213 static struct pxafb_mach_info generic_stn_320x240
= {
214 .modes
= &generic_stn_320x240_mode
,
216 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_PCLK_EDGE_FALL
|\
217 LCD_AC_BIAS_FREQ(0xff),
222 static struct pxafb_mode_info generic_tft_640x480_mode
= {
237 static struct pxafb_mach_info generic_tft_640x480
= {
238 .modes
= &generic_tft_640x480_mode
,
240 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_PCLK_EDGE_FALL
|\
241 LCD_AC_BIAS_FREQ(0xff),
246 static struct pxafb_mode_info generic_crt_640x480_mode
= {
257 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
258 FB_SYNC_VERT_HIGH_ACT
),
262 static struct pxafb_mach_info generic_crt_640x480
= {
263 .modes
= &generic_crt_640x480_mode
,
265 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
270 static struct pxafb_mode_info generic_crt_800x600_mode
= {
281 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
282 FB_SYNC_VERT_HIGH_ACT
),
286 static struct pxafb_mach_info generic_crt_800x600
= {
287 .modes
= &generic_crt_800x600_mode
,
289 .lcd_conn
= LCD_COLOR_TFT_8BPP
| LCD_AC_BIAS_FREQ(0xff),
294 static struct pxafb_mode_info generic_tft_320x240_mode
= {
309 static struct pxafb_mach_info generic_tft_320x240
= {
310 .modes
= &generic_tft_320x240_mode
,
312 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_AC_BIAS_FREQ(0xff),
317 static struct pxafb_mode_info generic_stn_640x480_mode
= {
328 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
329 FB_SYNC_VERT_HIGH_ACT
),
333 static struct pxafb_mach_info generic_stn_640x480
= {
334 .modes
= &generic_stn_640x480_mode
,
336 .lcd_conn
= LCD_COLOR_STN_8BPP
| LCD_AC_BIAS_FREQ(0xff),
341 static struct pxafb_mach_info
*cmx2xx_display
= &generic_crt_640x480
;
343 static int __init
cmx2xx_set_display(char *str
)
345 int disp_type
= simple_strtol(str
, NULL
, 0);
347 case MTYPE_STN320x240
:
348 cmx2xx_display
= &generic_stn_320x240
;
350 case MTYPE_TFT640x480
:
351 cmx2xx_display
= &generic_tft_640x480
;
353 case MTYPE_CRT640x480
:
354 cmx2xx_display
= &generic_crt_640x480
;
356 case MTYPE_CRT800x600
:
357 cmx2xx_display
= &generic_crt_800x600
;
359 case MTYPE_TFT320x240
:
360 cmx2xx_display
= &generic_tft_320x240
;
362 case MTYPE_STN640x480
:
363 cmx2xx_display
= &generic_stn_640x480
;
365 default: /* fallback to CRT 640x480 */
366 cmx2xx_display
= &generic_crt_640x480
;
373 This should be done really early to get proper configuration for
375 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
376 has limitied line length for kernel command line, and also it will
377 break compatibitlty with proprietary releases already in field.
379 __setup("monitor=", cmx2xx_set_display
);
381 static void __init
cmx2xx_init_display(void)
383 pxa_set_fb_info(NULL
, cmx2xx_display
);
386 static inline void cmx2xx_init_display(void) {}
390 static unsigned long sleep_save_msc
[10];
392 static int cmx2xx_suspend(void)
394 cmx2xx_pci_suspend();
396 /* save MSC registers */
397 sleep_save_msc
[0] = __raw_readl(MSC0
);
398 sleep_save_msc
[1] = __raw_readl(MSC1
);
399 sleep_save_msc
[2] = __raw_readl(MSC2
);
401 /* setup power saving mode registers */
416 static void cmx2xx_resume(void)
420 /* restore MSC registers */
421 __raw_writel(sleep_save_msc
[0], MSC0
);
422 __raw_writel(sleep_save_msc
[1], MSC1
);
423 __raw_writel(sleep_save_msc
[2], MSC2
);
426 static struct syscore_ops cmx2xx_pm_syscore_ops
= {
427 .resume
= cmx2xx_resume
,
428 .suspend
= cmx2xx_suspend
,
431 static int __init
cmx2xx_pm_init(void)
433 register_syscore_ops(&cmx2xx_pm_syscore_ops
);
438 static int __init
cmx2xx_pm_init(void) { return 0; }
441 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
442 static void __init
cmx2xx_init_ac97(void)
444 pxa_set_ac97_info(NULL
);
447 static inline void cmx2xx_init_ac97(void) {}
450 static void __init
cmx2xx_init(void)
452 pxa_set_ffuart_info(NULL
);
453 pxa_set_btuart_info(NULL
);
454 pxa_set_stuart_info(NULL
);
463 cmx2xx_init_dm9000();
464 cmx2xx_init_display();
466 cmx2xx_init_touchscreen();
470 static void __init
cmx2xx_init_irq(void)
472 if (cpu_is_pxa25x()) {
474 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ
);
477 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ
);
482 /* Map PCI companion statically */
483 static struct map_desc cmx2xx_io_desc
[] __initdata
= {
484 [0] = { /* PCI bridge */
485 .virtual = (unsigned long)CMX2XX_IT8152_VIRT
,
486 .pfn
= __phys_to_pfn(PXA_CS4_PHYS
),
492 static void __init
cmx2xx_map_io(void)
500 iotable_init(cmx2xx_io_desc
, ARRAY_SIZE(cmx2xx_io_desc
));
502 it8152_base_address
= CMX2XX_IT8152_VIRT
;
505 static void __init
cmx2xx_map_io(void)
515 MACHINE_START(ARMCORE
, "Compulab CM-X2XX")
516 .atag_offset
= 0x100,
517 .map_io
= cmx2xx_map_io
,
518 .nr_irqs
= CMX2XX_NR_IRQS
,
519 .init_irq
= cmx2xx_init_irq
,
520 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
521 .handle_irq
= pxa25x_handle_irq
,
523 .init_machine
= cmx2xx_init
,
525 .dma_zone_size
= SZ_64M
,
527 .restart
= pxa_restart
,