From: "Damien Riégel" <damien.riegel@silabs.com>
To: greybus-dev@lists.linaro.org, Johan Hovold <johan@kernel.org>,
Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Cc: "Silicon Labs Kernel Team" <linux-devel@silabs.com>,
"Damien Riégel" <damien.riegel@silabs.com>
Subject: [PATCH v2 01/14] greybus: cpc: add minimal CPC Host Device infrastructure
Date: Thu, 15 Jan 2026 10:57:54 -0500 [thread overview]
Message-ID: <20260115155808.36102-2-damien.riegel@silabs.com> (raw)
In-Reply-To: <20260115155808.36102-1-damien.riegel@silabs.com>
As the first step for adding CPC support with Greybus, add a very
minimal module for CPC Host Devices. For now, this module only proxies
calls to the Greybus Host Device API and does nothing useful, but
further commits will use this base to add features.
Signed-off-by: Damien Riégel <damien.riegel@silabs.com>
---
MAINTAINERS | 6 +++
drivers/greybus/Kconfig | 2 +
drivers/greybus/Makefile | 2 +
drivers/greybus/cpc/Kconfig | 10 +++++
drivers/greybus/cpc/Makefile | 6 +++
drivers/greybus/cpc/host.c | 84 ++++++++++++++++++++++++++++++++++++
drivers/greybus/cpc/host.h | 40 +++++++++++++++++
7 files changed, 150 insertions(+)
create mode 100644 drivers/greybus/cpc/Kconfig
create mode 100644 drivers/greybus/cpc/Makefile
create mode 100644 drivers/greybus/cpc/host.c
create mode 100644 drivers/greybus/cpc/host.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 6d1de82e6dc..56daf9ec310 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -10774,6 +10774,12 @@ S: Maintained
F: Documentation/devicetree/bindings/net/ti,cc1352p7.yaml
F: drivers/greybus/gb-beagleplay.c
+GREYBUS CPC DRIVERS
+M: Damien Riégel <damien.riegel@silabs.com>
+R: Silicon Labs Kernel Team <linux-devel@silabs.com>
+S: Supported
+F: drivers/greybus/cpc/*
+
GREYBUS SUBSYSTEM
M: Johan Hovold <johan@kernel.org>
M: Alex Elder <elder@kernel.org>
diff --git a/drivers/greybus/Kconfig b/drivers/greybus/Kconfig
index c3f056d28b0..565a0fdcb2c 100644
--- a/drivers/greybus/Kconfig
+++ b/drivers/greybus/Kconfig
@@ -30,6 +30,8 @@ config GREYBUS_BEAGLEPLAY
To compile this code as a module, chose M here: the module
will be called gb-beagleplay.ko
+source "drivers/greybus/cpc/Kconfig"
+
config GREYBUS_ES2
tristate "Greybus ES3 USB host controller"
depends on USB
diff --git a/drivers/greybus/Makefile b/drivers/greybus/Makefile
index d986e94f889..92fe1d62691 100644
--- a/drivers/greybus/Makefile
+++ b/drivers/greybus/Makefile
@@ -21,6 +21,8 @@ ccflags-y += -I$(src)
obj-$(CONFIG_GREYBUS_BEAGLEPLAY) += gb-beagleplay.o
# Greybus Host controller drivers
+obj-$(CONFIG_GREYBUS_CPC) += cpc/
+
gb-es2-y := es2.o
obj-$(CONFIG_GREYBUS_ES2) += gb-es2.o
diff --git a/drivers/greybus/cpc/Kconfig b/drivers/greybus/cpc/Kconfig
new file mode 100644
index 00000000000..ab96fedd0de
--- /dev/null
+++ b/drivers/greybus/cpc/Kconfig
@@ -0,0 +1,10 @@
+# SPDX-License-Identifier: GPL-2.0
+
+config GREYBUS_CPC
+ tristate "Greybus CPC driver"
+ help
+ Select this option if you have a Silicon Labs device that acts as a
+ Greybus SVC.
+
+ To compile this code as a module, chose M here: the module will be
+ called gb-cpc.ko
diff --git a/drivers/greybus/cpc/Makefile b/drivers/greybus/cpc/Makefile
new file mode 100644
index 00000000000..490982a0ff5
--- /dev/null
+++ b/drivers/greybus/cpc/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+gb-cpc-y := host.o
+
+# CPC core
+obj-$(CONFIG_GREYBUS_CPC) += gb-cpc.o
diff --git a/drivers/greybus/cpc/host.c b/drivers/greybus/cpc/host.c
new file mode 100644
index 00000000000..80516517ff6
--- /dev/null
+++ b/drivers/greybus/cpc/host.c
@@ -0,0 +1,84 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2025, Silicon Laboratories, Inc.
+ */
+
+#include <linux/err.h>
+#include <linux/greybus.h>
+#include <linux/module.h>
+
+#include "host.h"
+
+static struct cpc_host_device *gb_hd_to_cpc_hd(struct gb_host_device *hd)
+{
+ return (struct cpc_host_device *)&hd->hd_priv;
+}
+
+static int cpc_gb_message_send(struct gb_host_device *gb_hd, u16 cport_id,
+ struct gb_message *message, gfp_t gfp_mask)
+{
+ struct cpc_host_device *cpc_hd = gb_hd_to_cpc_hd(gb_hd);
+
+ return cpc_hd->driver->message_send(cpc_hd, cport_id, message, gfp_mask);
+}
+
+static void cpc_gb_message_cancel(struct gb_message *message)
+{
+ /* Not implemented */
+}
+
+static struct gb_hd_driver cpc_gb_driver = {
+ .hd_priv_size = sizeof(struct cpc_host_device),
+ .message_send = cpc_gb_message_send,
+ .message_cancel = cpc_gb_message_cancel,
+};
+
+struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct device *parent)
+{
+ struct cpc_host_device *cpc_hd;
+ struct gb_host_device *hd;
+
+ if ((!driver->message_send) || (!driver->message_cancel)) {
+ dev_err(parent, "missing mandatory callbacks\n");
+ return ERR_PTR(-EINVAL);
+ }
+
+ hd = gb_hd_create(&cpc_gb_driver, parent, GB_CPC_MSG_SIZE_MAX, GB_CPC_NUM_CPORTS);
+ if (IS_ERR(hd))
+ return (struct cpc_host_device *)hd;
+
+ cpc_hd = gb_hd_to_cpc_hd(hd);
+ cpc_hd->gb_hd = hd;
+ cpc_hd->driver = driver;
+
+ return cpc_hd;
+}
+EXPORT_SYMBOL_GPL(cpc_hd_create);
+
+int cpc_hd_add(struct cpc_host_device *cpc_hd)
+{
+ return gb_hd_add(cpc_hd->gb_hd);
+}
+EXPORT_SYMBOL_GPL(cpc_hd_add);
+
+void cpc_hd_put(struct cpc_host_device *cpc_hd)
+{
+ return gb_hd_put(cpc_hd->gb_hd);
+}
+EXPORT_SYMBOL_GPL(cpc_hd_put);
+
+void cpc_hd_del(struct cpc_host_device *cpc_hd)
+{
+ return gb_hd_del(cpc_hd->gb_hd);
+}
+EXPORT_SYMBOL_GPL(cpc_hd_del);
+
+void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, u16 cport_id, u8 *data, size_t length)
+{
+ greybus_data_rcvd(cpc_hd->gb_hd, cport_id, data, length);
+}
+EXPORT_SYMBOL_GPL(cpc_hd_rcvd);
+
+MODULE_DESCRIPTION("Greybus over CPC");
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Silicon Laboratories, Inc.");
diff --git a/drivers/greybus/cpc/host.h b/drivers/greybus/cpc/host.h
new file mode 100644
index 00000000000..f55feb303f4
--- /dev/null
+++ b/drivers/greybus/cpc/host.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2025, Silicon Laboratories, Inc.
+ */
+
+#ifndef __CPC_HOST_H
+#define __CPC_HOST_H
+
+#include <linux/device.h>
+#include <linux/greybus.h>
+#include <linux/types.h>
+
+#define GB_CPC_MSG_SIZE_MAX 4096
+#define GB_CPC_NUM_CPORTS 8
+
+struct cpc_host_device;
+
+struct cpc_hd_driver {
+ int (*message_send)(struct cpc_host_device *hd, u16 dest_cport_id,
+ struct gb_message *message, gfp_t gfp_mask);
+ void (*message_cancel)(struct gb_message *message);
+};
+
+/**
+ * struct cpc_host_device - CPC host device.
+ * @gb_hd: pointer to Greybus Host Device this device belongs to.
+ * @driver: driver operations.
+ */
+struct cpc_host_device {
+ struct gb_host_device *gb_hd;
+ const struct cpc_hd_driver *driver;
+};
+
+struct cpc_host_device *cpc_hd_create(struct cpc_hd_driver *driver, struct device *parent);
+int cpc_hd_add(struct cpc_host_device *cpc_hd);
+void cpc_hd_put(struct cpc_host_device *cpc_hd);
+void cpc_hd_del(struct cpc_host_device *cpc_hd);
+void cpc_hd_rcvd(struct cpc_host_device *cpc_hd, u16 cport_id, u8 *data, size_t length);
+
+#endif
--
2.52.0
next prev parent reply other threads:[~2026-01-15 16:10 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 15:57 [PATCH v2 00/14] greybus: introduce CPC as transport layer Damien Riégel
2026-01-15 15:57 ` Damien Riégel [this message]
2026-01-16 15:11 ` [PATCH v2 01/14] greybus: cpc: add minimal CPC Host Device infrastructure Greg Kroah-Hartman
2026-01-27 21:11 ` Damien Riégel
2026-01-15 15:57 ` [PATCH v2 02/14] greybus: cpc: introduce CPC cport structure Damien Riégel
2026-01-15 15:57 ` [PATCH v2 03/14] greybus: cpc: use socket buffers instead of gb_message in TX path Damien Riégel
2026-01-15 15:57 ` [PATCH v2 04/14] greybus: cpc: pack cport ID in Greybus header Damien Riégel
2026-01-15 15:57 ` [PATCH v2 05/14] greybus: cpc: switch RX path to socket buffers Damien Riégel
2026-01-15 15:57 ` [PATCH v2 06/14] greybus: cpc: introduce CPC header structure Damien Riégel
2026-01-15 21:46 ` Jérôme Pouiller
2026-01-15 15:58 ` [PATCH v2 07/14] greybus: cpc: account for CPC header size in RX and TX path Damien Riégel
2026-01-15 15:58 ` [PATCH v2 08/14] greybus: cpc: add and validate sequence numbers Damien Riégel
2026-01-15 21:46 ` Jérôme Pouiller
2026-01-15 15:58 ` [PATCH v2 09/14] greybus: cpc: acknowledge all incoming messages Damien Riégel
2026-01-15 15:58 ` [PATCH v2 10/14] greybus: cpc: use holding queue instead of sending out immediately Damien Riégel
2026-01-15 15:58 ` [PATCH v2 11/14] greybus: cpc: honour remote's RX window Damien Riégel
2026-01-15 15:58 ` [PATCH v2 12/14] greybus: cpc: let host device drivers dequeue TX frames Damien Riégel
2026-01-15 15:58 ` [PATCH v2 13/14] greybus: cpc: add private data pointer in CPC Host Device Damien Riégel
2026-01-15 15:58 ` [PATCH v2 14/14] greybus: cpc: add CPC SDIO host driver Damien Riégel
2026-01-15 21:46 ` Jérôme Pouiller
2026-01-15 22:34 ` Jérôme Pouiller
2026-01-15 21:46 ` [PATCH v2 00/14] greybus: introduce CPC as transport layer Jérôme Pouiller
2026-01-15 22:48 ` Jérôme Pouiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260115155808.36102-2-damien.riegel@silabs.com \
--to=damien.riegel@silabs.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-devel@silabs.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®