Lines Matching +full:peripheral +full:- +full:to +full:- +full:memory
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()
140 * Device isn't required as there is only one argument - no device in __get_convention()
141 * needed to dma_map_single to secure world in __get_convention()
150 * QCOM_SCM_INFO_IS_CALL_AVAIL call, so we fallback to forcing ARM_64 in __get_convention()
153 * will be valid here to check if the compatible matches. in __get_convention()
155 if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL, "qcom,scm-sc7180")) { in __get_convention()
180 * qcom_scm_call() - Invoke a syscall in the secure world
186 * Sends a command to the SCM and waits for the command to finish processing.
187 * This should *only* be called in pre-emptible context.
201 return -EINVAL; in qcom_scm_call()
206 * qcom_scm_call_atomic() - atomic variation of qcom_scm_call()
213 * Sends a command to the SCM and waits for the command to finish processing.
228 return -EINVAL; in qcom_scm_call_atomic()
264 * qcom_scm_set_warm_boot_addr() - Set the warm boot address for cpus
268 * Set the Linux entry point for the SCM to transfer control to when coming
284 * to cpuidle entry point or vice versa. in qcom_scm_set_warm_boot_addr()
299 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_set_warm_boot_addr()
310 * qcom_scm_set_cold_boot_addr() - Set the cold boot address for cpus
335 return -EINVAL; in qcom_scm_set_cold_boot_addr()
347 return qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_set_cold_boot_addr()
352 * qcom_scm_cpu_power_down() - Power down the cpu
353 * @flags - Flags to flush cache
355 * This is an end point to power down cpu. If there was a pending interrupt,
356 * the control would return from this function, otherwise, the cpu jumps to the
369 qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_cpu_power_down()
386 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_set_remote_state()
404 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in __qcom_scm_set_dload_mode()
412 avail = __qcom_scm_is_call_available(__scm->dev, in qcom_scm_set_download_mode()
416 ret = __qcom_scm_set_dload_mode(__scm->dev, enable); in qcom_scm_set_download_mode()
417 } else if (__scm->dload_mode_addr) { in qcom_scm_set_download_mode()
418 ret = qcom_scm_io_writel(__scm->dload_mode_addr, in qcom_scm_set_download_mode()
421 dev_err(__scm->dev, in qcom_scm_set_download_mode()
426 dev_err(__scm->dev, "failed to set download mode: %d\n", ret); in qcom_scm_set_download_mode()
430 * qcom_scm_pas_init_image() - Initialize peripheral authentication service
431 * state machine for a given peripheral, using the
433 * @peripheral: peripheral id
434 * @metadata: pointer to memory containing ELF header, program header table
441 int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) in qcom_scm_pas_init_image() argument
450 .args[0] = peripheral, in qcom_scm_pas_init_image()
456 * During the scm call memory protection will be enabled for the meta in qcom_scm_pas_init_image()
458 * non-cachable to avoid XPU violations. in qcom_scm_pas_init_image()
460 mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, in qcom_scm_pas_init_image()
463 dev_err(__scm->dev, "Allocation of metadata buffer failed.\n"); in qcom_scm_pas_init_image()
464 return -ENOMEM; in qcom_scm_pas_init_image()
474 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_init_image()
479 dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); in qcom_scm_pas_init_image()
486 * qcom_scm_pas_mem_setup() - Prepare the memory related to a given peripheral
488 * @peripheral: peripheral id
489 * @addr: start address of memory area to prepare
490 * @size: size of the memory area to prepare
494 int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size) in qcom_scm_pas_mem_setup() argument
501 .args[0] = peripheral, in qcom_scm_pas_mem_setup()
512 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_mem_setup()
520 * qcom_scm_pas_auth_and_reset() - Authenticate the given peripheral firmware
522 * @peripheral: peripheral id
526 int qcom_scm_pas_auth_and_reset(u32 peripheral) in qcom_scm_pas_auth_and_reset() argument
533 .args[0] = peripheral, in qcom_scm_pas_auth_and_reset()
542 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_auth_and_reset()
550 * qcom_scm_pas_shutdown() - Shut down the remote processor
551 * @peripheral: peripheral id
555 int qcom_scm_pas_shutdown(u32 peripheral) in qcom_scm_pas_shutdown() argument
562 .args[0] = peripheral, in qcom_scm_pas_shutdown()
571 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_shutdown()
580 * qcom_scm_pas_supported() - Check if the peripheral authentication service is
582 * @peripheral: peripheral id
584 * Returns true if PAS is supported for this peripheral, otherwise false.
586 bool qcom_scm_pas_supported(u32 peripheral) in qcom_scm_pas_supported() argument
593 .args[0] = peripheral, in qcom_scm_pas_supported()
598 if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL, in qcom_scm_pas_supported()
602 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_supported()
621 ret = qcom_scm_call(__scm->dev, &desc, &res); in __qcom_scm_pas_mss_reset()
630 return -EINVAL; in qcom_scm_pas_reset_assert()
632 return __qcom_scm_pas_mss_reset(__scm->dev, 1); in qcom_scm_pas_reset_assert()
639 return -EINVAL; in qcom_scm_pas_reset_deassert()
641 return __qcom_scm_pas_mss_reset(__scm->dev, 0); in qcom_scm_pas_reset_deassert()
662 ret = qcom_scm_call_atomic(__scm->dev, &desc, &res); in qcom_scm_io_readl()
681 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_io_writel()
686 * qcom_scm_restore_sec_cfg_available() - Check if secure environment
689 * Return true if restore-cfg interface is supported, false if not.
693 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, in qcom_scm_restore_sec_cfg_available()
711 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_restore_sec_cfg()
729 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_iommu_secure_ptbl_size()
752 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_iommu_secure_ptbl_init()
755 if (ret == -EPERM) in qcom_scm_iommu_secure_ptbl_init()
780 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_mem_protect_video_var()
814 * qcom_scm_assign_mem() - Make a secure call to reassign memory ownership
815 * @mem_addr: mem region whose ownership need to be reassigned
851 ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); in qcom_scm_assign_mem()
853 return -ENOMEM; in qcom_scm_assign_mem()
861 /* Fill details of mem buff to map */ in qcom_scm_assign_mem()
864 mem_to_map->mem_addr = cpu_to_le64(mem_addr); in qcom_scm_assign_mem()
865 mem_to_map->mem_size = cpu_to_le64(mem_sz); in qcom_scm_assign_mem()
872 destvm->vmid = cpu_to_le32(newvm->vmid); in qcom_scm_assign_mem()
873 destvm->perm = cpu_to_le32(newvm->perm); in qcom_scm_assign_mem()
874 destvm->ctx = 0; in qcom_scm_assign_mem()
875 destvm->ctx_size = 0; in qcom_scm_assign_mem()
876 next_vm |= BIT(newvm->vmid); in qcom_scm_assign_mem()
879 ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, in qcom_scm_assign_mem()
881 dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); in qcom_scm_assign_mem()
883 dev_err(__scm->dev, in qcom_scm_assign_mem()
884 "Assign memory protection call failed %d\n", ret); in qcom_scm_assign_mem()
885 return -EINVAL; in qcom_scm_assign_mem()
894 * qcom_scm_ocmem_lock_available() - is OCMEM lock/unlock interface available
898 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_OCMEM, in qcom_scm_ocmem_lock_available()
904 * qcom_scm_ocmem_lock() - call OCMEM lock interface to assign an OCMEM
905 * region to the specified initiator
925 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_lock()
930 * qcom_scm_ocmem_unlock() - call OCMEM unlock interface to release an OCMEM
948 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_unlock()
953 * qcom_scm_ice_available() - Is the ICE key programming interface available?
960 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
962 __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
968 * qcom_scm_ice_invalidate_key() - Invalidate an inline encryption key
969 * @index: the keyslot to invalidate
971 * The UFSHCI and eMMC standards define a standard way to do this, but it
975 * call doesn't specify which ICE instance the keyslot belongs to.
977 * Return: 0 on success; -errno on failure.
989 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_invalidate_key()
994 * qcom_scm_ice_set_key() - Set an inline encryption key
995 * @index: the keyslot into which to set the key
996 * @key: the key to program
1000 * individual plaintext and ciphertext. Given in 512-byte
1004 * can then be used to encrypt/decrypt UFS or eMMC I/O requests inline.
1006 * The UFSHCI and eMMC standards define a standard way to do this, but it
1010 * call doesn't specify which ICE instance the keyslot belongs to.
1012 * Return: 0 on success; -errno on failure.
1034 * 'key' may point to vmalloc()'ed memory, but we need to pass a in qcom_scm_ice_set_key()
1035 * physical address that's been properly flushed. The sanctioned way to in qcom_scm_ice_set_key()
1040 * keys is normally rare and thus not performance-critical. in qcom_scm_ice_set_key()
1043 keybuf = dma_alloc_coherent(__scm->dev, key_size, &key_phys, in qcom_scm_ice_set_key()
1046 return -ENOMEM; in qcom_scm_ice_set_key()
1050 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_set_key()
1054 dma_free_coherent(__scm->dev, key_size, keybuf, key_phys); in qcom_scm_ice_set_key()
1060 * qcom_scm_hdcp_available() - Check if secure environment supports HDCP.
1072 avail = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_HDCP, in qcom_scm_hdcp_available()
1082 * qcom_scm_hdcp_req() - Send HDCP request.
1085 * @resp: response buffer passed to SCM
1113 return -ERANGE; in qcom_scm_hdcp_req()
1119 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_hdcp_req()
1140 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_qsmmu500_wait_safe_toggle()
1147 struct device_node *np = dev->of_node; in qcom_scm_find_dload_address()
1152 tcsr = of_parse_phandle(np, "qcom,dload-mode", 0); in qcom_scm_find_dload_address()
1161 ret = of_property_read_u32_index(np, "qcom,dload-mode", 1, &offset); in qcom_scm_find_dload_address()
1171 * qcom_scm_is_available() - Checks if SCM is available
1185 scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL); in qcom_scm_probe()
1187 return -ENOMEM; in qcom_scm_probe()
1189 ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr); in qcom_scm_probe()
1193 clks = (unsigned long)of_device_get_match_data(&pdev->dev); in qcom_scm_probe()
1195 scm->core_clk = devm_clk_get(&pdev->dev, "core"); in qcom_scm_probe()
1196 if (IS_ERR(scm->core_clk)) { in qcom_scm_probe()
1197 if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1198 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1201 dev_err(&pdev->dev, "failed to acquire core clk\n"); in qcom_scm_probe()
1202 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1205 scm->core_clk = NULL; in qcom_scm_probe()
1208 scm->iface_clk = devm_clk_get(&pdev->dev, "iface"); in qcom_scm_probe()
1209 if (IS_ERR(scm->iface_clk)) { in qcom_scm_probe()
1210 if (PTR_ERR(scm->iface_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1211 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1214 dev_err(&pdev->dev, "failed to acquire iface clk\n"); in qcom_scm_probe()
1215 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1218 scm->iface_clk = NULL; in qcom_scm_probe()
1221 scm->bus_clk = devm_clk_get(&pdev->dev, "bus"); in qcom_scm_probe()
1222 if (IS_ERR(scm->bus_clk)) { in qcom_scm_probe()
1223 if (PTR_ERR(scm->bus_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1224 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1227 dev_err(&pdev->dev, "failed to acquire bus clk\n"); in qcom_scm_probe()
1228 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1231 scm->bus_clk = NULL; in qcom_scm_probe()
1234 scm->reset.ops = &qcom_scm_pas_reset_ops; in qcom_scm_probe()
1235 scm->reset.nr_resets = 1; in qcom_scm_probe()
1236 scm->reset.of_node = pdev->dev.of_node; in qcom_scm_probe()
1237 ret = devm_reset_controller_register(&pdev->dev, &scm->reset); in qcom_scm_probe()
1242 ret = clk_set_rate(scm->core_clk, INT_MAX); in qcom_scm_probe()
1247 __scm->dev = &pdev->dev; in qcom_scm_probe()
1253 * will cause the the boot stages to enter download mode, unless in qcom_scm_probe()
1264 /* Clean shutdown, disable download mode to allow normal restart */ in qcom_scm_shutdown()
1270 { .compatible = "qcom,scm-apq8064",
1273 { .compatible = "qcom,scm-apq8084", .data = (void *)(SCM_HAS_CORE_CLK |
1277 { .compatible = "qcom,scm-ipq4019" },
1278 { .compatible = "qcom,scm-msm8660", .data = (void *) SCM_HAS_CORE_CLK },
1279 { .compatible = "qcom,scm-msm8960", .data = (void *) SCM_HAS_CORE_CLK },
1280 { .compatible = "qcom,scm-msm8916", .data = (void *)(SCM_HAS_CORE_CLK |
1284 { .compatible = "qcom,scm-msm8974", .data = (void *)(SCM_HAS_CORE_CLK |
1288 { .compatible = "qcom,scm-msm8994" },
1289 { .compatible = "qcom,scm-msm8996" },