xref: /linux/arch/arm/mach-omap2/omap-smc.S (revision d2912cb15bdda8ba4a5dd73396ad62641af2f520)
1*d2912cb1SThomas 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>
9a33f1788SPali Rohár * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com>
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".
21ba9456acSSantosh Shilimkar * Function signature : void omap_smc1(u32 fn, u32 arg)
22ba9456acSSantosh Shilimkar */
23ba9456acSSantosh Shilimkar
24ba9456acSSantosh ShilimkarENTRY(omap_smc1)
25ba9456acSSantosh Shilimkar	stmfd   sp!, {r2-r12, lr}
26ba9456acSSantosh Shilimkar	mov	r12, r0
27ba9456acSSantosh Shilimkar	mov 	r0, r1
28ba9456acSSantosh Shilimkar	dsb
29ba9456acSSantosh Shilimkar	smc	#0
30ba9456acSSantosh Shilimkar	ldmfd   sp!, {r2-r12, pc}
31ba9456acSSantosh ShilimkarENDPROC(omap_smc1)
32ba9456acSSantosh Shilimkar
33ba9456acSSantosh Shilimkar/**
34ba9456acSSantosh Shilimkar * u32 omap_smc2(u32 id, u32 falg, u32 pargs)
35ba9456acSSantosh Shilimkar * Low level common routine for secure HAL and PPA APIs.
36ba9456acSSantosh Shilimkar * @id: Application ID of HAL APIs
37ba9456acSSantosh Shilimkar * @flag: Flag to indicate the criticality of operation
38ba9456acSSantosh Shilimkar * @pargs: Physical address of parameter list starting
39ba9456acSSantosh Shilimkar *	    with number of parametrs
40ba9456acSSantosh Shilimkar */
41ba9456acSSantosh ShilimkarENTRY(omap_smc2)
42ba9456acSSantosh Shilimkar	stmfd   sp!, {r4-r12, lr}
43ba9456acSSantosh Shilimkar	mov	r3, r2
44ba9456acSSantosh Shilimkar	mov	r2, r1
45ba9456acSSantosh Shilimkar	mov	r1, #0x0	@ Process ID
46ba9456acSSantosh Shilimkar	mov	r6, #0xff
47ba9456acSSantosh Shilimkar	mov	r12, #0x00	@ Secure Service ID
48ba9456acSSantosh Shilimkar	mov	r7, #0
49ba9456acSSantosh Shilimkar	mcr	p15, 0, r7, c7, c5, 6
50ba9456acSSantosh Shilimkar	dsb
51ba9456acSSantosh Shilimkar	dmb
52ba9456acSSantosh Shilimkar	smc	#0
53ba9456acSSantosh Shilimkar	ldmfd   sp!, {r4-r12, pc}
54ba9456acSSantosh ShilimkarENDPROC(omap_smc2)
55ba9456acSSantosh Shilimkar
56a33f1788SPali Rohár/**
57a33f1788SPali Rohár * u32 omap_smc3(u32 service_id, u32 process_id, u32 flag, u32 pargs)
58a33f1788SPali Rohár * Low level common routine for secure HAL and PPA APIs via smc #1
59a33f1788SPali Rohár * r0 - @service_id: Secure Service ID
60a33f1788SPali Rohár * r1 - @process_id: Process ID
61a33f1788SPali Rohár * r2 - @flag: Flag to indicate the criticality of operation
62a33f1788SPali Rohár * r3 - @pargs: Physical address of parameter list
63a33f1788SPali Rohár */
64a33f1788SPali RohárENTRY(omap_smc3)
65a33f1788SPali Rohár	stmfd	sp!, {r4-r11, lr}
66a33f1788SPali Rohár	mov	r12, r0		@ Copy the secure service ID
67a33f1788SPali Rohár	mov	r6, #0xff	@ Indicate new Task call
68a33f1788SPali Rohár	dsb			@ Memory Barrier (not sure if needed, copied from omap_smc2)
69a33f1788SPali Rohár	smc	#1		@ Call PPA service
70a33f1788SPali Rohár	ldmfd	sp!, {r4-r11, pc}
71a33f1788SPali RohárENDPROC(omap_smc3)
72a33f1788SPali Rohár
73ba9456acSSantosh ShilimkarENTRY(omap_modify_auxcoreboot0)
74ba9456acSSantosh Shilimkar	stmfd   sp!, {r1-r12, lr}
75ba9456acSSantosh Shilimkar	ldr	r12, =0x104
76ba9456acSSantosh Shilimkar	dsb
77ba9456acSSantosh Shilimkar	smc	#0
78ba9456acSSantosh Shilimkar	ldmfd   sp!, {r1-r12, pc}
79ba9456acSSantosh ShilimkarENDPROC(omap_modify_auxcoreboot0)
80ba9456acSSantosh Shilimkar
81ba9456acSSantosh ShilimkarENTRY(omap_auxcoreboot_addr)
82ba9456acSSantosh Shilimkar	stmfd   sp!, {r2-r12, lr}
83ba9456acSSantosh Shilimkar	ldr	r12, =0x105
84ba9456acSSantosh Shilimkar	dsb
85ba9456acSSantosh Shilimkar	smc	#0
86ba9456acSSantosh Shilimkar	ldmfd   sp!, {r2-r12, pc}
87ba9456acSSantosh ShilimkarENDPROC(omap_auxcoreboot_addr)
88ba9456acSSantosh Shilimkar
89ba9456acSSantosh ShilimkarENTRY(omap_read_auxcoreboot0)
90ba9456acSSantosh Shilimkar	stmfd   sp!, {r2-r12, lr}
91ba9456acSSantosh Shilimkar	ldr	r12, =0x103
92ba9456acSSantosh Shilimkar	dsb
93ba9456acSSantosh Shilimkar	smc	#0
94ba9456acSSantosh Shilimkar	ldmfd   sp!, {r2-r12, pc}
95ba9456acSSantosh ShilimkarENDPROC(omap_read_auxcoreboot0)
96