• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision1ca6f9483e9ab56fa66b2e922b2df2c9ad609fbb (tree)
Time2022-07-22 15:30:16
AuthorMichael Trimarchi <michael@amar...>
CommiterMichael Trimarchi

Log Message

mtd: nand: Get rid of busw parameter

Upstream linux commit 29a198a1592d83.

Auto-detection functions are passed a busw parameter to retrieve the actual
NAND bus width and eventually set the correct value in chip->options.
Rework the nand_get_flash_type() function to get rid of this extra
parameter and let detection code directly set the NAND_BUSWIDTH_16 flag in
chip->options if needed.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>

Change Summary

Incremental Difference

--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -3898,8 +3898,7 @@ static void nand_onfi_detect_micron(struct nand_chip *chip,
38983898 /*
38993899 * Check if the NAND chip is ONFI compliant, returns 1 if it is, 0 otherwise.
39003900 */
3901-static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
3902- int *busw)
3901+static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip)
39033902 {
39043903 struct nand_onfi_params *p = &chip->onfi_params;
39053904 char id[4];
@@ -3971,9 +3970,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
39713970 chip->bits_per_cell = p->bits_per_cell;
39723971
39733972 if (onfi_feature(chip) & ONFI_FEATURE_16_BIT_BUS)
3974- *busw = NAND_BUSWIDTH_16;
3975- else
3976- *busw = 0;
3973+ chip->options |= NAND_BUSWIDTH_16;
39773974
39783975 if (p->ecc_bits != 0xff) {
39793976 chip->ecc_strength_ds = p->ecc_bits;
@@ -4003,8 +4000,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
40034000 return 1;
40044001 }
40054002 #else
4006-static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
4007- int *busw)
4003+static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip)
40084004 {
40094005 return 0;
40104006 }
@@ -4013,8 +4009,7 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
40134009 /*
40144010 * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise.
40154011 */
4016-static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip,
4017- int *busw)
4012+static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip)
40184013 {
40194014 struct nand_jedec_params *p = &chip->jedec_params;
40204015 struct jedec_ecc_info *ecc;
@@ -4076,9 +4071,7 @@ static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip,
40764071 chip->bits_per_cell = p->bits_per_cell;
40774072
40784073 if (jedec_feature(chip) & JEDEC_FEATURE_16_BIT_BUS)
4079- *busw = NAND_BUSWIDTH_16;
4080- else
4081- *busw = 0;
4074+ chip->options |= NAND_BUSWIDTH_16;
40824075
40834076 /* ECC info */
40844077 ecc = &p->ecc_info[0];
@@ -4168,7 +4161,7 @@ static int nand_get_bits_per_cell(u8 cellinfo)
41684161 * manufacturer-specific "extended ID" decoding patterns.
41694162 */
41704163 static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
4171- u8 id_data[8], int *busw)
4164+ u8 id_data[8])
41724165 {
41734166 int extid, id_len;
41744167 /* The 3rd id byte holds MLC / multichip data */
@@ -4221,7 +4214,6 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
42214214 /* Calc blocksize */
42224215 mtd->erasesize = (128 * 1024) <<
42234216 (((extid >> 1) & 0x04) | (extid & 0x03));
4224- *busw = 0;
42254217 } else if (id_len == 6 && id_data[0] == NAND_MFR_HYNIX &&
42264218 !nand_is_slc(chip)) {
42274219 unsigned int tmp;
@@ -4262,7 +4254,6 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
42624254 mtd->erasesize = 768 * 1024;
42634255 else
42644256 mtd->erasesize = (64 * 1024) << tmp;
4265- *busw = 0;
42664257 } else {
42674258 /* Calc pagesize */
42684259 mtd->writesize = 1024 << (extid & 0x03);
@@ -4275,7 +4266,9 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
42754266 mtd->erasesize = (64 * 1024) << (extid & 0x03);
42764267 extid >>= 2;
42774268 /* Get buswidth information */
4278- *busw = (extid & 0x01) ? NAND_BUSWIDTH_16 : 0;
4269+ /* Get buswidth information */
4270+ if (extid & 0x1)
4271+ chip->options |= NAND_BUSWIDTH_16;
42794272
42804273 /*
42814274 * Toshiba 24nm raw SLC (i.e., not BENAND) have 32B OOB per
@@ -4301,15 +4294,13 @@ static void nand_decode_ext_id(struct mtd_info *mtd, struct nand_chip *chip,
43014294 * the chip.
43024295 */
43034296 static void nand_decode_id(struct mtd_info *mtd, struct nand_chip *chip,
4304- struct nand_flash_dev *type, u8 id_data[8],
4305- int *busw)
4297+ struct nand_flash_dev *type, u8 id_data[8])
43064298 {
43074299 int maf_id = id_data[0];
43084300
43094301 mtd->erasesize = type->erasesize;
43104302 mtd->writesize = type->pagesize;
43114303 mtd->oobsize = mtd->writesize / 32;
4312- *busw = type->options & NAND_BUSWIDTH_16;
43134304
43144305 /* All legacy ID NAND are small-page, SLC */
43154306 chip->bits_per_cell = 1;
@@ -4371,7 +4362,7 @@ static inline bool is_full_id_nand(struct nand_flash_dev *type)
43714362 }
43724363
43734364 static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
4374- struct nand_flash_dev *type, u8 *id_data, int *busw)
4365+ struct nand_flash_dev *type, u8 *id_data)
43754366 {
43764367 if (!strncmp((char *)type->id, (char *)id_data, type->id_len)) {
43774368 mtd->writesize = type->pagesize;
@@ -4386,8 +4377,6 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
43864377 chip->onfi_timing_mode_default =
43874378 type->onfi_timing_mode_default;
43884379
4389- *busw = type->options & NAND_BUSWIDTH_16;
4390-
43914380 if (!mtd->name)
43924381 mtd->name = type->name;
43934382
@@ -4449,9 +4438,24 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
44494438 if (!type)
44504439 type = nand_flash_ids;
44514440
4441+ /*
4442+ * Save the NAND_BUSWIDTH_16 flag before letting auto-detection logic
4443+ * override it.
4444+ * This is required to make sure initial NAND bus width set by the
4445+ * NAND controller driver is coherent with the real NAND bus width
4446+ * (extracted by auto-detection code).
4447+ */
4448+ busw = chip->options & NAND_BUSWIDTH_16;
4449+
4450+ /*
4451+ * The flag is only set (never cleared), reset it to its default value
4452+ * before starting auto-detection.
4453+ */
4454+ chip->options &= ~NAND_BUSWIDTH_16;
4455+
44524456 for (; type->name != NULL; type++) {
44534457 if (is_full_id_nand(type)) {
4454- if (find_full_id_nand(mtd, chip, type, id_data, &busw))
4458+ if (find_full_id_nand(mtd, chip, type, id_data))
44554459 goto ident_done;
44564460 } else if (*dev_id == type->dev_id) {
44574461 break;
@@ -4461,11 +4465,11 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
44614465 chip->onfi_version = 0;
44624466 if (!type->name || !type->pagesize) {
44634467 /* Check if the chip is ONFI compliant */
4464- if (nand_flash_detect_onfi(mtd, chip, &busw))
4468+ if (nand_flash_detect_onfi(mtd, chip))
44654469 goto ident_done;
44664470
44674471 /* Check if the chip is JEDEC compliant */
4468- if (nand_flash_detect_jedec(mtd, chip, &busw))
4472+ if (nand_flash_detect_jedec(mtd, chip))
44694473 goto ident_done;
44704474 }
44714475
@@ -4479,10 +4483,11 @@ struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
44794483
44804484 if (!type->pagesize) {
44814485 /* Decode parameters from extended ID */
4482- nand_decode_ext_id(mtd, chip, id_data, &busw);
4486+ nand_decode_ext_id(mtd, chip, id_data);
44834487 } else {
4484- nand_decode_id(mtd, chip, type, id_data, &busw);
4488+ nand_decode_id(mtd, chip, type, id_data);
44854489 }
4490+
44864491 /* Get chip options */
44874492 chip->options |= type->options;
44884493