drivers: memc: stm32: add support for st,mem-swap
Implements H7 FMC binding memory remap or swap configuration. Enables: * sdram-sram - swaps the NOR/PSRAM and SDRAM banks. * sdramb2 - remaps SDRAM bank 2. Does nothing for 'disabled' value (default mapping, reset state). Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
This commit is contained in:
parent
88aee54d54
commit
2dca9d859a
|
@ -4,9 +4,8 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT st_stm32_fmc
|
||||
|
||||
#include <device.h>
|
||||
#include <soc.h>
|
||||
|
||||
#include <drivers/clock_control/stm32_clock_control.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
|
@ -14,6 +13,14 @@
|
|||
#include <logging/log.h>
|
||||
LOG_MODULE_REGISTER(memc_stm32, CONFIG_MEMC_LOG_LEVEL);
|
||||
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_fmc)
|
||||
#define DT_DRV_COMPAT st_stm32_fmc
|
||||
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_fmc)
|
||||
#define DT_DRV_COMPAT st_stm32h7_fmc
|
||||
#else
|
||||
#error "No compatible FMC devicetree node found"
|
||||
#endif
|
||||
|
||||
struct memc_stm32_config {
|
||||
uint32_t fmc;
|
||||
struct stm32_pclken pclken;
|
||||
|
@ -43,6 +50,16 @@ static int memc_stm32_init(const struct device *dev)
|
|||
return r;
|
||||
}
|
||||
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_fmc)
|
||||
#if (DT_ENUM_IDX(DT_DRV_INST(0), st_mem_swap) == 1)
|
||||
/* sdram-sram */
|
||||
MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, FMC_BCR1_BMAP_0);
|
||||
#elif (DT_ENUM_IDX(DT_DRV_INST(0), st_mem_swap) == 2)
|
||||
/* sdramb2 */
|
||||
MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, FMC_BCR1_BMAP_1);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue