Skip to contentSkip to conversation

Meson: R/W support for pages used by boot ROM

PATCH RESEND Superseded Arseniy Krasnov 2 participants 10 messages Aug 26, 2024

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Meson: R/W support for pages used by boot ROM

Patchset is based on patchset for Linux (today merged to nand-next):
https://lore.kernel.org/linux-mtd/[email protected]/

Here is description from it:

Quoted 10 lines

Amlogic's boot ROM code needs that some pages on NAND must be written in special "short" ECC mode with scrambling enabled. Such pages:
1) Contain some metadata about hardware.
2) Located with some interval starting from 0 offset, until some specified offset. Interval and second offset are set in the device tree.

This patchset adds R/W support for such pages. To enable it we can setup it in dts:

Quoted 8 lines
     nand-is-boot-medium;
     amlogic,boot-pages = <1024>;
     amlogic,boot-page-step = <128>;

It means that each 128th page in range 0 to 1024 pages will be accessed in special mode ("short" ECC + scrambling). In practice this feature is needed when we want to update first block of NAND - driver will enable required mode by itself using value from device tree.

The only difference is that patchset for Linux updates DT bindings, while this adds NAND_IS_BOOT_MEDIUM flag support.

Changelog:
v1 -> v2:
* Pls see per-patch changelog.

Arseniy Krasnov (3):
mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag
mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()'
mtd: rawnand: meson: read/write access for boot ROM pages

 drivers/mtd/nand/raw/meson_nand.c | 84 +++++++++++++++++++++----------
 drivers/mtd/nand/raw/nand_base.c  |  3 ++
 include/linux/mtd/rawnand.h       |  5 ++
 3 files changed, 65 insertions(+), 27 deletions(-)
Signature · 1 line
2.30.1
#1 lore raw

PATCH v2 1/3 mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag

Based on Linux kernel:
commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")

Allow to define a NAND chip as a boot device. This can be helpful for the selection of the ECC algorithm and strength in case the boot ROM supports only a subset of controller provided options.

---
Changelog:
v1 -> v2:
* Place 'NAND_IS_BOOT_MEDIUM' according its numerical value.

 drivers/mtd/nand/raw/nand_base.c | 3 +++
 include/linux/mtd/rawnand.h      | 5 +++++
 2 files changed, 8 insertions(+)
drivers/mtd/nand/raw/nand_base.c +3 -0
index c40a0f23d7..ed605b4af5 100644
@@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
 	if (ret == 16)
 		chip->options |= NAND_BUSWIDTH_16;
 
+	if (ofnode_read_bool(node, "nand-is-boot-medium"))
+		chip->options |= NAND_IS_BOOT_MEDIUM;
+
 	if (ofnode_read_bool(node, "nand-on-flash-bbt"))
 		chip->bbt_options |= NAND_BBT_USE_FLASH;
 
include/linux/mtd/rawnand.h +5 -0
index fb002ae641..61690e816f 100644
@@ -248,6 +248,11 @@ enum nand_ecc_algo {
  * kmap'ed, vmalloc'ed highmem buffers being passed from upper layers
  */
 #define NAND_USE_BOUNCE_BUFFER	0x00100000
+/*
+ * Whether the NAND chip is a boot medium. Drivers might use this information
+ * to select ECC algorithms supported by the boot ROM or similar restrictions.
+ */
+#define NAND_IS_BOOT_MEDIUM	0x00400000
 
 /* Options set by nand scan */
 /* bbt has already been read */
Signature · 1 line
2.30.1
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] mtd: rawnand: nand_base: support for 'NAND_IS_BOOT_MEDIUM' flag

Hi

Quoted 39 lines · Arseniy Krasnov

Based on Linux kernel:
commit f922bd798bb9 ("mtd: rawnand: add an option to specify NAND chip as a boot device")

Allow to define a NAND chip as a boot device. This can be helpful for the selection of the ECC algorithm and strength in case the boot ROM supports only a subset of controller provided options.

---
Changelog:
v1 -> v2:
* Place 'NAND_IS_BOOT_MEDIUM' according its numerical value.

 drivers/mtd/nand/raw/nand_base.c | 3 +++
 include/linux/mtd/rawnand.h      | 5 +++++
 2 files changed, 8 insertions(+)
