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
,
214 .lccr3
= (LCCR3_PixClkDiv(0x03) |
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 .lccr0
= (LCCR0_PAS
),
240 .lccr3
= (LCCR3_PixClkDiv(0x01) |
247 static struct pxafb_mode_info generic_crt_640x480_mode
= {
258 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
259 FB_SYNC_VERT_HIGH_ACT
),
263 static struct pxafb_mach_info generic_crt_640x480
= {
264 .modes
= &generic_crt_640x480_mode
,
266 .lccr0
= (LCCR0_PAS
),
267 .lccr3
= (LCCR3_PixClkDiv(0x01) |
273 static struct pxafb_mode_info generic_crt_800x600_mode
= {
284 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
285 FB_SYNC_VERT_HIGH_ACT
),
289 static struct pxafb_mach_info generic_crt_800x600
= {
290 .modes
= &generic_crt_800x600_mode
,
292 .lccr0
= (LCCR0_PAS
),
293 .lccr3
= (LCCR3_PixClkDiv(0x02) |
299 static struct pxafb_mode_info generic_tft_320x240_mode
= {
314 static struct pxafb_mach_info generic_tft_320x240
= {
315 .modes
= &generic_tft_320x240_mode
,
317 .lccr0
= (LCCR0_PAS
),
318 .lccr3
= (LCCR3_PixClkDiv(0x06) |
325 static struct pxafb_mode_info generic_stn_640x480_mode
= {
336 .sync
= (FB_SYNC_HOR_HIGH_ACT
|
337 FB_SYNC_VERT_HIGH_ACT
),
341 static struct pxafb_mach_info generic_stn_640x480
= {
342 .modes
= &generic_stn_640x480_mode
,
345 .lccr3
= (LCCR3_PixClkDiv(0x02) |
351 static struct pxafb_mach_info
*cmx2xx_display
= &generic_crt_640x480
;
353 static int __init
cmx2xx_set_display(char *str
)
355 int disp_type
= simple_strtol(str
, NULL
, 0);
357 case MTYPE_STN320x240
:
358 cmx2xx_display
= &generic_stn_320x240
;
360 case MTYPE_TFT640x480
:
361 cmx2xx_display
= &generic_tft_640x480
;
363 case MTYPE_CRT640x480
:
364 cmx2xx_display
= &generic_crt_640x480
;
366 case MTYPE_CRT800x600
:
367 cmx2xx_display
= &generic_crt_800x600
;
369 case MTYPE_TFT320x240
:
370 cmx2xx_display
= &generic_tft_320x240
;
372 case MTYPE_STN640x480
:
373 cmx2xx_display
= &generic_stn_640x480
;
375 default: /* fallback to CRT 640x480 */
376 cmx2xx_display
= &generic_crt_640x480
;
383 This should be done really early to get proper configuration for
385 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
386 has limitied line length for kernel command line, and also it will
387 break compatibitlty with proprietary releases already in field.
389 __setup("monitor=", cmx2xx_set_display
);
391 static void __init
cmx2xx_init_display(void)
393 set_pxa_fb_info(cmx2xx_display
);
396 static inline void cmx2xx_init_display(void) {}
400 static unsigned long sleep_save_msc
[10];
402 static int cmx2xx_suspend(struct sys_device
*dev
, pm_message_t state
)
404 cmx2xx_pci_suspend();
406 /* save MSC registers */
407 sleep_save_msc
[0] = MSC0
;
408 sleep_save_msc
[1] = MSC1
;
409 sleep_save_msc
[2] = MSC2
;
411 /* setup power saving mode registers */
426 static int cmx2xx_resume(struct sys_device
*dev
)
430 /* restore MSC registers */
431 MSC0
= sleep_save_msc
[0];
432 MSC1
= sleep_save_msc
[1];
433 MSC2
= sleep_save_msc
[2];
438 static struct sysdev_class cmx2xx_pm_sysclass
= {
440 .resume
= cmx2xx_resume
,
441 .suspend
= cmx2xx_suspend
,
444 static struct sys_device cmx2xx_pm_device
= {
445 .cls
= &cmx2xx_pm_sysclass
,
448 static int __init
cmx2xx_pm_init(void)
451 error
= sysdev_class_register(&cmx2xx_pm_sysclass
);
453 error
= sysdev_register(&cmx2xx_pm_device
);
457 static int __init
cmx2xx_pm_init(void) { return 0; }
460 #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
461 static void __init
cmx2xx_init_ac97(void)
463 pxa_set_ac97_info(NULL
);
466 static inline void cmx2xx_init_ac97(void) {}
469 static void __init
cmx2xx_init(void)
478 cmx2xx_init_dm9000();
479 cmx2xx_init_display();
481 cmx2xx_init_touchscreen();
485 static void __init
cmx2xx_init_irq(void)
489 if (cpu_is_pxa25x()) {
491 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ
);
494 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ
);
499 /* Map PCI companion statically */
500 static struct map_desc cmx2xx_io_desc
[] __initdata
= {
501 [0] = { /* PCI bridge */
502 .virtual = CMX2XX_IT8152_VIRT
,
503 .pfn
= __phys_to_pfn(PXA_CS4_PHYS
),
509 static void __init
cmx2xx_map_io(void)
512 iotable_init(cmx2xx_io_desc
, ARRAY_SIZE(cmx2xx_io_desc
));
514 it8152_base_address
= CMX2XX_IT8152_VIRT
;
517 static void __init
cmx2xx_map_io(void)
523 MACHINE_START(ARMCORE
, "Compulab CM-X2XX")
524 .boot_params
= 0xa0000100,
525 .phys_io
= 0x40000000,
526 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
527 .map_io
= cmx2xx_map_io
,
528 .init_irq
= cmx2xx_init_irq
,
530 .init_machine
= cmx2xx_init
,