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