Commit Graph

931 Commits

Author SHA1 Message Date
Soby Mathew 12d0d00d1e PSCI: Introduce new platform and CM helper APIs
This patch introduces new platform APIs and context management helper APIs
to support the new topology framework based on linear core position. This
framework will be introduced in the follwoing patch and it removes the
assumption that the MPIDR based affinity levels map directly to levels
in a power domain tree. The new platforms APIs and context management
helpers based on core position are as described below:

* plat_my_core_pos() and plat_core_pos_by_mpidr()

These 2 new mandatory platform APIs are meant to replace the existing
'platform_get_core_pos()' API. The 'plat_my_core_pos()' API returns the
linear index of the calling core and 'plat_core_pos_by_mpidr()' returns
the linear index of a core specified by its MPIDR. The latter API will also
validate the MPIDR passed as an argument and will return an error code (-1)
if an invalid MPIDR is passed as the argument. This enables the caller to
safely convert an MPIDR of another core to its linear index without querying
the PSCI topology tree e.g. during a call to PSCI CPU_ON.

Since the 'plat_core_pos_by_mpidr()' API verifies an MPIDR, which is always
platform specific, it is no longer possible to maintain a default implementation
of this API. Also it might not be possible for a platform port to verify an
MPIDR before the C runtime has been setup or the topology has been initialized.
This would prevent 'plat_core_pos_by_mpidr()' from being callable prior to
topology setup. As a result, the generic Trusted Firmware code does not call
this API before the topology setup has been done.

The 'plat_my_core_pos' API should be able to run without a C runtime.
Since this API needs to return a core position which is equal to the one
returned by 'plat_core_pos_by_mpidr()' API for the corresponding MPIDR,
this too cannot have default implementation and is a mandatory API for
platform ports. These APIs will be implemented by the ARM reference platform
ports later in the patch stack.

* plat_get_my_stack() and plat_set_my_stack()

These APIs are the stack management APIs which set/return stack addresses
appropriate for the calling core. These replace the 'platform_get_stack()' and
'platform_set_stack()' APIs. A default weak MP version and a global UP version
of these APIs are provided for the platforms.

* Context management helpers based on linear core position

A set of new context management(CM) helpers viz cm_get_context_by_index(),
cm_set_context_by_index(), cm_init_my_context() and cm_init_context_by_index()
are defined which are meant to replace the old helpers which took MPIDR
as argument. The old CM helpers are implemented based on the new helpers to
allow for code consolidation and will be deprecated once the switch to the new
framework is done.

Change-Id: I89758632b370c2812973a4b2efdd9b81a41f9b69
2015-08-13 16:17:58 +01:00
danh-arm 9caf7e3671 Merge pull request #360 from vwadekar/tegra-platform-def-v2
Tegra: fix PLATFORM_{MAX_AFFLVL|CORE_COUNT|NUM_AFFS} macros
2015-08-12 09:54:25 +01:00
danh-arm dcd9338df5 Merge pull request #357 from vwadekar/tegra-bl31-memmap-fix
Tegra: memmap the actual memory available for BL31
2015-08-12 09:40:35 +01:00
Varun Wadekar 43ec35ee75 Tegra: fix PLATFORM_{CORE_COUNT|NUM_AFFS} macros
This patch fixes the following macros for Tegra SoCs.

* PLATFORM_CORE_COUNT: PLATFORM_CLUSTER_COUNT * PLATFORM_MAX_CPUS_PER_CLUSTER
* PLATFORM_NUM_AFFS: PLATFORM_CORE_COUNT + PLATFORM_CLUSTER_COUNT + 1

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-08-12 09:24:50 +05:30
danh-arm aaa0567c38 Merge pull request #356 from mtk09422/mt8173-support-v3
Mt8173 support v3
2015-08-11 10:08:55 +01:00
Varun Wadekar b25f58014b Tegra: memmap the actual memory available for BL31
On Tegra SoCs, the TZDRAM contains the BL31 and BL32 images. This patch
uses only the actual memory available for BL31 instead of mapping the
entire TZDRAM.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-08-11 14:20:14 +05:30
CC Ma 7d116dccab Initial platform port for MediaTek mt8173
- Boot up 4 cores.
- Add a generic UART driver.
- Add generic CPU helper functions
- Supoort suspend
- Add system_off & system_reset implementation
- Add crash console reporting implementation
- Add get_sys_suspend_power_state() for PSCI 1.0 SYSTEM_SUSPEND
- Add Mediatek SIP runtime service
- Add delay timer platform implementation

