]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/nand/mxs_nand.c
powerpc: MPC8541CDS: Remove macro CONFIG_MPC8541CDS
[u-boot] / drivers / mtd / nand / mxs_nand.c
index 5528d4b45bc8cc1685cd69c6772f0358984965f1..92005448d2eeef16007bd089efe5c6a76541b72d 100644 (file)
@@ -18,7 +18,7 @@
 #include <linux/mtd/nand.h>
 #include <linux/types.h>
 #include <malloc.h>
-#include <asm/errno.h>
+#include <linux/errno.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #endif
 #define        MXS_NAND_METADATA_SIZE                  10
 #define        MXS_NAND_BITS_PER_ECC_LEVEL             13
+
+#if !defined(CONFIG_SYS_CACHELINE_SIZE) || CONFIG_SYS_CACHELINE_SIZE < 32
 #define        MXS_NAND_COMMAND_BUFFER_SIZE            32
+#else
+#define        MXS_NAND_COMMAND_BUFFER_SIZE            CONFIG_SYS_CACHELINE_SIZE
+#endif
 
 #define        MXS_NAND_BCH_TIMEOUT                    10000
 
@@ -264,8 +269,8 @@ static int mxs_nand_wait_for_bch_complete(void)
  */
 static void mxs_nand_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl)
 {
-       struct nand_chip *nand = mtd->priv;
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct nand_chip *nand = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_dma_desc *d;
        uint32_t channel = MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;
        int ret;
@@ -343,8 +348,8 @@ static void mxs_nand_cmd_ctrl(struct mtd_info *mtd, int data, unsigned int ctrl)
  */
 static int mxs_nand_device_ready(struct mtd_info *mtd)
 {
-       struct nand_chip *chip = mtd->priv;
-       struct mxs_nand_info *nand_info = chip->priv;
+       struct nand_chip *chip = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(chip);
        struct mxs_gpmi_regs *gpmi_regs =
                (struct mxs_gpmi_regs *)MXS_GPMI_BASE;
        uint32_t tmp;
@@ -360,8 +365,8 @@ static int mxs_nand_device_ready(struct mtd_info *mtd)
  */
 static void mxs_nand_select_chip(struct mtd_info *mtd, int chip)
 {
-       struct nand_chip *nand = mtd->priv;
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct nand_chip *nand = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
 
        nand_info->cur_chip = chip;
 }
@@ -410,8 +415,8 @@ static void mxs_nand_swap_block_mark(struct mtd_info *mtd,
  */
 static void mxs_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int length)
 {
-       struct nand_chip *nand = mtd->priv;
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct nand_chip *nand = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_dma_desc *d;
        uint32_t channel = MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;
        int ret;
@@ -494,8 +499,8 @@ rtn:
 static void mxs_nand_write_buf(struct mtd_info *mtd, const uint8_t *buf,
                                int length)
 {
-       struct nand_chip *nand = mtd->priv;
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct nand_chip *nand = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_dma_desc *d;
        uint32_t channel = MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;
        int ret;
@@ -559,7 +564,7 @@ static int mxs_nand_ecc_read_page(struct mtd_info *mtd, struct nand_chip *nand,
                                        uint8_t *buf, int oob_required,
                                        int page)
 {
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_dma_desc *d;
        uint32_t channel = MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;
        uint32_t corrected = 0, failed = 0;
@@ -707,9 +712,9 @@ rtn:
  */
 static int mxs_nand_ecc_write_page(struct mtd_info *mtd,
                                struct nand_chip *nand, const uint8_t *buf,
-                               int oob_required)
+                               int oob_required, int page)
 {
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_dma_desc *d;
        uint32_t channel = MXS_DMA_CHANNEL_AHB_APBH_GPMI0 + nand_info->cur_chip;
        int ret;
@@ -775,8 +780,8 @@ rtn:
 static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from,
                                        struct mtd_oob_ops *ops)
 {
-       struct nand_chip *chip = mtd->priv;
-       struct mxs_nand_info *nand_info = chip->priv;
+       struct nand_chip *chip = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(chip);
        int ret;
 
        if (ops->mode == MTD_OPS_RAW)
@@ -800,8 +805,8 @@ static int mxs_nand_hook_read_oob(struct mtd_info *mtd, loff_t from,
 static int mxs_nand_hook_write_oob(struct mtd_info *mtd, loff_t to,
                                        struct mtd_oob_ops *ops)
 {
-       struct nand_chip *chip = mtd->priv;
-       struct mxs_nand_info *nand_info = chip->priv;
+       struct nand_chip *chip = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(chip);
        int ret;
 
        if (ops->mode == MTD_OPS_RAW)
@@ -824,8 +829,8 @@ static int mxs_nand_hook_write_oob(struct mtd_info *mtd, loff_t to,
  */
 static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs)
 {
-       struct nand_chip *chip = mtd->priv;
-       struct mxs_nand_info *nand_info = chip->priv;
+       struct nand_chip *chip = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(chip);
        int ret;
 
        nand_info->marking_block_bad = 1;
@@ -884,7 +889,7 @@ static int mxs_nand_hook_block_markbad(struct mtd_info *mtd, loff_t ofs)
 static int mxs_nand_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
                                int page)
 {
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
 
        /*
         * First, fill in the OOB buffer. If we're doing a raw read, we need to
@@ -919,7 +924,7 @@ static int mxs_nand_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
 static int mxs_nand_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *nand,
                                        int page)
 {
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        uint8_t block_mark = 0;
 
        /*
@@ -961,7 +966,7 @@ static int mxs_nand_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *nand,
  * Thus, this function is only called when we want *all* blocks to look good,
  * so it *always* return success.
  */
-static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
+static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs)
 {
        return 0;
 }
@@ -976,14 +981,14 @@ static int mxs_nand_block_bad(struct mtd_info *mtd, loff_t ofs, int getchip)
  * counted, so we know the physical geometry. This enables us to make some
  * important configuration decisions.
  *
- * The return value of this function propogates directly back to this driver's
+ * The return value of this function propagates directly back to this driver's
  * call to nand_scan(). Anything other than zero will cause this driver to
  * tear everything down and declare failure.
  */
 static int mxs_nand_scan_bbt(struct mtd_info *mtd)
 {
-       struct nand_chip *nand = mtd->priv;
-       struct mxs_nand_info *nand_info = nand->priv;
+       struct nand_chip *nand = mtd_to_nand(mtd);
+       struct mxs_nand_info *nand_info = nand_get_controller_data(nand);
        struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE;
        uint32_t tmp;
 
@@ -1175,7 +1180,7 @@ int board_nand_init(struct nand_chip *nand)
 
        memset(&fake_ecc_layout, 0, sizeof(fake_ecc_layout));
 
-       nand->priv = nand_info;
+       nand_set_controller_data(nand, nand_info);
        nand->options |= NAND_NO_SUBPAGE_WRITE;
 
        nand->cmd_ctrl          = mxs_nand_cmd_ctrl;