vserver 1.9.5.x5
[linux-2.6.git] / arch / arm / mach-sa1100 / collie.c
index 23bf73e..2bc071a 100644 (file)
@@ -22,6 +22,8 @@
 #include <linux/tty.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
 #include <linux/timer.h>
 
 #include <asm/hardware.h>
 #include <asm/arch/collie.h>
 
 #include <asm/mach/arch.h>
+#include <asm/mach/flash.h>
 #include <asm/mach/map.h>
 #include <asm/mach/serial_sa1100.h>
 
+#include <asm/hardware/scoop.h>
 #include <asm/hardware/locomo.h>
 
 #include "generic.h"
 
-static void __init scoop_init(void)
-{
+static struct resource collie_scoop_resources[] = {
+       [0] = {
+               .start          = 0x40800000,
+               .end            = 0x40800fff,
+               .flags          = IORESOURCE_MEM,
+       },
+};
 
-#define        COLLIE_SCP_INIT_DATA(adr,dat)   (((adr)<<16)|(dat))
-#define        COLLIE_SCP_INIT_DATA_END        ((unsigned long)-1)
-       static const unsigned long scp_init[] = {
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_MCR, 0x0140),   // 00
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_MCR, 0x0100),
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_CDR, 0x0000),   // 04
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_CPR, 0x0000),   // 0C
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_CCR, 0x0000),   // 10
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_IMR, 0x0000),   // 18
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_IRM, 0x00FF),   // 14
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_ISR, 0x0000),   // 1C
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_IRM, 0x0000),
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_GPCR, COLLIE_SCP_IO_DIR),       // 20
-               COLLIE_SCP_INIT_DATA(COLLIE_SCP_GPWR, COLLIE_SCP_IO_OUT),       // 24
-               COLLIE_SCP_INIT_DATA_END
-       };
-       int i;
-       for (i = 0; scp_init[i] != COLLIE_SCP_INIT_DATA_END; i++) {
-               int adr = scp_init[i] >> 16;
-               COLLIE_SCP_REG(adr) = scp_init[i] & 0xFFFF;
-       }
+static struct scoop_config collie_scoop_setup = {
+       .io_dir         = COLLIE_SCOOP_IO_DIR,
+       .io_out         = COLLIE_SCOOP_IO_OUT,
+};
+
+static struct platform_device colliescoop_device = {
+       .name           = "sharp-scoop",
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &collie_scoop_setup,
+       },
+       .num_resources  = ARRAY_SIZE(collie_scoop_resources),
+       .resource       = collie_scoop_resources,
+};
 
-}
 
 static struct resource locomo_resources[] = {
        [0] = {
@@ -87,6 +88,49 @@ static struct platform_device locomo_device = {
 
 static struct platform_device *devices[] __initdata = {
        &locomo_device,
+       &colliescoop_device,
+};
+
+static struct mtd_partition collie_partitions[] = {
+       {
+               .name           = "bootloader",
+               .offset         = 0,
+               .size           = 0x000C0000,
+               .mask_flags     = MTD_WRITEABLE
+       }, {
+               .name           = "kernel",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 0x00100000,
+       }, {
+               .name           = "rootfs",
+               .offset         = MTDPART_OFS_APPEND,
+               .size           = 0x00e20000,
+       }
+};
+
+static void collie_set_vpp(int vpp)
+{
+       write_scoop_reg(SCOOP_GPCR, read_scoop_reg(SCOOP_GPCR) | COLLIE_SCP_VPEN);
+       if (vpp) {
+               write_scoop_reg(SCOOP_GPWR, read_scoop_reg(SCOOP_GPWR) | COLLIE_SCP_VPEN);
+       } else {
+               write_scoop_reg(SCOOP_GPWR, read_scoop_reg(SCOOP_GPWR) & ~COLLIE_SCP_VPEN);
+       }
+}
+
+static struct flash_platform_data collie_flash_data = {
+       .map_name       = "cfi_probe",
+       .set_vpp        = collie_set_vpp,
+       .parts          = collie_partitions,
+       .nr_parts       = ARRAY_SIZE(collie_partitions),
+};
+
+static struct resource collie_flash_resources[] = {
+       {
+               .start  = SA1100_CS0_PHYS,
+               .end    = SA1100_CS0_PHYS + SZ_32M - 1,
+               .flags  = IORESOURCE_MEM,
+       }
 };
 
 static void __init collie_init(void)
@@ -115,19 +159,19 @@ static void __init collie_init(void)
        GPDR |= GPIO_32_768kHz;
        TUCR  = TUCR_32_768kHz;
 
-       scoop_init();
-
        ret = platform_add_devices(devices, ARRAY_SIZE(devices));
        if (ret) {
                printk(KERN_WARNING "collie: Unable to register LoCoMo device\n");
        }
+
+       sa11x0_set_flash_data(&collie_flash_data, collie_flash_resources,
+                             ARRAY_SIZE(collie_flash_resources));
 }
 
 static struct map_desc collie_io_desc[] __initdata = {
        /* virtual     physical    length      type */
        {0xe8000000, 0x00000000, 0x02000000, MT_DEVICE},        /* 32M main flash (cs0) */
        {0xea000000, 0x08000000, 0x02000000, MT_DEVICE},        /* 32M boot flash (cs1) */
-       {0xf0000000, 0x40000000, 0x01000000, MT_DEVICE},        /* 16M LOCOMO  & SCOOP (cs4) */
 };
 
 static void __init collie_map_io(void)
@@ -140,6 +184,6 @@ MACHINE_START(COLLIE, "Sharp-Collie")
        BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
        MAPIO(collie_map_io)
        INITIRQ(sa1100_init_irq)
-       INIT_MACHINE(collie_init)
-       INITTIME(sa1100_init_time)
+       .timer          = &sa1100_timer,
+       .init_machine   = collie_init,
 MACHINE_END