Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3bd0a995 authored by Prasad Sodagudi's avatar Prasad Sodagudi
Browse files

qcom: scm: provide scm_is_secure_device() api



Add new scm_is_secure_device() API, so that
all platform drivers can check and take appropriate
action for secure and non-secure devices.

Change-Id: I5569f4aaf4bcbec2922a7745ec0fdc1ab423cc23
Signed-off-by: default avatarPrasad Sodagudi <psodagud@codeaurora.org>
parent 7cf3ab10
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -1200,3 +1200,39 @@ int scm_restore_sec_cfg(u32 device_id, u32 spare, int *scm_ret)
	return 0;
}
EXPORT_SYMBOL(scm_restore_sec_cfg);

/*
 * SCM call command ID to check secure mode
 * Return zero for secure device.
 * Return one for non secure device or secure
 * device with debug enabled device.
 */
#define TZ_INFO_GET_SECURE_STATE	0x4
bool scm_is_secure_device(void)
{
	struct scm_desc desc = {0};
	int ret = 0, resp;

	desc.args[0] = 0;
	desc.arginfo = 0;
	if (!is_scm_armv8()) {
		ret = scm_call(SCM_SVC_INFO, TZ_INFO_GET_SECURE_STATE, NULL,
			0, &resp, sizeof(resp));
	} else {
		ret = scm_call2(SCM_SIP_FNID(SCM_SVC_INFO,
				TZ_INFO_GET_SECURE_STATE),
				&desc);
		resp = desc.ret[0];
	}

	if (ret) {
		pr_err("%s: SCM call failed\n", __func__);
		return false;
	}

	if ((resp & BIT(0)) || (resp & BIT(2)))
		return true;
	else
		return false;
}
EXPORT_SYMBOL(scm_is_secure_device);
+6 −0
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ extern bool is_scm_armv8(void);
extern int scm_restore_sec_cfg(u32 device_id, u32 spare, int *scm_ret);
extern u32 scm_io_read(phys_addr_t address);
extern int scm_io_write(phys_addr_t address, u32 val);
extern bool scm_is_secure_device(void);

#define SCM_HDCP_MAX_REG 5

@@ -227,5 +228,10 @@ static inline int scm_io_write(phys_addr_t address, u32 val)
{
	return 0;
}

inline bool scm_is_secure_device(void)
{
	return false;
}
#endif
#endif