blob: ec170a552c2375cf17d35f44950ca42c80a1973f [file] [log] [blame]
Mike Rapoport3696a8a2007-09-23 15:59:26 +01001/*
Mike Rapoportda591932008-10-05 10:25:44 +01002 * linux/arch/arm/mach-pxa/cm-x2xx.c
Mike Rapoport3696a8a2007-09-23 15:59:26 +01003 *
Mike Rapoport4adc5fb62008-10-05 10:26:10 +01004 * Copyright (C) 2008 CompuLab, Ltd.
Mike Rapoport3696a8a2007-09-23 15:59:26 +01005 * Mike Rapoport <mike@compulab.co.il>
6 *
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.
10 */
11
Mike Rapoport3696a8a2007-09-23 15:59:26 +010012#include <linux/platform_device.h>
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +020013#include <linux/syscore_ops.h>
Mike Rapoport2f01a972008-06-17 12:29:58 +010014#include <linux/irq.h>
15#include <linux/gpio.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010016
17#include <linux/dm9000.h>
Mike Rapoport2f01a972008-06-17 12:29:58 +010018#include <linux/leds.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010019
20#include <asm/mach/arch.h>
21#include <asm/mach-types.h>
22#include <asm/mach/map.h>
23
Eric Miaoca0e6872011-05-18 21:19:04 +080024#include <mach/pxa25x.h>
25#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/audio.h>
27#include <mach/pxafb.h>
Marek Vasutad68bb92010-11-03 16:29:35 +010028#include <mach/smemc.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010029
30#include <asm/hardware/it8152.h>
31
32#include "generic.h"
Mike Rapoport7d76e3f2008-10-07 11:58:25 +010033#include "cm-x2xx-pci.h"
Mike Rapoport3696a8a2007-09-23 15:59:26 +010034
Mike Rapoporta7f3f032008-10-05 10:26:55 +010035extern void cmx255_init(void);
Mike Rapoport4adc5fb62008-10-05 10:26:10 +010036extern void cmx270_init(void);
37
Haojian Zhuang6ac6b812010-08-20 15:23:59 +080038/* reserve IRQs for IT8152 */
39#define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
40
Mike Rapoport2f01a972008-06-17 12:29:58 +010041/* virtual addresses for statically mapped regions */
Arnd Bergmann97b09da2011-10-01 22:03:45 +020042#define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
Mike Rapoportda591932008-10-05 10:25:44 +010043#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010044
Mike Rapoport4adc5fb62008-10-05 10:26:10 +010045/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010046#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010047#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
48
49/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010050#define CMX255_GPIO_RED (27)
51#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010052#define CMX270_GPIO_RED (93)
53#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010054
Mike Rapoport2f01a972008-06-17 12:29:58 +010055/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010056#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010057#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010058#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010059#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010060
Mike Rapoporta7f3f032008-10-05 10:26:55 +010061#define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010062#define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010063
64#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010065static struct resource cmx255_dm9000_resource[] = {
66 [0] = {
67 .start = CMX255_DM9000_PHYS_BASE,
68 .end = CMX255_DM9000_PHYS_BASE + 3,
69 .flags = IORESOURCE_MEM,
70 },
71 [1] = {
72 .start = CMX255_DM9000_PHYS_BASE + 4,
73 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
74 .flags = IORESOURCE_MEM,
75 },
76 [2] = {
77 .start = CMX255_ETHIRQ,
78 .end = CMX255_ETHIRQ,
79 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
80 }
81};
82
Mike Rapoport2f01a972008-06-17 12:29:58 +010083static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010084 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010085 .start = CMX270_DM9000_PHYS_BASE,
86 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010087 .flags = IORESOURCE_MEM,
88 },
89 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +010090 .start = CMX270_DM9000_PHYS_BASE + 8,
91 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010092 .flags = IORESOURCE_MEM,
93 },
94 [2] = {
95 .start = CMX270_ETHIRQ,
96 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +010097 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010098 }
99};
100
Mike Rapoport2f01a972008-06-17 12:29:58 +0100101static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200102 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100103};
104
Mike Rapoportda591932008-10-05 10:25:44 +0100105static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100106 .name = "dm9000",
107 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100108 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100109 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100110 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100111 }
112};
113
Mike Rapoportda591932008-10-05 10:25:44 +0100114static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100115{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100116 if (cpu_is_pxa25x())
117 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
118 else
119 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100120 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100121}
122#else
Mike Rapoportda591932008-10-05 10:25:44 +0100123static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100124#endif
125
126/* UCB1400 touchscreen controller */
127#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100128static struct platform_device cmx2xx_ts_device = {
Marek Vasut50f6bb02009-04-01 22:30:07 +0800129 .name = "ucb1400_core",
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100130 .id = -1,
131};
132
Mike Rapoportda591932008-10-05 10:25:44 +0100133static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100134{
Mike Rapoportda591932008-10-05 10:25:44 +0100135 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100136}
137#else
Mike Rapoportda591932008-10-05 10:25:44 +0100138static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100139#endif
140
Mike Rapoport2f01a972008-06-17 12:29:58 +0100141/* CM-X270 LEDs */
142#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100143static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100144 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100145 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100146 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100147 .active_low = 1,
148 },
149 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100150 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100151 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100152 .active_low = 1,
153 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100154};
155
Mike Rapoportda591932008-10-05 10:25:44 +0100156static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
157 .num_leds = ARRAY_SIZE(cmx2xx_leds),
158 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100159};
160
Mike Rapoportda591932008-10-05 10:25:44 +0100161static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100162 .name = "leds-gpio",
163 .id = -1,
164 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100165 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100166 },
167};
168
Mike Rapoportda591932008-10-05 10:25:44 +0100169static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100170{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100171 if (cpu_is_pxa25x()) {
172 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
173 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
174 } else {
175 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
176 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
177 }
Mike Rapoportda591932008-10-05 10:25:44 +0100178 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100179}
180#else
Mike Rapoportda591932008-10-05 10:25:44 +0100181static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100182#endif
183
Mike Rapoport2f01a972008-06-17 12:29:58 +0100184#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100185/*
186 Display definitions
187 keep these for backwards compatibility, although symbolic names (as
188 e.g. in lpd270.c) looks better
189*/
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
196
197static struct pxafb_mode_info generic_stn_320x240_mode = {
198 .pixclock = 76923,
199 .bpp = 8,
200 .xres = 320,
201 .yres = 240,
202 .hsync_len = 3,
203 .vsync_len = 2,
204 .left_margin = 3,
205 .upper_margin = 0,
206 .right_margin = 3,
207 .lower_margin = 0,
208 .sync = (FB_SYNC_HOR_HIGH_ACT |
209 FB_SYNC_VERT_HIGH_ACT),
210 .cmap_greyscale = 0,
211};
212
213static struct pxafb_mach_info generic_stn_320x240 = {
214 .modes = &generic_stn_320x240_mode,
215 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800216 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
217 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100218 .cmap_inverse = 0,
219 .cmap_static = 0,
220};
221
222static struct pxafb_mode_info generic_tft_640x480_mode = {
223 .pixclock = 38461,
224 .bpp = 8,
225 .xres = 640,
226 .yres = 480,
227 .hsync_len = 60,
228 .vsync_len = 2,
229 .left_margin = 70,
230 .upper_margin = 10,
231 .right_margin = 70,
232 .lower_margin = 5,
233 .sync = 0,
234 .cmap_greyscale = 0,
235};
236
237static struct pxafb_mach_info generic_tft_640x480 = {
238 .modes = &generic_tft_640x480_mode,
239 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800240 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
241 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100242 .cmap_inverse = 0,
243 .cmap_static = 0,
244};
245
246static struct pxafb_mode_info generic_crt_640x480_mode = {
247 .pixclock = 38461,
248 .bpp = 8,
249 .xres = 640,
250 .yres = 480,
251 .hsync_len = 63,
252 .vsync_len = 2,
253 .left_margin = 81,
254 .upper_margin = 33,
255 .right_margin = 16,
256 .lower_margin = 10,
257 .sync = (FB_SYNC_HOR_HIGH_ACT |
258 FB_SYNC_VERT_HIGH_ACT),
259 .cmap_greyscale = 0,
260};
261
262static struct pxafb_mach_info generic_crt_640x480 = {
263 .modes = &generic_crt_640x480_mode,
264 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800265 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100266 .cmap_inverse = 0,
267 .cmap_static = 0,
268};
269
270static struct pxafb_mode_info generic_crt_800x600_mode = {
271 .pixclock = 28846,
272 .bpp = 8,
273 .xres = 800,
274 .yres = 600,
275 .hsync_len = 63,
276 .vsync_len = 2,
277 .left_margin = 26,
278 .upper_margin = 21,
279 .right_margin = 26,
280 .lower_margin = 11,
281 .sync = (FB_SYNC_HOR_HIGH_ACT |
282 FB_SYNC_VERT_HIGH_ACT),
283 .cmap_greyscale = 0,
284};
285
286static struct pxafb_mach_info generic_crt_800x600 = {
287 .modes = &generic_crt_800x600_mode,
288 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800289 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100290 .cmap_inverse = 0,
291 .cmap_static = 0,
292};
293
294static struct pxafb_mode_info generic_tft_320x240_mode = {
295 .pixclock = 134615,
296 .bpp = 16,
297 .xres = 320,
298 .yres = 240,
299 .hsync_len = 63,
300 .vsync_len = 7,
301 .left_margin = 75,
302 .upper_margin = 0,
303 .right_margin = 15,
304 .lower_margin = 15,
305 .sync = 0,
306 .cmap_greyscale = 0,
307};
308
309static struct pxafb_mach_info generic_tft_320x240 = {
310 .modes = &generic_tft_320x240_mode,
311 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800312 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100313 .cmap_inverse = 0,
314 .cmap_static = 0,
315};
316
317static struct pxafb_mode_info generic_stn_640x480_mode = {
318 .pixclock = 57692,
319 .bpp = 8,
320 .xres = 640,
321 .yres = 480,
322 .hsync_len = 4,
323 .vsync_len = 2,
324 .left_margin = 10,
325 .upper_margin = 5,
326 .right_margin = 10,
327 .lower_margin = 5,
328 .sync = (FB_SYNC_HOR_HIGH_ACT |
329 FB_SYNC_VERT_HIGH_ACT),
330 .cmap_greyscale = 0,
331};
332
333static struct pxafb_mach_info generic_stn_640x480 = {
334 .modes = &generic_stn_640x480_mode,
335 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800336 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100337 .cmap_inverse = 0,
338 .cmap_static = 0,
339};
340
Mike Rapoportda591932008-10-05 10:25:44 +0100341static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100342
Mike Rapoportda591932008-10-05 10:25:44 +0100343static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100344{
345 int disp_type = simple_strtol(str, NULL, 0);
346 switch (disp_type) {
347 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100348 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100349 break;
350 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100351 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100352 break;
353 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100354 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100355 break;
356 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100357 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100358 break;
359 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100360 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100361 break;
362 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100363 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100364 break;
365 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100366 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100367 break;
368 }
369 return 1;
370}
371
372/*
373 This should be done really early to get proper configuration for
374 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100375 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100376 has limitied line length for kernel command line, and also it will
377 break compatibitlty with proprietary releases already in field.
378*/
Mike Rapoportda591932008-10-05 10:25:44 +0100379__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100380
Mike Rapoportda591932008-10-05 10:25:44 +0100381static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100382{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800383 pxa_set_fb_info(NULL, cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100384}
385#else
Mike Rapoportda591932008-10-05 10:25:44 +0100386static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100387#endif
388
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100389#ifdef CONFIG_PM
390static unsigned long sleep_save_msc[10];
391
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200392static int cmx2xx_suspend(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100393{
Mike Rapoportda591932008-10-05 10:25:44 +0100394 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100395
396 /* save MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100397 sleep_save_msc[0] = __raw_readl(MSC0);
398 sleep_save_msc[1] = __raw_readl(MSC1);
399 sleep_save_msc[2] = __raw_readl(MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100400
401 /* setup power saving mode registers */
402 PCFR = 0x0;
403 PSLR = 0xff400000;
404 PMCR = 0x00000005;
405 PWER = 0x80000000;
406 PFER = 0x00000000;
407 PRER = 0x00000000;
408 PGSR0 = 0xC0018800;
409 PGSR1 = 0x004F0002;
410 PGSR2 = 0x6021C000;
411 PGSR3 = 0x00020000;
412
413 return 0;
414}
415
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200416static void cmx2xx_resume(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100417{
Mike Rapoportda591932008-10-05 10:25:44 +0100418 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100419
420 /* restore MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100421 __raw_writel(sleep_save_msc[0], MSC0);
422 __raw_writel(sleep_save_msc[1], MSC1);
423 __raw_writel(sleep_save_msc[2], MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100424}
425
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200426static struct syscore_ops cmx2xx_pm_syscore_ops = {
Mike Rapoportda591932008-10-05 10:25:44 +0100427 .resume = cmx2xx_resume,
428 .suspend = cmx2xx_suspend,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100429};
430
Mike Rapoportda591932008-10-05 10:25:44 +0100431static int __init cmx2xx_pm_init(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100432{
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200433 register_syscore_ops(&cmx2xx_pm_syscore_ops);
434
435 return 0;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100436}
437#else
Mike Rapoportda591932008-10-05 10:25:44 +0100438static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100439#endif
440
Mike Rapoport2f01a972008-06-17 12:29:58 +0100441#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100442static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100443{
444 pxa_set_ac97_info(NULL);
445}
446#else
Mike Rapoportda591932008-10-05 10:25:44 +0100447static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100448#endif
449
Mike Rapoportda591932008-10-05 10:25:44 +0100450static void __init cmx2xx_init(void)
451{
Russell Kingcc155c62009-11-09 13:34:08 +0800452 pxa_set_ffuart_info(NULL);
453 pxa_set_btuart_info(NULL);
454 pxa_set_stuart_info(NULL);
455
Mike Rapoportda591932008-10-05 10:25:44 +0100456 cmx2xx_pm_init();
457
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100458 if (cpu_is_pxa25x())
459 cmx255_init();
460 else
461 cmx270_init();
Mike Rapoportda591932008-10-05 10:25:44 +0100462
463 cmx2xx_init_dm9000();
464 cmx2xx_init_display();
465 cmx2xx_init_ac97();
466 cmx2xx_init_touchscreen();
467 cmx2xx_init_leds();
468}
469
470static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100471{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100472 if (cpu_is_pxa25x()) {
473 pxa25x_init_irq();
474 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
475 } else {
476 pxa27x_init_irq();
477 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
478 }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100479}
480
Mike Rapoport2f01a972008-06-17 12:29:58 +0100481#ifdef CONFIG_PCI
482/* Map PCI companion statically */
Mike Rapoportda591932008-10-05 10:25:44 +0100483static struct map_desc cmx2xx_io_desc[] __initdata = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100484 [0] = { /* PCI bridge */
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200485 .virtual = (unsigned long)CMX2XX_IT8152_VIRT,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100486 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
487 .length = SZ_64M,
488 .type = MT_DEVICE
489 },
490};
491
Mike Rapoportda591932008-10-05 10:25:44 +0100492static void __init cmx2xx_map_io(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100493{
Marek Vasut851982c2010-10-11 02:20:19 +0200494 if (cpu_is_pxa25x())
495 pxa25x_map_io();
496
497 if (cpu_is_pxa27x())
498 pxa27x_map_io();
499
Mike Rapoportda591932008-10-05 10:25:44 +0100500 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100501
Mike Rapoportda591932008-10-05 10:25:44 +0100502 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100503}
504#else
Mike Rapoportda591932008-10-05 10:25:44 +0100505static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100506{
Marek Vasut851982c2010-10-11 02:20:19 +0200507 if (cpu_is_pxa25x())
508 pxa25x_map_io();
509
510 if (cpu_is_pxa27x())
511 pxa27x_map_io();
Mike Rapoport2f01a972008-06-17 12:29:58 +0100512}
513#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100514
Mike Rapoportda591932008-10-05 10:25:44 +0100515MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400516 .atag_offset = 0x100,
Mike Rapoportda591932008-10-05 10:25:44 +0100517 .map_io = cmx2xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800518 .nr_irqs = CMX2XX_NR_IRQS,
Mike Rapoportda591932008-10-05 10:25:44 +0100519 .init_irq = cmx2xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800520 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
521 .handle_irq = pxa25x_handle_irq,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100522 .timer = &pxa_timer,
Mike Rapoportda591932008-10-05 10:25:44 +0100523 .init_machine = cmx2xx_init,
Nicolas Pitre805e88d2011-07-05 22:28:09 -0400524#ifdef CONFIG_PCI
525 .dma_zone_size = SZ_64M,
526#endif
Russell King271a74f2011-11-04 14:15:53 +0000527 .restart = pxa_restart,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100528MACHINE_END