blob: 2345453809df47b2149eea867eea5139125a86d5 [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
Stephen Boydd89eebe2011-09-28 23:28:11 -070022static int pil_tzapps_init_image(struct pil_desc *pil, const u8 *metadata,
23 size_t size)
24{
25 return pas_init_image(PAS_TZAPPS, metadata, size);
26}
27
28static int pil_tzapps_reset(struct pil_desc *pil)
29{
30 return pas_auth_and_reset(PAS_TZAPPS);
31}
32
33static int pil_tzapps_shutdown(struct pil_desc *pil)
34{
35 return pas_shutdown(PAS_TZAPPS);
36}
37
38static struct pil_reset_ops pil_tzapps_ops = {
39 .init_image = pil_tzapps_init_image,
Stephen Boydd89eebe2011-09-28 23:28:11 -070040 .auth_and_reset = pil_tzapps_reset,
41 .shutdown = pil_tzapps_shutdown,
42};
43
44static int __devinit pil_tzapps_driver_probe(struct platform_device *pdev)
45{
46 struct pil_desc *desc;
Stephen Boyd6d67d252011-09-27 11:50:05 -070047 struct pil_device *pil;
Stephen Boydd89eebe2011-09-28 23:28:11 -070048
49 if (pas_supported(PAS_TZAPPS) < 0)
50 return -ENOSYS;
51
52 desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL);
53 if (!desc)
54 return -ENOMEM;
55
56 desc->name = "tzapps";
57 desc->dev = &pdev->dev;
58 desc->ops = &pil_tzapps_ops;
Stephen Boyd6d67d252011-09-27 11:50:05 -070059 desc->owner = THIS_MODULE;
60 pil = msm_pil_register(desc);
61 if (IS_ERR(pil))
62 return PTR_ERR(pil);
63 platform_set_drvdata(pdev, pil);
Stephen Boydd89eebe2011-09-28 23:28:11 -070064 return 0;
65}
66
67static int __devexit pil_tzapps_driver_exit(struct platform_device *pdev)
68{
Stephen Boyd6d67d252011-09-27 11:50:05 -070069 struct pil_device *pil = platform_get_drvdata(pdev);
70 msm_pil_unregister(pil);
Stephen Boydd89eebe2011-09-28 23:28:11 -070071 return 0;
72}
73
74static struct platform_driver pil_tzapps_driver = {
75 .probe = pil_tzapps_driver_probe,
76 .remove = __devexit_p(pil_tzapps_driver_exit),
77 .driver = {
78 .name = "pil_tzapps",
79 .owner = THIS_MODULE,
80 },
81};
82
83static int __init pil_tzapps_init(void)
84{
85 return platform_driver_register(&pil_tzapps_driver);
86}
87module_init(pil_tzapps_init);
88
89static void __exit pil_tzapps_exit(void)
90{
91 platform_driver_unregister(&pil_tzapps_driver);
92}
93module_exit(pil_tzapps_exit);
94
95MODULE_DESCRIPTION("Support for booting TZApps images");
96MODULE_LICENSE("GPL v2");