summaryrefslogtreecommitdiff
path: root/arch/arm/include/asm/arch-sunxi
AgeCommit message (Collapse)Author
2026-03-17sunxi: a133: dram: Align parameters terminology with AllwinnerPaul Kocialkowski
There is a mistmatch between Allwinner's dram_para BSP definitions and the parameters names in mainline u-boot for TPR1-3. What we call TPR1 is actually MR22 while TPR2 is TPR0 and TPR3 is TPR1. MR22 does get written to the corresponding register. This only concerns LPDDR4 support. Introduce a new Kconfig entry for MR22 and proceed with the rename. Update the only config currently using it. See the list of parameters from the Allwinner BSP at the end of: https://linux-sunxi.org/A133/DRAMC Note that the H616/H6 code is coherent with this new TPR0 definition (and does not use TPR1 and MR22). Signed-off-by: Paul Kocialkowski <[email protected]> Sponsored-by: MEC Electronics GmbH <https://www.mec.at/> Acked-by: Jernej Skrabec <[email protected]>
2026-02-03sunxi: clock: H6: add NAND controller clock registersRichard Genoud
Add missing NAND controller-related clock registers The NAND controller on H6/H616 uses one clock for its internal logic (NAND0_CLK) and one clock for ECC engine (NAND1_CLK) in addition to AHB and MBUS clocks. As NAND{0,1}_CLKs and MBUS_GATE are missing, add them. The bit locations are from H616/H6 User Manual. Signed-off-by: Richard Genoud <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2026-02-03mtd: rawnand: sunxi: remove usage of struct sunxi_ccm_regRichard Genoud
The sunxi_ccm_reg is legacy, drop its usage from nand related code For that, CCU_NAND0_CLK_CFG and CCU_AHB_GATE1 are added to the clock files when missing. And clock code in sunxi_nand{,_spl}.c and board.c are changed to use the new scheme. Moreover, drop AHB_DIV_1 in favor of the more readable CCM_NAND_CTRL_M/N Suggested-by: Andre Przywara <[email protected]> Signed-off-by: Richard Genoud <[email protected]> Signed-off-by: Michael Trimarchi <[email protected]>
2026-01-25sunxi: dram: detect non-power-of-2 sized DRAM chipsAndre Przywara
Some boards feature an "odd" DRAM size, where the total RAM is 1.5GB or 3GB. Our existing DRAM size detection routines can only detect power-of-2 sized configuration, and on those boards the DRAM size is overestimated, so this typically breaks the boot quite early. There doesn't seem to be an easy explicit way to detect those odd-sized chips, but we can test whether the later part of the memory behaves like memory, by verifying that a written pattern can be read back. Experiments show that there is no aliasing effect here, as all locations in the unimplemented range always return some fixed pattern, and cannot be changed. Also so far all those boards use a factor of 3 of some lower power-of-2 number, or 3/4th of some higher number. The size detection routine discovers the higher number, so we can check for some memory cells beyond 75% of the detected size to be legit. Add a routine the inverts all bits at a given location in memory, and reads that back to prove that the new value was stored. Then test the memory cell at exactly 3/4th of the detected size, and cap the size of the memory to 75% when this test fails. For good measure also make sure that memory just below the assumed memory end really works. This enables boards which ship with such odd memory sizes. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]>
2025-07-27sunxi: A523: add DRAM initialisation routineJernej Skrabec
DRAM init code, as per reverse engineering and matching against previous SoCs. As usual no real documentation, and the DRAM controller is the usual mixture of close-to-previous IP and new inventions. This version supports LPDDR4 for now only, as seen on the early boards. This needs improvements, but it can be done later. Signed-off-by: Jernej Skrabec <[email protected]> Signed-off-by: Andre Przywara <[email protected]>
2025-07-27sunxi: sun50i_h6: add A523 SPL clock setup codeJernej Skrabec
This adds the early A523 clock setup code, for the basic peripheral PLL and the basic bus clocks (APB/AHB). This is quite close to the existing H6 and H616 clock code, so this shares the same file. A few bits and bobs are different, though, so filter for the A523 in a few occasions. Signed-off-by: Jernej Skrabec <[email protected]> Signed-off-by: Andre Przywara <[email protected]>
2025-07-27sunxi: update cpu_sunxi_ncat2.hAndre Przywara
The cpu_sunxi_ncat2.h header file contains addresses of some peripherals that are needed for the SPL, for chips that belong to the "NCAT2" generation. The Allwinner A523 is a member of this group, but a few addresses differ, and we need a few more addresses, for playing with the core reset, for instance. Add the new addresses needed for the A523 and guard existing definitions that conflict with that new chip. Signed-off-by: Andre Przywara <[email protected]>
2025-07-27sunxi: spl: add support for Allwinner A523 watchdogAndre Przywara
The watchdog in the Allwinner A523 SoC differs a bit from the one in the previous SoCs: it lives in a separate register frame, so no longer inside some timer device, and it manages to shuffle around some registers a bit. But it also conveniently adds a direct reset functionality, so we don't need to use a dummy timeout period. Avoid introducing a new MMIO register frame C struct, but just define the one needed register offset as a macro. Then just trigger this new direct reset functionality in the A523 specific reset_cpu() implementation. Signed-off-by: Andre Przywara <[email protected]>
2025-07-27sunxi: clock: H6: add A523 CPU PLL supportAndre Przywara
The Allwinner A523 features 8 CPU cores, organised in two clusters, both driven by separate PLLs. Also there is the DSU PLL, which clocks the hardware that connects the cores to the rest of the system. And while the PLL registers itself are very similar, they are located in a separate register frame, outside the main CCU, and also the register controlling the CPU clock source (mux) is different. Provide a separate function that reparents the two clusters and the DSU, while their PLLs are programmed. For the actual PLL programming, we rely on the existing shared routine. The selection between the new A523 routine and the existing code is made with C if statements, but since the choice is effectively made at compile time already, the compiler optimises away the other code paths, leaving just the one required function in. Signed-off-by: Andre Przywara <[email protected]>
2025-07-27sunxi: clock: H6: factor out clock_set_pll()Andre Przywara
The SPL initial clock setup code for the Allwinner H6 and H616 SoCs uses a simple CPU PLL setup routine, which programs all register bits at once, then waits for the LOCK bit to clear. The manual suggests to follow a certain procedure for bringing up any PLLs, which involves several register writes, one at a time, and some delays. Also the H616 and the new A523 require some tiny changes in this sequence, and the different SoCs also feature some extra bits here and there, which we should not just clear. So factor out the PLL setup routine, and make it follow the manual's suggestion. This will read the PLL register at the beginning, then tweak the bits we need to manipulate, and writes the register several times on the way. This allows to cover the specific bits for different SoCs. Besides improving the reliability of the PLL setup, this helps with the A523, which requires *three* CPU PLLs to be programmed. Signed-off-by: Andre Przywara <[email protected]>
2025-07-27sunxi: clock: H6: unify PLL control bit definitionsAndre Przywara
The Allwinner PLLs share most of their control bits, they differ mostly in the factors and dividers. Drop the PLL specific definition of those common bits, and use one shared macro, for all PLLs. This requires changing the users in the SPL clock and DRAM code. Signed-off-by: Andre Przywara <[email protected]>
2025-06-24sunxi: add support for the Allwinner A100/A133 SoCAndre Przywara
The Allwinner A100 SoC has been around for a while, mostly on cheap tablets, but didn't generate much interest in the community so far. There were some efforts by two Allwinner employees in 2020, which led to basic upstream Linux support for that SoC, although this momentum dried up pretty quickly, leaving a lot of peripherals unsupported. The A100 was silently replaced with the seemingly identical Allwinner A133, which is reportedly a better bin of the A100. So far we assume that both are compatible from a software perspective. There are some more devices with the A133 out there now, so people are working on filling the gaps, and adding U-Boot (and TF-A) support. Based on the just added pinctrl, clock and DRAM support, this adds the missing bits, mostly addresses and values for the SPL. The A133 seems to be an predecessor to the H6, so we can share a lot of code with that (and the H616 code), and just need to adjust some details. Signed-off-by: Andre Przywara <[email protected]>
2025-06-24sunxi: A133: add DRAM init codeCody Eksal
This adds preliminary support for the DRAM controller in the Allwinner A100/A133 SoCs. This is work in progress, and has rough edges, but works on at least three different boards. It contains support for DDR4 and LPDDR4. Signed-off-by: Cody Eksal <[email protected]> [Andre: formatting fixes, adapt to mainline, drop unused parameters, remove struct struct sunxi_mctl_com_reg, hardcode MR registers, switch to mctl_check_pattern(), remove simple DRAM check] Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: clock: H6: remove struct sunxi_prcm_regAndre Przywara
With the SPL clock code and the DRAM init routine we converted all users of the H6 class "struct sunxi_prcm_reg" over to use #define'd register offsets now. Drop the whole definition of this struct now, since it's not needed anymore, for all H6 and H616 boards. This removes the entire fragile and questionable definition, and allows new SoCs to share the code more easily. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: H6/H616: dram: remove usage of struct sunxi_prcm_regAndre Przywara
The Allwinner H6 and H616 DRAM initialisation code uses a complex C struct, modelling the PRCM clock register frame. For those SoCs, this struct contains 20 registers, but the DRAM code only uses two of them. Since we want to get rid of this struct, drop the usage of the struct in the H6 and H616 DRAM code, by using #define'd register names and their offset, and then adding those names to the base pointer. This removes one more user of the PRCM clock register struct. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: clock: H6: drop usage of struct sunxi_prcm_regAndre Przywara
U-Boot drivers often revert to using C structures for modelling hardware register frames. This creates some problems: - A "struct" is a C language construct to group several variables together. The details of the layout of this struct are partly subject to the compiler's discretion (padding and alignment). - The "packed" attribute would force a certain layout, but we are not using it. - The actual source of information from the data sheet is the register offset. Here we create an artificial struct, carefully tuning the layout (with a lot of reserved members) to match that offset. To help with correctness, we put the desired information as a *comment*, though this is purely for the human reader, and has no effect on the generated layout. This sounds all very backwards. - Using a struct suggests we can assign a pointer and then access the register content via the members. But this is not the case, instead every MMIO register access must go through specific accessor functions, to meet the ordering and access size guarantees the hardware requires. - We share those structs in code shared across multiple SoC families, though most SoCs define their own version of the struct. Members must match in their name, across every SoC, otherwise compilation will fail. We work around this with even more #ifdefs in the shared code. - Some SoCs have an *almost* identical layout, but differ in a few registers. This requires hard to maintain #ifdef's in the struct definition. - Some of the register frames are huge: the H6 CCU device defines 127 registers. We use 15 of them. Still the whole frame would need to be described, which is very tedious, but for no reason. - Adding a new SoC often forces people to decide whether to share an existing struct, or to create a new copy. For some cases (say like 80% similarity) this works out badly either way. The Linux kernel heavily frowns upon those register structs, and instead uses a much simpler solution: #define REG_NAME <offset> This easily maps to the actual information from the data sheet, and can much simpler be shared across multiple SoCs, as it allows to have all SoC versions visible, so we can use C "if" statements instead of #ifdef's. Also it requires to just define the registers we need, and we can use alternative locations for some registers much more easily. Drop the usage of "struct sunxi_prcm_reg" in the H6 SPL clock code, by defining the respective register names and their offsets, then adding them to the base pointer. We cannot drop the struct definition quite yet, as it's also used in other drivers, still. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: clock: H6: remove struct sunxi_ccm_regAndre Przywara
With the SPL clock code, the MMC driver, and the DRAM init routine we converted all users of the H6 class "struct sunxi_ccm_reg" over to use #define'd register offsets now. Drop the whole definition of this struct now, since it's not needed anymore, for all H6 and H616 boards. This removes the entire fragile and questionable definition, and allows new SoCs to share the code more easily. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: H616: dram: remove usage of struct sunxi_ccm_regAndre Przywara
The Allwinner H616 DRAM initialisation code uses a complex C struct, modelling the clock device's register frame. For this SoC, the struct contains 127 registers, but the DRAM code only uses four of them. Since we want to get rid of this struct, drop the usage of the struct in the H616 DRAM code, by using #define'd register names and their offset, and then adding those names to the base pointer. This removes one more user of the clock register struct. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: mmc: remove usage of struct sunxi_ccm_regAndre Przywara
The Allwinner MMC code uses a complex C struct, modelling the clock device's register frame. We rely on sharing the member names across all Allwinner SoCs, which is fragile. Drop the usage of the struct in the MMC code, by using #define'd register names and their offset, and then adding those names to the base pointer. This requires to define those offsets for all SoCs, but since we only use between four and six clock registers in the MMC code, this is easily done. This removes one common user of the clock register struct. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: clock: H6: drop usage of struct sunxi_ccm_regAndre Przywara
U-Boot drivers often revert to using C structures for modelling hardware register frames. This creates some problems: - A "struct" is a C language construct to group several variables together. The details of the layout of this struct are partly subject to the compiler's discretion (padding and alignment). - The "packed" attribute would force a certain layout, but we are not using it. - The actual source of information from the data sheet is the register offset. Here we create an artificial struct, carefully tuning the layout (with a lot of reserved members) to match that offset. To help with correctness, we put the desired information as a *comment*, though this is purely for the human reader, and has no effect on the generated layout. This sounds all very backwards. - Using a struct suggests we can assign a pointer and then access the register content via the members. But this is not the case, instead every MMIO register access must go through specific accessor functions, to meet the ordering and access size guarantees the hardware requires. - We share those structs in code shared across multiple SoC families, though most SoCs define their own version of the struct. Members must match in their name, across every SoC, otherwise compilation will fail. We work around this with even more #ifdefs in the shared code. - Some SoCs have an *almost* identical layout, but differ in a few registers. This requires hard to maintain #ifdef's in the struct definition. - Some of the register frames are huge: the H6 CCU device defines 127 registers. We use 15 of them. Still the whole frame would need to be described, which is very tedious, but for no reason. - Adding a new SoC often forces people to decide whether to share an existing struct, or to create a new copy. For some cases (say like 80% similarity) this works out badly either way. The Linux kernel heavily frowns upon those register structs, and instead uses a much simpler solution: #define REG_NAME <offset> This easily maps to the actual information from the data sheet, and can much simpler be shared across multiple SoCs, as it allows to have all SoC versions visible, so we can use C "if" statements instead of #ifdef's. Also it requires to just define the registers we need, and we can use alternative locations for some registers much more easily. Drop the usage of "struct sunxi_ccm_reg" in the H6 SPL clock code, by defining the respective register names and their offsets, then adding them to the base pointer. We cannot drop the struct definition quite yet, as it's also used in other drivers, still. Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: armv8: FEL: save and restore SP_IRQAndre Przywara
Thanks for Jernej's JTAG debugging effort, it turns out that the BROM expects SP_IRQ to be saved and restored, when we want to enter back into FEL after the SPL's AArch64 stint. Save and restore SP_IRQ as part of the FEL state handling. The banked MRS/MSR access to SP_IRQ, without actually being in IRQ mode, was introduced with the ARMv7 virtualisation extensions. The Arm Cortex-A8 cores used in the A10/A13s or older F1C100s SoCs would not support that, but this code here is purely in the ARMv8/AArch64 code path, so it's safe to use unconditionally. Reported-by: Jernej Skrabec <[email protected]> Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]>
2025-04-28sunxi: armv8: FEL: save and restore GICv3 registersAndre Przywara
To be able to return to the BootROM FEL USB debug code, we must restore the core's state as accurately as possible after the SPL has been run. Since the BootROM runs in AArch32, but the SPL uses AArch64, this requires a core reset, which clears the core's state. So far we were saving and restoring the required registers like SCTLR and VBAR, but could ignore the interrupt controller's state (GICC), since that lives in MMIO registers, unaffected by a core reset. Newer Allwinner SoCs now feature a GICv3 interrupt controller, which keeps some GIC state in architected system registers, and those are cleared when we switch back to AArch32. To enable FEL operation on the Allwinner A523 SoC, Add AArch32 assembly code to save and restore the ICC_PMR and ICC_IGRPEN1 system registers. The other GICv3 sysregs are either not relevant for the BROM operation, or haven't been changed from their reset defaults by the BROM anyway. This enables FEL operation on the Allwinner A523 family of SoCs. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]>
2025-04-28sunxi: h6/h616: Reuse common DRAM infrastructureJernej Skrabec
H616 rank and size detection code is superior to the H6. Nevertheless, they are structurally the same. Split functions from H616 into new file and reuse them in H6 DRAM driver too. This should also fix some bugs for H6 too, like incorrect DRAM size detection. Signed-off-by: Jernej Skrabec <[email protected]> [Andre: back out panic if test fails to allow 2^11 columns] Reviewed-by: Andre Przywara <[email protected]> Signed-off-by: Andre Przywara <[email protected]>
2025-04-28sunxi: h6: dram: split dram_para structJernej Skrabec
This change is same as in commit 78aa00c38e86 ("sunxi: H616: dram: split struct dram_para"), but for H6. This is needed in order to extract common code between H6 and H616 later. Signed-off-by: Jernej Skrabec <[email protected]> Reviewed-by: Andre Przywara <[email protected]>
2025-04-26sunxi: H6: Remove useless DRAM timings parameterJernej Skrabec
This is just cosmetic fix for later easier rework. Signed-off-by: Jernej Skrabec <[email protected]> Reviewed-by: Andre Przywara <[email protected]>
2025-03-27sunxi: arm64: boot0.h: move fel_stash_addr variable to the frontAndre Przywara
To be able to return to the BootROM when booting via the FEL USB protocol, we need to save the CPU state very early, which we need to do in the embedded AArch32 code. At the moment the pointer to the buffer for that state is located *after* the code, which makes the PC relative code fragile: adding or removing instructions will change the distance to that pointer variable. The "new" Allwinner A523 SoC requires more state to be saved (GICv3 system registers), but we must do that *only* on that SoC. Conditional compilation sounds like the easiest solution, but would mean that the distance to that pointer would change. Solve this rather easily by moving the pointer to the *front* of the code: we load that pointer in the first instructions, so the distance would always stay the same. Later in the code we won't need PC relative addressing anymore, so this code can grow or shrink easily, for instance due to conditional compilation. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]>
2025-01-22sunxi: clock: improve grouping of default clock register valuesAndre Przywara
With each new SoC added to the clock_sun50i_h6.h header file, we add a list of default values for the bus clock registers. This list gets a bit hard to read, as the spacing between the lines looks confusing. Tighten the lines by removing empty lines, to make it more obvious which values belong together. Also remove those comments that were more or less duplicating the next code line, and didn't add any information. This makes it easier to find existing values and to add support for new SoCs. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]>
2024-10-11arch: Use CONFIG_XPL_BUILD instead of CONFIG_SPL_BUILDSimon Glass
Use the new symbol to refer to any 'SPL' build, including TPL and VPL Signed-off-by: Simon Glass <[email protected]>
2024-07-15arm: include: sunxi: Remove duplicate newlinesMarek Vasut
Drop all duplicate newlines. No functional change. Signed-off-by: Marek Vasut <[email protected]>
2024-05-20Restore patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"Tom Rini
As part of bringing the master branch back in to next, we need to allow for all of these changes to exist here. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-19Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""Tom Rini
When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay Ethernet"' I failed to notice that b4 noticed it was based on next and so took that as the base commit and merged that part of next to master. This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35. Reported-by: Jonas Karlman <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2024-05-07arm: sunxi: Add missing <linux/types.h>Tom Rini
These files have many "Linux" style types in them, add <linux/types.h> Signed-off-by: Tom Rini <[email protected]>
2024-04-22sunxi: sun9i: make more clock functions SPL onlyAndre Przywara
In clock_sun9i.c, responsible for (mostly early) clock setup on the Allwinner A80 SoC, many functions are only needed by the SPL, and are thus already guarded by CONFIG_SPL_BUILD. Over the years drivers like for the UART or I2C were converted to DM, and they care about clock setup themselves now, by using a proper DM clock driver. This means those devices need the clock setup functions here for the SPL only. Move some functions around, to group all SPL-only function within one #ifdef guard. Some functions were exported, but never used outside of this file, so remove their prototypes from the header file and mark them as static. This avoids unnecessary code in U-Boot proper and helps further refactoring. Add some comments on the way to help understanding of the file. Signed-off-by: Andre Przywara <[email protected]>
2024-04-22sunxi: move #ifdef guards around tzpc_init() to header fileAndre Przywara
Some later 32-bit SoCs require some setup of the Secure Peripherals Controller, which is handled in tzpc_init(). At the moment this is guarded in board.c by some #ifdefs selecting the SoCs that need it. Move those #ifdef guards into the header file, providing an empty stub function for all other SoCs, so that the #ifdefs can be removed from the .c file, to improve readability. Signed-off-by: Andre Przywara <[email protected]>
2024-03-05sunxi: reorganize mctl_mem_matches_* functionsAndrey Skvortsov
mctl_mem_matches and mctl_mem_matches_base identical functions. To avoid code duplication move them to dram_helpers and make mctl_mem_matches use generic mctl_mem_matches_base. Signed-off-by: Andrey Skvortsov <[email protected]> Reviewed-by: Andre Przywara <[email protected]>
2024-01-29sunxi: sun9i: remove unneeded base addresses from headerAndre Przywara
The cpu_sun9i.h header file defined the base addresses for quite some peripherals of the Allwinner A80 CPU, even though we now only use a fraction of that. Most of the addresses are now either read from the DT, or were never used in U-Boot in the first place. Removed the ones that are not used in the whole of the U-Boot source. to make it clear that this file only contains addresses that are needed for the SPL operation. Signed-off-by: Andre Przywara <[email protected]>
2024-01-29sunxi: sun4i: remove unneeded base addresses from headerAndre Przywara
The cpu_sun4i.h header file defined the base addresses for quite some peripherals of earlier Allwinner CPUs, even though we now only use a fraction of that. Most of the addresses are now either read from the DT, or were never used in U-Boot in the first place. Removed the ones that are not used in the whole of the U-Boot source. to make it clear that this file only contains addresses that are needed for the SPL operation. Signed-off-by: Andre Przywara <[email protected]>
2024-01-29sunxi: sun50i-h6: remove unneeded base addresses from headerAndre Przywara
The cpu_sun50i_h6.h header file defined the base addresses for quite some peripherals of the Allwinner H6 and related CPUs, even though we now only use a fraction of that. Most of the addresses are now either read from the DT, or were never used in U-Boot in the first place. Removed the ones that are not used in the whole of the U-Boot source. to make it clear that this file only contains addresses that are needed for the SPL operation. Signed-off-by: Andre Przywara <[email protected]>
2023-11-12sunxi: H616: add LPDDR4 DRAM supportMikhail Kalashnikov
The H616 SoC family has support for several types of DRAM: DDR3, LPDDR3, DDR4 and LPDDR4. At the moment, the driver only supports DDR3 and LPDDR3 memory. Let's extend the driver to support the LPDDR4 memory. This type of memory widely used in device with T507(-H) SoC and new orangepi zero3 with H618. The compatibility with T507 is not yet complete, because there is difference in the phy_init array. The LPDDR4-2133 timings correspond to DRAM Rayson RS1G32LO4D2BDS-53BT found on the NOR SPI from the Orangepi Zero 3 4GB. Signed-off-by: Mikhail Kalashnikov <[email protected]> Tested-by: Piotr Oniszczuk <[email protected]> Reviewed-by: Jernej Skrabec <[email protected]> Acked-by: Andre Przywara <[email protected]>
2023-11-12sunxi: mmc: Move header to the driver directorySamuel Holland
The MMC controller driver is (and ought to be) the only user of these register definitions. Put them in a header next to the driver to remove the dependency on a specific ARM platform's headers. Due to the sunxi_mmc_init() prototype, the file was not renamed. None of the register definitions were changed. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Jaehoon Chung <[email protected]>
2023-10-22sunxi: psci: stop modeling register layout with C structsSam Edwards
Since the sunxi support nowadays generally prefers #defined register offsets instead of modeling register layouts using C structs, now is a good time to do this for PSCI as well. This patch moves away from using the structs `sunxi_cpucfg_reg` and `sunxi_prcm_reg` in psci.c. The former struct and its associated header file existed only to support PSCI code, so also delete them altogether. Signed-off-by: Sam Edwards <[email protected]> Reviewed-by: Andre Przywara <[email protected]>
2023-10-22sunxi: refactor serial base addresses to avoid asm/arch/cpu.hAndre Przywara
At the moment we have each SoC's memory map defined in its own cpu.h, which is included in include/configs/sunxi_common.h. This will be a problem with the introduction of Allwinner RISC-V support. Remove the inclusion of that header file from the common config header, instead move the required serial base addresses (for the SPL) into a separate header file. Then include the original cpu.h file only where we really need it, which is only under arch/arm now. This disentangles the architecture specific header files from the generic code. Signed-off-by: Andre Przywara <[email protected]>
2023-10-22sunxi: add Allwinner R528/T113 SoC supportAndre Przywara
This adds the remaining code bits to teach U-Boot about Allwinner's newest SoC generation. This was introduced with the RISC-V based Allwinner D1 SoC, which actually shares a die with the ARM cores versions called R528 (BGA, without DRAM) and T113s (QFP, with embedded DRAM). This adds the new Kconfig stanza, using the two newly introduced symbols for the new SoC generation and pincontroller. It also adds the new symbols to the relavent code places, to set all the hardcoded bits directly. We need one DT override: The ARM core version of the DT specifies the CPUX watchdog as "reserved", which means it won't be recognised by U-Boot. Override this in our generic sunxi-u-boot.dtsi, to let U-Boot pick up this watchdog, so that the generic reset driver will work. Signed-off-by: Andre Przywara <[email protected]>
2023-10-22sunxi: clock: support D1/R528 PLL6 clockAndre Przywara
The PLL_PERIPH0 clock changed a bit in the D1/R528/T113s SoCs: there is new P0 divider at bits [18:16], and the M divider is 1. Add code to support this version of "PLL6". Signed-off-by: Andre Przywara <[email protected]>
2023-10-22sunxi: clock: D1/R528: Enable PLL LDO during PLL1 setupAndre Przywara
The D1/R528/T113s SoCs introduce a new "LDO enable" bit in the CPUX_PLL. Just enable that when we program that PLL. Signed-off-by: Andre Przywara <[email protected]>
2023-10-22sunxi: introduce NCAT2 generation modelAndre Przywara
Allwinner seems to typically stick to a common MMIO memory map for several SoCs, but from time to time does some breaking changes, which also introduce new generations of some peripherals. The last time this happened with the H6, which apart from re-organising the base addresses also changed the clock controller significantly. We added a CONFIG_SUN50I_GEN_H6 symbol back then to mark SoCs sharing those traits. Now the Allwinner D1 changes the memory map again, and also extends the pincontroller, among other peripherals. To mark this generation of SoCs, add a CONFIG_SUNXI_GEN_NCAT2 symbol, this name is reportedly used in the Allwinner BSP code, and prevents us from inventing our own name. Add this new symbol to some guards that were already checking for the H6 generation, since many features are shared between the two (like the renovated clock controller). This paves the way to introduce a first user of this generation. Signed-off-by: Andre Przywara <[email protected]> Tested-by: Samuel Holland <[email protected]>
2023-10-22pinctrl: sunxi: move PIO_BASE into sunxi_gpio.hAndre Przywara
On the Allwinner platform we were describing a quite comprehensive memory map in a per-SoC header unser arch/arm. In the old days that was used by every driver, but nowadays it should only be needed by SPL drivers (not using the DT). Many addresses in there were never used, and some are not needed anymore. To avoid a dependency on CPU specific headers in an arch specific directory, move the definition of the pinctroller MMIO base address into the sunxi_gpio.h header, because the SPL routines for GPIO should be the only one needing this address. This is a first step towards getting rid of cpu_sun[x]i.h completely, and allows to remove the inclusion of that file from the sunxi_gpio.h header. Signed-off-by: Andre Przywara <[email protected]>
2023-10-22pinctrl: sunxi: remove GPIO_EXTRA_HEADERAndre Przywara
U-Boot's generic GPIO_EXTRA_HEADER is a convenience symbol to allow code to more easily include platform specific GPIO headers. This should not be needed in a DM world anymore, since the generic GPIO framework handles that nicely. For Allwinner boards we still need to deal with non-DM GPIO in the SPL, but this should become the exception, not the rule. Make this more obvious by removing the definition of GPIO_EXTRA_HEADER, and just force every legacy user of platform specific GPIO to include the new sunxi_gpio.h header explicitly. Everyone doing so should feel ashamed and should find a way to avoid it from now on. Signed-off-by: Andre Przywara <[email protected]> Tested-by: Samuel Holland <[email protected]>
2023-10-22pinctrl: sunxi: remove struct sunxi_gpioAndre Przywara
So far every Allwinner SoC used the same basic pincontroller/GPIO register frame, and just differed by the number of implemented banks and pins, plus some special functionality from time to time. However the D1 and successors use a slightly different pinctrl register layout. Use that opportunity to drop "struct sunxi_gpio", that described that MMIO frame in a C struct. That approach is somewhat frowned upon in the Linux world and rarely used there, though still popular with U-Boot. Switching from a C struct to a "base address plus offset" approach allows to switch between the two models more dynamically, without reverting to preprocessor macros and #ifdef's. Model the pinctrl MMIO register frame in the usual "base address + offset" way, and replace a hard-to-parse CPP macro with a more readable static function. All the users get converted over. There are no functional changes at this point, it just prepares the stages for the D1 and friends. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]>
2023-10-22pinctrl: sunxi: move pinctrl codeAndre Przywara
Move the existing sunxi-specific low level pinctrl routines from arch/arm/mach-sunxi into the existing GPIO code under drivers/gpio, so that the common code can be shared outside of arch/arm. This also takes the opportunity to move some definitions from our header file into the driver C file, as they are private to the driver and are not needed elsewhere. Signed-off-by: Andre Przywara <[email protected]> Reviewed-by: Samuel Holland <[email protected]> Tested-by: Samuel Holland <[email protected]>