Debian Codegraph @

debian/patches/upstream/0018-fix-rcar3-drivers-disable-A-B-loader-support-by-defa.patch

raw
1 From 1a5711519a8e685d3db43620623f0f616317cfe9 Mon Sep 17 00:00:00 2001
2 From: Marek Vasut <[email protected]>
3 Date: Sat, 9 Nov 2024 11:42:59 +0100
4 Subject: [PATCH 018/159] fix(rcar3-drivers): disable A/B loader support by
5 default
6
7 The A/B loader [1] meant to be used for convenient CI testing.
8 The tool is installed into the same location as SA0, where it
9 conveniently fits due to its size, and where it makes use of
10 non-volatile PMIC registers to alternate between loading and
11 starting A or B copy of the BL2. The PMIC registers are used
12 because CPU registers are lost across reset.
13
14 In case the B copy is loaded, it is loaded from 8 MiB offset
15 from start of HF. In case the B copy fails to boot, a simple
16 reset of the system will switch back to booting previously
17 known working A copy and allow recovery.
18
19 The A/B loader sets MFIS bit MFISBTSTSR_BOOT_PARTITION to
20 pass the information which A/B copy is currently booting on
21 to TFA, which then loads the follow up components from 0 MiB
22 or 8 MiB offset, depending on whether the A or B copy is being
23 booted.
24
25 The MFISBTSTSR_BOOT_PARTITION interferes with regular A/B
26 switching during boot from eMMC as the boot media, where
27 the BootROM also sets MFISBTSTSR_BOOT_PARTITION bit in case
28 the system boots from SECOND eMMC HW BOOT partition.
29
30 Since the A/B loader is meant as a development and CI tool,
31 isolate the A/B loader use to RPC HF only and furthermore
32 isolate it behind new RCAR_RPC_HYPERFLASH_ABLOADER option
33 which is disabled by default.
34
35 [1] https://github.com/marex/abloader
36
37 Signed-off-by: Marek Vasut <[email protected]>
38 Change-Id: I04ecd50fa1405b78e1ba3949d54029034d4f22d8
39 ---
40 drivers/renesas/common/io/io_rcar.c | 18 ++++++++++++++++--
41 plat/renesas/rcar/platform.mk | 7 +++++++
42 2 files changed, 23 insertions(+), 2 deletions(-)
43
44 diff --git a/drivers/renesas/common/io/io_rcar.c b/drivers/renesas/common/io/io_rcar.c
45 index 66662c111..1529dc0f0 100644
46 --- a/drivers/renesas/common/io/io_rcar.c
47 +++ b/drivers/renesas/common/io/io_rcar.c
48 @@ -149,6 +149,9 @@ static uint64_t rcar_image_header[RCAR_MAX_BL3X_IMAGE + 2U] = { 0U };
49 static uint64_t rcar_image_header_prttn[RCAR_MAX_BL3X_IMAGE + 2U] = { 0U };
50 static uint64_t rcar_image_number = { 0U };
51 static uint32_t rcar_cert_load = { 0U };
52 +#if (RCAR_RPC_HYPERFLASH_ABLOADER == 1)
53 +static uint32_t rcar_image_offset = 0U;
54 +#endif
55
56 static io_type_t device_type_rcar(void)
57 {
58 @@ -196,8 +199,10 @@ static int32_t file_to_offset(const int32_t name, uintptr_t *offset,
59
60 *offset = rcar_image_header[addr];
61
62 - if (mmio_read_32(MFISBTSTSR) & MFISBTSTSR_BOOT_PARTITION)
63 - *offset += 0x800000;
64 +#if (RCAR_RPC_HYPERFLASH_ABLOADER == 1)
65 + *offset += rcar_image_offset;
66 +#endif
67 +
68 *cert = RCAR_CERT_SIZE;
69 *cert *= RCAR_ATTR_GET_CERTOFF(name_offset[i].attr);
70 *cert += RCAR_SDRAM_certESS;
71 @@ -499,6 +504,15 @@ static int32_t rcar_dev_init(io_dev_info_t *dev_info, const uintptr_t name)
72 */
73 offset = name == EMMC_DEV_ID ? RCAR_EMMC_CERT_HEADER :
74 RCAR_FLASH_CERT_HEADER;
75 +
76 +#if (RCAR_RPC_HYPERFLASH_ABLOADER == 1)
77 + rcar_image_offset = 0;
78 + if ((name == FLASH_DEV_ID) &&
79 + (mmio_read_32(MFISBTSTSR) & MFISBTSTSR_BOOT_PARTITION)) {
80 + rcar_image_offset = 0x800000;
81 + }
82 +#endif
83 +
84 rc = io_seek(handle, IO_SEEK_SET, offset);
85 if (rc != IO_SUCCESS) {
86 WARN("Firmware Image Package header failed to seek\n");
87 diff --git a/plat/renesas/rcar/platform.mk b/plat/renesas/rcar/platform.mk
88 index 481394946..c19eb3657 100644
89 --- a/plat/renesas/rcar/platform.mk
90 +++ b/plat/renesas/rcar/platform.mk
91 @@ -148,6 +148,13 @@ RCAR_RPC_HYPERFLASH_LOCKED := 1
92 endif
93 $(eval $(call add_define,RCAR_RPC_HYPERFLASH_LOCKED))
94
95 +# Support A/B switching with RPC HYPERFLASH access by default
96 +# Use together with https://github.com/marex/abloader .
97 +ifndef RCAR_RPC_HYPERFLASH_ABLOADER
98 +RCAR_RPC_HYPERFLASH_ABLOADER := 0
99 +endif
100 +$(eval $(call add_define,RCAR_RPC_HYPERFLASH_ABLOADER))
101 +
102 # Process RCAR_SECURE_BOOT flag
103 ifndef RCAR_SECURE_BOOT
104 RCAR_SECURE_BOOT := 1
105 --
106 2.39.5
107