Lines Matching +full:meson +full:- +full:gxbb +full:- +full:sm
1 // SPDX-License-Identifier: GPL-2.0-only
9 #define pr_fmt(fmt) "meson-sm: " fmt
11 #include <linux/arm-smccc.h>
23 #include <linux/firmware/meson/meson_sm.h>
62 const struct meson_sm_cmd *cmd = chip->cmd; in meson_sm_get_cmd()
64 while (cmd->smc_id && cmd->index != cmd_index) in meson_sm_get_cmd()
67 return cmd->smc_id; in meson_sm_get_cmd()
91 * meson_sm_call - generic SMC32 call to the secure-monitor
93 * @fw: Pointer to secure-monitor firmware
109 if (!fw->chip) in meson_sm_call()
110 return -ENOENT; in meson_sm_call()
112 cmd = meson_sm_get_cmd(fw->chip, cmd_index); in meson_sm_call()
114 return -EINVAL; in meson_sm_call()
126 * meson_sm_call_read - retrieve data from secure-monitor
128 * @fw: Pointer to secure-monitor firmware
149 if (!fw->chip) in meson_sm_call_read()
150 return -ENOENT; in meson_sm_call_read()
152 if (!fw->chip->cmd_shmem_out_base) in meson_sm_call_read()
153 return -EINVAL; in meson_sm_call_read()
155 if (bsize > fw->chip->shmem_size) in meson_sm_call_read()
156 return -EINVAL; in meson_sm_call_read()
159 return -EINVAL; in meson_sm_call_read()
162 return -EINVAL; in meson_sm_call_read()
170 memcpy(buffer, fw->sm_shmem_out_base, size); in meson_sm_call_read()
177 * meson_sm_call_write - send data to secure-monitor
179 * @fw: Pointer to secure-monitor firmware
197 if (!fw->chip) in meson_sm_call_write()
198 return -ENOENT; in meson_sm_call_write()
200 if (size > fw->chip->shmem_size) in meson_sm_call_write()
201 return -EINVAL; in meson_sm_call_write()
203 if (!fw->chip->cmd_shmem_in_base) in meson_sm_call_write()
204 return -EINVAL; in meson_sm_call_write()
206 memcpy(fw->sm_shmem_in_base, buffer, size); in meson_sm_call_write()
209 return -EINVAL; in meson_sm_call_write()
212 return -EINVAL; in meson_sm_call_write()
219 * meson_sm_get - get pointer to meson_sm_firmware structure.
221 * @sm_node: Pointer to the secure-monitor Device Tree node.
223 * Return: NULL is the secure-monitor device is not ready.
252 return -ENOMEM; in serial_show()
280 { .compatible = "amlogic,meson-gxbb-sm", .data = &gxbb_chip },
286 struct device *dev = &pdev->dev; in meson_sm_probe()
292 return -ENOMEM; in meson_sm_probe()
294 chip = of_match_device(meson_sm_ids, dev)->data; in meson_sm_probe()
296 if (chip->cmd_shmem_in_base) { in meson_sm_probe()
297 fw->sm_shmem_in_base = meson_sm_map_shmem(chip->cmd_shmem_in_base, in meson_sm_probe()
298 chip->shmem_size); in meson_sm_probe()
299 if (WARN_ON(!fw->sm_shmem_in_base)) in meson_sm_probe()
303 if (chip->cmd_shmem_out_base) { in meson_sm_probe()
304 fw->sm_shmem_out_base = meson_sm_map_shmem(chip->cmd_shmem_out_base, in meson_sm_probe()
305 chip->shmem_size); in meson_sm_probe()
306 if (WARN_ON(!fw->sm_shmem_out_base)) in meson_sm_probe()
310 fw->chip = chip; in meson_sm_probe()
314 pr_info("secure-monitor enabled\n"); in meson_sm_probe()
316 if (sysfs_create_group(&pdev->dev.kobj, &meson_sm_sysfs_attr_group)) in meson_sm_probe()
322 iounmap(fw->sm_shmem_in_base); in meson_sm_probe()
324 return -EINVAL; in meson_sm_probe()
329 .name = "meson-sm",