From: Johan Jonker <jbx6244@gmail.com> To: kever.yang@rock-chips.com Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, xypron.glpk@gmx.de, yifeng.zhao@rock-chips.com, jon.lin@rock-chips.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, miquel.raynal@bootlin.com, michael@amarulasolutions.com, dario.binacchi@amarulasolutions.com Subject: [PATCH v2 06/11] rockchip: idb: add randomizer option Date: Sat, 9 Jul 2022 20:49:57 +0200 [thread overview] Message-ID: <0b295d0e-53d6-b35a-3058-861e203b4d83@gmail.com> (raw) In-Reply-To: <20220709183130.8039-1-jbx6244@gmail.com> Add randomizer option as on some NAND chip all data writen by Rockchip tools after the IDB blocks is scrambled. Signed-off-by: Johan Jonker <jbx6244@gmail.com> --- optional --- arch/arm/mach-rockchip/rockchip_idb.c | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/arch/arm/mach-rockchip/rockchip_idb.c b/arch/arm/mach-rockchip/rockchip_idb.c index 37fe6ff2..39eb458a 100644 --- a/arch/arm/mach-rockchip/rockchip_idb.c +++ b/arch/arm/mach-rockchip/rockchip_idb.c @@ -190,6 +190,7 @@ struct rk_idb { u32 boot_blks; u32 boot_ecc; u32 pages_per_blk; + u32 randomizer; struct idb idblock[5]; u32 blk_counter; u32 idb_need_write_back; @@ -206,6 +207,41 @@ struct rk_idb { char uuid_disk_str[UUID_STR_LEN + 1]; }; +u16 random_seed[] = { + 0x576a, 0x05e8, 0x629d, 0x45a3, + 0x649c, 0x4bf0, 0x2342, 0x272e, + 0x7358, 0x4ff3, 0x73ec, 0x5f70, + 0x7a60, 0x1ad8, 0x3472, 0x3612, + 0x224f, 0x0454, 0x030e, 0x70a5, + 0x7809, 0x2521, 0x48f4, 0x5a2d, + 0x492a, 0x043d, 0x7f61, 0x3969, + 0x517a, 0x3b42, 0x769d, 0x0647, + 0x7e2a, 0x1383, 0x49d9, 0x07b8, + 0x2578, 0x4eec, 0x4423, 0x352f, + 0x5b22, 0x72b9, 0x367b, 0x24b6, + 0x7e8e, 0x2318, 0x6bd0, 0x5519, + 0x1783, 0x18a7, 0x7b6e, 0x7602, + 0x4b7f, 0x3648, 0x2c53, 0x6b99, + 0x0c23, 0x67cf, 0x7e0e, 0x4d8c, + 0x5079, 0x209d, 0x244a, 0x747b, + 0x350b, 0x0e4d, 0x7004, 0x6ac3, + 0x7f3e, 0x21f5, 0x7a15, 0x2379, + 0x1517, 0x1aba, 0x4e77, 0x15a1, + 0x04fa, 0x2d61, 0x253a, 0x1302, + 0x1f63, 0x5ab3, 0x049a, 0x5ae8, + 0x1cd7, 0x4a00, 0x30c8, 0x3247, + 0x729c, 0x5034, 0x2b0e, 0x57f2, + 0x00e4, 0x575b, 0x6192, 0x38f8, + 0x2f6a, 0x0c14, 0x45fc, 0x41df, + 0x38da, 0x7ae1, 0x7322, 0x62df, + 0x5e39, 0x0e64, 0x6d85, 0x5951, + 0x5937, 0x6281, 0x33a1, 0x6a32, + 0x3a5a, 0x2bac, 0x743a, 0x5e74, + 0x3b2e, 0x7ec7, 0x4fd2, 0x5d28, + 0x751f, 0x3ef8, 0x39b1, 0x4e49, + 0x746b, 0x6ef6, 0x44be, 0x6db7, +}; + struct nand_para_info nand_para_tbl[] = { {6, {0x2c, 0x64, 0x44, 0x4b, 0xa9, 0x00}, 4, 1, 16, 256, 2, 2, 2048, 0x01df, 3, 17, 40, 32, 1, 0, 1, 0, 0, {0, 0, 0, 0, 0}}, {6, {0x2c, 0x44, 0x44, 0x4b, 0xa9, 0x00}, 4, 1, 16, 256, 2, 2, 1064, 0x01df, 3, 17, 40, 32, 1, 0, 1, 0, 0, {0, 0, 0, 0, 0}}, @@ -640,6 +676,15 @@ void rk_idb_read_page_op(struct rk_idb *plat, int page, int col) writeb(page >> 8, bank_base + BANK_ADDR); writeb(page >> 16, bank_base + BANK_ADDR); writeb(NAND_CMD_READSTART, bank_base + BANK_CMD); + + u32 seed = random_seed[page & 0x7F]; + + if (plat->randomizer) { + if (!(page < plat->pages_per_blk * plat->boot_blks)) + seed |= 0xC0000000; + } + + writel(seed, regs + plat->cfg->randmz_off); } void rk_idb_write_page_op_begin(struct rk_idb *plat, int page, int col) @@ -653,6 +698,15 @@ void rk_idb_write_page_op_begin(struct rk_idb *plat, int page, int col) writeb(page, bank_base + BANK_ADDR); writeb(page >> 8, bank_base + BANK_ADDR); writeb(page >> 16, bank_base + BANK_ADDR); + + u32 seed = random_seed[page & 0x7F]; + + if (plat->randomizer) { + if (!(page < plat->pages_per_blk * plat->boot_blks)) + seed |= 0xC0000000; + } + + writel(seed, regs + plat->cfg->randmz_off); } void rk_idb_write_page_op_end(struct rk_idb *plat) @@ -1277,6 +1331,8 @@ int rk_idb_probe(struct udevice *dev) return -ENODEV; } + plat->randomizer = (plat->info->operation_opt >> 7) & 1; + rk_idb_block_align(plat, plat->info->page_per_blk); rk_idb_build_page_table(plat, plat->info->lsb_mode); -- 2.20.1 _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip
WARNING: multiple messages have this Message-ID (diff)
From: Johan Jonker <jbx6244@gmail.com> To: kever.yang@rock-chips.com Cc: sjg@chromium.org, philipp.tomsich@vrull.eu, xypron.glpk@gmx.de, yifeng.zhao@rock-chips.com, jon.lin@rock-chips.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, miquel.raynal@bootlin.com, michael@amarulasolutions.com, dario.binacchi@amarulasolutions.com Subject: [PATCH v2 06/11] rockchip: idb: add randomizer option Date: Sat, 9 Jul 2022 20:49:57 +0200 [thread overview] Message-ID: <0b295d0e-53d6-b35a-3058-861e203b4d83@gmail.com> (raw) In-Reply-To: <20220709183130.8039-1-jbx6244@gmail.com> Add randomizer option as on some NAND chip all data writen by Rockchip tools after the IDB blocks is scrambled. Signed-off-by: Johan Jonker <jbx6244@gmail.com> --- optional --- arch/arm/mach-rockchip/rockchip_idb.c | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/arch/arm/mach-rockchip/rockchip_idb.c b/arch/arm/mach-rockchip/rockchip_idb.c index 37fe6ff2..39eb458a 100644 --- a/arch/arm/mach-rockchip/rockchip_idb.c +++ b/arch/arm/mach-rockchip/rockchip_idb.c @@ -190,6 +190,7 @@ struct rk_idb { u32 boot_blks; u32 boot_ecc; u32 pages_per_blk; + u32 randomizer; struct idb idblock[5]; u32 blk_counter; u32 idb_need_write_back; @@ -206,6 +207,41 @@ struct rk_idb { char uuid_disk_str[UUID_STR_LEN + 1]; }; +u16 random_seed[] = { + 0x576a, 0x05e8, 0x629d, 0x45a3, + 0x649c, 0x4bf0, 0x2342, 0x272e, + 0x7358, 0x4ff3, 0x73ec, 0x5f70, + 0x7a60, 0x1ad8, 0x3472, 0x3612, + 0x224f, 0x0454, 0x030e, 0x70a5, + 0x7809, 0x2521, 0x48f4, 0x5a2d, + 0x492a, 0x043d, 0x7f61, 0x3969, + 0x517a, 0x3b42, 0x769d, 0x0647, + 0x7e2a, 0x1383, 0x49d9, 0x07b8, + 0x2578, 0x4eec, 0x4423, 0x352f, + 0x5b22, 0x72b9, 0x367b, 0x24b6, + 0x7e8e, 0x2318, 0x6bd0, 0x5519, + 0x1783, 0x18a7, 0x7b6e, 0x7602, + 0x4b7f, 0x3648, 0x2c53, 0x6b99, + 0x0c23, 0x67cf, 0x7e0e, 0x4d8c, + 0x5079, 0x209d, 0x244a, 0x747b, + 0x350b, 0x0e4d, 0x7004, 0x6ac3, + 0x7f3e, 0x21f5, 0x7a15, 0x2379, + 0x1517, 0x1aba, 0x4e77, 0x15a1, + 0x04fa, 0x2d61, 0x253a, 0x1302, + 0x1f63, 0x5ab3, 0x049a, 0x5ae8, + 0x1cd7, 0x4a00, 0x30c8, 0x3247, + 0x729c, 0x5034, 0x2b0e, 0x57f2, + 0x00e4, 0x575b, 0x6192, 0x38f8, + 0x2f6a, 0x0c14, 0x45fc, 0x41df, + 0x38da, 0x7ae1, 0x7322, 0x62df, + 0x5e39, 0x0e64, 0x6d85, 0x5951, + 0x5937, 0x6281, 0x33a1, 0x6a32, + 0x3a5a, 0x2bac, 0x743a, 0x5e74, + 0x3b2e, 0x7ec7, 0x4fd2, 0x5d28, + 0x751f, 0x3ef8, 0x39b1, 0x4e49, + 0x746b, 0x6ef6, 0x44be, 0x6db7, +}; + struct nand_para_info nand_para_tbl[] = { {6, {0x2c, 0x64, 0x44, 0x4b, 0xa9, 0x00}, 4, 1, 16, 256, 2, 2, 2048, 0x01df, 3, 17, 40, 32, 1, 0, 1, 0, 0, {0, 0, 0, 0, 0}}, {6, {0x2c, 0x44, 0x44, 0x4b, 0xa9, 0x00}, 4, 1, 16, 256, 2, 2, 1064, 0x01df, 3, 17, 40, 32, 1, 0, 1, 0, 0, {0, 0, 0, 0, 0}}, @@ -640,6 +676,15 @@ void rk_idb_read_page_op(struct rk_idb *plat, int page, int col) writeb(page >> 8, bank_base + BANK_ADDR); writeb(page >> 16, bank_base + BANK_ADDR); writeb(NAND_CMD_READSTART, bank_base + BANK_CMD); + + u32 seed = random_seed[page & 0x7F]; + + if (plat->randomizer) { + if (!(page < plat->pages_per_blk * plat->boot_blks)) + seed |= 0xC0000000; + } + + writel(seed, regs + plat->cfg->randmz_off); } void rk_idb_write_page_op_begin(struct rk_idb *plat, int page, int col) @@ -653,6 +698,15 @@ void rk_idb_write_page_op_begin(struct rk_idb *plat, int page, int col) writeb(page, bank_base + BANK_ADDR); writeb(page >> 8, bank_base + BANK_ADDR); writeb(page >> 16, bank_base + BANK_ADDR); + + u32 seed = random_seed[page & 0x7F]; + + if (plat->randomizer) { + if (!(page < plat->pages_per_blk * plat->boot_blks)) + seed |= 0xC0000000; + } + + writel(seed, regs + plat->cfg->randmz_off); } void rk_idb_write_page_op_end(struct rk_idb *plat) @@ -1277,6 +1331,8 @@ int rk_idb_probe(struct udevice *dev) return -ENODEV; } + plat->randomizer = (plat->info->operation_opt >> 7) & 1; + rk_idb_block_align(plat, plat->info->page_per_blk); rk_idb_build_page_table(plat, plat->info->lsb_mode); -- 2.20.1
next prev parent reply other threads:[~2022-07-09 18:50 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20220709183130.8039-1-jbx6244@gmail.com> 2022-07-09 18:48 ` [PATCH v2 01/11] rockchip: idb: prepare IDB block device Johan Jonker 2022-07-09 18:48 ` Johan Jonker 2022-07-09 18:49 ` [PATCH v2 02/11] rockchip: idb: add basic functions Johan Jonker 2022-07-09 18:49 ` Johan Jonker 2022-07-09 18:49 ` [PATCH v2 03/11] rockchip: idb: add IDB block device Johan Jonker 2022-07-09 18:49 ` Johan Jonker 2022-07-09 18:49 ` [PATCH v2 04/11] rockchip: idb: add info and stop command Johan Jonker 2022-07-09 18:49 ` Johan Jonker 2022-07-09 18:49 ` [PATCH v2 05/11] rockchip: idb: add sector1 info Johan Jonker 2022-07-09 18:49 ` Johan Jonker 2022-07-09 18:49 ` Johan Jonker [this message] 2022-07-09 18:49 ` [PATCH v2 06/11] rockchip: idb: add randomizer option Johan Jonker 2022-07-09 18:50 ` [PATCH v2 07/11] rockchip: spl: allow more boot devices Johan Jonker 2022-07-09 18:50 ` Johan Jonker 2022-07-09 18:50 ` [PATCH v2 08/11] rockchip: rk3066: add Rockchip IDB block device as boot action Johan Jonker 2022-07-09 18:50 ` Johan Jonker 2022-07-09 18:50 ` [PATCH v2 09/11] arm: dts: rockchip: sync rk3066/rk3188 DT files from Linux Johan Jonker 2022-07-09 18:50 ` Johan Jonker 2022-09-04 11:04 ` Johan Jonker 2022-09-09 9:49 ` Kever Yang 2022-07-09 18:50 ` [PATCH v2 10/11] arm: dts: rockchip: enable nfc node in spl for rk3066 mk808 Johan Jonker 2022-07-09 18:50 ` Johan Jonker 2022-07-09 18:51 ` [PATCH v2 11/11] rockchip: configs: mk808: add idb configs Johan Jonker 2022-07-09 18:51 ` Johan Jonker
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=0b295d0e-53d6-b35a-3058-861e203b4d83@gmail.com \ --to=jbx6244@gmail.com \ --cc=dario.binacchi@amarulasolutions.com \ --cc=jon.lin@rock-chips.com \ --cc=kever.yang@rock-chips.com \ --cc=linux-rockchip@lists.infradead.org \ --cc=michael@amarulasolutions.com \ --cc=miquel.raynal@bootlin.com \ --cc=philipp.tomsich@vrull.eu \ --cc=sjg@chromium.org \ --cc=u-boot@lists.denx.de \ --cc=xypron.glpk@gmx.de \ --cc=yifeng.zhao@rock-chips.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.