forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/mtd/nand/onenand/onenand_base.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright © 2005-2009 Samsung Electronics
34 * Copyright © 2007 Nokia Corporation
....@@ -12,10 +13,6 @@
1213 * Flex-OneNAND support
1314 * Amul Kumar Saha <amul.saha at samsung.com>
1415 * OTP support
15
- *
16
- * This program is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License version 2 as
18
- * published by the Free Software Foundation.
1916 */
2017
2118 #include <linux/kernel.h>
....@@ -1055,16 +1052,11 @@
10551052 int thislen)
10561053 {
10571054 struct onenand_chip *this = mtd->priv;
1058
- int ret;
10591055
10601056 this->read_bufferram(mtd, ONENAND_SPARERAM, this->oob_buf, 0,
10611057 mtd->oobsize);
1062
- ret = mtd_ooblayout_get_databytes(mtd, buf, this->oob_buf,
1063
- column, thislen);
1064
- if (ret)
1065
- return ret;
1066
-
1067
- return 0;
1058
+ return mtd_ooblayout_get_databytes(mtd, buf, this->oob_buf,
1059
+ column, thislen);
10681060 }
10691061
10701062 /**
....@@ -2458,7 +2450,7 @@
24582450 bbm->bbt[block >> 2] |= 0x01 << ((block & 0x03) << 1);
24592451
24602452 /* We write two bytes, so we don't have to mess with 16-bit access */
2461
- ofs += mtd->oobsize + (bbm->badblockpos & ~0x01);
2453
+ ofs += mtd->oobsize + (this->badblockpos & ~0x01);
24622454 /* FIXME : What to do when marking SLC block in partition
24632455 * with MLC erasesize? For now, it is not advisable to
24642456 * create partitions containing both SLC and MLC regions.
....@@ -2856,7 +2848,7 @@
28562848
28572849 /* Exit OTP access mode */
28582850 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2859
- this->wait(mtd, FL_RESETING);
2851
+ this->wait(mtd, FL_RESETTING);
28602852
28612853 status = this->read_word(this->base + ONENAND_REG_CTRL_STATUS);
28622854 status &= 0x60;
....@@ -2927,7 +2919,7 @@
29272919
29282920 /* Exit OTP access mode */
29292921 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2930
- this->wait(mtd, FL_RESETING);
2922
+ this->wait(mtd, FL_RESETTING);
29312923
29322924 return ret;
29332925 }
....@@ -2971,7 +2963,7 @@
29712963
29722964 /* Exit OTP access mode */
29732965 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
2974
- this->wait(mtd, FL_RESETING);
2966
+ this->wait(mtd, FL_RESETTING);
29752967
29762968 return ret;
29772969 }
....@@ -3011,7 +3003,7 @@
30113003
30123004 /* Exit OTP access mode */
30133005 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3014
- this->wait(mtd, FL_RESETING);
3006
+ this->wait(mtd, FL_RESETTING);
30153007 } else {
30163008 ops.mode = MTD_OPS_PLACE_OOB;
30173009 ops.ooblen = len;
....@@ -3260,6 +3252,9 @@
32603252
32613253 /* Lock scheme */
32623254 switch (density) {
3255
+ case ONENAND_DEVICE_DENSITY_8Gb:
3256
+ this->options |= ONENAND_HAS_NOP_1;
3257
+ fallthrough;
32633258 case ONENAND_DEVICE_DENSITY_4Gb:
32643259 if (ONENAND_IS_DDP(this))
32653260 this->options |= ONENAND_HAS_2PLANE;
....@@ -3280,12 +3275,15 @@
32803275 if ((this->version_id & 0xf) == 0xe)
32813276 this->options |= ONENAND_HAS_NOP_1;
32823277 }
3278
+ this->options |= ONENAND_HAS_UNLOCK_ALL;
3279
+ break;
32833280
32843281 case ONENAND_DEVICE_DENSITY_2Gb:
32853282 /* 2Gb DDP does not have 2 plane */
32863283 if (!ONENAND_IS_DDP(this))
32873284 this->options |= ONENAND_HAS_2PLANE;
32883285 this->options |= ONENAND_HAS_UNLOCK_ALL;
3286
+ break;
32893287
32903288 case ONENAND_DEVICE_DENSITY_1Gb:
32913289 /* A-Die has all block unlock */
....@@ -3410,7 +3408,7 @@
34103408 this->boundary[die] = bdry & FLEXONENAND_PI_MASK;
34113409
34123410 this->command(mtd, ONENAND_CMD_RESET, 0, 0);
3413
- this->wait(mtd, FL_RESETING);
3411
+ this->wait(mtd, FL_RESETTING);
34143412
34153413 printk(KERN_INFO "Die %d boundary: %d%s\n", die,
34163414 this->boundary[die], locked ? "(Locked)" : "(Unlocked)");
....@@ -3632,7 +3630,7 @@
36323630 ret = this->wait(mtd, FL_WRITING);
36333631 out:
36343632 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_REG_COMMAND);
3635
- this->wait(mtd, FL_RESETING);
3633
+ this->wait(mtd, FL_RESETTING);
36363634 if (!ret)
36373635 /* Recalculate device size on boundary change*/
36383636 flexonenand_get_size(mtd);
....@@ -3668,7 +3666,7 @@
36683666 /* Reset OneNAND to read default register values */
36693667 this->write_word(ONENAND_CMD_RESET, this->base + ONENAND_BOOTRAM);
36703668 /* Wait reset */
3671
- this->wait(mtd, FL_RESETING);
3669
+ this->wait(mtd, FL_RESETTING);
36723670
36733671 /* Restore system configuration 1 */
36743672 this->write_word(syscfg, this->base + ONENAND_REG_SYS_CFG1);
....@@ -3877,6 +3875,9 @@
38773875 if (!this->oob_buf) {
38783876 if (this->options & ONENAND_PAGEBUF_ALLOC) {
38793877 this->options &= ~ONENAND_PAGEBUF_ALLOC;
3878
+#ifdef CONFIG_MTD_ONENAND_VERIFY_WRITE
3879
+ kfree(this->verify_buf);
3880
+#endif
38803881 kfree(this->page_buf);
38813882 }
38823883 return -ENOMEM;
....@@ -3967,6 +3968,9 @@
39673968 if (!(this->options & ONENAND_SKIP_INITIAL_UNLOCKING))
39683969 this->unlock_all(mtd);
39693970
3971
+ /* Set the bad block marker position */
3972
+ this->badblockpos = ONENAND_BADBLOCK_POS;
3973
+
39703974 ret = this->scan_bbt(mtd);
39713975 if ((!FLEXONENAND(this)) || ret)
39723976 return ret;