Skip to content

Commit 590f243

Browse files
miquelraynalbroonie
authored andcommitted
spi: cadence-qspi: Make sure write protection is disabled
Renesas RZ/N1 QSPI controllers embed the Cadence IP with some modifications. For instance, they feature a write protection of the direct mapping at the controller level, with this feature all data writes to the AHB region are aborted. Despite the fact that the flag setting write protection is disabled by default, Bootloaders may (and actually do) set it, so mark this feature as being available with a specific flag to, if applicable, make sure it is disabled. Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Miquel Raynal (Schneider Electric) <miquel.raynal@bootlin.com> Tested-by: Santhosh Kumar K <s-k6@ti.com> Link: https://patch.msgid.link/20260122-schneider-6-19-rc1-qspi-v4-12-f9c21419a3e6@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent ae62e7c commit 590f243

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/spi/spi-cadence-quadspi.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static_assert(CQSPI_MAX_CHIPSELECT <= SPI_DEVICE_CS_CNT_MAX);
4848
#define CQSPI_DISABLE_STIG_MODE BIT(9)
4949
#define CQSPI_DISABLE_RUNTIME_PM BIT(10)
5050
#define CQSPI_NO_INDIRECT_MODE BIT(11)
51+
#define CQSPI_HAS_WR_PROTECT BIT(12)
5152

5253
/* Capabilities */
5354
#define CQSPI_SUPPORTS_OCTAL BIT(0)
@@ -220,6 +221,8 @@ struct cqspi_driver_platdata {
220221
#define CQSPI_REG_IRQSTATUS 0x40
221222
#define CQSPI_REG_IRQMASK 0x44
222223

224+
#define CQSPI_REG_WR_PROT_CTRL 0x58
225+
223226
#define CQSPI_REG_INDIRECTRD 0x60
224227
#define CQSPI_REG_INDIRECTRD_START_MASK BIT(0)
225228
#define CQSPI_REG_INDIRECTRD_CANCEL_MASK BIT(1)
@@ -1643,6 +1646,10 @@ static void cqspi_controller_init(struct cqspi_st *cqspi)
16431646
cqspi->iobase + CQSPI_REG_INDIRECTWRWATERMARK);
16441647
}
16451648

1649+
/* Disable write protection at controller level */
1650+
if (cqspi->ddata && cqspi->ddata->quirks & CQSPI_HAS_WR_PROTECT)
1651+
writel(0, cqspi->iobase + CQSPI_REG_WR_PROT_CTRL);
1652+
16461653
/* Disable direct access controller */
16471654
if (!cqspi->use_direct_mode) {
16481655
reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);

0 commit comments

Comments
 (0)