mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
![Linus Torvalds](/assets/img/avatar_default.png)
This contains a few bug fixes and a cleanup up of the resource-table handling in the framework, which removes the need for drivers with no resource table to provide a fake one. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJaeJRAAAoJEAsfOT8Nma3FcwYP/jk/ubIEEF8Ne2ZRhcyT9J/2 4sT8NJhmtHIALOlQPtKcHv766ukFtzN4Xd8fUgHiivVMOrYBbfiuO1MNXXEq2kyf 7lWqC1eJRaa7wmlQumNw5aIOvJPuCu0oFd+K8CoKowLco32tURzJ9ANtYeXKTc/n KCk4KgigXRzlUP+J8TZ75Uop+N5WREGbqOHhP/J8+PYmHY+IxPN4K1CHlOBITpJz eLX+gs51UUKOFLGusVS5CLpUOYUc+bfWkGGeqRzMISCloSDkxdwIGuVa630VE1sJ QkxvvNbhQWmaaeBfplMhNHT7wHgE87c2P6mvABu5Rsf+u8V3o6JzbBW5XgxxT5uU QER4NRzZ/288vuOnr6FPvmR5ZZg9TaU/9Ef1vYNFEXR1uhquBmYulSbJ9FenM2up qQkVRQuLWYo5JLRWshVMvA0u+HGv7iA+kcGGBTfWJQgYJTG7ytmEamqoCchBOiM1 cGOxGVkSD5tt8XBvSUx6wsmEkBqU8MGKbf77XFhYDBJNU2ZLuoETPnj2+Wjh8Myo 5R1B0jBsWjGZ90AAXoKT2rbw2QeaADpFSneWKVbDEyTczmFDjQNZ5Qhuk1X1U3wq VZwmZwe2TsdaRZJhO+8SfdfspR71j2ollT1iLO2ESR5lbZZmouBm+EeW8c/ri8yW ei1bP8q5f2qYfSNga0hc =awTj -----END PGP SIGNATURE----- Merge tag 'rproc-v4.16' of git://github.com/andersson/remoteproc Pull remoteproc updates from Bjorn Andersson: "This contains a few bug fixes and a cleanup up of the resource-table handling in the framework, which removes the need for drivers with no resource table to provide a fake one" * tag 'rproc-v4.16' of git://github.com/andersson/remoteproc: remoteproc: Reset table_ptr on stop remoteproc: Drop dangling find_rsc_table dummies remoteproc: Move resource table load logic to find remoteproc: Don't handle empty resource table remoteproc: Merge rproc_ops and rproc_fw_ops remoteproc: Clone rproc_ops in rproc_alloc() remoteproc: Cache resource table size remoteproc: Remove depricated crash completion virtio_remoteproc: correct put_device virtio_device.dev
197 lines
5.7 KiB
C
197 lines
5.7 KiB
C
/*
|
|
* Qualcomm Peripheral Image Loader helpers
|
|
*
|
|
* Copyright (C) 2016 Linaro Ltd
|
|
* Copyright (C) 2015 Sony Mobile Communications Inc
|
|
* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include <linux/firmware.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/module.h>
|
|
#include <linux/notifier.h>
|
|
#include <linux/remoteproc.h>
|
|
#include <linux/rpmsg/qcom_glink.h>
|
|
#include <linux/rpmsg/qcom_smd.h>
|
|
|
|
#include "remoteproc_internal.h"
|
|
#include "qcom_common.h"
|
|
|
|
#define to_glink_subdev(d) container_of(d, struct qcom_rproc_glink, subdev)
|
|
#define to_smd_subdev(d) container_of(d, struct qcom_rproc_subdev, subdev)
|
|
#define to_ssr_subdev(d) container_of(d, struct qcom_rproc_ssr, subdev)
|
|
|
|
static BLOCKING_NOTIFIER_HEAD(ssr_notifiers);
|
|
|
|
static int glink_subdev_probe(struct rproc_subdev *subdev)
|
|
{
|
|
struct qcom_rproc_glink *glink = to_glink_subdev(subdev);
|
|
|
|
glink->edge = qcom_glink_smem_register(glink->dev, glink->node);
|
|
|
|
return PTR_ERR_OR_ZERO(glink->edge);
|
|
}
|
|
|
|
static void glink_subdev_remove(struct rproc_subdev *subdev)
|
|
{
|
|
struct qcom_rproc_glink *glink = to_glink_subdev(subdev);
|
|
|
|
qcom_glink_smem_unregister(glink->edge);
|
|
glink->edge = NULL;
|
|
}
|
|
|
|
/**
|
|
* qcom_add_glink_subdev() - try to add a GLINK subdevice to rproc
|
|
* @rproc: rproc handle to parent the subdevice
|
|
* @glink: reference to a GLINK subdev context
|
|
*/
|
|
void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink)
|
|
{
|
|
struct device *dev = &rproc->dev;
|
|
|
|
glink->node = of_get_child_by_name(dev->parent->of_node, "glink-edge");
|
|
if (!glink->node)
|
|
return;
|
|
|
|
glink->dev = dev;
|
|
rproc_add_subdev(rproc, &glink->subdev, glink_subdev_probe, glink_subdev_remove);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_add_glink_subdev);
|
|
|
|
/**
|
|
* qcom_remove_glink_subdev() - remove a GLINK subdevice from rproc
|
|
* @rproc: rproc handle
|
|
* @glink: reference to a GLINK subdev context
|
|
*/
|
|
void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink)
|
|
{
|
|
rproc_remove_subdev(rproc, &glink->subdev);
|
|
of_node_put(glink->node);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_remove_glink_subdev);
|
|
|
|
static int smd_subdev_probe(struct rproc_subdev *subdev)
|
|
{
|
|
struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
|
|
|
|
smd->edge = qcom_smd_register_edge(smd->dev, smd->node);
|
|
|
|
return PTR_ERR_OR_ZERO(smd->edge);
|
|
}
|
|
|
|
static void smd_subdev_remove(struct rproc_subdev *subdev)
|
|
{
|
|
struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
|
|
|
|
qcom_smd_unregister_edge(smd->edge);
|
|
smd->edge = NULL;
|
|
}
|
|
|
|
/**
|
|
* qcom_add_smd_subdev() - try to add a SMD subdevice to rproc
|
|
* @rproc: rproc handle to parent the subdevice
|
|
* @smd: reference to a Qualcomm subdev context
|
|
*/
|
|
void qcom_add_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
|
|
{
|
|
struct device *dev = &rproc->dev;
|
|
|
|
smd->node = of_get_child_by_name(dev->parent->of_node, "smd-edge");
|
|
if (!smd->node)
|
|
return;
|
|
|
|
smd->dev = dev;
|
|
rproc_add_subdev(rproc, &smd->subdev, smd_subdev_probe, smd_subdev_remove);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_add_smd_subdev);
|
|
|
|
/**
|
|
* qcom_remove_smd_subdev() - remove the smd subdevice from rproc
|
|
* @rproc: rproc handle
|
|
* @smd: the SMD subdevice to remove
|
|
*/
|
|
void qcom_remove_smd_subdev(struct rproc *rproc, struct qcom_rproc_subdev *smd)
|
|
{
|
|
rproc_remove_subdev(rproc, &smd->subdev);
|
|
of_node_put(smd->node);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_remove_smd_subdev);
|
|
|
|
/**
|
|
* qcom_register_ssr_notifier() - register SSR notification handler
|
|
* @nb: notifier_block to notify for restart notifications
|
|
*
|
|
* Returns 0 on success, negative errno on failure.
|
|
*
|
|
* This register the @notify function as handler for restart notifications. As
|
|
* remote processors are stopped this function will be called, with the SSR
|
|
* name passed as a parameter.
|
|
*/
|
|
int qcom_register_ssr_notifier(struct notifier_block *nb)
|
|
{
|
|
return blocking_notifier_chain_register(&ssr_notifiers, nb);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_register_ssr_notifier);
|
|
|
|
/**
|
|
* qcom_unregister_ssr_notifier() - unregister SSR notification handler
|
|
* @nb: notifier_block to unregister
|
|
*/
|
|
void qcom_unregister_ssr_notifier(struct notifier_block *nb)
|
|
{
|
|
blocking_notifier_chain_unregister(&ssr_notifiers, nb);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_unregister_ssr_notifier);
|
|
|
|
static int ssr_notify_start(struct rproc_subdev *subdev)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static void ssr_notify_stop(struct rproc_subdev *subdev)
|
|
{
|
|
struct qcom_rproc_ssr *ssr = to_ssr_subdev(subdev);
|
|
|
|
blocking_notifier_call_chain(&ssr_notifiers, 0, (void *)ssr->name);
|
|
}
|
|
|
|
/**
|
|
* qcom_add_ssr_subdev() - register subdevice as restart notification source
|
|
* @rproc: rproc handle
|
|
* @ssr: SSR subdevice handle
|
|
* @ssr_name: identifier to use for notifications originating from @rproc
|
|
*
|
|
* As the @ssr is registered with the @rproc SSR events will be sent to all
|
|
* registered listeners in the system as the remoteproc is shut down.
|
|
*/
|
|
void qcom_add_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr,
|
|
const char *ssr_name)
|
|
{
|
|
ssr->name = ssr_name;
|
|
|
|
rproc_add_subdev(rproc, &ssr->subdev, ssr_notify_start, ssr_notify_stop);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_add_ssr_subdev);
|
|
|
|
/**
|
|
* qcom_remove_ssr_subdev() - remove subdevice as restart notification source
|
|
* @rproc: rproc handle
|
|
* @ssr: SSR subdevice handle
|
|
*/
|
|
void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr)
|
|
{
|
|
rproc_remove_subdev(rproc, &ssr->subdev);
|
|
}
|
|
EXPORT_SYMBOL_GPL(qcom_remove_ssr_subdev);
|
|
|
|
MODULE_DESCRIPTION("Qualcomm Remoteproc helper driver");
|
|
MODULE_LICENSE("GPL v2");
|