u-boot-brain/arch/arm
Bryan O'Donoghue 723f8359c1 imx: mx7: snvs: Add an SNVS init routine
Working with HAB on the i.MX7 we've encountered a case where a board that
successfully authenticates u-boot when booting Linux via OPTEE subsequently
fails to properly bring up the RTC.

The RTC registers live in the low-power block of the Secure Non-Volatile
Storage (SNVS) block.

The root cause of the error has been traced to the HAB handing off the
SNVS-RTC in a state where HPCOMR::NPSWA_EN = 0 in other words where the
Non-Privileged Software Access Enable bit is zero. In ordinary
circumstances this is OK since we typically do not run in TZ mode, however
when we boot via HAB and enablng TrustZone, it is required to set
HPCOMR::NPSWA_EN = 1 in order for the upstream Linux driver to have
sufficient permissions to manipulate the SNVS-LP block.

On our reference board it is the difference between Linux doing this:

root@imx7s-warp-mbl:~# dmesg | grep rtc
snvs_rtc_enable read 0x00000000 from SNVS_LPLR @ 0x00000034
snvs_rtc_enable read 0x00000021 from SNVS_LPCR @ 0x00000038
snvs_rtc_enable read 0x00000000 from SNVS_HPLR @ 0x00000000
snvs_rtc_enable read 0x80002100 from SNVS_HPCOMR @ 0x00000004
snvs_rtc 30370000.snvs:snvs-rtc-lp: rtc core: registered
         30370000.snvs:snvs-rtc-lp as rtc0
snvs_rtc 30370000.snvs:snvs-rtc-lp: setting system clock to2018-04-01 00:51:04 UTC (1522543864)

and doing this:

root@imx7s-warp-mbl:~# dmesg | grep rtc
snvs_rtc_enable read 0x00000000 from SNVS_LPLR @ 0x00000034
snvs_rtc_enable read 0x00000020 from SNVS_LPCR @ 0x00000038
snvs_rtc_enable read 0x00000001 from SNVS_HPLR @ 0x00000000
snvs_rtc_enable read 0x00002020 from SNVS_HPCOMR @ 0x00000004
snvs_rtc 30370000.snvs:snvs-rtc-lp: failed to enable rtc -110
snvs_rtc: probe of 30370000.snvs:snvs-rtc-lp failed with error -110
hctosys: unable to open rtc device (rtc0)

Note bit 1 of LPCR is not set in the second case and is set in the first
case and that bit 31 of HPCOMR is set in the second case but not in the
first.

Setting NPSWA_EN in HPCOMR allows us to boot through enabling TrustZone
and continue onto the kernel. The kernel then has the necessary permissions
to set LPCR::SRTC_ENV (RTC enable in the LP command register) whereas in
contrast - in the failing case the non-privileged kernel cannot do so.

This patch adds a simple init_snvs() call which sets the permission-bit
called from soc.c for the i.MX7. It may be possible, safe and desirable to
perform this on other i.MX processors but for now this is only tested on
i.MX7 as working.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
2018-04-15 11:48:44 +02:00
..
cpu drivers: i2c: mxc: Update SYS_I2C_MXC_I2C support in Kconfig 2018-03-29 17:20:42 +02:00
dts ARM: dts: imx6ull: add wdog3 2018-03-29 17:29:11 +02:00
include imx: mx7: snvs: Add an SNVS init routine 2018-04-15 11:48:44 +02:00
lib libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mach-aspeed aspeed: Refactor SCU to use consistent mask & shift 2017-05-08 11:57:35 -04:00
mach-at91 spl: eMMC/SD: Provide one __weak spl_boot_mode() function 2018-02-07 22:06:18 -05:00
mach-bcm283x bcm283x: Add pinctrl driver 2018-01-28 12:27:32 -05:00
mach-davinci spl: eMMC/SD: Provide one __weak spl_boot_mode() function 2018-02-07 22:06:18 -05:00
mach-exynos usb: net: migrate USB Ethernet adapters to Kconfig 2017-09-08 10:23:00 -04:00
mach-highbank
mach-imx imx: mx7: snvs: Add an SNVS init routine 2018-04-15 11:48:44 +02:00
mach-integrator env: Convert CONFIG_ENV_IS_IN... to a choice 2017-08-15 20:50:01 -04:00
mach-keystone cmd: ti: Generalize cmd_ddr3 command 2018-01-19 15:49:26 -05:00
mach-kirkwood spi: Migrate CONFIG_KIRKWOOD_SPI to Kconfig 2018-02-13 23:01:44 -05:00
mach-meson libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mach-mvebu libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mach-omap2 libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mach-orion5x spl: add hierarchical defaults for SPL_LDSCRIPT 2017-08-13 17:12:37 +02:00
mach-qemu ARM: qemu-arm: Add support for AArch64 2018-01-19 15:49:30 -05:00
mach-rmobile ARM: rmobile: Add R8A77965 M3N IDs 2018-03-05 10:59:37 +01:00
mach-rockchip rockchip: rk3288: Fix wrong TPL_TEXT_BASE 2018-02-24 18:47:23 +01:00
mach-s5pc1xx
mach-snapdragon db820c: add qualcomm dragonboard 820C support 2018-01-15 16:29:02 -05:00
mach-socfpga libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mach-sti board: Add STMicroelectronics STiH410-B2260 support 2017-03-14 20:40:21 -04:00
mach-stm32 board: stm32: Fix stm32f746-disco boot 2018-01-29 12:48:30 -05:00
mach-sunxi spl: eMMC/SD: Provide one __weak spl_boot_mode() function 2018-02-07 22:06:18 -05:00
mach-tegra aes: Allow non-zero initialization vector 2018-01-29 12:50:13 -05:00
mach-uniphier libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h> 2018-03-05 10:16:28 -05:00
mach-versatile
mach-zynq mmc: Added Kconfig support for CONFIG_ZYNQ_SDHCI_MAX_FREQ 2018-03-01 16:44:10 +01:00
thumb1/include/asm/proc-armv
config.mk binman: arm: Include the binman symbol table 2017-12-12 19:53:45 -07:00
Kconfig ARM: Kconfig: Move TI_SECURE_DEVICE to a common area 2018-02-23 10:21:41 -05:00
Kconfig.debug
Makefile imx: add i.MX8M into Kconfig 2018-02-04 12:00:58 +01:00