blob: b50ef39eabfcdadf5751b34d69d79bdeb3fefaf2 [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
Mike Rapoport2f01a972008-06-17 12:29:58 +010036/* virtual addresses for statically mapped regions */
Mike Rapoportda591932008-10-05 10:25:44 +010037#define CMX2XX_VIRT_BASE (0xe8000000)
38#define CMX2XX_IT8152_VIRT (CMX2XX_VIRT_BASE)
Mike Rapoport2f01a972008-06-17 12:29:58 +010039
Mike Rapoport4adc5fb2008-10-05 10:26:10 +010040/* physical address if local-bus attached devices */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010041#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
Mike Rapoportda591932008-10-05 10:25:44 +010042#define CMX270_DM9000_PHYS_BASE (PXA_CS1_PHYS + (6 << 22))
43
44/* leds */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010045#define CMX255_GPIO_RED (27)
46#define CMX255_GPIO_GREEN (32)
Mike Rapoportda591932008-10-05 10:25:44 +010047#define CMX270_GPIO_RED (93)
48#define CMX270_GPIO_GREEN (94)
Mike Rapoport3696a8a2007-09-23 15:59:26 +010049
Mike Rapoport2f01a972008-06-17 12:29:58 +010050/* GPIO IRQ usage */
Mike Rapoporta7f3f032008-10-05 10:26:55 +010051#define GPIO22_ETHIRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010052#define GPIO10_ETHIRQ (10)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010053#define CMX255_GPIO_IT8152_IRQ (0)
Mike Rapoportda591932008-10-05 10:25:44 +010054#define CMX270_GPIO_IT8152_IRQ (22)
Mike Rapoport2f01a972008-06-17 12:29:58 +010055
Mike Rapoporta7f3f032008-10-05 10:26:55 +010056#define CMX255_ETHIRQ IRQ_GPIO(GPIO22_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010057#define CMX270_ETHIRQ IRQ_GPIO(GPIO10_ETHIRQ)
Mike Rapoport2f01a972008-06-17 12:29:58 +010058
59#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
Mike Rapoporta7f3f032008-10-05 10:26:55 +010060static struct resource cmx255_dm9000_resource[] = {
61 [0] = {
62 .start = CMX255_DM9000_PHYS_BASE,
63 .end = CMX255_DM9000_PHYS_BASE + 3,
64 .flags = IORESOURCE_MEM,
65 },
66 [1] = {
67 .start = CMX255_DM9000_PHYS_BASE + 4,
68 .end = CMX255_DM9000_PHYS_BASE + 4 + 500,
69 .flags = IORESOURCE_MEM,
70 },
71 [2] = {
72 .start = CMX255_ETHIRQ,
73 .end = CMX255_ETHIRQ,
74 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
75 }
76};
77
Mike Rapoport2f01a972008-06-17 12:29:58 +010078static struct resource cmx270_dm9000_resource[] = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +010079 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +010080 .start = CMX270_DM9000_PHYS_BASE,
81 .end = CMX270_DM9000_PHYS_BASE + 3,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010082 .flags = IORESOURCE_MEM,
83 },
84 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +010085 .start = CMX270_DM9000_PHYS_BASE + 8,
86 .end = CMX270_DM9000_PHYS_BASE + 8 + 500,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010087 .flags = IORESOURCE_MEM,
88 },
89 [2] = {
90 .start = CMX270_ETHIRQ,
91 .end = CMX270_ETHIRQ,
Mike Rapoport2f01a972008-06-17 12:29:58 +010092 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010093 }
94};
95
Mike Rapoport2f01a972008-06-17 12:29:58 +010096static struct dm9000_plat_data cmx270_dm9000_platdata = {
Mike Rapoportbff22c92009-02-23 18:01:12 +020097 .flags = DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
Mike Rapoport3696a8a2007-09-23 15:59:26 +010098};
99
Mike Rapoportda591932008-10-05 10:25:44 +0100100static struct platform_device cmx2xx_dm9000_device = {
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100101 .name = "dm9000",
102 .id = 0,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100103 .num_resources = ARRAY_SIZE(cmx270_dm9000_resource),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100104 .dev = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100105 .platform_data = &cmx270_dm9000_platdata,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100106 }
107};
108
Mike Rapoportda591932008-10-05 10:25:44 +0100109static void __init cmx2xx_init_dm9000(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100110{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100111 if (cpu_is_pxa25x())
112 cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
113 else
114 cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
Mike Rapoportda591932008-10-05 10:25:44 +0100115 platform_device_register(&cmx2xx_dm9000_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100116}
117#else
Mike Rapoportda591932008-10-05 10:25:44 +0100118static inline void cmx2xx_init_dm9000(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100119#endif
120
121/* UCB1400 touchscreen controller */
122#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100123static struct platform_device cmx2xx_ts_device = {
Marek Vasut50f6bb02009-04-01 22:30:07 +0800124 .name = "ucb1400_core",
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100125 .id = -1,
126};
127
Mike Rapoportda591932008-10-05 10:25:44 +0100128static void __init cmx2xx_init_touchscreen(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100129{
Mike Rapoportda591932008-10-05 10:25:44 +0100130 platform_device_register(&cmx2xx_ts_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100131}
132#else
Mike Rapoportda591932008-10-05 10:25:44 +0100133static inline void cmx2xx_init_touchscreen(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100134#endif
135
Mike Rapoport2f01a972008-06-17 12:29:58 +0100136/* CM-X270 LEDs */
137#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100138static struct gpio_led cmx2xx_leds[] = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100139 [0] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100140 .name = "cm-x2xx:red",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100141 .default_trigger = "nand-disk",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100142 .active_low = 1,
143 },
144 [1] = {
Mike Rapoportda591932008-10-05 10:25:44 +0100145 .name = "cm-x2xx:green",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100146 .default_trigger = "heartbeat",
Mike Rapoport2f01a972008-06-17 12:29:58 +0100147 .active_low = 1,
148 },
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100149};
150
Mike Rapoportda591932008-10-05 10:25:44 +0100151static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
152 .num_leds = ARRAY_SIZE(cmx2xx_leds),
153 .leds = cmx2xx_leds,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100154};
155
Mike Rapoportda591932008-10-05 10:25:44 +0100156static struct platform_device cmx2xx_led_device = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100157 .name = "leds-gpio",
158 .id = -1,
159 .dev = {
Mike Rapoportda591932008-10-05 10:25:44 +0100160 .platform_data = &cmx2xx_gpio_led_pdata,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100161 },
162};
163
Mike Rapoportda591932008-10-05 10:25:44 +0100164static void __init cmx2xx_init_leds(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100165{
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100166 if (cpu_is_pxa25x()) {
167 cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
168 cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
169 } else {
170 cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
171 cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
172 }
Mike Rapoportda591932008-10-05 10:25:44 +0100173 platform_device_register(&cmx2xx_led_device);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100174}
175#else
Mike Rapoportda591932008-10-05 10:25:44 +0100176static inline void cmx2xx_init_leds(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100177#endif
178
Mike Rapoport2f01a972008-06-17 12:29:58 +0100179#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100180/*
181 Display definitions
182 keep these for backwards compatibility, although symbolic names (as
183 e.g. in lpd270.c) looks better
184*/
185#define MTYPE_STN320x240 0
186#define MTYPE_TFT640x480 1
187#define MTYPE_CRT640x480 2
188#define MTYPE_CRT800x600 3
189#define MTYPE_TFT320x240 6
190#define MTYPE_STN640x480 7
191
192static struct pxafb_mode_info generic_stn_320x240_mode = {
193 .pixclock = 76923,
194 .bpp = 8,
195 .xres = 320,
196 .yres = 240,
197 .hsync_len = 3,
198 .vsync_len = 2,
199 .left_margin = 3,
200 .upper_margin = 0,
201 .right_margin = 3,
202 .lower_margin = 0,
203 .sync = (FB_SYNC_HOR_HIGH_ACT |
204 FB_SYNC_VERT_HIGH_ACT),
205 .cmap_greyscale = 0,
206};
207
208static struct pxafb_mach_info generic_stn_320x240 = {
209 .modes = &generic_stn_320x240_mode,
210 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800211 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
212 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100213 .cmap_inverse = 0,
214 .cmap_static = 0,
215};
216
217static struct pxafb_mode_info generic_tft_640x480_mode = {
218 .pixclock = 38461,
219 .bpp = 8,
220 .xres = 640,
221 .yres = 480,
222 .hsync_len = 60,
223 .vsync_len = 2,
224 .left_margin = 70,
225 .upper_margin = 10,
226 .right_margin = 70,
227 .lower_margin = 5,
228 .sync = 0,
229 .cmap_greyscale = 0,
230};
231
232static struct pxafb_mach_info generic_tft_640x480 = {
233 .modes = &generic_tft_640x480_mode,
234 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800235 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
236 LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100237 .cmap_inverse = 0,
238 .cmap_static = 0,
239};
240
241static struct pxafb_mode_info generic_crt_640x480_mode = {
242 .pixclock = 38461,
243 .bpp = 8,
244 .xres = 640,
245 .yres = 480,
246 .hsync_len = 63,
247 .vsync_len = 2,
248 .left_margin = 81,
249 .upper_margin = 33,
250 .right_margin = 16,
251 .lower_margin = 10,
252 .sync = (FB_SYNC_HOR_HIGH_ACT |
253 FB_SYNC_VERT_HIGH_ACT),
254 .cmap_greyscale = 0,
255};
256
257static struct pxafb_mach_info generic_crt_640x480 = {
258 .modes = &generic_crt_640x480_mode,
259 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800260 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100261 .cmap_inverse = 0,
262 .cmap_static = 0,
263};
264
265static struct pxafb_mode_info generic_crt_800x600_mode = {
266 .pixclock = 28846,
267 .bpp = 8,
268 .xres = 800,
269 .yres = 600,
270 .hsync_len = 63,
271 .vsync_len = 2,
272 .left_margin = 26,
273 .upper_margin = 21,
274 .right_margin = 26,
275 .lower_margin = 11,
276 .sync = (FB_SYNC_HOR_HIGH_ACT |
277 FB_SYNC_VERT_HIGH_ACT),
278 .cmap_greyscale = 0,
279};
280
281static struct pxafb_mach_info generic_crt_800x600 = {
282 .modes = &generic_crt_800x600_mode,
283 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800284 .lcd_conn = LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100285 .cmap_inverse = 0,
286 .cmap_static = 0,
287};
288
289static struct pxafb_mode_info generic_tft_320x240_mode = {
290 .pixclock = 134615,
291 .bpp = 16,
292 .xres = 320,
293 .yres = 240,
294 .hsync_len = 63,
295 .vsync_len = 7,
296 .left_margin = 75,
297 .upper_margin = 0,
298 .right_margin = 15,
299 .lower_margin = 15,
300 .sync = 0,
301 .cmap_greyscale = 0,
302};
303
304static struct pxafb_mach_info generic_tft_320x240 = {
305 .modes = &generic_tft_320x240_mode,
306 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800307 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100308 .cmap_inverse = 0,
309 .cmap_static = 0,
310};
311
312static struct pxafb_mode_info generic_stn_640x480_mode = {
313 .pixclock = 57692,
314 .bpp = 8,
315 .xres = 640,
316 .yres = 480,
317 .hsync_len = 4,
318 .vsync_len = 2,
319 .left_margin = 10,
320 .upper_margin = 5,
321 .right_margin = 10,
322 .lower_margin = 5,
323 .sync = (FB_SYNC_HOR_HIGH_ACT |
324 FB_SYNC_VERT_HIGH_ACT),
325 .cmap_greyscale = 0,
326};
327
328static struct pxafb_mach_info generic_stn_640x480 = {
329 .modes = &generic_stn_640x480_mode,
330 .num_modes = 1,
Eric Miao95873192008-12-07 17:49:01 +0800331 .lcd_conn = LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100332 .cmap_inverse = 0,
333 .cmap_static = 0,
334};
335
Mike Rapoportda591932008-10-05 10:25:44 +0100336static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100337
Mike Rapoportda591932008-10-05 10:25:44 +0100338static int __init cmx2xx_set_display(char *str)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100339{
340 int disp_type = simple_strtol(str, NULL, 0);
341 switch (disp_type) {
342 case MTYPE_STN320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100343 cmx2xx_display = &generic_stn_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100344 break;
345 case MTYPE_TFT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100346 cmx2xx_display = &generic_tft_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100347 break;
348 case MTYPE_CRT640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100349 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100350 break;
351 case MTYPE_CRT800x600:
Mike Rapoportda591932008-10-05 10:25:44 +0100352 cmx2xx_display = &generic_crt_800x600;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100353 break;
354 case MTYPE_TFT320x240:
Mike Rapoportda591932008-10-05 10:25:44 +0100355 cmx2xx_display = &generic_tft_320x240;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100356 break;
357 case MTYPE_STN640x480:
Mike Rapoportda591932008-10-05 10:25:44 +0100358 cmx2xx_display = &generic_stn_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100359 break;
360 default: /* fallback to CRT 640x480 */
Mike Rapoportda591932008-10-05 10:25:44 +0100361 cmx2xx_display = &generic_crt_640x480;
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100362 break;
363 }
364 return 1;
365}
366
367/*
368 This should be done really early to get proper configuration for
369 frame buffer.
Mike Rapoportda591932008-10-05 10:25:44 +0100370 Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100371 has limitied line length for kernel command line, and also it will
372 break compatibitlty with proprietary releases already in field.
373*/
Mike Rapoportda591932008-10-05 10:25:44 +0100374__setup("monitor=", cmx2xx_set_display);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100375
Mike Rapoportda591932008-10-05 10:25:44 +0100376static void __init cmx2xx_init_display(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100377{
Mike Rapoportda591932008-10-05 10:25:44 +0100378 set_pxa_fb_info(cmx2xx_display);
Mike Rapoport2f01a972008-06-17 12:29:58 +0100379}
380#else
Mike Rapoportda591932008-10-05 10:25:44 +0100381static inline void cmx2xx_init_display(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100382#endif
383
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100384#ifdef CONFIG_PM
385static unsigned long sleep_save_msc[10];
386
Mike Rapoportda591932008-10-05 10:25:44 +0100387static int cmx2xx_suspend(struct sys_device *dev, pm_message_t state)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100388{
Mike Rapoportda591932008-10-05 10:25:44 +0100389 cmx2xx_pci_suspend();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100390
391 /* save MSC registers */
392 sleep_save_msc[0] = MSC0;
393 sleep_save_msc[1] = MSC1;
394 sleep_save_msc[2] = MSC2;
395
396 /* setup power saving mode registers */
397 PCFR = 0x0;
398 PSLR = 0xff400000;
399 PMCR = 0x00000005;
400 PWER = 0x80000000;
401 PFER = 0x00000000;
402 PRER = 0x00000000;
403 PGSR0 = 0xC0018800;
404 PGSR1 = 0x004F0002;
405 PGSR2 = 0x6021C000;
406 PGSR3 = 0x00020000;
407
408 return 0;
409}
410
Mike Rapoportda591932008-10-05 10:25:44 +0100411static int cmx2xx_resume(struct sys_device *dev)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100412{
Mike Rapoportda591932008-10-05 10:25:44 +0100413 cmx2xx_pci_resume();
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100414
415 /* restore MSC registers */
416 MSC0 = sleep_save_msc[0];
417 MSC1 = sleep_save_msc[1];
418 MSC2 = sleep_save_msc[2];
419
420 return 0;
421}
422
Mike Rapoportda591932008-10-05 10:25:44 +0100423static struct sysdev_class cmx2xx_pm_sysclass = {
Kay Sieversaf5ca3f2007-12-20 02:09:39 +0100424 .name = "pm",
Mike Rapoportda591932008-10-05 10:25:44 +0100425 .resume = cmx2xx_resume,
426 .suspend = cmx2xx_suspend,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100427};
428
Mike Rapoportda591932008-10-05 10:25:44 +0100429static struct sys_device cmx2xx_pm_device = {
430 .cls = &cmx2xx_pm_sysclass,
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{
435 int error;
Mike Rapoportda591932008-10-05 10:25:44 +0100436 error = sysdev_class_register(&cmx2xx_pm_sysclass);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100437 if (error == 0)
Mike Rapoportda591932008-10-05 10:25:44 +0100438 error = sysdev_register(&cmx2xx_pm_device);
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100439 return error;
440}
441#else
Mike Rapoportda591932008-10-05 10:25:44 +0100442static int __init cmx2xx_pm_init(void) { return 0; }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100443#endif
444
Mike Rapoport2f01a972008-06-17 12:29:58 +0100445#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
Mike Rapoportda591932008-10-05 10:25:44 +0100446static void __init cmx2xx_init_ac97(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100447{
448 pxa_set_ac97_info(NULL);
449}
450#else
Mike Rapoportda591932008-10-05 10:25:44 +0100451static inline void cmx2xx_init_ac97(void) {}
Mike Rapoport2f01a972008-06-17 12:29:58 +0100452#endif
453
Mike Rapoportda591932008-10-05 10:25:44 +0100454static void __init cmx2xx_init(void)
455{
456 cmx2xx_pm_init();
457
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100458 if (cpu_is_pxa25x())
459 cmx255_init();
460 else
461 cmx270_init();
Mike Rapoportda591932008-10-05 10:25:44 +0100462
463 cmx2xx_init_dm9000();
464 cmx2xx_init_display();
465 cmx2xx_init_ac97();
466 cmx2xx_init_touchscreen();
467 cmx2xx_init_leds();
468}
469
470static void __init cmx2xx_init_irq(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100471{
472 pxa27x_init_irq();
473
Mike Rapoporta7f3f032008-10-05 10:26:55 +0100474 if (cpu_is_pxa25x()) {
475 pxa25x_init_irq();
476 cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
477 } else {
478 pxa27x_init_irq();
479 cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
480 }
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100481}
482
Mike Rapoport2f01a972008-06-17 12:29:58 +0100483#ifdef CONFIG_PCI
484/* Map PCI companion statically */
Mike Rapoportda591932008-10-05 10:25:44 +0100485static struct map_desc cmx2xx_io_desc[] __initdata = {
Mike Rapoport2f01a972008-06-17 12:29:58 +0100486 [0] = { /* PCI bridge */
Mike Rapoportda591932008-10-05 10:25:44 +0100487 .virtual = CMX2XX_IT8152_VIRT,
Mike Rapoport2f01a972008-06-17 12:29:58 +0100488 .pfn = __phys_to_pfn(PXA_CS4_PHYS),
489 .length = SZ_64M,
490 .type = MT_DEVICE
491 },
492};
493
Mike Rapoportda591932008-10-05 10:25:44 +0100494static void __init cmx2xx_map_io(void)
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100495{
496 pxa_map_io();
Mike Rapoportda591932008-10-05 10:25:44 +0100497 iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100498
Mike Rapoportda591932008-10-05 10:25:44 +0100499 it8152_base_address = CMX2XX_IT8152_VIRT;
Mike Rapoport2f01a972008-06-17 12:29:58 +0100500}
501#else
Mike Rapoportda591932008-10-05 10:25:44 +0100502static void __init cmx2xx_map_io(void)
Mike Rapoport2f01a972008-06-17 12:29:58 +0100503{
504 pxa_map_io();
505}
506#endif
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100507
Mike Rapoportda591932008-10-05 10:25:44 +0100508MACHINE_START(ARMCORE, "Compulab CM-X2XX")
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100509 .boot_params = 0xa0000100,
510 .phys_io = 0x40000000,
511 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Mike Rapoportda591932008-10-05 10:25:44 +0100512 .map_io = cmx2xx_map_io,
513 .init_irq = cmx2xx_init_irq,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100514 .timer = &pxa_timer,
Mike Rapoportda591932008-10-05 10:25:44 +0100515 .init_machine = cmx2xx_init,
Mike Rapoport3696a8a2007-09-23 15:59:26 +0100516MACHINE_END