Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Oct 23, 2023
  2. Oct 22, 2023
    • Andre Przywara's avatar
      sunxi: add MangoPi MQ-R board support · fa066df6
      Andre Przywara authored
      
      The MangoPi MQ-R board uses an Allwinner T113s Soc (with 128MB of
      embedded DRAM), support for which was just added to the code.
      
      Since the devicetree was already synced from the latest Linux kernel
      tree, all we need is a _defconfig file to add support for the board.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      fa066df6
    • Sam Edwards's avatar
      sunxi: psci: implement PSCI on R528 · 352ba256
      Sam Edwards authored
      
      This patch adds the necessary code to make nonsec booting and PSCI
      secondary core management functional on the R528/T113.
      
      Signed-off-by: default avatarSam Edwards <CFSworks@gmail.com>
      Tested-by: default avatarMaksim Kiselev <bigunclemax@gmail.com>
      Tested-by: default avatarKevin Amadiva <kevin.amadiva@mec.at>
      Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
      352ba256
    • Sam Edwards's avatar
      sunxi: psci: stop modeling register layout with C structs · b1fbc20e
      Sam Edwards authored
      
      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: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
      b1fbc20e
    • Sam Edwards's avatar
      sunxi: psci: refactor register access to separate functions · 3f31c6f1
      Sam Edwards authored
      
      This is to prepare for R528, which does not have the typical
      "CPUCFG" block; it has a "CPUX" block which provides these
      same functions but is organized differently.
      
      Moving the hardware-access bits to their own functions separates the
      logic from the hardware so we can reuse the same logic.
      
      Signed-off-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
      3f31c6f1
    • Sam Edwards's avatar
      sunxi: psci: clean away preprocessor macros · f9670d7b
      Sam Edwards authored
      
      This patch restructures psci.c to get away from the "many different
      function definitions switched by #ifdef" paradigm to the preferred style
      of having a single function definition with `if (IS_ENABLED(...))` to
      make the optimizer include only the appropriate function bodies instead.
      
      There are no functional changes here.
      
      Signed-off-by: default avatarSam Edwards <CFSworks@gmail.com>
      Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
      f9670d7b
    • Andre Przywara's avatar
      sunxi: refactor serial base addresses to avoid asm/arch/cpu.h · beeace9b
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      beeace9b
    • Okhunjon Sobirjonov's avatar
      sunxi: R528: add SMHC2 pin pull ups support · 5b7c58fb
      Okhunjon Sobirjonov authored
      
      Add support for eMMC (SMHC2) pin pull ups for R528 boards.
      
      The D1 and T113s (and even R329) SoCs do not support 8-bit eMMC anymore,
      so it's just four data pins to cover here.
      
      Signed-off-by: default avatarOkhunjon Sobirjonov <Okhunjon.Sobirjonov@Mec-electronics.com>
      Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
      [Andre: adjust commit message]
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      5b7c58fb
    • Andre Przywara's avatar
      sunxi: add Allwinner R528/T113 SoC support · 95168d77
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      95168d77
    • Andre Przywara's avatar
      sunxi: add R528/T113-s3/D1(s) DRAM initialisation code · 124289bd
      Andre Przywara authored
      
      The Allwinner R528/T113-s/D1/D1s SoCs all share the same die, so use the
      same DRAM initialisation code.
      Make use of prior art here and lift some code from awboot[1], which
      carried init code based on earlier decompilation efforts, but with a
      GPL2 license tag.
      This code has been heavily reworked and cleaned up, to match previous
      DRAM routines for other SoCs, and also to be closer to U-Boot's coding
      style and support routines.
      The actual DRAM chip timing parameters are included in the main file,
      since they cover all DRAM types, and are protected by a new Kconfig
      CONFIG_SUNXI_DRAM_TYPE symbol, which allows the compiler to pick only
      the relevant settings, at build time.
      
      The relevant DRAM chips/board specific configuration parameters are
      delivered via Kconfig, so this code here should work for all supported
      SoCs and DRAM chips combinations.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Tested-by: default avatarSam Edwards <CFSworks@gmail.com>
      124289bd
    • Andre Przywara's avatar
      Kconfig: sunxi: prepare for using drivers/ram/sunxi · 8bddb974
      Andre Przywara authored
      
      At the moment all Allwinner DRAM initialisation routines are stored in
      arch/arm/mach-sunxi, even though those "drivers" are just a giant
      collection of writel's, without any architectural dependency.
      
      The R528/T113-s SoC (with ARM cores) and the D1/D1s Soc (with RISC-V
      cores) share the same die, so should share the same DRAM init routines as
      well.
      
      To prepare for this, add a new sunxi directory inside drivers/ram, and
      add some stub entries to prepare for the addition of the share DRAM code
      for those SoCs.
      
      The RISC-V D1(s) SoCs will probably use SPL_DM, so for that SoC this
      would be the right directory anyway.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      8bddb974
    • Andre Przywara's avatar
      sunxi: clock: support D1/R528 PLL6 clock · a94c9c80
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      a94c9c80
    • Andre Przywara's avatar
      sunxi: clock: D1/R528: Enable PLL LDO during PLL1 setup · 39ba4746
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      39ba4746
    • Samuel Holland's avatar
      clk: sunxi: Add support for the D1 CCU · b9a91b98
      Samuel Holland authored
      
      Since the D1 CCU binding is defined, we can add support for its
      gates/resets, following the pattern of the existing drivers.
      
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Acked-by: default avatarSean Anderson <seanga2@gmail.com>
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      b9a91b98
    • Andre Przywara's avatar
      pinctrl: sunxi: add Allwinner D1 pinctrl description · ad9dcb50
      Andre Przywara authored
      
      Apart from using the new pinctrl MMIO register layout, the Allwinner D1
      and related SoCs still need to usual set of mux values hardcoded in
      U-Boot's pinctrl driver.
      Add the values we need so far to this list, so that DM based drivers
      will just work without further ado.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      ad9dcb50
    • Andre Przywara's avatar
      sunxi: introduce NCAT2 generation model · 4a9e89a3
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      Tested-by: default avatarSamuel Holland <samuel@sholland.org>
      4a9e89a3
    • Andre Przywara's avatar
      pinctrl: sunxi: add new D1 pinctrl support · 452369cd
      Andre Przywara authored
      
      For the first time since at least the Allwinner A10 SoCs, the D1 (and
      related cores) use a new pincontroller MMIO register layout, so we
      cannot use our hardcoded, fixed offsets anymore.
      Ideally this would all be handled by devicetree and DM drivers, but for
      the DT-less SPL we still need the legacy interfaces.
      
      Add a new Kconfig symbol to differenciate between the two generations of
      pincontrollers, and just use that to just switch some basic symbols.
      The rest is already abstracted enough, so works out of the box.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarSam Edwards <CFSworks@gmail.com>
      Tested-by: default avatarSam Edwards <CFSworks@gmail.com>
      Tested-by: default avatarSamuel Holland <samuel@sholland.org>
      452369cd
    • Andre Przywara's avatar
      pinctrl: sunxi: move PIO_BASE into sunxi_gpio.h · 1da48c99
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      1da48c99
    • Andre Przywara's avatar
      pinctrl: sunxi: remove GPIO_EXTRA_HEADER · 207ed0a3
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      Tested-by: default avatarSamuel Holland <samuel@sholland.org>
      207ed0a3
    • Andre Przywara's avatar
      pinctrl: sunxi: remove struct sunxi_gpio · 30097ee3
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarSamuel Holland <samuel@sholland.org>
      Tested-by: default avatarSamuel Holland <samuel@sholland.org>
      30097ee3
    • Andre Przywara's avatar
      pinctrl: sunxi: add GPIO in/out wrappers · 316ec7ff
      Andre Przywara authored
      
      So far we were open-coding the pincontroller's GPIO output/input access
      in each function using that.
      
      Provide functions that wrap that nicely, and follow the existing pattern
      (set/get_{bank,}), so users don't need to know about the internals, and
      we can abstract the new D1 pinctrl more easily.
      
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarSamuel Holland <samuel@sholland.org>
      316ec7ff
    • Andre Przywara's avatar
      pinctrl: sunxi: move pinctrl code · 20b78c55
      Andre Przywara authored
      
      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: default avatarAndre Przywara <andre.przywara@arm.com>
      Reviewed-by: default avatarSamuel Holland <samuel@sholland.org>
      Tested-by: default avatarSamuel Holland <samuel@sholland.org>
      20b78c55
Loading