drivers/mtd/nand/raw/nand_base.c +3 -0
index c40a0f23d7..ed605b4af5 100644
@@ -4458,6 +4458,9 @@ static int nand_dt_init(struct mtd_info *mtd, struct nand_chip *chip, ofnode nod
        if (ret == 16)
                chip->options |= NAND_BUSWIDTH_16;
 
+       if (ofnode_read_bool(node, "nand-is-boot-medium"))
+               chip->options |= NAND_IS_BOOT_MEDIUM;
+
        if (ofnode_read_bool(node, "nand-on-flash-bbt"))
                chip->bbt_options |= NAND_BBT_USE_FLASH;
 
include/linux/mtd/rawnand.h +0 -0
index fb002ae641..61690e816f 100644
@@ -248,6 +248,11 @@ enum nand_ecc_algo {
  * kmap'ed, vmalloc'ed highmem buffers being passed from upper layers
  */

include/linux/mtd/rawnand.h enum nand_ecc_algo {

Quoted 10 lines
include/linux/mtd/rawnand.h +5 -1
 #define NAND_USE_BOUNCE_BUFFER 0x00100000
+/*
+ * Whether the NAND chip is a boot medium. Drivers might use this information
+ * to select ECC algorithms supported by the boot ROM or similar restrictions.
+ */
+#define NAND_IS_BOOT_MEDIUM    0x00400000
 
 /* Options set by nand scan */
 /* bbt has already been read */
--

I will then backport this from linux kernel
dd6ed5c9890b759ba1b56697b9f3f50e71909e43

Quoted 2 lines

2.30.1

--
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com

#3 lore raw

PATCH v2 2/3 mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()'

In reply to Arseniy Krasnov

Move call 'meson_nfc_cmd_seed()' and check for 'NAND_NEED_SCRAMBLING' to 'meson_nfc_cmd_access()', thus removing code duplication.

---
 drivers/mtd/nand/raw/meson_nand.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +12 -18
index 5d411c4594..19f005202b 100644
@@ -229,14 +229,19 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
 	       nfc->reg_base + NFC_REG_CMD);
 }
 
-static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir,
-				 int scrambler)
+static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
 	struct mtd_info *mtd = nand_to_mtd(nand);
 	const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
 	const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
 	u32 bch = meson_chip->bch_mode, cmd;
 	int len = mtd->writesize, pagesize, pages;
+	int scrambler;
+
+	if (nand->options & NAND_NEED_SCRAMBLING)
+		scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+	else
+		scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 
 	pagesize = nand->ecc.size;
 
@@ -252,6 +257,9 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir,
 	cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
 		       NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
 
+	if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
+		meson_nfc_cmd_seed(nfc, page);
+
 	writel(cmd, nfc->reg_base + NFC_REG_CMD);
 }
 
@@ -566,14 +574,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand,
 		return ret;
 	}
 
-	if (nand->options & NAND_NEED_SCRAMBLING) {
-		meson_nfc_cmd_seed(nfc, page);
-		meson_nfc_cmd_access(nand, raw, DIRWRITE,
-				     NFC_CMD_SCRAMBLER_ENABLE);
-	} else {
-		meson_nfc_cmd_access(nand, raw, DIRWRITE,
-				     NFC_CMD_SCRAMBLER_DISABLE);
-	}
+	meson_nfc_cmd_access(nand, raw, DIRWRITE, page);
 
 	cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG;
 	writel(cmd, nfc->reg_base + NFC_REG_CMD);
@@ -644,14 +645,7 @@ static int meson_nfc_read_page_sub(struct nand_chip *nand,
 	if (ret)
 		return ret;
 
-	if (nand->options & NAND_NEED_SCRAMBLING) {
-		meson_nfc_cmd_seed(nfc, page);
-		meson_nfc_cmd_access(nand, raw, DIRREAD,
-				     NFC_CMD_SCRAMBLER_ENABLE);
-	} else {
-		meson_nfc_cmd_access(nand, raw, DIRREAD,
-				     NFC_CMD_SCRAMBLER_DISABLE);
-	}
+	meson_nfc_cmd_access(nand, raw, DIRREAD, page);
 
 	meson_nfc_wait_dma_finish(nfc);
 	meson_nfc_check_ecc_pages_valid(nfc, nand, raw);
Signature · 1 line
2.30.1
Reviewed-by on v2 2/3
#4 lore raw

Re: [PATCH v2 2/3] mtd: rawnand: meson: refactor use of 'meson_nfc_cmd_access()'

Hi

Quoted 18 lines · Arseniy Krasnov

Move call 'meson_nfc_cmd_seed()' and check for 'NAND_NEED_SCRAMBLING' to 'meson_nfc_cmd_access()', thus removing code duplication.

---
 drivers/mtd/nand/raw/meson_nand.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +0 -1
index 5d411c4594..19f005202b 100644
@@ -229,14 +229,19 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
               nfc->reg_base + NFC_REG_CMD);
 }
 
-static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir,

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 240

