Lines Matching +full:rpmsg +full:- +full:out
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
17 #include <linux/rpmsg/qcom_glink.h>
18 #include <linux/rpmsg/qcom_smd.h>
39 * struct minidump_region - Minidump region
55 * struct minidump_subsystem - Subsystem's SMEM Table of content
73 * struct minidump_global_toc - Global Table of Content
99 list_for_each_entry_safe(entry, tmp, &rproc->dump_segments, node) { in qcom_minidump_cleanup()
100 list_del(&entry->node); in qcom_minidump_cleanup()
101 kfree(entry->priv); in qcom_minidump_cleanup()
117 if (WARN_ON(!list_empty(&rproc->dump_segments))) { in qcom_add_minidump_segments()
118 dev_err(&rproc->dev, "dump segment list already populated\n"); in qcom_add_minidump_segments()
119 return -EUCLEAN; in qcom_add_minidump_segments()
122 seg_cnt = le32_to_cpu(subsystem->region_count); in qcom_add_minidump_segments()
123 ptr = ioremap((unsigned long)le64_to_cpu(subsystem->regions_baseptr), in qcom_add_minidump_segments()
126 return -EFAULT; in qcom_add_minidump_segments()
131 name = kstrndup(region.name, MAX_REGION_NAME_LENGTH - 1, GFP_KERNEL); in qcom_add_minidump_segments()
134 return -ENOMEM; in qcom_add_minidump_segments()
159 if (IS_ERR(toc) || !toc->status) { in qcom_minidump()
160 dev_err(&rproc->dev, "Minidump TOC not found in SMEM\n"); in qcom_minidump()
165 subsystem = &toc->subsystems[minidump_id]; in qcom_minidump()
171 if (subsystem->regions_baseptr == 0 || in qcom_minidump()
172 le32_to_cpu(subsystem->status) != 1 || in qcom_minidump()
173 le32_to_cpu(subsystem->enabled) != MINIDUMP_SS_ENABLED) { in qcom_minidump()
177 if (le32_to_cpu(subsystem->encryption_status) != MINIDUMP_SS_ENCR_DONE) { in qcom_minidump()
178 dev_err(&rproc->dev, "Minidump not ready, skipping\n"); in qcom_minidump()
183 * Clear out the dump segments populated by parse_fw before in qcom_minidump()
184 * re-populating them with minidump segments. in qcom_minidump()
190 dev_err(&rproc->dev, "Failed with error: %d while adding minidump entries\n", ret); in qcom_minidump()
203 glink->edge = qcom_glink_smem_register(glink->dev, glink->node); in glink_subdev_start()
205 return PTR_ERR_OR_ZERO(glink->edge); in glink_subdev_start()
212 qcom_glink_smem_unregister(glink->edge); in glink_subdev_stop()
213 glink->edge = NULL; in glink_subdev_stop()
220 qcom_glink_ssr_notify(glink->ssr_name); in glink_subdev_unprepare()
224 * qcom_add_glink_subdev() - try to add a GLINK subdevice to rproc
232 struct device *dev = &rproc->dev; in qcom_add_glink_subdev()
234 glink->node = of_get_child_by_name(dev->parent->of_node, "glink-edge"); in qcom_add_glink_subdev()
235 if (!glink->node) in qcom_add_glink_subdev()
238 glink->ssr_name = kstrdup_const(ssr_name, GFP_KERNEL); in qcom_add_glink_subdev()
239 if (!glink->ssr_name) in qcom_add_glink_subdev()
242 glink->dev = dev; in qcom_add_glink_subdev()
243 glink->subdev.start = glink_subdev_start; in qcom_add_glink_subdev()
244 glink->subdev.stop = glink_subdev_stop; in qcom_add_glink_subdev()
245 glink->subdev.unprepare = glink_subdev_unprepare; in qcom_add_glink_subdev()
247 rproc_add_subdev(rproc, &glink->subdev); in qcom_add_glink_subdev()
252 * qcom_remove_glink_subdev() - remove a GLINK subdevice from rproc
258 if (!glink->node) in qcom_remove_glink_subdev()
261 rproc_remove_subdev(rproc, &glink->subdev); in qcom_remove_glink_subdev()
262 kfree_const(glink->ssr_name); in qcom_remove_glink_subdev()
263 of_node_put(glink->node); in qcom_remove_glink_subdev()
268 * qcom_register_dump_segments() - register segments for coredump
285 ehdr = (struct elf32_hdr *)fw->data; in qcom_register_dump_segments()
288 for (i = 0; i < ehdr->e_phnum; i++) { in qcom_register_dump_segments()
291 if (phdr->p_type != PT_LOAD) in qcom_register_dump_segments()
294 if ((phdr->p_flags & QCOM_MDT_TYPE_MASK) == QCOM_MDT_TYPE_HASH) in qcom_register_dump_segments()
297 if (!phdr->p_memsz) in qcom_register_dump_segments()
300 ret = rproc_coredump_add_segment(rproc, phdr->p_paddr, in qcom_register_dump_segments()
301 phdr->p_memsz); in qcom_register_dump_segments()
314 smd->edge = qcom_smd_register_edge(smd->dev, smd->node); in smd_subdev_start()
316 return PTR_ERR_OR_ZERO(smd->edge); in smd_subdev_start()
323 qcom_smd_unregister_edge(smd->edge); in smd_subdev_stop()
324 smd->edge = NULL; in smd_subdev_stop()
328 * qcom_add_smd_subdev() - try to add a SMD subdevice to rproc
334 struct device *dev = &rproc->dev; in qcom_add_smd_subdev()
336 smd->node = of_get_child_by_name(dev->parent->of_node, "smd-edge"); in qcom_add_smd_subdev()
337 if (!smd->node) in qcom_add_smd_subdev()
340 smd->dev = dev; in qcom_add_smd_subdev()
341 smd->subdev.start = smd_subdev_start; in qcom_add_smd_subdev()
342 smd->subdev.stop = smd_subdev_stop; in qcom_add_smd_subdev()
344 rproc_add_subdev(rproc, &smd->subdev); in qcom_add_smd_subdev()
349 * qcom_remove_smd_subdev() - remove the smd subdevice from rproc
355 if (!smd->node) in qcom_remove_smd_subdev()
358 rproc_remove_subdev(rproc, &smd->subdev); in qcom_remove_smd_subdev()
359 of_node_put(smd->node); in qcom_remove_smd_subdev()
370 if (!strcmp(info->name, name)) in qcom_ssr_get_subsys()
371 goto out; in qcom_ssr_get_subsys()
375 info = ERR_PTR(-ENOMEM); in qcom_ssr_get_subsys()
376 goto out; in qcom_ssr_get_subsys()
378 info->name = kstrdup_const(name, GFP_KERNEL); in qcom_ssr_get_subsys()
379 srcu_init_notifier_head(&info->notifier_list); in qcom_ssr_get_subsys()
382 list_add_tail(&info->list, &qcom_ssr_subsystem_list); in qcom_ssr_get_subsys()
384 out: in qcom_ssr_get_subsys()
390 * qcom_register_ssr_notifier() - register SSR notification handler
409 srcu_notifier_chain_register(&info->notifier_list, nb); in qcom_register_ssr_notifier()
411 return &info->notifier_list; in qcom_register_ssr_notifier()
416 * qcom_unregister_ssr_notifier() - unregister SSR notification handler
435 .name = ssr->info->name, in ssr_notify_prepare()
439 srcu_notifier_call_chain(&ssr->info->notifier_list, in ssr_notify_prepare()
448 .name = ssr->info->name, in ssr_notify_start()
452 srcu_notifier_call_chain(&ssr->info->notifier_list, in ssr_notify_start()
461 .name = ssr->info->name, in ssr_notify_stop()
465 srcu_notifier_call_chain(&ssr->info->notifier_list, in ssr_notify_stop()
473 .name = ssr->info->name, in ssr_notify_unprepare()
477 srcu_notifier_call_chain(&ssr->info->notifier_list, in ssr_notify_unprepare()
482 * qcom_add_ssr_subdev() - register subdevice as restart notification source
498 dev_err(&rproc->dev, "Failed to add ssr subdevice\n"); in qcom_add_ssr_subdev()
502 ssr->info = info; in qcom_add_ssr_subdev()
503 ssr->subdev.prepare = ssr_notify_prepare; in qcom_add_ssr_subdev()
504 ssr->subdev.start = ssr_notify_start; in qcom_add_ssr_subdev()
505 ssr->subdev.stop = ssr_notify_stop; in qcom_add_ssr_subdev()
506 ssr->subdev.unprepare = ssr_notify_unprepare; in qcom_add_ssr_subdev()
508 rproc_add_subdev(rproc, &ssr->subdev); in qcom_add_ssr_subdev()
513 * qcom_remove_ssr_subdev() - remove subdevice as restart notification source
519 rproc_remove_subdev(rproc, &ssr->subdev); in qcom_remove_ssr_subdev()
520 ssr->info = NULL; in qcom_remove_ssr_subdev()
539 return -ENOMEM; in pdm_notify_prepare()
541 adev->dev.parent = pdm->dev; in pdm_notify_prepare()
542 adev->dev.release = pdm_dev_release; in pdm_notify_prepare()
543 adev->name = "pd-mapper"; in pdm_notify_prepare()
544 adev->id = pdm->index; in pdm_notify_prepare()
558 pdm->adev = adev; in pdm_notify_prepare()
568 if (!pdm->adev) in pdm_notify_unprepare()
571 auxiliary_device_delete(pdm->adev); in pdm_notify_unprepare()
572 auxiliary_device_uninit(pdm->adev); in pdm_notify_unprepare()
573 pdm->adev = NULL; in pdm_notify_unprepare()
577 * qcom_add_pdm_subdev() - register PD Mapper subdevice
586 pdm->dev = &rproc->dev; in qcom_add_pdm_subdev()
587 pdm->index = rproc->index; in qcom_add_pdm_subdev()
589 pdm->subdev.prepare = pdm_notify_prepare; in qcom_add_pdm_subdev()
590 pdm->subdev.unprepare = pdm_notify_unprepare; in qcom_add_pdm_subdev()
592 rproc_add_subdev(rproc, &pdm->subdev); in qcom_add_pdm_subdev()
597 * qcom_remove_pdm_subdev() - remove PD Mapper subdevice
605 rproc_remove_subdev(rproc, &pdm->subdev); in qcom_remove_pdm_subdev()