From e8d9dec1417ddb04e06b6c3cb4ae0cd4c5dcd12e Mon Sep 17 00:00:00 2001 From: Daniel DeGrasse Date: Tue, 15 Oct 2024 17:12:50 +0000 Subject: [PATCH] drivers: memc: memc_mcux_flexspi: allow setting ahb alignment boundary Some instances of the FLEXSPI IP permit limiting AHB bus access so that no memory access requests will straddle a page boundary. Add a property to manage this setting. Signed-off-by: Daniel DeGrasse --- drivers/memc/memc_mcux_flexspi.c | 8 ++++++++ dts/bindings/spi/nxp,imx-flexspi.yaml | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/memc/memc_mcux_flexspi.c b/drivers/memc/memc_mcux_flexspi.c index f81e677085c..f62b418f7ad 100644 --- a/drivers/memc/memc_mcux_flexspi.c +++ b/drivers/memc/memc_mcux_flexspi.c @@ -53,6 +53,7 @@ struct memc_flexspi_data { bool ahb_cacheable; bool ahb_prefetch; bool ahb_read_addr_opt; + uint8_t ahb_boundary; bool combination_mode; bool sck_differential_clock; flexspi_read_sample_clock_t rx_sample_clock; @@ -342,6 +343,12 @@ FSL_FEATURE_FLEXSPI_SUPPORT_SEPERATE_RXCLKSRC_PORTB FLEXSPI_Init(data->base, &flexspi_config); +#if defined(FLEXSPI_AHBCR_ALIGNMENT_MASK) + /* Configure AHB alignment boundary */ + data->base->AHBCR = (data->base->AHBCR & ~FLEXSPI_AHBCR_ALIGNMENT_MASK) | + FLEXSPI_AHBCR_ALIGNMENT(data->ahb_boundary); +#endif + if (memc_flexspi_is_running_xip(dev)) { /* Restore flash sizes */ for (i = 0; i < kFLEXSPI_PortCount; i++) { @@ -414,6 +421,7 @@ static int memc_flexspi_pm_action(const struct device *dev, enum pm_device_actio .ahb_cacheable = DT_INST_PROP(n, ahb_cacheable), \ .ahb_prefetch = DT_INST_PROP(n, ahb_prefetch), \ .ahb_read_addr_opt = DT_INST_PROP(n, ahb_read_addr_opt),\ + .ahb_boundary = DT_INST_ENUM_IDX(n, ahb_boundary), \ .combination_mode = DT_INST_PROP(n, combination_mode), \ .sck_differential_clock = DT_INST_PROP(n, sck_differential_clock), \ .rx_sample_clock = DT_INST_PROP(n, rx_clock_source), \ diff --git a/dts/bindings/spi/nxp,imx-flexspi.yaml b/dts/bindings/spi/nxp,imx-flexspi.yaml index 8a266a8a91d..cedf484ba7a 100644 --- a/dts/bindings/spi/nxp,imx-flexspi.yaml +++ b/dts/bindings/spi/nxp,imx-flexspi.yaml @@ -86,6 +86,18 @@ properties: master_id: AHBRXBUFxCRx[MSTRID] buf_size: AHBRXBUFxCRx[BUFSZ] + ahb-boundary: + type: string + default: "no-boundary" + enum: + - "no-boundary" + - "1024" + - "512" + - "256" + description: | + Sets the AHB read/write boundary. Only supported by some versions of + the FLEXSPI IP. When set, all memory accesses that cross an address + boundary of the specified size will be divided into smaller sub accesses. child-binding: description: NXP FlexSPI port