trusty-mtee.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2013 Google, Inc.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/cpu.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/of_platform.h>
  18. #include <linux/slab.h>
  19. #include <linux/string.h>
  20. #include <linux/trusty/smcall.h>
  21. #include <linux/trusty/sm_err.h>
  22. #include <linux/trusty/trusty.h>
  23. static struct platform_device *trusty_mtee_dev;
  24. s32 trusty_mtee_std_call32(u32 smcnr, u32 a0, u32 a1, u32 a2)
  25. {
  26. return trusty_std_call32(trusty_mtee_dev->dev.parent,
  27. smcnr, a0, a1, a2);
  28. }
  29. static int trusty_mtee_probe(struct platform_device *pdev)
  30. {
  31. dev_dbg(&pdev->dev, "%s\n", __func__);
  32. trusty_mtee_dev = pdev;
  33. return 0;
  34. }
  35. static int trusty_mtee_remove(struct platform_device *pdev)
  36. {
  37. dev_dbg(&pdev->dev, "%s\n", __func__);
  38. return 0;
  39. }
  40. #define MODULE_NAME "trusty-mtee"
  41. static const struct of_device_id trusty_mtee_of_match[] = {
  42. { .compatible = "mediatek,trusty-mtee-v1", },
  43. };
  44. MODULE_DEVICE_TABLE(of, trusty_mtee_of_match);
  45. static struct platform_driver trusty_mtee_driver = {
  46. .probe = trusty_mtee_probe,
  47. .remove = trusty_mtee_remove,
  48. .driver = {
  49. .name = MODULE_NAME,
  50. .owner = THIS_MODULE,
  51. .of_match_table = trusty_mtee_of_match,
  52. },
  53. };
  54. static int __init register_trusty_mtee_driver(void)
  55. {
  56. int ret = 0;
  57. if (platform_driver_register(&trusty_mtee_driver)) {
  58. ret = -ENODEV;
  59. pr_warn("[%s] could not register device for the device, ret:%d\n",
  60. MODULE_NAME,
  61. ret);
  62. return ret;
  63. }
  64. return ret;
  65. }
  66. static int __init trusty_mtee_init(void)
  67. {
  68. int ret = 0;
  69. ret = register_trusty_mtee_driver();
  70. if (ret) {
  71. pr_warn("[%s] register device/driver failed, ret:%d\n",
  72. MODULE_NAME,
  73. ret);
  74. return ret;
  75. }
  76. return 0;
  77. }
  78. subsys_initcall(trusty_mtee_init);