Commit Graph

1481 Commits

Author SHA1 Message Date
davidcunado-arm f6ace15f9f Merge pull request #689 from yatharth-arm/yk/plat_report_expn
Remove looping around `plat_report_exception`
2016-08-31 14:36:20 +01:00
davidcunado-arm 9115b86795 Merge pull request #690 from soby-mathew/sm/level_sel_xlat
Automatically select initial xlation lookup level
2016-08-31 12:44:21 +01:00
davidcunado-arm 8dff2c3503 Merge pull request #693 from dp-arm/pmf-asm
Move pmf headers to include/lib/pmf and add assembler helper
2016-08-31 11:26:24 +01:00
davidcunado-arm 52c11c3f39 Merge pull request #692 from dp-arm/master
fiptool: Fix typo in create and update usage functions
2016-08-26 16:52:51 +01:00
davidcunado-arm 27c67f4ee9 Merge pull request #691 from rockchip-linux/fixes-suspend/resume-bugs
Fixes suspend/resume bugs
2016-08-26 11:59:42 +01:00
dp-arm 5695cfe77f Add assembler helper to calculate PMF timestamp offset
Given the service name and timestamp id, this assembler macro
calculates the offset into a memory region where the per-cpu timestamp
value is located.

Change-Id: I47f6dfa2a17be182675e2ca0489d6eed42433209
2016-08-26 09:41:44 +01:00
dp-arm afdda571f1 Move pmf headers to include/lib/pmf
More headers will be needed soon so better to move these to their own
directory to avoid cluttering include/lib.

Change-Id: I6a72dc5b602d6f51954cf60aadd1beb52a268670
2016-08-26 09:41:44 +01:00
davidcunado-arm c2229abd75 Merge pull request #684 from rockchip-linux/add-sdram-for-rk3399
rockchip: add dram driver for rk3399
2016-08-25 13:56:25 +01:00
dp-arm 23fcb90d9a fiptool: Fix typo in create and update usage functions
It should be 'fiptool' instead of 'fiptfool'.

Change-Id: I84ce1b6aaae5b8b33e5781bfe4f9e9cf462edb03
2016-08-25 09:39:39 +01:00
Caesar Wang bdb2763d64 rockchip: handle some interrupt before enter power mode for rk3399
For the PMU design, we don't expect to get the interrupts before enter
the power mode. Since that will cause the confusion for the state
machine in the power mode.

Change-Id: Id8dee79ae617a66271b5caf92caf35f520f45099
2016-08-25 12:29:43 +08:00
Caesar Wang b346423251 rockchip: remove the unused code for rk3399
Change-Id: I986d64df9dc62354d50ccea0468b90f090a44160
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
2016-08-25 12:29:43 +08:00
Caesar Wang 9d5aee2b1f rockchip: on rk3399 enable Schmitt trigger on 32 kHz clock
If we don't enable the Schmitt trigger on the 32 kHz clock then systems
won't always resume from suspend properly.  Presumably anything else in
the system that relies on the 32 kHz clock also will have problems
without the Schmitt trigger enabled.

Enable it always since having the 32 kHz clock on GPIO0_A0 isn't
exactly an optional feature, so all boards using rk3399 will need this.

Change-Id: Idc18c6cd1adc5be5f60efd9cb805d83d5cd40129
2016-08-25 12:29:27 +08:00
Caesar Wang 863edcea43 rockchip: enable or disable auto power down base on frequency
add auto_pd_dis_freq parameter, we can pass a frequency from kernel
to disable or enable ddr auto power down function.

Change-Id: Ie30914701336c59047c380381c6b75dd76a89562
2016-08-25 08:39:16 +08:00
Caesar Wang fe877779ee rockchip: rk3399: add dram driver
add dram driver, and kernel can through sip function talk to bl31 to
do ddr frequency scaling. and ddr auto powerdown.

Change-Id: I0d0f2869aed95e336c6e23ba96a9310985c84840
2016-08-25 08:37:42 +08:00
Caesar Wang 0786d68853 rockchip: on rk3399 init the PMU counts at boot; set 24M/32k properly
In a previous change we mistakenly thought that PMU_24M_EN_CFG directly
controlled whether the PMU counts ran off the 32k vs. 24M clock.
Apparently that's not true.  Real logic is now documented in code.

