ceph: update discussion list address in MAINTAINERS
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / cm-x270.c
index 6d4416a..a9926bb 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * linux/arch/arm/mach-pxa/cm-x270.c
  *
- * Copyright (C) 2007 CompuLab, Ltd.
+ * Copyright (C) 2007, 2008 CompuLab, Ltd.
  * Mike Rapoport <mike@compulab.co.il>
  *
  * This program is free software; you can redistribute it and/or modify
  * published by the Free Software Foundation.
  */
 
-#include <linux/types.h>
-#include <linux/pm.h>
-#include <linux/fb.h>
 #include <linux/platform_device.h>
-#include <linux/irq.h>
 #include <linux/sysdev.h>
-#include <linux/io.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
 #include <linux/delay.h>
 
-#include <linux/dm9000.h>
 #include <linux/rtc-v3020.h>
-#include <linux/serial_8250.h>
-
 #include <video/mbxfb.h>
 
-#include <asm/mach/arch.h>
-#include <asm/mach-types.h>
-#include <asm/mach/map.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/libertas_spi.h>
 
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/pxa2xx-regs.h>
-#include <asm/arch/pxa2xx-gpio.h>
-#include <asm/arch/pxafb.h>
-#include <asm/arch/ohci.h>
-#include <asm/arch/mmc.h>
-#include <asm/arch/bitfield.h>
-#include <asm/arch/cm-x270.h>
-
-#include <asm/hardware/it8152.h>
+#include <mach/pxa27x.h>
+#include <mach/ohci.h>
+#include <mach/mmc.h>
+#include <mach/pxa2xx_spi.h>
 
 #include "generic.h"
-#include "cm-x270-pci.h"
 
+/* physical address if local-bus attached devices */
 #define RTC_PHYS_BASE          (PXA_CS1_PHYS + (5 << 22))
-#define DM9000_PHYS_BASE       (PXA_CS1_PHYS + (6 << 22))
-
-static struct resource cmx270_dm9k_resource[] = {
-       [0] = {
-               .start = DM9000_PHYS_BASE,
-               .end   = DM9000_PHYS_BASE + 4,
-               .flags = IORESOURCE_MEM,
-       },
-       [1] = {
-               .start = DM9000_PHYS_BASE + 8,
-               .end   = DM9000_PHYS_BASE + 8 + 500,
-               .flags = IORESOURCE_MEM,
-       },
-       [2] = {
-               .start = CMX270_ETHIRQ,
-               .end   = CMX270_ETHIRQ,
-               .flags = IORESOURCE_IRQ,
-       }
-};
-
-/* for the moment we limit ourselves to 32bit IO until some
- * better IO routines can be written and tested
- */
-static struct dm9000_plat_data cmx270_dm9k_platdata = {
-       .flags          = DM9000_PLATF_32BITONLY,
-};
-
-/* Ethernet device */
-static struct platform_device cmx270_device_dm9k = {
-       .name           = "dm9000",
-       .id             = 0,
-       .num_resources  = ARRAY_SIZE(cmx270_dm9k_resource),
-       .resource       = cmx270_dm9k_resource,
-       .dev            = {
-               .platform_data = &cmx270_dm9k_platdata,
-       }
-};
 
