[ARM] 5210/2: AFEB9260: board support
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / lpd270.c
index 12479ae..b703894 100644 (file)
 #include <linux/ioport.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/pwm_backlight.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
 #include <asm/memory.h>
 #include <asm/mach-types.h>
-#include <asm/hardware.h>
+#include <mach/hardware.h>
 #include <asm/irq.h>
 #include <asm/sizes.h>
 
 #include <asm/mach/irq.h>
 #include <asm/mach/flash.h>
 
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/lpd270.h>
-#include <asm/arch/audio.h>
-#include <asm/arch/pxafb.h>
-#include <asm/arch/mmc.h>
-#include <asm/arch/irda.h>
-#include <asm/arch/ohci.h>
+#include <mach/pxa-regs.h>
+#include <mach/pxa2xx-regs.h>
+#include <mach/pxa2xx-gpio.h>
+#include <mach/lpd270.h>
+#include <mach/audio.h>
+#include <mach/pxafb.h>
+#include <mach/mmc.h>
+#include <mach/irda.h>
+#include <mach/ohci.h>
 
 #include "generic.h"
+#include "devices.h"
 
 
 static unsigned int lpd270_irq_enabled;
@@ -75,8 +79,7 @@ static struct irq_chip lpd270_irq_chip = {
        .unmask         = lpd270_unmask_irq,
 };
 
-static void lpd270_irq_handler(unsigned int irq, struct irqdesc *desc,
-                                 struct pt_regs *regs)
+static void lpd270_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long pending;
 
