1/*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2021 Adrian Chadd <adrian@FreeBSD.org>
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 *    notice, this list of conditions and the following disclaimer in the
13 *    documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#ifndef	__QCOM_SCM_DEFS_H__
29#define	__QCOM_SCM_DEFS_H__
30
31/*
32 * Maximum SCM arguments and return values.
33 */
34#define	MAX_QCOM_SCM_ARGS			10
35#define	MAX_QCOM_SCM_RETS			3
36
37/*
38 * SCM argument type definitions.
39 */
40#define	QCOM_SCM_ARGTYPE_VAL			0x00
41#define	QCOM_SCM_ARGTYPE_RO			0x01
42#define	QCOM_SCM_ARGTYPE_RW			0x02
43#define	QCOM_SCM_ARGTYPE_BUFVAL			0x03
44
45/*
46 * SCM calls + arguments.
47 */
48#define	QCOM_SCM_SVC_BOOT			0x01
49#define		QCOM_SCM_BOOT_SET_ADDR		0x01
50#define		QCOM_SCM_BOOT_TERMINATE_PC	0x02
51#define		QCOM_SCM_BOOT_SET_DLOAD_MODE	0x10
52#define		QCOM_SCM_BOOT_SET_REMOTE_STATE	0x0a
53#define		QCOM_SCM_FLUSH_FLAG_MASK	0x3
54
55/* Flags for QCOM_SCM_BOOT_SET_ADDR argv[0] */
56/* Note: no COLDBOOT for CPU0, it's already booted */
57#define		QCOM_SCM_FLAG_COLDBOOT_CPU1	0x01
58#define		QCOM_SCM_FLAG_WARMBOOT_CPU1	0x02
59#define		QCOM_SCM_FLAG_WARMBOOT_CPU0	0x04
60#define		QCOM_SCM_FLAG_COLDBOOT_CPU2	0x08
61#define		QCOM_SCM_FLAG_WARMBOOT_CPU2	0x10
62#define		QCOM_SCM_FLAG_COLDBOOT_CPU3	0x20
63#define		QCOM_SCM_FLAG_WARMBOOT_CPU3	0x40
64
65#define	QCOM_SCM_SVC_PIL			0x02
66#define		QCOM_SCM_PIL_PAS_INIT_IMAGE	0x01
67#define		QCOM_SCM_PIL_PAS_MEM_SETUP	0x02
68#define		QCOM_SCM_PIL_PAS_AUTH_AND_RESET	0x05
69#define		QCOM_SCM_PIL_PAS_SHUTDOWN	0x06
70#define		QCOM_SCM_PIL_PAS_IS_SUPPORTED	0x07
71#define		QCOM_SCM_PIL_PAS_MSS_RESET	0x0a
72
73#define	QCOM_SCM_SVC_IO				0x05
74#define		QCOM_SCM_IO_READ		0x01
75#define		QCOM_SCM_IO_WRITE		0x02
76
77/*
78 * Fetch SCM call availability information.
79 */
80#define	QCOM_SCM_SVC_INFO			0x06
81#define		QCOM_SCM_INFO_IS_CALL_AVAIL	0x01
82
83#define	QCOM_SCM_SVC_MP				0x0c
84#define		QCOM_SCM_MP_RESTORE_SEC_CFG	0x02
85#define		QCOM_SCM_MP_IOMMU_SECURE_PTBL_SIZE	0x03
86#define		QCOM_SCM_MP_IOMMU_SECURE_PTBL_INIT	0x04
87#define		QCOM_SCM_MP_VIDEO_VAR		0x08
88#define		QCOM_SCM_MP_ASSIGN		0x16
89
90#define	QCOM_SCM_SVC_OCMEM			0x0f
91#define		QCOM_SCM_OCMEM_LOCK_CMD		0x01
92#define		QCOM_SCM_OCMEM_UNLOCK_CMD	0x02
93
94#define	QCOM_SCM_SVC_ES				0x10
95#define		QCOM_SCM_ES_INVALIDATE_ICE_KEY	0x03
96#define		QCOM_SCM_ES_CONFIG_SET_ICE_KEY	0x04
97
98#define	QCOM_SCM_SVC_HDCP			0x11
99#define		QCOM_SCM_HDCP_INVOKE		0x01
100
101#define	QCOM_SCM_SVC_LMH			0x13
102#define		QCOM_SCM_LMH_LIMIT_PROFILE_CHANGE	0x01
103#define		QCOM_SCM_LMH_LIMIT_DCVSH	0x10
104
105#define	QCOM_SCM_SVC_SMMU_PROGRAM		0x15
106#define		QCOM_SCM_SMMU_CONFIG_ERRATA1	0x03
107#define		QCOM_SCM_SMMU_CONFIG_ERRATA1_CLIENT_ALL	0x02
108
109/*
110 * Return values from the SCM calls.
111 */
112#define	QCOM_SCM_RETVAL_V2_EBUSY		-12
113#define	QCOM_SCM_RETVAL_ENOMEM			-5
114#define	QCOM_SCM_RETVAL_EOPNOTSUPP		-4
115#define	QCOM_SCM_RETVAL_EINVAL_ADDR		-3
116#define	QCOM_SCM_RETVAL_EINVAL_ARG		-2
117#define	QCOM_SCM_RETVAL_ERROR			-1
118#define	QCOM_SCM_RETVAL_INTERRUPTED		1
119
120#endif	/* __QCOM_SCM_DEFS_H__ */
121