omap-secure.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 <mach/omap-secure.h>
  19. static phys_addr_t omap_secure_memblock_base;
  20. /**
  21. * omap_sec_dispatcher: Routine to dispatch low power secure
  22. * service routines
  23. * @idx: The HAL API index
  24. * @flag: The flag indicating criticality of operation
  25. * @nargs: Number of valid arguments out of four.
  26. * @arg1, arg2, arg3 args4: Parameters passed to secure API
  27. *
  28. * Return the non-zero error value on failure.
  29. */
  30. u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
  31. u32 arg3, u32 arg4)
  32. {
  33. u32 ret;
  34. u32 param[5];
  35. param[0] = nargs;
  36. param[1] = arg1;
  37. param[2] = arg2;
  38. param[3] = arg3;
  39. param[4] = arg4;
  40. /*
  41. * Secure API needs physical address
  42. * pointer for the parameters
  43. */
  44. flush_cache_all();
  45. outer_clean_range(__pa(param), __pa(param + 5));
  46. ret = omap_smc2(idx, flag, __pa(param));
  47. return ret;
  48. }
  49. /* Allocate the memory to save secure ram */
  50. int __init omap_secure_ram_reserve_memblock(void)
  51. {
  52. u32 size = OMAP_SECURE_RAM_STORAGE;
  53. size = ALIGN(size, SZ_1M);
  54. omap_secure_memblock_base = arm_memblock_steal(size, SZ_1M);
  55. return 0;
  56. }
  57. phys_addr_t omap_secure_ram_mempool_base(void)
  58. {
  59. return omap_secure_memblock_base;
  60. }