mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
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 <tudor.ambarus@linaro.org> Link: https://msgid.link/r/20240216070555.2483977-5-tudor.ambarus@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
d6911cf27e
commit
c6e776ab6a
@ -191,6 +191,7 @@ struct s3c64xx_spi_port_config {
|
|||||||
* @tx_dma: Local transmit DMA data (e.g. chan and direction)
|
* @tx_dma: Local transmit DMA data (e.g. chan and direction)
|
||||||
* @port_conf: Local SPI port configuration data
|
* @port_conf: Local SPI port configuration data
|
||||||
* @port_id: Port identification number
|
* @port_id: Port identification number
|
||||||
|
* @fifo_depth: depth of the FIFO.
|
||||||
* @rx_fifomask: SPI_STATUS.RX_FIFO_LVL mask. Shifted mask defining the field's
|
* @rx_fifomask: SPI_STATUS.RX_FIFO_LVL mask. Shifted mask defining the field's
|
||||||
* length and position.
|
* length and position.
|
||||||
* @tx_fifomask: SPI_STATUS.TX_FIFO_LVL mask. Shifted mask defining the field's
|
* @tx_fifomask: SPI_STATUS.TX_FIFO_LVL mask. Shifted mask defining the field's
|
||||||
@ -214,6 +215,7 @@ struct s3c64xx_spi_driver_data {
|
|||||||
struct s3c64xx_spi_dma_data tx_dma;
|
struct s3c64xx_spi_dma_data tx_dma;
|
||||||
const struct s3c64xx_spi_port_config *port_conf;
|
const struct s3c64xx_spi_port_config *port_conf;
|
||||||
unsigned int port_id;
|
unsigned int port_id;
|
||||||
|
unsigned int fifo_depth;
|
||||||
u32 rx_fifomask;
|
u32 rx_fifomask;
|
||||||
u32 tx_fifomask;
|
u32 tx_fifomask;
|
||||||
};
|
};
|
||||||
@ -424,7 +426,7 @@ static bool s3c64xx_spi_can_dma(struct spi_controller *host,
|
|||||||
struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
|
struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
|
||||||
|
|
||||||
if (sdd->rx_dma.ch && sdd->tx_dma.ch)
|
if (sdd->rx_dma.ch && sdd->tx_dma.ch)
|
||||||
return xfer->len > FIFO_DEPTH(sdd);
|
return xfer->len > sdd->fifo_depth;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -548,7 +550,7 @@ static u32 s3c64xx_spi_wait_for_timeout(struct s3c64xx_spi_driver_data *sdd,
|
|||||||
void __iomem *regs = sdd->regs;
|
void __iomem *regs = sdd->regs;
|
||||||
unsigned long val = 1;
|
unsigned long val = 1;
|
||||||
u32 status;
|
u32 status;
|
||||||
u32 max_fifo = FIFO_DEPTH(sdd);
|
u32 max_fifo = sdd->fifo_depth;
|
||||||
|
|
||||||
if (timeout_ms)
|
if (timeout_ms)
|
||||||
val = msecs_to_loops(timeout_ms);
|
val = msecs_to_loops(timeout_ms);
|
||||||
@ -655,7 +657,7 @@ static int s3c64xx_wait_for_pio(struct s3c64xx_spi_driver_data *sdd,
|
|||||||
* For any size less than the fifo size the below code is
|
* For any size less than the fifo size the below code is
|
||||||
* executed atleast once.
|
* executed atleast once.
|
||||||
*/
|
*/
|
||||||
loops = xfer->len / FIFO_DEPTH(sdd);
|
loops = xfer->len / sdd->fifo_depth;
|
||||||
buf = xfer->rx_buf;
|
buf = xfer->rx_buf;
|
||||||
do {
|
do {
|
||||||
/* wait for data to be received in the fifo */
|
/* wait for data to be received in the fifo */
|
||||||
@ -792,7 +794,7 @@ static int s3c64xx_spi_transfer_one(struct spi_controller *host,
|
|||||||
struct spi_transfer *xfer)
|
struct spi_transfer *xfer)
|
||||||
{
|
{
|
||||||
struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
|
struct s3c64xx_spi_driver_data *sdd = spi_controller_get_devdata(host);
|
||||||
const unsigned int fifo_len = FIFO_DEPTH(sdd);
|
const unsigned int fifo_len = sdd->fifo_depth;
|
||||||
const void *tx_buf = NULL;
|
const void *tx_buf = NULL;
|
||||||
void *rx_buf = NULL;
|
void *rx_buf = NULL;
|
||||||
int target_len = 0, origin_len = 0;
|
int target_len = 0, origin_len = 0;
|
||||||
@ -1261,6 +1263,8 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
|
|||||||
sdd->port_id = pdev->id;
|
sdd->port_id = pdev->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdd->fifo_depth = FIFO_DEPTH(sdd);
|
||||||
|
|
||||||
s3c64xx_spi_set_fifomask(sdd);
|
s3c64xx_spi_set_fifomask(sdd);
|
||||||
|
|
||||||
sdd->cur_bpw = 8;
|
sdd->cur_bpw = 8;
|
||||||
@ -1352,7 +1356,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
|
|||||||
dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Targets attached\n",
|
dev_dbg(&pdev->dev, "Samsung SoC SPI Driver loaded for Bus SPI-%d with %d Targets attached\n",
|
||||||
sdd->port_id, host->num_chipselect);
|
sdd->port_id, host->num_chipselect);
|
||||||
dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n",
|
dev_dbg(&pdev->dev, "\tIOmem=[%pR]\tFIFO %dbytes\n",
|
||||||
mem_res, FIFO_DEPTH(sdd));
|
mem_res, sdd->fifo_depth);
|
||||||
|
|
||||||
pm_runtime_mark_last_busy(&pdev->dev);
|
pm_runtime_mark_last_busy(&pdev->dev);
|
||||||
pm_runtime_put_autosuspend(&pdev->dev);
|
pm_runtime_put_autosuspend(&pdev->dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user