]> err.no Git - linux-2.6/blobdiff - drivers/mtd/nand/at91_nand.c
Merge branch 'for-linus' of git://www.jni.nu/cris
[linux-2.6] / drivers / mtd / nand / at91_nand.c
index c3eb203a2ad04eb4578700e78fb7fa9eb28064c8..0adb287027a249409062c5ba6a46cadc717f50a8 100644 (file)
@@ -93,6 +93,24 @@ struct at91_nand_host {
        void __iomem            *ecc;
 };
 
+/*
+ * Enable NAND.
+ */
+static void at91_nand_enable(struct at91_nand_host *host)
+{
+       if (host->board->enable_pin)
+               at91_set_gpio_value(host->board->enable_pin, 0);
+}
+
+/*
+ * Disable NAND.
+ */
+static void at91_nand_disable(struct at91_nand_host *host)
+{
+       if (host->board->enable_pin)
+               at91_set_gpio_value(host->board->enable_pin, 1);
+}
+
 /*
  * Hardware specific access to control-lines
  */
@@ -101,6 +119,12 @@ static void at91_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
        struct nand_chip *nand_chip = mtd->priv;
        struct at91_nand_host *host = nand_chip->priv;
 
+       if (ctrl & NAND_CTRL_CHANGE) {
+               if (ctrl & NAND_NCE)
+                       at91_nand_enable(host);
+               else
+                       at91_nand_disable(host);
+       }
        if (cmd == NAND_CMD_NONE)
                return;
 
@@ -121,24 +145,6 @@ static int at91_nand_device_ready(struct mtd_info *mtd)
        return at91_get_gpio_value(host->board->rdy_pin);
 }
 
-/*
- * Enable NAND.
- */
-static void at91_nand_enable(struct at91_nand_host *host)
-{
-       if (host->board->enable_pin)
-               at91_set_gpio_value(host->board->enable_pin, 0);
-}
-
-/*
- * Disable NAND.
- */
-static void at91_nand_disable(struct at91_nand_host *host)
-{
-       if (host->board->enable_pin)
-               at91_set_gpio_value(host->board->enable_pin, 1);
-}
-
 /*
  * write oob for small pages
  */
@@ -199,7 +205,7 @@ static int at91_nand_calculate(struct mtd_info *mtd,
        unsigned int ecc_value;
 
        /* get the first 2 ECC bytes */
-       ecc_value = ecc_readl(host->ecc, PR) & AT91_ECC_PARITY;
+       ecc_value = ecc_readl(host->ecc, PR);
 
        ecc_code[eccpos[0]] = ecc_value & 0xFF;
        ecc_code[eccpos[1]] = (ecc_value >> 8) & 0xFF;