Change-Id: I44138249f115ee10b9cbd26fdbc2dd3af04d825f
Signed-off-by: CC Ma <cc.ma@mediatek.com>
Signed-off-by: Jimmy Huang <jimmy.huang@mediatek.com>
2015-08-11 14:45:33 +08:00
Soby Mathew 4067dc3112 PSCI: Remove references to affinity based power management
As per Section 4.2.2. in the PSCI specification, the term "affinity"
is used in the context of describing the hierarchical arrangement
of cores. This often, but not always, maps directly to the processor
power domain topology of the system. The current PSCI implementation
assumes that this is always the case i.e. MPIDR based levels of
affinity always map to levels in a power domain topology tree.

This patch is the first in a series of patches which remove this
assumption. It removes all occurences of the terms "affinity
instances and levels" when used to describe the power domain
topology. Only the terminology is changed in this patch. Subsequent
patches will implement functional changes to remove the above
mentioned assumption.

Change-Id: Iee162f051b228828310610c5a320ff9d31009b4e
2015-08-05 14:15:26 +01:00
Soby Mathew 6590ce2295 PSCI: Invoke PM hooks only for the highest level
This patch optimizes the invocation of the platform power management hooks for
ON, OFF and SUSPEND such that they are called only for the highest affinity
level which will be powered off/on. Earlier, the hooks were being invoked for
all the intermediate levels as well.

This patch requires that the platforms migrate to the new semantics of the PM
hooks.  It also removes the `state` parameter from the pm hooks as the `afflvl`
parameter now indicates the highest affinity level for which power management
operations are required.

Change-Id: I57c87931d8a2723aeade14acc710e5b78ac41732
2015-08-05 14:14:24 +01:00
Soby Mathew b48349eb07 PSCI: Create new directory to implement new frameworks
This patch creates a copy of the existing PSCI files and related psci.h and
platform.h header files in a new `PSCI1.0` directory. The changes for the
new PSCI power domain topology and extended state-ID frameworks will be
added incrementally to these files. This incremental approach will
aid in review and in understanding the changes better. Once all the
changes have been introduced, these files will replace the existing PSCI
files.

Change-Id: Ibb8a52e265daa4204e34829ed050bddd7e3316ff
2015-08-05 14:12:26 +01:00
Jimmy Huang 6b0d97b24a cortex_a53: Add A53 errata #826319, #836870
- Apply a53 errata #826319 to revision <= r0p2
- Apply a53 errata #836870 to revision <= r0p3
- Update docs/cpu-specific-build-macros.md for newly added errata build flags

Change-Id: I44918e36b47dca1fa29695b68700ff9bf888865e
Signed-off-by: Jimmy Huang <jimmy.huang@mediatek.com>
2015-08-05 19:58:39 +08:00
Jimmy Huang fd904df14b Add mmio utility functions
- Add mmio 16 bits read/write functions.
- Add clear/set/clear-and-set utility functions.

Change-Id: I00fdbdf24af537424f8666b1cadaa5f77a2a46ed
Signed-off-by: Jimmy Huang <jimmy.huang@mediatek.com>
2015-08-05 19:55:06 +08:00
Juan Castillo 80bb6afd23 Fix build error with optimizations disabled (-O0)
If Trusted Firmware is built with optimizations disabled (-O0), the
linker throws the following error:

    undefined reference to 'xxx'

Where 'xxx' is a raw inline function defined in a header file. The
reason is that, with optimizations disabled, GCC may decide to skip
the inlining. If that is the case, an external definition to the
compilation unit must be provided. Because no external definition
is present, the linker throws the error.

This patch fixes the problem by declaring the following inline
functions static, so the internal definition is used:

    inline void soc_css_security_setup(void)
    inline const arm_config_t *get_arm_config(void)

