1. 30 Oct, 2018 2 commits
  2. 29 Oct, 2018 4 commits
    • Antonio Nino Diaz's avatar
      plat/arm: Fix MISRA defects in SiP SVC handler · 15b94cc1
      Antonio Nino Diaz authored
      
      
      No functional changes.
      
      Change-Id: I9b9f8d3dfde08d57706ad5450de6ff858a55ac01
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      15b94cc1
    • Soby Mathew's avatar
      FVP: Enable PIE for RESET_TO_BL31=1 · fc922ca8
      Soby Mathew authored
      
      
      This patch enabled PIE for FVP when RESET_TO_BL31=1. The references
      to BL31_BASE are replaced by BL31_START as being a symbol exported by
      the linker, will create a dynamic relocation entry in .rela.dyn and
      hence will be fixed up by dynamic linker at runtime. Also, we disable
      RECLAIM_INIT_CODE when PIE is enabled as the init section overlay
      creates some static relocations which cannot be handled by the
      dynamic linker currently.
      
      Change-Id: I86df1b0a8b2a8bbbe7c3f3c0b9a08c86c2963ec0
      Signed-off-by: default avatarSoby Mathew <soby.mathew@arm.com>
      fc922ca8
    • Soby Mathew's avatar
      plat/arm: Use `mov_imm` macro to load immediate values · bd83b396
      Soby Mathew authored
      
      
      This patch makes use of mov_imm macro where possible to load
      immediate values within ARM platform layer.
      
      Change-Id: I02bc7fbc1fa334c9fccf76fbddf515952f9a1298
      Signed-off-by: default avatarSoby Mathew <soby.mathew@arm.com>
      bd83b396
    • Soby Mathew's avatar
      Add helper to return reference to a symbol · 6a7b3005
      Soby Mathew authored
      
      
      This patch adds a utility function to return
      the address of a symbol. By default, the compiler
      generates adr/adrp instruction pair to return
      the reference and this utility is used to override
      this compiler generated to code and use `ldr`
      instruction.
      
      This is needed for Position Independent Executable
      when it needs to reference a symbol which is constant
      and does not depend on the execute address of the
      binary.
      
      For example, on the FVP, the GICv3 register context is
      stored in a secure carveout (arm_el3_tzc_dram) within
      DDR and does not relocate with the BL image. Now if
      BL31 is executing at a different address other than
      the compiled address, using adrp/adr instructions to
      reference this memory will not work as they generate an
      address that is PC relative. The way to get around this
      problem is to reference it as non-PC relative (i.e
      non-relocatable location) via `ldr` instruction.
      
      Change-Id: I5008a951b007144258121690afb68dc8e12ee6f7
      Signed-off-by: default avatarSoby Mathew <soby.mathew@arm.com>
      6a7b3005
  3. 26 Oct, 2018 5 commits
  4. 25 Oct, 2018 6 commits
    • Antonio Nino Diaz's avatar
      Deprecate weak crash console functions · e74afb65
      Antonio Nino Diaz authored
      
      
      The default behaviour of the plat_crash_console_xxx functions isn't
      obvious to someone that hasn't read all the documentation. As they are
      not mandatory, it is unlikely that the code will be checked when doing a
      platform port, which may mean that some platforms may not have crash
      console support at all.
      
      The idea of this patch is to force platform maintainers to decide how
      the crash console has to behave so that the final behaviour isn't
      unexpected.
      
      Change-Id: I40b2a7b56c5530c1dcd63eace5bd37ae6335056e
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      e74afb65
    • Antonio Nino Diaz's avatar
      rockchip: Use common crash console functions · a9d5a3ff
      Antonio Nino Diaz authored
      
      
      This platform depends on weak functions defined in
      ``plat/common/aarch64/platform_helpers.S`` that are going to be removed.
      
      Change-Id: I5104d091c32271d77ed9690e9dc257c061289def
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      a9d5a3ff
    • Antonio Nino Diaz's avatar
      Add sample crash console functions · 6c9ada31
      Antonio Nino Diaz authored
      
      
      Platforms that wish to use the sample functions have to add the file to
      their Makefile. It is not included by default.
      
      Change-Id: I713617bb58dc218967199248f68da86241d7ec40
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      6c9ada31
    • Antonio Nino Diaz's avatar
      plat/arm: Make crash console functions strong · c02c69f8
      Antonio Nino Diaz authored
      
      
      In Arm platforms the crash console doesn't print anything if the crash
      happens early enough. This happens in all images, not only BL1. The
      reason is that they the files ``plat/common/aarch64/platform_helpers.S``
      and ``plat/arm/common/aarch64/arm_helpers.S``, and the crash console
      functions are defined as weak in both files. In practice, the linker
      can pick the one in ``plat/common``, which simply switches the multi
      console to crash mode when it wants to initialize the crash console.
      In the case of Arm platforms, there are no console drivers registered
      at that point, so nothing is printed.
      
      This patch makes the functions in plat/arm strong so that they override
      the weak functions in plat/common.
      
      Change-Id: Id358db7d2567d7df0951790a695636cf6c9ac57f
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      c02c69f8
    • Antonio Nino Diaz's avatar
      Add plat_crash_console_flush to platforms without it · 9c675b37
      Antonio Nino Diaz authored
      
      
      Even though at this point plat_crash_console_flush is optional, it will
      stop being optional in a following patch.
      
      The console driver of warp7 doesn't support flush, so the implementation
      is a placeholder.
      
      TI had ``plat_crash_console_init`` and ``plat_crash_console_putc``, but
      they weren't global so they weren't actually used. Also, they were
      calling the wrong functions.
      
      imx8_helpers.S only has placeholders for all of the functions.
      
      Change-Id: I8d17bbf37c7dad74e134c61ceb92acb9af497718
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      9c675b37
    • Antonio Nino Diaz's avatar
      zynqmp: Remove dependency on arm_helpers.S · bde25ae2
      Antonio Nino Diaz authored
      
      
      Non-Arm platforms shouldn't use Arm platform code. This patch copies the
      implementation of the functions in arm_helpers.S to zynqmp_helpers.S to
      remove this dependency of zynqmp on Arm platforms.
      
      Change-Id: Ia85f303c4c63bcf0ffa57c7f3ef9d88376729b6b
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      bde25ae2
  5. 24 Oct, 2018 1 commit
    • Antonio Nino Diaz's avatar
      rpi3: Add mem reserve region to DTB if present · 5341b42e
      Antonio Nino Diaz authored
      
      
      When a device tree blob is present at a known address, instead of, for
      example, relying on the user modifying the Linux command line to warn
      about the memory reserved for the Trusted Firmware, pass it on the DTB.
      
      The current code deletes the memory reserved for the default bootstrap
      of the Raspberry Pi and adds the region used by the Trusted Firmware.
      
      This system replaces the previous one consisting on adding
      ``memmap=16M$256M`` to the Linux command line. It's also meant to be
      used by U-Boot and any other bootloader that understands DTB files.
      
      Change-Id: I13ee528475fb043d6e8d9e9f24228e37ac3ac436
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      5341b42e
  6. 23 Oct, 2018 2 commits
    • Antonio Nino Diaz's avatar
      juno: Increase BL2 max size · 472158f6
      Antonio Nino Diaz authored
      
      
      Version 1.4.7 of libfdt is bigger than the current one (1.4.2) and the
      current reserved space for BL2 in Juno isn't enough to fit the Trusted
      Firmware when compiling with clang or armclang.
      
      Change-Id: I7b73394ca60d17f417773f56dd5b3d54495a45a8
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      472158f6
    • Antonio Nino Diaz's avatar
      tzc: Fix MISRA defects · af6491f8
      Antonio Nino Diaz authored
      
      
      The definitions FAIL_CONTROL_*_SHIFT were incorrect, they have been
      fixed.
      
      The types tzc_region_attributes_t and tzc_action_t have been removed and
      replaced by unsigned int because it is not allowed to do logical
      operations on enums.
      
      Also, fix some address definitions in arm_def.h.
      
      Change-Id: Id37941d76883f9fe5045a5f0a4224c133c504d8b
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      af6491f8
  7. 20 Oct, 2018 19 commits
    • Andre Przywara's avatar
      allwinner: Use the arisc to turn off ARM cores · 7db0c960
      Andre Przywara authored
      
      
      PSCI requires a core to turn itself off, which we can't do properly by
      just executing an algorithm on that very core. As a consequence we just
      put a core into WFI on CPU_OFF right now.
      To fix this let's task the "arisc" management processor (an OpenRISC
      core) with that task of asserting reset and turning off the core's power
      domain. We use a handcrafted sequence of OpenRISC instructions to
      achieve this, and hand this data over to the new sunxi_execute_arisc_code()
      routine.
      The commented source code for this routine is provided in a separate file,
      but the ATF code contains the already encoded instructions as data.
      The H6 uses the same algorithm, but differs in the MMIO addresses, so
      provide a SoC (family) specific copy of that code.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      7db0c960
    • Andre Przywara's avatar
      allwinner: Prepare for executing code on the management processor · 11480b90
      Andre Przywara authored
      
      
      The more recent Allwinner SoCs contain an OpenRISC management
      controller (called arisc or CPUS), which shares the bus with the ARM cores,
      but runs on a separate power domain. This is meant to handle power
      management with the ARM cores off.
      There are efforts to run sophisticated firmware on that core
      (communicating via SCPI with the ARM world), but for now can use it for
      the rather simple task of helping to turn the ARM cores off. As this
      cannot be done by ARM code itself (because execution stops at the
      first of the three required steps), we can offload some instructions to
      this management processor.
      This introduces a helper function to hand over a bunch of instructions
      and triggers execution. We introduce a bakery lock to avoid two cores
      trying to use that (single) arisc core. The arisc code is expected to
      put itself into reset after is has finished execution.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      11480b90
    • Andre Przywara's avatar
      allwinner: PMIC: AXP803: Delay activation of DC1SW switch · ccd3ab2d
      Andre Przywara authored
      
      
      There are reports that activating the DC1SW before certain other
      regulators leads to the PMIC overheating and consequently shutting down.
      To avoid this situation, delay the activation of the DC1SW line until
      the very end, so those other lines are always activated earlier.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      ccd3ab2d
    • Andre Przywara's avatar
      allwinner: PMIC: AXP803: Setup basic voltage rails · fb4e9786
      Andre Przywara authored
      
      
      Based on the just introduced PMIC FDT framework, we check the DT for more
      voltage rails that need to be setup early:
      - DCDC1 is typically the main board power rail, used for I/O pins, for
      instance. The PMIC's default is 3.0V, but 3.3V is what most boards use,
      so this needs to be adjusted as soon as possible.
      - DCDC5 is supposed to be connected to the DRAM. The AXP has some
      configurable reset voltage, but some boards get that wrong, so we better
      set up this here to avoid over- or under-volting.
      - DLDO1,2,3 and FLDO1 mostly drive some graphics related IP, some boards
      need this to be up to enable HDMI or the LCD screen, so we get screen
      output in U-Boot.
      
      To get the right setup, but still being flexible, we query the DT for
      the required voltage and whether that regulator is actually used. That
      gives us some robust default setup U-Boot is happy with.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      fb4e9786
    • Andre Przywara's avatar
      allwinner: Scan AXP803 FDT node to setup initial power rails · ed80c1e2
      Andre Przywara authored
      
      
      Now that we have a pointer to the device tree blob, let's use that to
      do some initial setup of the PMIC:
      - We scan the DT for the compatible string to find the PMIC node.
      - We switch the N_VBUSEN pin if the DT property tells us so.
      - We scan over all regulator subnodes, and switch DC1SW if there is at
      least one other node referencing it (judging by the existence of a
      phandle property in that subnode).
      This is just the first part of the setup, a follow up patch will setup
      voltages.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      ed80c1e2
    • Andre Przywara's avatar
      allwinner: Pass FDT address to sunxi_pmic_setup() · df301601
      Andre Przywara authored
      
      
      For Allwinner boards we now use some heuritistics to find a preloaded
      .dtb file.
      
      Pass this address on to the PMIC setup routine, so that it can use the
      information contained therein to setup some initial power rails.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      df301601
    • Andre Przywara's avatar
      allwinner: Find DTB in BL33 image · 41538930
      Andre Przywara authored
      
      
      The initial PMIC setup for the Allwinner platform is quite board
      specific, and used to be guarded by reading the .dtb stub *name* from the
      SPL image in the legacy ATF port. This doesn't scale particularly well,
      and requires constant maintainance.
      Instead having the actual .dtb available would be much better, as the PMIC
      setup requirements could be read from there directly.
      The only available BL33 for Allwinner platforms so far is U-Boot, and
      fortunately U-Boot comes with the full featured .dtb, appended to the
      end of the U-Boot image.
      
      Introduce some code that scans the beginning of the BL33 image to look
      for the load address, which is followed by the image size. Adding those
      two values together gives us the end of the image and thus the .dtb
      address. Verify that this heuristic is valid by sanitising some values
      and checking the DTB magic.
      
      Print out the DTB address and the model name, if specified in the root
      node.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      41538930
    • Andre Przywara's avatar
      allwinner: A64: Add AXP803 PMIC support to power off the board · eae5fe79
      Andre Przywara authored
      
      
      Boards with the Allwinner A64 SoC are mostly paired with an AXP803 PMIC,
      which allows to programmatically power down the board.
      
      Use the newly introduced RSB driver to detect and program the PMIC on
      boot, then later to turn off the main voltage rails when receiving a
      PSCI SYSTEM_POWER_OFF command.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      eae5fe79
    • Andre Przywara's avatar
      allwinner: H6: Factor out I2C platform setup · d5ddf67a
      Andre Przywara authored
      
      
      In the H6 platform code there is a routine to do the platform
      initialisation of the R_I2C controller. We will need a very similar
      setup routine to initialise the RSB controller on the A64.
      
      Move this code to sunxi_common.c and generalise it to support all SoCs
      and also to cover the related RSB bus.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      d5ddf67a
    • Andre Przywara's avatar
      allwinner: H5: Implement power down for H5 reference design boards · 3d22228f
      Andre Przywara authored
      
      
      Allwinner produces reference board designs, which apparently most board
      vendors copy from. So every H5 board I checked uses regulators which are
      controlled by the same PortL GPIO pins to power the ARM CPU cores, the
      DRAM and the I/O ports.
      Add a SoC specific power down routine, which turns those regulators off
      when ATF detects running on an H5 SoC and the rich OS triggers a
      SYSTEM_POWEROFF PSCI call.
      
      NOTE: It sounds very tempting to turn the CPU power off, but this is not
      working as expected, instead the system is rebooting. Most probably this
      is due to VCC-SYS also being controlled by the same GPIO line, and
      turning this off requires an elaborate and not fully understood setup.
      Apparently not even Allwinner reference code is turning this regulator
      off. So for now we refrain to pulling down PL8, the power consumption is
      quite low anyway, so we are as close to poweroff as reasonably possible.
      Many thanks to Samuel for doing some research on that topic.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      3d22228f
    • Andre Przywara's avatar
      allwinner: Introduce GPIO helper function · 7020dca0
      Andre Przywara authored
      
      
      Many boards without a dedicated PMIC contain simple regulators, which
      can be controlled via GPIO pins.
      
      To later allow turning them off easily, introduce a simple function to
      configure a given pin as a GPIO out pin and set it to the desired level.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      7020dca0
    • Andre Przywara's avatar
      allwinner: Export sunxi_private.h · 4ec1a239
      Andre Przywara authored
      
      
      So far we have a sunxi_private.h header file in the common code directory.
      This holds the prototypes of various functions we share in *common*
      code. However we will need some of those in the platform specific code
      parts as well, and want to introduce new functions shared across the
      whole platform port.
      
      So move the sunxi_private.h file into the common/include directory, so
      that it becomes visible to all parts of the platform code.
      Fix up the existing #includes and add missing ones, also add the
      sunxi_read_soc_id() prototype here.
      
      This will be used in follow up patches.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      4ec1a239
    • Andre Przywara's avatar
      allwinner: A64/H5: Add basic and generic shutdown method · f953c30f
      Andre Przywara authored
      
      
      Some boards don't have a PMIC, so they can't easily turn their power
      off. To cover those boards anyway, let's turn off as many devices and
      clocks as possible, so that the power consumption is reduced. Then
      halt the last core, as before.
      This will later be extended with proper PMIC support for supported
      boards.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      f953c30f
    • Andre Przywara's avatar
      allwinner: Pass SoC ID to sunxi_pmic_setup() · fe57c7d4
      Andre Przywara authored
      
      
      In the BL31 platform setup we read the Allwinner SoC ID to identify the
      chip and print its name.
      In addition to that we will need to differentiate the power setup
      between the SoCs, to pass on the SoC ID to the PMIC setup routine.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      fe57c7d4
    • Andre Przywara's avatar
      allwinner: Introduce names for SoC IDs · 123bcb3f
      Andre Przywara authored
      
      
      We will soon make more use of the Allwinner SoC ID, to differentiate the
      platform setup.
      Introduce definitions to avoid dealing with magic numbers and make the
      code more readable.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      123bcb3f
    • Andre Przywara's avatar
      allwinner: H6: Fix SRAM size · f78f00aa
      Andre Przywara authored
      
      
      The SRAM in the Allwinner H6 SoC starts at 0x2000, with the last part
      ending at 0x117fff (although with gaps in between).
      So SUNXI_SRAM_SIZE should be 0xf8000, not 0x98000.
      
      Fix this to map the arisc exception vector area, which we will need
      shortly.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      f78f00aa
    • Andre Przywara's avatar
      allwinner: Disable USE_COHERENT_MEM · 43060513
      Andre Przywara authored
      
      
      According to the documentation, platforms may choose to trade memory
      footprint for performance (and elegancy) by not providing a separately
      mapped coherent page.
      
      Since a debug build is getting close to the SRAM size limit already, this
      allows us to save about 3.5KB of BSS and have some room for future
      enhancements.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      43060513
    • Andre Przywara's avatar
      allwinner: Adjust memory mapping to fit into 256MB · c3af6b00
      Andre Przywara authored
      
      
      At the moment we map as much of the DRAM into EL3 as possible, however
      we actually don't use it. The only exception is the secure DRAM for
      BL32 (if that is configured).
      
      To decrease the memory footprint of ATF, we save on some page tables by
      reducing the memory mapping to the actually required regions: SRAM, device
      MMIO, secure DRAM and U-Boot (to be used later).
      This introduces a non-identity mapping for the DRAM regions.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      c3af6b00
    • Andre Przywara's avatar
      allwinner: Unify platform.mk files · a80490c5
      Andre Przywara authored
      
      
      For the two different platforms we support in the Allwinner port we
      mostly rely on header files covering the differences. This leads to the
      platform.mk files in the respective directories to be almost identical.
      
      To avoid further divergence and make sure that one platform doesn't
      break accidentally, let's create a shared allwinner-common.mk file and
      include that from the platform directory.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      a80490c5
  8. 19 Oct, 2018 1 commit
    • Soby Mathew's avatar
      Multi-console: Deprecate the `finish_console_register` macro · cc5859ca
      Soby Mathew authored
      
      
      The `finish_console_register` macro is used by the multi console
      framework to register the `console_t` driver callbacks. It relied
      on weak references to the `ldr` instruction to populate 0 to the
      callback in case the driver has not defined the appropriate
      function. Use of `ldr` instruction to load absolute address to a
      reference makes the binary position dependant. These instructions
      should be replaced with adrp/adr instruction for position independant
      executable(PIE). But adrp/adr instructions don't work well with weak
      references as described in GNU ld bugzilla issue 22589.
      
      This patch defines a new version of `finish_console_register` macro
      which can spcify which driver callbacks are valid and deprecates the
      old one. If any of the argument is not specified, then the macro
      populates 0 for that callback. Hence the functionality of the previous
      deprecated macro is preserved. The USE_FINISH_CONSOLE_REG_2 define
      is used to select the new variant of the macro and will be removed
      once the deprecated variant is removed.
      
      All the upstream console drivers have been migrated to use the new
      macro in this patch.
      
      NOTE: Platforms be aware that the new variant of the
      `finish_console_register` should be used and the old variant is
      deprecated.
      
      Change-Id: Ia6a67aaf2aa3ba93932992d683587bbd0ad25259
      Signed-off-by: default avatarSoby Mathew <soby.mathew@arm.com>
      cc5859ca