Blame view

arch/arm/mach-pxa/cm-x2xx.c 11.9 KB
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
1
  /*
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
2
   * linux/arch/arm/mach-pxa/cm-x2xx.c
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
3
   *
4adc5fb67   Mike Rapoport   [ARM] 5281/1: pxa...
4
   * Copyright (C) 2008 CompuLab, Ltd.
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
5
6
7
8
9
10
   * Mike Rapoport <mike@compulab.co.il>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   */
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
11
  #include <linux/platform_device.h>
2eaa03b5b   Rafael J. Wysocki   ARM / PXA: Use st...
12
  #include <linux/syscore_ops.h>
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
13
14
  #include <linux/irq.h>
  #include <linux/gpio.h>
a927ef895   Robert Jarzmik   ARM: pxa: fix dm9...
15
  #include <linux/regulator/machine.h>
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
16
17
  
  #include <linux/dm9000.h>
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
18
  #include <linux/leds.h>
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
19
20
21
22
  
  #include <asm/mach/arch.h>
  #include <asm/mach-types.h>
  #include <asm/mach/map.h>
ca0e687c8   Eric Miao   ARM: pxa: move de...
23
  #include <mach/pxa25x.h>
e0347c523   Arnd Bergmann   ARM: pxa: work ar...
24
  #undef GPIO24_SSP1_SFRM
ca0e687c8   Eric Miao   ARM: pxa: move de...
25
  #include <mach/pxa27x.h>
a09e64fbc   Russell King   [ARM] Move includ...
26
  #include <mach/audio.h>
293b2da1b   Arnd Bergmann   ARM: pxa: move pl...
27
  #include <linux/platform_data/video-pxafb.h>
ad68bb9f7   Marek Vasut   ARM: pxa: Access ...
28
  #include <mach/smemc.h>
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
29
30
31
32
  
  #include <asm/hardware/it8152.h>
  
  #include "generic.h"
7d76e3f17   Mike Rapoport   [ARM] 5286/2: pxa...
33
  #include "cm-x2xx-pci.h"
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
34

a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
35
  extern void cmx255_init(void);
4adc5fb67   Mike Rapoport   [ARM] 5281/1: pxa...
36
  extern void cmx270_init(void);
6ac6b817f   Haojian Zhuang   ARM: pxa: encode ...
37
38
  /* reserve IRQs for IT8152 */
  #define CMX2XX_NR_IRQS		(IRQ_BOARD_START + 40)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
39
  /* virtual addresses for statically mapped regions */
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
40
  #define CMX2XX_VIRT_BASE	(void __iomem *)(0xe8000000)
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
41
  #define CMX2XX_IT8152_VIRT	(CMX2XX_VIRT_BASE)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
42

4adc5fb67   Mike Rapoport   [ARM] 5281/1: pxa...
43
  /* physical address if local-bus attached devices */
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
44
  #define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
45
46
47
  #define CMX270_DM9000_PHYS_BASE	(PXA_CS1_PHYS + (6 << 22))
  
  /* leds */
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
48
49
  #define CMX255_GPIO_RED		(27)
  #define CMX255_GPIO_GREEN	(32)
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
50
51
  #define CMX270_GPIO_RED		(93)
  #define CMX270_GPIO_GREEN	(94)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
52

2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
53
  /* GPIO IRQ usage */
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
54
  #define GPIO22_ETHIRQ		(22)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
55
  #define GPIO10_ETHIRQ		(10)
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
56
  #define CMX255_GPIO_IT8152_IRQ	(0)
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
57
  #define CMX270_GPIO_IT8152_IRQ	(22)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
58

6384fdadb   Haojian Zhuang   ARM: pxa: rename ...
59
60
  #define CMX255_ETHIRQ		PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
  #define CMX270_ETHIRQ		PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
