omap-secure.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * OMAP Secure API infrastructure.
  3. *
  4. * Copyright (C) 2011 Texas Instruments, Inc.
  5. * Santosh Shilimkar <santosh.shilimkar@ti.com>
  6. *
  7. *
  8. * This program is free software,you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <linux/memblock.h>
  16. #include <asm/cacheflush.h>
  17. #include <asm/memblock.h>
  18. #include <plat/omap-secure.h>
  19. #include <mach/omap-secure.h>
  20. static phys_addr_t omap_secure_memblock_base;
  21. /**
  22. * omap_sec_dispatcher: Routine to dispatch low power secure
  23. * service routines
  24. * @idx: The HAL API index
  25. * @flag: The flag indicating criticality of operation
  26. * @nargs: Number of valid arguments out of four.
  27. * @arg1, arg2, arg3 args4: Parameters passed to secure API
  28. *
  29. * Return the non-zero error value on failure.
  30. */
  31. u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
  32. u32 arg3, u32 arg4)
  33. {
  34. u32 ret;
  35. u32 param[5];
  36. param[0] = nargs;
  37. param[1] = arg1;
  38. param[2] = arg2;
  39. param[3] = arg3;
  40. param[4] = arg4;
  41. /*
  42. * Secure API needs physical address
  43. * pointer for the parameters
  44. */
  45. flush_cache_all();
  46. outer_clean_range(__pa(param), __pa(param + 5));
  47. ret = omap_smc2(idx, flag, __pa(param));
  48. return ret;
  49. }
  50. /* Allocate the memory to save secure ram */
  51. int __init omap_secure_ram_reserve_memblock(void)
  52. {
  53. u32 size = OMAP_SECURE_RAM_STORAGE;
  54. size = ALIGN(size, SZ_1M);
  55. omap_secure_memblock_base = arm_memblock_steal(size, SZ_1M);
  56. return 0;
  57. }
  58. phys_addr_t omap_secure_ram_mempool_base(void)
  59. {
  60. return omap_secure_memblock_base;
  61. }