Quoted 10 lines
drivers/mtd/nand/raw/meson_nand.c +3 -1
-                                int scrambler)
+static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
        struct mtd_info *mtd = nand_to_mtd(nand);
        const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
        const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
        u32 bch = meson_chip->bch_mode, cmd;
        int len = mtd->writesize, pagesize, pages;
+       int scrambler;
+

unsigned int

Quoted 50 lines
drivers/mtd/nand/raw/meson_nand.c +9 -17
+       if (nand->options & NAND_NEED_SCRAMBLING)
+               scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+       else
+               scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 
        pagesize = nand->ecc.size;
 
@@ -252,6 +257,9 @@ static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir,
        cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
                       NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
 
+       if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
+               meson_nfc_cmd_seed(nfc, page);
+
        writel(cmd, nfc->reg_base + NFC_REG_CMD);
 }
 
@@ -566,14 +574,7 @@ static int meson_nfc_write_page_sub(struct nand_chip *nand,
                return ret;
        }
 
-       if (nand->options & NAND_NEED_SCRAMBLING) {
-               meson_nfc_cmd_seed(nfc, page);
-               meson_nfc_cmd_access(nand, raw, DIRWRITE,
-                                    NFC_CMD_SCRAMBLER_ENABLE);
-       } else {
-               meson_nfc_cmd_access(nand, raw, DIRWRITE,
-                                    NFC_CMD_SCRAMBLER_DISABLE);
-       }
+       meson_nfc_cmd_access(nand, raw, DIRWRITE, page);
 
        cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_PAGEPROG;
        writel(cmd, nfc->reg_base + NFC_REG_CMD);
@@ -644,14 +645,7 @@ static int meson_nfc_read_page_sub(struct nand_chip *nand,
        if (ret)
                return ret;
 
-       if (nand->options & NAND_NEED_SCRAMBLING) {
-               meson_nfc_cmd_seed(nfc, page);
-               meson_nfc_cmd_access(nand, raw, DIRREAD,
-                                    NFC_CMD_SCRAMBLER_ENABLE);
-       } else {
-               meson_nfc_cmd_access(nand, raw, DIRREAD,
-                                    NFC_CMD_SCRAMBLER_DISABLE);
-       }
+       meson_nfc_cmd_access(nand, raw, DIRREAD, page);
 
        meson_nfc_wait_dma_finish(nfc);
        meson_nfc_check_ecc_pages_valid(nfc, nand, raw);
--
Quoted 2 lines

2.30.1

Please change to unsigned int because I think match options type

With this

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#5 lore raw

PATCH v2 3/3 mtd: rawnand: meson: read/write access for boot ROM pages

In reply to Arseniy Krasnov

Boot ROM on Meson needs some pages to be read/written in a special mode:
384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example):

[ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ]
^ ^ ^ ^

pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree.

---
 drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 10 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +46 -10
index 19f005202b..54ea035d8d 100644
@@ -40,6 +40,7 @@
 #define NFC_CMD_RB			BIT(20)
 #define NFC_CMD_SCRAMBLER_ENABLE	BIT(19)
 #define NFC_CMD_SCRAMBLER_DISABLE	0
+#define NFC_CMD_SHORTMODE_ENABLE	1
 #define NFC_CMD_SHORTMODE_DISABLE	0
 #define NFC_CMD_RB_INT			BIT(14)
 #define NFC_CMD_RB_INT_NO_PIN		((0xb << 10) | BIT(18) | BIT(16))
@@ -78,6 +79,8 @@
 
 #define DMA_DIR(dir)		((dir) ? NFC_CMD_N2M : NFC_CMD_M2N)
 
+#define NFC_SHORT_MODE_ECC_SZ	384
+
 #define ECC_CHECK_RETURN_FF	-1
 
 #define NAND_CE0		(0xe << 10)
@@ -141,6 +144,8 @@
 struct meson_nfc_nand_chip {
 	struct list_head node;
 	struct nand_chip nand;
+	u32 boot_pages;
+	u32 boot_page_step;
 
 	u32 bch_mode;
 	u8 *data_buf;
@@ -229,33 +234,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
 	       nfc->reg_base + NFC_REG_CMD);
 }
 
+static int meson_nfc_is_boot_page(struct nand_chip *nand, int page)
+{
+	const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
+
+	return (nand->options & NAND_IS_BOOT_MEDIUM) &&
+	       !(page % meson_chip->boot_page_step) &&
+	       (page < meson_chip->boot_pages);
+}
+
 static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
+	const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
 	struct mtd_info *mtd = nand_to_mtd(nand);
 	const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
-	const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
-	u32 bch = meson_chip->bch_mode, cmd;
 	int len = mtd->writesize, pagesize, pages;
 	int scrambler;
