Skip to contentSkip to conversation

add syscon_regmap_lookup_by_phandle() support

PATCH New Oleksij Rempel 1 participant 4 messages Jun 7, 2019

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

PATCH v2 1/4 add syscon_regmap_lookup_by_phandle() support

needed for remoteproc port

---
 drivers/mfd/syscon.c | 19 +++++++++++++++++++
 include/mfd/syscon.h |  7 +++++++
 2 files changed, 26 insertions(+)
drivers/mfd/syscon.c +19 -0
index b1ff1b1ea..809941937 100644
@@ -174,6 +174,25 @@ struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
 	return regmap;
 }
 
+struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
+					const char *property)
+{
+	struct device_node *syscon_np;
+	struct regmap *regmap;
+
+	if (property)
+		syscon_np = of_parse_phandle(np, property, 0);
+	else
+		syscon_np = np;
+
+	if (!syscon_np)
+		return ERR_PTR(-ENODEV);
+
+	regmap = syscon_node_to_regmap(syscon_np);
+
+	return regmap;
+}
+
 static int syscon_probe(struct device_d *dev)
 {
 	struct syscon *syscon;
include/mfd/syscon.h +7 -0
index 902f9fa2f..3e39c333f 100644
@@ -22,6 +22,8 @@ void __iomem *syscon_base_lookup_by_phandle
 	(struct device_node *np, const char *property);
 struct regmap *syscon_node_to_regmap(struct device_node *np);
 struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
+struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
+					const char *property);
 #else
 static inline void __iomem *syscon_base_lookup_by_pdevname(const char *s)
 {
@@ -42,6 +44,11 @@ static inline struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
 {
 	return ERR_PTR(-ENOSYS);
 }
+struct regmap *syscon_regmap_lookup_by_phandle(struct device_node *np,
+					const char *property)
+{
+	return ERR_PTR(-ENOSYS);
+}
 #endif
 
 #endif

--
2.20.1

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

#1 lore raw

PATCH v2 2/4 elf: add missing elf32_shdr

needed for remoteproc port

---
 include/elf.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/elf.h +1 -1
index 92c8d9c12..e1deb3fe0 100644
@@ -286,7 +286,7 @@ typedef struct elf64_phdr {
 #define SHN_COMMON	0xfff2
 #define SHN_HIRESERVE	0xffff
 
-typedef struct {
+typedef struct elf32_shdr {
   Elf32_Word	sh_name;
   Elf32_Word	sh_type;
   Elf32_Word	sh_flags;

--
2.20.1

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

#2 lore raw

PATCH v2 3/4 of: base: don't try to read cells_name property if no cells_name set

In reply to Oleksij Rempel

Some device tree node parsed by of_count_phandle_with_args() have no #*-cells parameter. To make linux device trees work with barebox, we should accept cells_name set to NULL, so sync this behavior with linux.

---
 drivers/of/base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/of/base.c +2 -1
index 838f530f8..d72c687ef 100644
@@ -1360,7 +1360,8 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
 					 np->full_name);
 				goto err;
 			}
-			if (of_property_read_u32(node, cells_name, &count)) {
+			if (cells_name &&
+			    of_property_read_u32(node, cells_name, &count)) {
 				pr_err("%s: could not get %s for %s\n",
 					 np->full_name, cells_name,
 					 node->full_name);

--
2.20.1

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

#3 lore raw

PATCH v2 4/4 port reduced version of remoteproc framework from linux

In reply to Oleksij Rempel

I tested it on phytec imx7 board with remoteproc ELF image previously used on Linux. Linux would load this image, create appropriate resource (if defined in image) and boot it. The barebox version is only loading image and boot it.

Currently barebox version do not extract resources defined by rproc ELF image. On this early stage it is hard to say, if it is needed.

Previously there was an attempt to port bootaux command from u-boot. Porting of remoteproc framework is my attempt to lead this topic in to the (IMO) right direction.

To start remoteproc image, firmwareload command should be used:
firmwareload /mnt/tftp/rproc-imx-rproc-fw

Since firmwareload already support multiple targets, it is possible to specify which exact cortex m4 CPU should be started (if multiple CPU are present). This example shows the list of available firmware targets:
barebox@Phytec i.MX7 phyBOARD-Zeta:/ firmwareload -l firmware programming handlers:

name: model:
soc:[email protected]

---
 drivers/Kconfig                            |   1 +
 drivers/Makefile                           |   1 +
 drivers/remoteproc/Kconfig                 |  26 ++
 drivers/remoteproc/Makefile                |   7 +
 drivers/remoteproc/imx_rproc.c             | 402 +++++++++++++++++++++
 drivers/remoteproc/remoteproc_core.c       | 166 +++++++++
 drivers/remoteproc/remoteproc_elf_loader.c |  88 +++++
 drivers/remoteproc/remoteproc_internal.h   |  30 ++
 include/linux/remoteproc.h                 |  51 +++
 9 files changed, 772 insertions(+)
 create mode 100644 drivers/remoteproc/Kconfig
 create mode 100644 drivers/remoteproc/Makefile
 create mode 100644 drivers/remoteproc/imx_rproc.c
 create mode 100644 drivers/remoteproc/remoteproc_core.c
 create mode 100644 drivers/remoteproc/remoteproc_elf_loader.c
 create mode 100644 drivers/remoteproc/remoteproc_internal.h
 create mode 100644 include/linux/remoteproc.h
drivers/Kconfig +1 -0
index f75da2698..09595433a 100644
@@ -31,6 +31,7 @@ source "drivers/pinctrl/Kconfig"
 source "drivers/nvmem/Kconfig"
 source "drivers/bus/Kconfig"
 source "drivers/regulator/Kconfig"
+source "drivers/remoteproc/Kconfig"
 source "drivers/reset/Kconfig"
 source "drivers/pci/Kconfig"
 source "drivers/rtc/Kconfig"
drivers/Makefile +1 -0
index fb7fcd3fc..5a52225ee 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_W1) += w1/
 obj-y += pinctrl/
 obj-y += bus/
 obj-$(CONFIG_REGULATOR) += regulator/
+obj-$(CONFIG_REMOTEPROC) += remoteproc/
 obj-$(CONFIG_RESET_CONTROLLER) += reset/
 obj-$(CONFIG_PCI) += pci/
 obj-y += rtc/
drivers/remoteproc/Kconfig new file +26 -0
new file mode 100644
index 000000000..8139b6442
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0-only
+menu "Remoteproc drivers"
+
+config REMOTEPROC
+	tristate "Support for Remote Processor subsystem"
+	select CRC32
+	select FIRMWARE
+	help
+	  Support for remote processors (such as DSP coprocessors). These
+	  are mainly used on embedded systems.
+
+if REMOTEPROC
+
+config IMX_REMOTEPROC
+	tristate "IMX6/7 remoteproc support"
+	depends on ARCH_IMX
+	select MFD_SYSCON
+	help
+	  Say y here to support iMX's remote processors (Cortex M4
+	  on iMX7D) via the remote processor framework.
+
+	  It's safe to say N here.
+
+endif # REMOTEPROC
+
+endmenu
drivers/remoteproc/Makefile new file +7 -0
new file mode 100644
index 000000000..107296922
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Generic framework for controlling remote processors
+#
+
+obj-$(CONFIG_REMOTEPROC)		+= remoteproc_core.o remoteproc_elf_loader.o
+obj-$(CONFIG_IMX_REMOTEPROC)		+= imx_rproc.o
drivers/remoteproc/imx_rproc.c new file +402 -0

402 lines not on this page · raw message

drivers/remoteproc/remoteproc_core.c new file +166 -0

166 lines not on this page · raw message

drivers/remoteproc/remoteproc_elf_loader.c new file +88 -0

88 lines not on this page · raw message

drivers/remoteproc/remoteproc_internal.h new file +30 -0
new file mode 100644
index 000000000..8893d1a40
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Remote processor framework
+ *
+ * Copyright (C) 2011 Texas Instruments, Inc.
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * Ohad Ben-Cohen <[email protected]>
+ * Brian Swetland <[email protected]>
+ */
+
+#ifndef REMOTEPROC_INTERNAL_H
+#define REMOTEPROC_INTERNAL_H
+
+struct rproc;
+
+void *rproc_da_to_va(struct rproc *rproc, u64 da, int len);
+
+int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw);
+
+static inline
+int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
+{
+	if (rproc->ops->load)
+		return rproc->ops->load(rproc, fw);
+
+	return -EINVAL;
+}
+
+#endif /* REMOTEPROC_INTERNAL_H */
include/linux/remoteproc.h new file +51 -0

51 lines not on this page · raw message

--
2.20.1

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