[ARM] pxa: introduce pxa{25x,27x,300,320,930}.h for board usage
[safe/jmp/linux-2.6] / arch / arm / mach-pxa / corgi.c
index fc428b8..3b89e50 100644 (file)
 
 #include <linux/kernel.h>
 #include <linux/init.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/interrupt.h>
 #include <linux/mmc/host.h>
+#include <linux/mtd/physmap.h>
+#include <linux/pm.h>
+#include <linux/gpio.h>
+#include <linux/backlight.h>
+#include <linux/io.h>
+#include <linux/spi/spi.h>
+#include <linux/spi/ads7846.h>
+#include <linux/spi/corgi_lcd.h>
+#include <linux/mtd/sharpsl.h>
+#include <video/w100fb.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/io.h>
+#include <asm/system.h>
 
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/irq.h>
 
-#include <asm/arch/pxa-regs.h>
-#include <asm/arch/irq.h>
-#include <asm/arch/mmc.h>
-#include <asm/arch/udc.h>
-#include <asm/arch/corgi.h>
+#include <mach/pxa25x.h>
+#include <mach/i2c.h>
+#include <mach/irda.h>
+#include <mach/mmc.h>
+#include <mach/udc.h>
+#include <mach/pxa2xx_spi.h>
+#include <mach/corgi.h>
+#include <mach/sharpsl.h>
 
 #include <asm/mach/sharpsl_param.h>
 #include <asm/hardware/scoop.h>
 
 #include "generic.h"
+#include "devices.h"
 #include "sharpsl.h"
 
