2 * linux/arch/arm/mach-pxa/lpd270.c
4 * Support for the LogicPD PXA270 Card Engine.
5 * Derived from the mainstone code, which carries these notices:
7 * Author: Nicolas Pitre
8 * Created: Nov 05, 2002
9 * Copyright: MontaVista Software Inc.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/sysdev.h>
19 #include <linux/interrupt.h>
20 #include <linux/sched.h>
21 #include <linux/bitops.h>
23 #include <linux/ioport.h>
24 #include <linux/mtd/mtd.h>
25 #include <linux/mtd/partitions.h>
26 #include <linux/pwm_backlight.h>
28 #include <asm/types.h>
29 #include <asm/setup.h>
30 #include <asm/memory.h>
31 #include <asm/mach-types.h>
32 #include <mach/hardware.h>
34 #include <asm/sizes.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/map.h>
38 #include <asm/mach/irq.h>
39 #include <asm/mach/flash.h>
41 #include <mach/pxa27x.h>
42 #include <mach/gpio.h>
43 #include <mach/lpd270.h>
44 #include <mach/audio.h>
45 #include <mach/pxafb.h>
47 #include <mach/irda.h>
48 #include <mach/ohci.h>
53 static unsigned long lpd270_pin_config[] __initdata = {
55 GPIO15_nCS_1, /* Mainboard Flash */
56 GPIO78_nCS_2, /* CPLD + Ethernet */
58 /* LCD - 16bpp Active TFT */
79 GPIO16_PWM0_OUT, /* Backlight */
88 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
91 static unsigned int lpd270_irq_enabled;
93 static void lpd270_mask_irq(unsigned int irq)
95 int lpd270_irq = irq - LPD270_IRQ(0);
97 __raw_writew(~(1 << lpd270_irq), LPD270_INT_STATUS);
99 lpd270_irq_enabled &= ~(1 << lpd270_irq);
100 __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
103 static void lpd270_unmask_irq(unsigned int irq)
105 int lpd270_irq = irq - LPD270_IRQ(0);
107 lpd270_irq_enabled |= 1 << lpd270_irq;
108 __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
111 static struct irq_chip lpd270_irq_chip = {
113 .ack = lpd270_mask_irq,
114 .mask = lpd270_mask_irq,
115 .unmask = lpd270_unmask_irq,
118 static void lpd270_irq_handler(unsigned int irq, struct irq_desc *desc)
120 unsigned long pending;
122 pending = __raw_readw(LPD270_INT_STATUS) & lpd270_irq_enabled;
124 GEDR(0) = GPIO_bit(0); /* clear useless edge notification */
125 if (likely(pending)) {
126 irq = LPD270_IRQ(0) + __ffs(pending);
127 generic_handle_irq(irq);
129 pending = __raw_readw(LPD270_INT_STATUS) &
135 static void __init lpd270_init_irq(void)
141 __raw_writew(0, LPD270_INT_MASK);
142 __raw_writew(0, LPD270_INT_STATUS);
144 /* setup extra LogicPD PXA270 irqs */
145 for (irq = LPD270_IRQ(2); irq <= LPD270_IRQ(4); irq++) {
146 set_irq_chip(irq, &lpd270_irq_chip);
147 set_irq_handler(irq, handle_level_irq);
148 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
150 set_irq_chained_handler(IRQ_GPIO(0), lpd270_irq_handler);
151 set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
156 static int lpd270_irq_resume(struct sys_device *dev)
158 __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
162 static struct sysdev_class lpd270_irq_sysclass = {
164 .resume = lpd270_irq_resume,
167 static struct sys_device lpd270_irq_device = {
168 .cls = &lpd270_irq_sysclass,
171 static int __init lpd270_irq_device_init(void)
174 if (machine_is_logicpd_pxa270()) {
175 ret = sysdev_class_register(&lpd270_irq_sysclass);
177 ret = sysdev_register(&lpd270_irq_device);
182 device_initcall(lpd270_irq_device_init);
186 static struct resource smc91x_resources[] = {
188 .start = LPD270_ETH_PHYS,
189 .end = (LPD270_ETH_PHYS + 0xfffff),
190 .flags = IORESOURCE_MEM,
193 .start = LPD270_ETHERNET_IRQ,
194 .end = LPD270_ETHERNET_IRQ,
195 .flags = IORESOURCE_IRQ,
199 static struct platform_device smc91x_device = {
202 .num_resources = ARRAY_SIZE(smc91x_resources),
203 .resource = smc91x_resources,
206 static struct resource lpd270_flash_resources[] = {
208 .start = PXA_CS0_PHYS,
209 .end = PXA_CS0_PHYS + SZ_64M - 1,
210 .flags = IORESOURCE_MEM,
213 .start = PXA_CS1_PHYS,
214 .end = PXA_CS1_PHYS + SZ_64M - 1,
215 .flags = IORESOURCE_MEM,
219 static struct mtd_partition lpd270_flash0_partitions[] = {
221 .name = "Bootloader",
224 .mask_flags = MTD_WRITEABLE /* force read-only */
228 .offset = 0x00040000,
230 .name = "Filesystem",
231 .size = MTDPART_SIZ_FULL,
236 static struct flash_platform_data lpd270_flash_data[2] = {
238 .name = "processor-flash",
239 .map_name = "cfi_probe",
240 .parts = lpd270_flash0_partitions,
241 .nr_parts = ARRAY_SIZE(lpd270_flash0_partitions),
243 .name = "mainboard-flash",
244 .map_name = "cfi_probe",
250 static struct platform_device lpd270_flash_device[2] = {
252 .name = "pxa2xx-flash",
255 .platform_data = &lpd270_flash_data[0],
257 .resource = &lpd270_flash_resources[0],
260 .name = "pxa2xx-flash",
263 .platform_data = &lpd270_flash_data[1],
265 .resource = &lpd270_flash_resources[1],
270 static struct platform_pwm_backlight_data lpd270_backlight_data = {
274 .pwm_period_ns = 78770,
277 static struct platform_device lpd270_backlight_device = {
278 .name = "pwm-backlight",
280 .parent = &pxa27x_device_pwm0.dev,
281 .platform_data = &lpd270_backlight_data,
285 /* 5.7" TFT QVGA (LoLo display number 1) */
286 static struct pxafb_mode_info sharp_lq057q3dc02_mode = {
293 .right_margin = 0x0a,
295 .upper_margin = 0x08,
296 .lower_margin = 0x14,
297 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
300 static struct pxafb_mach_info sharp_lq057q3dc02 = {
301 .modes = &sharp_lq057q3dc02_mode,
303 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
304 LCD_ALTERNATE_MAPPING,
307 /* 12.1" TFT SVGA (LoLo display number 2) */
308 static struct pxafb_mode_info sharp_lq121s1dg31_mode = {
315 .right_margin = 0x05,
317 .upper_margin = 0x14,
318 .lower_margin = 0x0a,
319 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
322 static struct pxafb_mach_info sharp_lq121s1dg31 = {
323 .modes = &sharp_lq121s1dg31_mode,
325 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
326 LCD_ALTERNATE_MAPPING,
329 /* 3.6" TFT QVGA (LoLo display number 3) */
330 static struct pxafb_mode_info sharp_lq036q1da01_mode = {
337 .right_margin = 0x0a,
339 .upper_margin = 0x03,
340 .lower_margin = 0x03,
341 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
344 static struct pxafb_mach_info sharp_lq036q1da01 = {
345 .modes = &sharp_lq036q1da01_mode,
347 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
348 LCD_ALTERNATE_MAPPING,
351 /* 6.4" TFT VGA (LoLo display number 5) */
352 static struct pxafb_mode_info sharp_lq64d343_mode = {
359 .right_margin = 0x19,
361 .upper_margin = 0x22,
362 .lower_margin = 0x00,
363 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
366 static struct pxafb_mach_info sharp_lq64d343 = {
367 .modes = &sharp_lq64d343_mode,
369 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
370 LCD_ALTERNATE_MAPPING,
373 /* 10.4" TFT VGA (LoLo display number 7) */
374 static struct pxafb_mode_info sharp_lq10d368_mode = {
381 .right_margin = 0x19,
383 .upper_margin = 0x22,
384 .lower_margin = 0x00,
385 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
388 static struct pxafb_mach_info sharp_lq10d368 = {
389 .modes = &sharp_lq10d368_mode,
391 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
392 LCD_ALTERNATE_MAPPING,
395 /* 3.5" TFT QVGA (LoLo display number 8) */
396 static struct pxafb_mode_info sharp_lq035q7db02_20_mode = {
403 .right_margin = 0x0a,
405 .upper_margin = 0x05,
406 .lower_margin = 0x14,
407 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
410 static struct pxafb_mach_info sharp_lq035q7db02_20 = {
411 .modes = &sharp_lq035q7db02_20_mode,
413 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
414 LCD_ALTERNATE_MAPPING,
417 static struct pxafb_mach_info *lpd270_lcd_to_use;
419 static int __init lpd270_set_lcd(char *str)
421 if (!strnicmp(str, "lq057q3dc02", 11)) {
422 lpd270_lcd_to_use = &sharp_lq057q3dc02;
423 } else if (!strnicmp(str, "lq121s1dg31", 11)) {
424 lpd270_lcd_to_use = &sharp_lq121s1dg31;
425 } else if (!strnicmp(str, "lq036q1da01", 11)) {
426 lpd270_lcd_to_use = &sharp_lq036q1da01;
427 } else if (!strnicmp(str, "lq64d343", 8)) {
428 lpd270_lcd_to_use = &sharp_lq64d343;
429 } else if (!strnicmp(str, "lq10d368", 8)) {
430 lpd270_lcd_to_use = &sharp_lq10d368;
431 } else if (!strnicmp(str, "lq035q7db02-20", 14)) {
432 lpd270_lcd_to_use = &sharp_lq035q7db02_20;
434 printk(KERN_INFO "lpd270: unknown lcd panel [%s]\n", str);
440 __setup("lcd=", lpd270_set_lcd);
442 static struct platform_device *platform_devices[] __initdata = {
444 &lpd270_backlight_device,
445 &lpd270_flash_device[0],
446 &lpd270_flash_device[1],
449 static struct pxaohci_platform_data lpd270_ohci_platform_data = {
450 .port_mode = PMM_PERPORT_MODE,
451 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
454 static void __init lpd270_init(void)
456 pxa2xx_mfp_config(ARRAY_AND_SIZE(lpd270_pin_config));
458 lpd270_flash_data[0].width = (BOOT_DEF & 1) ? 2 : 4;
459 lpd270_flash_data[1].width = 4;
462 * System bus arbiter setting:
464 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
466 ARB_CNTRL = ARB_CORE_PARK | 0x234;
468 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
470 pxa_set_ac97_info(NULL);
472 if (lpd270_lcd_to_use != NULL)
473 set_pxa_fb_info(lpd270_lcd_to_use);
475 pxa_set_ohci_info(&lpd270_ohci_platform_data);
479 static struct map_desc lpd270_io_desc[] __initdata = {
481 .virtual = LPD270_CPLD_VIRT,
482 .pfn = __phys_to_pfn(LPD270_CPLD_PHYS),
483 .length = LPD270_CPLD_SIZE,
488 static void __init lpd270_map_io(void)
491 iotable_init(lpd270_io_desc, ARRAY_SIZE(lpd270_io_desc));
493 /* for use I SRAM as framebuffer. */
498 MACHINE_START(LOGICPD_PXA270, "LogicPD PXA270 Card Engine")
499 /* Maintainer: Peter Barada */
500 .phys_io = 0x40000000,
501 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
502 .boot_params = 0xa0000100,
503 .map_io = lpd270_map_io,
504 .init_irq = lpd270_init_irq,
506 .init_machine = lpd270_init,