-/* audio device */
-static struct platform_device cmx270_audio_device = {
-       .name           = "pxa2xx-ac97",
-       .id             = -1,
+/* GPIO IRQ usage */
+#define GPIO83_MMC_IRQ         (83)
+
+#define CMX270_MMC_IRQ         IRQ_GPIO(GPIO83_MMC_IRQ)
+
+/* MMC power enable */
+#define GPIO105_MMC_POWER      (105)
+
+/* WLAN GPIOS */
+#define GPIO19_WLAN_STRAP      (19)
+#define GPIO102_WLAN_RST       (102)
+
+static unsigned long cmx270_pin_config[] = {
+       /* AC'97 */
+       GPIO28_AC97_BITCLK,
+       GPIO29_AC97_SDATA_IN_0,
+       GPIO30_AC97_SDATA_OUT,
+       GPIO31_AC97_SYNC,
+       GPIO98_AC97_SYSCLK,
+       GPIO113_AC97_nRESET,
+
+       /* BTUART */
+       GPIO42_BTUART_RXD,
+       GPIO43_BTUART_TXD,
+       GPIO44_BTUART_CTS,
+       GPIO45_BTUART_RTS,
+
+       /* STUART */
+       GPIO46_STUART_RXD,
+       GPIO47_STUART_TXD,
+
+       /* MCI controller */
+       GPIO32_MMC_CLK,
+       GPIO112_MMC_CMD,
+       GPIO92_MMC_DAT_0,
+       GPIO109_MMC_DAT_1,
+       GPIO110_MMC_DAT_2,
+       GPIO111_MMC_DAT_3,
+
+       /* LCD */
+       GPIOxx_LCD_TFT_16BPP,
+
+       /* I2C */
+       GPIO117_I2C_SCL,
+       GPIO118_I2C_SDA,
+
+       /* SSP1 */
+       GPIO23_SSP1_SCLK,
+       GPIO24_SSP1_SFRM,
+       GPIO25_SSP1_TXD,
+       GPIO26_SSP1_RXD,
+
+       /* SSP2 */
+       GPIO19_GPIO,    /* SSP2 clock is used as GPIO for Libertas pin-strap */
+       GPIO14_GPIO,
+       GPIO87_SSP2_TXD,
+       GPIO88_SSP2_RXD,
+
+       /* PC Card */
+       GPIO48_nPOE,
+       GPIO49_nPWE,
+       GPIO50_nPIOR,
+       GPIO51_nPIOW,
+       GPIO85_nPCE_1,
+       GPIO54_nPCE_2,
+       GPIO55_nPREG,
+       GPIO56_nPWAIT,
+       GPIO57_nIOIS16,
+
+       /* SDRAM and local bus */
+       GPIO15_nCS_1,
+       GPIO78_nCS_2,
+       GPIO79_nCS_3,
+       GPIO80_nCS_4,
+       GPIO33_nCS_5,
+       GPIO49_nPWE,
+       GPIO18_RDY,
+
+       /* GPIO */
+       GPIO0_GPIO      | WAKEUP_ON_EDGE_BOTH,
+       GPIO105_GPIO    | MFP_LPM_DRIVE_HIGH,   /* MMC/SD power */
+       GPIO53_GPIO,                            /* PC card reset */
+       GPIO102_GPIO,                           /* WLAN reset */
+
+       /* NAND controls */
+       GPIO11_GPIO     | MFP_LPM_DRIVE_HIGH,   /* NAND CE# */
+       GPIO89_GPIO,                            /* NAND Ready/Busy */
+
+       /* interrupts */
+       GPIO10_GPIO,    /* DM9000 interrupt */
+       GPIO83_GPIO,    /* MMC card detect */
+       GPIO95_GPIO,    /* WLAN interrupt */
 };
 
-/* touchscreen controller */
-static struct platform_device cmx270_ts_device = {
-       .name           = "ucb1400_ts",
-       .id             = -1,
-};
-
-/* RTC */
+/* V3020 RTC */
+#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
 static struct resource cmx270_v3020_resource[] = {
        [0] = {
                .start = RTC_PHYS_BASE,
@@ -116,59 +149,84 @@ static struct platform_device cmx270_rtc_device = {
        }
 };
 
-/*
- * CM-X270 LEDs
- */
-static struct platform_device cmx270_led_device = {
-       .name           = "cm-x270-led",
-       .id             = -1,
-};
+static void __init cmx270_init_rtc(void)
+{
+       platform_device_register(&cmx270_rtc_device);
+}
+#else
+static inline void cmx270_init_rtc(void) {}
+#endif
 
 /* 2700G graphics */
+#if defined(CONFIG_FB_MBX) || defined(CONFIG_FB_MBX_MODULE)
 static u64 fb_dma_mask = ~(u64)0;
 
 static struct resource cmx270_2700G_resource[] = {
        /* frame buffer memory including ODFB and External SDRAM */
        [0] = {
-               .start = MARATHON_PHYS,
-               .end   = MARATHON_PHYS + 0x02000000,
+               .start = PXA_CS2_PHYS,
+               .end   = PXA_CS2_PHYS + 0x01ffffff,
                .flags = IORESOURCE_MEM,
        },
        /* Marathon registers */
        [1] = {
-               .start = MARATHON_PHYS + 0x03fe0000,
-               .end   = MARATHON_PHYS + 0x03ffffff,
+               .start = PXA_CS2_PHYS + 0x03fe0000,
+               .end   = PXA_CS2_PHYS + 0x03ffffff,
                .flags = IORESOURCE_MEM,
        },
 };
 
-static unsigned long save_lcd_regs[10];
+static unsigned long cmx270_marathon_on[] = {
+       GPIO58_GPIO,
+       GPIO59_GPIO,
+       GPIO60_GPIO,
+       GPIO61_GPIO,
+       GPIO62_GPIO,
+       GPIO63_GPIO,
+       GPIO64_GPIO,
+       GPIO65_GPIO,
+       GPIO66_GPIO,
+       GPIO67_GPIO,
+       GPIO68_GPIO,
+       GPIO69_GPIO,
+       GPIO70_GPIO,
+       GPIO71_GPIO,
+       GPIO72_GPIO,
+       GPIO73_GPIO,
+       GPIO74_GPIO,
+       GPIO75_GPIO,
+       GPIO76_GPIO,
+       GPIO77_GPIO,
+};
+
+static unsigned long cmx270_marathon_off[] = {
+       GPIOxx_LCD_TFT_16BPP,
+};
 
 static int cmx270_marathon_probe(struct fb_info *fb)
 {
-       /* save PXA-270 pin settings before enabling 2700G */
-       save_lcd_regs[0] = GPDR1;
-       save_lcd_regs[1] = GPDR2;
-       save_lcd_regs[2] = GAFR1_U;
-       save_lcd_regs[3] = GAFR2_L;
-       save_lcd_regs[4] = GAFR2_U;
-
-       /* Disable PXA-270 on-chip controller driving pins */
-       GPDR1 &= ~(0xfc000000);
-       GPDR2 &= ~(0x00c03fff);
-       GAFR1_U &= ~(0xfff00000);
-       GAFR2_L &= ~(0x0fffffff);
-       GAFR2_U &= ~(0x0000f000);
+       int gpio, err;
+
+       for (gpio = 58; gpio <= 77; gpio++) {
+               err = gpio_request(gpio, "LCD");
+               if (err)
+                       return err;
+               gpio_direction_input(gpio);
+       }
+
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_on));
        return 0;
 }
 
 static int cmx270_marathon_remove(struct fb_info *fb)
 {
-       GPDR1 =   save_lcd_regs[0];
-       GPDR2 =   save_lcd_regs[1];
-       GAFR1_U = save_lcd_regs[2];
-       GAFR2_L = save_lcd_regs[3];
-       GAFR2_U = save_lcd_regs[4];
+       int gpio;
+
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_marathon_off));
+
+       for (gpio = 58; gpio <= 77; gpio++)
+               gpio_free(gpio);
+
        return 0;
 }
 
