Skip to content

Commit 2dca9d8

Browse files
GeorgeCGVcarlescufi
authored andcommitted
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 <[email protected]>
1 parent 88aee54 commit 2dca9d8

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

drivers/memc/memc_stm32.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#define DT_DRV_COMPAT st_stm32_fmc
8-
97
#include <device.h>
8+
#include <soc.h>
109

1110
#include <drivers/clock_control/stm32_clock_control.h>
1211
#include <drivers/pinctrl.h>
1312

1413
#include <logging/log.h>
1514
LOG_MODULE_REGISTER(memc_stm32, CONFIG_MEMC_LOG_LEVEL);
1615

16+
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_fmc)
17+
#define DT_DRV_COMPAT st_stm32_fmc
18+
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_fmc)
19+
#define DT_DRV_COMPAT st_stm32h7_fmc
20+
#else
21+
#error "No compatible FMC devicetree node found"
22+
#endif
23+
1724
struct memc_stm32_config {
1825
uint32_t fmc;
1926
struct stm32_pclken pclken;
@@ -43,6 +50,16 @@ static int memc_stm32_init(const struct device *dev)
4350
return r;
4451
}
4552

53+
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32h7_fmc)
54+
#if (DT_ENUM_IDX(DT_DRV_INST(0), st_mem_swap) == 1)
55+
/* sdram-sram */
56+
MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, FMC_BCR1_BMAP_0);
57+
#elif (DT_ENUM_IDX(DT_DRV_INST(0), st_mem_swap) == 2)
58+
/* sdramb2 */
59+
MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, FMC_BCR1_BMAP_1);
60+
#endif
61+
#endif
62+
4663
return 0;
4764
}
4865

0 commit comments

Comments
 (0)