xref: /openbmc/u-boot/arch/arm/mach-keystone/mon.c (revision e9c847c3)
1 /*
2  * K2HK: secure kernel command file
3  *
4  * (C) Copyright 2012-2014
5  *     Texas Instruments Incorporated, <www.ti.com>
6  *
7  * SPDX-License-Identifier:     GPL-2.0+
8  */
9 
10 #include <common.h>
11 #include <command.h>
12 #include <mach/mon.h>
13 asm(".arch_extension sec\n\t");
14 
15 int mon_install(u32 addr, u32 dpsc, u32 freq)
16 {
17 	int result;
18 
19 	__asm__ __volatile__ (
20 		"stmfd r13!, {lr}\n"
21 		"mov r0, %1\n"
22 		"mov r1, %2\n"
23 		"mov r2, %3\n"
24 		"blx r0\n"
25 		"ldmfd r13!, {lr}\n"
26 		: "=&r" (result)
27 		: "r" (addr), "r" (dpsc), "r" (freq)
28 		: "cc", "r0", "r1", "r2", "memory");
29 	return result;
30 }
31 
32 int mon_power_on(int core_id, void *ep)
33 {
34 	int result;
35 
36 	asm volatile (
37 		"stmfd  r13!, {lr}\n"
38 		"mov r1, %1\n"
39 		"mov r2, %2\n"
40 		"mov r0, #0\n"
41 		"smc	#0\n"
42 		"ldmfd  r13!, {lr}\n"
43 		: "=&r" (result)
44 		: "r" (core_id), "r" (ep)
45 		: "cc", "r0", "r1", "r2", "memory");
46 	return  result;
47 }
48 
49 int mon_power_off(int core_id)
50 {
51 	int result;
52 
53 	asm volatile (
54 		"stmfd  r13!, {lr}\n"
55 		"mov r1, %1\n"
56 		"mov r0, #1\n"
57 		"smc	#1\n"
58 		"ldmfd  r13!, {lr}\n"
59 		: "=&r" (result)
60 		: "r" (core_id)
61 		: "cc", "r0", "r1", "memory");
62 	return  result;
63 }
64