Also in the previous change we mistaknely though that PMU_24M_EN_CFG was
normally supposed to be 1 and we should "restore" it at resume time.
This is a terrible idea and made the system totally unreliable after
resume.  Apparently PMU_24M_EN_CFG should always be 0 with all the
current code and settings.

Let's fix the above two problems.  While we're changing all of this,
let's also:

1. Init at boot time.  Many of these counts are used when the system is
   running normally.  We want the behavior at boot to match the behavior
   after suspend/resume.

2. Init CPU counts to be 1 us.  Although old code was trying to set this
   to 1 ms (1000x slower) at suspend/resume time, we've been testing the
   kernel with 1 us for a long time now.  That's because the kernel (at
   boot time) set these values to 24.  Let's keep at 24 until we know
   that's wrong.

3. Init GPU counts to be 1 us.  Old code wasn't touching the GPU, but as
   documented in comments it makes sense to init here.  Do it.

4. Document the crap out of this code, since the SoC's behavior is
   confusing and poorly documented in the TRM.

5. Increase some stabilization times to 30 ms (from 3 ms).  It's unclear
   that a full 30 ms is needed, but let's be safe for now.

This also inits the counts for the GPU.

(Thanks to Doug's patch that come from https://crosreview.com/372381)

Change-Id: Id1bc159a5a99916aeab043895e5c4585c4adab22
2016-08-25 07:13:34 +08:00
Antonio Nino Diaz e8719552a2 Automatically select initial xlation lookup level
Instead of hardcoding a level 1 table as the base translation level
table, let the code decide which level is the most appropriate given
the virtual address space size.

As the table granularity is 4 KB, this allows the code to select
level 0, 1 or 2 as base level for AArch64. This way, instead of
limiting the virtual address space width to 39-31 bits, widths of
48-25 bit can be used.

For AArch32, this change allows the code to select level 1 or 2
as the base translation level table and use virtual address space
width of 32-25 bits.

Also removed some unused definitions related to translation tables.

Fixes ARM-software/tf-issues#362

Change-Id: Ie3bb5d6d1a4730a26700b09827c79f37ca3cdb65
2016-08-23 10:51:44 +01:00
Yatharth Kochar 5bbc451eea Remove looping around `plat_report_exception`
This patch removes the tight loop that calls `plat_report_exception`
in unhandled exceptions in AArch64 state.
The new behaviour is to call the `plat_report_exception` only
once followed by call to `plat_panic_handler`.
This allows platforms to take platform-specific action when
there is an unhandled exception, instead of always spinning
in a tight loop.

Note: This is a subtle break in behaviour for platforms that
      expect `plat_report_exception` to be continuously executed
      when there is an unhandled exception.

Change-Id: Ie2453804b9b7caf9b010ee73e1a90eeb8384e4e8
2016-08-22 13:41:14 +01:00
danh-arm 079e522d39 Merge pull request #687 from sandrine-bailleux-arm/sb/panic-handler
Add WFI in platform's unexpected error handlers
2016-08-19 15:31:36 +01:00
Sandrine Bailleux 8c9e1af0b5 Add WFI in platform's unexpected error handlers
This patch adds a WFI instruction in the default implementations of
plat_error_handler() and plat_panic_handler(). This potentially reduces
power consumption by allowing the hardware to enter a low-power state.
The same change has been made to the FVP and Juno platform ports.

Change-Id: Ia4e6e1e5bf1ed42efbba7d0ebbad7be8d5f9f173
2016-08-19 14:04:03 +01:00
danh-arm efc759ad82 Merge pull request #686 from danh-arm/dh/remove-inv-dcache-after-auth
Remove dcache invalidation after image authentication
2016-08-18 11:38:48 +01:00
danh-arm 937108a04a Merge pull request #678 from soby-mathew/sm/PSCI_AArch32
Introduce AArch32 support for PSCI library
2016-08-18 11:38:19 +01:00
Dan Handley ad4494dc38 Remove dcache invalidation after image authentication
At the end of successful image authentication in load_auth_image(),
the data cache for the virtual address range corresponding to the
image is invalidated (by a call to inv_dcache_range()). The intent
seems to be to ensure the data caches do not contain any sensitive
data used during authentication, which subsequent code can read.
However, this same address range is already flushed (cleaned and
invalidated by a call to flush_dcache_range()) at the end of
load_image(), and the subsequent invalidate has no functional
effect.

This patch removes the redundant call to inv_dcache_range(). It
also moves the flush_dcache_range() call from the end of load_image()
to the end of load_auth_image(), so the image data will remain in
the caches during authentication, improving performance.

This also improves the comments that explain the rationale for
calling flush_dcache_range() after image loading/authentication.

Change-Id: I14f17ad2935075ef6f3d1327361c5088bfb2d284
2016-08-17 17:01:12 +01:00
danh-arm 974603b554 Merge pull request #685 from sandrine-bailleux-arm/sb/base-fvp-7.6
Move up to Base FVP version 7.6
2016-08-17 16:09:31 +01:00
danh-arm a5794cc134 Merge pull request #683 from dp-arm/dp/fiptool
fiptool: Suppress verbose messages during normal build
2016-08-17 12:55:01 +01:00
danh-arm 6700ae65fb Merge pull request #682 from sudeep-holla/gicv3_ns_intr
gicv3: disable Group1 NonSecure interrupts during core powerdown
2016-08-17 12:54:38 +01:00
danh-arm d3ca949f00 Merge pull request #680 from hzhuang1/emmc_cmd23_v2
emmc: support CMD23
2016-08-17 12:54:14 +01:00
Sandrine Bailleux ccea0d2e7f Move up to Base FVP version 7.6
This patch updates the User Guide to move up from version 7.2 to 7.6
of the Base FVP.

Change-Id: I792b2250deb4836266e14b40992ae59a5ab5f729
2016-08-16 11:37:59 +01:00
dp-arm c2427cb001 fiptool: Suppress verbose messages during normal build
The output is shown only when built with V=1.

Change-Id: I17fef10df6f127f07956a78b478ff3cadba4bd61
2016-08-15 10:21:34 +01:00
Soby Mathew 9d29c227b2 AArch32: Enable build at top level Makefile for FVP
This patch enables the AArch32 build including SP_MIN in the
top level Makefile. The build flag `ARCH` now can specify either
`aarch64`(default) or `aarch32`. Currently only FVP AEM model is
supported for AArch32 build. Another new build flag `AARCH32_SP`
is introduced to specify the AArch32 secure payload to be built.

Change-Id: Ie1198cb9e52d7da1b79b93243338fc3868b08faa
2016-08-15 09:56:30 +01:00
danh-arm 50990186aa Merge pull request #679 from rockchip-linux/support-pwm-for-rk3399
Support pwm for rk3399
2016-08-12 12:19:43 +01:00
Haojian Zhuang 445b1e704e emmc: support CMD23
Support CMD23. When CMD23 is used, CMD12 could be avoided.

Two scenarios:
1. CMD17 for single block, CMD18 + CMD12 for multiple blocks.
2. CMD23 + CMD18 for both single block and multiple blocks.

The emmc_init() should initialize whether CMD23 is supported
or not.

Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org>
2016-08-12 11:41:00 +08:00
Sudeep Holla 65d68ca64d gicv3: disable Group1 NonSecure interrupts during core powerdown
As per the GICv3 specification, to power down a processor using GICv3
and allow automatic power-on if an interrupt must be sent to a processor,
software must set Enable to zero for all interrupt groups(by writing to
GICC_CTLR or ICC_IGRPEN{0,1}_EL1/3 as appropriate.

Also, NonSecure EL1 software may not be aware of the CPU power state
details and fail to choose right states that require quiescing the CPU
interface. So it's preferred that the PSCI implementation handles it as
it is fully aware of the CPU power states.

This patch adds disabling of Group1 NonSecure interrupts during processor
power down along with Group0 and Group1 Secure interrupts so that all the
interrupt groups are handled at once as per specification.

Change-Id: Ib564d773c9c4c41f2ca9471451c030e3de75e641
2016-08-11 11:09:35 +01:00
Caesar Wang 78f7017cdd rockchip: fix the reset-hold release for rk3399 resume
The pmusgrf reset-hold bits needs to be released, since the
pmusgrf reset-hold bits needs to be held.

Change-Id: Ia1eccc8fba18294f26b4cc07d47bc5e513dd9a1f
2016-08-11 13:19:18 +08:00
Caesar Wang 545bff0e1e rockchip: fix the power up/dowm cnt for rk3399
Sometimes this will cause the long delay for suspend/resume.
Since the 24M OCS will be turned off in power mode.
Also, remove the ERROR_DEPRECATED config define.

Change-Id: I78f21c35912c2250972e551695cdacc7bc4c020a
2016-08-11 13:12:10 +08:00
Caesar Wang 5d3b106753 rockchip: update to handle PWMs for rk3399
This patch updates some things for rk3399, as following:

1) Add the new file to handle the pwm. (e.g. the pwm regulator)
Make sure that good deal with the pwm related things.
Also, remove some pwm setting for pmu.c.

2) Set the plls slow mode and bypass in suspend, and restore them.

