blob: bb99f59a36d880f8879824af44b67c924078b283 [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 Rapoport4adc5fb2008-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>
Arnd Bergmanne0347c52012-04-30 13:34:49 +000025#undef GPIO24_SSP1_SFRM
Eric Miaoca0e6872011-05-18 21:19:04 +080026#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020028#include <linux/platform_data/video-pxafb.h>
Marek Vasutad68bb92010-11-03 16:29:35 +010029#include <mach/smemc.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010030
31#include <asm/hardware/it8152.h>
32
33#include "generic.h"
Mike Rapoport7d76e3f2008-10-07 11:58:25 +010034#include "cm-x2xx-pci.h"
Mike Rapoport3696a8a2007-09-23 15:59:26 +010035
Mike Rapoporta7f3f032008-10-05 10:26:55 +010036extern void cmx255_init(void);
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010037extern void cmx270_init(void);
38
Haojian Zhuang6ac6b812010-08-20 15:23:59 +080039/* reserve IRQs for IT8152 */
40#define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
41
Mike Rapoport2f01a972008-06-17 12:29:58 +010042/* virtual addresses for statically mapped regions */
Arnd Bergmann97b09da2011-10-01 22:03:45 +020043#define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
Mike Rapoportda591932008-10-05 10:25:44 +010044#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010045
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010046/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010047#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010048#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
49
50/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010051#define CMX255_GPIO_RED (27)
52#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010053#define CMX270_GPIO_RED (93)
54#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010055
Mike Rapoport2f01a972008-06-17 12:29:58 +010056/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010057#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010058#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010059#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010060#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010061
Haojian Zhuang6384fda2011-10-10 14:21:08 +080062#define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
63#define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010064
65#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010066static struct resource cmx255_dm9000_resource[] = {
67 [0] = {
68 .start = CMX255_DM9000_PHYS_BASE,
69 .end = CMX255_DM9000_PHYS_BASE + 3,
70 .flags = IORESOURCE_MEM,
71 },
72 [1] = {
73 .start = CMX255_DM9000_PHYS_BASE + 4,
74 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
75 .flags = IORESOURCE_MEM,
76 },
77 [2] = {
78 .start = CMX255_ETHIRQ,
79 .end = CMX255_ETHIRQ,
80 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
81 }
82};
83
Mike Rapoport2f01a972008-06-17 12:29:58 +010084static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010085 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010086 .start = CMX270_DM9000_PHYS_BASE,
87 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010088 .flags = IORESOURCE_MEM,
89 },
90 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +010091 .start = CMX270_DM9000_PHYS_BASE + 8,
92 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010093 .flags = IORESOURCE_MEM,
94 },
95 [2] = {
96 .start = CMX270_ETHIRQ,
97 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +010098 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010099 }
100};
101
Mike Rapoport2f01a972008-06-17 12:29:58 +0100102static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200103 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100104};
105
Mike Rapoportda591932008-10-05 10:25:44 +0100106static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100107 .name = "dm9000",
108 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100109 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100110 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100111 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100112 }
113};
114
Mike Rapoportda591932008-10-05 10:25:44 +0100115static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100116{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100117 if (cpu_is_pxa25x())
118 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
119 else
120 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100121 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100122}
123#else
Mike Rapoportda591932008-10-05 10:25:44 +0100124static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100125#endif
126
127/* UCB1400 touchscreen controller */
128#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100129static struct platform_device cmx2xx_ts_device = {
Marek Vasut50f6bb02009-04-01 22:30:07 +0800130 .name = "ucb1400_core",
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100131 .id = -1,
132};
133
Mike Rapoportda591932008-10-05 10:25:44 +0100134static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100135{
Mike Rapoportda591932008-10-05 10:25:44 +0100136 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100137}
138#else
Mike Rapoportda591932008-10-05 10:25:44 +0100139static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100140#endif
141
Mike Rapoport2f01a972008-06-17 12:29:58 +0100142/* CM-X270 LEDs */
143#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100144static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100145 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100146 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100147 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100148 .active_low = 1,
149 },
150 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100151 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100152 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100153 .active_low = 1,
154 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100155};
156
Mike Rapoportda591932008-10-05 10:25:44 +0100157static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
158 .num_leds = ARRAY_SIZE(cmx2xx_leds),
159 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100160};
161
Mike Rapoportda591932008-10-05 10:25:44 +0100162static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100163 .name = "leds-gpio",
164 .id = -1,
165 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100166 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100167 },
168};
169
Mike Rapoportda591932008-10-05 10:25:44 +0100170static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100171{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100172 if (cpu_is_pxa25x()) {
173 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
174 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
175 } else {
176 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
177 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
178 }
Mike Rapoportda591932008-10-05 10:25:44 +0100179 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100180}
181#else
Mike Rapoportda591932008-10-05 10:25:44 +0100182static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100183#endif
184
Mike Rapoport2f01a972008-06-17 12:29:58 +0100185#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100186/*
187 Display definitions
188 keep these for backwards compatibility, although symbolic names (as
189 e.g. in lpd270.c) looks better
190*/
191#define MTYPE_STN320x240 0
192#define MTYPE_TFT640x480 1
193#define MTYPE_CRT640x480 2
194#define MTYPE_CRT800x600 3
195#define MTYPE_TFT320x240 6
196#define MTYPE_STN640x480 7
197
198static struct pxafb_mode_info generic_stn_320x240_mode = {
199 .pixclock = 76923,
200 .bpp = 8,
201 .xres = 320,
202 .yres = 240,
203 .hsync_len = 3,
204 .vsync_len = 2,
205 .left_margin = 3,
206 .upper_margin = 0,
207 .right_margin = 3,
208 .lower_margin = 0,
209 .sync = (FB_SYNC_HOR_HIGH_ACT |
210 FB_SYNC_VERT_HIGH_ACT),
211 .cmap_greyscale = 0,
212};
213
214static struct pxafb_mach_info generic_stn_320x240 = {
215 .modes = &generic_stn_320x240_mode,
216 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800217 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
218 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100219 .cmap_inverse = 0,
220 .cmap_static = 0,
221};
222
223static struct pxafb_mode_info generic_tft_640x480_mode = {
224 .pixclock = 38461,
225 .bpp = 8,
226 .xres = 640,
227 .yres = 480,
228 .hsync_len = 60,
229 .vsync_len = 2,
230 .left_margin = 70,
231 .upper_margin = 10,
232 .right_margin = 70,
233 .lower_margin = 5,
234 .sync = 0,
235 .cmap_greyscale = 0,
236};
237
238static struct pxafb_mach_info generic_tft_640x480 = {
239 .modes = &generic_tft_640x480_mode,
240 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800241 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
242 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100243 .cmap_inverse = 0,
244 .cmap_static = 0,
245};
246
247static struct pxafb_mode_info generic_crt_640x480_mode = {
248 .pixclock = 38461,
249 .bpp = 8,
250 .xres = 640,
251 .yres = 480,
252 .hsync_len = 63,
253 .vsync_len = 2,
254 .left_margin = 81,
255 .upper_margin = 33,
256 .right_margin = 16,
257 .lower_margin = 10,
258 .sync = (FB_SYNC_HOR_HIGH_ACT |
259 FB_SYNC_VERT_HIGH_ACT),
260 .cmap_greyscale = 0,
261};
262
263static struct pxafb_mach_info generic_crt_640x480 = {
264 .modes = &generic_crt_640x480_mode,
265 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800266 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100267 .cmap_inverse = 0,
268 .cmap_static = 0,
269};
270
271static struct pxafb_mode_info generic_crt_800x600_mode = {
272 .pixclock = 28846,
273 .bpp = 8,
274 .xres = 800,
275 .yres = 600,
276 .hsync_len = 63,
277 .vsync_len = 2,
278 .left_margin = 26,
279 .upper_margin = 21,
280 .right_margin = 26,
281 .lower_margin = 11,
282 .sync = (FB_SYNC_HOR_HIGH_ACT |
283 FB_SYNC_VERT_HIGH_ACT),
284 .cmap_greyscale = 0,
285};
286
287static struct pxafb_mach_info generic_crt_800x600 = {
288 .modes = &generic_crt_800x600_mode,
289 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800290 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100291 .cmap_inverse = 0,
292 .cmap_static = 0,
293};
294
295static struct pxafb_mode_info generic_tft_320x240_mode = {
296 .pixclock = 134615,
297 .bpp = 16,
298 .xres = 320,
299 .yres = 240,
300 .hsync_len = 63,
301 .vsync_len = 7,
302 .left_margin = 75,
303 .upper_margin = 0,
304 .right_margin = 15,
305 .lower_margin = 15,
306 .sync = 0,
307 .cmap_greyscale = 0,
308};
309
310static struct pxafb_mach_info generic_tft_320x240 = {
311 .modes = &generic_tft_320x240_mode,
312 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800313 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100314 .cmap_inverse = 0,
315 .cmap_static = 0,
316};
317
318static struct pxafb_mode_info generic_stn_640x480_mode = {
319 .pixclock = 57692,
320 .bpp = 8,
321 .xres = 640,
322 .yres = 480,
323 .hsync_len = 4,
324 .vsync_len = 2,
325 .left_margin = 10,
326 .upper_margin = 5,
327 .right_margin = 10,
328 .lower_margin = 5,
329 .sync = (FB_SYNC_HOR_HIGH_ACT |
330 FB_SYNC_VERT_HIGH_ACT),
331 .cmap_greyscale = 0,
332};
333
334static struct pxafb_mach_info generic_stn_640x480 = {
335 .modes = &generic_stn_640x480_mode,
336 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800337 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100338 .cmap_inverse = 0,
339 .cmap_static = 0,
340};
341
Mike Rapoportda591932008-10-05 10:25:44 +0100342static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100343
Mike Rapoportda591932008-10-05 10:25:44 +0100344static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100345{
346 int disp_type = simple_strtol(str, NULL, 0);
347 switch (disp_type) {
348 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100349 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100350 break;
351 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100352 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100353 break;
354 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100355 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100356 break;
357 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100358 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100359 break;
360 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100361 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100362 break;
363 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100364 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100365 break;
366 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100367 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100368 break;
369 }
370 return 1;
371}
372
373/*
374 This should be done really early to get proper configuration for
375 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100376 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100377 has limitied line length for kernel command line, and also it will
378 break compatibitlty with proprietary releases already in field.
379*/
Mike Rapoportda591932008-10-05 10:25:44 +0100380__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100381
Mike Rapoportda591932008-10-05 10:25:44 +0100382static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100383{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800384 pxa_set_fb_info(NULL, cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100385}
386#else
Mike Rapoportda591932008-10-05 10:25:44 +0100387static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100388#endif
389
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100390#ifdef CONFIG_PM
391static unsigned long sleep_save_msc[10];
392
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200393static int cmx2xx_suspend(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100394{
Mike Rapoportda591932008-10-05 10:25:44 +0100395 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100396
397 /* save MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100398 sleep_save_msc[0] = __raw_readl(MSC0);
399 sleep_save_msc[1] = __raw_readl(MSC1);
400 sleep_save_msc[2] = __raw_readl(MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100401
402 /* setup power saving mode registers */
403 PCFR = 0x0;
404 PSLR = 0xff400000;
405 PMCR = 0x00000005;
406 PWER = 0x80000000;
407 PFER = 0x00000000;
408 PRER = 0x00000000;
409 PGSR0 = 0xC0018800;
410 PGSR1 = 0x004F0002;
411 PGSR2 = 0x6021C000;
412 PGSR3 = 0x00020000;
413
414 return 0;
415}
416
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200417static void cmx2xx_resume(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100418{
Mike Rapoportda591932008-10-05 10:25:44 +0100419 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100420
421 /* restore MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100422 __raw_writel(sleep_save_msc[0], MSC0);
423 __raw_writel(sleep_save_msc[1], MSC1);
424 __raw_writel(sleep_save_msc[2], MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100425}
426
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200427static struct syscore_ops cmx2xx_pm_syscore_ops = {
Mike Rapoportda591932008-10-05 10:25:44 +0100428 .resume = cmx2xx_resume,
429 .suspend = cmx2xx_suspend,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100430};
431
Mike Rapoportda591932008-10-05 10:25:44 +0100432static int __init cmx2xx_pm_init(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100433{
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200434 register_syscore_ops(&cmx2xx_pm_syscore_ops);
435
436 return 0;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100437}
438#else
Mike Rapoportda591932008-10-05 10:25:44 +0100439static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100440#endif
441
Mike Rapoport2f01a972008-06-17 12:29:58 +0100442#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100443static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100444{
445 pxa_set_ac97_info(NULL);
446}
447#else
Mike Rapoportda591932008-10-05 10:25:44 +0100448static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100449#endif
450
Mike Rapoportda591932008-10-05 10:25:44 +0100451static void __init cmx2xx_init(void)
452{
Russell Kingcc155c62009-11-09 13:34:08 +0800453 pxa_set_ffuart_info(NULL);
454 pxa_set_btuart_info(NULL);
455 pxa_set_stuart_info(NULL);
456
Mike Rapoportda591932008-10-05 10:25:44 +0100457 cmx2xx_pm_init();
458
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100459 if (cpu_is_pxa25x())
460 cmx255_init();
461 else
462 cmx270_init();
Mike Rapoportda591932008-10-05 10:25:44 +0100463
464 cmx2xx_init_dm9000();
465 cmx2xx_init_display();
466 cmx2xx_init_ac97();
467 cmx2xx_init_touchscreen();
468 cmx2xx_init_leds();
469}
470
471static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100472{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100473 if (cpu_is_pxa25x()) {
474 pxa25x_init_irq();
475 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
476 } else {
477 pxa27x_init_irq();
478 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
479 }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100480}
481
Mike Rapoport2f01a972008-06-17 12:29:58 +0100482#ifdef CONFIG_PCI
483/* Map PCI companion statically */
Mike Rapoportda591932008-10-05 10:25:44 +0100484static struct map_desc cmx2xx_io_desc[] __initdata = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100485 [0] = { /* PCI bridge */
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200486 .virtual = (unsigned long)CMX2XX_IT8152_VIRT,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100487 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
488 .length = SZ_64M,
489 .type = MT_DEVICE
490 },
491};
492
Mike Rapoportda591932008-10-05 10:25:44 +0100493static void __init cmx2xx_map_io(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100494{
Marek Vasut851982c2010-10-11 02:20:19 +0200495 if (cpu_is_pxa25x())
496 pxa25x_map_io();
497
498 if (cpu_is_pxa27x())
499 pxa27x_map_io();
500
Mike Rapoportda591932008-10-05 10:25:44 +0100501 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100502
Mike Rapoportda591932008-10-05 10:25:44 +0100503 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100504}
505#else
Mike Rapoportda591932008-10-05 10:25:44 +0100506static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100507{
Marek Vasut851982c2010-10-11 02:20:19 +0200508 if (cpu_is_pxa25x())
509 pxa25x_map_io();
510
511 if (cpu_is_pxa27x())
512 pxa27x_map_io();
Mike Rapoport2f01a972008-06-17 12:29:58 +0100513}
514#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100515
Mike Rapoportda591932008-10-05 10:25:44 +0100516MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400517 .atag_offset = 0x100,
Mike Rapoportda591932008-10-05 10:25:44 +0100518 .map_io = cmx2xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800519 .nr_irqs = CMX2XX_NR_IRQS,
Mike Rapoportda591932008-10-05 10:25:44 +0100520 .init_irq = cmx2xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800521 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
522 .handle_irq = pxa25x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700523 .init_time = pxa_timer_init,
Mike Rapoportda591932008-10-05 10:25:44 +0100524 .init_machine = cmx2xx_init,
Nicolas Pitre805e88d2011-07-05 22:28:09 -0400525#ifdef CONFIG_PCI
526 .dma_zone_size = SZ_64M,
527#endif
Russell King271a74f2011-11-04 14:15:53 +0000528 .restart = pxa_restart,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100529MACHINE_END