+	u32 cmd;
 
 	if (nand->options & NAND_NEED_SCRAMBLING)
 		scrambler = NFC_CMD_SCRAMBLER_ENABLE;
 	else
 		scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 
-	pagesize = nand->ecc.size;
-
 	if (raw) {
 		len = mtd->writesize + mtd->oobsize;
 		cmd = len | scrambler | DMA_DIR(dir);
-		writel(cmd, nfc->reg_base + NFC_REG_CMD);
-		return;
-	}
+	} else if (meson_nfc_is_boot_page(nand, page)) {
+		pagesize = NFC_SHORT_MODE_ECC_SZ >> 3;
+		pages = mtd->writesize / 512;
 
-	pages = len / nand->ecc.size;
+		scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+		cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K,
+			       NFC_CMD_SHORTMODE_ENABLE, pagesize, pages);
+	} else {
+		pagesize = nand->ecc.size >> 3;
+		pages = len / nand->ecc.size;
 
-	cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
-		       NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+		cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode,
+			       NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+	}
 
 	if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
 		meson_nfc_cmd_seed(nfc, page);
@@ -1132,6 +1150,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc,
 		goto err_chip_buf_free;
 	}
 
+	if (nand->options & NAND_IS_BOOT_MEDIUM) {
+		ret = ofnode_read_u32(node, "amlogic,boot-pages",
+				      &meson_chip->boot_pages);
+		if (ret) {
+			dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d",
+				ret);
+			goto err_chip_buf_free;
+		}
+
+		ret = ofnode_read_u32(node, "amlogic,boot-page-step",
+				      &meson_chip->boot_page_step);
+		if (ret) {
+			dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d",
+				ret);
+			goto err_chip_buf_free;
+		}
+	}
+
 	ret = nand_register(0, mtd);
 	if (ret) {
 		dev_err(dev, "'nand_register()' failed: %d\n", ret);
Signature · 1 line
2.30.1
#6 lore raw

Re: [PATCH v2 3/3] mtd: rawnand: meson: read/write access for boot ROM pages

Hi

Quoted 67 lines · Arseniy Krasnov

Boot ROM on Meson needs some pages to be read/written in a special mode:
384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example):

[ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ]
^ ^ ^ ^

pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree.

---
 drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 10 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +15 -1
index 19f005202b..54ea035d8d 100644
@@ -40,6 +40,7 @@
 #define NFC_CMD_RB                     BIT(20)
 #define NFC_CMD_SCRAMBLER_ENABLE       BIT(19)
 #define NFC_CMD_SCRAMBLER_DISABLE      0
+#define NFC_CMD_SHORTMODE_ENABLE       1
 #define NFC_CMD_SHORTMODE_DISABLE      0
 #define NFC_CMD_RB_INT                 BIT(14)
 #define NFC_CMD_RB_INT_NO_PIN          ((0xb << 10) | BIT(18) | BIT(16))
@@ -78,6 +79,8 @@
 
 #define DMA_DIR(dir)           ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N)
 
+#define NFC_SHORT_MODE_ECC_SZ  384
+
 #define ECC_CHECK_RETURN_FF    -1
 
 #define NAND_CE0               (0xe << 10)
@@ -141,6 +144,8 @@
 struct meson_nfc_nand_chip {
        struct list_head node;
        struct nand_chip nand;
+       u32 boot_pages;
+       u32 boot_page_step;
 
        u32 bch_mode;
        u8 *data_buf;
@@ -229,33 +234,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
               nfc->reg_base + NFC_REG_CMD);
 }
 
+static int meson_nfc_is_boot_page(struct nand_chip *nand, int page)
+{
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
+
+       return (nand->options & NAND_IS_BOOT_MEDIUM) &&
+              !(page % meson_chip->boot_page_step) &&
+              (page < meson_chip->boot_pages);
+}
+
 static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
        struct mtd_info *mtd = nand_to_mtd(nand);
        const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
-       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 259

Quoted 10 lines
drivers/mtd/nand/raw/meson_nand.c +1 -1
-       u32 bch = meson_chip->bch_mode, cmd;
        int len = mtd->writesize, pagesize, pages;
        int scrambler;
+       u32 cmd;
 
        if (nand->options & NAND_NEED_SCRAMBLING)
                scrambler = NFC_CMD_SCRAMBLER_ENABLE;
        else
                scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 

scrambler depends on NAND_NEED_SCRAMBLING so suppose that is not set

scrambler = NAND_NEED_SCRAMBLING;

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 263