Change-Id: I112806700bf433c87763aac23d22fa7e6a7f5264
2016-08-11 13:09:28 +08:00
Soby Mathew 181bbd41fb AArch32: Add FVP support for SP_MIN
This patch implements the support for SP_MIN in FVP. The SP_MIN platform
APIs are implemented and the required makefile support is added for FVP.

Change-Id: Id50bd6093eccbd5e38894e3fd2b20d5baeac5452
2016-08-10 18:01:38 +01:00
Soby Mathew 877cf3ff12 AArch32: Add essential ARM platform and FVP support
This patch adds AArch32 support for FVP and implements common platform APIs
like `plat_get_my_stack`, `plat_set_my_stack`, `plat_my_core_cos` for AArch32.
Only Multi Processor(MP) implementations of these functions are considered in
this patch. The ARM Standard platform layer helpers are implemented for
AArch32 and the common makefiles are modified to cater for both AArch64 and
AArch32 builds. Compatibility with the deprecated platform API is not
supported for AArch32.

Change-Id: Iad228400613eec91abf731b49e21a15bcf2833ea
2016-08-10 18:01:38 +01:00
Soby Mathew c11ba852b9 AArch32: add a minimal secure payload (SP_MIN)
This patch adds a minimal AArch32 secure payload SP_MIN. It relies on PSCI
library to initialize the normal world context. It runs in Monitor mode
and uses the runtime service framework to handle SMCs. It is added as
a BL32 component in the Trusted Firmware source tree.

