436-drivers-mtd-spi-nor-Add-calibration-support-for-spi-.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. From f3fe3b15eca7908eaac57f9b8387a5dbc45ec5b2 Mon Sep 17 00:00:00 2001
  2. From: "SkyLake.Huang" <[email protected]>
  3. Date: Thu, 23 Jun 2022 18:40:59 +0800
  4. Subject: [PATCH 6/6] drivers: mtd: spi-nor: Add calibration support for
  5. spi-nor
  6. Signed-off-by: SkyLake.Huang <[email protected]>
  7. ---
  8. drivers/mtd/nand/spi/core.c | 5 ++++-
  9. drivers/mtd/spi-nor/core.c | 15 +++++++++++++++
  10. 2 files changed, 19 insertions(+), 1 deletion(-)
  11. --- a/drivers/mtd/nand/spi/core.c
  12. +++ b/drivers/mtd/nand/spi/core.c
  13. @@ -1019,7 +1019,10 @@ int spinand_cal_read(void *priv, u32 *ad
  14. if (ret)
  15. return ret;
  16. - ret = spinand_wait(spinand, &status);
  17. + ret = spinand_wait(spinand,
  18. + SPINAND_READ_INITIAL_DELAY_US,
  19. + SPINAND_READ_POLL_DELAY_US,
  20. + &status);
  21. if (ret < 0)
  22. return ret;
  23. --- a/drivers/mtd/spi-nor/core.c
  24. +++ b/drivers/mtd/spi-nor/core.c
  25. @@ -2900,6 +2900,18 @@ static const struct flash_info *spi_nor_
  26. return NULL;
  27. }
  28. +static int spi_nor_cal_read(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen)
  29. +{
  30. + struct spi_nor *nor = (struct spi_nor *)priv;
  31. +
  32. + nor->reg_proto = SNOR_PROTO_1_1_1;
  33. + nor->read_proto = SNOR_PROTO_1_1_1;
  34. + nor->read_opcode = SPINOR_OP_READ;
  35. + nor->read_dummy = 0;
  36. +
  37. + return nor->controller_ops->read(nor, *addr, readlen, buf);
  38. +}
  39. +
  40. static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor,
  41. const char *name)
  42. {
  43. @@ -3003,6 +3015,9 @@ int spi_nor_scan(struct spi_nor *nor, co
  44. if (!nor->bouncebuf)
  45. return -ENOMEM;
  46. + if(nor->spimem)
  47. + spi_mem_do_calibration(nor->spimem, spi_nor_cal_read, nor);
  48. +
  49. info = spi_nor_get_flash_info(nor, name);
  50. if (IS_ERR(info))
  51. return PTR_ERR(info);