#include <linux/arm-smccc.h>
#include <linux/bitfield.h>
#include <linux/bits.h>
#include <linux/cleanup.h>
#include <linux/clk.h>
#include <linux/completion.h>
#include <linux/cpumask.h>
#include <linux/dma-mapping.h>
#include <linux/err.h>
#include <linux/export.h>
#include <linux/firmware/qcom/qcom_scm.h>
#include <linux/firmware/qcom/qcom_tzmem.h>
#include <linux/init.h>
#include <linux/interconnect.h>
#include <linux/interrupt.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
#include <linux/reset-controller.h>
#include <linux/sizes.h>
#include <linux/types.h>
#include "qcom_scm.h"
#include "qcom_tzmem.h"
static u32 download_mode;
struct qcom_scm { … };
struct qcom_scm_current_perm_info { … };
struct qcom_scm_mem_map_info { … };
struct qcom_scm_qseecom_resp { … };
enum qcom_scm_qseecom_result { … };
enum qcom_scm_qseecom_resp_type { … };
enum qcom_scm_qseecom_tz_owner { … };
enum qcom_scm_qseecom_tz_svc { … };
enum qcom_scm_qseecom_tz_cmd_app { … };
enum qcom_scm_qseecom_tz_cmd_info { … };
#define QSEECOM_MAX_APP_NAME_SIZE …
static const u8 qcom_scm_cpu_cold_bits[QCOM_SCM_BOOT_MAX_CPUS] = …;
static const u8 qcom_scm_cpu_warm_bits[QCOM_SCM_BOOT_MAX_CPUS] = …;
#define QCOM_SMC_WAITQ_FLAG_WAKE_ONE …
#define QCOM_DLOAD_MASK …
#define QCOM_DLOAD_NODUMP …
#define QCOM_DLOAD_FULLDUMP …
#define QCOM_DLOAD_MINIDUMP …
#define QCOM_DLOAD_BOTHDUMP …
static const char * const qcom_scm_convention_names[] = …;
static const char * const download_mode_name[] = …;
static struct qcom_scm *__scm;
static int qcom_scm_clk_enable(void)
{ … }
static void qcom_scm_clk_disable(void)
{ … }
static int qcom_scm_bw_enable(void)
{ … }
static void qcom_scm_bw_disable(void)
{ … }
enum qcom_scm_convention qcom_scm_convention = …;
static DEFINE_SPINLOCK(scm_query_lock);
struct qcom_tzmem_pool *qcom_scm_get_tzmem_pool(void)
{ … }
static enum qcom_scm_convention __get_convention(void)
{ … }
static int qcom_scm_call(struct device *dev, const struct qcom_scm_desc *desc,
struct qcom_scm_res *res)
{ … }
static int qcom_scm_call_atomic(struct device *dev,
const struct qcom_scm_desc *desc,
struct qcom_scm_res *res)
{ … }
static bool __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
u32 cmd_id)
{ … }
static int qcom_scm_set_boot_addr(void *entry, const u8 *cpu_bits)
{ … }
static int qcom_scm_set_boot_addr_mc(void *entry, unsigned int flags)
{ … }
int qcom_scm_set_warm_boot_addr(void *entry)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_set_cold_boot_addr(void *entry)
{ … }
EXPORT_SYMBOL_GPL(…);
void qcom_scm_cpu_power_down(u32 flags)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_set_remote_state(u32 state, u32 id)
{ … }
EXPORT_SYMBOL_GPL(…);
static int qcom_scm_disable_sdi(void)
{ … }
static int __qcom_scm_set_dload_mode(struct device *dev, bool enable)
{ … }
static int qcom_scm_io_rmw(phys_addr_t addr, unsigned int mask, unsigned int val)
{ … }
static void qcom_scm_set_download_mode(u32 dload_mode)
{ … }
int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size,
struct qcom_scm_pas_metadata *ctx)
{ … }
EXPORT_SYMBOL_GPL(…);
void qcom_scm_pas_metadata_release(struct qcom_scm_pas_metadata *ctx)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_pas_auth_and_reset(u32 peripheral)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_pas_shutdown(u32 peripheral)
{ … }
EXPORT_SYMBOL_GPL(…);
bool qcom_scm_pas_supported(u32 peripheral)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __qcom_scm_pas_mss_reset(struct device *dev, bool reset)
{ … }
static int qcom_scm_pas_reset_assert(struct reset_controller_dev *rcdev,
unsigned long idx)
{ … }
static int qcom_scm_pas_reset_deassert(struct reset_controller_dev *rcdev,
unsigned long idx)
{ … }
static const struct reset_control_ops qcom_scm_pas_reset_ops = …;
int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_io_writel(phys_addr_t addr, unsigned int val)
{ … }
EXPORT_SYMBOL_GPL(…);
bool qcom_scm_restore_sec_cfg_available(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_restore_sec_cfg(u32 device_id, u32 spare)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_iommu_secure_ptbl_size(u32 spare, size_t *size)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_iommu_secure_ptbl_init(u64 addr, u32 size, u32 spare)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_iommu_set_cp_pool_size(u32 spare, u32 size)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,
u32 cp_nonpixel_start,
u32 cp_nonpixel_size)
{ … }
EXPORT_SYMBOL_GPL(…);
static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region,
size_t mem_sz, phys_addr_t src, size_t src_sz,
phys_addr_t dest, size_t dest_sz)
{ … }
int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
u64 *srcvm,
const struct qcom_scm_vmperm *newvm,
unsigned int dest_cnt)
{ … }
EXPORT_SYMBOL_GPL(…);
bool qcom_scm_ocmem_lock_available(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_ocmem_lock(enum qcom_scm_ocmem_client id, u32 offset, u32 size,
u32 mode)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_ocmem_unlock(enum qcom_scm_ocmem_client id, u32 offset, u32 size)
{ … }
EXPORT_SYMBOL_GPL(…);
bool qcom_scm_ice_available(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_ice_invalidate_key(u32 index)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_ice_set_key(u32 index, const u8 *key, u32 key_size,
enum qcom_scm_ice_cipher cipher, u32 data_unit_size)
{ … }
EXPORT_SYMBOL_GPL(…);
bool qcom_scm_hdcp_available(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_hdcp_req(struct qcom_scm_hdcp_req *req, u32 req_cnt, u32 *resp)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_iommu_set_pt_format(u32 sec_id, u32 ctx_num, u32 pt_fmt)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_qsmmu500_wait_safe_toggle(bool en)
{ … }
EXPORT_SYMBOL_GPL(…);
bool qcom_scm_lmh_dcvsh_available(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_shm_bridge_enable(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_shm_bridge_create(struct device *dev, u64 pfn_and_ns_perm_flags,
u64 ipfn_and_s_perm_flags, u64 size_and_flags,
u64 ns_vmids, u64 *handle)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_shm_bridge_delete(struct device *dev, u64 handle)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_lmh_profile_change(u32 profile_id)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_lmh_dcvsh(u32 payload_fn, u32 payload_reg, u32 payload_val,
u64 limit_node, u32 node_id, u64 version)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_gpu_init_regs(u32 gpu_req)
{ … }
EXPORT_SYMBOL_GPL(…);
static int qcom_scm_find_dload_address(struct device *dev, u64 *addr)
{ … }
#ifdef CONFIG_QCOM_QSEECOM
static DEFINE_MUTEX(qcom_scm_qseecom_call_lock);
static int __qcom_scm_qseecom_call(const struct qcom_scm_desc *desc,
struct qcom_scm_qseecom_resp *res)
{ … }
static int qcom_scm_qseecom_call(const struct qcom_scm_desc *desc,
struct qcom_scm_qseecom_resp *res)
{ … }
static int qcom_scm_qseecom_get_version(u32 *version)
{ … }
int qcom_scm_qseecom_app_get_id(const char *app_name, u32 *app_id)
{ … }
EXPORT_SYMBOL_GPL(…);
int qcom_scm_qseecom_app_send(u32 app_id, void *req, size_t req_size,
void *rsp, size_t rsp_size)
{ … }
EXPORT_SYMBOL_GPL(…);
static const struct of_device_id qcom_scm_qseecom_allowlist[] __maybe_unused = …;
static bool qcom_scm_qseecom_machine_is_allowed(void)
{ … }
static void qcom_scm_qseecom_free(void *data)
{ … }
static int qcom_scm_qseecom_init(struct qcom_scm *scm)
{ … }
#else
static int qcom_scm_qseecom_init(struct qcom_scm *scm)
{
return 0;
}
#endif
bool qcom_scm_is_available(void)
{ … }
EXPORT_SYMBOL_GPL(…);
static int qcom_scm_assert_valid_wq_ctx(u32 wq_ctx)
{ … }
int qcom_scm_wait_for_wq_completion(u32 wq_ctx)
{ … }
static int qcom_scm_waitq_wakeup(unsigned int wq_ctx)
{ … }
static irqreturn_t qcom_scm_irq_handler(int irq, void *data)
{ … }
static int get_download_mode(char *buffer, const struct kernel_param *kp)
{ … }
static int set_download_mode(const char *val, const struct kernel_param *kp)
{ … }
static const struct kernel_param_ops download_mode_param_ops = …;
module_param_cb(…);
MODULE_PARM_DESC(…) …;
static int qcom_scm_probe(struct platform_device *pdev)
{ … }
static void qcom_scm_shutdown(struct platform_device *pdev)
{ … }
static const struct of_device_id qcom_scm_dt_match[] = …;
MODULE_DEVICE_TABLE(of, qcom_scm_dt_match);
static struct platform_driver qcom_scm_driver = …;
static int __init qcom_scm_init(void)
{ … }
subsys_initcall(qcom_scm_init);
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;