Commit c52c91bb authored by Vignesh Raghavendra's avatar Vignesh Raghavendra Committed by Mark Brown

spi: spi-ti-qspi: Fix a bug when accessing non default CS

When switching ChipSelect from default CS0 to any other CS, driver fails
to update the bits in system control module register that control which
CS is mapped for MMIO access. This causes reads to fail when driver
tries to access QSPI flash on CS1/2/3.

Fix this by updating appropriate bits whenever active CS changes.
Reported-by: default avatarAndreas Dannenberg <dannenberg@ti.com>
Signed-off-by: default avatarVignesh Raghavendra <vigneshr@ti.com>
Link: https://lore.kernel.org/r/20191211155216.30212-1-vigneshr@ti.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 3194d253
...@@ -62,6 +62,7 @@ struct ti_qspi { ...@@ -62,6 +62,7 @@ struct ti_qspi {
u32 dc; u32 dc;
bool mmap_enabled; bool mmap_enabled;
int current_cs;
}; };
#define QSPI_PID (0x0) #define QSPI_PID (0x0)
...@@ -487,6 +488,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi) ...@@ -487,6 +488,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
MEM_CS_EN(spi->chip_select)); MEM_CS_EN(spi->chip_select));
} }
qspi->mmap_enabled = true; qspi->mmap_enabled = true;
qspi->current_cs = spi->chip_select;
} }
static void ti_qspi_disable_memory_map(struct spi_device *spi) static void ti_qspi_disable_memory_map(struct spi_device *spi)
...@@ -498,6 +500,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi) ...@@ -498,6 +500,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg, regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
MEM_CS_MASK, 0); MEM_CS_MASK, 0);
qspi->mmap_enabled = false; qspi->mmap_enabled = false;
qspi->current_cs = -1;
} }
static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode, static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode,
...@@ -543,7 +546,7 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem, ...@@ -543,7 +546,7 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem,
mutex_lock(&qspi->list_lock); mutex_lock(&qspi->list_lock);
if (!qspi->mmap_enabled) if (!qspi->mmap_enabled || qspi->current_cs != mem->spi->chip_select)
ti_qspi_enable_memory_map(mem->spi); ti_qspi_enable_memory_map(mem->spi);
ti_qspi_setup_mmap_read(mem->spi, op->cmd.opcode, op->data.buswidth, ti_qspi_setup_mmap_read(mem->spi, op->cmd.opcode, op->data.buswidth,
op->addr.nbytes, op->dummy.nbytes); op->addr.nbytes, op->dummy.nbytes);
...@@ -799,6 +802,7 @@ static int ti_qspi_probe(struct platform_device *pdev) ...@@ -799,6 +802,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
} }
} }
qspi->mmap_enabled = false; qspi->mmap_enabled = false;
qspi->current_cs = -1;
ret = devm_spi_register_master(&pdev->dev, master); ret = devm_spi_register_master(&pdev->dev, master);
if (!ret) if (!ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment