• Home
  • Raw
  • Download

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 * Per the "SMC calling convention specification", the 64-bit calling in __get_convention()
141 * convention can only be used when the client is 64-bit, otherwise in __get_convention()
146 * Device isn't required as there is only one argument - no device in __get_convention()
147 * needed to dma_map_single to secure world in __get_convention()
156 * QCOM_SCM_INFO_IS_CALL_AVAIL call, so we fallback to forcing ARM_64 in __get_convention()
159 * will be valid here to check if the compatible matches. in __get_convention()
161 if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL, "qcom,scm-sc7180")) { in __get_convention()
187 * qcom_scm_call() - Invoke a syscall in the secure world
193 * Sends a command to the SCM and waits for the command to finish processing.
194 * This should *only* be called in pre-emptible context.
208 return -EINVAL; in qcom_scm_call()
213 * qcom_scm_call_atomic() - atomic variation of qcom_scm_call()
220 * Sends a command to the SCM and waits for the command to finish processing.
235 return -EINVAL; in qcom_scm_call_atomic()
271 * qcom_scm_set_warm_boot_addr() - Set the warm boot address for cpus
275 * Set the Linux entry point for the SCM to transfer control to when coming
291 * to cpuidle entry point or vice versa. in qcom_scm_set_warm_boot_addr()
306 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_set_warm_boot_addr()
317 * qcom_scm_set_cold_boot_addr() - Set the cold boot address for cpus
342 return -EINVAL; in qcom_scm_set_cold_boot_addr()
354 return qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_set_cold_boot_addr()
359 * qcom_scm_cpu_power_down() - Power down the cpu
360 * @flags - Flags to flush cache
362 * This is an end point to power down cpu. If there was a pending interrupt,
363 * the control would return from this function, otherwise, the cpu jumps to the
376 qcom_scm_call_atomic(__scm ? __scm->dev : NULL, &desc, NULL); in qcom_scm_cpu_power_down()
393 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_set_remote_state()
411 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in __qcom_scm_set_dload_mode()
419 avail = __qcom_scm_is_call_available(__scm->dev, in qcom_scm_set_download_mode()
423 ret = __qcom_scm_set_dload_mode(__scm->dev, enable); in qcom_scm_set_download_mode()
424 } else if (__scm->dload_mode_addr) { in qcom_scm_set_download_mode()
425 ret = qcom_scm_io_writel(__scm->dload_mode_addr, in qcom_scm_set_download_mode()
428 dev_err(__scm->dev, in qcom_scm_set_download_mode()
433 dev_err(__scm->dev, "failed to set download mode: %d\n", ret); in qcom_scm_set_download_mode()
437 * qcom_scm_pas_init_image() - Initialize peripheral authentication service
438 * state machine for a given peripheral, using the
440 * @peripheral: peripheral id
441 * @metadata: pointer to memory containing ELF header, program header table
448 int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size) in qcom_scm_pas_init_image() argument
457 .args[0] = peripheral, in qcom_scm_pas_init_image()
463 * During the scm call memory protection will be enabled for the meta in qcom_scm_pas_init_image()
465 * non-cachable to avoid XPU violations. in qcom_scm_pas_init_image()
467 mdata_buf = dma_alloc_coherent(__scm->dev, size, &mdata_phys, in qcom_scm_pas_init_image()
470 dev_err(__scm->dev, "Allocation of metadata buffer failed.\n"); in qcom_scm_pas_init_image()
471 return -ENOMEM; in qcom_scm_pas_init_image()
481 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_init_image()
486 dma_free_coherent(__scm->dev, size, mdata_buf, mdata_phys); in qcom_scm_pas_init_image()
493 * qcom_scm_pas_mem_setup() - Prepare the memory related to a given peripheral
495 * @peripheral: peripheral id
496 * @addr: start address of memory area to prepare
497 * @size: size of the memory area to prepare
501 int qcom_scm_pas_mem_setup(u32 peripheral, phys_addr_t addr, phys_addr_t size) in qcom_scm_pas_mem_setup() argument
508 .args[0] = peripheral, in qcom_scm_pas_mem_setup()
519 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_mem_setup()
527 * qcom_scm_pas_auth_and_reset() - Authenticate the given peripheral firmware
529 * @peripheral: peripheral id
533 int qcom_scm_pas_auth_and_reset(u32 peripheral) in qcom_scm_pas_auth_and_reset() argument
540 .args[0] = peripheral, in qcom_scm_pas_auth_and_reset()
549 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_auth_and_reset()
557 * qcom_scm_pas_shutdown() - Shut down the remote processor
558 * @peripheral: peripheral id
562 int qcom_scm_pas_shutdown(u32 peripheral) in qcom_scm_pas_shutdown() argument
569 .args[0] = peripheral, in qcom_scm_pas_shutdown()
578 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_shutdown()
587 * qcom_scm_pas_supported() - Check if the peripheral authentication service is
589 * @peripheral: peripheral id
591 * Returns true if PAS is supported for this peripheral, otherwise false.
593 bool qcom_scm_pas_supported(u32 peripheral) in qcom_scm_pas_supported() argument
600 .args[0] = peripheral, in qcom_scm_pas_supported()
605 if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL, in qcom_scm_pas_supported()
609 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_pas_supported()
628 ret = qcom_scm_call(__scm->dev, &desc, &res); in __qcom_scm_pas_mss_reset()
637 return -EINVAL; in qcom_scm_pas_reset_assert()
639 return __qcom_scm_pas_mss_reset(__scm->dev, 1); in qcom_scm_pas_reset_assert()
646 return -EINVAL; in qcom_scm_pas_reset_deassert()
648 return __qcom_scm_pas_mss_reset(__scm->dev, 0); in qcom_scm_pas_reset_deassert()
669 ret = qcom_scm_call_atomic(__scm->dev, &desc, &res); in qcom_scm_io_readl()
688 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_io_writel()
693 * qcom_scm_restore_sec_cfg_available() - Check if secure environment
696 * Return true if restore-cfg interface is supported, false if not.
700 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_MP, in qcom_scm_restore_sec_cfg_available()
718 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_restore_sec_cfg()
736 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_iommu_secure_ptbl_size()
759 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_iommu_secure_ptbl_init()
762 if (ret == -EPERM) in qcom_scm_iommu_secure_ptbl_init()
787 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_mem_protect_video_var()
821 * qcom_scm_assign_mem() - Make a secure call to reassign memory ownership
822 * @mem_addr: mem region whose ownership need to be reassigned
858 ptr = dma_alloc_coherent(__scm->dev, ptr_sz, &ptr_phys, GFP_KERNEL); in qcom_scm_assign_mem()
860 return -ENOMEM; in qcom_scm_assign_mem()
868 /* Fill details of mem buff to map */ in qcom_scm_assign_mem()
871 mem_to_map->mem_addr = cpu_to_le64(mem_addr); in qcom_scm_assign_mem()
872 mem_to_map->mem_size = cpu_to_le64(mem_sz); in qcom_scm_assign_mem()
879 destvm->vmid = cpu_to_le32(newvm->vmid); in qcom_scm_assign_mem()
880 destvm->perm = cpu_to_le32(newvm->perm); in qcom_scm_assign_mem()
881 destvm->ctx = 0; in qcom_scm_assign_mem()
882 destvm->ctx_size = 0; in qcom_scm_assign_mem()
883 next_vm |= BIT(newvm->vmid); in qcom_scm_assign_mem()
886 ret = __qcom_scm_assign_mem(__scm->dev, mem_to_map_phys, mem_to_map_sz, in qcom_scm_assign_mem()
888 dma_free_coherent(__scm->dev, ptr_sz, ptr, ptr_phys); in qcom_scm_assign_mem()
890 dev_err(__scm->dev, in qcom_scm_assign_mem()
891 "Assign memory protection call failed %d\n", ret); in qcom_scm_assign_mem()
892 return -EINVAL; in qcom_scm_assign_mem()
901 * qcom_scm_ocmem_lock_available() - is OCMEM lock/unlock interface available
905 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_OCMEM, in qcom_scm_ocmem_lock_available()
911 * qcom_scm_ocmem_lock() - call OCMEM lock interface to assign an OCMEM
912 * region to the specified initiator
932 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_lock()
937 * qcom_scm_ocmem_unlock() - call OCMEM unlock interface to release an OCMEM
955 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ocmem_unlock()
960 * qcom_scm_ice_available() - Is the ICE key programming interface available?
967 return __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
969 __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_ES, in qcom_scm_ice_available()
975 * qcom_scm_ice_invalidate_key() - Invalidate an inline encryption key
976 * @index: the keyslot to invalidate
978 * The UFSHCI standard defines a standard way to do this, but it doesn't work on
981 * Return: 0 on success; -errno on failure.
993 return qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_invalidate_key()
998 * qcom_scm_ice_set_key() - Set an inline encryption key
999 * @index: the keyslot into which to set the key
1000 * @key: the key to program
1004 * individual plaintext and ciphertext. Given in 512-byte
1008 * can then be used to encrypt/decrypt UFS I/O requests inline.
1010 * The UFSHCI standard defines a standard way to do this, but it doesn't work on
1013 * Return: 0 on success; -errno on failure.
1035 * 'key' may point to vmalloc()'ed memory, but we need to pass a in qcom_scm_ice_set_key()
1036 * physical address that's been properly flushed. The sanctioned way to in qcom_scm_ice_set_key()
1041 * keys is normally rare and thus not performance-critical. in qcom_scm_ice_set_key()
1044 keybuf = dma_alloc_coherent(__scm->dev, key_size, &key_phys, in qcom_scm_ice_set_key()
1047 return -ENOMEM; in qcom_scm_ice_set_key()
1051 ret = qcom_scm_call(__scm->dev, &desc, NULL); in qcom_scm_ice_set_key()
1055 dma_free_coherent(__scm->dev, key_size, keybuf, key_phys); in qcom_scm_ice_set_key()
1061 * qcom_scm_hdcp_available() - Check if secure environment supports HDCP.
1073 avail = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_HDCP, in qcom_scm_hdcp_available()
1083 * qcom_scm_hdcp_req() - Send HDCP request.
1086 * @resp: response buffer passed to SCM
1114 return -ERANGE; in qcom_scm_hdcp_req()
1120 ret = qcom_scm_call(__scm->dev, &desc, &res); in qcom_scm_hdcp_req()
1141 return qcom_scm_call_atomic(__scm->dev, &desc, NULL); in qcom_scm_qsmmu500_wait_safe_toggle()
1148 struct device_node *np = dev->of_node; in qcom_scm_find_dload_address()
1153 tcsr = of_parse_phandle(np, "qcom,dload-mode", 0); in qcom_scm_find_dload_address()
1162 ret = of_property_read_u32_index(np, "qcom,dload-mode", 1, &offset); in qcom_scm_find_dload_address()
1172 * qcom_scm_is_available() - Checks if SCM is available
1186 scm = devm_kzalloc(&pdev->dev, sizeof(*scm), GFP_KERNEL); in qcom_scm_probe()
1188 return -ENOMEM; in qcom_scm_probe()
1190 ret = qcom_scm_find_dload_address(&pdev->dev, &scm->dload_mode_addr); in qcom_scm_probe()
1194 clks = (unsigned long)of_device_get_match_data(&pdev->dev); in qcom_scm_probe()
1196 scm->core_clk = devm_clk_get(&pdev->dev, "core"); in qcom_scm_probe()
1197 if (IS_ERR(scm->core_clk)) { in qcom_scm_probe()
1198 if (PTR_ERR(scm->core_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1199 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1202 dev_err(&pdev->dev, "failed to acquire core clk\n"); in qcom_scm_probe()
1203 return PTR_ERR(scm->core_clk); in qcom_scm_probe()
1206 scm->core_clk = NULL; in qcom_scm_probe()
1209 scm->iface_clk = devm_clk_get(&pdev->dev, "iface"); in qcom_scm_probe()
1210 if (IS_ERR(scm->iface_clk)) { in qcom_scm_probe()
1211 if (PTR_ERR(scm->iface_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1212 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1215 dev_err(&pdev->dev, "failed to acquire iface clk\n"); in qcom_scm_probe()
1216 return PTR_ERR(scm->iface_clk); in qcom_scm_probe()
1219 scm->iface_clk = NULL; in qcom_scm_probe()
1222 scm->bus_clk = devm_clk_get(&pdev->dev, "bus"); in qcom_scm_probe()
1223 if (IS_ERR(scm->bus_clk)) { in qcom_scm_probe()
1224 if (PTR_ERR(scm->bus_clk) == -EPROBE_DEFER) in qcom_scm_probe()
1225 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1228 dev_err(&pdev->dev, "failed to acquire bus clk\n"); in qcom_scm_probe()
1229 return PTR_ERR(scm->bus_clk); in qcom_scm_probe()
1232 scm->bus_clk = NULL; in qcom_scm_probe()
1235 scm->reset.ops = &qcom_scm_pas_reset_ops; in qcom_scm_probe()
1236 scm->reset.nr_resets = 1; in qcom_scm_probe()
1237 scm->reset.of_node = pdev->dev.of_node; in qcom_scm_probe()
1238 ret = devm_reset_controller_register(&pdev->dev, &scm->reset); in qcom_scm_probe()
1243 ret = clk_set_rate(scm->core_clk, INT_MAX); in qcom_scm_probe()
1248 __scm->dev = &pdev->dev; in qcom_scm_probe()
1254 * will cause the the boot stages to enter download mode, unless in qcom_scm_probe()
1265 /* 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" },