Commit Graph

949 Commits

Author SHA1 Message Date
Sandrine Bailleux c17a4dc34c Make CASSERT() macro callable from anywhere
The CASSERT() macro introduces a typedef for the sole purpose of
triggering a compilation error if the condition to check is false.
This typedef is not used afterwards. As a consequence, when the
CASSERT() macro is called from withing a function block, the compiler
complains and outputs the following error message:

  error: typedef 'msg' locally defined but not used [-Werror=unused-local-typedefs]

This patch adds the "unused" attribute for the aforementioned
typedef. This silences the compiler warning and thus makes the
CASSERT() macro callable from within function blocks as well.

Change-Id: Ie36b58fcddae01a21584c48bb6ef43ec85590479
2015-10-19 08:52:35 +01:00
Sandrine Bailleux 3ae8a360e0 Fix #include path in ARM platform BL1 setup code
This patch fixes the relative path to the 'bl1_private.h' header file
included from 'arm_bl1_setup.c'. Note that, although the path was
incorrect, it wasn't causing a compilation error because the header
file still got included through an alternative include search path.

Change-Id: I28e4f3dbe50e3550ca6cad186502c88a9fb5e260
2015-10-19 08:46:54 +01:00
danh-arm a3a348993a Merge pull request #405 from vwadekar/tlkd-resume-fid-v3
TLKD: pass results with TLK_RESUME_FID function ID
2015-10-14 12:36:49 +01:00
danh-arm 3679240ac0 Merge pull request #406 from sandrine-bailleux/sb/cci-init-fix-assertion
Fix debug assertion in deprecated CCI-400 driver
2015-10-14 12:12:38 +01:00
Sandrine Bailleux 22b0eda5d2 Fix debug assertion in deprecated CCI-400 driver
This patch fixes a copy and paste issue that resulted in the cluster
indexes not being checked as intended. Note that this fix applies to
the deprecated CCI-400 driver, not the unified one.

Change-Id: I497132a91c236690e5eaff908f2db5c8c65e85ab
2015-10-12 10:21:55 +01:00
Varun Wadekar ca15d9bcdf TLKD: pass results with TLK_RESUME_FID function ID
TLK sends the "preempted" event to the NS world along with an
identifier for certain use cases. The NS world driver is then
expected to take appropriate action depending on the identifier
value. Upon completion, the NS world driver then sends the
results to TLK (via x1-x3) with the TLK_RESUME_FID function ID.

This patch uses the already present code to pass the results
from the NS world to TLK for the TLK_RESUME_FID function ID.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-10-09 22:22:56 +05:30
danh-arm 6e9fa3866d Merge pull request #402 from soby-mathew/sm/psci_cpu_off
PSCI: Update state only if CPU_OFF is not denied by SPD
2015-10-07 11:41:08 +01:00
Soby Mathew 16e05cdbf7 PSCI: Update state only if CPU_OFF is not denied by SPD
This patch fixes an issue in the PSCI framework where the affinity info
state of a core was being set to OFF even when the SPD had denied the
CPU_OFF request. Now, the state remains set to ON instead.

Fixes ARM-software/tf-issues#323

Change-Id: Ia9042aa41fae574eaa07fd2ce3f50cf8cae1b6fc
2015-10-06 09:49:10 +01:00
danh-arm 41099f4e74 Merge pull request #401 from sandrine-bailleux/sb/fix-sp804-bug-v2
Bug fix in the SP804 dual timer driver
2015-09-30 15:18:15 +01:00
Achin Gupta 271b60df72 Merge pull request #400 from vwadekar/tlkd-pm-handlers-v5
Send power management events to the Trusted OS (TLK)
2015-09-30 13:19:06 +01:00
danh-arm 895a7fb459 Merge pull request #393 from mtk09422/misc-updates
mt8173: Update SPM and fix watchdog setting
2015-09-30 11:13:33 +01:00
Varun Wadekar cb790c5e48 Send power management events to the Trusted OS (TLK)
This patch adds PM handlers to TLKD for the system suspend/resume and
system poweroff/reset cases. TLK expects all SMCs through a single
handler, which then fork out into multiple handlers depending on the
SMC. We tap into the same single entrypoint by restoring the S-EL1
context before passing the PM event via register 'x0'. On completion
of the PM event, TLK sends a completion SMC and TLKD then moves on
with the PM process.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-09-30 10:38:28 +05:30
Sandrine Bailleux 543128771c Bug fix in the SP804 dual timer driver
The generic delay timer driver expects a pointer to a timer_ops_t
structure containing the specific timer driver information. It
doesn't make a copy of the structure, instead it just keeps the
pointer. Therefore, this pointer must remain valid over time.

