1. 25 Sep, 2019 7 commits
    • Andre Przywara's avatar
      rpi4: Cleanup memory regions, move pens to first page · 882c0ff6
      Andre Przywara authored
      
      
      Now that we have the SMP pens in the first page of DRAM, we can get rid
      of all the fancy RPi3 memory regions that our RPi4 port does not really
      need. This avoids using up memory all over the place, restricting ATF
      to just run in the first 512KB of DRAM.
      
      Remove the now unused regions. This also moves the SMP pens into our
      first memory page (holding the firmware magic), where the original
      firmware put them, but where there is also enough space for them.
      
      Since the pens will require code execution privileges, we amend the
      memory attributes used for that page to include write and execution
      rights.
      
      Change-Id: I131633abeb4a4d7b9057e737b9b0d163b73e47c6
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      882c0ff6
    • Andre Przywara's avatar
      rpi4: Reserve resident BL31 region from non-secure world · 2b19e2f3
      Andre Przywara authored
      
      
      The GPU firmware loads the armstub8.bin (BL31) image at address 0, the
      beginning of DRAM. As this holds the resident PSCI code and the SMP
      pens, the non-secure world should better know about this, to avoid
      accessing memory owned by TF-A. This is particularly criticial as the
      Raspberry Pi 4 does not feature a secure memory controller, so
      overwriting code is a very real danger.
      
      Use the newly introduced function to add a node into reserved-memory
      node, where non-secure world can check for regions to be excluded from
      its mappings.
      
      Reserve the first 512KB of memory for now. We can refine this later if
      need be.
      
      Change-Id: I00e55e70c5c02615320d79ff35bc32b805d30770
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      2b19e2f3
    • Andre Przywara's avatar
      rpi4: Amend DTB to advertise PSCI · f67fa69c
      Andre Przywara authored
      
      
      The device tree provided by the official Raspberry Pi firmware uses
      spin tables for SMP bringup.
      
      One of the benefit of having TF-A is that it provides PSCI services, so
      let's rewrite the DTB to advertise PSCI instead of spin tables.
      This uses the (newly exported) routine from the QEMU platform port.
      
      Change-Id: Ifddcb14041ca253a333f8c2d5e97a42db152470c
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      f67fa69c
    • Andre Przywara's avatar
      rpi4: Determine BL33 entry point at runtime · 448fb352
      Andre Przywara authored
      
      
      Now that we have the armstub magic value in place, the GPU firmware will
      write the kernel load address (and DTB address) into our special page,
      so we can always easily access the actual location without hardcoding
      any addresses into the BL31 image.
      
      Make the compile-time defined PRELOADED_BL33_BASE macro optional, and
      read the BL33 entry point from the magic location, if the macro was not
      defined. We do the same for the DTB address.
      
      This also splits the currently "common" definition of
      plat_get_ns_image_entrypoint() to be separate between RPi3 and RPi4.
      
      Change-Id: I6f26c0adc6fce2df47786b271c490928b4529abb
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      448fb352
    • Andre Przywara's avatar
      rpi4: Accommodate "armstub8.bin" header at the beginning of BL31 image · c4597e13
      Andre Przywara authored
      
      
      The Raspberry Pi GPU firmware checks for a magic value at offset 240
      (0xf0) of the armstub8.bin image it loads. If that value matches,
      it writes the kernel load address and the DTB address into subsequent
      memory locations.
      We can use these addresses to avoid hardcoding these values into the BL31
      image, to make it more flexible and a drop-in replacement for the
      official armstub8.bin.
      
      Reserving just 16 bytes at offset 240 of the final image file is not easily
      possible, though, as this location is in the middle of the generic BL31
      entry point code.
      However we can prepend an extra section before the actual BL31 image, to
      contain the magic and addresses. This needs to be 4KB, because the
      actual BL31 entry point needs to be page aligned.
      
      Use the platform linker script hook that the generic code provides, to
      add an almost empty 4KB code block before the entry point code. The very
      first word contains a branch instruction to jump over this page, into
      the actual entry code.
      This also gives us plenty of room for the SMP pens later.
      
      Change-Id: I38caa5e7195fa39cbef8600933a03d86f09263d6
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      c4597e13
    • Andre Przywara's avatar
      Add basic support for Raspberry Pi 4 · f5cb15b0
      Andre Przywara authored
      
      
      The Raspberry Pi 4 is a single board computer with four Cortex-A72
      cores. From a TF-A perspective it is quite similar to the Raspberry Pi
      3, although it comes with more memory (up to 4GB) and has a GIC.
      
      This initial port though differs quite a lot from the existing rpi3
      platform port, mainly due to taking a much simpler and more robust
      approach to loading the non-secure payload:
      The GPU firmware of the SoC, which is responsible for initial platform
      setup (including DRAM initialisation), already loads the kernel, device
      tree and the "armstub" into DRAM. We take advantage of this, by placing
      just a BL31 component into the armstub8.bin component, which will be
      executed first, in AArch64 EL3.
      The non-secure payload can be a kernel or a boot loader (U-Boot or
      EDK-2), disguised as the "kernel" image and loaded by the GPU firmware.
      
      So this is just a BL31-only port, which directly drops into EL2
      and executes whatever has been loaded as the "kernel" image, handing
      over the DTB address in x0.
      
      Change-Id: I636f4d1f661821566ad9e341d69ba36f6bbfb546
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      f5cb15b0
    • Andre Przywara's avatar
      rpi3: Allow runtime determination of UART base clock rate · 7c0a1877
      Andre Przywara authored
      
      
      At the moment the UART input clock rate is hard coded at compile time.
      This works as long as the GPU firmware always sets up the same rate,
      which does not seem to be true for the Raspberry Pi 4.
      
      In preparation for being able to change this at runtime, add a base
      clock parameter to the console setup function. This is still hardcoded
      for the Raspberry Pi 3.
      
      Change-Id: I398bc2f1e9b46f7af9a84cb0b33cbe8e78f2d900
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      7c0a1877
  2. 13 Sep, 2019 1 commit
    • Andre Przywara's avatar
      rpi3: Add "rpi" platform directory · ab13addd
      Andre Przywara authored
      
      
      With the incoming support for the Raspberry Pi 4 boards, one directory
      to serve both versions will not end up well.
      
      Create an additional layer by inserting a "rpi" directory betweeen /plat
      and rpi3, so that we can more easily share or separate files between the
      two later.
      
      Change-Id: I75adbb054fe7902f34db0fd5e579a55612dd8a5f
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      ab13addd
  3. 01 Feb, 2019 1 commit
  4. 16 Jan, 2019 1 commit
    • Igor Opaniuk's avatar
      rpi3: fix RPI3_PRELOADED_DTB_BASE usage · eabbdafe
      Igor Opaniuk authored
      
      
      In case if `RPI3_PRELOADED_DTB_BASE` isn't defined explicitly with
      proper pre-loaded DTB address, `add_define` macro defined in
      `make_helpers/build_macros.mk` still supplies this definition to the
      compiler like `-DRPI3_PRELOADED_DTB_BASE`, and it's obviously is set to
      default value 1.
      
      This simply leads to the wrong `MAP_NS_DTB` region definition (base_va
      is set `0x1` instead of `0x00010000`) in `plat/rpi3/rpi3_common.c`:
      
      Which causes aligment check to fail in `mmap_add_region_check()`:
      VERBOSE: base_pa: 0x00000001, base_va: 0x00000001, size: 0x00010000
      ...
      ERROR:   mmap_add_region_check() failed. error -22
      Signed-off-by: default avatarIgor Opaniuk <igor.opaniuk@linaro.org>
      eabbdafe
  5. 04 Jan, 2019 1 commit
    • Antonio Nino Diaz's avatar
      Sanitise includes across codebase · 09d40e0e
      Antonio Nino Diaz authored
      Enforce full include path for includes. Deprecate old paths.
      
      The following folders inside include/lib have been left unchanged:
      
      - include/lib/cpus/${ARCH}
      - include/lib/el3_runtime/${ARCH}
      
      The reason for this change is that having a global namespace for
      includes isn't a good idea. It defeats one of the advantages of having
      folders and it introduces problems that are sometimes subtle (because
      you may not know the header you are actually including if there are two
      of them).
      
      For example, this patch had to be created because two headers were
      called the same way: e0ea0928 ("Fix gpio includes of mt8173 platform
      to avoid collision."). More recently, this patch has had similar
      problems: 46f9b2c3 ("drivers: add tzc380 support").
      
      This problem was introduced in commit 4ecca339
      
       ("Move include and
      source files to logical locations"). At that time, there weren't too
      many headers so it wasn't a real issue. However, time has shown that
      this creates problems.
      
      Platforms that want to preserve the way they include headers may add the
      removed paths to PLAT_INCLUDES, but this is discouraged.
      
      Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      09d40e0e
  6. 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
  7. 10 Oct, 2018 1 commit
  8. 17 Aug, 2018 1 commit
  9. 16 Jul, 2018 2 commits
  10. 27 Mar, 2018 1 commit
    • Antonio Nino Diaz's avatar
      rpi3: Use new console APIs · e0f21f62
      Antonio Nino Diaz authored
      
      
      Switch to the new console APIs enabled by setting MULTI_CONSOLE_API=1.
      
      The crash console doesn't use this API, it uses internally the core
      functions of the 16550 console.
      
      `bl31_plat_runtime_setup` is no longer needed. When this platform port
      was introduced, that function used to disable the console. It was needed
      to override that behaviour. The new behaviour is to switch to the
      runtime console. The console is registered for all scopes (boot, crash
      and runtime) in `rpi3_console_init` so it is not needed to override the
      default behaviour anymore.
      
      Update documentation.
      
      Change-Id: If2ee8f91044216183b7ef142e5c05ad6220ae92f
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      e0f21f62
  11. 01 Dec, 2017 1 commit