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/pxa-regs.h>
42 #include <mach/pxa2xx-regs.h>
43 #include <mach/mfp-pxa27x.h>
44 #include <mach/lpd270.h>
45 #include <mach/audio.h>
46 #include <mach/pxafb.h>
48 #include <mach/irda.h>
49 #include <mach/ohci.h>
54 static unsigned long lpd270_pin_config[] __initdata = {
56 GPIO15_nCS_1, /* Mainboard Flash */
57 GPIO78_nCS_2, /* CPLD + Ethernet */
59 /* LCD - 16bpp Active TFT */
80 GPIO16_PWM0_OUT, /* Backlight */
89 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
92 static unsigned int lpd270_irq_enabled;
94 static void lpd270_mask_irq(unsigned int irq)
96 int lpd270_irq = irq - LPD270_IRQ(0);
98 __raw_writew(~(1 << lpd270_irq), LPD270_INT_STATUS);
100 lpd270_irq_enabled &= ~(1 << lpd270_irq);
101 __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
104 static void lpd270_unmask_irq(unsigned int irq)
106 int lpd270_irq = irq - LPD270_IRQ(0);
108 lpd270_irq_enabled |= 1 << lpd270_irq;
109 __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
112 static struct irq_chip lpd270_irq_chip = {
114 .ack = lpd270_mask_irq,
115 .mask = lpd270_mask_irq,
116 .unmask = lpd270_unmask_irq,
119 static void lpd270_irq_handler(unsigned int irq, struct irq_desc *desc)
121 unsigned long pending;
123 pending = __raw_readw(LPD270_INT_STATUS) & lpd270_irq_enabled;
125 GEDR(0) = GPIO_bit(0); /* clear useless edge notification */
126 if (likely(pending)) {
127 irq = LPD270_IRQ(0) + __ffs(pending);
128 generic_handle_irq(irq);
130 pending = __raw_readw(LPD270_INT_STATUS) &
136 static void __init lpd270_init_irq(void)
142 __raw_writew(0, LPD270_INT_MASK);
143 __raw_writew(0, LPD270_INT_STATUS);
145 /* setup extra LogicPD PXA270 irqs */
146 for (irq = LPD270_IRQ(2); irq <= LPD270_IRQ(4); irq++) {
147 set_irq_chip(irq, &lpd270_irq_chip);
148 set_irq_handler(irq, handle_level_irq);
149 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
151 set_irq_chained_handler(IRQ_GPIO(0), lpd270_irq_handler);
152 set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
157 static int lpd270_irq_resume(struct sys_device *dev)
159 __raw_writew(lpd270_irq_enabled, LPD270_INT_MASK);
163 static struct sysdev_class lpd270_irq_sysclass = {
165 .resume = lpd270_irq_resume,
168 static struct sys_device lpd270_irq_device = {
169 .cls = &lpd270_irq_sysclass,
172 static int __init lpd270_irq_device_init(void)
175 if (machine_is_logicpd_pxa270()) {
176 ret = sysdev_class_register(&lpd270_irq_sysclass);
178 ret = sysdev_register(&lpd270_irq_device);
183 device_initcall(lpd270_irq_device_init);
187 static struct resource smc91x_resources[] = {
189 .start = LPD270_ETH_PHYS,
190 .end = (LPD270_ETH_PHYS + 0xfffff),
191 .flags = IORESOURCE_MEM,
194 .start = LPD270_ETHERNET_IRQ,
195 .end = LPD270_ETHERNET_IRQ,
196 .flags = IORESOURCE_IRQ,
200 static struct platform_device smc91x_device = {
203 .num_resources = ARRAY_SIZE(smc91x_resources),
204 .resource = smc91x_resources,
207 static struct resource lpd270_flash_resources[] = {
209 .start = PXA_CS0_PHYS,
210 .end = PXA_CS0_PHYS + SZ_64M - 1,
211 .flags = IORESOURCE_MEM,
214 .start = PXA_CS1_PHYS,
215 .end = PXA_CS1_PHYS + SZ_64M - 1,
216 .flags = IORESOURCE_MEM,
220 static struct mtd_partition lpd270_flash0_partitions[] = {
222 .name = "Bootloader",
225 .mask_flags = MTD_WRITEABLE /* force read-only */
229 .offset = 0x00040000,
231 .name = "Filesystem",
232 .size = MTDPART_SIZ_FULL,
237 static struct flash_platform_data lpd270_flash_data[2] = {
239 .name = "processor-flash",
240 .map_name = "cfi_probe",
241 .parts = lpd270_flash0_partitions,
242 .nr_parts = ARRAY_SIZE(lpd270_flash0_partitions),
244 .name = "mainboard-flash",
245 .map_name = "cfi_probe",
251 static struct platform_device lpd270_flash_device[2] = {
253 .name = "pxa2xx-flash",
256 .platform_data = &lpd270_flash_data[0],
258 .resource = &lpd270_flash_resources[0],
261 .name = "pxa2xx-flash",
264 .platform_data = &lpd270_flash_data[1],
266 .resource = &lpd270_flash_resources[1],
271 static struct platform_pwm_backlight_data lpd270_backlight_data = {
275 .pwm_period_ns = 78770,
278 static struct platform_device lpd270_backlight_device = {
279 .name = "pwm-backlight",
281 .parent = &pxa27x_device_pwm0.dev,
282 .platform_data = &lpd270_backlight_data,
286 /* 5.7" TFT QVGA (LoLo display number 1) */
287 static struct pxafb_mode_info sharp_lq057q3dc02_mode = {
294 .right_margin = 0x0a,
296 .upper_margin = 0x08,
297 .lower_margin = 0x14,
298 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
301 static struct pxafb_mach_info sharp_lq057q3dc02 = {
302 .modes = &sharp_lq057q3dc02_mode,
304 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
305 LCD_ALTERNATE_MAPPING,
308 /* 12.1" TFT SVGA (LoLo display number 2) */
309 static struct pxafb_mode_info sharp_lq121s1dg31_mode = {
316 .right_margin = 0x05,
318 .upper_margin = 0x14,
319 .lower_margin = 0x0a,
320 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
323 static struct pxafb_mach_info sharp_lq121s1dg31 = {
324 .modes = &sharp_lq121s1dg31_mode,
326 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
327 LCD_ALTERNATE_MAPPING,
330 /* 3.6" TFT QVGA (LoLo display number 3) */
331 static struct pxafb_mode_info sharp_lq036q1da01_mode = {
338 .right_margin = 0x0a,
340 .upper_margin = 0x03,
341 .lower_margin = 0x03,
342 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
345 static struct pxafb_mach_info sharp_lq036q1da01 = {
346 .modes = &sharp_lq036q1da01_mode,
348 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
349 LCD_ALTERNATE_MAPPING,
352 /* 6.4" TFT VGA (LoLo display number 5) */
353 static struct pxafb_mode_info sharp_lq64d343_mode = {
360 .right_margin = 0x19,
362 .upper_margin = 0x22,
363 .lower_margin = 0x00,
364 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
367 static struct pxafb_mach_info sharp_lq64d343 = {
368 .modes = &sharp_lq64d343_mode,
370 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
371 LCD_ALTERNATE_MAPPING,
374 /* 10.4" TFT VGA (LoLo display number 7) */
375 static struct pxafb_mode_info sharp_lq10d368_mode = {
382 .right_margin = 0x19,
384 .upper_margin = 0x22,
385 .lower_margin = 0x00,
386 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
389 static struct pxafb_mach_info sharp_lq10d368 = {
390 .modes = &sharp_lq10d368_mode,
392 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
393 LCD_ALTERNATE_MAPPING,
396 /* 3.5" TFT QVGA (LoLo display number 8) */
397 static struct pxafb_mode_info sharp_lq035q7db02_20_mode = {
404 .right_margin = 0x0a,
406 .upper_margin = 0x05,
407 .lower_margin = 0x14,
408 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
411 static struct pxafb_mach_info sharp_lq035q7db02_20 = {
412 .modes = &sharp_lq035q7db02_20_mode,
414 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL |
415 LCD_ALTERNATE_MAPPING,
418 static struct pxafb_mach_info *lpd270_lcd_to_use;
420 static int __init lpd270_set_lcd(char *str)
422 if (!strnicmp(str, "lq057q3dc02", 11)) {
423 lpd270_lcd_to_use = &sharp_lq057q3dc02;
424 } else if (!strnicmp(str, "lq121s1dg31", 11)) {
425 lpd270_lcd_to_use = &sharp_lq121s1dg31;
426 } else if (!strnicmp(str, "lq036q1da01", 11)) {
427 lpd270_lcd_to_use = &sharp_lq036q1da01;
428 } else if (!strnicmp(str, "lq64d343", 8)) {
429 lpd270_lcd_to_use = &sharp_lq64d343;
430 } else if (!strnicmp(str, "lq10d368", 8)) {
431 lpd270_lcd_to_use = &sharp_lq10d368;
432 } else if (!strnicmp(str, "lq035q7db02-20", 14)) {
433 lpd270_lcd_to_use = &sharp_lq035q7db02_20;
435 printk(KERN_INFO "lpd270: unknown lcd panel [%s]\n", str);
441 __setup("lcd=", lpd270_set_lcd);
443 static struct platform_device *platform_devices[] __initdata = {
445 &lpd270_backlight_device,
446 &lpd270_flash_device[0],
447 &lpd270_flash_device[1],
450 static struct pxaohci_platform_data lpd270_ohci_platform_data = {
451 .port_mode = PMM_PERPORT_MODE,
452 .flags = ENABLE_PORT_ALL | POWER_CONTROL_LOW | POWER_SENSE_LOW,
455 static void __init lpd270_init(void)
457 pxa2xx_mfp_config(ARRAY_AND_SIZE(lpd270_pin_config));
459 lpd270_flash_data[0].width = (BOOT_DEF & 1) ? 2 : 4;
460 lpd270_flash_data[1].width = 4;
463 * System bus arbiter setting:
465 * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4
467 ARB_CNTRL = ARB_CORE_PARK | 0x234;
469 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
471 pxa_set_ac97_info(NULL);
473 if (lpd270_lcd_to_use != NULL)
474 set_pxa_fb_info(lpd270_lcd_to_use);
476 pxa_set_ohci_info(&lpd270_ohci_platform_data);
480 static struct map_desc lpd270_io_desc[] __initdata = {
482 .virtual = LPD270_CPLD_VIRT,
483 .pfn = __phys_to_pfn(LPD270_CPLD_PHYS),
484 .length = LPD270_CPLD_SIZE,
489 static void __init lpd270_map_io(void)
492 iotable_init(lpd270_io_desc, ARRAY_SIZE(lpd270_io_desc));
494 /* for use I SRAM as framebuffer. */
499 MACHINE_START(LOGICPD_PXA270, "LogicPD PXA270 Card Engine")
500 /* Maintainer: Peter Barada */
501 .phys_io = 0x40000000,
502 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
503 .boot_params = 0xa0000100,
504 .map_io = lpd270_map_io,
505 .init_irq = lpd270_init_irq,
507 .init_machine = lpd270_init,