]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/mtd/nand/s3c2410_nand.c
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
[karo-tx-uboot.git] / drivers / mtd / nand / s3c2410_nand.c
index f70daefbfe126c5910dffd444697e79b00312773..b3a2a60bb268f26740b60fc968af6870405e2ceb 100644 (file)
@@ -2,20 +2,7 @@
  * (C) Copyright 2006 OpenMoko, Inc.
  * Author: Harald Welte <laforge@openmoko.org>
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -51,12 +38,12 @@ static void nand_read_buf(struct mtd_info *mtd, u_char *buf, int len)
 }
 #endif
 
-static void s3c2410_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
+static void s3c24x0_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
 {
        struct nand_chip *chip = mtd->priv;
-       struct s3c2410_nand *nand = s3c2410_get_base_nand();
+       struct s3c24x0_nand *nand = s3c24x0_get_base_nand();
 
-       debugX(1, "hwcontrol(): 0x%02x 0x%02x\n", cmd, ctrl);
+       debug("hwcontrol(): 0x%02x 0x%02x\n", cmd, ctrl);
 
        if (ctrl & NAND_CTRL_CHANGE) {
                ulong IO_ADDR_W = (ulong)nand;
@@ -80,35 +67,35 @@ static void s3c2410_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
                writeb(cmd, chip->IO_ADDR_W);
 }
 
-static int s3c2410_dev_ready(struct mtd_info *mtd)
+static int s3c24x0_dev_ready(struct mtd_info *mtd)
 {
-       struct s3c2410_nand *nand = s3c2410_get_base_nand();
-       debugX(1, "dev_ready\n");
+       struct s3c24x0_nand *nand = s3c24x0_get_base_nand();
+       debug("dev_ready\n");
        return readl(&nand->nfstat) & 0x01;
 }
 
 #ifdef CONFIG_S3C2410_NAND_HWECC
-void s3c2410_nand_enable_hwecc(struct mtd_info *mtd, int mode)
+void s3c24x0_nand_enable_hwecc(struct mtd_info *mtd, int mode)
 {
-       struct s3c2410_nand *nand = s3c2410_get_base_nand();
-       debugX(1, "s3c2410_nand_enable_hwecc(%p, %d)\n", mtd, mode);
+       struct s3c24x0_nand *nand = s3c24x0_get_base_nand();
+       debug("s3c24x0_nand_enable_hwecc(%p, %d)\n", mtd, mode);
        writel(readl(&nand->nfconf) | S3C2410_NFCONF_INITECC, &nand->nfconf);
 }
 
-static int s3c2410_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
+static int s3c24x0_nand_calculate_ecc(struct mtd_info *mtd, const u_char *dat,
                                      u_char *ecc_code)
 {
-       struct s3c2410_nand *nand = s3c2410_get_base_nand();
+       struct s3c24x0_nand *nand = s3c24x0_get_base_nand();
        ecc_code[0] = readb(&nand->nfecc);
        ecc_code[1] = readb(&nand->nfecc + 1);
        ecc_code[2] = readb(&nand->nfecc + 2);
-       debugX(1, "s3c2410_nand_calculate_hwecc(%p,): 0x%02x 0x%02x 0x%02x\n",
-              mtd , ecc_code[0], ecc_code[1], ecc_code[2]);
+       debug("s3c24x0_nand_calculate_hwecc(%p,): 0x%02x 0x%02x 0x%02x\n",
+             mtd , ecc_code[0], ecc_code[1], ecc_code[2]);
 
        return 0;
 }
 
-static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
+static int s3c24x0_nand_correct_data(struct mtd_info *mtd, u_char *dat,
                                     u_char *read_ecc, u_char *calc_ecc)
 {
        if (read_ecc[0] == calc_ecc[0] &&
@@ -116,7 +103,7 @@ static int s3c2410_nand_correct_data(struct mtd_info *mtd, u_char *dat,
            read_ecc[2] == calc_ecc[2])
                return 0;
 
-       printf("s3c2410_nand_correct_data: not implemented\n");
+       printf("s3c24x0_nand_correct_data: not implemented\n");
        return -1;
 }
 #endif
@@ -126,16 +113,22 @@ int board_nand_init(struct nand_chip *nand)
        u_int32_t cfg;
        u_int8_t tacls, twrph0, twrph1;
        struct s3c24x0_clock_power *clk_power = s3c24x0_get_base_clock_power();
-       struct s3c2410_nand *nand_reg = s3c2410_get_base_nand();
+       struct s3c24x0_nand *nand_reg = s3c24x0_get_base_nand();
 
-       debugX(1, "board_nand_init()\n");
+       debug("board_nand_init()\n");
 
        writel(readl(&clk_power->clkcon) | (1 << 4), &clk_power->clkcon);
 
        /* initialize hardware */
-       twrph0 = 3;
-       twrph1 = 0;
-       tacls = 0;
+#if defined(CONFIG_S3C24XX_CUSTOM_NAND_TIMING)
+       tacls  = CONFIG_S3C24XX_TACLS;
+       twrph0 = CONFIG_S3C24XX_TWRPH0;
+       twrph1 =  CONFIG_S3C24XX_TWRPH1;
+#else
+       tacls = 4;
+       twrph0 = 8;
+       twrph1 = 8;
+#endif
 
        cfg = S3C2410_NFCONF_EN;
        cfg |= S3C2410_NFCONF_TACLS(tacls - 1);
@@ -156,28 +149,27 @@ int board_nand_init(struct nand_chip *nand)
 #endif
 
        /* hwcontrol always must be implemented */
-       nand->cmd_ctrl = s3c2410_hwcontrol;
+       nand->cmd_ctrl = s3c24x0_hwcontrol;
 
-       nand->dev_ready = s3c2410_dev_ready;
+       nand->dev_ready = s3c24x0_dev_ready;
 
 #ifdef CONFIG_S3C2410_NAND_HWECC
-       nand->ecc.hwctl = s3c2410_nand_enable_hwecc;
-       nand->ecc.calculate = s3c2410_nand_calculate_ecc;
-       nand->ecc.correct = s3c2410_nand_correct_data;
+       nand->ecc.hwctl = s3c24x0_nand_enable_hwecc;
+       nand->ecc.calculate = s3c24x0_nand_calculate_ecc;
+       nand->ecc.correct = s3c24x0_nand_correct_data;
        nand->ecc.mode = NAND_ECC_HW;
        nand->ecc.size = CONFIG_SYS_NAND_ECCSIZE;
        nand->ecc.bytes = CONFIG_SYS_NAND_ECCBYTES;
+       nand->ecc.strength = 1;
 #else
        nand->ecc.mode = NAND_ECC_SOFT;
 #endif
 
 #ifdef CONFIG_S3C2410_NAND_BBT
-       nand->options = NAND_USE_FLASH_BBT;
-#else
-       nand->options = 0;
+       nand->bbt_options |= NAND_BBT_USE_FLASH;
 #endif
 
-       debugX(1, "end of nand_init\n");
+       debug("end of nand_init\n");
 
        return 0;
 }