[ARM] pxa: introduce plat-pxa for PXA common code and add DMA support
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / lubbock.c
index 83ff5ce..f04c833 100644 (file)
 #include <linux/interrupt.h>
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/partitions.h>
+#include <linux/smc91x.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
-#include <asm/arch/pxa2xx_spi.h>
+#include <mach/pxa2xx_spi.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/hardware/sa1111.h>
 
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/lubbock.h>
-#include <asm/arch/udc.h>
-#include <asm/arch/irda.h>
-#include <asm/arch/pxafb.h>
-#include <asm/arch/mmc.h>
+#include <mach/pxa25x.h>
+#include <mach/gpio.h>
+#include <mach/audio.h>
+#include <mach/lubbock.h>
+#include <mach/udc.h>
+#include <mach/irda.h>
+#include <mach/pxafb.h>
+#include <mach/mmc.h>
+#include <mach/pm.h>
 
 #include "generic.h"
+#include "clock.h"
+#include "devices.h"
 
+static unsigned long lubbock_pin_config[] __initdata = {
+       GPIO15_nCS_1,   /* CS1 - Flash */
+       GPIO78_nCS_2,   /* CS2 - Baseboard FGPA */
+       GPIO79_nCS_3,   /* CS3 - SMC ethernet */
+       GPIO80_nCS_4,   /* CS4 - SA1111 */
 
+       /* SSP data pins */
+       GPIO23_SSP1_SCLK,
+       GPIO25_SSP1_TXD,
+       GPIO26_SSP1_RXD,
+
+       /* LCD - 16bpp DSTN */
+       GPIO58_LCD_LDD_0,
+       GPIO59_LCD_LDD_1,
+       GPIO60_LCD_LDD_2,
+       GPIO61_LCD_LDD_3,
+       GPIO62_LCD_LDD_4,
+       GPIO63_LCD_LDD_5,
+       GPIO64_LCD_LDD_6,
+       GPIO65_LCD_LDD_7,
+       GPIO66_LCD_LDD_8,
+       GPIO67_LCD_LDD_9,
+       GPIO68_LCD_LDD_10,
+       GPIO69_LCD_LDD_11,
+       GPIO70_LCD_LDD_12,
+       GPIO71_LCD_LDD_13,
+       GPIO72_LCD_LDD_14,
+       GPIO73_LCD_LDD_15,
+       GPIO74_LCD_FCLK,
+       GPIO75_LCD_LCLK,
+       GPIO76_LCD_PCLK,
+
+       /* BTUART */
+       GPIO42_BTUART_RXD,
+       GPIO43_BTUART_TXD,
+       GPIO44_BTUART_CTS,
+       GPIO45_BTUART_RTS,
+
+       /* PC Card */
+       GPIO48_nPOE,
+       GPIO49_nPWE,
+       GPIO50_nPIOR,
+       GPIO51_nPIOW,
+       GPIO52_nPCE_1,
+       GPIO53_nPCE_2,
+       GPIO54_nPSKTSEL,
+       GPIO55_nPREG,
+       GPIO56_nPWAIT,
+       GPIO57_nIOIS16,
+
+       /* MMC */
+       GPIO6_MMC_CLK,
+       GPIO8_MMC_CS0,
+
+       /* wakeup */
+       GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
+};
+
+#define LUB_HEXLED             __LUB_REG(LUBBOCK_FPGA_PHYS + 0x010)
 #define LUB_MISC_WR            __LUB_REG(LUBBOCK_FPGA_PHYS + 0x080)
 
+void lubbock_set_hexled(uint32_t value)
+{
+       LUB_HEXLED = value;
+}
+
 void lubbock_set_misc_wr(unsigned int mask, unsigned int set)
 {
        unsigned long flags;
@@ -85,16 +154,14 @@ static struct irq_chip lubbock_irq_chip = {
        .unmask         = lubbock_unmask_irq,
 };
 
-static void lubbock_irq_handler(unsigned int irq, struct irqdesc *desc,
-                               struct pt_regs *regs)
+static void lubbock_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
        unsigned long pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
        do {
                GEDR(0) = GPIO_bit(0);  /* clear our parent irq */
                if (likely(pending)) {
                        irq = LUBBOCK_IRQ(0) + __ffs(pending);
-                       desc = irq_desc + irq;
-                       desc_handle_irq(irq, desc, regs);
+                       generic_handle_irq(irq);
                }
                pending = LUB_IRQ_SET_CLR & lubbock_irq_enabled;
        } while (pending);
@@ -104,17 +171,17 @@ static void __init lubbock_init_irq(void)
 {
        int irq;
 
-       pxa_init_irq();
+       pxa25x_init_irq();
 
        /* setup extra lubbock irqs */
        for (irq = LUBBOCK_IRQ(0); irq <= LUBBOCK_LAST_IRQ; irq++) {
                set_irq_chip(irq, &lubbock_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), lubbock_irq_handler);
-       set_irq_type(IRQ_GPIO(0), IRQT_FALLING);
+       set_irq_type(IRQ_GPIO(0), IRQ_TYPE_EDGE_FALLING);
 }
 
 #ifdef CONFIG_PM
@@ -126,7 +193,7 @@ static int lubbock_irq_resume(struct sys_device *dev)
 }
 
 static struct sysdev_class lubbock_irq_sysclass = {
-       set_kset_name("cpld_irq"),
+       .name = "cpld_irq",
        .resume = lubbock_irq_resume,
 };
 