@@ -205,440 +263,151 @@ static struct platform_device cmx270_2700G = {
        .id             = -1,
 };
 
-static u64 ata_dma_mask = ~(u64)0;
-
-static struct platform_device cmx270_ata = {
-       .name = "pata_cm_x270",
-       .id = -1,
-       .dev            = {
-               .dma_mask       = &ata_dma_mask,
-               .coherent_dma_mask = 0xffffffff,
-       },
-};
-
-/* platform devices */
-static struct platform_device *platform_devices[] __initdata = {
-       &cmx270_device_dm9k,
-       &cmx270_audio_device,
-       &cmx270_rtc_device,
-       &cmx270_2700G,
-       &cmx270_led_device,
-       &cmx270_ts_device,
-       &cmx270_ata,
-};
-
-/* Map PCI companion and IDE/General Purpose CS statically */
-static struct map_desc cmx270_io_desc[] __initdata = {
-       [0] = { /* IDE/general purpose space */
-               .virtual        = CMX270_IDE104_VIRT,
-               .pfn            = __phys_to_pfn(CMX270_IDE104_PHYS),
-               .length         = SZ_64M - SZ_8M,
-               .type           = MT_DEVICE
-       },
-       [1] = { /* PCI bridge */
-               .virtual        = CMX270_IT8152_VIRT,
-               .pfn            = __phys_to_pfn(CMX270_IT8152_PHYS),
-               .length         = SZ_64M,
-               .type           = MT_DEVICE
-       },
-};
-
-/*
-  Display definitions
-  keep these for backwards compatibility, although symbolic names (as
-  e.g. in lpd270.c) looks better
-*/
-#define MTYPE_STN320x240       0
-#define MTYPE_TFT640x480       1
-#define MTYPE_CRT640x480       2
-#define MTYPE_CRT800x600       3
-#define MTYPE_TFT320x240       6
-#define MTYPE_STN640x480       7
-
-static struct pxafb_mode_info generic_stn_320x240_mode = {
-       .pixclock       = 76923,
-       .bpp            = 8,
-       .xres           = 320,
-       .yres           = 240,
-       .hsync_len      = 3,
-       .vsync_len      = 2,
-       .left_margin    = 3,
-       .upper_margin   = 0,
-       .right_margin   = 3,
-       .lower_margin   = 0,
-       .sync           = (FB_SYNC_HOR_HIGH_ACT |
-                          FB_SYNC_VERT_HIGH_ACT),
-       .cmap_greyscale = 0,
-};
-
-static struct pxafb_mach_info generic_stn_320x240 = {
-       .modes          = &generic_stn_320x240_mode,
-       .num_modes      = 1,
-       .lccr0          = 0,
-       .lccr3          = (LCCR3_PixClkDiv(0x03) |
-                          LCCR3_Acb(0xff) |
-                          LCCR3_PCP),
-       .cmap_inverse   = 0,
-       .cmap_static    = 0,
-};
-
-static struct pxafb_mode_info generic_tft_640x480_mode = {
-       .pixclock       = 38461,
-       .bpp            = 8,
-       .xres           = 640,
-       .yres           = 480,
-       .hsync_len      = 60,
-       .vsync_len      = 2,
-       .left_margin    = 70,
-       .upper_margin   = 10,
-       .right_margin   = 70,
-       .lower_margin   = 5,
-       .sync           = 0,
-       .cmap_greyscale = 0,
-};
-
-static struct pxafb_mach_info generic_tft_640x480 = {
-       .modes          = &generic_tft_640x480_mode,
-       .num_modes      = 1,
-       .lccr0          = (LCCR0_PAS),
-       .lccr3          = (LCCR3_PixClkDiv(0x01) |
-                          LCCR3_Acb(0xff) |
-                          LCCR3_PCP),
-       .cmap_inverse   = 0,
-       .cmap_static    = 0,
-};
+static void __init cmx270_init_2700G(void)
+{
+       platform_device_register(&cmx270_2700G);
+}
+#else
+static inline void cmx270_init_2700G(void) {}
+#endif
 
