Merge remote-tracking branch 'lightnvm/for-next'
[deliverable/linux.git] / drivers / mtd / nand / brcmnand / iproc_nand.c
index 585596c549b296b9a38114d988f7aa589a265cfb..4c6ae113664d7d43658bd6db34bd4232f3549d29 100644 (file)
@@ -74,7 +74,8 @@ static void iproc_nand_intc_set(struct brcmnand_soc *soc, bool en)
        spin_unlock_irqrestore(&priv->idm_lock, flags);
 }
 
-static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare)
+static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare,
+                                 bool is_param)
 {
        struct iproc_nand_soc *priv =
                        container_of(soc, struct iproc_nand_soc, soc);
@@ -86,10 +87,19 @@ static void iproc_nand_apb_access(struct brcmnand_soc *soc, bool prepare)
 
        val = brcmnand_readl(mmio);
 
-       if (prepare)
-               val |= IPROC_NAND_APB_LE_MODE;
-       else
+       /*
+        * In the case of BE or when dealing with NAND data, alway configure
+        * the APB bus to LE mode before accessing the FIFO and back to BE mode
+        * after the access is done
+        */
+       if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) || !is_param) {
+               if (prepare)
+                       val |= IPROC_NAND_APB_LE_MODE;
+               else
+                       val &= ~IPROC_NAND_APB_LE_MODE;
+       } else { /* when in LE accessing the parameter page, keep APB in BE */
                val &= ~IPROC_NAND_APB_LE_MODE;
+       }
 
        brcmnand_writel(val, mmio);
 
This page took 0.063446 seconds and 5 git commands to generate.