@@ -136,9 +203,13 @@ static struct sys_device lubbock_irq_device = {
 
 static int __init lubbock_irq_device_init(void)
 {
-       int ret = sysdev_class_register(&lubbock_irq_sysclass);
-       if (ret == 0)
-               ret = sysdev_register(&lubbock_irq_device);
+       int ret = -ENODEV;
+
+       if (machine_is_lubbock()) {
+               ret = sysdev_class_register(&lubbock_irq_sysclass);
+               if (ret == 0)
+                       ret = sysdev_register(&lubbock_irq_device);
+       }
        return ret;
 }
 
@@ -156,11 +227,6 @@ static struct pxa2xx_udc_mach_info udc_info __initdata = {
        // no D+ pullup; lubbock can't connect/disconnect in software
 };
 
-static struct platform_device lub_audio_device = {
-       .name           = "pxa2xx-ac97",
-       .id             = -1,
-};
-
 static struct resource sa1111_resources[] = {
        [0] = {
                .start  = 0x10000000,
@@ -181,58 +247,13 @@ static struct platform_device sa1111_device = {
        .resource       = sa1111_resources,
 };
 
-static struct resource smc91x_resources[] = {
-       [0] = {
-               .name   = "smc91x-regs",
-               .start  = 0x0c000c00,
-               .end    = 0x0c0fffff,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = LUBBOCK_ETH_IRQ,
-               .end    = LUBBOCK_ETH_IRQ,
-               .flags  = IORESOURCE_IRQ,
-       },
-       [2] = {
-               .name   = "smc91x-attrib",
-               .start  = 0x0e000000,
-               .end    = 0x0e0fffff,
-               .flags  = IORESOURCE_MEM,
-       },
-};
-
 /* ADS7846 is connected through SSP ... and if your board has J5 populated,
  * you can select it to replace the ucb1400 by switching the touchscreen cable
  * (to J5) and poking board registers (as done below).  Else it's only useful
  * for the temperature sensors.
  */
-static struct resource pxa_ssp_resources[] = {
-       [0] = {
-               .start  = __PREG(SSCR0_P(1)),
-               .end    = __PREG(SSCR0_P(1)) + 0x14,
-               .flags  = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start  = IRQ_SSP,
-               .end    = IRQ_SSP,
-               .flags  = IORESOURCE_IRQ,
-       },
-};
-
 static struct pxa2xx_spi_master pxa_ssp_master_info = {
-       .ssp_type       = PXA25x_SSP,
-       .clock_enable   = CKEN3_SSP,
-       .num_chipselect = 0,
-};
-
-static struct platform_device pxa_ssp = {
-       .name           = "pxa2xx-spi",
-       .id             = 1,
-       .resource       = pxa_ssp_resources,
-       .num_resources  = ARRAY_SIZE(pxa_ssp_resources),
-       .dev = {
-               .platform_data  = &pxa_ssp_master_info,
-       },
+       .num_chipselect = 1,
 };
 
 static int lubbock_ads7846_pendown_state(void)
@@ -273,11 +294,38 @@ static struct spi_board_info spi_board_info[] __initdata = { {
 },
 };
 
+static struct resource smc91x_resources[] = {
+       [0] = {
+               .name   = "smc91x-regs",
+               .start  = 0x0c000c00,
+               .end    = 0x0c0fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+       [1] = {
+               .start  = LUBBOCK_ETH_IRQ,
+               .end    = LUBBOCK_ETH_IRQ,
+               .flags  = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
+       },
+       [2] = {
+               .name   = "smc91x-attrib",
+               .start  = 0x0e000000,
+               .end    = 0x0e0fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct smc91x_platdata lubbock_smc91x_info = {
+       .flags  = SMC91X_USE_16BIT | SMC91X_NOWAIT | SMC91X_IO_SHIFT_2,
+};
+
 static struct platform_device smc91x_device = {
        .name           = "smc91x",
        .id             = -1,
        .num_resources  = ARRAY_SIZE(smc91x_resources),
        .resource       = smc91x_resources,
+       .dev            = {
+               .platform_data = &lubbock_smc91x_info,
+       },
 };
 
 static struct resource flash_resources[] = {
@@ -345,14 +393,12 @@ static struct platform_device lubbock_flash_device[2] = {
 
 static struct platform_device *devices[] __initdata = {
        &sa1111_device,
-       &lub_audio_device,
        &smc91x_device,
        &lubbock_flash_device[0],
        &lubbock_flash_device[1],
-       &pxa_ssp,
 };
 
-static struct pxafb_mach_info sharp_lm8v31 __initdata = {
+static struct pxafb_mode_info sharp_lm8v31_mode = {
        .pixclock       = 270000,
        .xres           = 640,
        .yres           = 480,
@@ -365,16 +411,21 @@ static struct pxafb_mach_info sharp_lm8v31 __initdata = {
        .lower_margin   = 0,
        .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
        .cmap_greyscale = 0,
+};
+
+static struct pxafb_mach_info sharp_lm8v31 = {
+       .modes          = &sharp_lm8v31_mode,
+       .num_modes      = 1,
        .cmap_inverse   = 0,
        .cmap_static    = 0,
-       .lccr0          = LCCR0_SDS,
-       .lccr3          = LCCR3_PCP | LCCR3_Acb(255),
+       .lcd_conn       = LCD_COLOR_DSTN_16BPP | LCD_PCLK_EDGE_FALL |
+                         LCD_AC_BIAS_FREQ(255),
 };
 
 #define        MMC_POLL_RATE           msecs_to_jiffies(1000)
 
 static void lubbock_mmc_poll(unsigned long);
-static irqreturn_t (*mmc_detect_int)(int, void *, struct pt_regs *);
+static irq_handler_t mmc_detect_int;
 
 static struct timer_list mmc_timer = {
        .function       = lubbock_mmc_poll,
@@ -393,28 +444,24 @@ static void lubbock_mmc_poll(unsigned long data)
        if (LUB_IRQ_SET_CLR & (1 << 0))
                mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
        else {
-               (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data, NULL);
+               (void) mmc_detect_int(LUBBOCK_SD_IRQ, (void *)data);
                enable_irq(LUBBOCK_SD_IRQ);
        }
 }
 
-static irqreturn_t lubbock_detect_int(int irq, void *data, struct pt_regs *regs)
+static irqreturn_t lubbock_detect_int(int irq, void *data)
 {
        /* IRQ is level triggered; disable, and poll for removal */
        disable_irq(irq);
        mod_timer(&mmc_timer, jiffies + MMC_POLL_RATE);
 
-       return mmc_detect_int(irq, data, regs);
+       return mmc_detect_int(irq, data);
 }
 
 static int lubbock_mci_init(struct device *dev,
-               irqreturn_t (*detect_int)(int, void *, struct pt_regs *),
+               irq_handler_t detect_int,
                void *data)
 {
-       /* setup GPIO for PXA25x MMC controller */
-       pxa_gpio_mode(GPIO6_MMCCLK_MD);
-       pxa_gpio_mode(GPIO8_MMCCS0_MD);
-
        /* detect card insert/eject */
        mmc_detect_int = detect_int;
        init_timer(&mmc_timer);
@@ -452,6 +499,7 @@ static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
        } else if (mode & IR_FIRMODE) {
                LUB_MISC_WR |= 1 << 4;
        }
+       pxa2xx_transceiver_mode(dev, mode);
        local_irq_restore(flags);
 }
 
@@ -464,10 +512,14 @@ static void __init lubbock_init(void)
 {
        int flashboot = (LUB_CONF_SWITCHES & 1);
 
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(lubbock_pin_config));
+
+       clk_add_alias("SA1111_CLK", NULL, "GPIO11_CLK", NULL);
        pxa_set_udc_info(&udc_info);
        set_pxa_fb_info(&sharp_lm8v31);
        pxa_set_mci_info(&lubbock_mci_platform_data);
        pxa_set_ficp_info(&lubbock_ficp_platform_data);
+       pxa_set_ac97_info(NULL);
 
        lubbock_flash_data[0].width = lubbock_flash_data[1].width =
                (BOOT_DEF & 1) ? 2 : 4;
@@ -479,6 +531,7 @@ static void __init lubbock_init(void)
        lubbock_flash_data[flashboot].name = "boot-rom";
        (void) platform_add_devices(devices, ARRAY_SIZE(devices));
 
+       pxa2xx_set_spi_info(1, &pxa_ssp_master_info);
        spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
 }
 
@@ -496,27 +549,6 @@ static void __init lubbock_map_io(void)
        pxa_map_io();
        iotable_init(lubbock_io_desc, ARRAY_SIZE(lubbock_io_desc));
 
-       /* SSP data pins */
-       pxa_gpio_mode(GPIO23_SCLK_MD);
-       pxa_gpio_mode(GPIO25_STXD_MD);
-       pxa_gpio_mode(GPIO26_SRXD_MD);
-
-       /* This enables the BTUART */
-       pxa_gpio_mode(GPIO42_BTRXD_MD);
-       pxa_gpio_mode(GPIO43_BTTXD_MD);
-       pxa_gpio_mode(GPIO44_BTCTS_MD);
-       pxa_gpio_mode(GPIO45_BTRTS_MD);
-
-       /* This is for the SMC chip select */
-       pxa_gpio_mode(GPIO79_nCS_3_MD);
-
-       /* setup sleep mode values */
-       PWER  = 0x00000002;
-       PFER  = 0x00000000;
-       PRER  = 0x00000002;
-       PGSR0 = 0x00008000;
-       PGSR1 = 0x003F0202;
-       PGSR2 = 0x0001C000;
        PCFR |= PCFR_OPDE;
 }