Lines Matching +full:msm8974 +full:- +full:ocmem
1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/dma-mapping.h>
17 #include <linux/reset-controller.h>
18 #include <linux/arm-smccc.h>
87 ret = clk_prepare_enable(__scm->core_clk); in qcom_scm_clk_enable()
91 ret = clk_prepare_enable(__scm->iface_clk); in qcom_scm_clk_enable()
95 ret = clk_prepare_enable(__scm->bus_clk); in qcom_scm_clk_enable()
102 clk_disable_unprepare(__scm->iface_clk); in qcom_scm_clk_enable()
104 clk_disable_unprepare(__scm->core_clk); in qcom_scm_clk_enable()
111 clk_disable_unprepare(__scm->core_clk); in qcom_scm_clk_disable()
112 clk_disable_unprepare(__scm->iface_clk); in qcom_scm_clk_disable()
113 clk_disable_unprepare(__scm->bus_clk); in qcom_scm_clk_disable()
143 // Device isn't required as there is only one argument - no device in __query_convention()
170 * qcom_scm_call() - Invoke a syscall in the secure world
177 * This should *only* be called in pre-emptible context.
191 return -EINVAL; in qcom_scm_call()
196 * qcom_scm_call_atomic() - atomic variation of qcom_scm_call()
218 return -EINVAL; in qcom_scm_call_atomic()
245 return -EINVAL; in __qcom_scm_is_call_available()
254 * qcom_scm_set_warm_boot_addr() - Set the warm boot address for cpus
289 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_set_warm_boot_addr()
300 * qcom_scm_set_cold_boot_addr() - Set the cold boot address for cpus
325 return -EINVAL; in qcom_scm_set_cold_boot_addr()
337 return qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_set_cold_boot_addr()
342 * qcom_scm_cpu_power_down() - Power down the cpu
343 * @flags - Flags to flush cache
359 qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_cpu_power_down()
376 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_set_remote_state()
394 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in __qcom_scm_set_dload_mode()
402 avail = __qcom_scm_is_call_available(__scm->dev, in qcom_scm_set_download_mode()
406 ret = __qcom_scm_set_dload_mode(__scm->dev, enable); in qcom_scm_set_download_mode()
407 } else if (__scm->dload_mode_addr) { in qcom_scm_set_download_mode()
408 ret = qcom_scm_io_writel(__scm->dload_mode_addr, in qcom_scm_set_download_mode()
411 dev_err(__scm->dev, in qcom_scm_set_download_mode()
416 dev_err(__scm->dev, "failed to set download mode: %d\n", ret); in qcom_scm_set_download_mode()
420 * qcom_scm_pas_init_image() - Initialize peripheral authentication service
448 * non-cachable to avoid XPU violations. in qcom_scm_pas_init_image()
450 mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, in qcom_scm_pas_init_image()
453 dev_err(__scm->dev, "Allocation of metadata buffer failed.\n"); in qcom_scm_pas_init_image()
454 return -ENOMEM; in qcom_scm_pas_init_image()
464 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_init_image()
469 dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); in qcom_scm_pas_init_image()
476 * qcom_scm_pas_mem_setup() - Prepare the memory related to a given peripheral
502 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_mem_setup()
510 * qcom_scm_pas_auth_and_reset() - Authenticate the given peripheral firmware
532 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_auth_and_reset()
540 * qcom_scm_pas_shutdown() - Shut down the remote processor
561 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_shutdown()
570 * qcom_scm_pas_supported() - Check if the peripheral authentication service is
588 ret = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL, in qcom_scm_pas_supported()
593 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_supported()
612 ret = qcom_scm_call(__scm->dev, &desc, &res); in __qcom_scm_pas_mss_reset()
621 return -EINVAL; in qcom_scm_pas_reset_assert()
623 return __qcom_scm_pas_mss_reset(__scm->dev, 1); in qcom_scm_pas_reset_assert()
630 return -EINVAL; in qcom_scm_pas_reset_deassert()
632 return __qcom_scm_pas_mss_reset(__scm->dev, 0); in qcom_scm_pas_reset_deassert()
653 ret = qcom_scm_call_atomic(__scm->dev, &desc, &res); in qcom_scm_io_readl()
672 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_io_writel()
677 * qcom_scm_restore_sec_cfg_available() - Check if secure environment
680 * Return true if restore-cfg interface is supported, false if not.
684 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, in qcom_scm_restore_sec_cfg_available()
702 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_restore_sec_cfg()
720 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_iommu_secure_ptbl_size()
749 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_iommu_secure_ptbl_init()
752 if (ret == -EPERM) in qcom_scm_iommu_secure_ptbl_init()
777 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_mem_protect_video_var()
811 * qcom_scm_assign_mem() - Make a secure call to reassign memory ownership
848 ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); in qcom_scm_assign_mem()
850 return -ENOMEM; in qcom_scm_assign_mem()
861 mem_to_map->mem_addr = cpu_to_le64(mem_addr); in qcom_scm_assign_mem()
862 mem_to_map->mem_size = cpu_to_le64(mem_sz); in qcom_scm_assign_mem()
869 destvm->vmid = cpu_to_le32(newvm->vmid); in qcom_scm_assign_mem()
870 destvm->perm = cpu_to_le32(newvm->perm); in qcom_scm_assign_mem()
871 destvm->ctx = 0; in qcom_scm_assign_mem()
872 destvm->ctx_size = 0; in qcom_scm_assign_mem()
873 next_vm |= BIT(newvm->vmid); in qcom_scm_assign_mem()
876 ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, in qcom_scm_assign_mem()
878 dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); in qcom_scm_assign_mem()
880 dev_err(__scm->dev, in qcom_scm_assign_mem()
882 return -EINVAL; in qcom_scm_assign_mem()
891 * qcom_scm_ocmem_lock_available() - is OCMEM lock/unlock interface available
895 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_OCMEM, in qcom_scm_ocmem_lock_available()
901 * qcom_scm_ocmem_lock() - call OCMEM lock interface to assign an OCMEM
905 * @offset: OCMEM offset
906 * @size: OCMEM size
922 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_lock()
927 * qcom_scm_ocmem_unlock() - call OCMEM unlock interface to release an OCMEM
931 * @offset: OCMEM offset
932 * @size: OCMEM size
945 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_unlock()
950 * qcom_scm_ice_available() - Is the ICE key programming interface available?
957 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
959 __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
965 * qcom_scm_ice_invalidate_key() - Invalidate an inline encryption key
971 * Return: 0 on success; -errno on failure.
983 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_invalidate_key()
988 * qcom_scm_ice_set_key() - Set an inline encryption key
994 * individual plaintext and ciphertext. Given in 512-byte
1003 * Return: 0 on success; -errno on failure.
1031 * keys is normally rare and thus not performance-critical. in qcom_scm_ice_set_key()
1034 keybuf = dma_alloc_coherent(__scm->dev, key_size, &key_phys, in qcom_scm_ice_set_key()
1037 return -ENOMEM; in qcom_scm_ice_set_key()
1041 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_set_key()
1045 dma_free_coherent(__scm->dev, key_size, keybuf, key_phys); in qcom_scm_ice_set_key()
1051 * qcom_scm_hdcp_available() - Check if secure environment supports HDCP.
1062 ret = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_HDCP, in qcom_scm_hdcp_available()
1072 * qcom_scm_hdcp_req() - Send HDCP request.
1103 return -ERANGE; in qcom_scm_hdcp_req()
1109 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_hdcp_req()
1130 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_qsmmu500_wait_safe_toggle()
1137 struct device_node *np = dev->of_node; in qcom_scm_find_dload_address()
1142 tcsr = of_parse_phandle(np, "qcom,dload-mode", 0); in qcom_scm_find_dload_address()
1151 ret = of_property_read_u32_index(np, "qcom,dload-mode", 1, &offset); in qcom_scm_find_dload_address()
1161 * qcom_scm_is_available() - Checks if SCM is available
1175 scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL); in qcom_scm_probe()
1177 return -ENOMEM; in qcom_scm_probe()
1179 ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr); in qcom_scm_probe()
1183 clks = (unsigned long)of_device_get_match_data(&pdev->dev); in qcom_scm_probe()
1185 scm->core_clk = devm_clk_get(&pdev->dev, "core"); in qcom_scm_probe()
1186 if (IS_ERR(scm->core_clk)) { in qcom_scm_probe()
1187 if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1188 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1191 dev_err(&pdev->dev, "failed to acquire core clk\n"); in qcom_scm_probe()
1192 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1195 scm->core_clk = NULL; in qcom_scm_probe()
1198 scm->iface_clk = devm_clk_get(&pdev->dev, "iface"); in qcom_scm_probe()
1199 if (IS_ERR(scm->iface_clk)) { in qcom_scm_probe()
1200 if (PTR_ERR(scm->iface_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1201 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1204 dev_err(&pdev->dev, "failed to acquire iface clk\n"); in qcom_scm_probe()
1205 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1208 scm->iface_clk = NULL; in qcom_scm_probe()
1211 scm->bus_clk = devm_clk_get(&pdev->dev, "bus"); in qcom_scm_probe()
1212 if (IS_ERR(scm->bus_clk)) { in qcom_scm_probe()
1213 if (PTR_ERR(scm->bus_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1214 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1217 dev_err(&pdev->dev, "failed to acquire bus clk\n"); in qcom_scm_probe()
1218 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1221 scm->bus_clk = NULL; in qcom_scm_probe()
1224 scm->reset.ops = &qcom_scm_pas_reset_ops; in qcom_scm_probe()
1225 scm->reset.nr_resets = 1; in qcom_scm_probe()
1226 scm->reset.of_node = pdev->dev.of_node; in qcom_scm_probe()
1227 ret = devm_reset_controller_register(&pdev->dev, &scm->reset); in qcom_scm_probe()
1232 ret = clk_set_rate(scm->core_clk, INT_MAX); in qcom_scm_probe()
1237 __scm->dev = &pdev->dev; in qcom_scm_probe()
1260 { .compatible = "qcom,scm-apq8064",
1263 { .compatible = "qcom,scm-apq8084", .data = (void *)(SCM_HAS_CORE_CLK |
1267 { .compatible = "qcom,scm-ipq4019" },
1268 { .compatible = "qcom,scm-msm8660", .data = (void *) SCM_HAS_CORE_CLK },
1269 { .compatible = "qcom,scm-msm8960", .data = (void *) SCM_HAS_CORE_CLK },
1270 { .compatible = "qcom,scm-msm8916", .data = (void *)(SCM_HAS_CORE_CLK |
1274 { .compatible = "qcom,scm-msm8974", .data = (void *)(SCM_HAS_CORE_CLK |
1278 { .compatible = "qcom,scm-msm8994" },
1279 { .compatible = "qcom,scm-msm8996" },