msm: pil: Implement tzapps support as a platform driver
Create a platform driver to manage the tzapps support instead of
having a module that exists for any 8660 device. This allows us
to add platform devices when the configuration actually supports
it and have pil_get() fail otherwise.
Change-Id: I22707d8947ef360522edb1cd9ee6792cbd8fe797
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
diff --git a/arch/arm/mach-msm/Kconfig b/arch/arm/mach-msm/Kconfig
index d80586e..66c3af3 100644
--- a/arch/arm/mach-msm/Kconfig
+++ b/arch/arm/mach-msm/Kconfig
@@ -1619,6 +1619,16 @@
Riva is the wireless subsystem processor used in bluetooth, wireless
LAN, and FM software applications.
+config MSM_PIL_TZAPPS
+ tristate "TZApps Boot Support"
+ depends on MSM_PIL
+ help
+ Support for booting and shutting down TZApps.
+
+ TZApps is an image that runs in the secure processor state. It is
+ used to decrypt data and perform secure operations on the behalf of
+ the kernel.
+
config MSM_SCM
bool "Secure Channel Manager (SCM) support"
default n
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 44d9a74..e09e861 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -75,6 +75,7 @@
obj-$(CONFIG_MSM_PIL_QDSP6V3) += pil-q6v3.o
obj-$(CONFIG_MSM_PIL_QDSP6V4) += pil-q6v4.o
obj-$(CONFIG_MSM_PIL_RIVA) += pil-riva.o
+obj-$(CONFIG_MSM_PIL_TZAPPS) += pil-tzapps.o
obj-$(CONFIG_ARCH_QSD8X50) += sirc.o
obj-$(CONFIG_ARCH_FSM9XXX) += sirc-fsm9xxx.o
obj-$(CONFIG_MSM_FIQ_SUPPORT) += fiq_glue.o
diff --git a/arch/arm/mach-msm/board-8930.c b/arch/arm/mach-msm/board-8930.c
index 6eba2f9..dfe0b45 100644
--- a/arch/arm/mach-msm/board-8930.c
+++ b/arch/arm/mach-msm/board-8930.c
@@ -1577,6 +1577,7 @@
&msm_8960_q6_mss_fw,
&msm_8960_q6_mss_sw,
&msm_8960_riva,
+ &msm_pil_tzapps,
&msm8960_device_qup_spi_gsbi1,
&msm8960_device_qup_i2c_gsbi3,
&msm8960_device_qup_i2c_gsbi4,
diff --git a/arch/arm/mach-msm/board-8960.c b/arch/arm/mach-msm/board-8960.c
index dbda923..d29eb0d 100644
--- a/arch/arm/mach-msm/board-8960.c
+++ b/arch/arm/mach-msm/board-8960.c
@@ -1758,6 +1758,7 @@
&msm_8960_q6_mss_fw,
&msm_8960_q6_mss_sw,
&msm_8960_riva,
+ &msm_pil_tzapps,
&msm8960_device_otg,
&msm8960_device_gadget_peripheral,
&msm_device_hsusb_host,
diff --git a/arch/arm/mach-msm/board-msm8x60.c b/arch/arm/mach-msm/board-msm8x60.c
index 53b0fc0..5acb83d 100644
--- a/arch/arm/mach-msm/board-msm8x60.c
+++ b/arch/arm/mach-msm/board-msm8x60.c
@@ -5088,6 +5088,7 @@
&msm_device_smd,
&msm_device_uart_dm12,
&msm_pil_q6v3,
+ &msm_pil_tzapps,
#ifdef CONFIG_I2C_QUP
&msm_gsbi3_qup_i2c_device,
&msm_gsbi4_qup_i2c_device,
diff --git a/arch/arm/mach-msm/devices-8960.c b/arch/arm/mach-msm/devices-8960.c
index 57465ac..92197bd 100644
--- a/arch/arm/mach-msm/devices-8960.c
+++ b/arch/arm/mach-msm/devices-8960.c
@@ -947,6 +947,11 @@
.resource = msm_8960_riva_resources,
};
+struct platform_device msm_pil_tzapps = {
+ .name = "pil_tzapps",
+ .id = -1,
+};
+
struct platform_device msm_device_smd = {
.name = "msm_smd",
.id = -1,
diff --git a/arch/arm/mach-msm/devices-msm8x60.c b/arch/arm/mach-msm/devices-msm8x60.c
index eea7bc4..f1f6e64 100644
--- a/arch/arm/mach-msm/devices-msm8x60.c
+++ b/arch/arm/mach-msm/devices-msm8x60.c
@@ -194,6 +194,11 @@
.resource = msm_8660_q6_resources,
};
+struct platform_device msm_pil_tzapps = {
+ .name = "pil_tzapps",
+ .id = -1,
+};
+
static struct resource msm_uart1_dm_resources[] = {
{
.start = MSM_UART1DM_PHYS,
diff --git a/arch/arm/mach-msm/devices.h b/arch/arm/mach-msm/devices.h
index 0d6aa09..00ff5e8 100644
--- a/arch/arm/mach-msm/devices.h
+++ b/arch/arm/mach-msm/devices.h
@@ -178,6 +178,7 @@
extern struct platform_device msm_cpudai_incall_record_tx;
extern struct platform_device msm_pil_q6v3;
+extern struct platform_device msm_pil_tzapps;
extern struct platform_device msm_8960_q6_lpass;
extern struct platform_device msm_8960_q6_mss_fw;
extern struct platform_device msm_8960_q6_mss_sw;
diff --git a/arch/arm/mach-msm/peripheral-reset-8960.c b/arch/arm/mach-msm/peripheral-reset-8960.c
index d01851e..ad266f6 100644
--- a/arch/arm/mach-msm/peripheral-reset-8960.c
+++ b/arch/arm/mach-msm/peripheral-reset-8960.c
@@ -76,22 +76,6 @@
return pas_shutdown(PAS_DSPS);
}
-static int init_image_tzapps(struct pil_desc *pil, const u8 *metadata,
- size_t size)
-{
- return pas_init_image(PAS_TZAPPS, metadata, size);
-}
-
-static int reset_tzapps(struct pil_desc *pil)
-{
- return pas_auth_and_reset(PAS_TZAPPS);
-}
-
-static int shutdown_tzapps(struct pil_desc *pil)
-{
- return pas_shutdown(PAS_TZAPPS);
-}
-
struct pil_reset_ops pil_dsps_ops = {
.init_image = init_image_dsps_untrusted,
.verify_blob = verify_blob,
@@ -99,13 +83,6 @@
.shutdown = shutdown_dsps_untrusted,
};
-struct pil_reset_ops pil_tzapps_ops = {
- .init_image = init_image_tzapps,
- .verify_blob = verify_blob,
- .auth_and_reset = reset_tzapps,
- .shutdown = shutdown_tzapps,
-};
-
static struct platform_device pil_dsps = {
.name = "pil_dsps",
};
@@ -116,16 +93,6 @@
.ops = &pil_dsps_ops,
};
-static struct platform_device pil_tzapps = {
- .name = "pil_tzapps",
-};
-
-static struct pil_desc pil_tzapps_desc = {
- .name = "tzapps",
- .dev = &pil_tzapps.dev,
- .ops = &pil_tzapps_ops,
-};
-
static void __init use_secure_pil(void)
{
if (pas_supported(PAS_DSPS) > 0) {
@@ -148,8 +115,6 @@
BUG_ON(platform_device_register(&pil_dsps));
BUG_ON(msm_pil_register(&pil_dsps_desc));
- BUG_ON(platform_device_register(&pil_tzapps));
- BUG_ON(msm_pil_register(&pil_tzapps_desc));
return 0;
}
diff --git a/arch/arm/mach-msm/peripheral-reset.c b/arch/arm/mach-msm/peripheral-reset.c
index 2d60a7e..20ac429 100644
--- a/arch/arm/mach-msm/peripheral-reset.c
+++ b/arch/arm/mach-msm/peripheral-reset.c
@@ -298,22 +298,6 @@
return 0;
}
-static int init_image_playready(struct pil_desc *pil, const u8 *metadata,
- size_t size)
-{
- return pas_init_image(PAS_PLAYREADY, metadata, size);
-}
-
-static int reset_playready(struct pil_desc *pil)
-{
- return pas_auth_and_reset(PAS_PLAYREADY);
-}
-
-static int shutdown_playready(struct pil_desc *pil)
-{
- return pas_shutdown(PAS_PLAYREADY);
-}
-
struct pil_reset_ops pil_modem_ops = {
.init_image = init_image_modem_untrusted,
.verify_blob = verify_blob,
@@ -328,13 +312,6 @@
.shutdown = shutdown_dsps_untrusted,
};
-struct pil_reset_ops pil_playready_ops = {
- .init_image = init_image_playready,
- .verify_blob = verify_blob,
- .auth_and_reset = reset_playready,
- .shutdown = shutdown_playready,
-};
-
static struct platform_device pil_modem = {
.name = "pil_modem",
};
@@ -346,16 +323,6 @@
.ops = &pil_modem_ops,
};
-static struct platform_device pil_playready = {
- .name = "pil_playready",
-};
-
-static struct pil_desc pil_playready_desc = {
- .name = "tzapps",
- .dev = &pil_playready.dev,
- .ops = &pil_playready_ops,
-};
-
static struct platform_device pil_dsps = {
.name = "pil_dsps",
};
@@ -390,8 +357,6 @@
BUG_ON(platform_device_register(&pil_modem));
BUG_ON(msm_pil_register(&pil_modem_desc));
- BUG_ON(platform_device_register(&pil_playready));
- BUG_ON(msm_pil_register(&pil_playready_desc));
if (machine_is_msm8x60_fluid())
pil_dsps_desc.name = "dsps_fluid";
diff --git a/arch/arm/mach-msm/pil-tzapps.c b/arch/arm/mach-msm/pil-tzapps.c
new file mode 100644
index 0000000..90ac1d9
--- /dev/null
+++ b/arch/arm/mach-msm/pil-tzapps.c
@@ -0,0 +1,96 @@
+/* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/elf.h>
+#include <linux/err.h>
+
+#include "peripheral-loader.h"
+#include "scm-pas.h"
+
+static int nop_verify_blob(struct pil_desc *pil, u32 phy_addr, size_t size)
+{
+ return 0;
+}
+
+static int pil_tzapps_init_image(struct pil_desc *pil, const u8 *metadata,
+ size_t size)
+{
+ return pas_init_image(PAS_TZAPPS, metadata, size);
+}
+
+static int pil_tzapps_reset(struct pil_desc *pil)
+{
+ return pas_auth_and_reset(PAS_TZAPPS);
+}
+
+static int pil_tzapps_shutdown(struct pil_desc *pil)
+{
+ return pas_shutdown(PAS_TZAPPS);
+}
+
+static struct pil_reset_ops pil_tzapps_ops = {
+ .init_image = pil_tzapps_init_image,
+ .verify_blob = nop_verify_blob,
+ .auth_and_reset = pil_tzapps_reset,
+ .shutdown = pil_tzapps_shutdown,
+};
+
+static int __devinit pil_tzapps_driver_probe(struct platform_device *pdev)
+{
+ struct pil_desc *desc;
+
+ if (pas_supported(PAS_TZAPPS) < 0)
+ return -ENOSYS;
+
+ desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL);
+ if (!desc)
+ return -ENOMEM;
+
+ desc->name = "tzapps";
+ desc->dev = &pdev->dev;
+ desc->ops = &pil_tzapps_ops;
+ if (msm_pil_register(desc))
+ return -EINVAL;
+ return 0;
+}
+
+static int __devexit pil_tzapps_driver_exit(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static struct platform_driver pil_tzapps_driver = {
+ .probe = pil_tzapps_driver_probe,
+ .remove = __devexit_p(pil_tzapps_driver_exit),
+ .driver = {
+ .name = "pil_tzapps",
+ .owner = THIS_MODULE,
+ },
+};
+
+static int __init pil_tzapps_init(void)
+{
+ return platform_driver_register(&pil_tzapps_driver);
+}
+module_init(pil_tzapps_init);
+
+static void __exit pil_tzapps_exit(void)
+{
+ platform_driver_unregister(&pil_tzapps_driver);
+}
+module_exit(pil_tzapps_exit);
+
+MODULE_DESCRIPTION("Support for booting TZApps images");
+MODULE_LICENSE("GPL v2");
diff --git a/arch/arm/mach-msm/scm-pas.h b/arch/arm/mach-msm/scm-pas.h
index 4a3f4c5..67a0992 100644
--- a/arch/arm/mach-msm/scm-pas.h
+++ b/arch/arm/mach-msm/scm-pas.h
@@ -16,14 +16,12 @@
PAS_MODEM,
PAS_Q6,
PAS_DSPS,
- PAS_PLAYREADY,
+ PAS_TZAPPS,
PAS_MODEM_SW,
PAS_MODEM_FW,
PAS_RIVA,
};
-#define PAS_TZAPPS PAS_PLAYREADY
-
extern int pas_init_image(enum pas_id id, const u8 *metadata, size_t size);
extern int pas_auth_and_reset(enum pas_id id);
extern int pas_shutdown(enum pas_id id);