Linux Audio

Check our new training course

Loading...
v3.5.6
 
  1/*
  2 * linux/arch/arm/mach-pxa/cm-x2xx.c
  3 *
  4 * Copyright (C) 2008 CompuLab, Ltd.
  5 * 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
 12#include <linux/platform_device.h>
 13#include <linux/syscore_ops.h>
 14#include <linux/irq.h>
 15#include <linux/gpio.h>
 
 16
 17#include <linux/dm9000.h>
 18#include <linux/leds.h>
 19
 20#include <asm/mach/arch.h>
 21#include <asm/mach-types.h>
 22#include <asm/mach/map.h>
 23
 24#include <mach/pxa25x.h>
 25#include <mach/pxa27x.h>
 
 
 
 
 
 
 
 
 
 
 26#include <mach/audio.h>
 27#include <mach/pxafb.h>
 28#include <mach/smemc.h>
 29
 30#include <asm/hardware/it8152.h>
 31
 32#include "generic.h"
 33#include "cm-x2xx-pci.h"
 34
 35extern void cmx255_init(void);
 36extern void cmx270_init(void);
 37
 38/* reserve IRQs for IT8152 */
 39#define CMX2XX_NR_IRQS		(IRQ_BOARD_START + 40)
 40
 41/* virtual addresses for statically mapped regions */
 42#define CMX2XX_VIRT_BASE	(void __iomem *)(0xe8000000)
 43#define CMX2XX_IT8152_VIRT	(CMX2XX_VIRT_BASE)
 44
 45/* physical address if local-bus attached devices */
 46#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
 47#define CMX270_DM9000_PHYS_BASE	(PXA_CS1_PHYS + (6 << 22))
 48
 49/* leds */
 50#define CMX255_GPIO_RED		(27)
 51#define CMX255_GPIO_GREEN	(32)
 52#define CMX270_GPIO_RED		(93)
 53#define CMX270_GPIO_GREEN	(94)
 54
 55/* GPIO IRQ usage */
 56#define GPIO22_ETHIRQ		(22)
 57#define GPIO10_ETHIRQ		(10)
 58#define CMX255_GPIO_IT8152_IRQ	(0)
 59#define CMX270_GPIO_IT8152_IRQ	(22)
 60
 61#define CMX255_ETHIRQ		PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
 62#define CMX270_ETHIRQ		PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
 63
 64#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
 65static struct resource cmx255_dm9000_resource[] = {
 66	[0] = {
 67		.start = CMX255_DM9000_PHYS_BASE,
 68		.end   = CMX255_DM9000_PHYS_BASE + 3,
 69		.flags = IORESOURCE_MEM,
 70	},
 71	[1] = {
 72		.start = CMX255_DM9000_PHYS_BASE + 4,
 73		.end   = CMX255_DM9000_PHYS_BASE + 4 + 500,
 74		.flags = IORESOURCE_MEM,
 75	},
 76	[2] = {
 77		.start = CMX255_ETHIRQ,
 78		.end   = CMX255_ETHIRQ,
 79		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 80	}
 81};
 82
 83static struct resource cmx270_dm9000_resource[] = {
 84	[0] = {
 85		.start = CMX270_DM9000_PHYS_BASE,
 86		.end   = CMX270_DM9000_PHYS_BASE + 3,
 87		.flags = IORESOURCE_MEM,
 88	},
 89	[1] = {
 90		.start = CMX270_DM9000_PHYS_BASE + 8,
 91		.end   = CMX270_DM9000_PHYS_BASE + 8 + 500,
 92		.flags = IORESOURCE_MEM,
 93	},
 94	[2] = {
 95		.start = CMX270_ETHIRQ,
 96		.end   = CMX270_ETHIRQ,
 97		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 98	}
 99};
