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