Quoted 9 lines
drivers/mtd/nand/raw/meson_nand.c +1 -5
-       pagesize = nand->ecc.size;
-
        if (raw) {
                len = mtd->writesize + mtd->oobsize;
                cmd = len | scrambler | DMA_DIR(dir);
-               writel(cmd, nfc->reg_base + NFC_REG_CMD);
-               return;
-       }
+       } else if (meson_nfc_is_boot_page(nand, page)) {

Now here you seems that you don't care anymore about this option and check only meson_nfc_is_boot_page

Is something am I missing?

Michael

Quoted 47 lines
drivers/mtd/nand/raw/meson_nand.c +29 -4
+               pagesize = NFC_SHORT_MODE_ECC_SZ >> 3;
+               pages = mtd->writesize / 512;
 
-       pages = len / nand->ecc.size;
+               scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K,
+                              NFC_CMD_SHORTMODE_ENABLE, pagesize, pages);
+       } else {
+               pagesize = nand->ecc.size >> 3;
+               pages = len / nand->ecc.size;
 
-       cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
-                      NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode,
+                              NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+       }
 
        if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
                meson_nfc_cmd_seed(nfc, page);
@@ -1132,6 +1150,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc,
                goto err_chip_buf_free;
        }
 
+       if (nand->options & NAND_IS_BOOT_MEDIUM) {
+               ret = ofnode_read_u32(node, "amlogic,boot-pages",
+                                     &meson_chip->boot_pages);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+
+               ret = ofnode_read_u32(node, "amlogic,boot-page-step",
+                                     &meson_chip->boot_page_step);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+       }
+
        ret = nand_register(0, mtd);
        if (ret) {
                dev_err(dev, "'nand_register()' failed: %d\n", ret);
--

2.30.1

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#7 lore raw

Re: [PATCH v2 3/3] mtd: rawnand: meson: read/write access for boot ROM pages

Quoted 97 lines · Michael Nazzareno Trimarchi

Hi

Quoted 67 lines · Arseniy Krasnov

Boot ROM on Meson needs some pages to be read/written in a special mode:
384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example):

[ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ]
^ ^ ^ ^

pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree.

---
 drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 10 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +15 -1
index 19f005202b..54ea035d8d 100644
@@ -40,6 +40,7 @@
 #define NFC_CMD_RB                     BIT(20)
 #define NFC_CMD_SCRAMBLER_ENABLE       BIT(19)
 #define NFC_CMD_SCRAMBLER_DISABLE      0
+#define NFC_CMD_SHORTMODE_ENABLE       1
 #define NFC_CMD_SHORTMODE_DISABLE      0
 #define NFC_CMD_RB_INT                 BIT(14)
 #define NFC_CMD_RB_INT_NO_PIN          ((0xb << 10) | BIT(18) | BIT(16))
@@ -78,6 +79,8 @@
 
 #define DMA_DIR(dir)           ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N)
 
+#define NFC_SHORT_MODE_ECC_SZ  384
+
 #define ECC_CHECK_RETURN_FF    -1
 
 #define NAND_CE0               (0xe << 10)
@@ -141,6 +144,8 @@
 struct meson_nfc_nand_chip {
        struct list_head node;
        struct nand_chip nand;
+       u32 boot_pages;
+       u32 boot_page_step;
 
        u32 bch_mode;
        u8 *data_buf;
@@ -229,33 +234,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
               nfc->reg_base + NFC_REG_CMD);
 }
 
+static int meson_nfc_is_boot_page(struct nand_chip *nand, int page)
+{
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
+
+       return (nand->options & NAND_IS_BOOT_MEDIUM) &&
+              !(page % meson_chip->boot_page_step) &&
+              (page < meson_chip->boot_pages);
+}
+
 static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
        struct mtd_info *mtd = nand_to_mtd(nand);
        const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
-       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 259

Quoted 10 lines
drivers/mtd/nand/raw/meson_nand.c +1 -1
-       u32 bch = meson_chip->bch_mode, cmd;
        int len = mtd->writesize, pagesize, pages;
        int scrambler;
+       u32 cmd;
 
        if (nand->options & NAND_NEED_SCRAMBLING)
                scrambler = NFC_CMD_SCRAMBLER_ENABLE;
        else
                scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 

scrambler depends on NAND_NEED_SCRAMBLING so suppose that is not set

scrambler = NAND_NEED_SCRAMBLING;

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 263

