summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrice Chotard <patrice.chotard@st.com>2017-12-12 09:49:41 +0100
committerTom Rini <trini@konsulko.com>2018-01-10 08:05:47 -0500
commit0b3f789ad1a60a437410b2420118325a94f292f3 (patch)
tree0ccf09e3d9b8c10c54861604859cdf8898458934
parentc8f787760ede974ec24407cc66966571384db606 (diff)
ram: stm32: add memory mapping selection support
This allows to controls the memory internal mapping at address 0x0000 0000. We can either map at 0x0000 0000 : _ main flash memory _ system flash memory _ FMC bank1 (NOR/PSRAM 1 and 2) _ embedded SRAM _ FMC/SDRAM bank1 This is needed for future STM32F469-disco board Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
-rw-r--r--drivers/ram/stm32_sdram.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/drivers/ram/stm32_sdram.c b/drivers/ram/stm32_sdram.c
index 6e92b2222d..ec2edd67dd 100644
--- a/drivers/ram/stm32_sdram.c
+++ b/drivers/ram/stm32_sdram.c
@@ -11,6 +11,9 @@
#include <ram.h>
#include <asm/io.h>
+#define MEM_MODE_MASK GENMASK(2, 0)
+#define NOT_FOUND 0xff
+
DECLARE_GLOBAL_DATA_PTR;
struct stm32_fmc_regs {
@@ -253,9 +256,31 @@ static int stm32_fmc_ofdata_to_platdata(struct udevice *dev)
{
struct stm32_sdram_params *params = dev_get_platdata(dev);
struct bank_params *bank_params;
+ struct ofnode_phandle_args args;
+ u32 *syscfg_base;
+ u32 mem_remap;
ofnode bank_node;
char *bank_name;
u8 bank = 0;
+ int ret;
+
+ mem_remap = dev_read_u32_default(dev, "st,mem_remap", NOT_FOUND);
+ if (mem_remap != NOT_FOUND) {
+ ret = dev_read_phandle_with_args(dev, "st,syscfg", NULL, 0, 0,
+ &args);
+ if (ret) {
+ debug("%s: can't find syscon device (%d)\n", __func__,
+ ret);
+ return ret;
+ }
+
+ syscfg_base = (u32 *)ofnode_get_addr(args.node);
+
+ /* set memory mapping selection */
+ clrsetbits_le32(syscfg_base, MEM_MODE_MASK, mem_remap);
+ } else {
+ debug("%s: cannot find st,mem_remap property\n", __func__);
+ }
dev_for_each_subnode(bank_node, dev) {
/* extract the bank index from DT */