-static struct pxafb_mode_info generic_crt_640x480_mode = {
-       .pixclock       = 38461,
-       .bpp            = 8,
-       .xres           = 640,
-       .yres           = 480,
-       .hsync_len      = 63,
-       .vsync_len      = 2,
-       .left_margin    = 81,
-       .upper_margin   = 33,
-       .right_margin   = 16,
-       .lower_margin   = 10,
-       .sync           = (FB_SYNC_HOR_HIGH_ACT |
-                          FB_SYNC_VERT_HIGH_ACT),
-       .cmap_greyscale = 0,
+/* PXA27x OHCI controller setup */
+#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+static struct pxaohci_platform_data cmx270_ohci_platform_data = {
+       .port_mode      = PMM_PERPORT_MODE,
+       .flags          = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
 };
 
-static struct pxafb_mach_info generic_crt_640x480 = {
-       .modes          = &generic_crt_640x480_mode,
-       .num_modes      = 1,
-       .lccr0          = (LCCR0_PAS),
-       .lccr3          = (LCCR3_PixClkDiv(0x01) |
-                          LCCR3_Acb(0xff)),
-       .cmap_inverse   = 0,
-       .cmap_static    = 0,
-};
+static void __init cmx270_init_ohci(void)
+{
+       pxa_set_ohci_info(&cmx270_ohci_platform_data);
+}
+#else
+static inline void cmx270_init_ohci(void) {}
+#endif
 
