blob: d99fd9e4d8885d6e1300a42dbfbae76e6a2cbe51 [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>
25#include <mach/mfp-pxa27x.h>
26#include <mach/pxa-regs.h>
27#include <mach/audio.h>
28#include <mach/pxafb.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 Rapoport4adc5fb2008-10-05 10:26:10 +010036extern void cmx270_init(void);
37
Mike Rapoport2f01a972008-06-17 12:29:58 +010038/* virtual addresses for statically mapped regions */
Mike Rapoportda591932008-10-05 10:25:44 +010039#define CMX2XX_VIRT_BASE (0xe8000000)
40#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010041
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010042/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010043#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010044#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
45
46/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010047#define CMX255_GPIO_RED (27)
48#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010049#define CMX270_GPIO_RED (93)
50#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010051
Mike Rapoport2f01a972008-06-17 12:29:58 +010052/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010053#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010054#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010055#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010056#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010057
Mike Rapoporta7f3f032008-10-05 10:26:55 +010058#define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010059#define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010060
61#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010062static struct resource cmx255_dm9000_resource[] = {
63 [0] = {
64 .start = CMX255_DM9000_PHYS_BASE,
65 .end = CMX255_DM9000_PHYS_BASE + 3,
66 .flags = IORESOURCE_MEM,
67 },
68 [1] = {
69 .start = CMX255_DM9000_PHYS_BASE + 4,
70 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
71 .flags = IORESOURCE_MEM,
72 },
73 [2] = {
74 .start = CMX255_ETHIRQ,
75 .end = CMX255_ETHIRQ,
76 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
77 }
78};
79
Mike Rapoport2f01a972008-06-17 12:29:58 +010080static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010081 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010082 .start = CMX270_DM9000_PHYS_BASE,
83 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010084 .flags = IORESOURCE_MEM,
85 },
86 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +010087 .start = CMX270_DM9000_PHYS_BASE + 8,
88 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010089 .flags = IORESOURCE_MEM,
90 },
91 [2] = {
92 .start = CMX270_ETHIRQ,
93 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +010094 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010095 }
96};
97
Mike Rapoport2f01a972008-06-17 12:29:58 +010098static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010099 .flags = DM9000_PLATF_32BITONLY,
100};
101
Mike Rapoportda591932008-10-05 10:25:44 +0100102static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100103 .name = "dm9000",
104 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100105 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100106 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100107 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100108 }
109};
110
Mike Rapoportda591932008-10-05 10:25:44 +0100111static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100112{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100113 if (cpu_is_pxa25x())
114 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
115 else
116 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100117 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100118}
119#else
Mike Rapoportda591932008-10-05 10:25:44 +0100120static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100121#endif
122
123/* UCB1400 touchscreen controller */
124#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100125static struct platform_device cmx2xx_ts_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100126 .name = "ucb1400_ts",
127 .id = -1,
128};
129
Mike Rapoportda591932008-10-05 10:25:44 +0100130static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100131{
Mike Rapoportda591932008-10-05 10:25:44 +0100132 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100133}
134#else
Mike Rapoportda591932008-10-05 10:25:44 +0100135static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100136#endif
137
Mike Rapoport2f01a972008-06-17 12:29:58 +0100138/* CM-X270 LEDs */
139#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100140static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100141 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100142 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100143 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100144 .active_low = 1,
145 },
146 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100147 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100148 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100149 .active_low = 1,
150 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100151};
152
Mike Rapoportda591932008-10-05 10:25:44 +0100153static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
154 .num_leds = ARRAY_SIZE(cmx2xx_leds),
155 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100156};
157
Mike Rapoportda591932008-10-05 10:25:44 +0100158static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100159 .name = "leds-gpio",
160 .id = -1,
161 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100162 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100163 },
164};
165
Mike Rapoportda591932008-10-05 10:25:44 +0100166static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100167{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100168 if (cpu_is_pxa25x()) {
169 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
170 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
171 } else {
172 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
173 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
174 }
Mike Rapoportda591932008-10-05 10:25:44 +0100175 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100176}
177#else
Mike Rapoportda591932008-10-05 10:25:44 +0100178static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100179#endif
180
Mike Rapoport2f01a972008-06-17 12:29:58 +0100181#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100182/*
183 Display definitions
184 keep these for backwards compatibility, although symbolic names (as
185 e.g. in lpd270.c) looks better
186*/
187#define MTYPE_STN320x240 0
188#define MTYPE_TFT640x480 1
189#define MTYPE_CRT640x480 2
190#define MTYPE_CRT800x600 3
191#define MTYPE_TFT320x240 6
192#define MTYPE_STN640x480 7
193
194static struct pxafb_mode_info generic_stn_320x240_mode = {
195 .pixclock = 76923,
196 .bpp = 8,
197 .xres = 320,
198 .yres = 240,
199 .hsync_len = 3,
200 .vsync_len = 2,
201 .left_margin = 3,
202 .upper_margin = 0,
203 .right_margin = 3,
204 .lower_margin = 0,
205 .sync = (FB_SYNC_HOR_HIGH_ACT |
206 FB_SYNC_VERT_HIGH_ACT),
207 .cmap_greyscale = 0,
208};
209
210static struct pxafb_mach_info generic_stn_320x240 = {
211 .modes = &generic_stn_320x240_mode,
212 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800213 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
214 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100215 .cmap_inverse = 0,
216 .cmap_static = 0,
217};
218
219static struct pxafb_mode_info generic_tft_640x480_mode = {
220 .pixclock = 38461,
221 .bpp = 8,
222 .xres = 640,
223 .yres = 480,
224 .hsync_len = 60,
225 .vsync_len = 2,
226 .left_margin = 70,
227 .upper_margin = 10,
228 .right_margin = 70,
229 .lower_margin = 5,
230 .sync = 0,
231 .cmap_greyscale = 0,
232};
233
234static struct pxafb_mach_info generic_tft_640x480 = {
235 .modes = &generic_tft_640x480_mode,
236 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800237 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
238 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100239 .cmap_inverse = 0,
240 .cmap_static = 0,
241};
242
243static struct pxafb_mode_info generic_crt_640x480_mode = {
244 .pixclock = 38461,
245 .bpp = 8,
246 .xres = 640,
247 .yres = 480,
248 .hsync_len = 63,
249 .vsync_len = 2,
250 .left_margin = 81,
251 .upper_margin = 33,
252 .right_margin = 16,
253 .lower_margin = 10,
254 .sync = (FB_SYNC_HOR_HIGH_ACT |
255 FB_SYNC_VERT_HIGH_ACT),
256 .cmap_greyscale = 0,
257};
258
259static struct pxafb_mach_info generic_crt_640x480 = {
260 .modes = &generic_crt_640x480_mode,
261 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800262 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100263 .cmap_inverse = 0,
264 .cmap_static = 0,
265};
266
267static struct pxafb_mode_info generic_crt_800x600_mode = {
268 .pixclock = 28846,
269 .bpp = 8,
270 .xres = 800,
271 .yres = 600,
272 .hsync_len = 63,
273 .vsync_len = 2,
274 .left_margin = 26,
275 .upper_margin = 21,
276 .right_margin = 26,
277 .lower_margin = 11,
278 .sync = (FB_SYNC_HOR_HIGH_ACT |
279 FB_SYNC_VERT_HIGH_ACT),
280 .cmap_greyscale = 0,
281};
282
283static struct pxafb_mach_info generic_crt_800x600 = {
284 .modes = &generic_crt_800x600_mode,
285 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800286 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100287 .cmap_inverse = 0,
288 .cmap_static = 0,
289};
290
291static struct pxafb_mode_info generic_tft_320x240_mode = {
292 .pixclock = 134615,
293 .bpp = 16,
294 .xres = 320,
295 .yres = 240,
296 .hsync_len = 63,
297 .vsync_len = 7,
298 .left_margin = 75,
299 .upper_margin = 0,
300 .right_margin = 15,
301 .lower_margin = 15,
302 .sync = 0,
303 .cmap_greyscale = 0,
304};
305
306static struct pxafb_mach_info generic_tft_320x240 = {
307 .modes = &generic_tft_320x240_mode,
308 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800309 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100310 .cmap_inverse = 0,
311 .cmap_static = 0,
312};
313
314static struct pxafb_mode_info generic_stn_640x480_mode = {
315 .pixclock = 57692,
316 .bpp = 8,
317 .xres = 640,
318 .yres = 480,
319 .hsync_len = 4,
320 .vsync_len = 2,
321 .left_margin = 10,
322 .upper_margin = 5,
323 .right_margin = 10,
324 .lower_margin = 5,
325 .sync = (FB_SYNC_HOR_HIGH_ACT |
326 FB_SYNC_VERT_HIGH_ACT),
327 .cmap_greyscale = 0,
328};
329
330static struct pxafb_mach_info generic_stn_640x480 = {
331 .modes = &generic_stn_640x480_mode,
332 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800333 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100334 .cmap_inverse = 0,
335 .cmap_static = 0,
336};
337
Mike Rapoportda591932008-10-05 10:25:44 +0100338static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100339
Mike Rapoportda591932008-10-05 10:25:44 +0100340static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100341{
342 int disp_type = simple_strtol(str, NULL, 0);
343 switch (disp_type) {
344 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100345 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100346 break;
347 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100348 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100349 break;
350 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100351 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100352 break;
353 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100354 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100355 break;
356 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100357 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100358 break;
359 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100360 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100361 break;
362 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100363 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100364 break;
365 }
366 return 1;
367}
368
369/*
370 This should be done really early to get proper configuration for
371 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100372 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100373 has limitied line length for kernel command line, and also it will
374 break compatibitlty with proprietary releases already in field.
375*/
Mike Rapoportda591932008-10-05 10:25:44 +0100376__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100377
Mike Rapoportda591932008-10-05 10:25:44 +0100378static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100379{
Mike Rapoportda591932008-10-05 10:25:44 +0100380 set_pxa_fb_info(cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100381}
382#else
Mike Rapoportda591932008-10-05 10:25:44 +0100383static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100384#endif
385
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100386#ifdef CONFIG_PM
387static unsigned long sleep_save_msc[10];
388
Mike Rapoportda591932008-10-05 10:25:44 +0100389static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100390{
Mike Rapoportda591932008-10-05 10:25:44 +0100391 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100392
393 /* save MSC registers */
394 sleep_save_msc[0] = MSC0;
395 sleep_save_msc[1] = MSC1;
396 sleep_save_msc[2] = MSC2;
397
398 /* setup power saving mode registers */
399 PCFR = 0x0;
400 PSLR = 0xff400000;
401 PMCR = 0x00000005;
402 PWER = 0x80000000;
403 PFER = 0x00000000;
404 PRER = 0x00000000;
405 PGSR0 = 0xC0018800;
406 PGSR1 = 0x004F0002;
407 PGSR2 = 0x6021C000;
408 PGSR3 = 0x00020000;
409
410 return 0;
411}
412
Mike Rapoportda591932008-10-05 10:25:44 +0100413static int cmx2xx_resume(struct sys_device *dev)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100414{
Mike Rapoportda591932008-10-05 10:25:44 +0100415 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100416
417 /* restore MSC registers */
418 MSC0 = sleep_save_msc[0];
419 MSC1 = sleep_save_msc[1];
420 MSC2 = sleep_save_msc[2];
421
422 return 0;
423}
424
Mike Rapoportda591932008-10-05 10:25:44 +0100425static struct sysdev_class cmx2xx_pm_sysclass = {
Kay Sieversaf5ca3f2007-12-20 02:09:39 +0100426 .name = "pm",
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 struct sys_device cmx2xx_pm_device = {
432 .cls = &cmx2xx_pm_sysclass,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100433};
434
Mike Rapoportda591932008-10-05 10:25:44 +0100435static int __init cmx2xx_pm_init(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100436{
437 int error;
Mike Rapoportda591932008-10-05 10:25:44 +0100438 error = sysdev_class_register(&cmx2xx_pm_sysclass);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100439 if (error == 0)
Mike Rapoportda591932008-10-05 10:25:44 +0100440 error = sysdev_register(&cmx2xx_pm_device);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100441 return error;
442}
443#else
Mike Rapoportda591932008-10-05 10:25:44 +0100444static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100445#endif
446
Mike Rapoport2f01a972008-06-17 12:29:58 +0100447#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100448static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100449{
450 pxa_set_ac97_info(NULL);
451}
452#else
Mike Rapoportda591932008-10-05 10:25:44 +0100453static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100454#endif
455
Mike Rapoportda591932008-10-05 10:25:44 +0100456static void __init cmx2xx_init(void)
457{
458 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();
470}
471
472static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100473{
474 pxa27x_init_irq();
475
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 */
Mike Rapoportda591932008-10-05 10:25:44 +0100489 .virtual = 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{
498 pxa_map_io();
Mike Rapoportda591932008-10-05 10:25:44 +0100499 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100500
Mike Rapoportda591932008-10-05 10:25:44 +0100501 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100502}
503#else
Mike Rapoportda591932008-10-05 10:25:44 +0100504static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100505{
506 pxa_map_io();
507}
508#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100509
Mike Rapoportda591932008-10-05 10:25:44 +0100510MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100511 .boot_params = 0xa0000100,
512 .phys_io = 0x40000000,
513 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Mike Rapoportda591932008-10-05 10:25:44 +0100514 .map_io = cmx2xx_map_io,
515 .init_irq = cmx2xx_init_irq,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100516 .timer = &pxa_timer,
Mike Rapoportda591932008-10-05 10:25:44 +0100517 .init_machine = cmx2xx_init,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100518MACHINE_END