Quoted 9 lines
drivers/mtd/nand/raw/meson_nand.c +1 -5
-       pagesize = nand->ecc.size;
-
        if (raw) {
                len = mtd->writesize + mtd->oobsize;
                cmd = len | scrambler | DMA_DIR(dir);
-               writel(cmd, nfc->reg_base + NFC_REG_CMD);
-               return;
-       }
+       } else if (meson_nfc_is_boot_page(nand, page)) {
Quoted 4 lines

Now here you seems that you don't care anymore about this option and check only meson_nfc_is_boot_page

Is something am I missing?

Idea is the following IIUC: such boot pages could be read in ECC mode only with enabled scrambling - otherwise we get ECC error. Or we need to read it in raw mode. So:

if (read page in raw mode) {
use scrambler as provided
} else if (read boot page in ECC mode) {
force scrambling mode + NFC_ECC_BCH8_1K + NFC_CMD_SHORTMODE_ENABLE

} else {
    //we read non-boot page in ECC mode

use scrambler as provided
}

Thanks

Quoted 52 lines

Michael

Quoted 47 lines
drivers/mtd/nand/raw/meson_nand.c +29 -4
+               pagesize = NFC_SHORT_MODE_ECC_SZ >> 3;
+               pages = mtd->writesize / 512;
 
-       pages = len / nand->ecc.size;
+               scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K,
+                              NFC_CMD_SHORTMODE_ENABLE, pagesize, pages);
+       } else {
+               pagesize = nand->ecc.size >> 3;
+               pages = len / nand->ecc.size;
 
-       cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
-                      NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode,
+                              NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+       }
 
        if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
                meson_nfc_cmd_seed(nfc, page);
@@ -1132,6 +1150,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc,
                goto err_chip_buf_free;
        }
 
+       if (nand->options & NAND_IS_BOOT_MEDIUM) {
+               ret = ofnode_read_u32(node, "amlogic,boot-pages",
+                                     &meson_chip->boot_pages);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+
+               ret = ofnode_read_u32(node, "amlogic,boot-page-step",
+                                     &meson_chip->boot_page_step);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+       }
+
        ret = nand_register(0, mtd);
        if (ret) {
                dev_err(dev, "'nand_register()' failed: %d\n", ret);
--

2.30.1

#8 lore raw

Re: [PATCH v2 3/3] mtd: rawnand: meson: read/write access for boot ROM pages

Hi

Quoted 113 lines · Arseniy Krasnov
Quoted 97 lines · Michael Nazzareno Trimarchi

Hi

Quoted 67 lines · Arseniy Krasnov

Boot ROM on Meson needs some pages to be read/written in a special mode:
384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example):

[ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ]
^ ^ ^ ^

pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree.

---
 drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 10 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +15 -1
index 19f005202b..54ea035d8d 100644
@@ -40,6 +40,7 @@
 #define NFC_CMD_RB                     BIT(20)
 #define NFC_CMD_SCRAMBLER_ENABLE       BIT(19)
 #define NFC_CMD_SCRAMBLER_DISABLE      0
+#define NFC_CMD_SHORTMODE_ENABLE       1
 #define NFC_CMD_SHORTMODE_DISABLE      0
 #define NFC_CMD_RB_INT                 BIT(14)
 #define NFC_CMD_RB_INT_NO_PIN          ((0xb << 10) | BIT(18) | BIT(16))
@@ -78,6 +79,8 @@
 
 #define DMA_DIR(dir)           ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N)
 
+#define NFC_SHORT_MODE_ECC_SZ  384
+
 #define ECC_CHECK_RETURN_FF    -1
 
 #define NAND_CE0               (0xe << 10)
@@ -141,6 +144,8 @@
 struct meson_nfc_nand_chip {
        struct list_head node;
        struct nand_chip nand;
+       u32 boot_pages;
+       u32 boot_page_step;
 
        u32 bch_mode;
        u8 *data_buf;
@@ -229,33 +234,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
               nfc->reg_base + NFC_REG_CMD);
 }
 
+static int meson_nfc_is_boot_page(struct nand_chip *nand, int page)
+{
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
+
+       return (nand->options & NAND_IS_BOOT_MEDIUM) &&
+              !(page % meson_chip->boot_page_step) &&
+              (page < meson_chip->boot_pages);
+}
+
 static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
        struct mtd_info *mtd = nand_to_mtd(nand);
        const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
-       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 259

Quoted 10 lines
drivers/mtd/nand/raw/meson_nand.c +1 -1
-       u32 bch = meson_chip->bch_mode, cmd;
        int len = mtd->writesize, pagesize, pages;
        int scrambler;
+       u32 cmd;
 
        if (nand->options & NAND_NEED_SCRAMBLING)
                scrambler = NFC_CMD_SCRAMBLER_ENABLE;
        else
                scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 

scrambler depends on NAND_NEED_SCRAMBLING so suppose that is not set

scrambler = NAND_NEED_SCRAMBLING;

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 263

