43 Commits

Author SHA1 Message Date
Andre Przywara
02353e9ae4 fel: add support for Allwinner A133
The Allwinner A133 is a slightly older SoC (around 2020) with four
Cortex-A53 cores, sharing many treats with the H6.
The A100 and R818 are reportedly the same chip, just in different bins
or packaging.
The chip has only 16K of SRAM-A1, but this is immediately followed by
128K of SRAM-C, with later 64K of SRAM-A2, after some gap.
The BootROM SRAM usage is similar to other SoCs: there is the IRQ stack
growing down from a 5K offset in SRAM A1, and probably some buffers
located towards the end of SRAM C. We can use the area just before those
buffers for the IRQ stack backup, which gives us a nice contiguous 128K
SRAM area for any payloads.

This setup is known to boot the WIP mainline U-Boot setup, including
some placeholder TF-A port for now. SPL execution, including returning
back to the BROM, works, also the 64-bit switch, as well as the SID
dump.

Signed-off-by: Andre Przywara <osp@andrep.de>
2025-03-29 20:11:20 +01:00
Andre Przywara
f88e5fe32f fel: a523: change buffer and load addresses
The SRAM situation on the A523 family of SoCs is a bit more involved:
while there is indeed a large 128KB SRAM region at offset 0x20000, this
is labeled as "MCU0 SRAM" and is apparently switchable, to the RISC-V
MCU. It is unclear at this point whether the MCU will take posession of
this region at some point, and whether it might not be available when
rebooting or doing some suspend/resume operations. The BootROM doesn't
use this SRAM, and actually loads the initial boot0/SPL payload from MMC
to 0x44000, so at an 16K offset into SRAM A2.
To keep the SPL compatible between MMC/SPI and FEL loads (we cannot be
position independent), move the SPL address to this 0x44000.
This means we do need a swap buffer, since the FEL stack is right on
early in this region. The region after 0x5c000 seem to be used by the
BROM, so we cannot use that for buffers, without further limiting the
FEL payload. To leave the MCU0 SRAM alone, put those buffers in the 16K
*before* the new SPL load address. Since U-Boot will use 0x44000 for the
initial SPL stack, put the thunk buffer at the beginning, where it should
not be overwritten. The scratch address goes at the usual 4K offset of
the SPL address, where it is located just before the FEL stack.

Signed-off-by: Andre Przywara <osp@andrep.de>
2025-02-10 01:12:49 +00:00
Andre Przywara
f0834e49a0 fel: a523: add icache fix
The Allwinner A523 BROM sets the SCTLR.I bit, to enable the I-cache when
running the FEL BROM code. To avoid the required cache maintenance when
uploading and executing code, just flag the SoC with our .icache_fix
bit, so turn the .I bit off as early as possible.

This fixes more advanced sunxi-fel routines like readl/writel and the
"spl" command on the A523.

Signed-off-by: Andre Przywara <osp@andrep.de>
2025-02-10 01:12:49 +00:00
qianfan Zhao
df60a46e38 soc_info: Add t7_sid_maps
Copied from allwinner t7 linux 4.9 sdk

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2024-01-11 09:48:10 +00:00
qianfan Zhao
3fe6efdc8a fel: Add support for allwinner T7
Allwinner T7 share the same CCM/UART base address with H6.
Add support for it in uart0-helloworld-sdboot.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2024-01-11 09:48:10 +00:00
Andre Przywara
34573bfec5 fel: add Allwinner A523 SoC support
The Allwinner A523 has 128KiB of MCU0 SRAM, which the BootROM will not
touch. The BROM will use some memory in SRAM A2, which it also clears
upon entering FEL mode, starting from address 0x44000. The lowest
allocation seems to be the IRQ stack growing down from 0x45400.
So we won't touch any of that memory, but can freely use the full 128KB
of the primary SRAM for payloads. This means we won't need to swap any
buffers for preserving BROM stacks.
We put the SPL thunk code just below 0x44000, to leave as much SRAM for
the payload as possible.
The rest of the SoC is pretty standard, although the watchdogs are now
in separate MMIO frames, not part of some timer block anymore.

The secure boot mode will prevent even reading the BootROM, so we can
use an address in there to test for the secure boot state. However, even
though a simple "smc #0" will return to its caller, the NS bit is still
set, so we are still in non-secure state afterwards. So leave this bit
out for now until we figure out how to switch to secure state properly.

