1. 01 Apr, 2020 3 commits
    • Andrei Warkentin's avatar
      rpi: Implement PSCI CPU_OFF · 2e5f8443
      Andrei Warkentin authored
      We simulate the PSCI CPU_OFF operation by reseting the core via RMR.
      For secondaries, that already puts them in the holding pen waiting for a
      "warm boot" request as part of PSCI CPU_ON. For the BSP, we have to add
      logic to distinguish a regular boot from a CPU_OFF state, where, like the
      secondaries, the BSP needs to wait foor a "warm boot" request as part
      of CPU_ON.
      
      Testing done:
      
      - ACS suite now passes more tests (since it repeatedly
      calls code on secondaries via CPU_ON).
      
      - Linux testing including offlining/onlineing CPU0, e.g.
      "echo 0 > /sys/devices/system/cpu/cpu0/online".
      
      Change-Id: Id0ae11a0ee0721b20fa2578b54dadc72dcbd69e0
      Link: https://developer.trustedfirmware.org/T686
      
      Signed-off-by: default avatarAndrei Warkentin <andrey.warkentin@gmail.com>
      [Andre: adapt to unified plat_helpers.S, smaller fixes]
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      2e5f8443
    • Andre Przywara's avatar
      rpi: rpi3_pwr_domain_on(): Use MMIO accessor · af2a4877
      Andre Przywara authored
      
      
      When writing to arbitrary locations in memory using a constructed
      pointer, there is no guarantee that the compiler does not optimise away
      the access, since it cannot detect any dependency.
      
      One typical solution is to use the "volatile" keyword, but using MMIO
      accessors in usually the better answer, to avoid torn writes.
      
      Replace the usage of an array with such an MMIO accessor function in
      rpi3_pwr_domain_on(), to make sure the write is really happening.
      
      Change-Id: Ia18163c95e92f1557471089fd18abc6dc7fee0c7
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      af2a4877
    • Andre Przywara's avatar
      rpi: move plat_helpers.S to common · 07aa0c7e
      Andre Przywara authored
      
      
      The plat_helpers.S file was almost identical between its RPi3 and RPi4
      versions. Unify the two files, moving it into the common/ directory.
      
      This adds a plat_rpi_get_model() function, which can be used to trigger
      RPi4 specific action, detected at runtime. We use that to do the RPi4
      specific L2 cache initialisation.
      
      Change-Id: I2295704fd6dde7c76fe83b6d98c7bf998d4bf074
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      07aa0c7e
  2. 17 Mar, 2020 3 commits
    • Andre Przywara's avatar
      rpi: console: Autodetect Mini-UART vs. PL011 configuration · 9cc3fa1b
      Andre Przywara authored
      
      
      The Raspberry Pi has two different UART devices pin-muxed to GPIO 14&15:
      One ARM PL011 one and the 8250 compatible "Mini-UART".
      A dtoverlay parameter in config.txt will tell the firmware to switch
      between the two: it will setup the right clocks and will configure the
      pinmuxes accordingly.
      
      To autodetect the user's choice, we read the pinmux register and check
      its setting: ALT5 (0x2) means the Mini-UART is used, ALT0 (0x4) points
      to the PL011.
      Based on that we select the UART driver to initialise.
      
      This will allow console output in any case.
      
      Change-Id: I620d3ce68de6c6576599f2a405636020e1fd1376
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      9cc3fa1b
    • Andre Przywara's avatar
      rpi: Allow using PL011 UART for RPi3/RPi4 · 5e6d821c
      Andre Przywara authored
      
      
      The Broadcom 283x SoCs feature multiple UARTs: the mostly used
      "Mini-UART", which is an 8250 compatible IP, and at least one PL011.
      While the 8250 is usually used for serial console purposes, it suffers
      from a design flaw, where its clock depends on the VPU clock, which can
      change at runtime. This will reliably mess up the baud rate.
      To avoid this problem, people might choose to use the PL011 UART for
      the serial console, which is pin-mux'ed to the very same GPIO pins.
      This can be done by adding "miniuart-bt" to the "dtoverlay=" line in
      config.txt.
      
      To prepare for this situation, use the newly gained freedom of sharing
      one console_t pointer across different UART drivers, to introduce the
      option of choosing the PL011 for the console.
      
      This is for now hard-coded to choose the Mini-UART by default.
      A follow-up patch will introduce automatic detection.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Change-Id: I8cf2522151e09ff4ff94a6d396aec6fc4b091a05
      5e6d821c
    • Andre Przywara's avatar
      rpi3: console: Use same "clock-less" setup scheme as RPi4 · 795aefe5
      Andre Przywara authored
      
      
      In the wake of the upcoming unification of the console setup code
      between RPi3 and RPi4, extend the "clock-less" setup scheme to the
      RPi3. This avoid programming any clocks or baud rate registers,
      which makes the port more robust against GPU firmware changes.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      Change-Id: Ida83a963bb18a878997e9cbd55f8ceac6a2e1c1f
      795aefe5
  3. 25 Feb, 2020 1 commit
  4. 09 Dec, 2019 1 commit
    • Jan Kiszka's avatar
      rpi3/4: Add support for offlining CPUs · 9e78cb18
      Jan Kiszka authored
      
      
      The hooks were populated but the power down left the CPU in limbo-land.
      What we need to do - until there is a way to actually power off - is to
      turn off the MMU and enter the spinning loop as if we were cold-booted.
      This allows the on-call to pick up the CPU again.
      Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Change-Id: Iefc7a58424e3578ad3dd355a7bd6eaba4b412699
      9e78cb18
  5. 25 Sep, 2019 2 commits
    • 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
      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
  6. 13 Sep, 2019 3 commits
    • Andre Przywara's avatar
      rpi3: Prepare for supporting a GIC (in RPi4) · e6fd00ab
      Andre Przywara authored
      
      
      As the PSCI "power" management functions for the Raspberry Pi 3 port
      will be shared with the upcoming RPi4 support, we need to prepare them
      for dealing with the GIC interrupt controller.
      Splitting this code just for those simple calls to the generic GIC
      routines does not seem worthwhile, so just use a #define the protect the
      GIC code from being included by the existing RPi3 code.
      
      Change-Id: Iaca6b0214563852b28ad4a088ec45348ae8be40d
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      e6fd00ab
    • Andre Przywara's avatar
      rpi3: Make SHARED_RAM optional · a95e6415
      Andre Przywara authored
      
      
      The existing Raspberry Pi 3 port sports a number of memory regions,
      which are used for several purposes. The upcoming RPi4 port will not use
      all of those, so make the SHARED_RAM region optional, by only mapping it
      if it has actually been defined. This helps to get a cleaner RPi4 port.
      
      Change-Id: Id69677b7fb6ed48d9f238854b610896785db8cab
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      a95e6415
    • Andre Przywara's avatar
      rpi3: Move shared rpi3 files into common directory · 4f2b9848
      Andre Przywara authored
      
      
      To be able to share code more easily between the existing Raspberry Pi 3
      and the upcoming Raspberry Pi 4 platform, move some code which is not
      board specific into a "common" directory.
      
      Change-Id: I9211ab2d754b040128fac13c2f0a30a5cc8c7f2c
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      4f2b9848