msm: pil-q6v5-lpass: Add support for secure image loading
Use the scm-pas APIs to authenticate and securely boot signed images
when supported. This is very similar to secure peripheral support
present in previous PIL drivers.
Change-Id: I3b6be69ad2f30ff5ba8c5de93051276936a1ab44
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
diff --git a/arch/arm/mach-msm/pil-q6v5-lpass.c b/arch/arm/mach-msm/pil-q6v5-lpass.c
index 44d8bc6..ed072ea 100644
--- a/arch/arm/mach-msm/pil-q6v5-lpass.c
+++ b/arch/arm/mach-msm/pil-q6v5-lpass.c
@@ -21,6 +21,7 @@
#include <mach/clk.h>
#include "peripheral-loader.h"
#include "pil-q6v5.h"
+#include "scm-pas.h"
#define QDSP6SS_RST_EVB 0x010
#define PROXY_TIMEOUT_MS 10000
@@ -122,6 +123,30 @@
.shutdown = pil_lpass_shutdown,
};
+static int pil_lpass_init_image_trusted(struct pil_desc *pil,
+ const u8 *metadata, size_t size)
+{
+ return pas_init_image(PAS_Q6, metadata, size);
+}
+
+static int pil_lpass_reset_trusted(struct pil_desc *pil)
+{
+ return pas_auth_and_reset(PAS_Q6);
+}
+
+static int pil_lpass_shutdown_trusted(struct pil_desc *pil)
+{
+ return pas_shutdown(PAS_Q6);
+}
+
+static struct pil_reset_ops pil_lpass_ops_trusted = {
+ .init_image = pil_lpass_init_image_trusted,
+ .proxy_vote = pil_q6v5_make_proxy_votes,
+ .proxy_unvote = pil_q6v5_remove_proxy_votes,
+ .auth_and_reset = pil_lpass_reset_trusted,
+ .shutdown = pil_lpass_shutdown_trusted,
+};
+
static int __devinit pil_lpass_driver_probe(struct platform_device *pdev)
{
struct q6v5_data *drv;
@@ -155,6 +180,14 @@
if (IS_ERR(drv->reg_clk))
return PTR_ERR(drv->reg_clk);
+ if (pas_supported(PAS_Q6) > 0) {
+ desc->ops = &pil_lpass_ops_trusted;
+ dev_info(&pdev->dev, "using secure boot\n");
+ } else {
+ desc->ops = &pil_lpass_ops;
+ dev_info(&pdev->dev, "using non-secure boot\n");
+ }
+
drv->pil = msm_pil_register(desc);
if (IS_ERR(drv->pil))
return PTR_ERR(drv->pil);