]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mtd/nand/fsl_ifc_nand.c
nand: Sync with Linux v4.1
[karo-tx-uboot.git] / drivers / mtd / nand / fsl_ifc_nand.c
index 79fa88b22f975082bf6edd09cedfec71f4c8ca38..975b0d461318ff8f396de11e6021a9f3fca431a9 100644 (file)
@@ -47,7 +47,7 @@ struct fsl_ifc_ctrl {
 
        /* device info */
        struct fsl_ifc regs;
-       uint8_t __iomem *addr;   /* Address of assigned IFC buffer        */
+       void __iomem *addr;      /* Address of assigned IFC buffer        */
        unsigned int cs_nand;    /* On which chipsel NAND is connected    */
        unsigned int page;       /* Last page written to / read from      */
        unsigned int read_bytes; /* Number of bytes read during command   */
@@ -577,8 +577,15 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command,
 
                fsl_ifc_run_command(mtd);
 
-               /* Chip sometimes reporting write protect even when it's not */
-               out_8(ctrl->addr, in_8(ctrl->addr) | NAND_STATUS_WP);
+               /*
+                * The chip always seems to report that it is
+                * write-protected, even when it is not.
+                */
+               if (chip->options & NAND_BUSWIDTH_16)
+                       ifc_out16(ctrl->addr,
+                                 ifc_in16(ctrl->addr) | NAND_STATUS_WP);
+               else
+                       out_8(ctrl->addr, in_8(ctrl->addr) | NAND_STATUS_WP);
                return;
 
        case NAND_CMD_RESET:
@@ -618,7 +625,7 @@ static void fsl_ifc_write_buf(struct mtd_info *mtd, const u8 *buf, int len)
                len = bufsize - ctrl->index;
        }
 
-       memcpy_toio(&ctrl->addr[ctrl->index], buf, len);
+       memcpy_toio(ctrl->addr + ctrl->index, buf, len);
        ctrl->index += len;
 }
 
@@ -631,11 +638,16 @@ static u8 fsl_ifc_read_byte(struct mtd_info *mtd)
        struct nand_chip *chip = mtd->priv;
        struct fsl_ifc_mtd *priv = chip->priv;
        struct fsl_ifc_ctrl *ctrl = priv->ctrl;
+       unsigned int offset;
 
-       /* If there are still bytes in the IFC buffer, then use the
-        * next byte. */
-       if (ctrl->index < ctrl->read_bytes)
-               return in_8(&ctrl->addr[ctrl->index++]);
+       /*
+        * If there are still bytes in the IFC buffer, then use the
+        * next byte.
+        */
+       if (ctrl->index < ctrl->read_bytes) {
+               offset = ctrl->index++;
+               return in_8(ctrl->addr + offset);
+       }
 
        printf("%s beyond end of buffer\n", __func__);
        return ERR_BYTE;
@@ -657,8 +669,7 @@ static uint8_t fsl_ifc_read_byte16(struct mtd_info *mtd)
         * next byte.
         */
        if (ctrl->index < ctrl->read_bytes) {
-               data = ifc_in16((uint16_t *)&ctrl->
-                                addr[ctrl->index]);
+               data = ifc_in16(ctrl->addr + ctrl->index);
                ctrl->index += 2;
                return (uint8_t)data;
        }
@@ -681,7 +692,7 @@ static void fsl_ifc_read_buf(struct mtd_info *mtd, u8 *buf, int len)
                return;
 
        avail = min((unsigned int)len, ctrl->read_bytes - ctrl->index);
-       memcpy_fromio(buf, &ctrl->addr[ctrl->index], avail);
+       memcpy_fromio(buf, ctrl->addr + ctrl->index, avail);
        ctrl->index += avail;
 
        if (len > avail)