summaryrefslogtreecommitdiff
path: root/drivers/cdx/controller/cdx_controller.c
diff options
context:
space:
mode:
authorNipun Gupta <nipun.gupta@amd.com>2023-03-13 16:26:35 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-03-29 13:26:32 +0300
commit2a226927d9b836ddec674aebbcea311727d04240 (patch)
tree508575830ba25653e4d63ea2c7be34c9a630d0f1 /drivers/cdx/controller/cdx_controller.c
parent8a7923df35d3a0fa44985148cee5b7fde4a370ba (diff)
downloadlinux-2a226927d9b836ddec674aebbcea311727d04240.tar.xz
cdx: add rpmsg communication channel for CDX
RPMsg is used as a transport communication channel. This change introduces RPMsg driver and integrates it with the CDX controller. Signed-off-by: Abhijit Gangurde <abhijit.gangurde@amd.com> Signed-off-by: Nipun Gupta <nipun.gupta@amd.com> Reviewed-by: Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com> Tested-by: Nikhil Agarwal <nikhil.agarwal@amd.com> Link: https://lore.kernel.org/r/20230313132636.31850-7-nipun.gupta@amd.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/cdx/controller/cdx_controller.c')
-rw-r--r--drivers/cdx/controller/cdx_controller.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/drivers/cdx/controller/cdx_controller.c b/drivers/cdx/controller/cdx_controller.c
index fbebc8cdcbf8..0d1826980935 100644
--- a/drivers/cdx/controller/cdx_controller.c
+++ b/drivers/cdx/controller/cdx_controller.c
@@ -9,6 +9,7 @@
#include <linux/slab.h>
#include <linux/cdx/cdx_bus.h>
+#include "cdx_controller.h"
#include "../cdx.h"
#include "mcdi_functions.h"
#include "mcdi.h"
@@ -22,10 +23,8 @@ static void cdx_mcdi_request(struct cdx_mcdi *cdx,
const struct cdx_dword *hdr, size_t hdr_len,
const struct cdx_dword *sdu, size_t sdu_len)
{
- /*
- * This will get updated by rpmsg APIs, with RPMSG introduction
- * in CDX controller as a transport layer.
- */
+ if (cdx_rpmsg_send(cdx, hdr, hdr_len, sdu, sdu_len))
+ dev_err(&cdx->rpdev->dev, "Failed to send rpmsg data\n");
}
static const struct cdx_mcdi_ops mcdi_ops = {
@@ -33,6 +32,19 @@ static const struct cdx_mcdi_ops mcdi_ops = {
.mcdi_request = cdx_mcdi_request,
};
+void cdx_rpmsg_post_probe(struct cdx_controller *cdx)
+{
+ /* Register CDX controller with CDX bus driver */
+ if (cdx_register_controller(cdx))
+ dev_err(cdx->dev, "Failed to register CDX controller\n");
+}
+
+void cdx_rpmsg_pre_remove(struct cdx_controller *cdx)
+{
+ cdx_unregister_controller(cdx);
+ cdx_mcdi_wait_for_quiescence(cdx->priv, MCDI_RPC_TIMEOUT);
+}
+
static int cdx_scan_devices(struct cdx_controller *cdx)
{
struct cdx_mcdi *cdx_mcdi = cdx->priv;
@@ -124,8 +136,18 @@ static int xlnx_cdx_probe(struct platform_device *pdev)
cdx->priv = cdx_mcdi;
cdx->ops = &cdx_ops;
+ ret = cdx_setup_rpmsg(pdev);
+ if (ret) {
+ if (ret != -EPROBE_DEFER)
+ dev_err(&pdev->dev, "Failed to register CDX RPMsg transport\n");
+ goto cdx_rpmsg_fail;
+ }
+
+ dev_info(&pdev->dev, "Successfully registered CDX controller with RPMsg as transport\n");
return 0;
+cdx_rpmsg_fail:
+ kfree(cdx);
cdx_alloc_fail:
cdx_mcdi_finish(cdx_mcdi);
mcdi_init_fail:
@@ -139,6 +161,8 @@ static int xlnx_cdx_remove(struct platform_device *pdev)
struct cdx_controller *cdx = platform_get_drvdata(pdev);
struct cdx_mcdi *cdx_mcdi = cdx->priv;
+ cdx_destroy_rpmsg(pdev);
+
kfree(cdx);
cdx_mcdi_finish(cdx_mcdi);