Skip to content

Commit c6e776a

Browse files
ambarusbroonie
authored andcommitted
spi: s3c64xx: determine the fifo depth only once
Determine the FIFO depth only once, at probe time. ``sdd->fifo_depth`` can be set later on with the FIFO depth specified in the device tree. Signed-off-by: Tudor Ambarus <[email protected]> Link: https://msgid.link/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d6911cf commit c6e776a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/spi/spi-s3c64xx.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ struct s3c64xx_spi_port_config {
191191
* @tx_dma: Local transmit DMA data (e.g. chan and direction)
192192
* @port_conf: Local SPI port configuration data
193193
* @port_id: Port identification number
194+
* @fifo_depth: depth of the FIFO.
194195
* @rx_fifomask: SPI_STATUS.RX_FIFO_LVL mask. Shifted mask defining the field's
195196
* length and position.
196197
* @tx_fifomask: SPI_STATUS.TX_FIFO_LVL mask. Shifted mask defining the field's
@@ -214,6 +215,7 @@ struct s3c64xx_spi_driver_data {
214215
struct s3c64xx_spi_dma_data tx_dma;
215216
const struct s3c64xx_spi_port_config *port_conf;
216217
unsigned int port_id;
218+
unsigned int fifo_depth;
217219
u32 rx_fifomask;
218220
u32 tx_fifomask;
219221
};
@@ -424,7 +426,7 @@ static bool s3c64xx_spi_can_dma(struct spi_controller *host,
424426
struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
425427

426428
if (sdd->rx_dma.ch && sdd->tx_dma.ch)
427-
return xfer->len > FIFO_DEPTH(sdd);
429+
return xfer->len > sdd->fifo_depth;
428430

429431
return false;
430432
}
@@ -548,7 +550,7 @@ static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd,
548550
void __iomem *regs = sdd->regs;
549551
unsigned long val = 1;
550552
u32 status;
551-
u32 max_fifo = FIFO_DEPTH(sdd);
553+
u32 max_fifo = sdd->fifo_depth;
552554

553555
if (timeout_ms)
554556
val = msecs_to_loops(timeout_ms);
@@ -655,7 +657,7 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd,
655657
* For any size less than the fifo size the below code is
656658
* executed atleast once.
657659
*/
658-
loops = xfer->len / FIFO_DEPTH(sdd);
660+
loops = xfer->len / sdd->fifo_depth;
659661
buf = xfer->rx_buf;
660662
do {
661663
/* wait for data to be received in the fifo */
@@ -792,7 +794,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host,
792794
struct spi_transfer *xfer)
793795
{
794796
struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
795-
const unsigned int fifo_len = FIFO_DEPTH(sdd);
797+
const unsigned int fifo_len = sdd->fifo_depth;
796798
const void *tx_buf = NULL;
797799
void *rx_buf = NULL;
798800
int target_len = 0, origin_len = 0;
@@ -1261,6 +1263,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
12611263
sdd->port_id = pdev->id;
12621264
}
12631265

1266+
sdd->fifo_depth = FIFO_DEPTH(sdd);
1267+
12641268
s3c64xx_spi_set_fifomask(sdd);
12651269

12661270
sdd->cur_bpw = 8;
@@ -1352,7 +1356,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
13521356
dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Targets attached\n",
13531357
sdd->port_id, host->num_chipselect);
13541358
dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n",
1355-
mem_res, FIFO_DEPTH(sdd));
1359+
mem_res, sdd->fifo_depth);
13561360

13571361
pm_runtime_mark_last_busy(&pdev->dev);
13581362
pm_runtime_put_autosuspend(&pdev->dev);

0 commit comments

Comments
 (0)