blob: dcea7de9265c1e86e20493231eab7b9e1764512f [file] [log] [blame]
developer3c26b032022-06-23 19:02:08 +08001From a4f235c3a3c4d25aa6a4417ce64831ca0b38c324 Mon Sep 17 00:00:00 2001
2From: "SkyLake.Huang" <skylake.huang@mediatek.com>
3Date: Thu, 23 Jun 2022 18:37:55 +0800
4Subject: [PATCH] drivers: spi-mem: Add spi calibration hook
5
6Signed-off-by: SkyLake.Huang <skylake.huang@mediatek.com>
7---
8 drivers/spi/spi-mem.c | 8 ++++++++
9 include/linux/spi/spi-mem.h | 4 ++++
10 2 files changed, 12 insertions(+)
11
12diff --git a/drivers/spi/spi-mem.c b/drivers/spi/spi-mem.c
13index 33115bcfc..b5ab26e9c 100644
14--- a/drivers/spi/spi-mem.c
15+++ b/drivers/spi/spi-mem.c
16@@ -383,6 +383,14 @@ int spi_mem_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
17 }
18 EXPORT_SYMBOL_GPL(spi_mem_exec_op);
19
20+int spi_mem_do_calibration(struct spi_mem *mem,
21+ int (*cal_read)(void *priv, u32 *addr, int addrlen, u8 *buf, int readlen),
22+ void *priv)
23+{
24+ return spi_do_calibration(mem->spi->controller, mem->spi, cal_read, priv);
25+}
26+EXPORT_SYMBOL_GPL(spi_mem_do_calibration);
27+
28 /**
29 * spi_mem_get_name() - Return the SPI mem device name to be used by the
30 * upper layer if necessary
31diff --git a/include/linux/spi/spi-mem.h b/include/linux/spi/spi-mem.h
32index af9ff2f0f..e2cde8305 100644
33--- a/include/linux/spi/spi-mem.h
34+++ b/include/linux/spi/spi-mem.h
35@@ -332,6 +332,10 @@ bool spi_mem_supports_op(struct spi_mem *mem,
36 int spi_mem_exec_op(struct spi_mem *mem,
37 const struct spi_mem_op *op);
38
39+int spi_mem_do_calibration(struct spi_mem *mem,
40+ int (*cal_read)(void *, u32 *, int, u8 *, int),
41+ void *priv);
42+
43 const char *spi_mem_get_name(struct spi_mem *mem);
44
45 struct spi_mem_dirmap_desc *
46--
472.18.0
48