Skip to contentSkip to conversation

remoteproc: register a device for new remoteproc instances

PATCH Applied Ahmad Fatoum 2 participants 3 messages Nov 20, 2019 – Nov 25, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 remoteproc: register a device for new remoteproc instances

struct rproc has a device_d dev field, but so far it was unregistered. The implementation had a few downsides:

- dev_printf prints NULL, because the unique_name of the device is NULL
- The name used by firmwareload is the device tree node's name, which might be unnecessarily verbose, e.g. mlahb:[email protected]
- All remoteproc devices are given the same (unused) name and index

Fix these by registering a device for the remoteproc and using it where appropriate. While at it, allow the remoteproc name to come from a device tree alias as well.

This breaks user behavior in that firmwareload now uses the alias or remoteprocN to reference the remoteproc instance. This is probably acceptable as the driver is a very recent addition.

Cc Oleksij Rempel <[email protected]>
---
 drivers/remoteproc/remoteproc_core.c | 29 ++++++++++++++++++++++------
 include/linux/remoteproc.h           |  1 -
 2 files changed, 23 insertions(+), 7 deletions(-)
drivers/remoteproc/remoteproc_core.c +23 -6
index 7cac47e06ce9..8a28c1bafc1b 100644
@@ -107,14 +107,36 @@ static int rproc_firmware_finish(struct firmware_handler *fh)
 	return ret;
 }
 
+static int rproc_register_dev(struct rproc *rproc, const char *alias)
+{
+	if (alias) {
+		rproc->dev.id = DEVICE_ID_SINGLE;
+		dev_set_name(&rproc->dev, alias);
+	} else {
+		rproc->dev.id = DEVICE_ID_DYNAMIC;
+		dev_set_name(&rproc->dev, "remoteproc");
+	}
+
+	return register_device(&rproc->dev);
+}
+
 int rproc_add(struct rproc *rproc)
 {
 	struct device_d *dev = &rproc->dev;
 	struct firmware_handler *fh;
+	const char *alias = NULL;
 	int ret;
 
+	if (dev->device_node)
+		alias = of_alias_get(dev->device_node);
+
+	ret = rproc_register_dev(rproc, alias);
+	if (ret)
+		return ret;
+
 	fh = &rproc->fh;
-	fh->id = xstrdup(rproc->name);
+	fh->id = xstrdup(dev_name(dev));
+	fh->model = xstrdup(rproc->name);
 	fh->open = rproc_firmware_start;
 	fh->write = rproc_firmware_write_buf;
 	fh->close = rproc_firmware_finish;
@@ -153,11 +175,6 @@ struct rproc *rproc_alloc(struct device_d *dev, const char *name,
 	rproc->dev.parent = dev;
 	rproc->dev.priv = rproc;
 
-	/* Assign a unique device index and name */
-	rproc->index = 1;
-
-	dev_set_name(&rproc->dev, "remoteproc%d", rproc->index);
-
 	/* Default to ELF loader if no load function is specified */
 	if (!rproc->ops->load)
 		rproc->ops->load = rproc_elf_load_segments;
include/linux/remoteproc.h +0 -1
index feee9ee4eea7..c6264d1c0a49 100644
@@ -38,7 +38,6 @@ struct rproc {
 	void *priv;
 	struct rproc_ops *ops;
 	struct device_d dev;
-	int index;
 
 	void *fw_buf;
 	size_t fw_buf_ofs;
Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/2 remoteproc: add support for starting st,stm32mp1-m4

The STM32MP157C-DK2 has a Cortex-M4 MCU in addition to the two Cortex-A7 MPUs. This remoteproc driver allows barebox running on a Cortex-A7 core to bootstrap the MCU with an ELF binary.

Code ported from Linux v5.3 with rpmsg bits removed.

---
 drivers/remoteproc/Kconfig       |  10 ++
 drivers/remoteproc/Makefile      |   1 +
 drivers/remoteproc/stm32_rproc.c | 199 +++++++++++++++++++++++++++++++
 3 files changed, 210 insertions(+)
 create mode 100644 drivers/remoteproc/stm32_rproc.c
drivers/remoteproc/Kconfig +10 -0
index 8139b6442cc8..a193fadb69a9 100644
@@ -21,6 +21,16 @@ config IMX_REMOTEPROC
 
 	  It's safe to say N here.
 
+config STM32_REMOTEPROC
+	tristate "STM32 remoteproc support"
+	depends on ARCH_STM32MP
+	select MFD_SYSCON
+	help
+	  Say y here to support STM32 MCU processors via the
+	  remote processor framework.
+
+	  It's safe to say N here.
+
 endif # REMOTEPROC
 
 endmenu
drivers/remoteproc/Makefile +1 -0
index 107296922998..43658df5c6ac 100644
@@ -5,3 +5,4 @@
 
 obj-$(CONFIG_REMOTEPROC)		+= remoteproc_core.o remoteproc_elf_loader.o
 obj-$(CONFIG_IMX_REMOTEPROC)		+= imx_rproc.o
+obj-$(CONFIG_STM32_REMOTEPROC)		+= stm32_rproc.o
drivers/remoteproc/stm32_rproc.c new file +199 -0

199 lines not on this page · raw message

Signature · 7 lines
2.20.1


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#2 lore raw
In reply to Ahmad Fatoum
Quoted 16 lines · Ahmad Fatoum

struct rproc has a device_d dev field, but so far it was unregistered. The implementation had a few downsides:

- dev_printf prints NULL, because the unique_name of the device is NULL
- The name used by firmwareload is the device tree node's name, which might be unnecessarily verbose, e.g. mlahb:[email protected]
- All remoteproc devices are given the same (unused) name and index

Fix these by registering a device for the remoteproc and using it where appropriate. While at it, allow the remoteproc name to come from a device tree alias as well.

This breaks user behavior in that firmwareload now uses the alias or remoteprocN to reference the remoteproc instance. This is probably acceptable as the driver is a very recent addition.

Quoted 6 lines
Cc Oleksij Rempel <[email protected]>
---
 drivers/remoteproc/remoteproc_core.c | 29 ++++++++++++++++++++++------
 include/linux/remoteproc.h           |  1 -
 2 files changed, 23 insertions(+), 7 deletions(-)

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox