aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2009-10-21 04:39:05 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2009-11-12 02:31:37 -0500
commit13e1add1073f55d5361e5357016b631efc03bff8 (patch)
tree33793e7ae2525701339ba846ab15284286f739c3 /drivers/mtd/nand
parent8c1fd89a85f898384df02217c09c98c2f39b4832 (diff)
mxc_nand: cleanup initialization
The oob layout was initialized several times. Instead, use a smallpage layout by default and switch to a largepage afterwards if necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/mxc_nand.c72
1 files changed, 22 insertions, 50 deletions
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 2aae5a7ddbd1..dafa1f0e04db 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -921,45 +921,42 @@ static int __init mxcnd_probe(struct platform_device *pdev)
921 if (err) 921 if (err)
922 goto eirq; 922 goto eirq;
923 923
924 /* Reset NAND */
925 this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
926
927 /* preset operation */
928 /* Unlock the internal RAM Buffer */
929 writew(0x2, host->regs + NFC_CONFIG);
930
931 /* Blocks to be unlocked */
932 writew(0x0, host->regs + NFC_UNLOCKSTART_BLKADDR);
933 writew(0x4000, host->regs + NFC_UNLOCKEND_BLKADDR);
934
935 /* Unlock Block Command for given address range */
936 writew(0x4, host->regs + NFC_WRPROT);
937
938 this->ecc.size = 512;
939 this->ecc.bytes = 3;
940 this->ecc.layout = &nand_hw_eccoob_smallpage;
941
924 if (pdata->hw_ecc) { 942 if (pdata->hw_ecc) {
925 this->ecc.calculate = mxc_nand_calculate_ecc; 943 this->ecc.calculate = mxc_nand_calculate_ecc;
926 this->ecc.hwctl = mxc_nand_enable_hwecc; 944 this->ecc.hwctl = mxc_nand_enable_hwecc;
927 this->ecc.correct = mxc_nand_correct_data; 945 this->ecc.correct = mxc_nand_correct_data;
928 this->ecc.mode = NAND_ECC_HW; 946 this->ecc.mode = NAND_ECC_HW;
929 this->ecc.size = 512;
930 this->ecc.bytes = 3;
931 tmp = readw(host->regs + NFC_CONFIG1); 947 tmp = readw(host->regs + NFC_CONFIG1);
932 tmp |= NFC_ECC_EN; 948 tmp |= NFC_ECC_EN;
933 writew(tmp, host->regs + NFC_CONFIG1); 949 writew(tmp, host->regs + NFC_CONFIG1);
934 } else { 950 } else {
935 this->ecc.size = 512;
936 this->ecc.bytes = 3;
937 this->ecc.layout = &nand_hw_eccoob_smallpage;
938 this->ecc.mode = NAND_ECC_SOFT; 951 this->ecc.mode = NAND_ECC_SOFT;
939 tmp = readw(host->regs + NFC_CONFIG1); 952 tmp = readw(host->regs + NFC_CONFIG1);
940 tmp &= ~NFC_ECC_EN; 953 tmp &= ~NFC_ECC_EN;
941 writew(tmp, host->regs + NFC_CONFIG1); 954 writew(tmp, host->regs + NFC_CONFIG1);
942 } 955 }
943 956
944 /* Reset NAND */
945 this->cmdfunc(mtd, NAND_CMD_RESET, -1, -1);
946
947 /* preset operation */
948 /* Unlock the internal RAM Buffer */
949 writew(0x2, host->regs + NFC_CONFIG);
950
951 /* Blocks to be unlocked */
952 writew(0x0, host->regs + NFC_UNLOCKSTART_BLKADDR);
953 writew(0x4000, host->regs + NFC_UNLOCKEND_BLKADDR);
954
955 /* Unlock Block Command for given address range */
956 writew(0x4, host->regs + NFC_WRPROT);
957
958 /* NAND bus width determines access funtions used by upper layer */ 957 /* NAND bus width determines access funtions used by upper layer */
959 if (pdata->width == 2) { 958 if (pdata->width == 2)
960 this->options |= NAND_BUSWIDTH_16; 959 this->options |= NAND_BUSWIDTH_16;
961 this->ecc.layout = &nand_hw_eccoob_smallpage;
962 }
963 960
964 /* first scan to find the device and get the page size */ 961 /* first scan to find the device and get the page size */
965 if (nand_scan_ident(mtd, 1)) { 962 if (nand_scan_ident(mtd, 1)) {
@@ -967,34 +964,9 @@ static int __init mxcnd_probe(struct platform_device *pdev)
967 goto escan; 964 goto escan;
968 } 965 }
969 966
970 host->pagesize_2k = (mtd->writesize == 2048) ? 1 : 0; 967 if (mtd->writesize == 2048) {
971 968 host->pagesize_2k = 1;
972 if (this->ecc.mode == NAND_ECC_HW) { 969 this->ecc.layout = &nand_hw_eccoob_largepage;
973 switch (mtd->oobsize) {
974 case 8:
975 this->ecc.layout = &nand_hw_eccoob_smallpage;
976 break;
977 case 16:
978 this->ecc.layout = &nand_hw_eccoob_smallpage;
979 break;
980 case 64:
981 this->ecc.layout = &nand_hw_eccoob_largepage;
982 break;
983 default:
984 /* page size not handled by HW ECC */
985 /* switching back to soft ECC */
986 this->ecc.size = 512;
987 this->ecc.bytes = 3;
988 this->ecc.layout = &nand_hw_eccoob_smallpage;
989 this->ecc.mode = NAND_ECC_SOFT;
990 this->ecc.calculate = NULL;
991 this->ecc.correct = NULL;
992 this->ecc.hwctl = NULL;
993 tmp = readw(host->regs + NFC_CONFIG1);
994 tmp &= ~NFC_ECC_EN;
995 writew(tmp, host->regs + NFC_CONFIG1);
996 break;
997 }
998 } 970 }
999 971
1000 /* second phase scan */ 972 /* second phase scan */