imx: imx_snvs: Add an SNVS core functionality

This patch adds snvs.c with a imx_snvs_init() function.

imx_snvs_init() sets up permissions of the RTC via the SNVS HPCOMR.

During previous work with OPTEE on the i.MX7 part we discovered that prior
to switching from secure-world to normal-world it is required to apply more
permissive permissions than are defaulted to in order for Linux to be able
to access the RTC and CAAM functionality in general.

This patch pertains to fixing the RTC permissions by way of the
HPCOMR.NPSWA_EN bit.

Once set non-privileged code aka Linux-kernel code has permissions to
access the SNVS where the RTC resides.

Perform that permissions fix in imx_snvs_init() now, with a later patch making
the call from our platform setup code.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
This commit is contained in:
Bryan O'Donoghue 2018-05-25 16:52:03 +01:00
parent a60ca3b4d5
commit f7ea6d5223
1 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,21 @@
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <mmio.h>
#include <imx_regs.h>
#include <imx_snvs.h>
void imx_snvs_init(void)
{
struct snvs *snvs = (struct snvs *)SNVS_BASE;
uintptr_t addr;
uint32_t val;
addr = (uintptr_t)&snvs->hpcomr;
val = mmio_read_32(addr);
val |= HPCOMR_NPSWA_EN;
mmio_write_32(addr, val);
}