1. 24 Jan, 2021 5 commits
    • Samuel Holland's avatar
      allwinner: Separate code to power off self and other CPUs · a1d349be
      Samuel Holland authored
      
      
      Currently, sunxi_cpu_off() has two separate code paths: one for the
      local CPU, and one for other CPUs. Let's split them in to two functions.
      This actually simplifies things, because all callers either operate on
      the local CPU only (sunxi_pwr_down_wfi()) or other CPUs only
      (sunxi_cpu_power_off_others()). This avoids needing a second MPIDR read
      to choose the appropriate code path.
      
      Change-Id: I55de85025235cc95466bfa106831fc4c2368f527
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      a1d349be
    • Samuel Holland's avatar
      allwinner: Leave CPU power alone during BL31 setup · ed267c92
      Samuel Holland authored
      
      
      Disabling secondary CPUs during boot is unnecessary because the other
      CPUs are already in reset, and it saves an entirely insignificant amount
      of power. Let's remove this bit of code that was added mostly "because
      we can", and along with it remove an unconditional dependency on the CPU
      ops functions.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Ia77a1b722da6ba989c3992b656a6cde3f2238fd7
      ed267c92
    • Samuel Holland's avatar
      allwinner: psci: Invert check in .validate_ns_entrypoint · 814dce8f
      Samuel Holland authored
      
      
      Checking the exceptional case and letting the success case fall through
      is not only more idiomatic, but it also allows adding more exceptional
      cases in the future, such as a check for overlapping secure DRAM.
      
      Change-Id: I720441a6a8853fd7f211ebe851f14d921a6db03d
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      814dce8f
    • Samuel Holland's avatar
      allwinner: psci: Drop MPIDR check from .pwr_domain_on · 772ef7e7
      Samuel Holland authored
      
      
      This duplicated the logic in psci_validate_mpidr() which was already
      called from psci_cpu_on().
      
      Change-Id: I96ee92f1ce3e9cc2985b4e229ba86ebd27b79915
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      772ef7e7
    • Samuel Holland's avatar
      allwinner: psci: Drop .get_node_hw_state callback · a1473c99
      Samuel Holland authored
      
      
      This optional PSCI function was only implemented when SCPI was
      available. However, the underlying SCPI function is not able to fulfill
      the necessary contract. First, the SCPI protocol has no way to represent
      HW_STANDBY at the CPU power level. Second, the SCPI implementation
      maintains its own logical view of power states, and its implementation
      of SCPI_CMD_GET_CSS_POWER_STATE does not actually query the hardware.
      Thus it cannot provide "the physical view of power state", as required
      for this function by the PSCI specification.
      
      Since the function is optional, drop it.
      
      Change-Id: I5f3a0810ac19ddeb3c0c5d35aeb09f09a0b80c1d
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      a1473c99
  2. 14 Dec, 2020 7 commits
  3. 17 Aug, 2020 1 commit
  4. 29 Jun, 2020 1 commit
  5. 23 Mar, 2020 1 commit
    • Andre Przywara's avatar
      allwinner: H6: Fix GPIO and CCU memory map addresses · 5fac0d32
      Andre Przywara authored
      
      
      The base address for both the GPIO and the clock unit of the H6 memory map
      have been typo-ed. Fix them to match the Linux DT and the manual.
      
      The H6 code use neither of them, so this doesn't change or fix anything
      in the real world, but should be corrected anyway.
      
      The issue was found and reported by Github user "armlabs".
      
      Change-Id: Ic6fdfb732ce1cfc54cbb927718035624a06a9e08
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      5fac0d32
  6. 25 Feb, 2020 1 commit
  7. 13 Feb, 2020 4 commits
    • Samuel Holland's avatar
      allwinner: Implement PSCI system suspend using SCPI · e382c88e
      Samuel Holland authored
      
      
      If an SCP firmware is present and able to communicate via SCPI, then use
      that to implement CPU and system power state transitions, including CPU
      hotplug and system suspend. Otherwise, fall back to the existing CPU
      power control implementation.
      
      The last 16 KiB of SRAM A2 are reserved for the SCP firmware, and the
      SCPI shared memory is at the very end of this region (and therefore the
      end of SRAM A2). BL31 continues to start at the beginning of SRAM A2
      (not counting the ARISC exception vector area) and fills up to the
      beginning of the SCP firmware.
      
      Because the SCP firmware is not loaded adjacent to the ARISC exception
      vector area, the jump instructions used for exception handling cannot be
      included in the SCP firmware image, and must be initialized here before
      turning on the SCP.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I37b9b9636f94d4125230423726f3ac5e9cdb551c
      e382c88e
    • Samuel Holland's avatar
      allwinner: Add a msgbox driver for use with SCPI · 50cabf6d
      Samuel Holland authored
      
      
      The function names follow the naming convention used by the existing
      ARM SCPI client.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I543bae7d46e206eb405dbedfcf7aeba88a12ca48
      50cabf6d
    • Samuel Holland's avatar
      allwinner: Reserve and map space for the SCP firmware · 57b36632
      Samuel Holland authored
      
      
      The SCP firmware is allocated the last 16KiB of SRAM A2. This includes
      the SCPI shared memory area, which must be mapped as MT_DEVICE to
      prevent problems with cache coherency between the AP CPUs and the SCP.
      For simplicity, map the whole SCP region as MT_DEVICE.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Ie39eb5ff281b8898a3c1d9748dc08755f528e2f8
      57b36632
    • Samuel Holland's avatar
      allwinner: Adjust SRAM A2 base to include the ARISC vectors · ae3fe6e3
      Samuel Holland authored
      
      
      The ARISC vector area consists of 0x4000 bytes before the beginning of
      usable SRAM. Still, it is technically a part of SRAM A2, so include it
      in the memory definition. This avoids the confusing practice of
      subtracting from the beginning of the SRAM region when referencing the
      ARISC vectors.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Iae89e01aeab93560159562692e03e88306e2a1bf
      ae3fe6e3
  8. 24 Jan, 2020 1 commit
  9. 20 Jan, 2020 1 commit
    • Samuel Holland's avatar
      allwinner: Clean up MMU setup · ddb4c9e0
      Samuel Holland authored
      
      
      Remove the general BL31 mmap region: it duplicates the existing static
      mapping for the entire SRAM region. Use the helper definitions when
      applicable to simplify the code and add the MT_EXECUTE_NEVER flag.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I7a6b79e50e4b5c698774229530dd3d2a89e94a6d
      ddb4c9e0
  10. 15 Jan, 2020 1 commit
    • Samuel Holland's avatar
      allwinner: Reenable USE_COHERENT_MEM · 6c281cc3
      Samuel Holland authored
      
      
      Now that there is plenty of space (32 KiB) available for NOBITS
      sections, we can afford using an entire page for coherent memory. In
      fact, because it simplifies the code, this is a beneficial change for
      loaded image (.text) size, where we are still close to the size limit.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I0b899dabcb162015c63b0e4aed0869569c889ed9
      6c281cc3
  11. 29 Dec, 2019 2 commits
  12. 14 Dec, 2019 11 commits
    • Samuel Holland's avatar
      allwinner: h6: power: Switch to using the AXP driver · fb23b104
      Samuel Holland authored
      
      
      Chip ID checking and poweroff work just like they did before.
      Regulators are now enabled just like on A64/H5.
      
      This changes the signatures of the low-level register read/write
      functions to match the interface expected by the common driver.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I14d63d171a094fa1375904928270fa3e21761646
      fb23b104
    • Samuel Holland's avatar
      allwinner: Convert AXP803 regulator setup code into a driver · 0bc752c9
      Samuel Holland authored
      
      
      Previously, the A64/H5 and H6 platforms' PMIC setup code was entirely
      independent. However, some H6 boards also need early regulator setup.
      
      Most of the register interface and all of the device tree traversal code
      can be reused between the AXP803 and AXP805. The main difference is the
      hardware bus interface, so that part is left to the platforms. The
      remainder is moved into a driver.
      
      I factored out the bits that were obviously specific to the AXP803;
      additional changes for compatibility with other PMICs can be made as
      needed.
      
      The only functional change is that rsb_init() now checks the PMIC's chip
      ID register against the expected value. This was already being done in
      the H6 version of the code.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Icdcf9edd6565f78cccc503922405129ac27e08a2
      0bc752c9
    • Samuel Holland's avatar
      allwinner: a64: power: Use fdt_for_each_subnode · 79b85465
      Samuel Holland authored
      
      
      This simplifies the code a bit. Verified to produce the same binary.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Ie1ec1ce2ea39c46525840906826c90a8a7eff287
      79b85465
    • Samuel Holland's avatar
      allwinner: a64: power: Remove obsolete register check · 494c8233
      Samuel Holland authored
      As of a561e41b
      
       ("allwinner: power: add enable switches for DCDC1/5")
      there are no longer regulators without an enable register provided.
      Since it seems reasonable that this will continue to be the case, drop
      the check.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Icd7ec26fc6450d053e6e6d855fc16229b1d65a39
      494c8233
    • Samuel Holland's avatar
      allwinner: a64: power: Remove duplicate DT check · 3bea03e7
      Samuel Holland authored
      
      
      should_enable_regulator() is already checked in the regulators subnode
      loop before setup_regulator() is called, so there's no need to check it
      again here.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Idb8b8a6e435246f4fb226bc84813449d80a0a977
      3bea03e7
    • Samuel Holland's avatar
      allwinner: Build PMIC bus drivers only in BL31 · 18fbfefb
      Samuel Holland authored
      
      
      These are used by the PMIC setup code, which runs during BL31
      initialization, and the PSCI shutdown code, also a part of BL31.
      They can't be needed before BL31, or it wouldn't be possible to boot.
      Allwinner platforms don't generally build anything but BL31 anyway, but
      this change improves clarity and consistency with allwinner-common.mk.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I24f1d9ca8b4256e44badf5218d04d8690082babf
      18fbfefb
    • Samuel Holland's avatar
      allwinner: a64: power: Make sunxi_turn_off_soc static · df77a954
      Samuel Holland authored
      
      
      The function is only used in this file, and it doesn't make sense for it
      to be used anywhere else.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Iab18f082911edcdbc37ceeaff8c512be68e0cb0f
      df77a954
    • Samuel Holland's avatar
      allwinner: Merge duplicate code in sunxi_power_down · 818e6732
      Samuel Holland authored
      
      
      The action of last resort isn't going to change between SoCs. This moves
      that code back to the PSCI implementation, where it more obviously
      matches the code in sunxi_system_reset().
      
      The two error messages say essentially the same thing anyway.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I62ac35fdb5ed78a016e9b18281416f1dcea38a4a
      818e6732
    • Samuel Holland's avatar
      allwinner: Clean up PMIC-related error handling · 4538c498
      Samuel Holland authored
      
      
      - Check the return value from sunxi_init_platform_r_twi().
      - Print the PMIC banner before doing anything that might fail.
      - Remove double prefixes in error messages.
      - Consistently omit the trailing period.
      - No need to print the unknown SoC's ID, since we already did that
        earlier in bl31_platform_setup().
      - On the other hand, do print the ID of the unknown PMIC.
      - Try to keep the messages concise, as the large string size in these
        files was causing the firmware to spill into the next page.
      - Downgrade the banner from NOTICE to INFO. It's purely informational,
        and people should be using debug builds on untested hardware anyway.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Ib909408a5fdaebe05470fbce48d245dd0bf040eb
      4538c498
    • Samuel Holland's avatar
      allwinner: Synchronize PMIC enumerations · c0e109f2
      Samuel Holland authored
      
      
      Ensure that the default (zero) value represents the case where we take
      no action. Previously, if a PLAT=sun50i_a64 build was booted on an
      unknown SoC ID, it would be treated as an H5 at shutdown.
      
      This removes some duplicate code and fixes error propagation on H6.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: I4e51d8a43a56eccb0d8088593cb9908e52e782bc
      c0e109f2
    • Samuel Holland's avatar
      allwinner: Enable clock before resetting I2C/RSB · eb75518d
      Samuel Holland authored
      
      
      The clock must be running for the module to be reset.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Ic8fafc946f3a1a697174b91288e357ffa033ab9a
      eb75518d
  13. 04 Dec, 2019 1 commit
  14. 26 Nov, 2019 1 commit
  15. 28 Jun, 2019 1 commit
  16. 08 Jun, 2019 1 commit
    • Samuel Holland's avatar
      allwinner: Disable unused features to save space · 8f31853b
      Samuel Holland authored
      
      
      As all Allwinner platforms are single-cluster A53 chips, we can disable
      support for newer, unsupported architecture extensions. We can also
      avoid some cache maintenance code, since no platform-specific setup is
      required to enable coherency.
      
      These changes reduce the size of .text on a default build with GCC 9.1
      enough that .vectors again fits in the second half of a page, instead
      of requiring its own page.
      
      This commit was boot-tested on the Pinebook.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Ib90454ef0c798d5e714b7780c585be0b1ed49c6d
      8f31853b