dt-bindings: Document JZ47xx VPU auxiliary processor
Paul Cercueil
maintainerPATCH v5 1/5 dt-bindings: Document JZ47xx VPU auxiliary processor
Inside the Video Processing Unit (VPU) of the recent JZ47xx SoCs from Ingenic is a second Xburst MIPS CPU very similar to the main core. This document describes the devicetree bindings for this auxiliary processor.
---
Notes:
v2: Update TCSM0 address in example
v3: Change node name to 'video-decoder'
v4: Convert to YAML. I didn't add Rob's Ack on v3 because of that (sorry Rob)
v5: - Fix 'reg' not in <addr, len> pairs
- Add missing include to devicetree example
.../bindings/remoteproc/ingenic,vpu.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/ingenic,vpu.yaml
Documentation/devicetree/bindings/remoteproc/ingenic,vpu.yaml new file +77 -0
@@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/remoteproc/ingenic,vpu.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Ingenic Video Processing Unit bindings + +description: + Inside the Video Processing Unit (VPU) of the recent JZ47xx SoCs from + Ingenic is a second Xburst MIPS CPU very similar to the main core. + This document describes the devicetree bindings for this auxiliary + processor. + +maintainers: + - Paul Cercueil <[email protected]> + +properties: + compatible: + const: ingenic,jz4770-vpu-rproc + + reg: + items: + - description: aux registers + - description: tcsm0 registers + - description: tcsm1 registers + - description: sram registers + + reg-names: + items: + - const: aux + - const: tcsm0 + - const: tcsm1 + - const: sram + + clocks: + items: + - description: aux clock + - description: vpu clock + + clock-names: + items: + - const: aux + - const: vpu + + interrupts: + description: VPU hardware interrupt + +required: + - compatible + - reg + - reg-names + - clocks + - clock-names + - interrupts + +additionalProperties: false + +examples: + - | + #include <dt-bindings/clock/jz4770-cgu.h> + + vpu: video-decoder@132a0000 { + compatible = "ingenic,jz4770-vpu-rproc"; + + reg = <0x132a0000 0x20>, /* AUX */ + <0x132b0000 0x4000>, /* TCSM0 */ + <0x132c0000 0xc000>, /* TCSM1 */ + <0x132f0000 0x7000>; /* SRAM */ + reg-names = "aux", "tcsm0", "tcsm1", "sram"; + + clocks = <&cgu JZ4770_CLK_AUX>, <&cgu JZ4770_CLK_VPU>; + clock-names = "aux", "vpu"; + + interrupt-parent = <&cpuintc>; + interrupts = <3>; + };
Signature · 1 line
2.25.0
Paul Cercueil
maintainerPATCH v5 2/5 remoteproc: Add device-managed variants of rproc_alloc/rproc_add
Add API functions devm_rproc_alloc() and devm_rproc_add(), which behave like rproc_alloc() and rproc_add() respectively, but register their respective cleanup function to be called on driver detach.
---
Notes:
v3: New patch
v4: No change
v5: - Fix return value documentation
- Fix typo in documentation
drivers/remoteproc/remoteproc_core.c | 67 ++++++++++++++++++++++++++++ include/linux/remoteproc.h | 5 +++ 2 files changed, 72 insertions(+)
drivers/remoteproc/remoteproc_core.c +67 -0
@@ -1932,6 +1932,33 @@ int rproc_add(struct rproc *rproc) }EXPORT_SYMBOL (rproc_add); +static void devm_rproc_remove (void *rproc) +{ +rproc_del (rproc); +} + +/** +* devm_rproc_add() - resource managed rproc_add() +* @dev: the underlying device +* @rproc: the remote processor handle to register +* +* This function performs like rproc_add() but the registered rproc device will +* automatically be removed on driver detach. +* +* Returns: 0 on success, negative errno on failure +*/ +int devm_rproc_add (struct device *dev,struct rproc *rproc) +{ +int err; + + err =rproc_add (rproc); +if (err) +return err; + +return devm_add_action_or_reset (dev, devm_rproc_remove, rproc); +} +EXPORT_SYMBOL (devm_rproc_add); +/** * rproc_type_release() - release a remote processor instance * @dev: the rproc's device
@@ -2149,6 +2176,46 @@ int rproc_del(struct rproc *rproc) }EXPORT_SYMBOL (rproc_del); +static void devm_rproc_free (struct device *dev,void *res) +{ +rproc_free (*(struct rproc **)res); +} + +/** +* devm_rproc_alloc() - resource managed rproc_alloc() +* @dev: the underlying device +* @name: name of this remote processor +* @ops: platform-specific handlers (mainly start/stop) +* @firmware: name of firmware file to load, can be NULL +* @len: length of private data needed by the rproc driver (in bytes) +* +* This function performs like rproc_alloc() but the acquired rproc device will +* automatically be released on driver detach. +* +* Returns: new rproc instance, or NULL on failure +*/ +struct rproc *devm_rproc_alloc (struct device *dev,const char *name, +const struct rproc_ops *ops, +const char *firmware,int len) +{ +struct rproc **ptr, *rproc; + + ptr =devres_alloc (devm_rproc_free,sizeof (*ptr),GFP_KERNEL ); +if (!ptr) +return ERR_PTR (-ENOMEM ); + + rproc =rproc_alloc (dev, name, ops, firmware, len); +if (rproc) { + *ptr = rproc; +devres_add (dev, ptr); + }else { +devres_free (ptr); + } + +return rproc; +} +EXPORT_SYMBOL (devm_rproc_alloc); +/** * rproc_add_subdev() - add a subdevice to a remoteproc * @rproc: rproc handle to add the subdevice to
include/linux/remoteproc.h +5 -0
@@ -595,6 +595,11 @@ int rproc_add(struct rproc *rproc);int rproc_del (struct rproc *rproc);void rproc_free (struct rproc *rproc); +struct rproc *devm_rproc_alloc (struct device *dev,const char *name, +const struct rproc_ops *ops, +const char *firmware,int len); +int devm_rproc_add (struct device *dev,struct rproc *rproc); +void rproc_add_carveout (struct rproc *rproc,struct rproc_mem_entry *mem); struct rproc_mem_entry *
Signature · 1 line
2.25.0
Paul Cercueil
maintainerPATCH v5 3/5 remoteproc: Add prepare/unprepare callbacks
In reply to Paul CercueilThe .prepare() callback is called before the firmware is loaded to memory. This is useful for instance in the case where some setup is required for the memory to be accessible.
---
Notes:
v2-v4: No change
v5: Move calls to prepare/unprepare to rproc_fw_boot/rproc_shutdown
drivers/remoteproc/remoteproc_core.c | 16 +++++++++++++++- include/linux/remoteproc.h | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +15 -1
@@ -1373,6 +1373,14 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)dev_info (dev,"Booting fw image %s, size %zd\n" , name, fw->size); +if (rproc->ops->prepare) { + ret = rproc->ops->prepare (rproc); +if (ret) { +dev_err (dev,"Failed to prepare rproc: %d\n" , ret); +return ret; + } + } +/* * if enabling an IOMMU isn't relevant for this rproc, this is * just a nop
@@ -1380,7 +1388,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ret =rproc_enable_iommu (rproc);if (ret) {dev_err (dev,"can't enable iommu: %d\n" , ret); -return ret; + goto unprepare_rproc; } rproc->bootaddr =rproc_get_boot_addr (rproc, fw);
@@ -1424,6 +1432,9 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) rproc->table_ptr =NULL ; disable_iommu:rproc_disable_iommu (rproc); +unprepare_rproc: +if (rproc->ops->unprepare) + rproc->ops->unprepare (rproc);return ret; }
@@ -1823,6 +1834,9 @@ void rproc_shutdown(struct rproc *rproc)rproc_disable_iommu (rproc); +if (rproc->ops->unprepare) + rproc->ops->unprepare (rproc); +/* Free the copy of the resource table */ kfree (rproc->cached_table); rproc->cached_table =NULL ;
include/linux/remoteproc.h +4 -0
@@ -355,6 +355,8 @@ enum rsc_handling_status {/** * struct rproc_ops - platform-specific device handlers +* @prepare: prepare the device for power up (before the firmware is loaded) +* @unprepare: unprepare the device after it is stopped * @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter)
@@ -371,6 +373,8 @@ enum rsc_handling_status {* @get_boot_addr: get boot address to entry point specified in firmware */ struct rproc_ops { +int (*prepare)(struct rproc *rproc); +void (*unprepare)(struct rproc *rproc);int (*start)(struct rproc *rproc);int (*stop)(struct rproc *rproc);void (*kick)(struct rproc *rproc,int vqid);
Signature · 1 line
2.25.0
Re: [PATCH v5 3/5] remoteproc: Add prepare/unprepare callbacks
Hi Paul,
I still wonder about the use of pm_runtime mechanism as a more generic alternative...
Else just a minor remark inline.
Quoted 68 lines · Paul Cercueil
The .prepare() callback is called before the firmware is loaded to memory. This is useful for instance in the case where some setup is required for the memory to be accessible.
Signed-off-by Paul Cercueil <[email protected]>---
Notes:
v2-v4: No change
v5: Move calls to prepare/unprepare to rproc_fw_boot/rproc_shutdowndrivers/remoteproc/remoteproc_core.c | 16 +++++++++++++++- include/linux/remoteproc.h | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-)drivers/remoteproc/remoteproc_core.c +15
-1@@ -1373,6 +1373,14 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)dev_info (dev,"Booting fw image %s, size %zd\n" , name, fw->size); +if (rproc->ops->prepare) { + ret = rproc->ops->prepare (rproc); +if (ret) { +dev_err (dev,"Failed to prepare rproc: %d\n" , ret); +return ret; + } + } +/* * if enabling an IOMMU isn't relevant for this rproc, this is * just a nop @@ -1380,7 +1388,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) ret =rproc_enable_iommu (rproc);if (ret) {dev_err (dev,"can't enable iommu: %d\n" , ret); -return ret; + goto unprepare_rproc; } rproc->bootaddr =rproc_get_boot_addr (rproc, fw);@@ -1424,6 +1432,9 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) rproc->table_ptr =NULL ; disable_iommu:rproc_disable_iommu (rproc); +unprepare_rproc: +if (rproc->ops->unprepare) + rproc->ops->unprepare (rproc);return ret; }@@ -1823,6 +1834,9 @@ void rproc_shutdown(struct rproc *rproc)rproc_disable_iommu (rproc); +if (rproc->ops->unprepare) + rproc->ops->unprepare (rproc); +/* Free the copy of the resource table */ kfree (rproc->cached_table); rproc->cached_table =NULL ;include/linux/remoteproc.h +0
-0
include/linux/remoteproc.h enum rsc_handling_status { · line 359
Quoted 5 lines
include/linux/remoteproc.h +2
-0@@ -355,6 +355,8 @@ enum rsc_handling_status {/** * struct rproc_ops - platform-specific device handlers +* @prepare: prepare the device for power up (before the firmware is loaded) +* @unprepare: unprepare the device after it is stopped
Would be nice here to precise that these functions are optional you can look at rproc_ops struct for example.
Regards,
Arnaud
Quoted 13 lines
include/linux/remoteproc.h +2
-0* @start: power on the device and boot it * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) @@ -371,6 +373,8 @@ enum rsc_handling_status {* @get_boot_addr: get boot address to entry point specified in firmware */ struct rproc_ops { +int (*prepare)(struct rproc *rproc); +void (*unprepare)(struct rproc *rproc);int (*start)(struct rproc *rproc);int (*stop)(struct rproc *rproc);void (*kick)(struct rproc *rproc,int vqid);
Paul Cercueil
maintainerRe: [PATCH v5 3/5] remoteproc: Add prepare/unprepare callbacks
Hi Arnaud,
Quoted 3 lines · Arnaud POULIQUEN
Hi Paul,
I still wonder about the use of
pm_runtimemechanism as a more generic alternative...
The use of pm_runtime is perfect if CONFIG_PM is enabled, but otherwise it's a bit cumbersome, as the clocks must be enabled in the probe.
-Paul
Quoted 103 lines
Else just a minor remark inline.
Quoted 74 lines · Paul Cercueil
The .prepare() callback is called before the firmware is loaded to memory. This is useful for instance in the case where some setup is required for the memory to be accessible.
Signed-off-by Paul Cercueil <[email protected]>---
Notes:
v2-v4: No change
v5: Move calls to prepare/unprepare to
rproc_fw_boot/rproc_shutdowndrivers/remoteproc/remoteproc_core.c | 16 +++++++++++++++- include/linux/remoteproc.h | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-)diff --git
a/drivers/remoteproc/remoteproc_core.cb/drivers/remoteproc/remoteproc_core.c
indexfe5c7a2f9767..022b927e176b100644
---a/drivers/remoteproc/remoteproc_core.c
+++b/drivers/remoteproc/remoteproc_core.c
@@ -1373,6 +1373,14 @@ static int rproc_fw_boot(struct rproc
*rproc, const struct firmware *fw)dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size);+ if (
rproc->ops->prepare) {
+ ret =rproc->ops->prepare(rproc);
+ if (ret) {
+dev_err(dev, "Failed to prepare rproc: %d\n", ret);
+ return ret;
+ }
+ }
+
/*
* if enabling an IOMMU isn't relevant for this rproc, this is
* just a nop
@@ -1380,7 +1388,7 @@ static int rproc_fw_boot(struct rproc *rproc,
const struct firmware *fw)
ret =rproc_enable_iommu(rproc);
if (ret) {
dev_err(dev, "can't enable iommu: %d\n", ret);
- return ret;
+ gotounprepare_rproc;
}
rproc->bootaddr=rproc_get_boot_addr(rproc, fw);
@@ -1424,6 +1432,9 @@ static int rproc_fw_boot(struct rproc *rproc,
const struct firmware *fw)
rproc->table_ptr= NULL;
disable_iommu:
rproc_disable_iommu(rproc);
+unprepare_rproc:
+ if (rproc->ops->unprepare)
+rproc->ops->unprepare(rproc);
return ret;
}@@ -1823,6 +1834,9 @@ void
rproc_shutdown(struct rproc *rproc)rproc_disable_iommu(rproc);+ if (
rproc->ops->unprepare)
+rproc->ops->unprepare(rproc);
+
/* Free the copy of the resource table */kfree(rproc->cached_table);
rproc->cached_table= NULL;
diff --gita/include/linux/remoteproc.hb/include/linux/remoteproc.hindex5f201f0c86c3..a6272d1ba384100644
---a/include/linux/remoteproc.h
+++b/include/linux/remoteproc.h
@@ -355,6 +355,8 @@ enumrsc_handling_status{Quoted 5 lines
/**
* structrproc_ops- platform-specific device handlers
+ * @prepare: prepare the device for power up (before the firmware
is loaded)
+ * @unprepare: unprepare the device after it is stoppedWould be nice here to precise that these functions are optional you can look at
rproc_opsstruct for example.Regards,
ArnaudQuoted 14 lines
* @start: power on the device and boot it
* @stop: power off the device
* @kick: kick a virtqueue (virtqueue id given as a parameter)
@@ -371,6 +373,8 @@ enumrsc_handling_status{
* @get_boot_addr: get boot address to entry point specified in
firmware
*/
structrproc_ops{
+ int (*prepare)(struct rproc *rproc);
+ void (*unprepare)(struct rproc *rproc);
int (*start)(struct rproc *rproc); int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid);
Paul Cercueil
maintainerPATCH v5 4/5 remoteproc: ingenic: Added remoteproc driver
In reply to Paul CercueilThis driver is used to boot, communicate with and load firmwares to the MIPS co-processor found in the VPU hardware of the JZ47xx SoCs from Ingenic.
---
Notes:
v2: Remove exception for always-mapped memories
v3: - Use clk_bulk API
- Move device-managed code to its own patch [3/4]
- Move devicetree table right above ingenic_rproc_driver
- Removed #ifdef CONFIG_OF around devicetree table
- Removed .owner = THIS_MODULE in ingenic_rproc_driver
- Removed useless platform_set_drvdata()
v4: - Add fix reported by Julia
- Change Kconfig symbol to INGENIC_VPU_RPROC
- Add documentation to struct vpu
- disable_irq_nosync() -> disable_irq()
v5: No change
drivers/remoteproc/Kconfig | 8 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/ingenic_rproc.c | 247 +++++++++++++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100644 drivers/remoteproc/ingenic_rproc.c
drivers/remoteproc/Kconfig +8 -0
@@ -224,6 +224,14 @@ config STM32_RPROC This can be either built-in or a loadable module. +config INGENIC_VPU_RPROC + tristate "Ingenic JZ47xx VPU remoteproc support" + depends on MIPS || COMPILE_TEST + help + Say y or m here to support the VPU in the JZ47xx SoCs from Ingenic. + This can be either built-in or a loadable module. + If unsure say N. + endif # REMOTEPROC endmenu
drivers/remoteproc/Makefile +1 -0
@@ -10,6 +10,7 @@ remoteproc-y += remoteproc_sysfs.o remoteproc-y += remoteproc_virtio.o remoteproc-y += remoteproc_elf_loader.o obj-$(CONFIG_IMX_REMOTEPROC) += imx_rproc.o +obj-$(CONFIG_INGENIC_VPU_RPROC) += ingenic_rproc.o obj-$(CONFIG_MTK_SCP) += mtk_scp.o mtk_scp_ipi.o obj-$(CONFIG_OMAP_REMOTEPROC) += omap_remoteproc.o obj-$(CONFIG_WKUP_M3_RPROC) += wkup_m3_rproc.o
drivers/remoteproc/ingenic_rproc.c new file +247 -0
247 lines not on this page · raw message
Signature · 1 line
2.25.0
Paul Cercueil
maintainerPATCH v5 5/5 MAINTAINERS: Add myself as reviewer for Ingenic rproc driver
In reply to Paul CercueilAdd myself as the reviewer for the Ingenic VPU remoteproc driver.
---
Notes:
v4: New patch
v5: No change
MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -8294,6 +8294,7 @@ F: drivers/mtd/nand/raw/ingenic/ F: drivers/pinctrl/pinctrl-ingenic.c F: drivers/power/supply/ingenic-battery.c F: drivers/pwm/pwm-jz4740.c +F: drivers/remoteproc/ingenic_rproc.c F: drivers/rtc/rtc-jz4740.c F: drivers/tty/serial/8250/8250_ingenic.c F: drivers/usb/musb/jz4740.c
Signature · 1 line
2.25.0
Quoted 15 lines · Paul Cercueil
Inside the Video Processing Unit (VPU) of the recent JZ47xx SoCs from Ingenic is a second Xburst MIPS CPU very similar to the main core. This document describes the devicetree bindings for this auxiliary processor.
Signed-off-by Paul Cercueil <[email protected]>---
Notes:
v2: Update TCSM0 address in example
v3: Change node name to 'video-decoder'
v4: Convert to YAML. I didn't add Rob's Ack on v3 because of that (sorry Rob)
v5: - Fix 'reg' not in <addr, len> pairs
- Add missing include to devicetree example
Quoted 3 lines
.../bindings/remoteproc/ingenic,vpu.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/ingenic,vpu.yaml
Rob Herring
maintainerQuoted 15 lines · Paul Cercueil
Inside the Video Processing Unit (VPU) of the recent JZ47xx SoCs from Ingenic is a second Xburst MIPS CPU very similar to the main core. This document describes the devicetree bindings for this auxiliary processor.
Signed-off-by Paul Cercueil <[email protected]>---
Notes:
v2: Update TCSM0 address in example
v3: Change node name to 'video-decoder'
v4: Convert to YAML. I didn't add Rob's Ack on v3 because of that (sorry Rob)
v5: - Fix 'reg' not in <addr, len> pairs
- Add missing include to devicetree example
Quoted 4 lines
.../bindings/remoteproc/ingenic,vpu.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/ingenic,vpu.yaml
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Rob Herring
maintainerQuoted 22 lines · Rob Herring
Quoted 15 lines · Paul Cercueil
Inside the Video Processing Unit (VPU) of the recent JZ47xx SoCs from Ingenic is a second Xburst MIPS CPU very similar to the main core. This document describes the devicetree bindings for this auxiliary processor.
Signed-off-by Paul Cercueil <[email protected]>---
Notes:
v2: Update TCSM0 address in example
v3: Change node name to 'video-decoder'
v4: Convert to YAML. I didn't add Rob's Ack on v3 because of that (sorry Rob)
v5: - Fix 'reg' not in <addr, len> pairs
- Add missing include to devicetree exampleQuoted 4 lines
.../bindings/remoteproc/ingenic,vpu.yaml | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/ingenic,vpu.yaml
Quoted 5 lines
Please add Acked-by/Reviewed-by tags when posting new versions. However, there's no need to repost patches *only* to add the tags. The upstream maintainer will do that for acks received on the version they apply.
If a tag was not added on purpose, please state why and what changed.
Disregard this, you did say why.