Lines Matching +full:hdcp +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/arm-smccc.h>
13 #include <linux/dma-mapping.h>
29 #include <linux/reset-controller.h>
70 * struct qcom_scm_qseecom_resp - QSEECOM SCM call response.
153 ret = clk_prepare_enable(__scm->core_clk); in qcom_scm_clk_enable()
157 ret = clk_prepare_enable(__scm->iface_clk); in qcom_scm_clk_enable()
161 ret = clk_prepare_enable(__scm->bus_clk); in qcom_scm_clk_enable()
168 clk_disable_unprepare(__scm->iface_clk); in qcom_scm_clk_enable()
170 clk_disable_unprepare(__scm->core_clk); in qcom_scm_clk_enable()
177 clk_disable_unprepare(__scm->core_clk); in qcom_scm_clk_disable()
178 clk_disable_unprepare(__scm->iface_clk); in qcom_scm_clk_disable()
179 clk_disable_unprepare(__scm->bus_clk); in qcom_scm_clk_disable()
186 if (!__scm->path) in qcom_scm_bw_enable()
189 mutex_lock(&__scm->scm_bw_lock); in qcom_scm_bw_enable()
190 if (!__scm->scm_vote_count) { in qcom_scm_bw_enable()
191 ret = icc_set_bw(__scm->path, 0, UINT_MAX); in qcom_scm_bw_enable()
193 dev_err(__scm->dev, "failed to set bandwidth request\n"); in qcom_scm_bw_enable()
197 __scm->scm_vote_count++; in qcom_scm_bw_enable()
199 mutex_unlock(&__scm->scm_bw_lock); in qcom_scm_bw_enable()
206 if (!__scm->path) in qcom_scm_bw_disable()
209 mutex_lock(&__scm->scm_bw_lock); in qcom_scm_bw_disable()
210 if (__scm->scm_vote_count-- == 1) in qcom_scm_bw_disable()
211 icc_set_bw(__scm->path, 0, 0); in qcom_scm_bw_disable()
212 mutex_unlock(&__scm->scm_bw_lock); in qcom_scm_bw_disable()
220 return __scm ? __scm->mempool : NULL; in qcom_scm_get_tzmem_pool()
244 * Per the "SMC calling convention specification", the 64-bit calling in __get_convention()
245 * convention can only be used when the client is 64-bit, otherwise in __get_convention()
250 * Device isn't required as there is only one argument - no device in __get_convention()
265 if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL, "qcom,scm-sc7180")) { in __get_convention()
291 * qcom_scm_call() - Invoke a syscall in the secure world
297 * This should *only* be called in pre-emptible context.
311 return -EINVAL; in qcom_scm_call()
316 * qcom_scm_call_atomic() - atomic variation of qcom_scm_call()
336 return -EINVAL; in qcom_scm_call_atomic()
384 return -EINVAL; in qcom_scm_set_boot_addr()
391 return qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_set_boot_addr()
411 return -EOPNOTSUPP; in qcom_scm_set_boot_addr_mc()
413 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_set_boot_addr_mc()
417 * qcom_scm_set_warm_boot_addr() - Set the warm boot address for all cpus
433 * qcom_scm_set_cold_boot_addr() - Set the cold boot address for all cpus
446 * qcom_scm_cpu_power_down() - Power down the cpu
463 qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_cpu_power_down()
480 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_set_remote_state()
502 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_disable_sdi()
521 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in __qcom_scm_set_dload_mode()
543 if (__scm->dload_mode_addr) { in qcom_scm_set_download_mode()
544 ret = qcom_scm_io_rmw(__scm->dload_mode_addr, QCOM_DLOAD_MASK, in qcom_scm_set_download_mode()
546 } else if (__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_BOOT, in qcom_scm_set_download_mode()
548 ret = __qcom_scm_set_dload_mode(__scm->dev, !!dload_mode); in qcom_scm_set_download_mode()
550 dev_err(__scm->dev, in qcom_scm_set_download_mode()
555 dev_err(__scm->dev, "failed to set download mode: %d\n", ret); in qcom_scm_set_download_mode()
559 * qcom_scm_pas_init_image() - Initialize peripheral authentication service
593 * non-cachable to avoid XPU violations. in qcom_scm_pas_init_image()
602 mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, in qcom_scm_pas_init_image()
605 return -ENOMEM; in qcom_scm_pas_init_image()
619 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_init_image()
627 dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); in qcom_scm_pas_init_image()
629 ctx->ptr = mdata_buf; in qcom_scm_pas_init_image()
630 ctx->phys = mdata_phys; in qcom_scm_pas_init_image()
631 ctx->size = size; in qcom_scm_pas_init_image()
639 * qcom_scm_pas_metadata_release() - release metadata context
644 if (!ctx->ptr) in qcom_scm_pas_metadata_release()
647 dma_free_coherent(__scm->dev, ctx->size, ctx->ptr, ctx->phys); in qcom_scm_pas_metadata_release()
649 ctx->ptr = NULL; in qcom_scm_pas_metadata_release()
650 ctx->phys = 0; in qcom_scm_pas_metadata_release()
651 ctx->size = 0; in qcom_scm_pas_metadata_release()
656 * qcom_scm_pas_mem_setup() - Prepare the memory related to a given peripheral
686 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_mem_setup()
697 * qcom_scm_pas_auth_and_reset() - Authenticate the given peripheral firmware
723 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_auth_and_reset()
734 * qcom_scm_pas_shutdown() - Shut down the remote processor
759 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_shutdown()
770 * qcom_scm_pas_supported() - Check if the peripheral authentication service is
788 if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL, in qcom_scm_pas_supported()
792 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_supported()
811 ret = qcom_scm_call(__scm->dev, &desc, &res); in __qcom_scm_pas_mss_reset()
820 return -EINVAL; in qcom_scm_pas_reset_assert()
822 return __qcom_scm_pas_mss_reset(__scm->dev, 1); in qcom_scm_pas_reset_assert()
829 return -EINVAL; in qcom_scm_pas_reset_deassert()
831 return __qcom_scm_pas_mss_reset(__scm->dev, 0); in qcom_scm_pas_reset_deassert()
852 ret = qcom_scm_call_atomic(__scm->dev, &desc, &res); in qcom_scm_io_readl()
871 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_io_writel()
876 * qcom_scm_restore_sec_cfg_available() - Check if secure environment
879 * Return true if restore-cfg interface is supported, false if not.
883 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, in qcom_scm_restore_sec_cfg_available()
901 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_restore_sec_cfg()
919 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_iommu_secure_ptbl_size()
942 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_iommu_secure_ptbl_init()
945 if (ret == -EPERM) in qcom_scm_iommu_secure_ptbl_init()
963 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_iommu_set_cp_pool_size()
985 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_mem_protect_video_var()
1019 * qcom_scm_assign_mem() - Make a secure call to reassign memory ownership
1055 void *ptr __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, in qcom_scm_assign_mem()
1058 return -ENOMEM; in qcom_scm_assign_mem()
1073 mem_to_map->mem_addr = cpu_to_le64(mem_addr); in qcom_scm_assign_mem()
1074 mem_to_map->mem_size = cpu_to_le64(mem_sz); in qcom_scm_assign_mem()
1081 destvm->vmid = cpu_to_le32(newvm->vmid); in qcom_scm_assign_mem()
1082 destvm->perm = cpu_to_le32(newvm->perm); in qcom_scm_assign_mem()
1083 destvm->ctx = 0; in qcom_scm_assign_mem()
1084 destvm->ctx_size = 0; in qcom_scm_assign_mem()
1085 next_vm |= BIT(newvm->vmid); in qcom_scm_assign_mem()
1088 ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, in qcom_scm_assign_mem()
1091 dev_err(__scm->dev, in qcom_scm_assign_mem()
1093 return -EINVAL; in qcom_scm_assign_mem()
1102 * qcom_scm_ocmem_lock_available() - is OCMEM lock/unlock interface available
1106 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_OCMEM, in qcom_scm_ocmem_lock_available()
1112 * qcom_scm_ocmem_lock() - call OCMEM lock interface to assign an OCMEM
1133 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_lock()
1138 * qcom_scm_ocmem_unlock() - call OCMEM unlock interface to release an OCMEM
1156 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_unlock()
1161 * qcom_scm_ice_available() - Is the ICE key programming interface available?
1168 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
1170 __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
1176 * qcom_scm_ice_invalidate_key() - Invalidate an inline encryption key
1185 * Return: 0 on success; -errno on failure.
1197 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_invalidate_key()
1202 * qcom_scm_ice_set_key() - Set an inline encryption key
1208 * individual plaintext and ciphertext. Given in 512-byte
1220 * Return: 0 on success; -errno on failure.
1240 void *keybuf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, in qcom_scm_ice_set_key()
1244 return -ENOMEM; in qcom_scm_ice_set_key()
1248 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_set_key()
1257 * qcom_scm_hdcp_available() - Check if secure environment supports HDCP.
1259 * Return true if HDCP is supported, false if not.
1269 avail = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_HDCP, in qcom_scm_hdcp_available()
1279 * qcom_scm_hdcp_req() - Send HDCP request.
1280 * @req: HDCP request array
1281 * @req_cnt: HDCP request array count
1284 * Write HDCP register(s) through SCM.
1310 return -ERANGE; in qcom_scm_hdcp_req()
1316 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_hdcp_req()
1333 .args[2] = pt_fmt, /* 0: LPAE AArch32 - 1: AArch64 */ in qcom_scm_iommu_set_pt_format()
1337 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_iommu_set_pt_format()
1353 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_qsmmu500_wait_safe_toggle()
1359 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_LMH, QCOM_SCM_LMH_LIMIT_DCVSH); in qcom_scm_lmh_dcvsh_available()
1375 if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, in qcom_scm_shm_bridge_enable()
1377 return -EOPNOTSUPP; in qcom_scm_shm_bridge_enable()
1379 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_shm_bridge_enable()
1385 return -EOPNOTSUPP; in qcom_scm_shm_bridge_enable()
1410 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_shm_bridge_create()
1429 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_shm_bridge_delete()
1443 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_lmh_profile_change()
1464 u32 *payload_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, in qcom_scm_lmh_dcvsh()
1468 return -ENOMEM; in qcom_scm_lmh_dcvsh()
1478 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_lmh_dcvsh()
1494 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_gpu_init_regs()
1501 struct device_node *np = dev->of_node; in qcom_scm_find_dload_address()
1506 tcsr = of_parse_phandle(np, "qcom,dload-mode", 0); in qcom_scm_find_dload_address()
1515 ret = of_property_read_u32_index(np, "qcom,dload-mode", 1, &offset); in qcom_scm_find_dload_address()
1541 status = qcom_scm_call(__scm->dev, desc, &scm_res); in __qcom_scm_qseecom_call()
1543 res->result = scm_res.result[0]; in __qcom_scm_qseecom_call()
1544 res->resp_type = scm_res.result[1]; in __qcom_scm_qseecom_call()
1545 res->data = scm_res.result[2]; in __qcom_scm_qseecom_call()
1554 * qcom_scm_qseecom_call() - Perform a QSEECOM SCM call.
1578 dev_dbg(__scm->dev, "%s: owner=%x, svc=%x, cmd=%x, result=%lld, type=%llx, data=%llx\n", in qcom_scm_qseecom_call()
1579 __func__, desc->owner, desc->svc, desc->cmd, res->result, in qcom_scm_qseecom_call()
1580 res->resp_type, res->data); in qcom_scm_qseecom_call()
1583 dev_err(__scm->dev, "qseecom: scm call failed with error %d\n", status); in qcom_scm_qseecom_call()
1595 WARN_ON(res->result == QSEECOM_RESULT_INCOMPLETE); in qcom_scm_qseecom_call()
1596 WARN_ON(res->result == QSEECOM_RESULT_BLOCKED_ON_LISTENER); in qcom_scm_qseecom_call()
1602 * qcom_scm_qseecom_get_version() - Query the QSEECOM version.
1632 * qcom_scm_qseecom_app_get_id() - Query the app ID for a given QSEE app name.
1640 * Return: Zero on success, nonzero on failure, -ENOENT if the app has not been
1652 return -EINVAL; in qcom_scm_qseecom_app_get_id()
1654 char *name_buf __free(qcom_tzmem) = qcom_tzmem_alloc(__scm->mempool, in qcom_scm_qseecom_app_get_id()
1658 return -ENOMEM; in qcom_scm_qseecom_app_get_id()
1675 return -ENOENT; in qcom_scm_qseecom_app_get_id()
1678 return -EINVAL; in qcom_scm_qseecom_app_get_id()
1681 return -EINVAL; in qcom_scm_qseecom_app_get_id()
1689 * qcom_scm_qseecom_app_send() - Send to and receive data from a given QSEE app.
1699 * respective (app-specific) request data. The QSEE app reads this and returns
1734 return -EIO; in qcom_scm_qseecom_app_send()
1741 * We do not yet support re-entrant calls via the qseecom interface. To prevent
1745 { .compatible = "lenovo,flex-5g" },
1746 { .compatible = "lenovo,thinkpad-t14s" },
1747 { .compatible = "lenovo,thinkpad-x13s", },
1750 { .compatible = "qcom,sc8180x-primus" },
1751 { .compatible = "qcom,x1e80100-crd" },
1752 { .compatible = "qcom,x1e80100-qcp" },
1800 dev_info(scm->dev, "qseecom: found qseecom with version 0x%x\n", version); in qcom_scm_qseecom_init()
1803 dev_info(scm->dev, "qseecom: untested machine, skipping\n"); in qcom_scm_qseecom_init()
1811 qseecom_dev = platform_device_alloc("qcom_qseecom", -1); in qcom_scm_qseecom_init()
1813 return -ENOMEM; in qcom_scm_qseecom_init()
1815 qseecom_dev->dev.parent = scm->dev; in qcom_scm_qseecom_init()
1823 return devm_add_action_or_reset(scm->dev, qcom_scm_qseecom_free, qseecom_dev); in qcom_scm_qseecom_init()
1836 * qcom_scm_is_available() - Checks if SCM is available
1851 dev_err(__scm->dev, "Firmware unexpectedly passed non-zero wq_ctx\n"); in qcom_scm_assert_valid_wq_ctx()
1852 return -EINVAL; in qcom_scm_assert_valid_wq_ctx()
1866 wait_for_completion(&__scm->waitq_comp); in qcom_scm_wait_for_wq_completion()
1879 complete(&__scm->waitq_comp); in qcom_scm_waitq_wakeup()
1893 dev_err(scm->dev, "GET_WQ_CTX SMC call failed: %d\n", ret); in qcom_scm_irq_handler()
1898 dev_err(scm->dev, "Invalid flags received for wq_ctx: %u\n", flags); in qcom_scm_irq_handler()
1956 scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL); in qcom_scm_probe()
1958 return -ENOMEM; in qcom_scm_probe()
1960 scm->dev = &pdev->dev; in qcom_scm_probe()
1961 ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr); in qcom_scm_probe()
1965 init_completion(&scm->waitq_comp); in qcom_scm_probe()
1966 mutex_init(&scm->scm_bw_lock); in qcom_scm_probe()
1968 scm->path = devm_of_icc_get(&pdev->dev, NULL); in qcom_scm_probe()
1969 if (IS_ERR(scm->path)) in qcom_scm_probe()
1970 return dev_err_probe(&pdev->dev, PTR_ERR(scm->path), in qcom_scm_probe()
1973 scm->core_clk = devm_clk_get_optional(&pdev->dev, "core"); in qcom_scm_probe()
1974 if (IS_ERR(scm->core_clk)) in qcom_scm_probe()
1975 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1977 scm->iface_clk = devm_clk_get_optional(&pdev->dev, "iface"); in qcom_scm_probe()
1978 if (IS_ERR(scm->iface_clk)) in qcom_scm_probe()
1979 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1981 scm->bus_clk = devm_clk_get_optional(&pdev->dev, "bus"); in qcom_scm_probe()
1982 if (IS_ERR(scm->bus_clk)) in qcom_scm_probe()
1983 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1985 scm->reset.ops = &qcom_scm_pas_reset_ops; in qcom_scm_probe()
1986 scm->reset.nr_resets = 1; in qcom_scm_probe()
1987 scm->reset.of_node = pdev->dev.of_node; in qcom_scm_probe()
1988 ret = devm_reset_controller_register(&pdev->dev, &scm->reset); in qcom_scm_probe()
1993 ret = clk_set_rate(scm->core_clk, INT_MAX); in qcom_scm_probe()
2002 if (irq != -ENXIO) in qcom_scm_probe()
2005 ret = devm_request_threaded_irq(__scm->dev, irq, NULL, qcom_scm_irq_handler, in qcom_scm_probe()
2006 IRQF_ONESHOT, "qcom-scm", __scm); in qcom_scm_probe()
2008 return dev_err_probe(scm->dev, ret, "Failed to request qcom-scm irq\n"); in qcom_scm_probe()
2023 if (of_property_read_bool(pdev->dev.of_node, "qcom,sdi-enabled") || !download_mode) in qcom_scm_probe()
2026 ret = of_reserved_mem_device_init(__scm->dev); in qcom_scm_probe()
2027 if (ret && ret != -ENODEV) in qcom_scm_probe()
2028 return dev_err_probe(__scm->dev, ret, in qcom_scm_probe()
2031 ret = qcom_tzmem_enable(__scm->dev); in qcom_scm_probe()
2033 return dev_err_probe(__scm->dev, ret, in qcom_scm_probe()
2041 __scm->mempool = devm_qcom_tzmem_pool_new(__scm->dev, &pool_config); in qcom_scm_probe()
2042 if (IS_ERR(__scm->mempool)) in qcom_scm_probe()
2043 return dev_err_probe(__scm->dev, PTR_ERR(__scm->mempool), in qcom_scm_probe()
2049 * Note: QSEECOM is fairly self-contained and this only adds the in qcom_scm_probe()
2051 * lifting). So any errors returned here should be either -ENOMEM or in qcom_scm_probe()
2052 * -EINVAL (with the latter only in case there's a bug in our code). in qcom_scm_probe()
2072 { .compatible = "qcom,scm-apq8064" },
2073 { .compatible = "qcom,scm-apq8084" },
2074 { .compatible = "qcom,scm-ipq4019" },
2075 { .compatible = "qcom,scm-msm8953" },
2076 { .compatible = "qcom,scm-msm8974" },
2077 { .compatible = "qcom,scm-msm8996" },