Signed-off-by: Andre Przywara <osp@andrep.de>
2023-11-21 15:42:51 +01:00
Andre Przywara
34c3150898 fel: introduce get_next_soc()
At the moment we can search for a specific SoC in our supported SoC
table by looking for its SoC ID, but we cannot otherwise enumerate all
supported SoCs.

Add a get_next_soc() function that allows iterating over our (internal)
table: The first call will take NULL as an argument, subsequent calls
pass in the pointer returned by the previous call. When we reach the end
of the list, the function returns NULL.

Signed-off-by: Andre Przywara <osp@andrep.de>
2023-10-25 19:55:02 +02:00
Andre Przywara
05f58b50dd fel: h616: support alternative die variant
The Allwinner H616 ships in at least two die variants, sometime under a
different name (H618, T507), but sometimes labeled as a normal "H616".
The die variants differ in their CPU cluster control subsystem, which
affects the location of the RVBAR shadow register used to reset the core
into 64-bit mode. We use that in the "reset64" command, but also as part
of the boot process using the "uboot" command, on ARMv8 cores.

Add code to detect the die variant by reading the VER_REG MMIO register,
where the original die reports 0x00 in the lower 8 bits, but the newer
die variants apparently 0x02. In the latter case let the aw_rmr_request()
function use the alternative RVBAR address to do the 64-bit switch.
This matches what we do in U-Boot and Trusted Firmware.

Signed-off-by: Andre Przywara <osp@andrep.de>
2023-08-08 01:16:55 +01:00
Andre Przywara
6a2f6b5e32 fel: sid: fix segfault with default section map
The generic_2k_sid_maps, describing the SID sections for chips where we
don't have any specific information yet, was missing the terminating
NULL section, so we would run off into to woods, beyond the array limit.
This would most commonly result in a segfault:
$ sunxi-fel sid-dump
....
                00000000 00000000 00000000 00000000
Segmentation fault (core dumped)
=================

Add the NULL sentinel to terminate the loop correctly.

Signed-off-by: Andre Przywara <osp@andrep.de>
2023-04-11 23:21:48 +01:00
Andre Przywara
536a1910ad fel: sid: add SID dump maps for other SoCs
At the moment we only have a SID map for the R40. Add a generic
placeholder map, covering the 2048 bits that most SoCs have (at least).

The linux-sunxi Wiki page [1] for the SID register layout describes
entries for the H6 and "SoCs before H6". Add those tables as well, and
use the latter one for some SoCs which were released the closest to the
H6 (H3, A64, H5).
If people have more information, more specific maps can be added.

[1] https://linux-sunxi.org/SID_Register_Guide#eFUSE_Region_Overview

Signed-off-by: Andre Przywara <osp@andrep.de>
2023-03-05 23:24:33 +00:00
qianfan Zhao
056b65fbc0 fel: Introduce 'sid-dump'
The sid memory maps are copied from allwinner 3.10 bsp.

Next is a sample output from allwinner T3:
$ sunxi-fel sid-dump
chipid          1300000c 02c04700 79350400 30791acc
in              00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
ssk             00000000 00000000 00000000 00000000
thermal         0823081c
ft_zone         00000000 00000000
tvout           00ff02ad 00f8029e 00f0028d 00f902a2
rssk            00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
hdcp_hash       00000000 00000000 00000000 00000000
reserved        00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                00000000 00000000 00000000 00000000

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
2023-02-22 11:50:56 +00:00
chalesyu
7123ec8d16 fel: add support for A63
Allwinner A63 is almost same as H6, so just copy H6 code
and change id to add support for it.

Signed-off-by: Zhao Yu <574249312@qq.com>
2022-07-29 22:55:22 +01:00
Andre Przywara
cbaf572b3d fel: add Allwinner V5 SoC support
The V5 is (yet another) example of a more recent SoC with A7 cores, so
it goes with the H6 memory map and peripherals, but with 32-bit cores.

Add basic support, to facilitate development.

Signed-off-by: Andre Przywara <osp@andrep.de>
2022-07-29 12:01:30 +01:00
Andre Przywara
f0e5fe9766 fel: add support for R528/T113s
This SoC is using the same die as the RISC-V D1, but we don't support
non-ARM yet. The memory map and peripherals (watchdog) are very similar
to the V853, also the BROM enabled the instruction cache, so requires
the same I cache hack.

Signed-off-by: Andre Przywara <osp@andrep.de>
2022-07-29 12:01:30 +01:00
Icenowy Zheng
d39b0a7d6e fel: add support for V853
Allwinner V853 is a new SoC from Allwinner that has I-Cache enabled
(thus broken FEL write-and-execute) in BROM.

