blob: 7202022ee243e5702e092d41c5f4291b22de34f7 [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
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010025#include "pxa25x.h"
Arnd Bergmanne0347c52012-04-30 13:34:49 +000026#undef GPIO24_SSP1_SFRM
Arnd Bergmannf39c42f2015-12-08 23:42:07 +010027#undef GPIO86_GPIO
28#undef GPIO87_GPIO
29#undef GPIO88_GPIO
30#undef GPIO89_GPIO
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010031#include "pxa27x.h"
Arnd Bergmannf39c42f2015-12-08 23:42:07 +010032#undef GPIO24_SSP1_SFRM
33#undef GPIO86_GPIO
34#undef GPIO87_GPIO
35#undef GPIO88_GPIO
36#undef GPIO89_GPIO
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020038#include <linux/platform_data/video-pxafb.h>
Marek Vasutad68bb92010-11-03 16:29:35 +010039#include <mach/smemc.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010040
41#include <asm/hardware/it8152.h>
42
43#include "generic.h"
Mike Rapoport7d76e3f2008-10-07 11:58:25 +010044#include "cm-x2xx-pci.h"
Mike Rapoport3696a8a2007-09-23 15:59:26 +010045
Mike Rapoporta7f3f032008-10-05 10:26:55 +010046extern void cmx255_init(void);
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010047extern void cmx270_init(void);
48
Haojian Zhuang6ac6b812010-08-20 15:23:59 +080049/* reserve IRQs for IT8152 */
50#define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
51
Mike Rapoport2f01a972008-06-17 12:29:58 +010052/* virtual addresses for statically mapped regions */
Arnd Bergmann97b09da2011-10-01 22:03:45 +020053#define CMX2XX_VIRT_BASE (void __iomem *)(0xe8000000)
Mike Rapoportda591932008-10-05 10:25:44 +010054#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010055
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010056/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010057#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010058#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
59
60/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010061#define CMX255_GPIO_RED (27)
62#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010063#define CMX270_GPIO_RED (93)
64#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010065
Mike Rapoport2f01a972008-06-17 12:29:58 +010066/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010067#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010068#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010069#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010070#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010071
Haojian Zhuang6384fda2011-10-10 14:21:08 +080072#define CMX255_ETHIRQ PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
73#define CMX270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010074
75#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010076static struct resource cmx255_dm9000_resource[] = {
77 [0] = {
78 .start = CMX255_DM9000_PHYS_BASE,
79 .end = CMX255_DM9000_PHYS_BASE + 3,
80 .flags = IORESOURCE_MEM,
81 },
82 [1] = {
83 .start = CMX255_DM9000_PHYS_BASE + 4,
84 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
85 .flags = IORESOURCE_MEM,
86 },
87 [2] = {
88 .start = CMX255_ETHIRQ,
89 .end = CMX255_ETHIRQ,
90 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
91 }
92};
93
Mike Rapoport2f01a972008-06-17 12:29:58 +010094static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010095 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010096 .start = CMX270_DM9000_PHYS_BASE,
97 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010098 .flags = IORESOURCE_MEM,
99 },
100 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100101 .start = CMX270_DM9000_PHYS_BASE + 8,
102 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100103 .flags = IORESOURCE_MEM,
104 },
105 [2] = {
106 .start = CMX270_ETHIRQ,
107 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100108 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100109 }
110};
111
Mike Rapoport2f01a972008-06-17 12:29:58 +0100112static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200113 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100114};
115
Mike Rapoportda591932008-10-05 10:25:44 +0100116static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100117 .name = "dm9000",
118 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100119 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100120 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100121 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100122 }
123};
124
Mike Rapoportda591932008-10-05 10:25:44 +0100125static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100126{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100127 if (cpu_is_pxa25x())
128 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
129 else
130 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100131 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100132}
133#else
Mike Rapoportda591932008-10-05 10:25:44 +0100134static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100135#endif
136
137/* UCB1400 touchscreen controller */
138#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100139static struct platform_device cmx2xx_ts_device = {
Marek Vasut50f6bb02009-04-01 22:30:07 +0800140 .name = "ucb1400_core",
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100141 .id = -1,
142};
143
Mike Rapoportda591932008-10-05 10:25:44 +0100144static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100145{
Mike Rapoportda591932008-10-05 10:25:44 +0100146 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100147}
148#else
Mike Rapoportda591932008-10-05 10:25:44 +0100149static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100150#endif
151
Mike Rapoport2f01a972008-06-17 12:29:58 +0100152/* CM-X270 LEDs */
153#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100154static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100155 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100156 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100157 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100158 .active_low = 1,
159 },
160 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100161 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100162 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100163 .active_low = 1,
164 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100165};
166
Mike Rapoportda591932008-10-05 10:25:44 +0100167static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
168 .num_leds = ARRAY_SIZE(cmx2xx_leds),
169 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100170};
171
Mike Rapoportda591932008-10-05 10:25:44 +0100172static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100173 .name = "leds-gpio",
174 .id = -1,
175 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100176 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100177 },
178};
179
Mike Rapoportda591932008-10-05 10:25:44 +0100180static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100181{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100182 if (cpu_is_pxa25x()) {
183 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
184 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
185 } else {
186 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
187 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
188 }
Mike Rapoportda591932008-10-05 10:25:44 +0100189 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100190}
191#else
Mike Rapoportda591932008-10-05 10:25:44 +0100192static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100193#endif
194
Mike Rapoport2f01a972008-06-17 12:29:58 +0100195#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100196/*
197 Display definitions
198 keep these for backwards compatibility, although symbolic names (as
199 e.g. in lpd270.c) looks better
200*/
201#define MTYPE_STN320x240 0
202#define MTYPE_TFT640x480 1
203#define MTYPE_CRT640x480 2
204#define MTYPE_CRT800x600 3
205#define MTYPE_TFT320x240 6
206#define MTYPE_STN640x480 7
207
208static struct pxafb_mode_info generic_stn_320x240_mode = {
209 .pixclock = 76923,
210 .bpp = 8,
211 .xres = 320,
212 .yres = 240,
213 .hsync_len = 3,
214 .vsync_len = 2,
215 .left_margin = 3,
216 .upper_margin = 0,
217 .right_margin = 3,
218 .lower_margin = 0,
219 .sync = (FB_SYNC_HOR_HIGH_ACT |
220 FB_SYNC_VERT_HIGH_ACT),
221 .cmap_greyscale = 0,
222};
223
224static struct pxafb_mach_info generic_stn_320x240 = {
225 .modes = &generic_stn_320x240_mode,
226 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800227 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
228 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100229 .cmap_inverse = 0,
230 .cmap_static = 0,
231};
232
233static struct pxafb_mode_info generic_tft_640x480_mode = {
234 .pixclock = 38461,
235 .bpp = 8,
236 .xres = 640,
237 .yres = 480,
238 .hsync_len = 60,
239 .vsync_len = 2,
240 .left_margin = 70,
241 .upper_margin = 10,
242 .right_margin = 70,
243 .lower_margin = 5,
244 .sync = 0,
245 .cmap_greyscale = 0,
246};
247
248static struct pxafb_mach_info generic_tft_640x480 = {
249 .modes = &generic_tft_640x480_mode,
250 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800251 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
252 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100253 .cmap_inverse = 0,
254 .cmap_static = 0,
255};
256
257static struct pxafb_mode_info generic_crt_640x480_mode = {
258 .pixclock = 38461,
259 .bpp = 8,
260 .xres = 640,
261 .yres = 480,
262 .hsync_len = 63,
263 .vsync_len = 2,
264 .left_margin = 81,
265 .upper_margin = 33,
266 .right_margin = 16,
267 .lower_margin = 10,
268 .sync = (FB_SYNC_HOR_HIGH_ACT |
269 FB_SYNC_VERT_HIGH_ACT),
270 .cmap_greyscale = 0,
271};
272
273static struct pxafb_mach_info generic_crt_640x480 = {
274 .modes = &generic_crt_640x480_mode,
275 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800276 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100277 .cmap_inverse = 0,
278 .cmap_static = 0,
279};
280
281static struct pxafb_mode_info generic_crt_800x600_mode = {
282 .pixclock = 28846,
283 .bpp = 8,
284 .xres = 800,
285 .yres = 600,
286 .hsync_len = 63,
287 .vsync_len = 2,
288 .left_margin = 26,
289 .upper_margin = 21,
290 .right_margin = 26,
291 .lower_margin = 11,
292 .sync = (FB_SYNC_HOR_HIGH_ACT |
293 FB_SYNC_VERT_HIGH_ACT),
294 .cmap_greyscale = 0,
295};
296
297static struct pxafb_mach_info generic_crt_800x600 = {
298 .modes = &generic_crt_800x600_mode,
299 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800300 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100301 .cmap_inverse = 0,
302 .cmap_static = 0,
303};
304
305static struct pxafb_mode_info generic_tft_320x240_mode = {
306 .pixclock = 134615,
307 .bpp = 16,
308 .xres = 320,
309 .yres = 240,
310 .hsync_len = 63,
311 .vsync_len = 7,
312 .left_margin = 75,
313 .upper_margin = 0,
314 .right_margin = 15,
315 .lower_margin = 15,
316 .sync = 0,
317 .cmap_greyscale = 0,
318};
319
320static struct pxafb_mach_info generic_tft_320x240 = {
321 .modes = &generic_tft_320x240_mode,
322 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800323 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100324 .cmap_inverse = 0,
325 .cmap_static = 0,
326};
327
328static struct pxafb_mode_info generic_stn_640x480_mode = {
329 .pixclock = 57692,
330 .bpp = 8,
331 .xres = 640,
332 .yres = 480,
333 .hsync_len = 4,
334 .vsync_len = 2,
335 .left_margin = 10,
336 .upper_margin = 5,
337 .right_margin = 10,
338 .lower_margin = 5,
339 .sync = (FB_SYNC_HOR_HIGH_ACT |
340 FB_SYNC_VERT_HIGH_ACT),
341 .cmap_greyscale = 0,
342};
343
344static struct pxafb_mach_info generic_stn_640x480 = {
345 .modes = &generic_stn_640x480_mode,
346 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800347 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100348 .cmap_inverse = 0,
349 .cmap_static = 0,
350};
351
Mike Rapoportda591932008-10-05 10:25:44 +0100352static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100353
Mike Rapoportda591932008-10-05 10:25:44 +0100354static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100355{
356 int disp_type = simple_strtol(str, NULL, 0);
357 switch (disp_type) {
358 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100359 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100360 break;
361 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100362 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100363 break;
364 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100365 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100366 break;
367 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100368 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100369 break;
370 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100371 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100372 break;
373 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100374 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100375 break;
376 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100377 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100378 break;
379 }
380 return 1;
381}
382
383/*
384 This should be done really early to get proper configuration for
385 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100386 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100387 has limitied line length for kernel command line, and also it will
388 break compatibitlty with proprietary releases already in field.
389*/
Mike Rapoportda591932008-10-05 10:25:44 +0100390__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100391
Mike Rapoportda591932008-10-05 10:25:44 +0100392static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100393{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800394 pxa_set_fb_info(NULL, cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100395}
396#else
Mike Rapoportda591932008-10-05 10:25:44 +0100397static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100398#endif
399
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100400#ifdef CONFIG_PM
401static unsigned long sleep_save_msc[10];
402
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200403static int cmx2xx_suspend(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100404{
Mike Rapoportda591932008-10-05 10:25:44 +0100405 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100406
407 /* save MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100408 sleep_save_msc[0] = __raw_readl(MSC0);
409 sleep_save_msc[1] = __raw_readl(MSC1);
410 sleep_save_msc[2] = __raw_readl(MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100411
412 /* setup power saving mode registers */
413 PCFR = 0x0;
414 PSLR = 0xff400000;
415 PMCR = 0x00000005;
416 PWER = 0x80000000;
417 PFER = 0x00000000;
418 PRER = 0x00000000;
419 PGSR0 = 0xC0018800;
420 PGSR1 = 0x004F0002;
421 PGSR2 = 0x6021C000;
422 PGSR3 = 0x00020000;
423
424 return 0;
425}
426
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200427static void cmx2xx_resume(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100428{
Mike Rapoportda591932008-10-05 10:25:44 +0100429 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100430
431 /* restore MSC registers */
Marek Vasutad68bb92010-11-03 16:29:35 +0100432 __raw_writel(sleep_save_msc[0], MSC0);
433 __raw_writel(sleep_save_msc[1], MSC1);
434 __raw_writel(sleep_save_msc[2], MSC2);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100435}
436
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200437static struct syscore_ops cmx2xx_pm_syscore_ops = {
Mike Rapoportda591932008-10-05 10:25:44 +0100438 .resume = cmx2xx_resume,
439 .suspend = cmx2xx_suspend,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100440};
441
Mike Rapoportda591932008-10-05 10:25:44 +0100442static int __init cmx2xx_pm_init(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100443{
Rafael J. Wysocki2eaa03b2011-04-22 22:03:11 +0200444 register_syscore_ops(&cmx2xx_pm_syscore_ops);
445
446 return 0;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100447}
448#else
Mike Rapoportda591932008-10-05 10:25:44 +0100449static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100450#endif
451
Mike Rapoport2f01a972008-06-17 12:29:58 +0100452#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100453static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100454{
455 pxa_set_ac97_info(NULL);
456}
457#else
Mike Rapoportda591932008-10-05 10:25:44 +0100458static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100459#endif
460
Mike Rapoportda591932008-10-05 10:25:44 +0100461static void __init cmx2xx_init(void)
462{
Russell Kingcc155c62009-11-09 13:34:08 +0800463 pxa_set_ffuart_info(NULL);
464 pxa_set_btuart_info(NULL);
465 pxa_set_stuart_info(NULL);
466
Mike Rapoportda591932008-10-05 10:25:44 +0100467 cmx2xx_pm_init();
468
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100469 if (cpu_is_pxa25x())
470 cmx255_init();
471 else
472 cmx270_init();
Mike Rapoportda591932008-10-05 10:25:44 +0100473
474 cmx2xx_init_dm9000();
475 cmx2xx_init_display();
476 cmx2xx_init_ac97();
477 cmx2xx_init_touchscreen();
478 cmx2xx_init_leds();
Robert Jarzmika927ef82015-07-11 21:33:06 +0200479
480 regulator_has_full_constraints();
Mike Rapoportda591932008-10-05 10:25:44 +0100481}
482
483static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100484{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100485 if (cpu_is_pxa25x()) {
486 pxa25x_init_irq();
487 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
488 } else {
489 pxa27x_init_irq();
490 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
491 }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100492}
493
Mike Rapoport2f01a972008-06-17 12:29:58 +0100494#ifdef CONFIG_PCI
495/* Map PCI companion statically */
Mike Rapoportda591932008-10-05 10:25:44 +0100496static struct map_desc cmx2xx_io_desc[] __initdata = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100497 [0] = { /* PCI bridge */
Arnd Bergmann97b09da2011-10-01 22:03:45 +0200498 .virtual = (unsigned long)CMX2XX_IT8152_VIRT,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100499 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
500 .length = SZ_64M,
501 .type = MT_DEVICE
502 },
503};
504
Mike Rapoportda591932008-10-05 10:25:44 +0100505static void __init cmx2xx_map_io(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +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();
512
Mike Rapoportda591932008-10-05 10:25:44 +0100513 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100514
Mike Rapoportda591932008-10-05 10:25:44 +0100515 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100516}
517#else
Mike Rapoportda591932008-10-05 10:25:44 +0100518static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100519{
Marek Vasut851982c2010-10-11 02:20:19 +0200520 if (cpu_is_pxa25x())
521 pxa25x_map_io();
522
523 if (cpu_is_pxa27x())
524 pxa27x_map_io();
Mike Rapoport2f01a972008-06-17 12:29:58 +0100525}
526#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100527
Mike Rapoportda591932008-10-05 10:25:44 +0100528MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400529 .atag_offset = 0x100,
Mike Rapoportda591932008-10-05 10:25:44 +0100530 .map_io = cmx2xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800531 .nr_irqs = CMX2XX_NR_IRQS,
Mike Rapoportda591932008-10-05 10:25:44 +0100532 .init_irq = cmx2xx_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800533 /* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
534 .handle_irq = pxa25x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700535 .init_time = pxa_timer_init,
Mike Rapoportda591932008-10-05 10:25:44 +0100536 .init_machine = cmx2xx_init,
Nicolas Pitre805e88d2011-07-05 22:28:09 -0400537#ifdef CONFIG_PCI
538 .dma_zone_size = SZ_64M,
539#endif
Russell King271a74f2011-11-04 14:15:53 +0000540 .restart = pxa_restart,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100541MACHINE_END