Lines Matching +full:secure +full:- +full:firmware

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Amlogic Secure Monitor driver
9 #define pr_fmt(fmt) "meson-sm: " fmt
11 #include <linux/arm-smccc.h>
24 #include <linux/firmware/meson/meson_sm.h>
63 const struct meson_sm_cmd *cmd = chip->cmd; in meson_sm_get_cmd()
65 while (cmd->smc_id && cmd->index != cmd_index) in meson_sm_get_cmd()
68 return cmd->smc_id; in meson_sm_get_cmd()
92 * meson_sm_call - generic SMC32 call to the secure-monitor
94 * @fw: Pointer to secure-monitor firmware
111 if (!fw->chip) in meson_sm_call()
112 return -ENOENT; in meson_sm_call()
114 cmd = meson_sm_get_cmd(fw->chip, cmd_index); in meson_sm_call()
116 return -EINVAL; in meson_sm_call()
128 * meson_sm_call_read - retrieve data from secure-monitor
130 * @fw: Pointer to secure-monitor firmware
151 if (!fw->chip) in meson_sm_call_read()
152 return -ENOENT; in meson_sm_call_read()
154 if (!fw->chip->cmd_shmem_out_base) in meson_sm_call_read()
155 return -EINVAL; in meson_sm_call_read()
157 if (bsize > fw->chip->shmem_size) in meson_sm_call_read()
158 return -EINVAL; in meson_sm_call_read()
161 return -EINVAL; in meson_sm_call_read()
164 return -EINVAL; in meson_sm_call_read()
177 memcpy(buffer, fw->sm_shmem_out_base, size); in meson_sm_call_read()
184 * meson_sm_call_write - send data to secure-monitor
186 * @fw: Pointer to secure-monitor firmware
204 if (!fw->chip) in meson_sm_call_write()
205 return -ENOENT; in meson_sm_call_write()
207 if (size > fw->chip->shmem_size) in meson_sm_call_write()
208 return -EINVAL; in meson_sm_call_write()
210 if (!fw->chip->cmd_shmem_in_base) in meson_sm_call_write()
211 return -EINVAL; in meson_sm_call_write()
213 memcpy(fw->sm_shmem_in_base, buffer, size); in meson_sm_call_write()
216 return -EINVAL; in meson_sm_call_write()
219 return -EINVAL; in meson_sm_call_write()
226 * meson_sm_get - get pointer to meson_sm_firmware structure.
228 * @sm_node: Pointer to the secure-monitor Device Tree node.
230 * Return: NULL is the secure-monitor device is not ready.
259 return -ENOMEM; in serial_show()
284 { .compatible = "amlogic,meson-gxbb-sm", .data = &gxbb_chip },
290 struct device *dev = &pdev->dev; in meson_sm_probe()
296 return -ENOMEM; in meson_sm_probe()
300 return -EINVAL; in meson_sm_probe()
302 if (chip->cmd_shmem_in_base) { in meson_sm_probe()
303 fw->sm_shmem_in_base = meson_sm_map_shmem(chip->cmd_shmem_in_base, in meson_sm_probe()
304 chip->shmem_size); in meson_sm_probe()
305 if (WARN_ON(!fw->sm_shmem_in_base)) in meson_sm_probe()
309 if (chip->cmd_shmem_out_base) { in meson_sm_probe()
310 fw->sm_shmem_out_base = meson_sm_map_shmem(chip->cmd_shmem_out_base, in meson_sm_probe()
311 chip->shmem_size); in meson_sm_probe()
312 if (WARN_ON(!fw->sm_shmem_out_base)) in meson_sm_probe()
316 fw->chip = chip; in meson_sm_probe()
323 pr_info("secure-monitor enabled\n"); in meson_sm_probe()
328 iounmap(fw->sm_shmem_out_base); in meson_sm_probe()
330 iounmap(fw->sm_shmem_in_base); in meson_sm_probe()
332 return -EINVAL; in meson_sm_probe()
337 .name = "meson-sm",
343 MODULE_DESCRIPTION("Amlogic Secure Monitor driver");