Add support for it.

The SRAM infomation was gathered by reverse engineering its BROM and
checking its SRAM usage, confirmed by the manual.

Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
[Andre: fix watchdog]
Signed-off-by: Andre Przywara <osp@andrep.de>
2022-07-29 10:11:23 +01:00
Chen-Yu Tsai
76089c82d0
Merge pull request #173 from apritzel/f1c100
Allwinner F1C100 support
2022-03-29 21:10:49 +08:00
Chen-Yu Tsai
cf942c0293
Merge pull request #164 from danielkucera/v536
Add V536 SoC support
2022-03-29 21:10:25 +08:00
Icenowy Zheng
1fc2af5c4b fel: add F1C100s SoC
Allwinner F1C100s is one of the new ARM9 SoCs produced by Allwinner.

Add support for it in FEL.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Andre Przywara <osp@andrep.de>
2022-03-06 00:48:11 +00:00
Daniel Kucera
458a2c6d25 add V536 SoC support
HW very similar to V831, for the purpose of fel practically identical
2021-12-16 07:53:58 +01:00
Icenowy Zheng
7a21ba04de fel: add support for R329
Allwinner R329 has no SRAM A1, but a huge SRAM A2 that is partly
utilized as boot time SRAM.

Add basical support for it. The spl subcommand is tested with modified
uart0-helloworld-sdboot and extracted original boot0.

Signed-off-by: Icenowy Zheng <icenowy@sipeed.com>
2021-07-20 17:25:43 +08:00
Andre Przywara
ada2483093 fel: A64/H5: Allow bigger SPL size
The A64 and H5 have a rather generous SRAM C directly adjacent to
SRAM A1, so we can make use of the larger continuous SRAM area to
increase the maximum SPL size.

Move the location of the FEL stack backup buffer up, towards the end of
SRAM C. We restrict ourselves to the slightly tighter requirements of
the H5, to be able to still share the joint swap_buffers data structure.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:14:54 +00:00
Andre Przywara
2f59b574ba fel: H6: Allow bigger SPL size
The H6 has quite a large chunk of continuous SRAM, and also the BROM
allows to load eGON images far bigger than 32KB.

Move the FEL stack backup buffers and the thunk address towards the end
of SRAM C, so that we have a larger chunk of continuous SRAM available
for the SPL.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:14:38 +00:00
Andre Przywara
2a2af190d4 fel: H616: Allow bigger SPL size
The H616 has quite a large chunk of continuous SRAM, and also the BROM
allows to load eGON images far bigger than 32KB. U-Boot's SPL is
actually relying on this, as we need more code for the PMIC and DRAM
driver.

Move the FEL stack backup buffers and the thunk address towards the end
of SRAM C, so that we have a larger chunk of continuous SRAM available
for the SPL.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:13:59 +00:00
Andre Przywara
276a97da6c soc_info: Introduce SRAM size
At the moment we assume the SPL load size to be limited to 32KB, even
though many SoCs have more SRAM A1 or a large SRAM C directly after SRAM
A1.

To later allow to extend the SPL load size, let's introduce a SoC
specific variable to hold the SRAM size after the SPL load address. This
could either cover the whole of SRAM A1, or even SRAM C, if that is
contiguous to SRAM A1.

Eventually this variable is meant to hold the *usable* SRAM size, so not
including regions that are used by the BROM code. However this value is
very SoC specific and not documented, and the SPL size is limited by the
thunk and stack buffers anyway at the moment, so the values used here
right now are just taken from the respective manuals.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-12-31 18:13:51 +00:00
Andre Przywara
ac432c4c77 wdreset: Add remaining SoCs
The "wdreset" command so far only covered a few SoCs.

Add the watchdog data for the other ones as well.

Signed-off-by: Andre Przywara <osp@andrep.de>
2020-11-08 16:38:12 +00:00
Jernej Skrabec
40ac9dafe1 Add support for H616 2020-10-02 17:42:25 +02:00
Chen-Yu Tsai
7cc37c883b
Merge pull request #140 from Icenowy/v831
V831 SoC support
2020-09-29 17:39:49 +08:00
Icenowy Zheng
c6111193f6 fel: add initial SoC info for V831
The non-IRQ stack is moved to near the end of the SRAM C, which is very
high, and have no need to save.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
2020-09-29 14:28:08 +08:00
Chen-Yu Tsai
e334ccf5b2
Merge pull request #110 from jackmitch/master
fel: enable A83T MMU
2020-09-29 14:21:48 +08:00
Priit Laes
6e825a0b33 FEL: Add wdreset support to Allwinner A20 SoC
Signed-off-by: Priit Laes <plaes@plaes.org>
2020-06-14 14:54:48 +03:00
Karl Palsson
39bd0d1dd8 Provide a wrapper for reset via watchdog
The watchdog register isn't in the same place, nor uses the same values
to trigger a reset.