-static struct pxafb_mode_info generic_crt_800x600_mode = {
-       .pixclock       = 28846,
-       .bpp            = 8,
-       .xres           = 800,
-       .yres           = 600,
-       .hsync_len      = 63,
-       .vsync_len      = 2,
-       .left_margin    = 26,
-       .upper_margin   = 21,
-       .right_margin   = 26,
-       .lower_margin   = 11,
-       .sync           = (FB_SYNC_HOR_HIGH_ACT |
-                          FB_SYNC_VERT_HIGH_ACT),
-       .cmap_greyscale = 0,
+#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
+static struct pxamci_platform_data cmx270_mci_platform_data = {
+       .ocr_mask               = MMC_VDD_32_33|MMC_VDD_33_34,
+       .gpio_card_detect       = GPIO83_MMC_IRQ,
+       .gpio_card_ro           = -1,
+       .gpio_power             = GPIO105_MMC_POWER,
+       .gpio_power_invert      = 1,
 };
 
-static struct pxafb_mach_info generic_crt_800x600 = {
-       .modes          = &generic_crt_800x600_mode,
-       .num_modes      = 1,
-       .lccr0          = (LCCR0_PAS),
-       .lccr3          = (LCCR3_PixClkDiv(0x02) |
-                          LCCR3_Acb(0xff)),
-       .cmap_inverse   = 0,
-       .cmap_static    = 0,
-};
+static void __init cmx270_init_mmc(void)
+{
+       pxa_set_mci_info(&cmx270_mci_platform_data);
+}
+#else
+static inline void cmx270_init_mmc(void) {}
+#endif
 
-static struct pxafb_mode_info generic_tft_320x240_mode = {
-       .pixclock       = 134615,
-       .bpp            = 16,
-       .xres           = 320,
-       .yres           = 240,
-       .hsync_len      = 63,
-       .vsync_len      = 7,
-       .left_margin    = 75,
-       .upper_margin   = 0,
-       .right_margin   = 15,
-       .lower_margin   = 15,
-       .sync           = 0,
-       .cmap_greyscale = 0,
+#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
+static struct pxa2xx_spi_master cm_x270_spi_info = {
+       .num_chipselect = 1,
+       .enable_dma     = 1,
 };
 
-static struct pxafb_mach_info generic_tft_320x240 = {
-       .modes          = &generic_tft_320x240_mode,
-       .num_modes      = 1,
-       .lccr0          = (LCCR0_PAS),
-       .lccr3          = (LCCR3_PixClkDiv(0x06) |
-                          LCCR3_Acb(0xff) |
-                          LCCR3_PCP),
-       .cmap_inverse   = 0,
-       .cmap_static    = 0,
+static struct pxa2xx_spi_chip cm_x270_libertas_chip = {
+       .rx_threshold   = 1,
+       .tx_threshold   = 1,
+       .timeout        = 1000,
+       .gpio_cs        = 14,
 };
 
-static struct pxafb_mode_info generic_stn_640x480_mode = {
-       .pixclock       = 57692,
-       .bpp            = 8,
-       .xres           = 640,
-       .yres           = 480,
-       .hsync_len      = 4,
-       .vsync_len      = 2,
-       .left_margin    = 10,
-       .upper_margin   = 5,
-       .right_margin   = 10,
-       .lower_margin   = 5,
-       .sync           = (FB_SYNC_HOR_HIGH_ACT |
-                          FB_SYNC_VERT_HIGH_ACT),
-       .cmap_greyscale = 0,
-};
+static unsigned long cm_x270_libertas_pin_config[] = {
+       /* SSP2 */
+       GPIO19_SSP2_SCLK,
+       GPIO14_GPIO,
+       GPIO87_SSP2_TXD,
+       GPIO88_SSP2_RXD,
 
-static struct pxafb_mach_info generic_stn_640x480 = {
-       .modes          = &generic_stn_640x480_mode,
-       .num_modes      = 1,
-       .lccr0          = 0,
-       .lccr3          = (LCCR3_PixClkDiv(0x02) |
-                          LCCR3_Acb(0xff)),
-       .cmap_inverse   = 0,
-       .cmap_static    = 0,
 };
 
-static struct pxafb_mach_info *cmx270_display = &generic_crt_640x480;
-
-static int __init cmx270_set_display(char *str)
-{
-       int disp_type = simple_strtol(str, NULL, 0);
-       switch (disp_type) {
-       case MTYPE_STN320x240:
-               cmx270_display = &generic_stn_320x240;
-               break;
-       case MTYPE_TFT640x480:
-               cmx270_display = &generic_tft_640x480;
-               break;
-       case MTYPE_CRT640x480:
-               cmx270_display = &generic_crt_640x480;
-               break;
-       case MTYPE_CRT800x600:
-               cmx270_display = &generic_crt_800x600;
-               break;
-       case MTYPE_TFT320x240:
-               cmx270_display = &generic_tft_320x240;
-               break;
-       case MTYPE_STN640x480:
-               cmx270_display = &generic_stn_640x480;
-               break;
-       default: /* fallback to CRT 640x480 */
-               cmx270_display = &generic_crt_640x480;
-               break;
-       }
-       return 1;
-}
-
-/*
-   This should be done really early to get proper configuration for
-   frame buffer.
-   Indeed, pxafb parameters can be used istead, but CM-X270 bootloader
-   has limitied line length for kernel command line, and also it will
-   break compatibitlty with proprietary releases already in field.
-*/
-__setup("monitor=", cmx270_set_display);
-
-/* PXA27x OHCI controller setup */
-static int cmx270_ohci_init(struct device *dev)
+static int cm_x270_libertas_setup(struct spi_device *spi)
 {
-       /* Set the Power Control Polarity Low */
-       UHCHR = (UHCHR | UHCHR_PCPL) &
-               ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE);
-
-       return 0;
-}
-
-static struct pxaohci_platform_data cmx270_ohci_platform_data = {
-       .port_mode      = PMM_PERPORT_MODE,
-       .init           = cmx270_ohci_init,
-};
+       int err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
+       if (err)
+               return err;
 
+       err = gpio_request(GPIO102_WLAN_RST, "WLAN RST");
+       if (err)
+               goto err_free_strap;
 
-static int cmx270_mci_init(struct device *dev,
-                          irq_handler_t cmx270_detect_int,
-                          void *data)
-{
-       int err;
-
-       /*
-        * setup GPIO for PXA27x MMC controller
-        */
-       pxa_gpio_mode(GPIO32_MMCCLK_MD);
-       pxa_gpio_mode(GPIO112_MMCCMD_MD);
-       pxa_gpio_mode(GPIO92_MMCDAT0_MD);
-       pxa_gpio_mode(GPIO109_MMCDAT1_MD);
-       pxa_gpio_mode(GPIO110_MMCDAT2_MD);
-       pxa_gpio_mode(GPIO111_MMCDAT3_MD);
-
-       /* SB-X270 uses GPIO105 as SD power enable */
-       pxa_gpio_mode(105 | GPIO_OUT);
-
-       /* card detect IRQ on GPIO 83 */
-       pxa_gpio_mode(IRQ_TO_GPIO(CMX270_MMC_IRQ));
-
-       err = request_irq(CMX270_MMC_IRQ, cmx270_detect_int,
-                         IRQF_DISABLED | IRQF_TRIGGER_FALLING,
-                         "MMC card detect", data);
+       err = gpio_direction_output(GPIO102_WLAN_RST, 0);
        if (err)
-               printk(KERN_ERR "cmx270_mci_init: MMC/SD: can't"
-                      " request MMC card detect IRQ\n");
+               goto err_free_strap;
+       msleep(100);
 
-       return err;
-}
+       err = gpio_direction_output(GPIO19_WLAN_STRAP, 1);
+       if (err)
+               goto err_free_strap;
+       msleep(100);
 
-static void cmx270_mci_setpower(struct device *dev, unsigned int vdd)
-{
-       struct pxamci_platform_data *p_d = dev->platform_data;
-
-       if ((1 << vdd) & p_d->ocr_mask) {
-               printk(KERN_DEBUG "%s: on\n", __func__);
-               GPCR(105) = GPIO_bit(105);
-       } else {
-               GPSR(105) = GPIO_bit(105);
-               printk(KERN_DEBUG "%s: off\n", __func__);
-       }
-}
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(cm_x270_libertas_pin_config));
 
-static void cmx270_mci_exit(struct device *dev, void *data)
-{
-       free_irq(CMX270_MMC_IRQ, data);
-}
+       gpio_set_value(GPIO102_WLAN_RST, 1);
+       msleep(100);
 
-static struct pxamci_platform_data cmx270_mci_platform_data = {
-       .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
-       .init           = cmx270_mci_init,
-       .setpower       = cmx270_mci_setpower,
-       .exit           = cmx270_mci_exit,
-};
+       spi->bits_per_word = 16;
+       spi_setup(spi);
 
-#ifdef CONFIG_PM
-static unsigned long sleep_save_msc[10];
+       return 0;
 
-static int cmx270_suspend(struct sys_device *dev, pm_message_t state)
-{
-       cmx270_pci_suspend();
-
-       /* save MSC registers */
-       sleep_save_msc[0] = MSC0;
-       sleep_save_msc[1] = MSC1;
-       sleep_save_msc[2] = MSC2;
-
-       /* setup power saving mode registers */
-       PCFR = 0x0;
-       PSLR = 0xff400000;
-       PMCR  = 0x00000005;
-       PWER  = 0x80000000;
-       PFER  = 0x00000000;
-       PRER  = 0x00000000;
-       PGSR0 = 0xC0018800;
-       PGSR1 = 0x004F0002;
-       PGSR2 = 0x6021C000;
-       PGSR3 = 0x00020000;
+err_free_strap:
+       gpio_free(GPIO19_WLAN_STRAP);
 
-       return 0;
+       return err;
 }
 
-static int cmx270_resume(struct sys_device *dev)
+static int cm_x270_libertas_teardown(struct spi_device *spi)
 {
-       cmx270_pci_resume();
-
-       /* restore MSC registers */
-       MSC0 = sleep_save_msc[0];
-       MSC1 = sleep_save_msc[1];
-       MSC2 = sleep_save_msc[2];
+       gpio_set_value(GPIO102_WLAN_RST, 0);
+       gpio_free(GPIO102_WLAN_RST);
+       gpio_free(GPIO19_WLAN_STRAP);
 
        return 0;
 }
 
-static struct sysdev_class cmx270_pm_sysclass = {
-       .name = "pm",
-       .resume = cmx270_resume,
-       .suspend = cmx270_suspend,
+struct libertas_spi_platform_data cm_x270_libertas_pdata = {
+       .use_dummy_writes       = 1,
+       .setup                  = cm_x270_libertas_setup,
+       .teardown               = cm_x270_libertas_teardown,
 };
 
-static struct sys_device cmx270_pm_device = {
-       .cls = &cmx270_pm_sysclass,
+static struct spi_board_info cm_x270_spi_devices[] __initdata = {
+       {
+               .modalias               = "libertas_spi",
+               .max_speed_hz           = 13000000,
+               .bus_num                = 2,
+               .irq                    = gpio_to_irq(95),
+               .chip_select            = 0,
+               .controller_data        = &cm_x270_libertas_chip,
+               .platform_data          = &cm_x270_libertas_pdata,
+       },
 };
 
-static int __init cmx270_pm_init(void)
+static void __init cmx270_init_spi(void)
 {
-       int error;
-       error = sysdev_class_register(&cmx270_pm_sysclass);
-       if (error == 0)
-               error = sysdev_register(&cmx270_pm_device);
-       return error;
+       pxa2xx_set_spi_info(2, &cm_x270_spi_info);
+       spi_register_board_info(ARRAY_AND_SIZE(cm_x270_spi_devices));
 }
 #else
-static int __init cmx270_pm_init(void) { return 0; }
+static inline void cmx270_init_spi(void) {}
 #endif
 
-static void __init cmx270_init(void)
-{
-       cmx270_pm_init();
-
-       set_pxa_fb_info(cmx270_display);
-
-       /* register CM-X270 platform devices */
-       platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
-
-       /* set MCI and OHCI platform parameters */
-       pxa_set_mci_info(&cmx270_mci_platform_data);
-       pxa_set_ohci_info(&cmx270_ohci_platform_data);
-
-       /* This enables the STUART */
-       pxa_gpio_mode(GPIO46_STRXD_MD);
-       pxa_gpio_mode(GPIO47_STTXD_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);
-}
-
-static void __init cmx270_init_irq(void)
+void __init cmx270_init(void)
 {
-       pxa27x_init_irq();
-
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(cmx270_pin_config));
 
-       cmx270_pci_init_irq();
-
-       /* Setup interrupt for dm9000 */
-       pxa_gpio_mode(IRQ_TO_GPIO(CMX270_ETHIRQ));
-       set_irq_type(CMX270_ETHIRQ, IRQT_RISING);
-
-       /* Setup interrupt for 2700G */
-       pxa_gpio_mode(IRQ_TO_GPIO(CMX270_GFXIRQ));
-       set_irq_type(CMX270_GFXIRQ, IRQT_FALLING);
-}
+#ifdef CONFIG_PM
+       pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
+#endif
 
-static void __init cmx270_map_io(void)
-{
-       pxa_map_io();
-       iotable_init(cmx270_io_desc, ARRAY_SIZE(cmx270_io_desc));
+       cmx270_init_rtc();
+       cmx270_init_mmc();
+       cmx270_init_ohci();
+       cmx270_init_2700G();
+       cmx270_init_spi();
 }
-
-
-MACHINE_START(ARMCORE, "Compulab CM-x270")
-       .boot_params    = 0xa0000100,
-       .phys_io        = 0x40000000,
-       .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
-       .map_io         = cmx270_map_io,
-       .init_irq       = cmx270_init_irq,
-       .timer          = &pxa_timer,
-       .init_machine   = cmx270_init,
-MACHINE_END