1. 15 May, 2018 3 commits
    • Derek Basehore's avatar
      rockchip/rk3399: Add watchdog support in pmusram · 5b886432
      Derek Basehore authored
      
      
      To catch early hangs in resume, this sets up the watchdog before
      anything else in the pmusram code (ignoring setting up the stack...).
      This uses hard coded settings for the watchdog until the proper
      watchdog restore later on in the firmware/kernel.
      
      This also restores the old watchdog register values before the PLLs
      are restored to make sure we don't temporarily switch over to a 1/3s
      timeout on the watchdog when the pclk_wdt goes from 4MHz to 100MHz.
      
      Change-Id: I8f7652089a88783271b17482117b4609330abe80
      Signed-off-by: default avatarDerek Basehore <dbasehore@chromium.org>
      5b886432
    • Lin Huang's avatar
      rockchip/rk3399: Split M0 binary into two · ff4735cf
      Lin Huang authored
      
      
      All the m0 code run in SRAM before, but we need to watch PMU_POWER_ST
      when SOC enter into FSM, and SRAM will shutdown during this time, so
      this code need run in PMUSRAM. But PMUSRAM only 8K space, we can not
      put all the m0 binary into PMUSRAM, Split the M0 binary into two, dram
      part still run in SRAM, and suspend part run in PMUSRAM.
      
      Change-Id: Ie08bdf3e2b8838f12b9297fe60ab0aad219684b1
      Signed-off-by: default avatarLin Huang <hl@rock-chips.com>
      ff4735cf
    • Lin Huang's avatar
      rockchip/rk3399: improve pmu powermode configure when suspend · 133598cb
      Lin Huang authored
      
      
      we need to enable PMU_WKUP_RST_EN for pmu powermode configure, since
      enable wakeup reset will hold the soc status, so the SOC will not affect
      by some power or other single glitch when resume, and keep the soc in the
      right status. And it not need to enable DDRIO_RET_HW_DE_REQ, the ddr resume
      will do it manual.
      
      Change-Id: Ib4af897ffb3cb63dc2aa9a6002e5d9ef86ee4a49
      Signed-off-by: default avatarLin Huang <hl@rock-chips.com>
      133598cb
  2. 27 Apr, 2018 2 commits
    • Masahiro Yamada's avatar
      types: use int-ll64 for both aarch32 and aarch64 · 0a2d5b43
      Masahiro Yamada authored
      Since commit 031dbb12
      
       ("AArch32: Add essential Arch helpers"),
      it is difficult to use consistent format strings for printf() family
      between aarch32 and aarch64.
      
      For example, uint64_t is defined as 'unsigned long long' for aarch32
      and as 'unsigned long' for aarch64.  Likewise, uintptr_t is defined
      as 'unsigned int' for aarch32, and as 'unsigned long' for aarch64.
      
      A problem typically arises when you use printf() in common code.
      
      One solution could be, to cast the arguments to a type long enough
      for both architectures.  For example, if 'val' is uint64_t type,
      like this:
      
        printf("val = %llx\n", (unsigned long long)val);
      
      Or, somebody may suggest to use a macro provided by <inttypes.h>,
      like this:
      
        printf("val = %" PRIx64 "\n", val);
      
      But, both would make the code ugly.
      
      The solution adopted in Linux kernel is to use the same typedefs for
      all architectures.  The fixed integer types in the kernel-space have
      been unified into int-ll64, like follows:
      
          typedef signed char           int8_t;
          typedef unsigned char         uint8_t;
      
          typedef signed short          int16_t;
          typedef unsigned short        uint16_t;
      
          typedef signed int            int32_t;
          typedef unsigned int          uint32_t;
      
          typedef signed long long      int64_t;
          typedef unsigned long long    uint64_t;
      
      [ Linux commit: 0c79a8e29b5fcbcbfd611daf9d500cfad8370fcf ]
      
      This gets along with the codebase shared between 32 bit and 64 bit,
      with the data model called ILP32, LP64, respectively.
      
      The width for primitive types is defined as follows:
      
                         ILP32           LP64
          int            32              32
          long           32              64
          long long      64              64
          pointer        32              64
      
      'long long' is 64 bit for both, so it is used for defining uint64_t.
      'long' has the same width as pointer, so for uintptr_t.
      
      We still need an ifdef conditional for (s)size_t.
      
      All 64 bit architectures use "unsigned long" size_t, and most 32 bit
      architectures use "unsigned int" size_t.  H8/300, S/390 are known as
      exceptions; they use "unsigned long" size_t despite their architecture
      is 32 bit.
      
      One idea for simplification might be to define size_t as 'unsigned long'
      across architectures, then forbid the use of "%z" string format.
      However, this would cause a distortion between size_t and sizeof()
      operator.  We have unknowledge about the native type of sizeof(), so
      we need a guess of it anyway.  I want the following formula to always
      return 1:
      
        __builtin_types_compatible_p(size_t, typeof(sizeof(int)))
      
      Fortunately, ARM is probably a majority case.  As far as I know, all
      32 bit ARM compilers use "unsigned int" size_t.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      0a2d5b43
    • Masahiro Yamada's avatar
      Fix pointer type mismatch of handlers · 57d1e5fa
      Masahiro Yamada authored
      Commit 4c0d0390
      
       ("Rework type usage in Trusted Firmware") changed
      the type usage in struct declarations, but did not touch the definition
      side.  Fix the type mismatch.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      57d1e5fa
  3. 07 Apr, 2018 1 commit
  4. 27 Mar, 2018 1 commit
    • Joel Hutton's avatar
      Clean usage of void pointers to access symbols · 9f85f9e3
      Joel Hutton authored
      
      
      Void pointers have been used to access linker symbols, by declaring an
      extern pointer, then taking the address of it. This limits symbols
      values to aligned pointer values. To remove this restriction an
      IMPORT_SYM macro has been introduced, which declares it as a char
      pointer and casts it to the required type.
      
      Change-Id: I89877fc3b13ed311817bb8ba79d4872b89bfd3b0
      Signed-off-by: default avatarJoel Hutton <Joel.Hutton@Arm.com>
      9f85f9e3
  5. 26 Mar, 2018 1 commit
  6. 21 Mar, 2018 1 commit
    • Antonio Nino Diaz's avatar
      Rename 'smcc' to 'smccc' · 085e80ec
      Antonio Nino Diaz authored
      
      
      When the source code says 'SMCC' it is talking about the SMC Calling
      Convention. The correct acronym is SMCCC. This affects a few definitions
      and file names.
      
      Some files have been renamed (smcc.h, smcc_helpers.h and smcc_macros.S)
      but the old files have been kept for compatibility, they include the
      new ones with an ERROR_DEPRECATED guard.
      
      Change-Id: I78f94052a502436fdd97ca32c0fe86bd58173f2f
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      085e80ec
  7. 20 Mar, 2018 1 commit
    • Lin Huang's avatar
      rockchip/rk3399: save/restore watchdog register correctly · 56bf9407
      Lin Huang authored
      
      
      there are two fix for save/restore watchdog register:
      1. watchdog plck will shutdown after secure_watchdog_disable(), so need
         to save register before it and restore after secure_watchdog_enable().
      2. need write 0x76 to cnt_restart to keep watchdog alive when restore
         watchdog register.
      
      Change-Id: I1f6fbceae22186e3b72a87df6332a110adf37479
      Signed-off-by: default avatarLin Huang <hl@rock-chips.com>
      56bf9407
  8. 27 Feb, 2018 1 commit
  9. 21 Feb, 2018 1 commit
  10. 30 Jan, 2018 1 commit
    • Caesar Wang's avatar
      rockchip/rk3399: Fix memory corruptions or illegal memory access · de3c3007
      Caesar Wang authored
      
      
      Coverity scan done for the coreboot project found the issue:
      Coverity (*** CID 1385418: Memory - illegal accesses (OVERRUN))
      Coverity (*** CID 1385419: Memory - corruptions  (OVERRUN))
      
      Fix the Converity error issue with store_cru[] loop needs to be one
      element bigger.
      
      Fixes: ARM-software/tf-issues#544
      
      Change-Id: I420f0a660b24baaa5fc5e78fca242cf750c9bbc7
      Signed-off-by: default avatarCaesar Wang <wxt@rock-chips.com>
      de3c3007
  11. 29 Jan, 2018 1 commit
  12. 26 Jan, 2018 1 commit
  13. 24 Jan, 2018 4 commits
  14. 19 Jan, 2018 2 commits
    • Julius Werner's avatar
      rockchip: Move to MULTI_CONSOLE_API · 890abc33
      Julius Werner authored
      
      
      This patch changes all Rockchip platforms to use the new
      MULTI_CONSOLE_API. The platform-specific plat_crash_console
      implementations are removed so that the platform can use the ones from
      the common platform code instead.
      
      Also change the registers used in plat_crash_print_regs. The existing
      use of x16 and x17 has always been illegal, since those registers are
      reserved for use by the linker as a temporary scratch registers in
      intra-procedure-call veneers and can never be expected to maintain their
      values across a function call.
      
      Change-Id: I8249424150be8d5543ed4af93b56756795a5288f
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      890abc33
    • Julius Werner's avatar
      rockchip: Use coreboot-supplied serial console on coreboot systems · 3c250b9a
      Julius Werner authored
      
      
      This patch changes all Rockchip platforms to initialize the serial
      console with information supplied by coreboot rather than hardcoded
      base address and divisor values if BL31 is run on top of coreboot.
      Moving the BL2-to-BL31 parameter parsing as early as possible to ensure
      that the console is available for all following code.
      
      Also update the Rockchip platform to use MULTI_CONSOLE_API.
      
      Change-Id: I670d350fa2f8b8133539f91ac14977ab47db60d9
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      3c250b9a
  15. 12 Dec, 2017 1 commit
    • Julius Werner's avatar
      rockchip: Implement a panic handler that will reboot the system · a33e763c
      Julius Werner authored
      
      
      The current Rockchip platform code retains the "common" default panic
      handler which simply hangs the system (until the watchdog kicks in, if
      enabled). This is usually not a great user experience.
      
      This patch implements a Rockchip-specific panic handler that calls the
      platform's reboot implementation to reset the system.
      
      Change-Id: I4cbe09c48f1b3f86ebdfc0108c186565f9ffc119
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      a33e763c
  16. 02 Dec, 2017 1 commit
  17. 30 Nov, 2017 1 commit
    • David Cunado's avatar
      Do not enable SVE on pre-v8.2 platforms · 3872fc2d
      David Cunado authored
      
      
      Pre-v8.2 platforms such as the Juno platform does not have
      the Scalable Vector Extensions implemented and so the build
      option ENABLE_SVE is set to zero.
      
      This has a minor performance improvement with no functional
      impact.
      
      Change-Id: Ib072735db7a0247406f8b60e325b7e28b1e04ad1
      Signed-off-by: default avatarDavid Cunado <david.cunado@arm.com>
      3872fc2d
  18. 29 Nov, 2017 1 commit
    • Antonio Nino Diaz's avatar
      Replace magic numbers in linkerscripts by PAGE_SIZE · a2aedac2
      Antonio Nino Diaz authored
      
      
      When defining different sections in linker scripts it is needed to align
      them to multiples of the page size. In most linker scripts this is done
      by aligning to the hardcoded value 4096 instead of PAGE_SIZE.
      
      This may be confusing when taking a look at all the codebase, as 4096
      is used in some parts that aren't meant to be a multiple of the page
      size.
      
      Change-Id: I36c6f461c7782437a58d13d37ec8b822a1663ec1
      Signed-off-by: default avatarAntonio Nino Diaz <antonio.ninodiaz@arm.com>
      a2aedac2
  19. 06 Nov, 2017 1 commit
  20. 01 Nov, 2017 1 commit
  21. 29 Aug, 2017 7 commits
  22. 15 Aug, 2017 1 commit
    • Julius Werner's avatar
      Add new alignment parameter to func assembler macro · 64726e6d
      Julius Werner authored
      
      
      Assembler programmers are used to being able to define functions with a
      specific aligment with a pattern like this:
      
          .align X
        myfunction:
      
      However, this pattern is subtly broken when instead of a direct label
      like 'myfunction:', you use the 'func myfunction' macro that's standard
      in Trusted Firmware. Since the func macro declares a new section for the
      function, the .align directive written above it actually applies to the
      *previous* section in the assembly file, and the function it was
      supposed to apply to is linked with default alignment.
      
      An extreme case can be seen in Rockchip's plat_helpers.S which contains
      this code:
      
        [...]
        endfunc plat_crash_console_putc
      
        .align 16
        func platform_cpu_warmboot
        [...]
      
      This assembles into the following plat_helpers.o:
      
        Sections:
        Idx Name                             Size  [...]  Algn
         9 .text.plat_crash_console_putc 00010000  [...]  2**16
        10 .text.platform_cpu_warmboot   00000080  [...]  2**3
      
      As can be seen, the *previous* function actually got the alignment
      constraint, and it is also 64KB big even though it contains only two
      instructions, because the .align directive at the end of its section
      forces the assembler to insert a giant sled of NOPs. The function we
      actually wanted to align has the default constraint. This code only
      works at all because the linker just happens to put the two functions
      right behind each other when linking the final image, and since the end
      of plat_crash_console_putc is aligned the start of platform_cpu_warmboot
      will also be. But it still wastes almost 64KB of image space
      unnecessarily, and it will break under certain circumstances (e.g. if
      the plat_crash_console_putc function becomes unused and its section gets
      garbage-collected out).
      
      There's no real way to fix this with the existing func macro. Code like
      
       func myfunc
       .align X
      
      happens to do the right thing, but is still not really correct code
      (because the function label is inserted before the .align directive, so
      the assembler is technically allowed to insert padding at the beginning
      of the function which would then get executed as instructions if the
      function was called). Therefore, this patch adds a new parameter with a
      default value to the func macro that allows overriding its alignment.
      
      Also fix up all existing instances of this dangerous antipattern.
      
      Change-Id: I5696a07e2fde896f21e0e83644c95b7b6ac79a10
      Signed-off-by: default avatarJulius Werner <jwerner@chromium.org>
      64726e6d
  23. 14 Jul, 2017 1 commit
  24. 05 Jul, 2017 1 commit
  25. 30 Jun, 2017 1 commit
    • Caesar Wang's avatar
      rockchip/rk3399: fixes the typo and the WARNINGS during suspend/resume · c3710ee7
      Caesar Wang authored
      
      
      This patch fixes the two things as follows:
      
      1) rk3399_flash_l2_b" seems to be a typo. That's "flush", not "flash".
      
      2) fixes the warnings log.
      We always hit the warnings thing during the suspend, as below log:
      ..
      [   51.022334] CPU5: shutdown
      [   51.025069] psci: CPU5 killed.
      INFO:    sdram_params->ddr_freq = 928000000
      WARNING: rk3399_flash_l2_b:reg 28830380,wait
      
      When the L2 completes the clean and invalidate sequence, it asserts the
      L2FLUSHDONE signal. The SoC can now deassert L2FLUSHREQ signal and then
      the L2 deasserts L2FLUSHDONE.
      
      Then, a loop without a delay isn't really great to measure time. We should
      probably add a udelay(10) or so in there and then maybe replace the WARN()
      after the loop. In the actual tests, the L2 cache will take ~4ms by
      default for big cluster.
      
      In the real world that give 10ms for the enough margin, like the
      ddr/cpu/cci frequency and other factors that will affect it.
      
      Change-Id: I55788c897be232bf72e8c7b0e10cf9b06f7aa50d
      Signed-off-by: default avatarCaesar Wang <wxt@rock-chips.com>
      c3710ee7
  26. 28 Jun, 2017 1 commit
    • Caesar Wang's avatar
      rockchip: enable A53's erratum 855873 for rk3399 · dea1e8ee
      Caesar Wang authored
      
      
      For rk3399, the L2ACTLR[14] is 0 by default, as ACE CCI-500 doesn't
      support WriteEvict. and you will hit the condition L2ACTLR[3] with 0,
      as the Evict transactions should propagate to CCI-500 since it has
      snoop filters.
      
      Maybe this erratum applies to all Cortex-A53 cores so far, especially
      if RK3399's A53 is a r0p4. we should enable it to avoid data corruption,
      
      Change-Id: Ib86933f1fc84f8919c8e43dac41af60fd0c3ce2f
      Signed-off-by: default avatarCaesar Wang <wxt@rock-chips.com>
      dea1e8ee
  27. 26 Jun, 2017 1 commit