Quoted 9 lines
drivers/mtd/nand/raw/meson_nand.c +1 -5
-       pagesize = nand->ecc.size;
-
        if (raw) {
                len = mtd->writesize + mtd->oobsize;
                cmd = len | scrambler | DMA_DIR(dir);
-               writel(cmd, nfc->reg_base + NFC_REG_CMD);
-               return;
-       }
+       } else if (meson_nfc_is_boot_page(nand, page)) {
Quoted 4 lines

Now here you seems that you don't care anymore about this option and check only meson_nfc_is_boot_page

Is something am I missing?

Idea is the following IIUC: such boot pages could be read in ECC mode only with enabled scrambling - otherwise we get ECC error. Or we need to read it in raw mode. So:

if (read page in raw mode) {
use scrambler as provided
} else if (read boot page in ECC mode) {
force scrambling mode + NFC_ECC_BCH8_1K + NFC_CMD_SHORTMODE_ENABLE

Quoted 60 lines
} else {
    //we read non-boot page in ECC mode

use scrambler as provided
}

Thanks

Quoted 52 lines

Michael

Quoted 47 lines
drivers/mtd/nand/raw/meson_nand.c +29 -4
+               pagesize = NFC_SHORT_MODE_ECC_SZ >> 3;
+               pages = mtd->writesize / 512;
 
-       pages = len / nand->ecc.size;
+               scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K,
+                              NFC_CMD_SHORTMODE_ENABLE, pagesize, pages);
+       } else {
+               pagesize = nand->ecc.size >> 3;
+               pages = len / nand->ecc.size;
 
-       cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
-                      NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode,
+                              NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+       }
 
        if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
                meson_nfc_cmd_seed(nfc, page);
@@ -1132,6 +1150,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc,
                goto err_chip_buf_free;
        }
 
+       if (nand->options & NAND_IS_BOOT_MEDIUM) {
+               ret = ofnode_read_u32(node, "amlogic,boot-pages",
+                                     &meson_chip->boot_pages);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+
+               ret = ofnode_read_u32(node, "amlogic,boot-page-step",
+                                     &meson_chip->boot_page_step);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+       }
+
        ret = nand_register(0, mtd);
        if (ret) {
                dev_err(dev, "'nand_register()' failed: %d\n", ret);
--

2.30.1

The first patch seems not apply clean to me on master

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#9 lore raw

Re: [PATCH v2 3/3] mtd: rawnand: meson: read/write access for boot ROM pages

Quoted 178 lines · Michael Nazzareno Trimarchi

Hi

Quoted 113 lines · Arseniy Krasnov
Quoted 97 lines · Michael Nazzareno Trimarchi

Hi

Quoted 67 lines · Arseniy Krasnov

Boot ROM on Meson needs some pages to be read/written in a special mode:
384 byte ECC mode (so called "short" by Amlogic) and with scrambling enabled. Such pages are located on the chip in the following way (for example):

[ p0 ][ p1 ][ p2 ][ p3 ][ p4 ][ p5 ][ p6 ][ p7 ] ... [ pN ]
^ ^ ^ ^

pX is page number "X". "^" means "special" page used by boot ROM - e.g. every 2nd page in the range of [0, 7]. Step (2 here) and last page in range is read from the device tree.

---
 drivers/mtd/nand/raw/meson_nand.c | 56 +++++++++++++++++++++++++------
 1 file changed, 46 insertions(+), 10 deletions(-)
drivers/mtd/nand/raw/meson_nand.c +15 -1
index 19f005202b..54ea035d8d 100644
@@ -40,6 +40,7 @@
 #define NFC_CMD_RB                     BIT(20)
 #define NFC_CMD_SCRAMBLER_ENABLE       BIT(19)
 #define NFC_CMD_SCRAMBLER_DISABLE      0
+#define NFC_CMD_SHORTMODE_ENABLE       1
 #define NFC_CMD_SHORTMODE_DISABLE      0
 #define NFC_CMD_RB_INT                 BIT(14)
 #define NFC_CMD_RB_INT_NO_PIN          ((0xb << 10) | BIT(18) | BIT(16))
@@ -78,6 +79,8 @@
 
 #define DMA_DIR(dir)           ((dir) ? NFC_CMD_N2M : NFC_CMD_M2N)
 
+#define NFC_SHORT_MODE_ECC_SZ  384
+
 #define ECC_CHECK_RETURN_FF    -1
 
 #define NAND_CE0               (0xe << 10)
@@ -141,6 +144,8 @@
 struct meson_nfc_nand_chip {
        struct list_head node;
        struct nand_chip nand;
+       u32 boot_pages;
+       u32 boot_page_step;
 
        u32 bch_mode;
        u8 *data_buf;
@@ -229,33 +234,46 @@ static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed)
               nfc->reg_base + NFC_REG_CMD);
 }
 
