blob: a17a91eb8e9a384aae47458ae9e84665aa8e60df [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>
Robert Jarzmika927ef82015-07-11 21:33:06 +020016#include <linux/regulator/machine.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010017
18#include <linux/dm9000.h>
Mike Rapoport2f01a972008-06-17 12:29:58 +010019#include <linux/leds.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010020
21#include <asm/mach/arch.h>
22#include <asm/mach-types.h>
23#include <asm/mach/map.h>
24
Eric Miaoca0e6872011-05-18 21:19:04 +080025#include <mach/pxa25x.h>
Arnd Bergmanne0347c52012-04-30 13:34:49 +000026#undef GPIO24_SSP1_SFRM
Eric Miaoca0e6872011-05-18 21:19:04 +080027#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020029#include <linux/platform_data/video-pxafb.h>
Marek Vasutad68bb92010-11-03 16:29:35 +010030#include <mach/smemc.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010031
32#include <asm/hardware/it8152.h>
33
34#include "generic.h"
Mike Rapoport7d76e3f2008-10-07 11:58:25 +010035#include "cm-x2xx-pci.h"
Mike Rapoport3696a8a2007-09-23 15:59:26 +010036
Mike Rapoporta7f3f032008-10-05 10:26:55 +010037extern void cmx255_init(void);
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010038extern void cmx270_init(void);
39
Haojian Zhuang6ac6b812010-08-20 15:23:59 +080040/* reserve IRQs for IT8152 */
41#define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
42
Mike Rapoport2f01a972008-06-17 12:29:58 +010043/* virtual addresses for statically mapped regions */
Arnd Bergmann97b09da2011-10-01 22:03:45 +020044#define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
Mike Rapoportda591932008-10-05 10:25:44 +010045#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010046
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010047/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010048#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010049#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
50
51/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010052#define CMX255_GPIO_RED (27)
53#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010054#define CMX270_GPIO_RED (93)
55#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010056
Mike Rapoport2f01a972008-06-17 12:29:58 +010057/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010058#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010059#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010060#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010061#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010062
Haojian Zhuang6384fda2011-10-10 14:21:08 +080063#define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
64#define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010065
66#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010067static struct resource cmx255_dm9000_resource[] = {
68 [0] = {
69 .start = CMX255_DM9000_PHYS_BASE,
70 .end = CMX255_DM9000_PHYS_BASE + 3,
71 .flags = IORESOURCE_MEM,
72 },
73 [1] = {
74 .start = CMX255_DM9000_PHYS_BASE + 4,
75 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
76 .flags = IORESOURCE_MEM,
77 },
78 [2] = {
79 .start = CMX255_ETHIRQ,
80 .end = CMX255_ETHIRQ,
81 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
82 }
83};
84
Mike Rapoport2f01a972008-06-17 12:29:58 +010085static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010086 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010087 .start = CMX270_DM9000_PHYS_BASE,
88 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010089 .flags = IORESOURCE_MEM,
90 },
91 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +010092 .start = CMX270_DM9000_PHYS_BASE + 8,
93 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010094 .flags = IORESOURCE_MEM,
95 },
96 [2] = {
97 .start = CMX270_ETHIRQ,
98 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +010099 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100100 }
101};
102
Mike Rapoport2f01a972008-06-17 12:29:58 +0100103static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200104 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100105};
106
Mike Rapoportda591932008-10-05 10:25:44 +0100107static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100108 .name = "dm9000",
109 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100110 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100111 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100112 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100113 }
114};
115
Mike Rapoportda591932008-10-05 10:25:44 +0100116static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100117{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100118 if (cpu_is_pxa25x())
119 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
120 else
121 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100122 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100123}
124#else
Mike Rapoportda591932008-10-05 10:25:44 +0100125static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100126#endif
127
128/* UCB1400 touchscreen controller */
129#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100130static struct platform_device cmx2xx_ts_device = {
Marek Vasut50f6bb02009-04-01 22:30:07 +0800131 .name = "ucb1400_core",
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100132 .id = -1,
133};
134
Mike Rapoportda591932008-10-05 10:25:44 +0100135static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100136{
Mike Rapoportda591932008-10-05 10:25:44 +0100137 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100138}
139#else
Mike Rapoportda591932008-10-05 10:25:44 +0100140static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100141#endif
142
Mike Rapoport2f01a972008-06-17 12:29:58 +0100143/* CM-X270 LEDs */
144#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100145static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100146 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100147 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100148 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100149 .active_low = 1,
150 },
151 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100152 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100153 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100154 .active_low = 1,
155 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100156};
157
Mike Rapoportda591932008-10-05 10:25:44 +0100158static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
159 .num_leds = ARRAY_SIZE(cmx2xx_leds),
160 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100161};
162
Mike Rapoportda591932008-10-05 10:25:44 +0100163static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100164 .name = "leds-gpio",
165 .id = -1,
166 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100167 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100168 },
169};
170
Mike Rapoportda591932008-10-05 10:25:44 +0100171static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100172{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100173 if (cpu_is_pxa25x()) {
174 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
175 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
176 } else {
177 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
178 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
179 }
Mike Rapoportda591932008-10-05 10:25:44 +0100180 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100181}
182#else
Mike Rapoportda591932008-10-05 10:25:44 +0100183static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100184#endif
185
Mike Rapoport2f01a972008-06-17 12:29:58 +0100186#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100187/*
188 Display definitions
189 keep these for backwards compatibility, although symbolic names (as
190 e.g. in lpd270.c) looks better
191*/
192#define MTYPE_STN320x240 0
193#define MTYPE_TFT640x480 1
194#define MTYPE_CRT640x480 2
195#define MTYPE_CRT800x600 3
196#define MTYPE_TFT320x240 6
197#define MTYPE_STN640x480 7
198
199static struct pxafb_mode_info generic_stn_320x240_mode = {
200 .pixclock = 76923,
201 .bpp = 8,
202 .xres = 320,
203 .yres = 240,
204 .hsync_len = 3,
205 .vsync_len = 2,
206 .left_margin = 3,
207 .upper_margin = 0,
208 .right_margin = 3,
209 .lower_margin = 0,
210 .sync = (FB_SYNC_HOR_HIGH_ACT |
211 FB_SYNC_VERT_HIGH_ACT),
212 .cmap_greyscale = 0,
213};
214
215static struct pxafb_mach_info generic_stn_320x240 = {
216 .modes = &generic_stn_320x240_mode,
217 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800218 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
219 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100220 .cmap_inverse = 0,
221 .cmap_static = 0,
222};
223
224static struct pxafb_mode_info generic_tft_640x480_mode = {
225 .pixclock = 38461,
226 .bpp = 8,
227 .xres = 640,
228 .yres = 480,
229 .hsync_len = 60,
230 .vsync_len = 2,
231 .left_margin = 70,
232 .upper_margin = 10,
233 .right_margin = 70,
234 .lower_margin = 5,
235 .sync = 0,
236 .cmap_greyscale = 0,
237};
238
239static struct pxafb_mach_info generic_tft_640x480 = {
240 .modes = &generic_tft_640x480_mode,
241 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800242 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
243 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100244 .cmap_inverse = 0,
245 .cmap_static = 0,
246};
247
248static struct pxafb_mode_info generic_crt_640x480_mode = {
249 .pixclock = 38461,
250 .bpp = 8,
251 .xres = 640,
252 .yres = 480,
253 .hsync_len = 63,
254 .vsync_len = 2,
255 .left_margin = 81,
256 .upper_margin = 33,
257 .right_margin = 16,
258 .lower_margin = 10,
259 .sync = (FB_SYNC_HOR_HIGH_ACT |
260 FB_SYNC_VERT_HIGH_ACT),
261 .cmap_greyscale = 0,
262};
263
264static struct pxafb_mach_info generic_crt_640x480 = {
265 .modes = &generic_crt_640x480_mode,
266 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800267 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100268 .cmap_inverse = 0,
269 .cmap_static = 0,
270};
271
272static struct pxafb_mode_info generic_crt_800x600_mode = {
273 .pixclock = 28846,
274 .bpp = 8,
275 .xres = 800,
276 .yres = 600,
277 .hsync_len = 63,
278 .vsync_len = 2,
279 .left_margin = 26,
280 .upper_margin = 21,
281 .right_margin = 26,
282 .lower_margin = 11,
283 .sync = (FB_SYNC_HOR_HIGH_ACT |
284 FB_SYNC_VERT_HIGH_ACT),
285 .cmap_greyscale = 0,
286};
287
288static struct pxafb_mach_info generic_crt_800x600 = {
289 .modes = &generic_crt_800x600_mode,
290 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800291 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100292 .cmap_inverse = 0,
293 .cmap_static = 0,
294};
295
296static struct pxafb_mode_info generic_tft_320x240_mode = {
297 .pixclock = 134615,
298 .bpp = 16,
299 .xres = 320,
300 .yres = 240,
301 .hsync_len = 63,
302 .vsync_len = 7,
303 .left_margin = 75,
304 .upper_margin = 0,
305 .right_margin = 15,
306 .lower_margin = 15,
307 .sync = 0,
308 .cmap_greyscale = 0,
309};
310
311static struct pxafb_mach_info generic_tft_320x240 = {
312 .modes = &generic_tft_320x240_mode,
313 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800314 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100315 .cmap_inverse = 0,
316 .cmap_static = 0,
317};
318
319static struct pxafb_mode_info generic_stn_640x480_mode = {
320 .pixclock = 57692,
321 .bpp = 8,
322 .xres = 640,
323 .yres = 480,
324 .hsync_len = 4,
325 .vsync_len = 2,
326 .left_margin = 10,
327 .upper_margin = 5,
328 .right_margin = 10,
329 .lower_margin = 5,
330 .sync = (FB_SYNC_HOR_HIGH_ACT |
331 FB_SYNC_VERT_HIGH_ACT),
332 .cmap_greyscale = 0,
333};
334
335static struct pxafb_mach_info generic_stn_640x480 = {
336 .modes = &generic_stn_640x480_mode,
337 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800338 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100339 .cmap_inverse = 0,
340 .cmap_static = 0,
341};
342
Mike Rapoportda591932008-10-05 10:25:44 +0100343static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100344
Mike Rapoportda591932008-10-05 10:25:44 +0100345static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100346{
347 int disp_type = simple_strtol(str, NULL, 0);
348 switch (disp_type) {
349 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100350 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100351 break;
352 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100353 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100354 break;
355 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100356 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100357 break;
358 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100359 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100360 break;
361 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100362 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100363 break;
364 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100365 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100366 break;
367 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100368 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100369 break;
370 }
371 return 1;
372}
373
374/*
375 This should be done really early to get proper configuration for
376 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100377 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100378 has limitied line length for kernel command line, and also it will
379 break compatibitlty with proprietary releases already in field.
380*/
Mike Rapoportda591932008-10-05 10:25:44 +0100381__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100382
Mike Rapoportda591932008-10-05 10:25:44 +0100383static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100384{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800385 pxa_set_fb_info(NULL, cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100386}
387#else
Mike Rapoportda591932008-10-05 10:25:44 +0100388static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100389#endif
390
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100391#ifdef CONFIG_PM
392static unsigned long sleep_save_msc[10];
393
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200394static int cmx2xx_suspend(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100395{
Mike Rapoportda591932008-10-05 10:25:44 +0100396 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100397
398 /* save MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100399 sleep_save_msc[0] = __raw_readl(MSC0);
400 sleep_save_msc[1] = __raw_readl(MSC1);
401 sleep_save_msc[2] = __raw_readl(MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100402
403 /* setup power saving mode registers */
404 PCFR = 0x0;
405 PSLR = 0xff400000;
406 PMCR = 0x00000005;
407 PWER = 0x80000000;
408 PFER = 0x00000000;
409 PRER = 0x00000000;
410 PGSR0 = 0xC0018800;
411 PGSR1 = 0x004F0002;
412 PGSR2 = 0x6021C000;
413 PGSR3 = 0x00020000;
414
415 return 0;
416}
417
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200418static void cmx2xx_resume(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100419{
Mike Rapoportda591932008-10-05 10:25:44 +0100420 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100421
422 /* restore MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100423 __raw_writel(sleep_save_msc[0], MSC0);
424 __raw_writel(sleep_save_msc[1], MSC1);
425 __raw_writel(sleep_save_msc[2], MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100426}
427
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200428static struct syscore_ops cmx2xx_pm_syscore_ops = {
Mike Rapoportda591932008-10-05 10:25:44 +0100429 .resume = cmx2xx_resume,
430 .suspend = cmx2xx_suspend,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100431};
432
Mike Rapoportda591932008-10-05 10:25:44 +0100433static int __init cmx2xx_pm_init(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100434{
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200435 register_syscore_ops(&cmx2xx_pm_syscore_ops);
436
437 return 0;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100438}
439#else
Mike Rapoportda591932008-10-05 10:25:44 +0100440static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100441#endif
442
Mike Rapoport2f01a972008-06-17 12:29:58 +0100443#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100444static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100445{
446 pxa_set_ac97_info(NULL);
447}
448#else
Mike Rapoportda591932008-10-05 10:25:44 +0100449static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100450#endif
451
Mike Rapoportda591932008-10-05 10:25:44 +0100452static void __init cmx2xx_init(void)
453{
Russell Kingcc155c62009-11-09 13:34:08 +0800454 pxa_set_ffuart_info(NULL);
455 pxa_set_btuart_info(NULL);
456 pxa_set_stuart_info(NULL);
457
Mike Rapoportda591932008-10-05 10:25:44 +0100458 cmx2xx_pm_init();
459
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100460 if (cpu_is_pxa25x())
461 cmx255_init();
462 else
463 cmx270_init();
Mike Rapoportda591932008-10-05 10:25:44 +0100464
465 cmx2xx_init_dm9000();
466 cmx2xx_init_display();
467 cmx2xx_init_ac97();
468 cmx2xx_init_touchscreen();
469 cmx2xx_init_leds();
Robert Jarzmika927ef82015-07-11 21:33:06 +0200470
471 regulator_has_full_constraints();
Mike Rapoportda591932008-10-05 10:25:44 +0100472}
473
474static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100475{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100476 if (cpu_is_pxa25x()) {
477 pxa25x_init_irq();
478 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
479 } else {
480 pxa27x_init_irq();
481 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
482 }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100483}
484
Mike Rapoport2f01a972008-06-17 12:29:58 +0100485#ifdef CONFIG_PCI
486/* Map PCI companion statically */
Mike Rapoportda591932008-10-05 10:25:44 +0100487static struct map_desc cmx2xx_io_desc[] __initdata = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100488 [0] = { /* PCI bridge */
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200489 .virtual = (unsigned long)CMX2XX_IT8152_VIRT,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100490 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
491 .length = SZ_64M,
492 .type = MT_DEVICE
493 },
494};
495
Mike Rapoportda591932008-10-05 10:25:44 +0100496static void __init cmx2xx_map_io(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100497{
Marek Vasut851982c2010-10-11 02:20:19 +0200498 if (cpu_is_pxa25x())
499 pxa25x_map_io();
500
501 if (cpu_is_pxa27x())
502 pxa27x_map_io();
503
Mike Rapoportda591932008-10-05 10:25:44 +0100504 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100505
Mike Rapoportda591932008-10-05 10:25:44 +0100506 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100507}
508#else
Mike Rapoportda591932008-10-05 10:25:44 +0100509static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100510{
Marek Vasut851982c2010-10-11 02:20:19 +0200511 if (cpu_is_pxa25x())
512 pxa25x_map_io();
513
514 if (cpu_is_pxa27x())
515 pxa27x_map_io();
Mike Rapoport2f01a972008-06-17 12:29:58 +0100516}
517#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100518
Mike Rapoportda591932008-10-05 10:25:44 +0100519MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400520 .atag_offset = 0x100,
Mike Rapoportda591932008-10-05 10:25:44 +0100521 .map_io = cmx2xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800522 .nr_irqs = CMX2XX_NR_IRQS,
Mike Rapoportda591932008-10-05 10:25:44 +0100523 .init_irq = cmx2xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800524 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
525 .handle_irq = pxa25x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700526 .init_time = pxa_timer_init,
Mike Rapoportda591932008-10-05 10:25:44 +0100527 .init_machine = cmx2xx_init,
Nicolas Pitre805e88d2011-07-05 22:28:09 -0400528#ifdef CONFIG_PCI
529 .dma_zone_size = SZ_64M,
530#endif
Russell King271a74f2011-11-04 14:15:53 +0000531 .restart = pxa_restart,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100532MACHINE_END