The SP804 driver doesn't satisfy this requirement. The
sp804_timer_init() macro creates a temporary instanciation of the
timer_ops_t structure on the fly and passes it to the generic
delay timer. When this temporary instanciation gets deallocated,
the generic delay timer is left with a pointer to invalid data.

This patch fixes this bug by statically allocating the SP804
timer_ops_t structure.

Change-Id: I8fbf75907583aef06701e3fd9fabe0b2c9bc95bf
2015-09-28 16:33:00 +01:00
Achin Gupta cdb8f1c87f Merge pull request #398 from achingupta/vk/fix_bakery_lock_size
Fix relocation of __PERCPU_BAKERY_LOCK_SIZE__ in PR #390
2015-09-28 14:39:45 +01:00
Vikram Kanigiri 7173f5f618 Fix relocation of __PERCPU_BAKERY_LOCK_SIZE__
When a platform port does not define PLAT_PERCPU_BAKERY_LOCK_SIZE, the total
memory that should be allocated per-cpu to accommodate all bakery locks is
calculated by the linker in bl31.ld.S. The linker stores this value in the
__PERCPU_BAKERY_LOCK_SIZE__ linker symbol. The runtime value of this symbol is
different from the link time value as the symbol is relocated into the current
section (.bss). This patch fixes this issue by marking the symbol as ABSOLUTE
which allows it to retain its correct value even at runtime.

The description of PLAT_PERCPU_BAKERY_LOCK_SIZE in the porting-guide.md has been
made clearer as well.

Change-Id: Ia0cfd42f51deaf739d792297e60cad5c6e6e610b
2015-09-25 16:35:10 +01:00
Achin Gupta a6ef882c0e Merge pull request #394 from achingupta/ag/ccn_driver
Support for ARM CoreLink CCN interconnects
2015-09-22 16:34:52 +01:00
Achin Gupta fd6007de64 Add a generic driver for ARM CCN IP
This patch adds a device driver which can be used to program the following
aspects of ARM CCN IP:

1. Specify the mapping between ACE/ACELite/ACELite+DVM/CHI master interfaces and
   Request nodes.
2. Add and remove master interfaces from the snoop and dvm
   domains.
3. Place the L3 cache in a given power state.
4. Configuring system adress map and enabling 3 SN striping mode of memory
   controller operation.

Change-Id: I0f665c6a306938e5b66f6a92f8549b529aa8f325
2015-09-14 22:09:40 +01:00
Vikram Kanigiri e3616819a9 Tegra: Perform cache maintenance on video carveout memory
Currently, the non-overlapping video memory carveout region is cleared after
disabling the MMU at EL3. If at any exception level the carveout region is being
marked as cacheable, this zeroing of memory will not have an affect on the
cached lines. Hence, we first invalidate the dirty lines and update the memory
and invalidate again so that both caches and memory is zeroed out.