Change-Id: Id650d6be1b1396bdb48af1ac8a4c7900d212e95f
2015-08-05 09:34:48 +01:00
danh-arm c905376f96 Merge pull request #351 from davwan01/davwan01/docs-update
Some minor fixes to interrupt-framework-design.md
2015-08-04 09:13:53 +01:00
danh-arm 3747e291ad Merge pull request #349 from jcastillo-arm/jc/tbb_cert_opt
TBB: rework cert_create tool to follow a data driven approach
2015-08-04 09:07:37 +01:00
danh-arm c4d22eaefc Merge pull request #348 from vwadekar/bootargs-tzdram-base-v2
Bootargs tzdram base v2
2015-08-04 09:05:59 +01:00
David Wang 8abbe53fd0 Some minor fixes to interrupt-framework-design.md
This patch fixes a pair of typos. The security state had been described
as non-secure where it should have been secure.

Change-Id: Ib3f424708a6b8e2084e5447f8507ea4e9c99ee79
2015-08-04 12:20:46 +08:00
Varun Wadekar d49d7e7b09 docs: fix the command to compile BL31 on Tegra
This patch fixes the command line used to compile BL31 on
Tegra platforms.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-08-01 11:14:32 +05:30
Varun Wadekar 2ee2c4f0bb Tegra132: set TZDRAM_BASE to 0xF5C00000
The TZDRAM base on the reference platform has been bumped up due to
some BL2 memory cleanup. Platforms can also use a different TZDRAM
base by setting TZDRAM_BASE=<value> in the build command line.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-31 10:26:22 +05:30
Varun Wadekar 0bf1b022f2 Tegra: retrieve BL32's bootargs from bl32_ep_info
This patch removes the bootargs pointer from the platform params
structure. Instead the bootargs are passed by the BL2 in the
bl32_ep_info struct which is a part of the EL3 params struct.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-31 10:26:22 +05:30
danh-arm c9af52e1b6 Merge pull request #344 from vwadekar/tegra-mselect-restore-v2
Tegra210: enable WRAP to INCR burst type conversions
2015-07-28 15:14:42 +01:00
Varun Wadekar 42ca2d86c8 Tegra210: enable WRAP to INCR burst type conversions
The Memory Select Switch Controller routes any CPU transactions to
the appropriate slave depending on the transaction address. During
system suspend, it loses all config settings and hence the CPU has
to restore them during resume.

This patch restores the controller's settings for enabling WRAP to
INCR burst type conversions on the master ports, for any incoming
requests from the AXI slave ports.

Tested by performing multiple system suspend cycles.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-27 17:34:41 +05:30
danh-arm fcee3b00ba Merge pull request #342 from vwadekar/tlkd-delete-need-bl32-v1
tlkd: delete 'NEED_BL32' build variable
2015-07-24 16:17:17 +01:00
Varun Wadekar 458c3c1300 tlkd: delete 'NEED_BL32' build variable
Remove the 'NEED_BL32' flag from the makefile. TLK compiles using a
completely different build system and is present on the device as a
binary blob. The NEED_BL32 flag does not influence the TLK load/boot
sequence at all. Moreover, it expects that TLK binary be present on
the host before we can compile BL31 support for Tegra.

This patch removes the flag from the makefile and thus decouples both
the build systems.

Tested by booting TLK without the NEED_BL32 flag.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-24 18:23:12 +05:30
danh-arm 7d4479a383 Merge pull request #341 from vwadekar/tegra-denver-plat-support-v3
Tegra denver plat support v3
2015-07-24 10:40:18 +01:00
Varun Wadekar 1f95e28ce2 Tegra: modify 'BUILD_PLAT' to point to soc specific build dirs
This patch modifies the 'BUILD_PLAT' makefile variable to point to the soc
specific build directory in order to allow each Tegra soc to have its own
build directory. This way we can keep the build outputs separate and can
keep multiple soc specific builds alive at the same time.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-24 09:25:35 +05:30
Varun Wadekar e7d4caa298 Tegra: Support for Tegra's T132 platforms
This patch implements support for T132 (Denver CPU) based Tegra
platforms.

The following features have been added:

