summaryrefslogtreecommitdiffstats
path: root/drivers/hab
diff options
context:
space:
mode:
authorRoland Hieber <r.hieber@pengutronix.de>2018-11-29 14:42:08 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-12-05 08:47:50 +0100
commit8fc60229cd50eba3a17f2a3b85bc698a3747c517 (patch)
treea711c3dea7f657184e59edf1505e33317305de51 /drivers/hab
parent620cd45ac1b97fb0f5cf68be309c6f45cc53cc6a (diff)
downloadbarebox-8fc60229cd50eba3a17f2a3b85bc698a3747c517.tar.gz
barebox-8fc60229cd50eba3a17f2a3b85bc698a3747c517.tar.xz
i.MX: HABv4: always print HAB status at boot time
Currently, board code needs to call habv4_get_status() explicitely, but there is no reason that it cannot be called automatically at startup when HABv4 is enabled. This way the call cannot be forgotten and we can make sure to report all potentially occuring HAB warnings and errors. Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/hab')
-rw-r--r--drivers/hab/habv3.c4
-rw-r--r--drivers/hab/habv4.c46
2 files changed, 50 insertions, 0 deletions
diff --git a/drivers/hab/habv3.c b/drivers/hab/habv3.c
index 82ae245f8a..47d3caf864 100644
--- a/drivers/hab/habv3.c
+++ b/drivers/hab/habv3.c
@@ -78,5 +78,9 @@ int imx_habv3_get_status(uint32_t status)
int imx25_hab_get_status(void)
{
+ if (!cpu_is_mx25())
+ return 0;
+
return imx_habv3_get_status(readl(IOMEM(0x780018d4)));
}
+postmmu_initcall(imx25_hab_get_status);
diff --git a/drivers/hab/habv4.c b/drivers/hab/habv4.c
index aa9506c022..ca95c01e7b 100644
--- a/drivers/hab/habv4.c
+++ b/drivers/hab/habv4.c
@@ -20,6 +20,7 @@
#include <common.h>
#include <hab.h>
+#include <init.h>
#include <types.h>
#include <mach/generic.h>
@@ -501,9 +502,54 @@ int imx6_hab_get_status(void)
return -EINVAL;
}
+static int init_imx6_hab_get_status(void)
+{
+ int ret = 0;
+
+ if (!cpu_is_mx6())
+ /* can happen in multi-image builds and is not an error */
+ return 0;
+
+ ret = imx6_hab_get_status();
+
+ /*
+ * Nobody will check the return value if there were HAB errors, but the
+ * initcall will fail spectaculously with a strange error message.
+ */
+ if (ret == -EPERM)
+ return 0;
+ return ret;
+}
+
+/*
+ * Need to run before MMU setup because i.MX6 ROM code is mapped near 0x0,
+ * which will no longer be accessible when the MMU sets the zero page to
+ * faulting.
+ */
+postconsole_initcall(init_imx6_hab_get_status);
+
int imx28_hab_get_status(void)
{
const struct habv4_rvt *rvt = (void *)HABV4_RVT_IMX28;
return habv4_get_status(rvt);
}
+
+static int init_imx28_hab_get_status(void)
+{
+ int ret = 0;
+
+ if (!cpu_is_mx28())
+ /* can happen in multi-image builds and is not an error */
+ return 0;
+
+ ret = imx28_hab_get_status();
+
+ /* nobody will check the return value if there were HAB errors, but the
+ * initcall will fail spectaculously with a strange error message. */
+ if (ret == -EPERM)
+ return 0;
+ return ret;
+}
+/* i.MX28 ROM code can be run after MMU setup to make use of caching */
+postmmu_initcall(init_imx28_hab_get_status);