meta-st-stm32mp/recipes-bsp/u-boot/u-boot-stm32mp/0014-ARM-v2018.11-stm32mp-r...

495 lines
15 KiB
Diff

From 19120ee9047a8e592c8a82d12a8482ef944f0dda Mon Sep 17 00:00:00 2001
From: Romuald JEANNE <romuald.jeanne@st.com>
Date: Thu, 30 Jan 2020 14:55:56 +0100
Subject: [PATCH 14/17] ARM v2018.11 stm32mp r4 MACHINE
---
arch/arm/mach-stm32mp/Makefile | 3 +-
arch/arm/mach-stm32mp/bsec.c | 4 +-
arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c | 82 ++++++++++++++-----------
arch/arm/mach-stm32mp/cpu.c | 21 +++++++
arch/arm/mach-stm32mp/include/mach/ddr.h | 6 +-
arch/arm/mach-stm32mp/include/mach/stm32.h | 1 +
arch/arm/mach-stm32mp/include/mach/sys_proto.h | 13 +++-
arch/arm/mach-stm32mp/spl.c | 41 ++++++++-----
arch/arm/mach-stm32mp/stm32mp1_helper_dbg.S | 5 +-
9 files changed, 116 insertions(+), 60 deletions(-)
diff --git a/arch/arm/mach-stm32mp/Makefile b/arch/arm/mach-stm32mp/Makefile
index 9158a20..13e7773 100644
--- a/arch/arm/mach-stm32mp/Makefile
+++ b/arch/arm/mach-stm32mp/Makefile
@@ -6,6 +6,7 @@
obj-y += cpu.o
obj-y += dram_init.o
obj-y += syscon.o
+obj-y += bsec.o
ifdef CONFIG_SPL_BUILD
obj-y += spl.o
@@ -13,8 +14,6 @@ obj-$(CONFIG_STM32MP1_RESET_HALT_WORKAROUND) += stm32mp1_helper_dbg.o
else
obj-$(CONFIG_CMD_STM32PROG) += cmd_stm32prog/
obj-$(CONFIG_CMD_STM32KEY) += cmd_stm32key.o
-
-obj-y += bsec.o
obj-$(CONFIG_SYSRESET) += cmd_poweroff.o
obj-$(CONFIG_ARMV7_PSCI) += psci.o
endif
diff --git a/arch/arm/mach-stm32mp/bsec.c b/arch/arm/mach-stm32mp/bsec.c
index 5256378..fa7f39f 100644
--- a/arch/arm/mach-stm32mp/bsec.c
+++ b/arch/arm/mach-stm32mp/bsec.c
@@ -436,7 +436,7 @@ static int stm32mp_bsec_ofdata_to_platdata(struct udevice *dev)
return 0;
}
-#ifndef CONFIG_STM32MP1_TRUSTED
+#if !defined(CONFIG_STM32MP1_TRUSTED) && !defined(CONFIG_SPL_BUILD)
static int stm32mp_bsec_probe(struct udevice *dev)
{
int otp;
@@ -463,7 +463,7 @@ U_BOOT_DRIVER(stm32mp_bsec) = {
.ofdata_to_platdata = stm32mp_bsec_ofdata_to_platdata,
.platdata_auto_alloc_size = sizeof(struct stm32mp_bsec_platdata),
.ops = &stm32mp_bsec_ops,
-#ifndef CONFIG_STM32MP1_TRUSTED
+#if !defined(CONFIG_STM32MP1_TRUSTED) && !defined(CONFIG_SPL_BUILD)
.probe = stm32mp_bsec_probe,
#endif
};
diff --git a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
index 8325b56..c6d8f14 100644
--- a/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
+++ b/arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c
@@ -63,7 +63,7 @@ static const efi_guid_t uuid_mmc[3] = {
};
DECLARE_GLOBAL_DATA_PTR;
-#define ENV_BUF_LEN SZ_1K
+#define ALT_BUF_LEN SZ_1K
/* order of column in flash layout file */
enum stm32prog_col_t {
@@ -842,8 +842,8 @@ static int treat_partition_list(struct stm32prog_data *data)
static int create_partitions(struct stm32prog_data *data)
{
int offset = 0;
- char cmdbuf[32];
- char buf[ENV_BUF_LEN];
+ const int buflen = SZ_8K;
+ char *buf;
char uuid[UUID_STR_LEN + 1];
unsigned char *uuid_bin;
unsigned int mmc_id;
@@ -851,6 +851,10 @@ static int create_partitions(struct stm32prog_data *data)
bool rootfs_found;
struct stm32prog_part_t *part;
+ buf = malloc(buflen);
+ if (!buf)
+ return -ENOMEM;
+
puts("partitions : ");
/* initialize the selected device */
for (i = 0; i < data->dev_nb; i++) {
@@ -860,7 +864,7 @@ static int create_partitions(struct stm32prog_data *data)
offset = 0;
rootfs_found = false;
- memset(buf, 0, sizeof(buf));
+ memset(buf, 0, buflen);
list_for_each_entry(part, &data->dev[i].part_list, list) {
/* skip eMMC boot partitions */
@@ -871,7 +875,17 @@ static int create_partitions(struct stm32prog_data *data)
if (part->part_type == RAW_IMAGE)
continue;
- offset += snprintf(buf + offset, ENV_BUF_LEN - offset,
+ if (offset + 100 > buflen) {
+ pr_debug("\n%s: buffer too small, %s skippped",
+ __func__, part->name);
+ continue;
+ }
+
+ if (!offset)
+ offset += sprintf(buf, "gpt write mmc %d \"",
+ data->dev[i].dev_id);
+
+ offset += snprintf(buf + offset, buflen - offset,
"name=%s,start=0x%llx,size=0x%llx",
part->name,
part->addr,
@@ -879,17 +893,17 @@ static int create_partitions(struct stm32prog_data *data)
if (part->part_type == PART_BINARY)
offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
+ buflen - offset,
",type="
LINUX_RESERVED_UUID);
else
offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
+ buflen - offset,
",type=linux");
if (part->part_type == PART_SYSTEM)
offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
+ buflen - offset,
",bootable");
if (!rootfs_found && !strcmp(part->name, "rootfs")) {
@@ -901,23 +915,21 @@ static int create_partitions(struct stm32prog_data *data)
uuid_bin_to_str(uuid_bin, uuid,
UUID_STR_FORMAT_GUID);
offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
+ buflen - offset,
",uuid=%s", uuid);
}
}
- offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
- ";");
+ offset += snprintf(buf + offset, buflen - offset, ";");
}
if (offset) {
- sprintf(cmdbuf, "gpt write mmc %d \"%s\"",
- data->dev[i].dev_id, buf);
- pr_debug("cmd: %s\n", cmdbuf);
- if (run_command(cmdbuf, 0)) {
- stm32prog_err("partitionning fail : %s",
- cmdbuf);
+ offset += snprintf(buf + offset, buflen - offset, "\"");
+ pr_debug("\ncmd: %s\n", buf);
+ if (run_command(buf, 0)) {
+ stm32prog_err("partitionning fail : %s", buf);
+ free(buf);
+
return -1;
}
}
@@ -926,21 +938,21 @@ static int create_partitions(struct stm32prog_data *data)
part_init(data->dev[i].block_dev);
#ifdef DEBUG
- sprintf(cmdbuf, "gpt verify mmc %d",
- data->dev[i].dev_id);
- pr_debug("cmd: %s ", cmdbuf);
- if (run_command(cmdbuf, 0))
+ sprintf(buf, "gpt verify mmc %d", data->dev[i].dev_id);
+ pr_debug("\ncmd: %s", buf);
+ if (run_command(buf, 0))
printf("fail !\n");
else
printf("OK\n");
/* TEMP : for debug, display partition */
- sprintf(cmdbuf, "part list mmc %d",
- data->dev[i].dev_id);
- run_command(cmdbuf, 0);
+ sprintf(buf, "part list mmc %d", data->dev[i].dev_id);
+ run_command(buf, 0);
#endif
}
puts("done\n");
+ free(buf);
+
return 0;
}
@@ -952,7 +964,7 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
int offset = 0;
char devstr[4];
char dfustr[10];
- char buf[ENV_BUF_LEN];
+ char buf[ALT_BUF_LEN];
u32 size;
char multiplier, type;
@@ -973,7 +985,7 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
type = 'a';/*Readable*/
memset(buf, 0, sizeof(buf));
- offset = snprintf(buf, ENV_BUF_LEN - offset,
+ offset = snprintf(buf, ALT_BUF_LEN - offset,
"@%s/0x%02x/1*%d%c%c ",
part->name, part->id,
size, multiplier, type);
@@ -985,29 +997,29 @@ static int stm32prog_alt_add(struct stm32prog_data *data,
dfu_size = part->size / part->dev->lba_blk_size;
else
dfu_size = part->size;
- offset += snprintf(buf + offset, ENV_BUF_LEN - offset,
+ offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
"raw 0x0 0x%llx", dfu_size);
} else if (part->part_id < 0) {
u64 nb_blk = part->size / part->dev->lba_blk_size;
/* lba_blk_size, mmc->read_bl_len */
- offset += snprintf(buf + offset, ENV_BUF_LEN - offset,
+ offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
"raw 0x%llx 0x%llx",
part->addr, nb_blk);
- offset += snprintf(buf + offset, ENV_BUF_LEN - offset,
+ offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
" mmcpart %d;", -(part->part_id));
} else {
if (part->part_type == PART_SYSTEM &&
(part->dev_type == DFU_DEV_NAND ||
part->dev_type == DFU_DEV_SF))
offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
+ ALT_BUF_LEN - offset,
"partubi");
else
offset += snprintf(buf + offset,
- ENV_BUF_LEN - offset,
+ ALT_BUF_LEN - offset,
"part");
- offset += snprintf(buf + offset, ENV_BUF_LEN - offset,
+ offset += snprintf(buf + offset, ALT_BUF_LEN - offset,
" %d %d;",
part->dev_id,
part->part_id);
@@ -1041,7 +1053,7 @@ static int stm32prog_alt_add_virt(struct dfu_entity *dfu,
{
int ret = 0;
char devstr[4];
- char buf[ENV_BUF_LEN];
+ char buf[ALT_BUF_LEN];
sprintf(devstr, "%d", phase);
sprintf(buf, "@%s/0x%02x/1*%dBe", name, phase, size);
@@ -1100,7 +1112,7 @@ static int dfu_init_entities(struct stm32prog_data *data)
ret = stm32prog_alt_add(data, dfu, part);
}
} else {
- char buf[ENV_BUF_LEN];
+ char buf[ALT_BUF_LEN];
sprintf(buf, "@FlashLayout/0x%02x/1*256Ke ram %x 40000",
PHASE_FLASHLAYOUT, STM32_DDR_BASE);
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index efe8b79..5d43f0b 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -291,18 +291,36 @@ int print_cpuinfo(void)
/* MPUs Part Numbers */
switch (get_cpu_type()) {
+ case CPU_STM32MP157Fxx:
+ cpu_s = "157F";
+ break;
+ case CPU_STM32MP157Dxx:
+ cpu_s = "157D";
+ break;
case CPU_STM32MP157Cxx:
cpu_s = "157C";
break;
case CPU_STM32MP157Axx:
cpu_s = "157A";
break;
+ case CPU_STM32MP153Fxx:
+ cpu_s = "153F";
+ break;
+ case CPU_STM32MP153Dxx:
+ cpu_s = "153D";
+ break;
case CPU_STM32MP153Cxx:
cpu_s = "153C";
break;
case CPU_STM32MP153Axx:
cpu_s = "153A";
break;
+ case CPU_STM32MP151Fxx:
+ cpu_s = "151F";
+ break;
+ case CPU_STM32MP151Dxx:
+ cpu_s = "151D";
+ break;
case CPU_STM32MP151Cxx:
cpu_s = "151C";
break;
@@ -341,6 +359,9 @@ int print_cpuinfo(void)
case CPU_REVB:
cpu_r = "B";
break;
+ case CPU_REVZ:
+ cpu_r = "Z";
+ break;
default:
cpu_r = "?";
break;
diff --git a/arch/arm/mach-stm32mp/include/mach/ddr.h b/arch/arm/mach-stm32mp/include/mach/ddr.h
index b8a17cf..bfc42a7 100644
--- a/arch/arm/mach-stm32mp/include/mach/ddr.h
+++ b/arch/arm/mach-stm32mp/include/mach/ddr.h
@@ -9,8 +9,10 @@
/* DDR power initializations */
enum ddr_type {
STM32MP_DDR3,
- STM32MP_LPDDR2,
- STM32MP_LPDDR3,
+ STM32MP_LPDDR2_16,
+ STM32MP_LPDDR2_32,
+ STM32MP_LPDDR3_16,
+ STM32MP_LPDDR3_32,
};
int board_ddr_power_init(enum ddr_type ddr_type);
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h
index 5283e90..70fb235 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
@@ -96,6 +96,7 @@ enum boot_device {
#define TAMP_BACKUP_MAGIC_NUMBER TAMP_BACKUP_REGISTER(4)
#define TAMP_BACKUP_BRANCH_ADDRESS TAMP_BACKUP_REGISTER(5)
/* non secure access */
+#define TAMP_COPRO_RSC_TBL_ADDRESS TAMP_BACKUP_REGISTER(17)
#define TAMP_BOOT_CONTEXT TAMP_BACKUP_REGISTER(20)
#define TAMP_BOOTCOUNT TAMP_BACKUP_REGISTER(21)
diff --git a/arch/arm/mach-stm32mp/include/mach/sys_proto.h b/arch/arm/mach-stm32mp/include/mach/sys_proto.h
index 871324b..0ede1e7 100644
--- a/arch/arm/mach-stm32mp/include/mach/sys_proto.h
+++ b/arch/arm/mach-stm32mp/include/mach/sys_proto.h
@@ -3,19 +3,26 @@
* Copyright (C) 2015-2017, STMicroelectronics - All Rights Reserved
*/
-/* ID = Device Version (bit31:16) + Device Part Number (RPN) (bit15:0)*/
+/* ID = Device Version (bit31:16) + Device Part Number (RPN) (bit7:0) */
#define CPU_STM32MP157Cxx 0x05000000
#define CPU_STM32MP157Axx 0x05000001
#define CPU_STM32MP153Cxx 0x05000024
#define CPU_STM32MP153Axx 0x05000025
#define CPU_STM32MP151Cxx 0x0500002E
#define CPU_STM32MP151Axx 0x0500002F
+#define CPU_STM32MP157Fxx 0x05000080
+#define CPU_STM32MP157Dxx 0x05000081
+#define CPU_STM32MP153Fxx 0x050000A4
+#define CPU_STM32MP153Dxx 0x050000A5
+#define CPU_STM32MP151Fxx 0x050000AE
+#define CPU_STM32MP151Dxx 0x050000AF
/* return CPU_STMP32MP...Xxx constants */
u32 get_cpu_type(void);
#define CPU_REVA 0x1000
#define CPU_REVB 0x2000
+#define CPU_REVZ 0x2001
/* return CPU_REV constants */
u32 get_cpu_rev(void);
@@ -32,3 +39,7 @@ u32 get_cpu_package(void);
u32 get_bootmode(void);
/* start IWDG watchdog */
int watchdog_start(void);
+
+/* board power management : configure vddcore according OPP */
+void board_vddcore_init(u32 voltage_mv);
+int board_vddcore_set(void);
diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c
index 6c8744f..74b56f9 100644
--- a/arch/arm/mach-stm32mp/spl.c
+++ b/arch/arm/mach-stm32mp/spl.c
@@ -85,42 +85,49 @@ void spl_display_print(void)
}
#endif
+__weak int board_vddcore_set(void)
+{
+ return 0;
+}
+
void board_init_f(ulong dummy)
{
struct udevice *dev;
- int ret;
+ int ret, clk, reset, pinctrl, power;
arch_cpu_init();
ret = spl_early_init();
if (ret) {
- debug("spl_early_init() failed: %d\n", ret);
+ debug("%s: spl_early_init() failed: %d\n", __func__, ret);
hang();
}
- ret = uclass_get_device(UCLASS_CLK, 0, &dev);
- if (ret) {
- debug("Clock init failed: %d\n", ret);
- return;
- }
+ clk = uclass_get_device(UCLASS_CLK, 0, &dev);
+ if (clk)
+ debug("%s: Clock init failed: %d\n", __func__, clk);
- ret = uclass_get_device(UCLASS_RESET, 0, &dev);
- if (ret) {
- debug("Reset init failed: %d\n", ret);
- return;
- }
+ reset = uclass_get_device(UCLASS_RESET, 0, &dev);
+ if (reset)
+ debug("%s: Reset init failed: %d\n", __func__, reset);
- ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
- if (ret) {
- debug("%s: Cannot find pinctrl device\n", __func__);
- return;
- }
+ pinctrl = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
+ if (pinctrl)
+ debug("%s: Cannot find pinctrl device: %d\n",
+ __func__, pinctrl);
/* enable console uart printing */
preloader_console_init();
watchdog_start();
+ /* change vddcore if needed after clock tree init */
+ power = board_vddcore_set();
+
+ if (clk || reset || pinctrl || power)
+ printf("%s: probe failed clk=%d reset=%d pinctrl=%d power=%d\n",
+ __func__, clk, reset, pinctrl, power);
+
ret = uclass_get_device(UCLASS_RAM, 0, &dev);
if (ret) {
printf("DRAM init failed: %d\n", ret);
diff --git a/arch/arm/mach-stm32mp/stm32mp1_helper_dbg.S b/arch/arm/mach-stm32mp/stm32mp1_helper_dbg.S
index 37a1b06..d17a37a 100644
--- a/arch/arm/mach-stm32mp/stm32mp1_helper_dbg.S
+++ b/arch/arm/mach-stm32mp/stm32mp1_helper_dbg.S
@@ -10,6 +10,9 @@
* fixes the limitation. Anyway, this source code identifies the Soc revision
* and is only executed if it corresponds, so it can be kept on other
* revisions without any consequence.
+ * The revisions that need the workaround have ID values:
+ * - 0x2000X500
+ * - 0x2001X500
****************************************************************************/
#include <linux/linkage.h>
@@ -30,7 +33,7 @@
#define PWR_CR1_DBP BIT(8)
#define DBGMCU_IDC_ADDR 0x50081000
-#define DBGMCU_IDC_MASK 0xFFFF0FFF
+#define DBGMCU_IDC_MASK 0xFFFE0FFF
#define DBGMCU_IDC_VALUE 0x20000500
#define TAMP_BKP_REGISTER_20 (0x5C00A100 + (20 << 2))
--
2.7.4