Change-Id: Icc04fa6b242025a769c1f6c7022fde19459c43e9
2016-08-10 18:01:38 +01:00
Soby Mathew 727e5238fa AArch32: Add support to PSCI lib
This patch adds AArch32 support to PSCI library, as follows :

* The `psci_helpers.S` is implemented for AArch32.

* AArch32 version of internal helper function `psci_get_ns_ep_info()` is
  defined.

* The PSCI Library is responsible for the Non Secure context initialization.
  Hence a library interface `psci_prepare_next_non_secure_ctx()` is introduced
  to enable EL3 runtime firmware to initialize the non secure context without
  invoking context management library APIs.

Change-Id: I25595b0cc2dbfdf39dbf7c589b875cba33317b9d
2016-08-10 14:43:48 +01:00
Soby Mathew e33b78a658 AArch32: Add support in TF libraries
This patch adds AArch32 support to cpu ops, context management,
per-cpu data and spinlock libraries. The `entrypoint_info`
structure is modified to add support for AArch32 register
arguments. The CPU operations for AEM generic cpu in AArch32
mode is also added.

Change-Id: I1e52e79f498661d8f31f1e7b3a29e222bc7a4483
2016-08-10 12:35:46 +01:00
Soby Mathew 66be868e9a AArch32: Add console driver
This patch adds console drivers including the pl011 driver
for the AArch32 mode.

Change-Id: Ifd22520d370fca3e73dbbf6f2d97d6aee65b67dd
2016-08-10 12:35:46 +01:00
Soby Mathew 367d0ffb14 AArch32: Enable GIC and TZC support
This patch modifies GICv3 and TZC drivers to add AArch32 support.
No modifications are required for the GICv2 driver for AArch32 support.
The TZC driver assumes that the secure world is running in Little-Endian
mode to do 64 bit manipulations. Assertions are present to validate the
assumption.

Note: The legacy GICv3 driver is not supported for AArch32.

