Stephen Boyd | d89eebe | 2011-09-28 23:28:11 -0700 | [diff] [blame^] | 1 | /* Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 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 | |
| 22 | static int nop_verify_blob(struct pil_desc *pil, u32 phy_addr, size_t size) |
| 23 | { |
| 24 | return 0; |
| 25 | } |
| 26 | |
| 27 | static 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 | |
| 33 | static int pil_tzapps_reset(struct pil_desc *pil) |
| 34 | { |
| 35 | return pas_auth_and_reset(PAS_TZAPPS); |
| 36 | } |
| 37 | |
| 38 | static int pil_tzapps_shutdown(struct pil_desc *pil) |
| 39 | { |
| 40 | return pas_shutdown(PAS_TZAPPS); |
| 41 | } |
| 42 | |
| 43 | static 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 | |
| 50 | static int __devinit pil_tzapps_driver_probe(struct platform_device *pdev) |
| 51 | { |
| 52 | struct pil_desc *desc; |
| 53 | |
| 54 | if (pas_supported(PAS_TZAPPS) < 0) |
| 55 | return -ENOSYS; |
| 56 | |
| 57 | desc = devm_kzalloc(&pdev->dev, sizeof(*desc), GFP_KERNEL); |
| 58 | if (!desc) |
| 59 | return -ENOMEM; |
| 60 | |
| 61 | desc->name = "tzapps"; |
| 62 | desc->dev = &pdev->dev; |
| 63 | desc->ops = &pil_tzapps_ops; |
| 64 | if (msm_pil_register(desc)) |
| 65 | return -EINVAL; |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | static int __devexit pil_tzapps_driver_exit(struct platform_device *pdev) |
| 70 | { |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | static 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 | |
| 83 | static int __init pil_tzapps_init(void) |
| 84 | { |
| 85 | return platform_driver_register(&pil_tzapps_driver); |
| 86 | } |
| 87 | module_init(pil_tzapps_init); |
| 88 | |
| 89 | static void __exit pil_tzapps_exit(void) |
| 90 | { |
| 91 | platform_driver_unregister(&pil_tzapps_driver); |
| 92 | } |
| 93 | module_exit(pil_tzapps_exit); |
| 94 | |
| 95 | MODULE_DESCRIPTION("Support for booting TZApps images"); |
| 96 | MODULE_LICENSE("GPL v2"); |