* SiP calls to switch T132 CPU's AARCH mode
* Complete PSCI support, including 'System Suspend'
* Platform specific MMIO settings
* Locking of CPU vector registers

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-24 09:25:23 +05:30
Varun Wadekar 3a8c55f600 Add "Project Denver" CPU support
Denver is NVIDIA's own custom-designed, 64-bit, dual-core CPU which is
fully ARMv8 architecture compatible.  Each of the two Denver cores
implements a 7-way superscalar microarchitecture (up to 7 concurrent
micro-ops can be executed per clock), and includes a 128KB 4-way L1
instruction cache, a 64KB 4-way L1 data cache, and a 2MB 16-way L2
cache, which services both cores.

Denver implements an innovative process called Dynamic Code Optimization,
which optimizes frequently used software routines at runtime into dense,
highly tuned microcode-equivalent routines. These are stored in a
dedicated, 128MB main-memory-based optimization cache. After being read
into the instruction cache, the optimized micro-ops are executed,
re-fetched and executed from the instruction cache as long as needed and
capacity allows.

Effectively, this reduces the need to re-optimize the software routines.
Instead of using hardware to extract the instruction-level parallelism
(ILP) inherent in the code, Denver extracts the ILP once via software
techniques, and then executes those routines repeatedly, thus amortizing
the cost of ILP extraction over the many execution instances.

Denver also features new low latency power-state transitions, in addition
to extensive power-gating and dynamic voltage and clock scaling based on
workloads.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-24 09:08:27 +05:30
Varun Wadekar 93eafbcad4 Tegra: implement per-SoC validate_power_state() handler
The validate_power_state() handler checks the power_state for a valid afflvl
and state id. Although the afflvl check is common, the state ids are implementation
defined.