Change-Id: Id1bc75a9f5dafb9715c9500ca77b4606eb1e2458
2016-08-10 12:35:46 +01:00
Soby Mathew 3e3616ab21 AArch32: Add SMCC context
This patch defines a SMCC context to save and restore
registers during a SMC call. It also adds appropriate helpers
to save and restore from this context for use by AArch32
secure payload and BL stages.

Change-Id: I64c8d6fe1d6cac22e1f1f39ea1b54ee1b1b72248
2016-08-10 12:35:46 +01:00
Soby Mathew 1ae0a49a37 AArch32: Add API to invoke runtime service handler
This patch adds an API in runtime service framework to
invoke the registered handler corresponding to the SMC function
identifier. This is helpful for AArch32 because the number of
arguments required by the handler is more than registers
available as per AArch32 program calling conventions and
requires the use of stack. Hence this new API will do the
necessary argument setup and invoke the appropriate
handler. Although this API is primarily intended for AArch32,
it can be used for AArch64 as well.

Change-Id: Iefa15947fe5a1df55b0859886e677446a0fd7241
2016-08-10 12:35:46 +01:00
Soby Mathew bc202b4493 AArch32: Add tf_printf support
The tf_printf library uses 64 bit division to print numbers
in appropriate formats but AArch32 mode cannot do 64 bit division
natively. Hence this patch adds additional number printing routines
to handle AArch32 mode in tf_printf library. The decimal format
printing capability is limited to 32 bit integers whereas 64 bits
are supported in hexadecimal format. The library assumes that
secure world is running in Little-Endian mode to do bit
manipulations on 64 bit. Suitable assertions are present to
enforce this assumption.

Change-Id: I55a21e448cef4915d1834d76e48a84ccf0bec36d
2016-08-10 12:35:46 +01:00
Soby Mathew b2bca61da5 AArch32: Add translation table library support
This patch adds translation library supports for AArch32 platforms.
The library only supports long descriptor formats for AArch32.
The `enable_mmu_secure()` enables the MMU for secure world with
`TTBR0` pointing to the populated translation tables.

Change-Id: I061345b1779391d098e35e7fe0c76e3ebf850e08
2016-08-10 12:35:46 +01:00
Soby Mathew f24307dec4 AArch32: Add assembly helpers
This patch adds various assembly helpers for AArch32 like :

* cache management : Functions to flush, invalidate and clean
cache by MVA. Also helpers to do cache operations by set-way
are also added.

* stack management: Macros to declare stack and get the current
stack corresponding to current CPU.

* Misc: Macros to access co processor registers in AArch32,
macros to define functions in assembly, assert macros, generic
`do_panic()` implementation and function to zero block of memory.

Change-Id: I7b78ca3f922c0eda39beb9786b7150e9193425be
2016-08-10 12:35:46 +01:00
Soby Mathew 031dbb1224 AArch32: Add essential Arch helpers
This patch adds the essential AArch32 architecture helpers
arch.h and arch_helpers.h and modifies `_types.h` to add AArch32
support.

A new build option `ARCH` is defined in the top level makefile to
enable the component makefiles to choose the right files based on the
Architecture it is being build for. Depending on this flag, either
`AARCH32` or `AARCH64` flag is defined by the Makefile. The default
value of `ARCH` flag is `aarch64`. The AArch32 build support will be
added in a later patch.

Change-Id: I405e5fac02db828a55cd25989b572b64cb005241
2016-08-10 12:34:50 +01:00
Soby Mathew c45f627de4 Move SIZE_FROM_LOG2_WORDS macro to utils.h
This patch moves the macro SIZE_FROM_LOG2_WORDS() defined in
`arch.h` to `utils.h` as it is utility macro.

Change-Id: Ia8171a226978f053a1ee4037f80142c0a4d21430
2016-08-09 17:33:57 +01:00
Soby Mathew 12ab697e8f Move spinlock library code to AArch64 folder
This patch moves the assembly exclusive lock library code
`spinlock.S` into architecture specific folder `aarch64`.
A stub file which includes the file from new location is
retained at the original location for compatibility. The BL
makefiles are also modified to include the file from the new
location.

Change-Id: Ide0b601b79c439e390c3a017d93220a66be73543
2016-08-09 17:33:57 +01:00