blob: 47e242005fac7889956462c855fb2f3e1f951953 [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>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010013#include <linux/sysdev.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
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/pxa2xx-regs.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/audio.h>
26#include <mach/pxafb.h>
Mike Rapoport3696a8a2007-09-23 15:59:26 +010027
28#include <asm/hardware/it8152.h>
29
30#include "generic.h"
Mike Rapoport7d76e3f2008-10-07 11:58:25 +010031#include "cm-x2xx-pci.h"
Mike Rapoport3696a8a2007-09-23 15:59:26 +010032
Mike Rapoporta7f3f032008-10-05 10:26:55 +010033extern void cmx255_init(void);
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010034extern void cmx270_init(void);
35
Haojian Zhuang6ac6b812010-08-20 15:23:59 +080036/* reserve IRQs for IT8152 */
37#define CMX2XX_NR_IRQS (IRQ_BOARD_START + 40)
38
Mike Rapoport2f01a972008-06-17 12:29:58 +010039/* virtual addresses for statically mapped regions */
Mike Rapoportda591932008-10-05 10:25:44 +010040#define CMX2XX_VIRT_BASE (0xe8000000)
41#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010042
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010043/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010044#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010045#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
46
47/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010048#define CMX255_GPIO_RED (27)
49#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010050#define CMX270_GPIO_RED (93)
51#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010052
Mike Rapoport2f01a972008-06-17 12:29:58 +010053/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010054#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010055#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010056#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010057#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010058
Mike Rapoporta7f3f032008-10-05 10:26:55 +010059#define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010060#define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010061
62#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010063static struct resource cmx255_dm9000_resource[] = {
64 [0] = {
65 .start = CMX255_DM9000_PHYS_BASE,
66 .end = CMX255_DM9000_PHYS_BASE + 3,
67 .flags = IORESOURCE_MEM,
68 },
69 [1] = {
70 .start = CMX255_DM9000_PHYS_BASE + 4,
71 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
72 .flags = IORESOURCE_MEM,
73 },
74 [2] = {
75 .start = CMX255_ETHIRQ,
76 .end = CMX255_ETHIRQ,
77 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
78 }
79};
80
Mike Rapoport2f01a972008-06-17 12:29:58 +010081static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010082 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010083 .start = CMX270_DM9000_PHYS_BASE,
84 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010085 .flags = IORESOURCE_MEM,
86 },
87 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +010088 .start = CMX270_DM9000_PHYS_BASE + 8,
89 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010090 .flags = IORESOURCE_MEM,
91 },
92 [2] = {
93 .start = CMX270_ETHIRQ,
94 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +010095 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010096 }
97};
98
Mike Rapoport2f01a972008-06-17 12:29:58 +010099static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +0200100 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100101};
102
Mike Rapoportda591932008-10-05 10:25:44 +0100103static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100104 .name = "dm9000",
105 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100106 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100107 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100108 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100109 }
110};
111
Mike Rapoportda591932008-10-05 10:25:44 +0100112static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100113{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100114 if (cpu_is_pxa25x())
115 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
116 else
117 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100118 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100119}
120#else
Mike Rapoportda591932008-10-05 10:25:44 +0100121static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100122#endif
123
124/* UCB1400 touchscreen controller */
125#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100126static struct platform_device cmx2xx_ts_device = {
Marek Vasut50f6bb02009-04-01 22:30:07 +0800127 .name = "ucb1400_core",
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100128 .id = -1,
129};
130
Mike Rapoportda591932008-10-05 10:25:44 +0100131static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100132{
Mike Rapoportda591932008-10-05 10:25:44 +0100133 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100134}
135#else
Mike Rapoportda591932008-10-05 10:25:44 +0100136static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100137#endif
138
Mike Rapoport2f01a972008-06-17 12:29:58 +0100139/* CM-X270 LEDs */
140#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100141static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100142 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100143 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100144 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100145 .active_low = 1,
146 },
147 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100148 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100149 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100150 .active_low = 1,
151 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100152};
153
Mike Rapoportda591932008-10-05 10:25:44 +0100154static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
155 .num_leds = ARRAY_SIZE(cmx2xx_leds),
156 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100157};
158
Mike Rapoportda591932008-10-05 10:25:44 +0100159static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100160 .name = "leds-gpio",
161 .id = -1,
162 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100163 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100164 },
165};
166
Mike Rapoportda591932008-10-05 10:25:44 +0100167static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100168{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100169 if (cpu_is_pxa25x()) {
170 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
171 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
172 } else {
173 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
174 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
175 }
Mike Rapoportda591932008-10-05 10:25:44 +0100176 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100177}
178#else
Mike Rapoportda591932008-10-05 10:25:44 +0100179static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100180#endif
181
Mike Rapoport2f01a972008-06-17 12:29:58 +0100182#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100183/*
184 Display definitions
185 keep these for backwards compatibility, although symbolic names (as
186 e.g. in lpd270.c) looks better
187*/
188#define MTYPE_STN320x240 0
189#define MTYPE_TFT640x480 1
190#define MTYPE_CRT640x480 2
191#define MTYPE_CRT800x600 3
192#define MTYPE_TFT320x240 6
193#define MTYPE_STN640x480 7
194
195static struct pxafb_mode_info generic_stn_320x240_mode = {
196 .pixclock = 76923,
197 .bpp = 8,
198 .xres = 320,
199 .yres = 240,
200 .hsync_len = 3,
201 .vsync_len = 2,
202 .left_margin = 3,
203 .upper_margin = 0,
204 .right_margin = 3,
205 .lower_margin = 0,
206 .sync = (FB_SYNC_HOR_HIGH_ACT |
207 FB_SYNC_VERT_HIGH_ACT),
208 .cmap_greyscale = 0,
209};
210
211static struct pxafb_mach_info generic_stn_320x240 = {
212 .modes = &generic_stn_320x240_mode,
213 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800214 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
215 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100216 .cmap_inverse = 0,
217 .cmap_static = 0,
218};
219
220static struct pxafb_mode_info generic_tft_640x480_mode = {
221 .pixclock = 38461,
222 .bpp = 8,
223 .xres = 640,
224 .yres = 480,
225 .hsync_len = 60,
226 .vsync_len = 2,
227 .left_margin = 70,
228 .upper_margin = 10,
229 .right_margin = 70,
230 .lower_margin = 5,
231 .sync = 0,
232 .cmap_greyscale = 0,
233};
234
235static struct pxafb_mach_info generic_tft_640x480 = {
236 .modes = &generic_tft_640x480_mode,
237 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800238 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
239 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100240 .cmap_inverse = 0,
241 .cmap_static = 0,
242};
243
244static struct pxafb_mode_info generic_crt_640x480_mode = {
245 .pixclock = 38461,
246 .bpp = 8,
247 .xres = 640,
248 .yres = 480,
249 .hsync_len = 63,
250 .vsync_len = 2,
251 .left_margin = 81,
252 .upper_margin = 33,
253 .right_margin = 16,
254 .lower_margin = 10,
255 .sync = (FB_SYNC_HOR_HIGH_ACT |
256 FB_SYNC_VERT_HIGH_ACT),
257 .cmap_greyscale = 0,
258};
259
260static struct pxafb_mach_info generic_crt_640x480 = {
261 .modes = &generic_crt_640x480_mode,
262 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800263 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100264 .cmap_inverse = 0,
265 .cmap_static = 0,
266};
267
268static struct pxafb_mode_info generic_crt_800x600_mode = {
269 .pixclock = 28846,
270 .bpp = 8,
271 .xres = 800,
272 .yres = 600,
273 .hsync_len = 63,
274 .vsync_len = 2,
275 .left_margin = 26,
276 .upper_margin = 21,
277 .right_margin = 26,
278 .lower_margin = 11,
279 .sync = (FB_SYNC_HOR_HIGH_ACT |
280 FB_SYNC_VERT_HIGH_ACT),
281 .cmap_greyscale = 0,
282};
283
284static struct pxafb_mach_info generic_crt_800x600 = {
285 .modes = &generic_crt_800x600_mode,
286 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800287 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100288 .cmap_inverse = 0,
289 .cmap_static = 0,
290};
291
292static struct pxafb_mode_info generic_tft_320x240_mode = {
293 .pixclock = 134615,
294 .bpp = 16,
295 .xres = 320,
296 .yres = 240,
297 .hsync_len = 63,
298 .vsync_len = 7,
299 .left_margin = 75,
300 .upper_margin = 0,
301 .right_margin = 15,
302 .lower_margin = 15,
303 .sync = 0,
304 .cmap_greyscale = 0,
305};
306
307static struct pxafb_mach_info generic_tft_320x240 = {
308 .modes = &generic_tft_320x240_mode,
309 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800310 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100311 .cmap_inverse = 0,
312 .cmap_static = 0,
313};
314
315static struct pxafb_mode_info generic_stn_640x480_mode = {
316 .pixclock = 57692,
317 .bpp = 8,
318 .xres = 640,
319 .yres = 480,
320 .hsync_len = 4,
321 .vsync_len = 2,
322 .left_margin = 10,
323 .upper_margin = 5,
324 .right_margin = 10,
325 .lower_margin = 5,
326 .sync = (FB_SYNC_HOR_HIGH_ACT |
327 FB_SYNC_VERT_HIGH_ACT),
328 .cmap_greyscale = 0,
329};
330
331static struct pxafb_mach_info generic_stn_640x480 = {
332 .modes = &generic_stn_640x480_mode,
333 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800334 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100335 .cmap_inverse = 0,
336 .cmap_static = 0,
337};
338
Mike Rapoportda591932008-10-05 10:25:44 +0100339static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100340
Mike Rapoportda591932008-10-05 10:25:44 +0100341static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100342{
343 int disp_type = simple_strtol(str, NULL, 0);
344 switch (disp_type) {
345 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100346 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100347 break;
348 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100349 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100350 break;
351 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100352 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100353 break;
354 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100355 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100356 break;
357 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100358 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100359 break;
360 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100361 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100362 break;
363 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100364 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100365 break;
366 }
367 return 1;
368}
369
370/*
371 This should be done really early to get proper configuration for
372 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100373 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100374 has limitied line length for kernel command line, and also it will
375 break compatibitlty with proprietary releases already in field.
376*/
Mike Rapoportda591932008-10-05 10:25:44 +0100377__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100378
Mike Rapoportda591932008-10-05 10:25:44 +0100379static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100380{
Mike Rapoportda591932008-10-05 10:25:44 +0100381 set_pxa_fb_info(cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100382}
383#else
Mike Rapoportda591932008-10-05 10:25:44 +0100384static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100385#endif
386
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100387#ifdef CONFIG_PM
388static unsigned long sleep_save_msc[10];
389
Mike Rapoportda591932008-10-05 10:25:44 +0100390static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100391{
Mike Rapoportda591932008-10-05 10:25:44 +0100392 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100393
394 /* save MSC registers */
395 sleep_save_msc[0] = MSC0;
396 sleep_save_msc[1] = MSC1;
397 sleep_save_msc[2] = MSC2;
398
399 /* setup power saving mode registers */
400 PCFR = 0x0;
401 PSLR = 0xff400000;
402 PMCR = 0x00000005;
403 PWER = 0x80000000;
404 PFER = 0x00000000;
405 PRER = 0x00000000;
406 PGSR0 = 0xC0018800;
407 PGSR1 = 0x004F0002;
408 PGSR2 = 0x6021C000;
409 PGSR3 = 0x00020000;
410
411 return 0;
412}
413
Mike Rapoportda591932008-10-05 10:25:44 +0100414static int cmx2xx_resume(struct sys_device *dev)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100415{
Mike Rapoportda591932008-10-05 10:25:44 +0100416 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100417
418 /* restore MSC registers */
419 MSC0 = sleep_save_msc[0];
420 MSC1 = sleep_save_msc[1];
421 MSC2 = sleep_save_msc[2];
422
423 return 0;
424}
425
Mike Rapoportda591932008-10-05 10:25:44 +0100426static struct sysdev_class cmx2xx_pm_sysclass = {
Kay Sieversaf5ca3f2007-12-20 02:09:39 +0100427 .name = "pm",
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 struct sys_device cmx2xx_pm_device = {
433 .cls = &cmx2xx_pm_sysclass,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100434};
435
Mike Rapoportda591932008-10-05 10:25:44 +0100436static int __init cmx2xx_pm_init(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100437{
438 int error;
Mike Rapoportda591932008-10-05 10:25:44 +0100439 error = sysdev_class_register(&cmx2xx_pm_sysclass);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100440 if (error == 0)
Mike Rapoportda591932008-10-05 10:25:44 +0100441 error = sysdev_register(&cmx2xx_pm_device);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100442 return error;
443}
444#else
Mike Rapoportda591932008-10-05 10:25:44 +0100445static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100446#endif
447
Mike Rapoport2f01a972008-06-17 12:29:58 +0100448#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100449static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100450{
451 pxa_set_ac97_info(NULL);
452}
453#else
Mike Rapoportda591932008-10-05 10:25:44 +0100454static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100455#endif
456
Mike Rapoportda591932008-10-05 10:25:44 +0100457static void __init cmx2xx_init(void)
458{
Russell Kingcc155c62009-11-09 13:34:08 +0800459 pxa_set_ffuart_info(NULL);
460 pxa_set_btuart_info(NULL);
461 pxa_set_stuart_info(NULL);
462
Mike Rapoportda591932008-10-05 10:25:44 +0100463 cmx2xx_pm_init();
464
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100465 if (cpu_is_pxa25x())
466 cmx255_init();
467 else
468 cmx270_init();
Mike Rapoportda591932008-10-05 10:25:44 +0100469
470 cmx2xx_init_dm9000();
471 cmx2xx_init_display();
472 cmx2xx_init_ac97();
473 cmx2xx_init_touchscreen();
474 cmx2xx_init_leds();
475}
476
477static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100478{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100479 if (cpu_is_pxa25x()) {
480 pxa25x_init_irq();
481 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
482 } else {
483 pxa27x_init_irq();
484 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
485 }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100486}
487
Mike Rapoport2f01a972008-06-17 12:29:58 +0100488#ifdef CONFIG_PCI
489/* Map PCI companion statically */
Mike Rapoportda591932008-10-05 10:25:44 +0100490static struct map_desc cmx2xx_io_desc[] __initdata = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100491 [0] = { /* PCI bridge */
Mike Rapoportda591932008-10-05 10:25:44 +0100492 .virtual = CMX2XX_IT8152_VIRT,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100493 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
494 .length = SZ_64M,
495 .type = MT_DEVICE
496 },
497};
498
Mike Rapoportda591932008-10-05 10:25:44 +0100499static void __init cmx2xx_map_io(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100500{
Marek Vasut851982c2010-10-11 02:20:19 +0200501 if (cpu_is_pxa25x())
502 pxa25x_map_io();
503
504 if (cpu_is_pxa27x())
505 pxa27x_map_io();
506
Mike Rapoportda591932008-10-05 10:25:44 +0100507 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100508
Mike Rapoportda591932008-10-05 10:25:44 +0100509 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100510}
511#else
Mike Rapoportda591932008-10-05 10:25:44 +0100512static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100513{
Marek Vasut851982c2010-10-11 02:20:19 +0200514 if (cpu_is_pxa25x())
515 pxa25x_map_io();
516
517 if (cpu_is_pxa27x())
518 pxa27x_map_io();
Mike Rapoport2f01a972008-06-17 12:29:58 +0100519}
520#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100521
Mike Rapoportda591932008-10-05 10:25:44 +0100522MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100523 .boot_params = 0xa0000100,
Mike Rapoportda591932008-10-05 10:25:44 +0100524 .map_io = cmx2xx_map_io,
Haojian Zhuang6ac6b812010-08-20 15:23:59 +0800525 .nr_irqs = CMX2XX_NR_IRQS,
Mike Rapoportda591932008-10-05 10:25:44 +0100526 .init_irq = cmx2xx_init_irq,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100527 .timer = &pxa_timer,
Mike Rapoportda591932008-10-05 10:25:44 +0100528 .init_machine = cmx2xx_init,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100529MACHINE_END