Signed-off-by: Karl Palsson <karlp@tweak.net.au>
2020-06-14 14:50:34 +03:00
Icenowy Zheng
ed54b135c1 fel: add SoC info for H6 SoC
Allwinner H6 is a new SoC with its memory map changed.

Add its SoC info, including SRAM addresses and SID address.

Signed-off-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Andre Przywara <osp@andrep.de>
2018-07-09 09:16:24 +01:00
Jack Mitchell
2573658275 fel: enable A83T MMU
As per the wiki[1] set ttbr0 to 0x44000 to enable the MMU. Transfer
speed is increased from 191KB/s to ~800KB/s which is handy when
transferring larger kernels and root filesystems.

Tested on a custom H8/A83T board.

[1] https://linux-sunxi.org/FEL/USBBoot
2018-02-27 13:54:02 +00:00
Siarhei Siamashka
275827ad73 fel: Enable the SMC workaround for H3/H5/A64/H64
Use a hardwired L.NOP instruction from the OpenRISC reset
vector as a way to check if the workaround is necessary.
Because these L.NOP instructions are guaranteed to be there
and are read-only, this is the most reliable non-invasive test.

Reading SID would be less reliable because it is one-time
programmable and theoretically may be set to zero on some boards.

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
2017-02-28 21:10:44 +02:00
Icenowy Zheng
463cd64cbd fel: workaround H3 SID issue
H3 SID controller has some bug, that makes the initial value at
0x01c14200 wrong.

This commit workarounds this bug by reading them with register access
first.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
Reviewed-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-12-28 13:30:09 +01:00
Bernhard Nortmann
5c501c5bb8 soc_info: Split sid_addr into sid_base + sid_offset
This is a preparatory step. Instead of using memory-based access,
we might want to retrieve SID keys (e-fuses) via SID registers.
For this, it's convenient if the plain base address is available.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-12-28 13:29:47 +01:00
Icenowy Zheng
8361dac255 fel: Add SOC ID, SRAM info and SID address for V3s
The V3s SoC looks like A10/13/20 in SRAM mapping and SID address.

Add support for it.

Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz>
2016-12-28 17:45:03 +08:00
Bernhard Nortmann
445b1747e5 soc_info: Iterate over soc_info_table with pointer, not by index
Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-12-01 16:24:07 +01:00
Bernhard Nortmann
dfc93db131 fel_lib: Add a human-readable SoC name field to the device handle
open_fel_device() will automatically provide this member field,
based on the SoC ID from FEL/BROM version data. The field will
either receive a human-readable identifier, or the ID in 4-digit
hexadecimal representation (for unknown SoCs).

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-29 14:45:36 +01:00
Chen-Yu Tsai
4c4111034f fel: Add SID register address for A80
The SID block in the A80 is at 0x01c0e000, with the e-fuses we care
about at offset 0x200 within the block.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2016-11-29 13:47:39 +01:00
Chen-Yu Tsai
bbfcf117bb fel: Add SOC ID, SRAM info and SID address for R40
The R40 is marketed as the successor to the A20. The SRAM layout is the
same as the A20, but there doesn't seem to be a secure SRAM block.

The SID block is at a completely different address. The layout is the
same as the newer SoCs, with the e-fuses at an offset of 0x200.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
2016-11-29 15:21:17 +08:00
Bernhard Nortmann
93a26d58ad uart0-helloworld: Refactor SoC detection
Besides having fewer lines of code, the #define macros should
also prevent users from accidentally using these names without
braces (i.e. as function pointers). Instead, this will cause
compiler errors now.

soc_info.c: add "A10s" label in comment for SoC ID 0x1625.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-16 17:37:50 +01:00
Bernhard Nortmann
8640291376 fel: Factor out SoC information (and SRAM buffers) retrieval
While at it, modify the former "sram_info" identifiers
to carry a broader "soc_info" meaning.

Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
2016-11-13 21:33:58 +01:00