@@ -86,7 +89,7 @@ static void lpd270_irq_handler(unsigned int irq, struct irqdesc *desc,
                if (likely(pending)) {
                        irq = LPD270_IRQ(0) + __ffs(pending);
                        desc = irq_desc + irq;
-                       desc_handle_irq(irq, desc, regs);
+                       desc_handle_irq(irq, desc);
 
                        pending = __raw_readw(LPD270_INT_STATUS) &
                                                lpd270_irq_enabled;
@@ -98,7 +101,7 @@ static void __init lpd270_init_irq(void)
 {
        int irq;
 
-       pxa_init_irq();
+       pxa27x_init_irq();
 
        __raw_writew(0, LPD270_INT_MASK);
        __raw_writew(0, LPD270_INT_STATUS);
@@ -106,11 +109,11 @@ static void __init lpd270_init_irq(void)
        /* setup extra LogicPD PXA270 irqs */
        for (irq = LPD270_IRQ(2); irq <= LPD270_IRQ(4); irq++) {
                set_irq_chip(irq, &lpd270_irq_chip);
-               set_irq_handler(irq, do_level_IRQ);
+               set_irq_handler(irq, handle_level_irq);
                set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
        }
        set_irq_chained_handler(IRQ_GPIO(0), lpd270_irq_handler);
-       set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
+       set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
 }
 
 
@@ -122,7 +125,7 @@ static int lpd270_irq_resume(struct sys_device *dev)
 }
 
 static struct sysdev_class lpd270_irq_sysclass = {
-       set_kset_name("cpld_irq"),
+       .name = "cpld_irq",
        .resume = lpd270_irq_resume,
 };
 
@@ -132,9 +135,12 @@ static struct sys_device lpd270_irq_device = {
 
 static int __init lpd270_irq_device_init(void)
 {
-       int ret = sysdev_class_register(&lpd270_irq_sysclass);
-       if (ret == 0)
-               ret = sysdev_register(&lpd270_irq_device);
+       int ret = -ENODEV;
+       if (machine_is_logicpd_pxa270()) {
+               ret = sysdev_class_register(&lpd270_irq_sysclass);
+               if (ret == 0)
+                       ret = sysdev_register(&lpd270_irq_device);
+       }
        return ret;
 }
 
@@ -162,11 +168,6 @@ static struct platform_device smc91x_device = {
        .resource       = smc91x_resources,
 };
 
-static struct platform_device lpd270_audio_device = {
-       .name           = "pxa2xx-ac97",
-       .id             = -1,
-};
-
 static struct resource lpd270_flash_resources[] = {
        [0] = {
                .start  = PXA_CS0_PHYS,
@@ -231,24 +232,23 @@ static struct platform_device lpd270_flash_device[2] = {
        },
 };
 
-static void lpd270_backlight_power(int on)
-{
-       if (on) {
-               pxa_gpio_mode(GPIO16_PWM0_MD);
-               pxa_set_cken(CKEN0_PWM0, 1);
-               PWM_CTRL0 = 0;
-               PWM_PWDUTY0 = 0x3ff;
-               PWM_PERVAL0 = 0x3ff;
-       } else {
-               PWM_CTRL0 = 0;
-               PWM_PWDUTY0 = 0x0;
-               PWM_PERVAL0 = 0x3FF;
-               pxa_set_cken(CKEN0_PWM0, 0);
-       }
-}
+static struct platform_pwm_backlight_data lpd270_backlight_data = {
+       .pwm_id         = 0,
+       .max_brightness = 1,
+       .dft_brightness = 1,
+       .pwm_period_ns  = 78770,
+};
+
+static struct platform_device lpd270_backlight_device = {
+       .name           = "pwm-backlight",
+       .dev            = {
+               .parent = &pxa27x_device_pwm0.dev,
+               .platform_data = &lpd270_backlight_data,
+       },
+};
 
 /* 5.7" TFT QVGA (LoLo display number 1) */
-static struct pxafb_mach_info sharp_lq057q3dc02 __initdata = {
+static struct pxafb_mode_info sharp_lq057q3dc02_mode = {
        .pixclock               = 150000,
        .xres                   = 320,
        .yres                   = 240,
@@ -260,13 +260,17 @@ static struct pxafb_mach_info sharp_lq057q3dc02 __initdata = {
        .upper_margin           = 0x08,
        .lower_margin           = 0x14,
        .sync                   = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+};
+
+static struct pxafb_mach_info sharp_lq057q3dc02 = {
+       .modes                  = &sharp_lq057q3dc02_mode,
+       .num_modes              = 1,
        .lccr0                  = 0x07800080,
        .lccr3                  = 0x00400000,
-       .pxafb_backlight_power  = lpd270_backlight_power,
 };
 
 /* 12.1" TFT SVGA (LoLo display number 2) */
-static struct pxafb_mach_info sharp_lq121s1dg31 __initdata = {
+static struct pxafb_mode_info sharp_lq121s1dg31_mode = {
        .pixclock               = 50000,
        .xres                   = 800,
        .yres                   = 600,
@@ -278,13 +282,17 @@ static struct pxafb_mach_info sharp_lq121s1dg31 __initdata = {
        .upper_margin           = 0x14,
        .lower_margin           = 0x0a,
        .sync                   = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+};
+
+static struct pxafb_mach_info sharp_lq121s1dg31 = {
+       .modes                  = &sharp_lq121s1dg31_mode,
+       .num_modes              = 1,
        .lccr0                  = 0x07800080,
        .lccr3                  = 0x00400000,
-       .pxafb_backlight_power  = lpd270_backlight_power,
 };
 
 /* 3.6" TFT QVGA (LoLo display number 3) */
-static struct pxafb_mach_info sharp_lq036q1da01 __initdata = {
+static struct pxafb_mode_info sharp_lq036q1da01_mode = {
        .pixclock               = 150000,
        .xres                   = 320,
        .yres                   = 240,
@@ -296,13 +304,17 @@ static struct pxafb_mach_info sharp_lq036q1da01 __initdata = {
        .upper_margin           = 0x03,
        .lower_margin           = 0x03,
        .sync                   = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+};
+
+static struct pxafb_mach_info sharp_lq036q1da01 = {
+       .modes                  = &sharp_lq036q1da01_mode,
+       .num_modes              = 1,
        .lccr0                  = 0x07800080,
        .lccr3                  = 0x00400000,
-       .pxafb_backlight_power  = lpd270_backlight_power,
 };
 
 /* 6.4" TFT VGA (LoLo display number 5) */
-static struct pxafb_mach_info sharp_lq64d343 __initdata = {
+static struct pxafb_mode_info sharp_lq64d343_mode = {
        .pixclock               = 25000,
        .xres                   = 640,
        .yres                   = 480,
@@ -314,13 +326,17 @@ static struct pxafb_mach_info sharp_lq64d343 __initdata = {
        .upper_margin           = 0x22,
        .lower_margin           = 0x00,
        .sync                   = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+};
+
+static struct pxafb_mach_info sharp_lq64d343 = {
+       .modes                  = &sharp_lq64d343_mode,
+       .num_modes              = 1,
        .lccr0                  = 0x07800080,
        .lccr3                  = 0x00400000,
-       .pxafb_backlight_power  = lpd270_backlight_power,
 };
 
 /* 10.4" TFT VGA (LoLo display number 7) */
-static struct pxafb_mach_info sharp_lq10d368 __initdata = {
+static struct pxafb_mode_info sharp_lq10d368_mode = {
        .pixclock               = 25000,
        .xres                   = 640,
        .yres                   = 480,
@@ -332,13 +348,17 @@ static struct pxafb_mach_info sharp_lq10d368 __initdata = {
        .upper_margin           = 0x22,
        .lower_margin           = 0x00,
        .sync                   = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+};
+
+static struct pxafb_mach_info sharp_lq10d368 = {
+       .modes                  = &sharp_lq10d368_mode,
+       .num_modes              = 1,
        .lccr0                  = 0x07800080,
        .lccr3                  = 0x00400000,
-       .pxafb_backlight_power  = lpd270_backlight_power,
 };
 
 /* 3.5" TFT QVGA (LoLo display number 8) */
-static struct pxafb_mach_info sharp_lq035q7db02_20 __initdata = {
+static struct pxafb_mode_info sharp_lq035q7db02_20_mode = {
        .pixclock               = 150000,
        .xres                   = 240,
        .yres                   = 320,
@@ -350,9 +370,13 @@ static struct pxafb_mach_info sharp_lq035q7db02_20 __initdata = {
        .upper_margin           = 0x05,
        .lower_margin           = 0x14,
        .sync                   = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
+};
+
+static struct pxafb_mach_info sharp_lq035q7db02_20 = {
+       .modes                  = &sharp_lq035q7db02_20_mode,
+       .num_modes              = 1,
        .lccr0                  = 0x07800080,
        .lccr3                  = 0x00400000,
-       .pxafb_backlight_power  = lpd270_backlight_power,
 };
 
 static struct pxafb_mach_info *lpd270_lcd_to_use;
@@ -382,7 +406,7 @@ __setup("lcd=", lpd270_set_lcd);
 
 static struct platform_device *platform_devices[] __initdata = {
        &smc91x_device,
-       &lpd270_audio_device,
+       &lpd270_backlight_device,
        &lpd270_flash_device[0],
        &lpd270_flash_device[1],
 };
@@ -422,9 +446,12 @@ static void __init lpd270_init(void)
         * On LogicPD PXA270, we route AC97_SYSCLK via GPIO45.
         */
        pxa_gpio_mode(GPIO45_SYSCLK_AC97_MD);
+       pxa_gpio_mode(GPIO16_PWM0_MD);
 
        platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
 
+       pxa_set_ac97_info(NULL);
+
        if (lpd270_lcd_to_use != NULL)
                set_pxa_fb_info(lpd270_lcd_to_use);