u-boot/arch/arm/mach-imx
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
..
mx2 mx25: Select the ESDHC_A001 erratum 2017-11-07 10:13:00 +01:00
mx5 arm: imx: mx53loco: remove usage of mx53_dram_size 2018-02-04 12:00:58 +01:00
mx6 imx: board: Add support for the K+P's kp_imx6q_tpc board 2018-04-15 11:47:19 +02:00
mx7 imx: mx7: snvs: Add an SNVS init routine 2018-04-15 11:48:44 +02:00
mx7ulp arm: imx: Rework i.MX specific commands to be excluded from SPL 2018-01-12 14:28:04 +01:00
mx8m imx: mx8m: add soc related settings and files 2018-02-04 12:00:58 +01:00
mxs arm: imx: mx28: Move MX28 selection to Kconfig 2018-02-08 10:17:17 -05:00
cache.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cmd_bmode.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cmd_dek.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cmd_hdmidet.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
cpu.c imx: cpu: support get_boot_device for i.MX8M 2018-02-04 12:00:58 +01:00
ddrmc-vf610.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
hab.c imx: hab: Provide hab_auth_img_or_fail command 2018-04-15 11:44:13 +02:00
i2c-mxv7.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
imx_bootaux.c imx: bootaux: support i.MX8M 2018-02-04 12:00:58 +01:00
init.c imx: Remove boolean parameter from wdog powerdown function 2017-11-27 10:34:49 +01:00
iomux-v3.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
Kconfig imx: introduce CONFIG_GPT_TIMER 2018-01-08 17:33:06 +01:00
mac.c imx: refactor imx_get_mac_from_fuse 2018-02-04 12:00:58 +01:00
Makefile imx: makefile: compile files for i.MX8M 2018-02-04 12:00:58 +01:00
misc.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
mmc_env.c imx: mx7: move mmc env code to mmc_env.c 2018-02-04 12:00:58 +01:00
rdc-sema.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
sata.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
sip.c imx: add sip function 2018-02-04 12:00:58 +01:00
speed.c imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
spl.c imx7: spl: Check for Serial Downloader in spl_boot_device 2018-03-29 17:33:12 +02:00
spl_sd.cfg imx: reorganize IMX code as other SOCs 2017-07-12 10:17:44 +02:00
syscounter.c imx: syscounter: make sure asm is volatile 2018-03-09 13:06:14 +01:00
timer.c imx: timer: don't clear the GPT control register multiple times 2017-08-29 09:47:28 +02:00
video.c env: Rename getenv/_f() to env_get() 2017-08-16 08:30:24 -04:00