1. 14 Dec, 2020 1 commit
    • Samuel Holland's avatar
      allwinner: Always use a 3MHz RSB bus clock · d6fdb52b
      Samuel Holland authored
      
      
      None of the other drivers (Linux, U-Boot, Crust) need to lower the bus
      clock frequency to switch the PMIC to RSB mode. That logic is not needed
      here, either. The hardware takes care of running this transaction at the
      correct bus frequency.
      Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
      Change-Id: Idcfe933df4da75d5fd5a4f3e362da40ac26bdad1
      d6fdb52b
  2. 14 Dec, 2019 8 commits
    • 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: 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
  3. 26 Nov, 2019 1 commit
  4. 08 Mar, 2019 1 commit
    • Andre Przywara's avatar
      allwinner: regulators: pick correct DT subnode · c48d02ba
      Andre Przywara authored
      
      
      So far the DT node describing the AXP803 PMIC used in many Allwinner A64
      boards had only one subnode, so our code just entering the first subnode
      to find all regulators worked fine.
      
      However recent DT updates in the Linux kernel add more subnodes *before*
      that, so we need to make sure to explicitly enter the "regulators"
      subnode to find the information we are after.
      
      Improve some DT node parsing error handling on the way.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      c48d02ba
  5. 18 Feb, 2019 1 commit
  6. 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
  7. 14 Nov, 2018 3 commits
    • Andre Przywara's avatar
      allwinner: power: Add DCDC6 power rail · 793c38f0
      Andre Przywara authored
      
      
      The DCDC6 power rail is typically driving VDD_SYS in the SoC, so it is
      on by default and uses the default voltage.
      
      As there seems to be at least on board using a different voltage, add
      the rail to the list of known voltage lines, so we can setup the right
      voltage as early as possible.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      793c38f0
    • Andre Przywara's avatar
      allwinner: power: add enable switches for DCDC1/5 · a561e41b
      Andre Przywara authored
      
      
      The DCDC1 and DCDC5 power rails didn't specify the enable bits. This
      isn't critical, since those rails are on by default (and are needed for
      every board), but it is inconsistent.
      
      Add the respective enable bits for those two rails.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      a561e41b
    • Andre Przywara's avatar
      allwinner: power: fix DRIVEVBUS pin setup · d93eb446
      Andre Przywara authored
      
      
      The DRIVEVBUS pin setup was broken in two ways:
      - To configure this pin as an output pin, one has to *clear* the bit in
        register 0x8f. It is 0 by default, but rebooting from Linux might have
        left this bit set.
      - Doing this just configures the pin as an output pin, but doesn't
        actually drive power to it. This is done via bit 2 in register 0x30.
      
      Fix the routine to both properly configure the pin and drive power to
      it. Add an axp_clrsetbits() helper on the way.
      
      Now this isn't really perfect, still:
      We only need to setup the PMIC power rails that are needed for U-Boot.
      DRIVEVBUS typically controls the VBUS voltage for the host function of
      an USB-OTG port, something we typically don't want in U-Boot (fastboot,
      using the USB *device* functionality, is much more common). The
      BananaPi-M64 uses the regulator in this way, but the Remix Mini PC
      actually controls the power of both its USB ports via this line.
      
      Technically we should differentiate here: if DRIVEVBUS controls a
      microUSB-B socket, the power should stay off, any host-type A sockets
      should be supplied, though.
      For now just always enable the power, that shouldn't really hurt the
      USB-OTG functionality anyway.
      Signed-off-by: default avatarAndre Przywara <andre.przywara@arm.com>
      d93eb446
  8. 20 Oct, 2018 9 commits
    • 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: 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: 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: 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
  9. 07 Sep, 2018 2 commits