xref: /linux/arch/arm/mach-omap2/omap-smc.S (revision a33f1788192d13165594f8ec6975dbae34502ec9)
1ba9456acSSantosh Shilimkar/*
2*a33f1788SPali Rohár * OMAP34xx and OMAP44xx secure APIs file.
3ba9456acSSantosh Shilimkar *
4ba9456acSSantosh Shilimkar * Copyright (C) 2010 Texas Instruments, Inc.
5ba9456acSSantosh Shilimkar * Written by Santosh Shilimkar <santosh.shilimkar@ti.com>
6ba9456acSSantosh Shilimkar *
7*a33f1788SPali Rohár * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
8*a33f1788SPali Rohár * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com>
9ba9456acSSantosh Shilimkar *
10ba9456acSSantosh Shilimkar * This program is free software,you can redistribute it and/or modify
11ba9456acSSantosh Shilimkar * it under the terms of the GNU General Public License version 2 as
12ba9456acSSantosh Shilimkar * published by the Free Software Foundation.
13ba9456acSSantosh Shilimkar */
14ba9456acSSantosh Shilimkar
15ba9456acSSantosh Shilimkar#include <linux/linkage.h>
16ba9456acSSantosh Shilimkar
17ba9456acSSantosh Shilimkar/*
18ba9456acSSantosh Shilimkar * This is common routine to manage secure monitor API
19ba9456acSSantosh Shilimkar * used to modify the PL310 secure registers.
20ba9456acSSantosh Shilimkar * 'r0' contains the value to be modified and 'r12' contains
21ba9456acSSantosh Shilimkar * the monitor API number. It uses few CPU registers
22ba9456acSSantosh Shilimkar * internally and hence they need be backed up including
23ba9456acSSantosh Shilimkar * link register "lr".
24ba9456acSSantosh Shilimkar * Function signature : void omap_smc1(u32 fn, u32 arg)
25ba9456acSSantosh Shilimkar */
26ba9456acSSantosh Shilimkar
27ba9456acSSantosh ShilimkarENTRY(omap_smc1)
28ba9456acSSantosh Shilimkar	stmfd   sp!, {r2-r12, lr}
29ba9456acSSantosh Shilimkar	mov	r12, r0
30ba9456acSSantosh Shilimkar	mov 	r0, r1
31ba9456acSSantosh Shilimkar	dsb
32ba9456acSSantosh Shilimkar	smc	#0
33ba9456acSSantosh Shilimkar	ldmfd   sp!, {r2-r12, pc}
34ba9456acSSantosh ShilimkarENDPROC(omap_smc1)
35ba9456acSSantosh Shilimkar
36ba9456acSSantosh Shilimkar/**
37ba9456acSSantosh Shilimkar * u32 omap_smc2(u32 id, u32 falg, u32 pargs)
38ba9456acSSantosh Shilimkar * Low level common routine for secure HAL and PPA APIs.
39ba9456acSSantosh Shilimkar * @id: Application ID of HAL APIs
40ba9456acSSantosh Shilimkar * @flag: Flag to indicate the criticality of operation
41ba9456acSSantosh Shilimkar * @pargs: Physical address of parameter list starting
42ba9456acSSantosh Shilimkar *	    with number of parametrs
43ba9456acSSantosh Shilimkar */
44ba9456acSSantosh ShilimkarENTRY(omap_smc2)
45ba9456acSSantosh Shilimkar	stmfd   sp!, {r4-r12, lr}
46ba9456acSSantosh Shilimkar	mov	r3, r2
47ba9456acSSantosh Shilimkar	mov	r2, r1
48ba9456acSSantosh Shilimkar	mov	r1, #0x0	@ Process ID
49ba9456acSSantosh Shilimkar	mov	r6, #0xff
50ba9456acSSantosh Shilimkar	mov	r12, #0x00	@ Secure Service ID
51ba9456acSSantosh Shilimkar	mov	r7, #0
52ba9456acSSantosh Shilimkar	mcr	p15, 0, r7, c7, c5, 6
53ba9456acSSantosh Shilimkar	dsb
54ba9456acSSantosh Shilimkar	dmb
55ba9456acSSantosh Shilimkar	smc	#0
56ba9456acSSantosh Shilimkar	ldmfd   sp!, {r4-r12, pc}
57ba9456acSSantosh ShilimkarENDPROC(omap_smc2)
58ba9456acSSantosh Shilimkar
59*a33f1788SPali Rohár/**
60*a33f1788SPali Rohár * u32 omap_smc3(u32 service_id, u32 process_id, u32 flag, u32 pargs)
61*a33f1788SPali Rohár * Low level common routine for secure HAL and PPA APIs via smc #1
62*a33f1788SPali Rohár * r0 - @service_id: Secure Service ID
63*a33f1788SPali Rohár * r1 - @process_id: Process ID
64*a33f1788SPali Rohár * r2 - @flag: Flag to indicate the criticality of operation
65*a33f1788SPali Rohár * r3 - @pargs: Physical address of parameter list
66*a33f1788SPali Rohár */
67*a33f1788SPali RohárENTRY(omap_smc3)
68*a33f1788SPali Rohár	stmfd	sp!, {r4-r11, lr}
69*a33f1788SPali Rohár	mov	r12, r0		@ Copy the secure service ID
70*a33f1788SPali Rohár	mov	r6, #0xff	@ Indicate new Task call
71*a33f1788SPali Rohár	dsb			@ Memory Barrier (not sure if needed, copied from omap_smc2)
72*a33f1788SPali Rohár	smc	#1		@ Call PPA service
73*a33f1788SPali Rohár	ldmfd	sp!, {r4-r11, pc}
74*a33f1788SPali RohárENDPROC(omap_smc3)
75*a33f1788SPali Rohár
76ba9456acSSantosh ShilimkarENTRY(omap_modify_auxcoreboot0)
77ba9456acSSantosh Shilimkar	stmfd   sp!, {r1-r12, lr}
78ba9456acSSantosh Shilimkar	ldr	r12, =0x104
79ba9456acSSantosh Shilimkar	dsb
80ba9456acSSantosh Shilimkar	smc	#0
81ba9456acSSantosh Shilimkar	ldmfd   sp!, {r1-r12, pc}
82ba9456acSSantosh ShilimkarENDPROC(omap_modify_auxcoreboot0)
83ba9456acSSantosh Shilimkar
84ba9456acSSantosh ShilimkarENTRY(omap_auxcoreboot_addr)
85ba9456acSSantosh Shilimkar	stmfd   sp!, {r2-r12, lr}
86ba9456acSSantosh Shilimkar	ldr	r12, =0x105
87ba9456acSSantosh Shilimkar	dsb
88ba9456acSSantosh Shilimkar	smc	#0
89ba9456acSSantosh Shilimkar	ldmfd   sp!, {r2-r12, pc}
90ba9456acSSantosh ShilimkarENDPROC(omap_auxcoreboot_addr)
91ba9456acSSantosh Shilimkar
92ba9456acSSantosh ShilimkarENTRY(omap_read_auxcoreboot0)
93ba9456acSSantosh Shilimkar	stmfd   sp!, {r2-r12, lr}
94ba9456acSSantosh Shilimkar	ldr	r12, =0x103
95ba9456acSSantosh Shilimkar	dsb
96ba9456acSSantosh Shilimkar	smc	#0
97ba9456acSSantosh Shilimkar	mov	r0, r0, lsr #9
98ba9456acSSantosh Shilimkar	ldmfd   sp!, {r2-r12, pc}
99ba9456acSSantosh ShilimkarENDPROC(omap_read_auxcoreboot0)
100