100
101static struct dm9000_plat_data cmx270_dm9000_platdata = {
102	.flags		= DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
103};
104
105static struct platform_device cmx2xx_dm9000_device = {
106	.name		= "dm9000",
107	.id		= 0,
108	.num_resources	= ARRAY_SIZE(cmx270_dm9000_resource),
109	.dev		= {
110		.platform_data = &cmx270_dm9000_platdata,
111	}
112};
113
114static void __init cmx2xx_init_dm9000(void)
115{
116	if (cpu_is_pxa25x())
117		cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
118	else
119		cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
120	platform_device_register(&cmx2xx_dm9000_device);
121}
122#else
123static inline void cmx2xx_init_dm9000(void) {}
124#endif
125
126/* UCB1400 touchscreen controller */
127#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
128static struct platform_device cmx2xx_ts_device = {
129	.name		= "ucb1400_core",
130	.id		= -1,
131};
132
133static void __init cmx2xx_init_touchscreen(void)
134{
135	platform_device_register(&cmx2xx_ts_device);
136}
137#else
138static inline void cmx2xx_init_touchscreen(void) {}
139#endif
140
141/* CM-X270 LEDs */
142#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
143static struct gpio_led cmx2xx_leds[] = {
144	[0] = {
145		.name = "cm-x2xx:red",
146		.default_trigger = "nand-disk",
147		.active_low = 1,
148	},
149	[1] = {
150		.name = "cm-x2xx:green",
151		.default_trigger = "heartbeat",
152		.active_low = 1,
153	},
154};
155
156static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
157	.num_leds = ARRAY_SIZE(cmx2xx_leds),
158	.leds = cmx2xx_leds,
159};
160
161static struct platform_device cmx2xx_led_device = {
162	.name		= "leds-gpio",
163	.id		= -1,
164	.dev		= {
165		.platform_data = &cmx2xx_gpio_led_pdata,
166	},
167};
168
169static void __init cmx2xx_init_leds(void)
170{
171	if (cpu_is_pxa25x()) {
172		cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
173		cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
174	} else {
175		cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
176		cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
177	}
178	platform_device_register(&cmx2xx_led_device);
179}
180#else
181static inline void cmx2xx_init_leds(void) {}
182#endif
183
184#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
185/*
186  Display definitions
187  keep these for backwards compatibility, although symbolic names (as
188  e.g. in lpd270.c) looks better
189*/
190#define MTYPE_STN320x240	0
191#define MTYPE_TFT640x480	1
192#define MTYPE_CRT640x480	2
193#define MTYPE_CRT800x600	3
194#define MTYPE_TFT320x240	6
195#define MTYPE_STN640x480	7
196
197static struct pxafb_mode_info generic_stn_320x240_mode = {
198	.pixclock	= 76923,
199	.bpp		= 8,
200	.xres		= 320,
201	.yres		= 240,
202	.hsync_len	= 3,
203	.vsync_len	= 2,
204	.left_margin	= 3,
205	.upper_margin	= 0,
206	.right_margin	= 3,
207	.lower_margin	= 0,
208	.sync		= (FB_SYNC_HOR_HIGH_ACT |
209			   FB_SYNC_VERT_HIGH_ACT),
210	.cmap_greyscale = 0,
211};
212
213static struct pxafb_mach_info generic_stn_320x240 = {
214	.modes		= &generic_stn_320x240_mode,
215	.num_modes	= 1,
216	.lcd_conn	= LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
217			  LCD_AC_BIAS_FREQ(0xff),
218	.cmap_inverse	= 0,
219	.cmap_static	= 0,
220};
221
222static struct pxafb_mode_info generic_tft_640x480_mode = {
223	.pixclock	= 38461,
224	.bpp		= 8,
225	.xres		= 640,
226	.yres		= 480,
227	.hsync_len	= 60,
228	.vsync_len	= 2,
229	.left_margin	= 70,
230	.upper_margin	= 10,
231	.right_margin	= 70,
232	.lower_margin	= 5,
233	.sync		= 0,
234	.cmap_greyscale = 0,
235};
236
237static struct pxafb_mach_info generic_tft_640x480 = {
238	.modes		= &generic_tft_640x480_mode,
239	.num_modes	= 1,
240	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
241			  LCD_AC_BIAS_FREQ(0xff),
242	.cmap_inverse	= 0,
243	.cmap_static	= 0,
244};
245
246static struct pxafb_mode_info generic_crt_640x480_mode = {
247	.pixclock	= 38461,
248	.bpp		= 8,
249	.xres		= 640,
250	.yres		= 480,
251	.hsync_len	= 63,
252	.vsync_len	= 2,
253	.left_margin	= 81,
254	.upper_margin	= 33,
255	.right_margin	= 16,
256	.lower_margin	= 10,
257	.sync		= (FB_SYNC_HOR_HIGH_ACT |
258			   FB_SYNC_VERT_HIGH_ACT),
259	.cmap_greyscale = 0,
260};
261
262static struct pxafb_mach_info generic_crt_640x480 = {
263	.modes		= &generic_crt_640x480_mode,
264	.num_modes	= 1,
265	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
266	.cmap_inverse	= 0,
267	.cmap_static	= 0,
268};
269
270static struct pxafb_mode_info generic_crt_800x600_mode = {
271	.pixclock	= 28846,
272	.bpp		= 8,
273	.xres		= 800,
274	.yres	  	= 600,
275	.hsync_len	= 63,
276	.vsync_len	= 2,
277	.left_margin	= 26,
278	.upper_margin	= 21,
279	.right_margin	= 26,
280	.lower_margin	= 11,
281	.sync		= (FB_SYNC_HOR_HIGH_ACT |
282			   FB_SYNC_VERT_HIGH_ACT),
283	.cmap_greyscale = 0,
284};
285
286static struct pxafb_mach_info generic_crt_800x600 = {
287	.modes		= &generic_crt_800x600_mode,
288	.num_modes	= 1,
289	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
290	.cmap_inverse	= 0,
291	.cmap_static	= 0,
292};
293
294static struct pxafb_mode_info generic_tft_320x240_mode = {
295	.pixclock	= 134615,
296	.bpp		= 16,
297	.xres		= 320,
298	.yres		= 240,
299	.hsync_len	= 63,
300	.vsync_len	= 7,
301	.left_margin	= 75,
302	.upper_margin	= 0,
303	.right_margin	= 15,
304	.lower_margin	= 15,
305	.sync		= 0,
306	.cmap_greyscale = 0,
307};
308
309static struct pxafb_mach_info generic_tft_320x240 = {
310	.modes		= &generic_tft_320x240_mode,
311	.num_modes	= 1,
312	.lcd_conn	= LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
313	.cmap_inverse	= 0,
314	.cmap_static	= 0,
315};
316
317static struct pxafb_mode_info generic_stn_640x480_mode = {
318	.pixclock	= 57692,
319	.bpp		= 8,
320	.xres		= 640,
321	.yres		= 480,
322	.hsync_len	= 4,
323	.vsync_len	= 2,
324	.left_margin	= 10,
325	.upper_margin	= 5,
326	.right_margin	= 10,
327	.lower_margin	= 5,
328	.sync		= (FB_SYNC_HOR_HIGH_ACT |
329			   FB_SYNC_VERT_HIGH_ACT),
330	.cmap_greyscale = 0,
331};
332
333static struct pxafb_mach_info generic_stn_640x480 = {
334	.modes		= &generic_stn_640x480_mode,
335	.num_modes	= 1,
336	.lcd_conn	= LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
337	.cmap_inverse	= 0,
338	.cmap_static	= 0,
339};
340
341static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
342
343static int __init cmx2xx_set_display(char *str)
344{
345	int disp_type = simple_strtol(str, NULL, 0);
346	switch (disp_type) {
347	case MTYPE_STN320x240:
348		cmx2xx_display = &generic_stn_320x240;
349		break;
350	case MTYPE_TFT640x480:
351		cmx2xx_display = &generic_tft_640x480;
352		break;
353	case MTYPE_CRT640x480:
354		cmx2xx_display = &generic_crt_640x480;
355		break;
356	case MTYPE_CRT800x600:
357		cmx2xx_display = &generic_crt_800x600;
358		break;
359	case MTYPE_TFT320x240:
360		cmx2xx_display = &generic_tft_320x240;
361		break;
362	case MTYPE_STN640x480:
363		cmx2xx_display = &generic_stn_640x480;
364		break;
365	default: /* fallback to CRT 640x480 */
366		cmx2xx_display = &generic_crt_640x480;
367		break;
368	}
369	return 1;
370}
371
372/*
373   This should be done really early to get proper configuration for
374   frame buffer.
375   Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
376   has limitied line length for kernel command line, and also it will
377   break compatibitlty with proprietary releases already in field.
378*/
379__setup("monitor=", cmx2xx_set_display);
380
381static void __init cmx2xx_init_display(void)
382{
383	pxa_set_fb_info(NULL, cmx2xx_display);
384}
385#else
386static inline void cmx2xx_init_display(void) {}
387#endif
388
389#ifdef CONFIG_PM
390static unsigned long sleep_save_msc[10];
391
392static int cmx2xx_suspend(void)
393{
394	cmx2xx_pci_suspend();
395
396	/* save MSC registers */
397	sleep_save_msc[0] = __raw_readl(MSC0);
398	sleep_save_msc[1] = __raw_readl(MSC1);
399	sleep_save_msc[2] = __raw_readl(MSC2);
400
401	/* setup power saving mode registers */
402	PCFR = 0x0;
403	PSLR = 0xff400000;
404	PMCR  = 0x00000005;
405	PWER  = 0x80000000;
406	PFER  = 0x00000000;
407	PRER  = 0x00000000;
408	PGSR0 = 0xC0018800;
409	PGSR1 = 0x004F0002;
410	PGSR2 = 0x6021C000;
411	PGSR3 = 0x00020000;
412
413	return 0;
414}
415
416static void cmx2xx_resume(void)
417{
418	cmx2xx_pci_resume();
419
420	/* restore MSC registers */
421	__raw_writel(sleep_save_msc[0], MSC0);
422	__raw_writel(sleep_save_msc[1], MSC1);
423	__raw_writel(sleep_save_msc[2], MSC2);
424}
425
426static struct syscore_ops cmx2xx_pm_syscore_ops = {
427	.resume = cmx2xx_resume,
428	.suspend = cmx2xx_suspend,
429};
430
431static int __init cmx2xx_pm_init(void)
432{
433	register_syscore_ops(&cmx2xx_pm_syscore_ops);
434
435	return 0;
436}
437#else
438static int __init cmx2xx_pm_init(void) { return 0; }
439#endif
440
441#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
442static void __init cmx2xx_init_ac97(void)
443{
444	pxa_set_ac97_info(NULL);
445}
446#else
447static inline void cmx2xx_init_ac97(void) {}
448#endif
449
450static void __init cmx2xx_init(void)
451{
452	pxa_set_ffuart_info(NULL);
453	pxa_set_btuart_info(NULL);
454	pxa_set_stuart_info(NULL);
455
456	cmx2xx_pm_init();
457
458	if (cpu_is_pxa25x())
459		cmx255_init();
460	else
461		cmx270_init();
462
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)
471{
472	if (cpu_is_pxa25x()) {
473		pxa25x_init_irq();
474		cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
475	} else {
476		pxa27x_init_irq();
477		cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
478	}
479}
480
481#ifdef CONFIG_PCI
482/* Map PCI companion statically */
483static struct map_desc cmx2xx_io_desc[] __initdata = {
484	[0] = { /* PCI bridge */
485		.virtual	= (unsigned long)CMX2XX_IT8152_VIRT,
486		.pfn		= __phys_to_pfn(PXA_CS4_PHYS),
487		.length		= SZ_64M,
488		.type		= MT_DEVICE
489	},
490};
491
492static void __init cmx2xx_map_io(void)
493{
494	if (cpu_is_pxa25x())
495		pxa25x_map_io();
496
497	if (cpu_is_pxa27x())
498		pxa27x_map_io();
499
500	iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
501
502	it8152_base_address = CMX2XX_IT8152_VIRT;
503}
504#else
505static void __init cmx2xx_map_io(void)
506{
507	if (cpu_is_pxa25x())
508		pxa25x_map_io();
509
510	if (cpu_is_pxa27x())
511		pxa27x_map_io();
512}
513#endif
514
515MACHINE_START(ARMCORE, "Compulab CM-X2XX")
516	.atag_offset	= 0x100,
517	.map_io		= cmx2xx_map_io,
518	.nr_irqs	= CMX2XX_NR_IRQS,
519	.init_irq	= cmx2xx_init_irq,
520	/* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
521	.handle_irq	= pxa25x_handle_irq,
522	.timer		= &pxa_timer,
523	.init_machine	= cmx2xx_init,
524#ifdef CONFIG_PCI
525	.dma_zone_size	= SZ_64M,
526#endif
527	.restart	= pxa_restart,
528MACHINE_END
v5.4
  1// SPDX-License-Identifier: GPL-2.0-only
  2/*
  3 * linux/arch/arm/mach-pxa/cm-x2xx.c
  4 *
  5 * Copyright (C) 2008 CompuLab, Ltd.
  6 * Mike Rapoport <mike@compulab.co.il>
 
 
 
 
  7 */
  8
  9#include <linux/platform_device.h>
 10#include <linux/syscore_ops.h>
 11#include <linux/irq.h>
 12#include <linux/gpio.h>
 13#include <linux/regulator/machine.h>
 14
 15#include <linux/dm9000.h>
 16#include <linux/leds.h>
 17
 18#include <asm/mach/arch.h>
 19#include <asm/mach-types.h>
 20#include <asm/mach/map.h>
 21
 22#include "pxa25x.h"
 23#undef GPIO24_SSP1_SFRM
 24#undef GPIO86_GPIO
 25#undef GPIO87_GPIO
 26#undef GPIO88_GPIO
 27#undef GPIO89_GPIO
 28#include "pxa27x.h"
 29#undef GPIO24_SSP1_SFRM
 30#undef GPIO86_GPIO
 31#undef GPIO87_GPIO
 32#undef GPIO88_GPIO
 33#undef GPIO89_GPIO
 34#include <mach/audio.h>
 35#include <linux/platform_data/video-pxafb.h>
 36#include <mach/smemc.h>
 37
 38#include <asm/hardware/it8152.h>
 39
 40#include "generic.h"
 41#include "cm-x2xx-pci.h"
 42
 43extern void cmx255_init(void);
 44extern void cmx270_init(void);
 45
 46/* reserve IRQs for IT8152 */
 47#define CMX2XX_NR_IRQS		(IRQ_BOARD_START + 40)
 48
 49/* virtual addresses for statically mapped regions */
 50#define CMX2XX_VIRT_BASE	(void __iomem *)(0xe8000000)
 51#define CMX2XX_IT8152_VIRT	(CMX2XX_VIRT_BASE)
 52
 53/* physical address if local-bus attached devices */
 54#define CMX255_DM9000_PHYS_BASE (PXA_CS1_PHYS + (8 << 22))
 55#define CMX270_DM9000_PHYS_BASE	(PXA_CS1_PHYS + (6 << 22))
 56
 57/* leds */
 58#define CMX255_GPIO_RED		(27)
 59#define CMX255_GPIO_GREEN	(32)
 60#define CMX270_GPIO_RED		(93)
 61#define CMX270_GPIO_GREEN	(94)
 62
 63/* GPIO IRQ usage */
 64#define GPIO22_ETHIRQ		(22)
 65#define GPIO10_ETHIRQ		(10)
 66#define CMX255_GPIO_IT8152_IRQ	(0)
 67#define CMX270_GPIO_IT8152_IRQ	(22)
 68
 69#define CMX255_ETHIRQ		PXA_GPIO_TO_IRQ(GPIO22_ETHIRQ)
 70#define CMX270_ETHIRQ		PXA_GPIO_TO_IRQ(GPIO10_ETHIRQ)
 71
 72#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
 73static struct resource cmx255_dm9000_resource[] = {
 74	[0] = {
 75		.start = CMX255_DM9000_PHYS_BASE,
 76		.end   = CMX255_DM9000_PHYS_BASE + 3,
 77		.flags = IORESOURCE_MEM,
 78	},
 79	[1] = {
 80		.start = CMX255_DM9000_PHYS_BASE + 4,
 81		.end   = CMX255_DM9000_PHYS_BASE + 4 + 500,
 82		.flags = IORESOURCE_MEM,
 83	},
 84	[2] = {
 85		.start = CMX255_ETHIRQ,
 86		.end   = CMX255_ETHIRQ,
 87		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
 88	}
 89};
 90
 91static struct resource cmx270_dm9000_resource[] = {
 92	[0] = {
 93		.start = CMX270_DM9000_PHYS_BASE,
 94		.end   = CMX270_DM9000_PHYS_BASE + 3,
 95		.flags = IORESOURCE_MEM,
 96	},
 97	[1] = {
 98		.start = CMX270_DM9000_PHYS_BASE + 8,
 99		.end   = CMX270_DM9000_PHYS_BASE + 8 + 500,
100		.flags = IORESOURCE_MEM,
101	},
102	[2] = {
103		.start = CMX270_ETHIRQ,
104		.end   = CMX270_ETHIRQ,
105		.flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
106	}
107};
108
109static struct dm9000_plat_data cmx270_dm9000_platdata = {
110	.flags		= DM9000_PLATF_32BITONLY | DM9000_PLATF_NO_EEPROM,
111};
112
113static struct platform_device cmx2xx_dm9000_device = {
114	.name		= "dm9000",
115	.id		= 0,
116	.num_resources	= ARRAY_SIZE(cmx270_dm9000_resource),
117	.dev		= {
118		.platform_data = &cmx270_dm9000_platdata,
119	}
120};
121
122static void __init cmx2xx_init_dm9000(void)
123{
124	if (cpu_is_pxa25x())
125		cmx2xx_dm9000_device.resource = cmx255_dm9000_resource;
126	else
127		cmx2xx_dm9000_device.resource = cmx270_dm9000_resource;
128	platform_device_register(&cmx2xx_dm9000_device);
129}
130#else
131static inline void cmx2xx_init_dm9000(void) {}
132#endif
133
134/* UCB1400 touchscreen controller */
135#if defined(CONFIG_TOUCHSCREEN_UCB1400) || defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
136static struct platform_device cmx2xx_ts_device = {
137	.name		= "ucb1400_core",
138	.id		= -1,
139};
140
141static void __init cmx2xx_init_touchscreen(void)
142{
143	platform_device_register(&cmx2xx_ts_device);
144}
145#else
146static inline void cmx2xx_init_touchscreen(void) {}
147#endif
148
149/* CM-X270 LEDs */
150#if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
151static struct gpio_led cmx2xx_leds[] = {
152	[0] = {
153		.name = "cm-x2xx:red",
154		.default_trigger = "nand-disk",
155		.active_low = 1,
156	},
157	[1] = {
158		.name = "cm-x2xx:green",
159		.default_trigger = "heartbeat",
160		.active_low = 1,
161	},
162};
163
164static struct gpio_led_platform_data cmx2xx_gpio_led_pdata = {
165	.num_leds = ARRAY_SIZE(cmx2xx_leds),
166	.leds = cmx2xx_leds,
167};
168
169static struct platform_device cmx2xx_led_device = {
170	.name		= "leds-gpio",
171	.id		= -1,
172	.dev		= {
173		.platform_data = &cmx2xx_gpio_led_pdata,
174	},
175};
176
177static void __init cmx2xx_init_leds(void)
178{
179	if (cpu_is_pxa25x()) {
180		cmx2xx_leds[0].gpio = CMX255_GPIO_RED;
181		cmx2xx_leds[1].gpio = CMX255_GPIO_GREEN;
182	} else {
183		cmx2xx_leds[0].gpio = CMX270_GPIO_RED;
184		cmx2xx_leds[1].gpio = CMX270_GPIO_GREEN;
185	}
186	platform_device_register(&cmx2xx_led_device);
187}
188#else
189static inline void cmx2xx_init_leds(void) {}
190#endif
191
192#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
193/*
194  Display definitions
195  keep these for backwards compatibility, although symbolic names (as
196  e.g. in lpd270.c) looks better
197*/
198#define MTYPE_STN320x240	0
199#define MTYPE_TFT640x480	1
200#define MTYPE_CRT640x480	2
201#define MTYPE_CRT800x600	3
202#define MTYPE_TFT320x240	6
203#define MTYPE_STN640x480	7
204
205static struct pxafb_mode_info generic_stn_320x240_mode = {
206	.pixclock	= 76923,
207	.bpp		= 8,
208	.xres		= 320,
209	.yres		= 240,
210	.hsync_len	= 3,
211	.vsync_len	= 2,
212	.left_margin	= 3,
213	.upper_margin	= 0,
214	.right_margin	= 3,
215	.lower_margin	= 0,
216	.sync		= (FB_SYNC_HOR_HIGH_ACT |
217			   FB_SYNC_VERT_HIGH_ACT),
218	.cmap_greyscale = 0,
219};
220
221static struct pxafb_mach_info generic_stn_320x240 = {
222	.modes		= &generic_stn_320x240_mode,
223	.num_modes	= 1,
224	.lcd_conn	= LCD_COLOR_STN_8BPP | LCD_PCLK_EDGE_FALL |\
225			  LCD_AC_BIAS_FREQ(0xff),
226	.cmap_inverse	= 0,
227	.cmap_static	= 0,
228};
229
230static struct pxafb_mode_info generic_tft_640x480_mode = {
231	.pixclock	= 38461,
232	.bpp		= 8,
233	.xres		= 640,
234	.yres		= 480,
235	.hsync_len	= 60,
236	.vsync_len	= 2,
237	.left_margin	= 70,
238	.upper_margin	= 10,
239	.right_margin	= 70,
240	.lower_margin	= 5,
241	.sync		= 0,
242	.cmap_greyscale = 0,
243};
244
245static struct pxafb_mach_info generic_tft_640x480 = {
246	.modes		= &generic_tft_640x480_mode,
247	.num_modes	= 1,
248	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_PCLK_EDGE_FALL |\
249			  LCD_AC_BIAS_FREQ(0xff),
250	.cmap_inverse	= 0,
251	.cmap_static	= 0,
252};
253
254static struct pxafb_mode_info generic_crt_640x480_mode = {
255	.pixclock	= 38461,
256	.bpp		= 8,
257	.xres		= 640,
258	.yres		= 480,
259	.hsync_len	= 63,
260	.vsync_len	= 2,
261	.left_margin	= 81,
262	.upper_margin	= 33,
263	.right_margin	= 16,
264	.lower_margin	= 10,
265	.sync		= (FB_SYNC_HOR_HIGH_ACT |
266			   FB_SYNC_VERT_HIGH_ACT),
267	.cmap_greyscale = 0,
268};
269
270static struct pxafb_mach_info generic_crt_640x480 = {
271	.modes		= &generic_crt_640x480_mode,
272	.num_modes	= 1,
273	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
274	.cmap_inverse	= 0,
275	.cmap_static	= 0,
276};
277
278static struct pxafb_mode_info generic_crt_800x600_mode = {
279	.pixclock	= 28846,
280	.bpp		= 8,
281	.xres		= 800,
282	.yres	  	= 600,
283	.hsync_len	= 63,
284	.vsync_len	= 2,
285	.left_margin	= 26,
286	.upper_margin	= 21,
287	.right_margin	= 26,
288	.lower_margin	= 11,
289	.sync		= (FB_SYNC_HOR_HIGH_ACT |
290			   FB_SYNC_VERT_HIGH_ACT),
291	.cmap_greyscale = 0,
292};
293
294static struct pxafb_mach_info generic_crt_800x600 = {
295	.modes		= &generic_crt_800x600_mode,
296	.num_modes	= 1,
297	.lcd_conn	= LCD_COLOR_TFT_8BPP | LCD_AC_BIAS_FREQ(0xff),
298	.cmap_inverse	= 0,
299	.cmap_static	= 0,
300};
301
302static struct pxafb_mode_info generic_tft_320x240_mode = {
303	.pixclock	= 134615,
304	.bpp		= 16,
305	.xres		= 320,
306	.yres		= 240,
307	.hsync_len	= 63,
308	.vsync_len	= 7,
309	.left_margin	= 75,
310	.upper_margin	= 0,
311	.right_margin	= 15,
312	.lower_margin	= 15,
313	.sync		= 0,
314	.cmap_greyscale = 0,
315};
316
317static struct pxafb_mach_info generic_tft_320x240 = {
318	.modes		= &generic_tft_320x240_mode,
319	.num_modes	= 1,
320	.lcd_conn	= LCD_COLOR_TFT_16BPP | LCD_AC_BIAS_FREQ(0xff),
321	.cmap_inverse	= 0,
322	.cmap_static	= 0,
323};
324
325static struct pxafb_mode_info generic_stn_640x480_mode = {
326	.pixclock	= 57692,
327	.bpp		= 8,
328	.xres		= 640,
329	.yres		= 480,
330	.hsync_len	= 4,
331	.vsync_len	= 2,
332	.left_margin	= 10,
333	.upper_margin	= 5,
334	.right_margin	= 10,
335	.lower_margin	= 5,
336	.sync		= (FB_SYNC_HOR_HIGH_ACT |
337			   FB_SYNC_VERT_HIGH_ACT),
338	.cmap_greyscale = 0,
339};
340
341static struct pxafb_mach_info generic_stn_640x480 = {
342	.modes		= &generic_stn_640x480_mode,
343	.num_modes	= 1,
344	.lcd_conn	= LCD_COLOR_STN_8BPP | LCD_AC_BIAS_FREQ(0xff),
345	.cmap_inverse	= 0,
346	.cmap_static	= 0,
347};
348
349static struct pxafb_mach_info *cmx2xx_display = &generic_crt_640x480;
350
351static int __init cmx2xx_set_display(char *str)
352{
353	int disp_type = simple_strtol(str, NULL, 0);
354	switch (disp_type) {
355	case MTYPE_STN320x240:
356		cmx2xx_display = &generic_stn_320x240;
357		break;
358	case MTYPE_TFT640x480:
359		cmx2xx_display = &generic_tft_640x480;
360		break;
361	case MTYPE_CRT640x480:
362		cmx2xx_display = &generic_crt_640x480;
363		break;
364	case MTYPE_CRT800x600:
365		cmx2xx_display = &generic_crt_800x600;
366		break;
367	case MTYPE_TFT320x240:
368		cmx2xx_display = &generic_tft_320x240;
369		break;
370	case MTYPE_STN640x480:
371		cmx2xx_display = &generic_stn_640x480;
372		break;
373	default: /* fallback to CRT 640x480 */
374		cmx2xx_display = &generic_crt_640x480;
375		break;
376	}
377	return 1;
378}
379
380/*
381   This should be done really early to get proper configuration for
382   frame buffer.
383   Indeed, pxafb parameters can be used istead, but CM-X2XX bootloader
384   has limitied line length for kernel command line, and also it will
385   break compatibitlty with proprietary releases already in field.
386*/
387__setup("monitor=", cmx2xx_set_display);
388
389static void __init cmx2xx_init_display(void)
390{
391	pxa_set_fb_info(NULL, cmx2xx_display);
392}
393#else
394static inline void cmx2xx_init_display(void) {}
395#endif
396
397#ifdef CONFIG_PM
398static unsigned long sleep_save_msc[10];
399
400static int cmx2xx_suspend(void)
401{
402	cmx2xx_pci_suspend();
403
404	/* save MSC registers */
405	sleep_save_msc[0] = __raw_readl(MSC0);
406	sleep_save_msc[1] = __raw_readl(MSC1);
407	sleep_save_msc[2] = __raw_readl(MSC2);
408
409	/* setup power saving mode registers */
410	PCFR = 0x0;
411	PSLR = 0xff400000;
412	PMCR  = 0x00000005;
413	PWER  = 0x80000000;
414	PFER  = 0x00000000;
415	PRER  = 0x00000000;
416	PGSR0 = 0xC0018800;
417	PGSR1 = 0x004F0002;
418	PGSR2 = 0x6021C000;
419	PGSR3 = 0x00020000;
420
421	return 0;
422}
423
424static void cmx2xx_resume(void)
425{
426	cmx2xx_pci_resume();
427
428	/* restore MSC registers */
429	__raw_writel(sleep_save_msc[0], MSC0);
430	__raw_writel(sleep_save_msc[1], MSC1);
431	__raw_writel(sleep_save_msc[2], MSC2);
432}
433
434static struct syscore_ops cmx2xx_pm_syscore_ops = {
435	.resume = cmx2xx_resume,
436	.suspend = cmx2xx_suspend,
437};
438
439static int __init cmx2xx_pm_init(void)
440{
441	register_syscore_ops(&cmx2xx_pm_syscore_ops);
442
443	return 0;
444}
445#else
446static int __init cmx2xx_pm_init(void) { return 0; }
447#endif
448
449#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
450static void __init cmx2xx_init_ac97(void)
451{
452	pxa_set_ac97_info(NULL);
453}
454#else
455static inline void cmx2xx_init_ac97(void) {}
456#endif
457
458static void __init cmx2xx_init(void)
459{
460	pxa_set_ffuart_info(NULL);
461	pxa_set_btuart_info(NULL);
462	pxa_set_stuart_info(NULL);
463
464	cmx2xx_pm_init();
465
466	if (cpu_is_pxa25x())
467		cmx255_init();
468	else
469		cmx270_init();
470
471	cmx2xx_init_dm9000();
472	cmx2xx_init_display();
473	cmx2xx_init_ac97();
474	cmx2xx_init_touchscreen();
475	cmx2xx_init_leds();
476
477	regulator_has_full_constraints();
478}
479
480static void __init cmx2xx_init_irq(void)
481{
482	if (cpu_is_pxa25x()) {
483		pxa25x_init_irq();
484		cmx2xx_pci_init_irq(CMX255_GPIO_IT8152_IRQ);
485	} else {
486		pxa27x_init_irq();
487		cmx2xx_pci_init_irq(CMX270_GPIO_IT8152_IRQ);
488	}
489}
490
491#ifdef CONFIG_PCI
492/* Map PCI companion statically */
493static struct map_desc cmx2xx_io_desc[] __initdata = {
494	[0] = { /* PCI bridge */
495		.virtual	= (unsigned long)CMX2XX_IT8152_VIRT,
496		.pfn		= __phys_to_pfn(PXA_CS4_PHYS),
497		.length		= SZ_64M,
498		.type		= MT_DEVICE
499	},
500};
501
502static void __init cmx2xx_map_io(void)
503{
504	if (cpu_is_pxa25x())
505		pxa25x_map_io();
506
507	if (cpu_is_pxa27x())
508		pxa27x_map_io();
509
510	iotable_init(cmx2xx_io_desc, ARRAY_SIZE(cmx2xx_io_desc));
511
512	it8152_base_address = CMX2XX_IT8152_VIRT;
513}
514#else
515static void __init cmx2xx_map_io(void)
516{
517	if (cpu_is_pxa25x())
518		pxa25x_map_io();
519
520	if (cpu_is_pxa27x())
521		pxa27x_map_io();
522}
523#endif
524
525MACHINE_START(ARMCORE, "Compulab CM-X2XX")
526	.atag_offset	= 0x100,
527	.map_io		= cmx2xx_map_io,
528	.nr_irqs	= CMX2XX_NR_IRQS,
529	.init_irq	= cmx2xx_init_irq,
530	/* NOTE: pxa25x_handle_irq() works on PXA27x w/o camera support */
531	.handle_irq	= pxa25x_handle_irq,
532	.init_time	= pxa_timer_init,
533	.init_machine	= cmx2xx_init,
534#ifdef CONFIG_PCI
535	.dma_zone_size	= SZ_64M,
536#endif
537	.restart	= pxa_restart,
538MACHINE_END