Change-Id: If3b2d139ab7227f6799c0911d59e079849dc86aa
2015-09-14 22:09:40 +01:00
Achin Gupta 54dc71e7ec Make generic code work in presence of system caches
On the ARMv8 architecture, cache maintenance operations by set/way on the last
level of integrated cache do not affect the system cache. This means that such a
flush or clean operation could result in the data being pushed out to the system
cache rather than main memory. Another CPU could access this data before it
enables its data cache or MMU. Such accesses could be serviced from the main
memory instead of the system cache. If the data in the sysem cache has not yet
been flushed or evicted to main memory then there could be a loss of
coherency. The only mechanism to guarantee that the main memory will be updated
is to use cache maintenance operations to the PoC by MVA(See section D3.4.11
(System level caches) of ARMv8-A Reference Manual (Issue A.g/ARM DDI0487A.G).

This patch removes the reliance of Trusted Firmware on the flush by set/way
operation to ensure visibility of data in the main memory. Cache maintenance
operations by MVA are now used instead. The following are the broad category of
changes:

1. The RW areas of BL2/BL31/BL32 are invalidated by MVA before the C runtime is
   initialised. This ensures that any stale cache lines at any level of cache
   are removed.

2. Updates to global data in runtime firmware (BL31) by the primary CPU are made
   visible to secondary CPUs using a cache clean operation by MVA.

3. Cache maintenance by set/way operations are only used prior to power down.

NOTE: NON-UPSTREAM TRUSTED FIRMWARE CODE SHOULD MAKE EQUIVALENT CHANGES IN
ORDER TO FUNCTION CORRECTLY ON PLATFORMS WITH SUPPORT FOR SYSTEM CACHES.

Fixes ARM-software/tf-issues#205

Change-Id: I64f1b398de0432813a0e0881d70f8337681f6e9a
2015-09-14 22:09:40 +01:00
Achin Gupta 7dc28e9c6e Merge pull request #390 from vikramkanigiri/at/unify_bakery_locks_v2
Re-design bakery lock allocation and algorithm
2015-09-14 21:49:10 +01:00
Achin Gupta 84e1903689 Merge pull request #389 from vikramkanigiri/vk/css_rework
Add more configurability options in ARM platform port code
2015-09-14 21:47:22 +01:00
Jimmy Huang 2bab3d5273 mt8173: fix watchdog register setting
This patch corrects the watchdog register setting. To update watchdog
register, the watchdog mode key must be set to make the register
configurable.

Change-Id: I9ca98ea4012f7f220b116013461030de4638ce0b
Signed-off-by: Jimmy Huang <jimmy.huang@mediatek.com>
2015-09-14 14:35:20 +08:00
yt.lee 0ad1a9b329 mt8173: update spm suspend pcm codes
1. update suspend pcm code (add dummy apb read before mcusys power down)

BRANCH=none
BUG=none
TEST=verified

Change-Id: I2802cf8665fc1c8fe2304fd7d5f3eab9948b0b78
Signed-off-by: yt.lee <yt.lee@mediatek.com>
2015-09-14 14:35:15 +08:00
Vikram Kanigiri c3ec0b9ea4 Use unified bakery locks API in Mediatek port
This patch update Mediatek port to use the `DEFINE_BAKERY_LOCK` macro instead of
specifying the exact data structure to use for a bakery lock and the input
linker section that it should be allocated to.

Change-Id: I2116dbe27010bb46d7cc64fafef55c7240c4c721
2015-09-11 16:20:01 +01:00
Vikram Kanigiri e25e6f41f7 Update ARM platform ports to use new bakery lock apis.
This patch updates ARM platform ports to use the new unified bakery locks
API. The caller does not have to use a different bakery lock API depending upon
the value of the USE_COHERENT_MEM build option.

NOTE: THIS PATCH CAN BE USED AS A REFERENCE TO UPDATE OTHER PLATFORM PORTS.

Change-Id: I1b26afc7c9a9808a6040eb22f603d30192251da7
2015-09-11 16:19:39 +01:00
Andrew Thoelke ee7b35c4e1 Re-design bakery lock memory allocation and algorithm
This patch unifies the bakery lock api's across coherent and normal
memory implementation of locks by using same data type `bakery_lock_t`
and similar arguments to functions.

A separate section `bakery_lock` has been created and used to allocate
memory for bakery locks using `DEFINE_BAKERY_LOCK`. When locks are
allocated in normal memory, each lock for a core has to spread
across multiple cache lines. By using the total size allocated in a
separate cache line for a single core at compile time, the memory for
other core locks is allocated at link time by multiplying the single
core locks size with (PLATFORM_CORE_COUNT - 1). The normal memory lock
algorithm now uses lock address instead of the `id` in the per_cpu_data.
For locks allocated in coherent memory, it moves locks from
tzfw_coherent_memory to bakery_lock section.

The bakery locks are allocated as part of bss or in coherent memory
depending on usage of coherent memory. Both these regions are
initialised to zero as part of run_time_init before locks are used.
Hence, bakery_lock_init() is made an empty function as the lock memory
is already initialised to zero.

The above design lead to the removal of psci bakery locks from
non_cpu_power_pd_node to psci_locks.

NOTE: THE BAKERY LOCK API WHEN USE_COHERENT_MEM IS NOT SET HAS CHANGED.
THIS IS A BREAKING CHANGE FOR ALL PLATFORM PORTS THAT ALLOCATE BAKERY
LOCKS IN NORMAL MEMORY.

Change-Id: Ic3751c0066b8032dcbf9d88f1d4dc73d15f61d8b
2015-09-11 16:19:21 +01:00
Achin Gupta ab434b0554 Merge pull request #388 from achingupta/ag/spd_suspend_levels_v3
Pass the target suspend level to SPD suspend hooks
2015-09-11 12:19:21 +01:00
Vikram Kanigiri 883852ca0a Separate CSS security setup from SOC security setup
Currently, on ARM platforms(ex. Juno) non-secure access to specific
peripheral regions, config registers which are inside and outside CSS
is done in the soc_css_security_setup(). This patch separates the CSS
security setup from the SOC security setup in the css_security_setup().

The CSS security setup involves programming of the internal NIC to
provide access to regions inside the CSS. This is needed only in
Juno, hence Juno implements it in its board files as css_init_nic400().

Change-Id: I95a1fb9f13f9b18fa8e915eb4ae2f15264f1b060
2015-09-11 11:50:26 +01:00
Vikram Kanigiri 4b1439c5ae Define the Non-Secure timer frame ID for ARM platforms
On Juno and FVP platforms, the Non-Secure System timer corresponds
to frame 1. However, this is a platform-specific decision and it
shouldn't be hard-coded. Hence, this patch introduces
PLAT_ARM_NSTIMER_FRAME_ID which should be used by all ARM platforms
to specify the correct non-secure timer frame.

Change-Id: I6c3a905d7d89200a2f58c20ce5d1e1d166832bba
2015-09-11 11:39:22 +01:00
Vikram Kanigiri e86c1ff0c9 Re-factor definition of TZC-400 base address
This patch replaces the `ARM_TZC_BASE` constant with `PLAT_ARM_TZC_BASE` to
support different TrustZone Controller base addresses across ARM platforms.

Change-Id: Ie4e1c7600fd7a5875323c7cc35e067de0c6ef6dd
2015-09-11 11:37:38 +01:00
Achin Gupta f1054c93cc Pass the target suspend level to SPD suspend hooks
In certain Trusted OS implementations it is a requirement to pass them the
highest power level which will enter a power down state during a PSCI
CPU_SUSPEND or SYSTEM_SUSPEND API invocation. This patch passes this power level
to the SPD in the "max_off_pwrlvl" parameter of the svc_suspend() hook.

Currently, the highest power level which was requested to be placed in a low
power state (retention or power down) is passed to the SPD svc_suspend_finish()
hook. This hook is called after emerging from the low power state. It is more
useful to pass the highest power level which was powered down instead. This
patch does this by changing the semantics of the parameter passed to an SPD's
svc_suspend_finish() hook. The name of the parameter has been changed from
"suspend_level" to "max_off_pwrlvl" as well. Same changes have been made to the
parameter passed to the tsp_cpu_resume_main() function.

NOTE: THIS PATCH CHANGES THE SEMANTICS OF THE EXISTING "svc_suspend_finish()"
      API BETWEEN THE PSCI AND SPD/SP IMPLEMENTATIONS. THE LATTER MIGHT NEED
      UPDATES TO ENSURE CORRECT BEHAVIOUR.

Change-Id: If3a9d39b13119bbb6281f508a91f78a2f46a8b90
2015-09-10 15:16:45 +01:00
danh-arm 604d5da6f2 Merge pull request #383 from vikramkanigiri/vk/tf-issues-314-v1
Ensure BL2 security state is secure
2015-09-02 16:50:44 +01:00
Vikram Kanigiri a2f8b16650 Ensure BL2 security state is secure
BL2 loads secure runtime code(BL3-1, BL3-2) and hence it has to
run in secure world otherwise BL3-1/BL3-2 have to execute from
non-secure memory. Hence, This patch removes the change_security_state()
call in bl1_run_bl2() and replaces it with an assert to confirm
the BL2 as secure.

Fixes ARM-software/tf-issues#314

Change-Id: I611b83f5c4090e58a76a2e950b0d797b46df3c29
2015-09-02 13:48:45 +01:00
danh-arm 02516ae42d Merge pull request #382 from vikramkanigiri/vk/tf-issues-312
Configure all secure interrupts on ARM platforms
2015-09-02 12:29:48 +01:00
danh-arm dec806be9d Merge pull request #381 from vikramkanigiri/hl/gic_v3
Remove EL2/EL1 GICv3 register updates
2015-09-02 12:23:06 +01:00
Vikram Kanigiri a7270d35d7 Configure all secure interrupts on ARM platforms
ARM TF configures all interrupts as non-secure except those which
are present in irq_sec_array. This patch updates the irq_sec_array
with the missing secure interrupts for ARM platforms.

It also updates the documentation to be inline with the latest
implementation.

Fixes ARM-software/tf-issues#312

Change-Id: I39956c56a319086e3929d1fa89030b4ec4b01fcc
2015-09-01 14:11:09 +01:00
Vikram Kanigiri 889fce4259 Remove EL2/EL1 GICv3 register updates
From Linux 3.17 onwards, the mainline kernel has support for GICv3
systems and if EL3 exists, it only needs to initialise ICC_SRE_EL3.SRE
and ICC_SRE_EL3.Enable to 1. Hence, this patch removes the redundant
updates of ICC_SRE_EL2 and ICC_PMR_EL1.

NOTE: For partner software's which enter kernel in EL1,
ICC_SRE_EL2.Enable and ICC_SRE_EL2.SRE bit needs to be set to 1
in EL2 before jumping to linux.

Change-Id: I09ed47869351b08a3b034735f532bc677eaa6917
2015-09-01 12:44:00 +01:00
danh-arm f81bdb6e76 Merge pull request #375 from vwadekar/clear-videomem-region-v2
Tegra: fix logic to clear videomem regions
2015-09-01 12:31:30 +01:00
Varun Wadekar d49b9c8088 Tegra: fix logic to clear videomem regions
The previous logic in the memctrl driver was not catering to cases
where the new memory region lied inside the older region. This patch
fixes the if/elseif/elseif logic in the driver to take care of this
case.

Reported by: Vikram Kanigiri <vikram.kanigiri@arm.com>
Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-08-26 15:57:56 +05:30
Achin Gupta e04723e213 Merge pull request #371 from vwadekar/retention-entry-v3
Retention entry v3
2015-08-25 22:49:04 +01:00
Varun Wadekar b42192bcbd Tegra210: wait for 512 timer ticks before retention entry
This patch programs the CPUECTLR_EL1 and L2ECTLR_EL1 registers,
so that the core waits for 512 generic timer CNTVALUEB ticks before
entering retention state, after executing a WFI instruction.

This functionality is configurable and can be enabled for platforms
by setting the newly defined 'ENABLE_L2_DYNAMIC_RETENTION' and
'ENABLE_CPU_DYNAMIC_RETENTION' flag.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-08-24 21:34:28 +05:30
Varun Wadekar e0d913c786 Add macros for retention control in Cortex-A53/A57
This patch adds macros suitable for programming the Advanced
SIMD/Floating-point (only Cortex-A53), CPU and L2 dynamic
retention control policy in the CPUECTLR_EL1 and L2ECTLR
registers.

Signed-off-by: Varun Wadekar <vwadekar@nvidia.com>
2015-08-24 21:30:21 +05:30
danh-arm 468f808cb8 Merge pull request #368 from jcastillo-arm/jc/genfw/1126
TBB: abort boot if BL3-2 cannot be authenticated
2015-08-21 15:28:30 +01:00
danh-arm 42ed52d24e Merge pull request #367 from soby-mathew/sm/mig_guide_fix
docs: Fixes to platform-migration-guide.md
2015-08-20 16:58:54 +01:00
Juan Castillo fedbc0497b TBB: abort boot if BL3-2 cannot be authenticated
BL3-2 image (Secure Payload) is optional. If the image cannot be
loaded a warning message is printed and the boot process continues.
According to the TBBR document, this behaviour should not apply in
case of an authentication error, where the boot process should be
aborted.

This patch modifies the load_auth_image() function to distinguish
between a load error and an authentication error. The caller uses
the return value to abort the boot process or continue.

In case of authentication error, the memory region used to store
the image is wiped clean.

Change-Id: I534391d526d514b2a85981c3dda00de67e0e7992
2015-08-20 16:44:02 +01:00
Soby Mathew 76f01db025 docs: Fixes to platform-migration-guide.md
This patch corrects some typos in the platform migration guide. More                                                                                                                                                                                                              
importantly, the commit ID of the patch that implements migration of ARM
Reference platforms to the new platform API has been corrected.

Change-Id: Ib0109ea42c3d2bad2c6856ab725862652da7f3c8
2015-08-18 14:59:25 +01:00
danh-arm b0b4855f74 Merge pull request #365 from mtk09422/plat_topology
mt8173: Fix cluster 0 core count
2015-08-18 12:40:22 +01:00
danh-arm 6ab9bbbc3a Merge pull request #364 from mtk09422/spm_suspend
mt8173: update spm wake_src setting
2015-08-18 12:40:16 +01:00
danh-arm 01f1ebbb65 Merge pull request #362 from jcastillo-arm/jc/inline
Fix build error with optimizations disabled (-O0)
2015-08-18 10:33:40 +01:00
Jimmy Huang c4a99e8949 mt8173: Fix cluster 0 core count
Use constant macro defined in platform_def.h to replace hardcoded value.
This patch fix following assert in new psci-1.0 framework.

ASSERT: populate_power_domain_tree <183> : j == PLATFORM_CORE_COUNT

Change-Id: I9b7eda525479464a8c3805b6fe14ffb10debaf72
Signed-off-by: Jimmy Huang <jimmy.huang@mediatek.com>
2015-08-18 16:32:09 +08:00