blob: 2a05ef30a0cf70f36851be21a96842b691fba126 [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From 8efe8045522d7bd790b9ae7408c64f497a54e643 Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:18 +0800
4Subject: [PATCH]
5 [spi-and-storage][999-2363-spi-mediatek-fix-timeout-for-large-data.patch]
6
7---
8 drivers/spi/spi-mt65xx.c | 18 ++++++++++++++++++
9 1 file changed, 18 insertions(+)
10
11diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c
12index dbb471769..871eff03f 100644
13--- a/drivers/spi/spi-mt65xx.c
14+++ b/drivers/spi/spi-mt65xx.c
15@@ -721,6 +721,23 @@ static irqreturn_t mtk_spi_interrupt(int irq, void *dev_id)
16 return IRQ_HANDLED;
17 }
18
19+static int mtk_spi_mem_adjust_op_size(struct spi_mem *mem,
20+ struct spi_mem_op *op)
21+{
22+ int opcode_len;
23+
24+ if(!op->data.nbytes)
25+ return 0;
26+
27+ if (op->data.dir != SPI_MEM_NO_DATA) {
28+ opcode_len = 1 + op->addr.nbytes + op->dummy.nbytes;
29+ if (opcode_len + op->data.nbytes > MTK_SPI_IPM_PACKET_SIZE)
30+ op->data.nbytes = MTK_SPI_IPM_PACKET_SIZE -opcode_len;
31+ }
32+
33+ return 0;
34+}
35+
36 static bool mtk_spi_mem_supports_op(struct spi_mem *mem,
37 const struct spi_mem_op *op)
38 {
39@@ -947,6 +964,7 @@ err_exit:
40 }
41
42 static const struct spi_controller_mem_ops mtk_spi_mem_ops = {
43+ .adjust_op_size = mtk_spi_mem_adjust_op_size,
44 .supports_op = mtk_spi_mem_supports_op,
45 .exec_op = mtk_spi_mem_exec_op,
46 };
47--
482.34.1
49