uboot/arch/arm/mach-stm32mp/include/mach/stm32mp1_smc.h
<<
>>
Prefs
   1/* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
   2/*
   3 * Copyright (C) 2019, STMicroelectronics - All Rights Reserved
   4 */
   5
   6#ifndef __STM32MP1_SMC_H__
   7#define __STM32MP1_SMC_H__
   8
   9#include <linux/arm-smccc.h>
  10
  11/*
  12 * SMC function IDs for STM32 Service queries
  13 * STM32 SMC services use the space between 0x82000000 and 0x8200FFFF
  14 * like this is defined in SMC calling Convention by ARM
  15 * for SiP (silicon Partner)
  16 * http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html
  17 */
  18#define STM32_SMC_VERSION               0x82000000
  19
  20/* Secure Service access from Non-secure */
  21#define STM32_SMC_BSEC                  0x82001003
  22
  23/* Service for BSEC */
  24#define STM32_SMC_READ_SHADOW           0x01
  25#define STM32_SMC_PROG_OTP              0x02
  26#define STM32_SMC_WRITE_SHADOW          0x03
  27#define STM32_SMC_READ_OTP              0x04
  28#define STM32_SMC_READ_ALL              0x05
  29#define STM32_SMC_WRITE_ALL             0x06
  30#define STM32_SMC_WRLOCK_OTP            0x07
  31
  32/* SMC error codes */
  33#define STM32_SMC_OK                    0x0
  34#define STM32_SMC_NOT_SUPPORTED         -1
  35#define STM32_SMC_FAILED                -2
  36#define STM32_SMC_INVALID_PARAMS        -3
  37
  38#define stm32_smc_exec(svc, op, data1, data2) \
  39        stm32_smc(svc, op, data1, data2, NULL)
  40
  41#ifdef CONFIG_ARM_SMCCC
  42static inline u32 stm32_smc(u32 svc, u8 op, u32 data1, u32 data2, u32 *result)
  43{
  44        struct arm_smccc_res res;
  45
  46        arm_smccc_smc(svc, op, data1, data2, 0, 0, 0, 0, &res);
  47
  48        if (res.a0) {
  49                pr_err("%s: Failed to exec svc=%x op=%x in secure mode (err = %ld)\n",
  50                       __func__, svc, op, res.a0);
  51                return -EINVAL;
  52        }
  53        if (result)
  54                *result = (u32)res.a1;
  55
  56        return 0;
  57}
  58#else
  59static inline u32 stm32_smc(u32 svc, u8 op, u32 data1, u32 data2, u32 *result)
  60{
  61        return 0;
  62}
  63#endif
  64
  65#endif /* __STM32MP1_SMC_H__ */
  66