openwrt-redmi-ax3000/target/linux/ipq50xx/patches/405-mtd-rawnand-qcom-Enable-support-for-erase-read-write.patch

67 lines
2.4 KiB
Diff

From a5ba59a246e3842ee997e4f2d1ac8cecc8be464c Mon Sep 17 00:00:00 2001
From: Md Sadre Alam <mdalam@codeaurora.org>
Date: Tue, 1 Sep 2020 11:28:09 +0530
Subject: [PATCH 5/7] mtd: rawnand: qcom: Enable support for erase,read & write
for serial nand.
This change will enable support for erase, read & write support for
QSPI serial nand. In QPIC V2.0 onwards, to read last code word new
regiater is introduced. So to read for first three code word we have to
use LOCATION_n register and for last code word we ahve to use LAST_CW_n.
Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
Change-Id: Iafe34e238754dfc006363dd400a48cf9fc8d92d9
Pick from https://git.codelinaro.org/clo/qsdk/oss/kernel/linux-ipq-5.4/-/commit/17e85de9e7933a94461f76fe40a5b88334dfdad6
Signed-off-by: hzy <hzyitc@outlook.com>
---
drivers/mtd/nand/raw/qcom_nandc.c | 97 ++++++++++++++++++++++++++-----
1 file changed, 83 insertions(+), 14 deletions(-)
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c
index e19074062348..0a6b67ddcda2 100644
--- a/drivers/mtd/nand/raw/qcom_nandc.c
+++ b/drivers/mtd/nand/raw/qcom_nandc.c
@@ -733,13 +752,18 @@ static void update_rw_regs(struct qcom_nand_host *host, int num_cw, bool read)
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
u32 cmd, cfg0, cfg1, ecc_bch_cfg;
+ cmd = (PAGE_ACC | LAST_PAGE);
+
+ if (nandc->props->is_serial_nand)
+ cmd |= (SPI_TRANSFER_MODE_x1 | SPI_WP | SPI_HOLD);
+
if (read) {
if (host->use_ecc)
- cmd = OP_PAGE_READ_WITH_ECC | PAGE_ACC | LAST_PAGE;
+ cmd |= OP_PAGE_READ_WITH_ECC;
else
- cmd = OP_PAGE_READ | PAGE_ACC | LAST_PAGE;
+ cmd |= OP_PAGE_READ;
} else {
- cmd = OP_PROGRAM_PAGE | PAGE_ACC | LAST_PAGE;
+ cmd |= OP_PROGRAM_PAGE;
}
if (host->use_ecc) {
@@ -1265,9 +1298,13 @@ static int erase_block(struct qcom_nand_host *host, int page_addr)
{
struct nand_chip *chip = &host->chip;
struct qcom_nand_controller *nandc = get_qcom_nand_controller(chip);
+ u32 ers_cmd = OP_BLOCK_ERASE | PAGE_ACC | LAST_PAGE;
- nandc_set_reg(chip, NAND_FLASH_CMD,
- OP_BLOCK_ERASE | PAGE_ACC | LAST_PAGE);
+ if (nandc->props->is_serial_nand) {
+ ers_cmd |= (SPI_WP | SPI_HOLD | SPI_TRANSFER_MODE_x1);
+ page_addr <<= 16;
+ }
+ nandc_set_reg(chip, NAND_FLASH_CMD, ers_cmd);
nandc_set_reg(chip, NAND_ADDR0, page_addr);
nandc_set_reg(chip, NAND_ADDR1, 0);
nandc_set_reg(chip, NAND_DEV0_CFG0,
--
2.25.1