Merge branch 'master' into for-2.6.35
[safe/jmp/linux-2.6] / drivers / mtd / nand / orion_nand.c
index 6400248..d60fc57 100644 (file)
@@ -19,7 +19,7 @@
 #include <asm/io.h>
 #include <asm/sizes.h>
 #include <mach/hardware.h>
-#include <asm/plat-orion/orion_nand.h>
+#include <plat/orion_nand.h>
 
 #ifdef CONFIG_MTD_CMDLINE_PARTS
 static const char *part_probes[] = { "cmdlinepart", NULL };
@@ -47,6 +47,34 @@ static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl
        writeb(cmd, nc->IO_ADDR_W + offs);
 }
 
+static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
+{
+       struct nand_chip *chip = mtd->priv;
+       void __iomem *io_base = chip->IO_ADDR_R;
+       uint64_t *buf64;
+       int i = 0;
+
+       while (len && (unsigned long)buf & 7) {
+               *buf++ = readb(io_base);
+               len--;
+       }
+       buf64 = (uint64_t *)buf;
+       while (i < len/8) {
+               /*
+                * Since GCC has no proper constraint (PR 43518)
+                * force x variable to r2/r3 registers as ldrd instruction
+                * requires first register to be even.
+                */
+               register uint64_t x asm ("r2");
+
+               asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base));
+               buf64[i++] = x;
+       }
+       i *= 8;
+       while (i < len)
+               buf[i++] = readb(io_base);
+}
+
 static int __init orion_nand_probe(struct platform_device *pdev)
 {
        struct mtd_info *mtd;
@@ -83,6 +111,7 @@ static int __init orion_nand_probe(struct platform_device *pdev)
        nc->priv = board;
        nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
        nc->cmd_ctrl = orion_nand_cmd_ctrl;
+       nc->read_buf = orion_nand_read_buf;
        nc->ecc.mode = NAND_ECC_SOFT;
 
        if (board->chip_delay)
@@ -148,8 +177,7 @@ static int __devexit orion_nand_remove(struct platform_device *pdev)
 }
 
 static struct platform_driver orion_nand_driver = {
-       .probe          = orion_nand_probe,
-       .remove         = orion_nand_remove,
+       .remove         = __devexit_p(orion_nand_remove),
        .driver         = {
                .name   = "orion_nand",
                .owner  = THIS_MODULE,
@@ -158,7 +186,7 @@ static struct platform_driver orion_nand_driver = {
 
 static int __init orion_nand_init(void)
 {
-       return platform_driver_register(&orion_nand_driver);
+       return platform_driver_probe(&orion_nand_driver, orion_nand_probe);
 }
 
 static void __exit orion_nand_exit(void)