blob: b6e5343e9a3ba89c4617d45b1ee826767e08c3eb [file] [log] [blame]
Stephen Boyd6d67d252011-09-27 11:50:05 -07001/* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved.
Stephen Boydd89eebe2011-09-28 23:28:11 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#include <linux/init.h>
14#include <linux/module.h>
15#include <linux/platform_device.h>
16#include <linux/elf.h>
17#include <linux/err.h>
18
19#include "peripheral-loader.h"
20#include "scm-pas.h"
21
22static int nop_verify_blob(struct pil_desc *pil, u32 phy_addr, size_t size)
23{
24 return 0;
25}
26
27static int pil_tzapps_init_image(struct pil_desc *pil, const u8 *metadata,
28 size_t size)
29{
30 return pas_init_image(PAS_TZAPPS, metadata, size);
31}
32
33static int pil_tzapps_reset(struct pil_desc *pil)
34{
35 return pas_auth_and_reset(PAS_TZAPPS);
36}
37
38static int pil_tzapps_shutdown(struct pil_desc *pil)
39{
40 return pas_shutdown(PAS_TZAPPS);
41}
42
43static struct pil_reset_ops pil_tzapps_ops = {
44 .init_image = pil_tzapps_init_image,
45 .verify_blob = nop_verify_blob,
46 .auth_and_reset = pil_tzapps_reset,
47 .shutdown = pil_tzapps_shutdown,
48};
49
50static int __devinit pil_tzapps_driver_probe(struct platform_device *pdev)
51{
52 struct pil_desc *desc;
Stephen Boyd6d67d252011-09-27 11:50:05 -070053 struct pil_device *pil;
Stephen Boydd89eebe2011-09-28 23:28:11 -070054
55 if (pas_supported(PAS_TZAPPS) < 0)
56 return -ENOSYS;
57
58 desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL);
59 if (!desc)
60 return -ENOMEM;
61
62 desc->name = "tzapps";
63 desc->dev = &pdev->dev;
64 desc->ops = &pil_tzapps_ops;
Stephen Boyd6d67d252011-09-27 11:50:05 -070065 desc->owner = THIS_MODULE;
66 pil = msm_pil_register(desc);
67 if (IS_ERR(pil))
68 return PTR_ERR(pil);
69 platform_set_drvdata(pdev, pil);
Stephen Boydd89eebe2011-09-28 23:28:11 -070070 return 0;
71}
72
73static int __devexit pil_tzapps_driver_exit(struct platform_device *pdev)
74{
Stephen Boyd6d67d252011-09-27 11:50:05 -070075 struct pil_device *pil = platform_get_drvdata(pdev);
76 msm_pil_unregister(pil);
Stephen Boydd89eebe2011-09-28 23:28:11 -070077 return 0;
78}
79
80static struct platform_driver pil_tzapps_driver = {
81 .probe = pil_tzapps_driver_probe,
82 .remove = __devexit_p(pil_tzapps_driver_exit),
83 .driver = {
84 .name = "pil_tzapps",
85 .owner = THIS_MODULE,
86 },
87};
88
89static int __init pil_tzapps_init(void)
90{
91 return platform_driver_register(&pil_tzapps_driver);
92}
93module_init(pil_tzapps_init);
94
95static void __exit pil_tzapps_exit(void)
96{
97 platform_driver_unregister(&pil_tzapps_driver);
98}
99module_exit(pil_tzapps_exit);
100
101MODULE_DESCRIPTION("Support for booting TZApps images");
102MODULE_LICENSE("GPL v2");