]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-6.6/spi-s3c64xx-determine-the-fifo-depth-only-once.patch
Linux 6.1.85
[thirdparty/kernel/stable-queue.git] / queue-6.6 / spi-s3c64xx-determine-the-fifo-depth-only-once.patch
1 From 0775d8f28a19f70186de150e220cc1347cd153bb Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Fri, 16 Feb 2024 07:05:47 +0000
4 Subject: spi: s3c64xx: determine the fifo depth only once
5
6 From: Tudor Ambarus <tudor.ambarus@linaro.org>
7
8 [ Upstream commit c6e776ab6abdfce5a1edcde7a22c639e76499939 ]
9
10 Determine the FIFO depth only once, at probe time.
11 ``sdd->fifo_depth`` can be set later on with the FIFO depth
12 specified in the device tree.
13
14 Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
15 Link: https://msgid.link/r/20240216070555.2483977-5-tudor.ambarus@linaro.org
16 Signed-off-by: Mark Brown <broonie@kernel.org>
17 Stable-dep-of: a3d3eab627bb ("spi: s3c64xx: Use DMA mode from fifo size")
18 Signed-off-by: Sasha Levin <sashal@kernel.org>
19 ---
20 drivers/spi/spi-s3c64xx.c | 14 +++++++++-----
21 1 file changed, 9 insertions(+), 5 deletions(-)
22
23 diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
24 index 688b8fad9e2fd..e059fb9db1da1 100644
25 --- a/drivers/spi/spi-s3c64xx.c
26 +++ b/drivers/spi/spi-s3c64xx.c
27 @@ -189,6 +189,7 @@ struct s3c64xx_spi_port_config {
28 * @tx_dma: Local transmit DMA data (e.g. chan and direction)
29 * @port_conf: Local SPI port configuartion data
30 * @port_id: Port identification number
31 + * @fifo_depth: depth of the FIFO.
32 * @rx_fifomask: SPI_STATUS.RX_FIFO_LVL mask. Shifted mask defining the field's
33 * length and position.
34 * @tx_fifomask: SPI_STATUS.TX_FIFO_LVL mask. Shifted mask defining the field's
35 @@ -212,6 +213,7 @@ struct s3c64xx_spi_driver_data {
36 struct s3c64xx_spi_dma_data tx_dma;
37 const struct s3c64xx_spi_port_config *port_conf;
38 unsigned int port_id;
39 + unsigned int fifo_depth;
40 u32 rx_fifomask;
41 u32 tx_fifomask;
42 };
43 @@ -422,7 +424,7 @@ static bool s3c64xx_spi_can_dma(struct spi_controller *host,
44 struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
45
46 if (sdd->rx_dma.ch && sdd->tx_dma.ch)
47 - return xfer->len > FIFO_DEPTH(sdd);
48 + return xfer->len > sdd->fifo_depth;
49
50 return false;
51 }
52 @@ -509,7 +511,7 @@ static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd,
53 void __iomem *regs = sdd->regs;
54 unsigned long val = 1;
55 u32 status;
56 - u32 max_fifo = FIFO_DEPTH(sdd);
57 + u32 max_fifo = sdd->fifo_depth;
58
59 if (timeout_ms)
60 val = msecs_to_loops(timeout_ms);
61 @@ -616,7 +618,7 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd,
62 * For any size less than the fifo size the below code is
63 * executed atleast once.
64 */
65 - loops = xfer->len / FIFO_DEPTH(sdd);
66 + loops = xfer->len / sdd->fifo_depth;
67 buf = xfer->rx_buf;
68 do {
69 /* wait for data to be received in the fifo */
70 @@ -753,7 +755,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host,
71 struct spi_transfer *xfer)
72 {
73 struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
74 - const unsigned int fifo_len = FIFO_DEPTH(sdd);
75 + const unsigned int fifo_len = sdd->fifo_depth;
76 const void *tx_buf = NULL;
77 void *rx_buf = NULL;
78 int target_len = 0, origin_len = 0;
79 @@ -1220,6 +1222,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
80 sdd->port_id = pdev->id;
81 }
82
83 + sdd->fifo_depth = FIFO_DEPTH(sdd);
84 +
85 s3c64xx_spi_set_fifomask(sdd);
86
87 sdd->cur_bpw = 8;
88 @@ -1311,7 +1315,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
89 dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Targets attached\n",
90 sdd->port_id, host->num_chipselect);
91 dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n",
92 - mem_res, FIFO_DEPTH(sdd));
93 + mem_res, sdd->fifo_depth);
94
95 pm_runtime_mark_last_busy(&pdev->dev);
96 pm_runtime_put_autosuspend(&pdev->dev);
97 --
98 2.43.0
99