Hi,
This patchset brings support for Silicon Labs' CPC protocol as transport
layer for Greybus. As an example, a SPI driver is added as physical
layer and everything is bundled as a big kernel module. In the future,
as we plan to support other physical layers like SDIO, CPC core will be
its own module, and each physical layer CPC driver will be its own
module as well.
CPC implements some of the features of Unipro that Greybus relies upon,
like reliable transmission. CPC takes care of detecting transmission
errors and retransmit frames if necessary. There's also a flow-control
feature, preventing sending messages to full cports.
In addition to the host device over SPI part, there's also a class
driver for a vendor protocol that enables Bluetooth on supported
devices. This is mostly there to open the discussion on how a new
protocol should be added to Greybus.
Damien Riégel (6):
greybus: move host controller drivers comment in Makefile
greybus: cpc: add core logic
greybus: cpc: add SPI driver
greybus: add API for async unidirectional transfer
greybus: match device with bundle ID
greybus: add class driver for Silabs Bluetooth
MAINTAINERS | 12 +
drivers/greybus/Kconfig | 2 +
drivers/greybus/Makefile | 4 +-
drivers/greybus/core.c | 4 +
drivers/greybus/cpc/Kconfig | 12 +
drivers/greybus/cpc/Makefile | 6 +
drivers/greybus/cpc/cpc.h | 135 +++++++
drivers/greybus/cpc/endpoint.c | 158 ++++++++
drivers/greybus/cpc/header.c | 212 ++++++++++
drivers/greybus/cpc/header.h | 81 ++++
drivers/greybus/cpc/host.c | 113 ++++++
drivers/greybus/cpc/protocol.c | 274 +++++++++++++
drivers/greybus/cpc/spi.c | 585 +++++++++++++++++++++++++++
drivers/greybus/operation.c | 52 +++
drivers/staging/greybus/Kconfig | 9 +
drivers/staging/greybus/Makefile | 6 +
drivers/staging/greybus/silabs-ble.c | 203 ++++++++++
include/linux/greybus.h | 7 +-
include/linux/greybus/greybus_id.h | 2 +
include/linux/greybus/operation.h | 4 +
20 files changed, 1877 insertions(+), 4 deletions(-)
create mode 100644 drivers/greybus/cpc/Kconfig
create mode 100644 drivers/greybus/cpc/Makefile
create mode 100644 drivers/greybus/cpc/cpc.h
create mode 100644 drivers/greybus/cpc/endpoint.c
create mode 100644 drivers/greybus/cpc/header.c
create mode 100644 drivers/greybus/cpc/header.h
create mode 100644 drivers/greybus/cpc/host.c
create mode 100644 drivers/greybus/cpc/protocol.c
create mode 100644 drivers/greybus/cpc/spi.c
create mode 100644 drivers/staging/greybus/silabs-ble.c
--
2.49.0
Hey Akhil,
Thanks for your patch.
All looks good with the exception of a small nit...
On Mon Jul 14, 2025 at 2:56 PM WEST, Akhil Varkey wrote:
> Fix checkpatch check "CHECK:Alignment should match open parenthesis"
>
> Signed-off-by: Akhil Varkey <akhilvarkey(a)disroot.org>
> ---
>
> Hello, This is my first patch, I appreciate any feedbacks. Thanks!!
Welcome, and continue...
> ---
> drivers/staging/greybus/power_supply.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/greybus/power_supply.c b/drivers/staging/greybus/power_supply.c
> index 2ef46822f676..a484c0ca058d 100644
> --- a/drivers/staging/greybus/power_supply.c
> +++ b/drivers/staging/greybus/power_supply.c
> @@ -324,7 +324,7 @@ static struct gb_power_supply_prop *get_psy_prop(struct gb_power_supply *gbpsy,
> }
>
> static int is_psy_prop_writeable(struct gb_power_supply *gbpsy,
> - enum power_supply_property psp)
> + enum power_supply_property psp)
> {
> struct gb_power_supply_prop *prop;
>
> @@ -493,7 +493,7 @@ static int gb_power_supply_description_get(struct gb_power_supply *gbpsy)
> if (!gbpsy->model_name)
> return -ENOMEM;
> gbpsy->serial_number = kstrndup(resp.serial_number, PROP_MAX,
> - GFP_KERNEL);
> + GFP_KERNEL);
> if (!gbpsy->serial_number)
> return -ENOMEM;
>
> @@ -546,7 +546,7 @@ static int gb_power_supply_prop_descriptors_get(struct gb_power_supply *gbpsy)
> }
>
> gbpsy->props = kcalloc(gbpsy->properties_count, sizeof(*gbpsy->props),
> - GFP_KERNEL);
> + GFP_KERNEL);
> if (!gbpsy->props) {
> ret = -ENOMEM;
> goto out_put_operation;
> @@ -634,8 +634,8 @@ static int __gb_power_supply_property_get(struct gb_power_supply *gbpsy,
> }
>
> static int __gb_power_supply_property_strval_get(struct gb_power_supply *gbpsy,
> - enum power_supply_property psp,
> - union power_supply_propval *val)
> + enum power_supply_property psp,
> + union power_supply_propval *val)
Here you fix the alignment, but the last line goes over column 81, even
though 80 is not really one hard requirement anymore, all code
(strings is ok to go over to be easier to grep for messages) is on that
register.
So, to be coherent, if you could please send a V2 without this specific change
would be great, Or even better, if you could get rid of all the _ and __
prefixes in functions names that would be great, and will give more
space for function paramethers.
Your call.
Also, gives you also the chance to practice to send a new
version ;).
Cheers,
Rui
> {
> switch (psp) {
> case POWER_SUPPLY_PROP_MODEL_NAME:
> @@ -943,8 +943,8 @@ static int gb_power_supplies_setup(struct gb_power_supplies *supplies)
> goto out;
>
> supplies->supply = kcalloc(supplies->supplies_count,
> - sizeof(struct gb_power_supply),
> - GFP_KERNEL);
> + sizeof(struct gb_power_supply),
> + GFP_KERNEL);
>
> if (!supplies->supply) {
> ret = -ENOMEM;
> --
> 2.47.2
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(),
pm_runtime_autosuspend() and pm_request_autosuspend() now include a call
to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to
pm_runtime_mark_last_busy().
Signed-off-by: Sakari Ailus <sakari.ailus(a)linux.intel.com>
---
The cover letter of the set can be found here
<URL:https://lore.kernel.org/linux-pm/20250704075225.3212486-1-sakari.ailus@…>.
In brief, this patch depends on PM runtime patches adding marking the last
busy timestamp in autosuspend related functions. The patches are here, on
rc2:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
pm-runtime-6.17-rc1
drivers/greybus/bundle.c | 1 -
drivers/greybus/interface.c | 1 -
2 files changed, 2 deletions(-)
diff --git a/drivers/greybus/bundle.c b/drivers/greybus/bundle.c
index a6e1cca06172..269a82c5c757 100644
--- a/drivers/greybus/bundle.c
+++ b/drivers/greybus/bundle.c
@@ -155,7 +155,6 @@ static int gb_bundle_resume(struct device *dev)
static int gb_bundle_idle(struct device *dev)
{
- pm_runtime_mark_last_busy(dev);
pm_request_autosuspend(dev);
return 0;
diff --git a/drivers/greybus/interface.c b/drivers/greybus/interface.c
index a0f3e9422721..c49fe54c16ca 100644
--- a/drivers/greybus/interface.c
+++ b/drivers/greybus/interface.c
@@ -753,7 +753,6 @@ static int gb_interface_resume(struct device *dev)
static int gb_interface_runtime_idle(struct device *dev)
{
- pm_runtime_mark_last_busy(dev);
pm_request_autosuspend(dev);
return 0;
--
2.39.5
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(),
pm_runtime_autosuspend() and pm_request_autosuspend() now include a call
to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to
pm_runtime_mark_last_busy().
Signed-off-by: Sakari Ailus <sakari.ailus(a)linux.intel.com>
---
The cover letter of the set can be found here
<URL:https://lore.kernel.org/linux-pm/20250704075225.3212486-1-sakari.ailus@…>.
In brief, this patch depends on PM runtime patches adding marking the last
busy timestamp in autosuspend related functions. The patches are here, on
rc2:
git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git \
pm-runtime-6.17-rc1
drivers/staging/greybus/gbphy.c | 1 -
drivers/staging/greybus/gbphy.h | 1 -
2 files changed, 2 deletions(-)
diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c
index 6adcad286633..3068bd71cd98 100644
--- a/drivers/staging/greybus/gbphy.c
+++ b/drivers/staging/greybus/gbphy.c
@@ -53,7 +53,6 @@ static void gbphy_dev_release(struct device *dev)
#ifdef CONFIG_PM
static int gb_gbphy_idle(struct device *dev)
{
- pm_runtime_mark_last_busy(dev);
pm_request_autosuspend(dev);
return 0;
}
diff --git a/drivers/staging/greybus/gbphy.h b/drivers/staging/greybus/gbphy.h
index d4a225b76338..4a4ebc7f2b98 100644
--- a/drivers/staging/greybus/gbphy.h
+++ b/drivers/staging/greybus/gbphy.h
@@ -85,7 +85,6 @@ static inline void gbphy_runtime_put_autosuspend(struct gbphy_device *gbphy_dev)
{
struct device *dev = &gbphy_dev->dev;
- pm_runtime_mark_last_busy(dev);
pm_runtime_put_autosuspend(dev);
}
--
2.39.5
gbphy_dev_match_id() should be taking a const pointer, as the pointer
passed to it from the container_of() call was const to start with (it
was accidentally cast away with the call.) Fix this all up by correctly
marking the pointer types.
Cc: Johan Hovold <johan(a)kernel.org>
Cc: Alex Elder <elder(a)kernel.org>
Cc: greybus-dev(a)lists.linaro.org
Fixes: d69d80484598 ("driver core: have match() callback in struct bus_type take a const *")
Signed-off-by: Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
---
v2: - add Fixes: line as pointed out by Johan
- don't make gbphy_dev const, it's not needed, as pointed out by
Johan
drivers/staging/greybus/gbphy.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c
index 6adcad286633..60cf09a302a7 100644
--- a/drivers/staging/greybus/gbphy.c
+++ b/drivers/staging/greybus/gbphy.c
@@ -102,8 +102,8 @@ static int gbphy_dev_uevent(const struct device *dev, struct kobj_uevent_env *en
}
static const struct gbphy_device_id *
-gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
- struct gbphy_driver *gbphy_drv)
+gbphy_dev_match_id(const struct gbphy_device *gbphy_dev,
+ const struct gbphy_driver *gbphy_drv)
{
const struct gbphy_device_id *id = gbphy_drv->id_table;
@@ -119,7 +119,7 @@ gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
static int gbphy_dev_match(struct device *dev, const struct device_driver *drv)
{
- struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
+ const struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);
const struct gbphy_device_id *id;
--
2.50.0
Remove redundant gb_loopback_async_wait_all() as connection is disabled
at the beginning and no further incoming/outgoing requests are possible.
Signed-off-by: Pranav Tyagi <pranav.tyagi03(a)gmail.com>
---
drivers/staging/greybus/loopback.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c
index 1f19323b0e1a..9d0d4308ad25 100644
--- a/drivers/staging/greybus/loopback.c
+++ b/drivers/staging/greybus/loopback.c
@@ -1110,13 +1110,6 @@ static void gb_loopback_disconnect(struct gb_bundle *bundle)
gb_connection_latency_tag_disable(gb->connection);
debugfs_remove(gb->file);
- /*
- * FIXME: gb_loopback_async_wait_all() is redundant now, as connection
- * is disabled at the beginning and so we can't have any more
- * incoming/outgoing requests.
- */
- gb_loopback_async_wait_all(gb);
-
spin_lock_irqsave(&gb_dev.lock, flags);
gb_dev.count--;
spin_unlock_irqrestore(&gb_dev.lock, flags);
--
2.49.0