Blame view

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