spi: spi-ti-qspi: Fix a bug when accessing non default CS
PATCH 1/1 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.
--- drivers/spi/spi-ti-qspi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-ti-qspi.c +5 -1
@@ -62,6 +62,7 @@ struct ti_qspi {u32 dc;bool mmap_enabled; +int current_cs; };#define QSPI_PID (0x0)
@@ -487,6 +488,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi) MEM_CS_EN(spi->chip_select)); } qspi->mmap_enabled = true; + qspi->current_cs = spi->chip_select; }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,MEM_CS_MASK ,0 ); qspi->mmap_enabled = false; + qspi->current_cs =-1 ; } 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,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_setup_mmap_read (mem->spi, op->cmd.opcode, op->data.buswidth, op->addr.nbytes, op->dummy.nbytes);
@@ -799,6 +802,7 @@ static int ti_qspi_probe(struct platform_device *pdev) } } qspi->mmap_enabled = false; + qspi->current_cs =-1 ; ret =devm_spi_register_master (&pdev->dev, master);if (!ret)
Signature · 1 line
2.24.0
Mark Brown
maintainerApplied "spi: spi-ti-qspi: Fix a bug when accessing non default CS" to the spi tree
The patch
spi: spi-ti-qspi: Fix a bug when accessing non default CS
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-5.5
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
c52c91bb9aa6bd8c38dbf9776158e33038aedd43Mon Sep 17 00:00:00 2001
From: Vignesh Raghavendra <[email protected]>
Date: Wed, 11 Dec 2019 21:22:16 +0530
Subject: [PATCH] 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.
--- drivers/spi/spi-ti-qspi.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/spi/spi-ti-qspi.c +5 -1
@@ -62,6 +62,7 @@ struct ti_qspi {u32 dc;bool mmap_enabled; +int current_cs; };#define QSPI_PID (0x0)
@@ -487,6 +488,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi) MEM_CS_EN(spi->chip_select)); } qspi->mmap_enabled = true; + qspi->current_cs = spi->chip_select; }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,MEM_CS_MASK ,0 ); qspi->mmap_enabled = false; + qspi->current_cs =-1 ; } 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,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_setup_mmap_read (mem->spi, op->cmd.opcode, op->data.buswidth, op->addr.nbytes, op->dummy.nbytes);
@@ -799,6 +802,7 @@ static int ti_qspi_probe(struct platform_device *pdev) } } qspi->mmap_enabled = false; + qspi->current_cs =-1 ; ret =devm_spi_register_master (&pdev->dev, master);if (!ret)
Signature · 1 line
2.20.1