This patch moves the handler to the tegra/soc folder to allow each SoC to validate
the power_state for supported parameters.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-24 09:08:27 +05:30
Varun Wadekar fb11a62fed Tegra: T210: include CPU files from SoC's platform.mk
This patch moves the inclusion of CPU code (A53, A57) to T210's
makefile. This way we can reduce code size for Tegra platforms by
including only the required CPU files.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-24 09:08:27 +05:30
danh-arm 53d069c28c Merge pull request #337 from vwadekar/tegra-misc-fixes-v3
Tegra misc fixes v3
2015-07-17 14:48:14 +01:00
Varun Wadekar 8061a973ec Tegra: Introduce config for enabling NS access to L2/CPUECTRL regs
A new config, ENABLE_NS_L2_CPUECTRL_RW_ACCESS, allows Tegra platforms to
enable read/write access to the L2 and CPUECTRL registers. T210 is the
only platform that needs to enable this config for now.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:54 +05:30
Varun Wadekar e5b0664ce7 Tegra210: lock PMC registers holding CPU vector addresses
This patch locks access to the PMC registers which hold the CPU reset
vector addresses. The PMC registers are used by the warmboot code and
must be locked during boot/resume to avoid booting into custom firmware
installed by unknown parties e.g. hackers.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:54 +05:30
Varun Wadekar 764c57f6f5 Tegra: PMC: lock SCRATCH22 register
The PMC Scratch22 register contains the CPU reset vector to
be used by the warmboot code to power up the CPU while resuming
from  system suspend. This patch locks this PMC register to avoid
any further writes.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:47 +05:30
Varun Wadekar 2e7aea3d48 Tegra: PMC: check if a CPU is already online
This patch checks if the target CPU is already online before
proceeding with it's power ON sequence.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:47 +05:30
Varun Wadekar 03cd23a10a Tegra210: deassert CPU reset signals during power on
This patch de-asserts the CPU reset signals for each CPU as
part of it's power on sequence. This is needed to get rid of
the wait in BPMP firmware during SC7 exit.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:47 +05:30
Varun Wadekar 6a367fd1ef Tegra: Fix the delay loop used during SC7 exit
This patch fixes the delay loop used to wake up the BPMP during SC7 exit.
The earlier loop would fail just when the timer was about to wrap-around
(e.g. when TEGRA_TMRUS_BASE is 0xfffffffe, the target value becomes 0,
which would cause the loop to exit before it's expiry).

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:47 +05:30
Varun Wadekar c896132679 Tegra: introduce delay timer support
This patch introduces the backend required for implementing the delay
timer API. Tegra has an on-chip free flowing us timer which can be
used as the delay timer.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 19:06:36 +05:30
danh-arm ba06cf1b02 Merge pull request #336 from danh-arm/sb/move-user-guide-to-linaro-release
Update user guide to use Linaro releases
2015-07-17 14:01:32 +01:00
danh-arm 6058ee6a21 Merge pull request #335 from jcastillo-arm/jc/sh_write
Fix bug in semihosting write function
2015-07-17 10:16:51 +01:00
danh-arm 1f06ca8a63 Merge pull request #332 from jcastillo-arm/jc/tf-issues/214
Use uintptr_t as base address type in ARM driver APIs
2015-07-17 10:10:53 +01:00
Varun Wadekar 68e2a64181 Tegra: Exclude coherent memory region from memory map
This patch sets the 'USE_COHERENT_MEM' flag to '0', so that the
coherent memory region will not be included in the memory map.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-17 11:35:10 +05:30
Juan Castillo 31833aff68 Fix bug in semihosting write function
The return value from the SYS_WRITE semihosting operation is 0 if
the call is successful or the number of bytes not written, if there
is an error. The implementation of the write function in the
semihosting driver treats the return value as the number of bytes
written, which is wrong. This patch fixes it.

Change-Id: Id39dac3d17b5eac557408b8995abe90924c85b85
2015-07-16 20:36:41 +01:00
Juan Castillo 55e291a405 TBB: rework cert_create tool to follow a data driven approach
This patch reworks the certificate generation tool to follow a data
driven approach. The user may specify at build time the certificates,
keys and extensions defined in the CoT, register them using the
appropiate macros and the tool will take care of creating the
certificates corresponding to the CoT specified.

Change-Id: I29950b39343c3e1b71718fce0e77dcf2a9a0be2f
2015-07-16 14:31:20 +01:00
Sandrine Bailleux 640af0ee72 Update user guide to use Linaro releases
Linaro produce monthly software releases for the Juno and AEMv8-FVP
platforms. These provide an integrated set of software components
that have been tested together on these platforms.

From now on, it is recommend that Trusted Firmware developers use the
Linaro releases (currently 15.06) as a baseline for the dependent
software components: normal world firmware, Linux kernel and device
tree, file system as well as any additional micro-controller firmware
required by the platform.

This patch updates the user guide to document this new process. It
changes the instructions to get the source code of the full software
stack (including Trusted Firmware) and updates the dependency build
instructions to make use of the build scripts that the Linaro releases
provide.

Change-Id: Ia8bd043f4b74f1e1b10ef0d12cc8a56ed3c92b6e
2015-07-15 11:34:22 +01:00
Juan Castillo 02462972c9 Use uintptr_t as base address type in ARM driver APIs
This patch changes the type of the base address parameter in the
ARM device driver APIs to uintptr_t (GIC, CCI, TZC400, PL011). The
uintptr_t type allows coverage of the whole memory space and to
perform arithmetic operations on the addresses. ARM platform code
has also been updated to use uintptr_t as GIC base address in the
configuration.

Fixes ARM-software/tf-issues#214

Change-Id: I1b87daedadcc8b63e8f113477979675e07d788f1
2015-07-09 11:53:32 +01:00
Achin Gupta 7bcbb962fd Merge pull request #329 from vwadekar/tegra-system-suspend-v3
Implement get_sys_suspend_power_state() handler for Tegra
2015-07-07 13:13:17 +01:00
Varun Wadekar 94c672e77f Implement get_sys_suspend_power_state() handler for Tegra
This patch implements the get_sys_suspend_power_state() handler required by
the PSCI SYSTEM_SUSPEND API. The intent of this handler is to return the
appropriate State-ID field which can be utilized in `affinst_suspend()` to
suspend to system affinity level.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-07-06 09:15:02 +05:30
danh-arm 484bb38509 Merge pull request #324 from soby-mathew/sm/sys_suspend
PSCI: Add SYSTEM_SUSPEND API support
2015-07-02 16:17:11 +01:00
Achin Gupta 1ea5233f34 Merge pull request #326 from jcastillo-arm/jc/tbb_ecdsa
TBB: build 'cert_create' with ECDSA only if OpenSSL supports it
2015-07-01 16:09:27 +01:00