2023-03-10 23:53:54 +00:00
|
|
|
From f3fe3b15eca7908eaac57f9b8387a5dbc45ec5b2 Mon Sep 17 00:00:00 2001
|
|
|
|
From: "SkyLake.Huang" <skylake.huang@mediatek.com>
|
|
|
|
Date: Thu, 23 Jun 2022 18:40:59 +0800
|
|
|
|
Subject: [PATCH 6/6] drivers: mtd: spi-nor: Add calibration support for
|
|
|
|
spi-nor
|
|
|
|
|
|
|
|
Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
|
|
|
|
---
|
|
|
|
drivers/mtd/nand/spi/core.c | 5 ++++-
|
|
|
|
drivers/mtd/spi-nor/core.c | 15 +++++++++++++++
|
|
|
|
2 files changed, 19 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
--- a/drivers/mtd/nand/spi/core.c
|
|
|
|
+++ b/drivers/mtd/nand/spi/core.c
|
2023-03-31 10:40:31 +00:00
|
|
|
@@ -1018,7 +1018,10 @@ int spinand_cal_read(void *priv, u32 *ad
|
2023-03-10 23:53:54 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
- ret = spinand_wait(spinand, &status);
|
|
|
|
+ ret = spinand_wait(spinand,
|
|
|
|
+ SPINAND_READ_INITIAL_DELAY_US,
|
|
|
|
+ SPINAND_READ_POLL_DELAY_US,
|
|
|
|
+ &status);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
--- a/drivers/mtd/spi-nor/core.c
|
|
|
|
+++ b/drivers/mtd/spi-nor/core.c
|
2023-09-19 19:04:14 +00:00
|
|
|
@@ -3061,6 +3061,18 @@ static void spi_nor_debugfs_init(struct
|
2023-03-10 23:53:54 +00:00
|
|
|
info->id_len, info->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int spi_nor_cal_read(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen)
|
|
|
|
+{
|
|
|
|
+ struct spi_nor *nor = (struct spi_nor *)priv;
|
|
|
|
+
|
|
|
|
+ nor->reg_proto = SNOR_PROTO_1_1_1;
|
|
|
|
+ nor->read_proto = SNOR_PROTO_1_1_1;
|
|
|
|
+ nor->read_opcode = SPINOR_OP_READ;
|
|
|
|
+ nor->read_dummy = 0;
|
|
|
|
+
|
|
|
|
+ return nor->controller_ops->read(nor, *addr, readlen, buf);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
|
|
|
|
const char *name)
|
|
|
|
{
|
2023-09-19 19:04:14 +00:00
|
|
|
@@ -3134,6 +3146,9 @@ int spi_nor_scan(struct spi_nor *nor, co
|
2023-03-10 23:53:54 +00:00
|
|
|
if (!nor->bouncebuf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
+ if(nor->spimem)
|
|
|
|
+ spi_mem_do_calibration(nor->spimem, spi_nor_cal_read, nor);
|
|
|
|
+
|
|
|
|
info = spi_nor_get_flash_info(nor, name);
|
|
|
|
if (IS_ERR(info))
|
|
|
|
return PTR_ERR(info);
|