61
62
  
  #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  static struct resource cmx255_dm9000_resource[] = {
  	[0] = {
  		.start = CMX255_DM9000_PHYS_BASE,
  		.end   = CMX255_DM9000_PHYS_BASE + 3,
  		.flags = IORESOURCE_MEM,
  	},
  	[1] = {
  		.start = CMX255_DM9000_PHYS_BASE + 4,
  		.end   = CMX255_DM9000_PHYS_BASE + 4 + 500,
  		.flags = IORESOURCE_MEM,
  	},
  	[2] = {
  		.start = CMX255_ETHIRQ,
  		.end   = CMX255_ETHIRQ,
  		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  	}
  };
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
80
  static struct resource cmx270_dm9000_resource[] = {
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
81
  	[0] = {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
82
83
  		.start = CMX270_DM9000_PHYS_BASE,
  		.end   = CMX270_DM9000_PHYS_BASE + 3,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
84
85
86
  		.flags = IORESOURCE_MEM,
  	},
  	[1] = {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
87
88
  		.start = CMX270_DM9000_PHYS_BASE + 8,
  		.end   = CMX270_DM9000_PHYS_BASE + 8 + 500,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
89
90
91
92
93
  		.flags = IORESOURCE_MEM,
  	},
  	[2] = {
  		.start = CMX270_ETHIRQ,
  		.end   = CMX270_ETHIRQ,
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
94
  		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
95
96
  	}
  };
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
97
  static struct dm9000_plat_data cmx270_dm9000_platdata = {
bff22c9b8   Mike Rapoport   [ARM] pxa: add DM...
98
  	.flags		= DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
99
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
100
  static struct platform_device cmx2xx_dm9000_device = {
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
101
102
  	.name		= "dm9000",
  	.id		= 0,
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
103
  	.num_resources	= ARRAY_SIZE(cmx270_dm9000_resource),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
104
  	.dev		= {
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
105
  		.platform_data = &cmx270_dm9000_platdata,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
106
107
  	}
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
108
  static void __init cmx2xx_init_dm9000(void)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
109
  {
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
110
111
112
113
  	if (cpu_is_pxa25x())
  		cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
  	else
  		cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
114
  	platform_device_register(&cmx2xx_dm9000_device);
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
115
116
  }
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
117
  static inline void cmx2xx_init_dm9000(void) {}
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
118
119
120
121
  #endif
  
  /* UCB1400 touchscreen controller */
  #if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
122
  static struct platform_device cmx2xx_ts_device = {
50f6bb0ab   Marek Vasut   [ARM] pxa/cm-x2xx...
123
  	.name		= "ucb1400_core",
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
124
125
  	.id		= -1,
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
126
  static void __init cmx2xx_init_touchscreen(void)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
127
  {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
128
  	platform_device_register(&cmx2xx_ts_device);
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
129
130
  }
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
131
  static inline void cmx2xx_init_touchscreen(void) {}
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
132
  #endif
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
133
134
  /* CM-X270 LEDs */
  #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
135
  static struct gpio_led cmx2xx_leds[] = {
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
136
  	[0] = {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
137
  		.name = "cm-x2xx:red",
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
138
  		.default_trigger = "nand-disk",
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
139
140
141
  		.active_low = 1,
  	},
  	[1] = {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
142
  		.name = "cm-x2xx:green",
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
143
  		.default_trigger = "heartbeat",
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
144
145
146
  		.active_low = 1,
  	},
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
147
148
149
  static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
  	.num_leds = ARRAY_SIZE(cmx2xx_leds),
  	.leds = cmx2xx_leds,
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
150
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
151
  static struct platform_device cmx2xx_led_device = {
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
152
  	.name		= "leds-gpio",
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
153
  	.id		= -1,
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
154
  	.dev		= {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
155
  		.platform_data = &cmx2xx_gpio_led_pdata,
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
156
  	},
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
157
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
158
  static void __init cmx2xx_init_leds(void)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
159
  {
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
160
161
162
163
164
165
166
  	if (cpu_is_pxa25x()) {
  		cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
  		cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
  	} else {
  		cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
  		cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
  	}
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
167
  	platform_device_register(&cmx2xx_led_device);
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
168
169
  }
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
170
  static inline void cmx2xx_init_leds(void) {}
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
171
  #endif
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
172
  #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
  /*
    Display definitions
    keep these for backwards compatibility, although symbolic names (as
    e.g. in lpd270.c) looks better
  */
  #define MTYPE_STN320x240	0
  #define MTYPE_TFT640x480	1
  #define MTYPE_CRT640x480	2
  #define MTYPE_CRT800x600	3
  #define MTYPE_TFT320x240	6
  #define MTYPE_STN640x480	7
  
  static struct pxafb_mode_info generic_stn_320x240_mode = {
  	.pixclock	= 76923,
  	.bpp		= 8,
  	.xres		= 320,
  	.yres		= 240,
  	.hsync_len	= 3,
  	.vsync_len	= 2,
  	.left_margin	= 3,
  	.upper_margin	= 0,
  	.right_margin	= 3,
  	.lower_margin	= 0,
  	.sync		= (FB_SYNC_HOR_HIGH_ACT |
  			   FB_SYNC_VERT_HIGH_ACT),
  	.cmap_greyscale = 0,
  };
  
  static struct pxafb_mach_info generic_stn_320x240 = {
  	.modes		= &generic_stn_320x240_mode,
  	.num_modes	= 1,
9587319bf   Eric Miao   [ARM] pxa: conver...
204
205
  	.lcd_conn	= LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
  			  LCD_AC_BIAS_FREQ(0xff),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
  	.cmap_inverse	= 0,
  	.cmap_static	= 0,
  };
  
  static struct pxafb_mode_info generic_tft_640x480_mode = {
  	.pixclock	= 38461,
  	.bpp		= 8,
  	.xres		= 640,
  	.yres		= 480,
  	.hsync_len	= 60,
  	.vsync_len	= 2,
  	.left_margin	= 70,
  	.upper_margin	= 10,
  	.right_margin	= 70,
  	.lower_margin	= 5,
  	.sync		= 0,
  	.cmap_greyscale = 0,
  };
  
  static struct pxafb_mach_info generic_tft_640x480 = {
  	.modes		= &generic_tft_640x480_mode,
  	.num_modes	= 1,
9587319bf   Eric Miao   [ARM] pxa: conver...
228
229
  	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
  			  LCD_AC_BIAS_FREQ(0xff),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
  	.cmap_inverse	= 0,
  	.cmap_static	= 0,
  };
  
  static struct pxafb_mode_info generic_crt_640x480_mode = {
  	.pixclock	= 38461,
  	.bpp		= 8,
  	.xres		= 640,
  	.yres		= 480,
  	.hsync_len	= 63,
  	.vsync_len	= 2,
  	.left_margin	= 81,
  	.upper_margin	= 33,
  	.right_margin	= 16,
  	.lower_margin	= 10,
  	.sync		= (FB_SYNC_HOR_HIGH_ACT |
  			   FB_SYNC_VERT_HIGH_ACT),
  	.cmap_greyscale = 0,
  };
  
  static struct pxafb_mach_info generic_crt_640x480 = {
  	.modes		= &generic_crt_640x480_mode,
  	.num_modes	= 1,
9587319bf   Eric Miao   [ARM] pxa: conver...
253
  	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
  	.cmap_inverse	= 0,
  	.cmap_static	= 0,
  };
  
  static struct pxafb_mode_info generic_crt_800x600_mode = {
  	.pixclock	= 28846,
  	.bpp		= 8,
  	.xres		= 800,
  	.yres	  	= 600,
  	.hsync_len	= 63,
  	.vsync_len	= 2,
  	.left_margin	= 26,
  	.upper_margin	= 21,
  	.right_margin	= 26,
  	.lower_margin	= 11,
  	.sync		= (FB_SYNC_HOR_HIGH_ACT |
  			   FB_SYNC_VERT_HIGH_ACT),
  	.cmap_greyscale = 0,
  };
  
  static struct pxafb_mach_info generic_crt_800x600 = {
  	.modes		= &generic_crt_800x600_mode,
  	.num_modes	= 1,
9587319bf   Eric Miao   [ARM] pxa: conver...
277
  	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
  	.cmap_inverse	= 0,
  	.cmap_static	= 0,
  };
  
  static struct pxafb_mode_info generic_tft_320x240_mode = {
  	.pixclock	= 134615,
  	.bpp		= 16,
  	.xres		= 320,
  	.yres		= 240,
  	.hsync_len	= 63,
  	.vsync_len	= 7,
  	.left_margin	= 75,
  	.upper_margin	= 0,
  	.right_margin	= 15,
  	.lower_margin	= 15,
  	.sync		= 0,
  	.cmap_greyscale = 0,
  };
  
  static struct pxafb_mach_info generic_tft_320x240 = {
  	.modes		= &generic_tft_320x240_mode,
  	.num_modes	= 1,
9587319bf   Eric Miao   [ARM] pxa: conver...
300
  	.lcd_conn	= LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
  	.cmap_inverse	= 0,
  	.cmap_static	= 0,
  };
  
  static struct pxafb_mode_info generic_stn_640x480_mode = {
  	.pixclock	= 57692,
  	.bpp		= 8,
  	.xres		= 640,
  	.yres		= 480,
  	.hsync_len	= 4,
  	.vsync_len	= 2,
  	.left_margin	= 10,
  	.upper_margin	= 5,
  	.right_margin	= 10,
  	.lower_margin	= 5,
  	.sync		= (FB_SYNC_HOR_HIGH_ACT |
  			   FB_SYNC_VERT_HIGH_ACT),
  	.cmap_greyscale = 0,
  };
  
  static struct pxafb_mach_info generic_stn_640x480 = {
  	.modes		= &generic_stn_640x480_mode,
  	.num_modes	= 1,
9587319bf   Eric Miao   [ARM] pxa: conver...
324
  	.lcd_conn	= LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
325
326
327
  	.cmap_inverse	= 0,
  	.cmap_static	= 0,
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
328
  static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
329

da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
330
  static int __init cmx2xx_set_display(char *str)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
331
332
333
334
  {
  	int disp_type = simple_strtol(str, NULL, 0);
  	switch (disp_type) {
  	case MTYPE_STN320x240:
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
335
  		cmx2xx_display = &generic_stn_320x240;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
336
337
  		break;
  	case MTYPE_TFT640x480:
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
338
  		cmx2xx_display = &generic_tft_640x480;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
339
340
  		break;
  	case MTYPE_CRT640x480:
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
341
  		cmx2xx_display = &generic_crt_640x480;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
342
343
  		break;
  	case MTYPE_CRT800x600:
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
344
  		cmx2xx_display = &generic_crt_800x600;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
345
346
  		break;
  	case MTYPE_TFT320x240:
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
347
  		cmx2xx_display = &generic_tft_320x240;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
348
349
  		break;
  	case MTYPE_STN640x480:
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
350
  		cmx2xx_display = &generic_stn_640x480;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
351
352
  		break;
  	default: /* fallback to CRT 640x480 */
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
353
  		cmx2xx_display = &generic_crt_640x480;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
354
355
356
357
358
359
360
361
  		break;
  	}
  	return 1;
  }
  
  /*
     This should be done really early to get proper configuration for
     frame buffer.
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
362
     Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
363
364
365
     has limitied line length for kernel command line, and also it will
     break compatibitlty with proprietary releases already in field.
  */
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
366
  __setup("monitor=", cmx2xx_set_display);
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
367

da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
368
  static void __init cmx2xx_init_display(void)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
369
  {
4321e1a12   Russell King - ARM Linux   ARM: pxa: clean u...
370
  	pxa_set_fb_info(NULL, cmx2xx_display);
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
371
372
  }
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
373
  static inline void cmx2xx_init_display(void) {}
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
374
  #endif
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
375
376
  #ifdef CONFIG_PM
  static unsigned long sleep_save_msc[10];
2eaa03b5b   Rafael J. Wysocki   ARM / PXA: Use st...
377
  static int cmx2xx_suspend(void)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
378
  {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
379
  	cmx2xx_pci_suspend();
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
380
381
  
  	/* save MSC registers */
ad68bb9f7   Marek Vasut   ARM: pxa: Access ...
382
383
384
  	sleep_save_msc[0] = __raw_readl(MSC0);
  	sleep_save_msc[1] = __raw_readl(MSC1);
  	sleep_save_msc[2] = __raw_readl(MSC2);
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
  
  	/* setup power saving mode registers */
  	PCFR = 0x0;
  	PSLR = 0xff400000;
  	PMCR  = 0x00000005;
  	PWER  = 0x80000000;
  	PFER  = 0x00000000;
  	PRER  = 0x00000000;
  	PGSR0 = 0xC0018800;
  	PGSR1 = 0x004F0002;
  	PGSR2 = 0x6021C000;
  	PGSR3 = 0x00020000;
  
  	return 0;
  }
2eaa03b5b   Rafael J. Wysocki   ARM / PXA: Use st...
400
  static void cmx2xx_resume(void)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
401
  {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
402
  	cmx2xx_pci_resume();
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
403
404
  
  	/* restore MSC registers */
ad68bb9f7   Marek Vasut   ARM: pxa: Access ...
405
406
407
  	__raw_writel(sleep_save_msc[0], MSC0);
  	__raw_writel(sleep_save_msc[1], MSC1);
  	__raw_writel(sleep_save_msc[2], MSC2);
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
408
  }
2eaa03b5b   Rafael J. Wysocki   ARM / PXA: Use st...
409
  static struct syscore_ops cmx2xx_pm_syscore_ops = {
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
410
411
  	.resume = cmx2xx_resume,
  	.suspend = cmx2xx_suspend,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
412
  };
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
413
  static int __init cmx2xx_pm_init(void)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
414
  {
2eaa03b5b   Rafael J. Wysocki   ARM / PXA: Use st...
415
416
417
  	register_syscore_ops(&cmx2xx_pm_syscore_ops);
  
  	return 0;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
418
419
  }
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
420
  static int __init cmx2xx_pm_init(void) { return 0; }
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
421
  #endif
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
422
  #if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
423
  static void __init cmx2xx_init_ac97(void)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
424
  {
9f19d6382   Mark Brown   [ARM] 5085/2: PXA...
425
  	pxa_set_ac97_info(NULL);
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
426
427
  }
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
428
  static inline void cmx2xx_init_ac97(void) {}
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
429
  #endif
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
430

da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
431
432
  static void __init cmx2xx_init(void)
  {
cc155c6f2   Russell King   [ARM] pxa: allow ...
433
434
435
  	pxa_set_ffuart_info(NULL);
  	pxa_set_btuart_info(NULL);
  	pxa_set_stuart_info(NULL);
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
436
  	cmx2xx_pm_init();
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
437
438
439
440
  	if (cpu_is_pxa25x())
  		cmx255_init();
  	else
  		cmx270_init();
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
441
442
443
444
445
446
  
  	cmx2xx_init_dm9000();
  	cmx2xx_init_display();
  	cmx2xx_init_ac97();
  	cmx2xx_init_touchscreen();
  	cmx2xx_init_leds();
a927ef895   Robert Jarzmik   ARM: pxa: fix dm9...
447
448
  
  	regulator_has_full_constraints();
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
449
450
451
  }
  
  static void __init cmx2xx_init_irq(void)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
452
  {
a7f3f0309   Mike Rapoport   [ARM] 5282/1: pxa...
453
454
455
456
457
458
459
  	if (cpu_is_pxa25x()) {
  		pxa25x_init_irq();
  		cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
  	} else {
  		pxa27x_init_irq();
  		cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
  	}
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
460
  }
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
461

2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
462
463
  #ifdef CONFIG_PCI
  /* Map PCI companion statically */
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
464
  static struct map_desc cmx2xx_io_desc[] __initdata = {
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
465
  	[0] = { /* PCI bridge */
97b09da4e   Arnd Bergmann   ARM: pxa: use cor...
466
  		.virtual	= (unsigned long)CMX2XX_IT8152_VIRT,
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
467
468
469
470
471
  		.pfn		= __phys_to_pfn(PXA_CS4_PHYS),
  		.length		= SZ_64M,
  		.type		= MT_DEVICE
  	},
  };
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
472

da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
473
  static void __init cmx2xx_map_io(void)
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
474
  {
851982c1b   Marek Vasut   ARM: pxa: Introdu...
475
476
477
478
479
  	if (cpu_is_pxa25x())
  		pxa25x_map_io();
  
  	if (cpu_is_pxa27x())
  		pxa27x_map_io();
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
480
  	iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
481

da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
482
  	it8152_base_address = CMX2XX_IT8152_VIRT;
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
483
  }
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
484
  #else
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
485
  static void __init cmx2xx_map_io(void)
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
486
  {
851982c1b   Marek Vasut   ARM: pxa: Introdu...
487
488
489
490
491
  	if (cpu_is_pxa25x())
  		pxa25x_map_io();
  
  	if (cpu_is_pxa27x())
  		pxa27x_map_io();
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
492
  }
2f01a9737   Mike Rapoport   [ARM] 5103/2: CM-...
493
  #endif
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
494

da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
495
  MACHINE_START(ARMCORE, "Compulab CM-X2XX")
7375aba67   Nicolas Pitre   ARM: mach-pxa: co...
496
  	.atag_offset	= 0x100,
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
497
  	.map_io		= cmx2xx_map_io,
6ac6b817f   Haojian Zhuang   ARM: pxa: encode ...
498
  	.nr_irqs	= CMX2XX_NR_IRQS,
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
499
  	.init_irq	= cmx2xx_init_irq,
8a97ae2f5   Eric Miao   ARM: pxa: enable ...
500
501
  	/* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
  	.handle_irq	= pxa25x_handle_irq,
6bb27d734   Stephen Warren   ARM: delete struc...
502
  	.init_time	= pxa_timer_init,
da591937b   Mike Rapoport   [ARM] 5280/1: pxa...
503
  	.init_machine	= cmx2xx_init,
805e88dc4   Nicolas Pitre   ARM: mach-pxa: mo...
504
505
506
  #ifdef CONFIG_PCI
  	.dma_zone_size	= SZ_64M,
  #endif
271a74fc8   Russell King   ARM: restart: pxa...
507
  	.restart	= pxa_restart,
3696a8a42   Mike Rapoport   [ARM] 4576/1: CM-...
508
  MACHINE_END