+static int meson_nfc_is_boot_page(struct nand_chip *nand, int page)
+{
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
+
+       return (nand->options & NAND_IS_BOOT_MEDIUM) &&
+              !(page % meson_chip->boot_page_step) &&
+              (page < meson_chip->boot_pages);
+}
+
 static void meson_nfc_cmd_access(struct nand_chip *nand, bool raw, bool dir, int page)
 {
+       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);
        struct mtd_info *mtd = nand_to_mtd(nand);
        const struct meson_nfc *nfc = nand_get_controller_data(mtd_to_nand(mtd));
-       const struct meson_nfc_nand_chip *meson_chip = to_meson_nand(nand);

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 259

Quoted 10 lines
drivers/mtd/nand/raw/meson_nand.c +1 -1
-       u32 bch = meson_chip->bch_mode, cmd;
        int len = mtd->writesize, pagesize, pages;
        int scrambler;
+       u32 cmd;
 
        if (nand->options & NAND_NEED_SCRAMBLING)
                scrambler = NFC_CMD_SCRAMBLER_ENABLE;
        else
                scrambler = NFC_CMD_SCRAMBLER_DISABLE;
 

scrambler depends on NAND_NEED_SCRAMBLING so suppose that is not set

scrambler = NAND_NEED_SCRAMBLING;

drivers/mtd/nand/raw/meson_nand.c static void meson_nfc_cmd_seed(const struct meson_nfc *nfc, u32 seed) · line 263

Quoted 9 lines
drivers/mtd/nand/raw/meson_nand.c +1 -5
-       pagesize = nand->ecc.size;
-
        if (raw) {
                len = mtd->writesize + mtd->oobsize;
                cmd = len | scrambler | DMA_DIR(dir);
-               writel(cmd, nfc->reg_base + NFC_REG_CMD);
-               return;
-       }
+       } else if (meson_nfc_is_boot_page(nand, page)) {
Quoted 4 lines

Now here you seems that you don't care anymore about this option and check only meson_nfc_is_boot_page

Is something am I missing?

Idea is the following IIUC: such boot pages could be read in ECC mode only with enabled scrambling - otherwise we get ECC error. Or we need to read it in raw mode. So:

if (read page in raw mode) {
use scrambler as provided
} else if (read boot page in ECC mode) {
force scrambling mode + NFC_ECC_BCH8_1K + NFC_CMD_SHORTMODE_ENABLE

Quoted 60 lines
} else {
    //we read non-boot page in ECC mode

use scrambler as provided
}

Thanks

Quoted 52 lines

Michael

Quoted 47 lines
drivers/mtd/nand/raw/meson_nand.c +29 -4
+               pagesize = NFC_SHORT_MODE_ECC_SZ >> 3;
+               pages = mtd->writesize / 512;
 
-       pages = len / nand->ecc.size;
+               scrambler = NFC_CMD_SCRAMBLER_ENABLE;
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, NFC_ECC_BCH8_1K,
+                              NFC_CMD_SHORTMODE_ENABLE, pagesize, pages);
+       } else {
+               pagesize = nand->ecc.size >> 3;
+               pages = len / nand->ecc.size;
 
-       cmd = CMDRWGEN(DMA_DIR(dir), scrambler, bch,
-                      NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+               cmd = CMDRWGEN(DMA_DIR(dir), scrambler, meson_chip->bch_mode,
+                              NFC_CMD_SHORTMODE_DISABLE, pagesize, pages);
+       }
 
        if (scrambler == NFC_CMD_SCRAMBLER_ENABLE)
                meson_nfc_cmd_seed(nfc, page);
@@ -1132,6 +1150,24 @@ static int meson_nfc_nand_chip_init(struct udevice *dev, struct meson_nfc *nfc,
                goto err_chip_buf_free;
        }
 
+       if (nand->options & NAND_IS_BOOT_MEDIUM) {
+               ret = ofnode_read_u32(node, "amlogic,boot-pages",
+                                     &meson_chip->boot_pages);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-pages' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+
+               ret = ofnode_read_u32(node, "amlogic,boot-page-step",
+                                     &meson_chip->boot_page_step);
+               if (ret) {
+                       dev_err(dev, "could not retrieve 'amlogic,boot-page-step' property: %d",
+                               ret);
+                       goto err_chip_buf_free;
+               }
+       }
+
        ret = nand_register(0, mtd);
        if (ret) {
                dev_err(dev, "'nand_register()' failed: %d\n", ret);
--

2.30.1

Quoted 3 lines

The first patch seems not apply clean to me on master

Got it, I'll check

Thanks

Quoted 3 lines