+static unsigned long corgi_pin_config[] __initdata = {
+       /* Static Memory I/O */
+       GPIO78_nCS_2,   /* w100fb */
+       GPIO80_nCS_4,   /* scoop */
+
+       /* SSP1 */
+       GPIO23_SSP1_SCLK,
+       GPIO25_SSP1_TXD,
+       GPIO26_SSP1_RXD,
+       GPIO24_GPIO,    /* CORGI_GPIO_ADS7846_CS - SFRM as chip select */
+
+       /* I2S */
+       GPIO28_I2S_BITCLK_OUT,
+       GPIO29_I2S_SDATA_IN,
+       GPIO30_I2S_SDATA_OUT,
+       GPIO31_I2S_SYNC,
+       GPIO32_I2S_SYSCLK,
+
+       /* Infra-Red */
+       GPIO47_FICP_TXD,
+       GPIO46_FICP_RXD,
+
+       /* FFUART */
+       GPIO40_FFUART_DTR,
+       GPIO41_FFUART_RTS,
+       GPIO39_FFUART_TXD,
+       GPIO37_FFUART_DSR,
+       GPIO34_FFUART_RXD,
+       GPIO35_FFUART_CTS,
+
+       /* 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,
+
+       /* GPIO */
+       GPIO9_GPIO,     /* CORGI_GPIO_nSD_DETECT */
+       GPIO7_GPIO,     /* CORGI_GPIO_nSD_WP */
+       GPIO33_GPIO,    /* CORGI_GPIO_SD_PWR */
+       GPIO22_GPIO,    /* CORGI_GPIO_IR_ON */
+       GPIO44_GPIO,    /* CORGI_GPIO_HSYNC */
+
+       GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
+};
 
 /*
  * Corgi SCOOP Device
@@ -58,6 +127,17 @@ static struct resource corgi_scoop_resources[] = {
 static struct scoop_config corgi_scoop_setup = {
        .io_dir         = CORGI_SCOOP_IO_DIR,
        .io_out         = CORGI_SCOOP_IO_OUT,
+       .gpio_base      = CORGI_SCOOP_GPIO_BASE,
+};
+
+struct platform_device corgiscoop_device = {
+       .name           = "sharp-scoop",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &corgi_scoop_setup,
+       },
+       .num_resources  = ARRAY_SIZE(corgi_scoop_resources),
+       .resource       = corgi_scoop_resources,
 };
 
 static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
@@ -69,54 +149,119 @@ static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
 },
 };
 
-struct platform_device corgiscoop_device = {
-       .name           = "sharp-scoop",
-       .id             = -1,
-       .dev            = {
-               .platform_data  = &corgi_scoop_setup,
-       },
-       .num_resources  = ARRAY_SIZE(corgi_scoop_resources),
-       .resource       = corgi_scoop_resources,
+static struct scoop_pcmcia_config corgi_pcmcia_config = {
+       .devs         = &corgi_pcmcia_scoop[0],
+       .num_devs     = 1,
 };
 
+EXPORT_SYMBOL(corgiscoop_device);
 
-/*
- * Corgi SSP Device
- *
- * Set the parent as the scoop device because a lot of SSP devices
- * also use scoop functions and this makes the power up/down order
- * work correctly.
- */
-struct platform_device corgissp_device = {
-       .name           = "corgi-ssp",
-       .dev            = {
-               .parent = &corgiscoop_device.dev,
-       },
-       .id             = -1,
+static struct w100_mem_info corgi_fb_mem = {
+       .ext_cntl          = 0x00040003,
+       .sdram_mode_reg    = 0x00650021,
+       .ext_timing_cntl   = 0x10002a4a,
+       .io_cntl           = 0x7ff87012,
+       .size              = 0x1fffff,
 };
 
-struct corgissp_machinfo corgi_ssp_machinfo = {
-       .port           = 1,
-       .cs_lcdcon      = CORGI_GPIO_LCDCON_CS,
-       .cs_ads7846     = CORGI_GPIO_ADS7846_CS,
-       .cs_max1111     = CORGI_GPIO_MAX1111_CS,
-       .clk_lcdcon     = 76,
-       .clk_ads7846    = 2,
-       .clk_max1111    = 8,
+static struct w100_gen_regs corgi_fb_regs = {
+       .lcd_format    = 0x00000003,
+       .lcdd_cntl1    = 0x01CC0000,
+       .lcdd_cntl2    = 0x0003FFFF,
+       .genlcd_cntl1  = 0x00FFFF0D,
+       .genlcd_cntl2  = 0x003F3003,
+       .genlcd_cntl3  = 0x000102aa,
 };
 
+static struct w100_gpio_regs corgi_fb_gpio = {
+       .init_data1   = 0x000000bf,
+       .init_data2   = 0x00000000,
+       .gpio_dir1    = 0x00000000,
+       .gpio_oe1     = 0x03c0feff,
+       .gpio_dir2    = 0x00000000,
+       .gpio_oe2     = 0x00000000,
+};
 
-/*
- * Corgi Backlight Device
- */
-static struct platform_device corgibl_device = {
-       .name           = "corgi-bl",
-       .dev            = {
-               .parent = &corgifb_device.dev,
+static struct w100_mode corgi_fb_modes[] = {
+{
+       .xres            = 480,
+       .yres            = 640,
+       .left_margin     = 0x56,
+       .right_margin    = 0x55,
+       .upper_margin    = 0x03,
+       .lower_margin    = 0x00,
+       .crtc_ss         = 0x82360056,
+       .crtc_ls         = 0xA0280000,
+       .crtc_gs         = 0x80280028,
+       .crtc_vpos_gs    = 0x02830002,
+       .crtc_rev        = 0x00400008,
+       .crtc_dclk       = 0xA0000000,
+       .crtc_gclk       = 0x8015010F,
+       .crtc_goe        = 0x80100110,
+       .crtc_ps1_active = 0x41060010,
+       .pll_freq        = 75,
+       .fast_pll_freq   = 100,
+       .sysclk_src      = CLK_SRC_PLL,
+       .sysclk_divider  = 0,
+       .pixclk_src      = CLK_SRC_PLL,
+       .pixclk_divider  = 2,
+       .pixclk_divider_rotated = 6,
+},{
+       .xres            = 240,
+       .yres            = 320,
+       .left_margin     = 0x27,
+       .right_margin    = 0x2e,
+       .upper_margin    = 0x01,
+       .lower_margin    = 0x00,
+       .crtc_ss         = 0x81170027,
+       .crtc_ls         = 0xA0140000,
+       .crtc_gs         = 0xC0140014,
+       .crtc_vpos_gs    = 0x00010141,
+       .crtc_rev        = 0x00400008,
+       .crtc_dclk       = 0xA0000000,
+       .crtc_gclk       = 0x8015010F,
+       .crtc_goe        = 0x80100110,
+       .crtc_ps1_active = 0x41060010,
+       .pll_freq        = 0,
+       .fast_pll_freq   = 0,
+       .sysclk_src      = CLK_SRC_XTAL,
+       .sysclk_divider  = 0,
+       .pixclk_src      = CLK_SRC_XTAL,
+       .pixclk_divider  = 1,
+       .pixclk_divider_rotated = 1,
+},
+
+};
+
+static struct w100fb_mach_info corgi_fb_info = {
+       .init_mode  = INIT_MODE_ROTATED,
+       .mem        = &corgi_fb_mem,
+       .regs       = &corgi_fb_regs,
+       .modelist   = &corgi_fb_modes[0],
+       .num_modes  = 2,
+       .gpio       = &corgi_fb_gpio,
+       .xtal_freq  = 12500000,
+       .xtal_dbl   = 0,
+};
+
+static struct resource corgi_fb_resources[] = {
+       [0] = {
+               .start   = 0x08000000,
+               .end     = 0x08ffffff,
+               .flags   = IORESOURCE_MEM,
        },
-       .id             = -1,
 };
 
+static struct platform_device corgifb_device = {
+       .name           = "w100fb",
+       .id             = -1,
+       .num_resources  = ARRAY_SIZE(corgi_fb_resources),
+       .resource       = corgi_fb_resources,
+       .dev            = {
+               .platform_data = &corgi_fb_info,
+       },
+
+};
 
 /*
  * Corgi Keyboard Device
@@ -126,36 +271,35 @@ static struct platform_device corgikbd_device = {
        .id             = -1,
 };
 
-
 /*
- * Corgi Touch Screen Device
+ * Corgi LEDs
  */
-static struct resource corgits_resources[] = {
-       [0] = {
-               .start          = CORGI_IRQ_GPIO_TP_INT,
-               .end            = CORGI_IRQ_GPIO_TP_INT,
-               .flags          = IORESOURCE_IRQ,
+static struct gpio_led corgi_gpio_leds[] = {
+       {
+               .name                   = "corgi:amber:charge",
+               .default_trigger        = "sharpsl-charge",
+               .gpio                   = CORGI_GPIO_LED_ORANGE,
+       },
+       {
+               .name                   = "corgi:green:mail",
+               .default_trigger        = "nand-disk",
+               .gpio                   = CORGI_GPIO_LED_GREEN,
        },
 };
 
-static struct corgits_machinfo  corgi_ts_machinfo = {
-       .get_hsync_len   = corgi_get_hsync_len,
-       .put_hsync       = corgi_put_hsync,
-       .wait_hsync      = corgi_wait_hsync,
+static struct gpio_led_platform_data corgi_gpio_leds_info = {
+       .leds           = corgi_gpio_leds,
+       .num_leds       = ARRAY_SIZE(corgi_gpio_leds),
 };
 
-static struct platform_device corgits_device = {
-       .name           = "corgi-ts",
+static struct platform_device corgiled_device = {
+       .name           = "leds-gpio",
+       .id             = -1,
        .dev            = {
-               .parent = &corgissp_device.dev,
-               .platform_data  = &corgi_ts_machinfo,
+               .platform_data = &corgi_gpio_leds_info,
        },
-       .id             = -1,
-       .num_resources  = ARRAY_SIZE(corgits_resources),
-       .resource       = corgits_resources,
 };
 
-
 /*
  * MMC/SD Device
  *
@@ -164,51 +308,67 @@ static struct platform_device corgits_device = {
  */
 static struct pxamci_platform_data corgi_mci_platform_data;
 
-static int corgi_mci_init(struct device *dev, irqreturn_t (*corgi_detect_int)(int, void *, struct pt_regs *), void *data)
+static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, void *data)
 {
        int err;
 
-       /* setup GPIO for PXA25x MMC controller */
-       pxa_gpio_mode(GPIO6_MMCCLK_MD);
-       pxa_gpio_mode(GPIO8_MMCCS0_MD);
-       pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN);
-       pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT);
+       err = gpio_request(CORGI_GPIO_nSD_DETECT, "nSD_DETECT");
+       if (err)
+               goto err_out;
+
+       err = gpio_request(CORGI_GPIO_nSD_WP, "nSD_WP");
+       if (err)
+               goto err_free_1;
+
+       err = gpio_request(CORGI_GPIO_SD_PWR, "SD_PWR");
+       if (err)
+               goto err_free_2;
+
+       gpio_direction_input(CORGI_GPIO_nSD_DETECT);
+       gpio_direction_input(CORGI_GPIO_nSD_WP);
+       gpio_direction_output(CORGI_GPIO_SD_PWR, 0);
 
        corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250);
 
-       err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int, SA_INTERRUPT,
-                            "MMC card detect", data);
+       err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int,
+                               IRQF_DISABLED | IRQF_TRIGGER_RISING |
+                               IRQF_TRIGGER_FALLING,
+                               "MMC card detect", data);
        if (err) {
-               printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
-               return -1;
+               pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
+                               __func__);
+               goto err_free_3;
        }
-
-       set_irq_type(CORGI_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
-
        return 0;
+
+err_free_3:
+       gpio_free(CORGI_GPIO_SD_PWR);
+err_free_2:
+       gpio_free(CORGI_GPIO_nSD_WP);
+err_free_1:
+       gpio_free(CORGI_GPIO_nSD_DETECT);
+err_out:
+       return err;
 }
 
 static void corgi_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", __FUNCTION__);
-               GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
-       } else {
-               printk(KERN_DEBUG "%s: off\n", __FUNCTION__);
-               GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
-       }
+       gpio_set_value(CORGI_GPIO_SD_PWR, ((1 << vdd) & p_d->ocr_mask));
 }
 
 static int corgi_mci_get_ro(struct device *dev)
 {
-       return GPLR(CORGI_GPIO_nSD_WP) & GPIO_bit(CORGI_GPIO_nSD_WP);
+       return gpio_get_value(CORGI_GPIO_nSD_WP);
 }
 
 static void corgi_mci_exit(struct device *dev, void *data)
 {
        free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
+       gpio_free(CORGI_GPIO_SD_PWR);
+       gpio_free(CORGI_GPIO_nSD_WP);
+       gpio_free(CORGI_GPIO_nSD_DETECT);
 }
 
 static struct pxamci_platform_data corgi_mci_platform_data = {
@@ -220,48 +380,294 @@ static struct pxamci_platform_data corgi_mci_platform_data = {
 };
 
 
+/*
+ * Irda
+ */
+static void corgi_irda_transceiver_mode(struct device *dev, int mode)
+{
+       gpio_set_value(CORGI_GPIO_IR_ON, mode & IR_OFF);
+       pxa2xx_transceiver_mode(dev, mode);
+}
+
+static int corgi_irda_startup(struct device *dev)
+{
+       int err;
+
+       err = gpio_request(CORGI_GPIO_IR_ON, "IR_ON");
+       if (err)
+               return err;
+
+       gpio_direction_output(CORGI_GPIO_IR_ON, 1);
+       return 0;
+}
+
+static void corgi_irda_shutdown(struct device *dev)
+{
+       gpio_free(CORGI_GPIO_IR_ON);
+}
+
+static struct pxaficp_platform_data corgi_ficp_platform_data = {
+       .transceiver_cap        = IR_SIRMODE | IR_OFF,
+       .transceiver_mode       = corgi_irda_transceiver_mode,
+       .startup                = corgi_irda_startup,
+       .shutdown               = corgi_irda_shutdown,
+};
+
 
 /*
  * USB Device Controller
  */
-static void corgi_udc_command(int cmd)
+static struct pxa2xx_udc_mach_info udc_info __initdata = {
+       /* no connect GPIO; corgi can't tell connection status */
+       .gpio_pullup            = CORGI_GPIO_USB_PULLUP,
+};
+
+#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER)
+static struct pxa2xx_spi_master corgi_spi_info = {
+       .num_chipselect = 3,
+};
+
+static struct ads7846_platform_data corgi_ads7846_info = {
+       .model                  = 7846,
+       .vref_delay_usecs       = 100,
+       .x_plate_ohms           = 419,
+       .y_plate_ohms           = 486,
+       .gpio_pendown           = CORGI_GPIO_TP_INT,
+};
+
+static void corgi_ads7846_cs(u32 command)
+{
+       gpio_set_value(CORGI_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
+}
+
+static struct pxa2xx_spi_chip corgi_ads7846_chip = {
+       .cs_control     = corgi_ads7846_cs,
+};
+
+static void corgi_bl_kick_battery(void)
 {
-       switch(cmd)     {
-       case PXA2XX_UDC_CMD_CONNECT:
-               GPSR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
-               break;
-       case PXA2XX_UDC_CMD_DISCONNECT:
-               GPCR(CORGI_GPIO_USB_PULLUP) = GPIO_bit(CORGI_GPIO_USB_PULLUP);
-               break;
+       void (*kick_batt)(void);
+
+       kick_batt = symbol_get(sharpsl_battery_kick);
+       if (kick_batt) {
+               kick_batt();
+               symbol_put(sharpsl_battery_kick);
        }
 }
 
-static struct pxa2xx_udc_mach_info udc_info __initdata = {
-       /* no connect GPIO; corgi can't tell connection status */
-       .udc_command            = corgi_udc_command,
+static struct corgi_lcd_platform_data corgi_lcdcon_info = {
+       .init_mode              = CORGI_LCD_MODE_VGA,
+       .max_intensity          = 0x2f,
+       .default_intensity      = 0x1f,
+       .limit_mask             = 0x0b,
+       .gpio_backlight_cont    = CORGI_GPIO_BACKLIGHT_CONT,
+       .gpio_backlight_on      = -1,
+       .kick_battery           = corgi_bl_kick_battery,
+};
+
+static void corgi_lcdcon_cs(u32 command)
+{
+       gpio_set_value(CORGI_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
+}
+
+static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
+       .cs_control     = corgi_lcdcon_cs,
+};
+
+static void corgi_max1111_cs(u32 command)
+{
+       gpio_set_value(CORGI_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
+}
+
+static struct pxa2xx_spi_chip corgi_max1111_chip = {
+       .cs_control     = corgi_max1111_cs,
+};
+
+static struct spi_board_info corgi_spi_devices[] = {
+       {
+               .modalias       = "ads7846",
+               .max_speed_hz   = 1200000,
+               .bus_num        = 1,
+               .chip_select    = 0,
+               .platform_data  = &corgi_ads7846_info,
+               .controller_data= &corgi_ads7846_chip,
+               .irq            = gpio_to_irq(CORGI_GPIO_TP_INT),
+       }, {
+               .modalias       = "corgi-lcd",
+               .max_speed_hz   = 50000,
+               .bus_num        = 1,
+               .chip_select    = 1,
+               .platform_data  = &corgi_lcdcon_info,
+               .controller_data= &corgi_lcdcon_chip,
+       }, {
+               .modalias       = "max1111",
+               .max_speed_hz   = 450000,
+               .bus_num        = 1,
+               .chip_select    = 2,
+               .controller_data= &corgi_max1111_chip,
+       },
+};
+
+static void __init corgi_init_spi(void)
+{
+       int err;
+
+       err = gpio_request(CORGI_GPIO_ADS7846_CS, "ADS7846_CS");
+       if (err)
+               return;
+
+       err = gpio_request(CORGI_GPIO_LCDCON_CS, "LCDCON_CS");
+       if (err)
+               goto err_free_1;
+
+       err = gpio_request(CORGI_GPIO_MAX1111_CS, "MAX1111_CS");
+       if (err)
+               goto err_free_2;
+
+       gpio_direction_output(CORGI_GPIO_ADS7846_CS, 1);
+       gpio_direction_output(CORGI_GPIO_LCDCON_CS, 1);
+       gpio_direction_output(CORGI_GPIO_MAX1111_CS, 1);
+
+       pxa2xx_set_spi_info(1, &corgi_spi_info);
+       spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));
+       return;
+
+err_free_2:
+       gpio_free(CORGI_GPIO_LCDCON_CS);
+err_free_1:
+       gpio_free(CORGI_GPIO_ADS7846_CS);
+}
+#else
+static inline void corgi_init_spi(void) {}
+#endif
+
+static struct mtd_partition sharpsl_nand_partitions[] = {
+       {
+               .name = "System Area",
+               .offset = 0,
+               .size = 7 * 1024 * 1024,
+       },
+       {
+               .name = "Root Filesystem",
+               .offset = 7 * 1024 * 1024,
+               .size = 25 * 1024 * 1024,
+       },
+       {
+               .name = "Home Filesystem",
+               .offset = MTDPART_OFS_APPEND,
+               .size = MTDPART_SIZ_FULL,
+       },
+};
+
+static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
+
+static struct nand_bbt_descr sharpsl_bbt = {
+       .options = 0,
+       .offs = 4,
+       .len = 2,
+       .pattern = scan_ff_pattern
+};
+
+static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
+       .badblock_pattern       = &sharpsl_bbt,
+       .partitions             = sharpsl_nand_partitions,
+       .nr_partitions          = ARRAY_SIZE(sharpsl_nand_partitions),
+};
+
+static struct resource sharpsl_nand_resources[] = {
+       {
+               .start  = 0x0C000000,
+               .end    = 0x0C000FFF,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device sharpsl_nand_device = {
+       .name           = "sharpsl-nand",
+       .id             = -1,
+       .resource       = sharpsl_nand_resources,
+       .num_resources  = ARRAY_SIZE(sharpsl_nand_resources),
+       .dev.platform_data      = &sharpsl_nand_platform_data,
+};
+
+static struct mtd_partition sharpsl_rom_parts[] = {
+       {
+               .name   ="Boot PROM Filesystem",
+               .offset = 0x00120000,
+               .size   = MTDPART_SIZ_FULL,
+       },
 };
 
+static struct physmap_flash_data sharpsl_rom_data = {
+       .width          = 2,
+       .nr_parts       = ARRAY_SIZE(sharpsl_rom_parts),
+       .parts          = sharpsl_rom_parts,
+};
+
+static struct resource sharpsl_rom_resources[] = {
+       {
+               .start  = 0x00000000,
+               .end    = 0x007fffff,
+               .flags  = IORESOURCE_MEM,
+       },
+};
+
+static struct platform_device sharpsl_rom_device = {
+       .name   = "physmap-flash",
+       .id     = -1,
+       .resource = sharpsl_rom_resources,
+       .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
+       .dev.platform_data = &sharpsl_rom_data,
+};
 
 static struct platform_device *devices[] __initdata = {
        &corgiscoop_device,
-       &corgissp_device,
        &corgifb_device,
        &corgikbd_device,
-       &corgibl_device,
-       &corgits_device,
+       &corgiled_device,
+       &sharpsl_nand_device,
+       &sharpsl_rom_device,
 };
 
+static void corgi_poweroff(void)
+{
+       if (!machine_is_corgi())
+               /* Green LED off tells the bootloader to halt */
+               gpio_set_value(CORGI_GPIO_LED_GREEN, 0);
+
+       arm_machine_restart('h');
+}
+
+static void corgi_restart(char mode)
+{
+       if (!machine_is_corgi())
+               /* Green LED on tells the bootloader to reboot */
+               gpio_set_value(CORGI_GPIO_LED_GREEN, 1);
+
+       arm_machine_restart('h');
+}
+
 static void __init corgi_init(void)
 {
-       corgi_ssp_set_machinfo(&corgi_ssp_machinfo);
+       pm_power_off = corgi_poweroff;
+       arm_pm_restart = corgi_restart;
+
+       /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
+       PCFR |= PCFR_OPDE;
+
+       pxa2xx_mfp_config(ARRAY_AND_SIZE(corgi_pin_config));
+
+       corgi_init_spi();
 
-       pxa_gpio_mode(CORGI_GPIO_USB_PULLUP | GPIO_OUT);
-       pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
        pxa_set_udc_info(&udc_info);
        pxa_set_mci_info(&corgi_mci_platform_data);
+       pxa_set_ficp_info(&corgi_ficp_platform_data);
+       pxa_set_i2c_info(NULL);
+
+       platform_scoop_config = &corgi_pcmcia_config;
 
-       scoop_num = 1;
-       scoop_devs = &corgi_pcmcia_scoop[0];
+       if (machine_is_husky())
+               sharpsl_nand_partitions[1].size = 53 * 1024 * 1024;
 
        platform_add_devices(devices, ARRAY_SIZE(devices));
 }
@@ -279,42 +685,13 @@ static void __init fixup_corgi(struct machine_desc *desc,
                mi->bank[0].size = (64*1024*1024);
 }
 
-static void __init corgi_init_irq(void)
-{
-       pxa_init_irq();
-}
-
-static struct map_desc corgi_io_desc[] __initdata = {
-/*    virtual     physical    length      */
-/*     { 0xf1000000, 0x08000000, 0x01000000, MT_DEVICE },*/ /* LCDC (readable for Qt driver) */
-/*     { 0xef700000, 0x10800000, 0x00001000, MT_DEVICE },*/  /* SCOOP */
-       { 0xef800000, 0x00000000, 0x00800000, MT_DEVICE }, /* Boot Flash */
-};
-
-static void __init corgi_map_io(void)
-{
-       pxa_map_io();
-       iotable_init(corgi_io_desc,ARRAY_SIZE(corgi_io_desc));
-
-       /* setup sleep mode values */
-       PWER  = 0x00000002;
-       PFER  = 0x00000000;
-       PRER  = 0x00000002;
-       PGSR0 = 0x0158C000;
-       PGSR1 = 0x00FF0080;
-       PGSR2 = 0x0001C004;
-       /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
-       PCFR |= PCFR_OPDE;
-}
-
 #ifdef CONFIG_MACH_CORGI
 MACHINE_START(CORGI, "SHARP Corgi")
-       .phys_ram       = 0xa0000000,
        .phys_io        = 0x40000000,
        .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
        .fixup          = fixup_corgi,
-       .map_io         = corgi_map_io,
-       .init_irq       = corgi_init_irq,
+       .map_io         = pxa_map_io,
+       .init_irq       = pxa25x_init_irq,
        .init_machine   = corgi_init,
        .timer          = &pxa_timer,
 MACHINE_END
@@ -322,12 +699,11 @@ MACHINE_END
 
 #ifdef CONFIG_MACH_SHEPHERD
 MACHINE_START(SHEPHERD, "SHARP Shepherd")
-       .phys_ram       = 0xa0000000,
        .phys_io        = 0x40000000,
        .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
        .fixup          = fixup_corgi,
-       .map_io         = corgi_map_io,
-       .init_irq       = corgi_init_irq,
+       .map_io         = pxa_map_io,
+       .init_irq       = pxa25x_init_irq,
        .init_machine   = corgi_init,
        .timer          = &pxa_timer,
 MACHINE_END
@@ -335,12 +711,11 @@ MACHINE_END
 
 #ifdef CONFIG_MACH_HUSKY
 MACHINE_START(HUSKY, "SHARP Husky")
-       .phys_ram       = 0xa0000000,
        .phys_io        = 0x40000000,
        .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
        .fixup          = fixup_corgi,
-       .map_io         = corgi_map_io,
-       .init_irq       = corgi_init_irq,
+       .map_io         = pxa_map_io,
+       .init_irq       = pxa25x_init_irq,
        .init_machine   = corgi_init,
        .timer          = &pxa_timer,
 MACHINE_END