diff mbox series

[U-Boot,v2,6/6] remoteproc: stm32: load resource table from firmware

Message ID 1572442713-26353-7-git-send-email-fabien.dessenne@st.com
State Accepted
Commit 33fd41951a8bf61be33b2b793a2c87a62eb0c1cf
Delegated to: Tom Rini
Headers show
Series remoteproc: add elf resource table loader | expand

Commit Message

Fabien DESSENNE Oct. 30, 2019, 1:38 p.m. UTC
Load the optional resource table from the firmware, and write its
address in the dedicated backup register.

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
---
 drivers/remoteproc/stm32_copro.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Patrick DELAUNAY Nov. 25, 2019, 4:56 p.m. UTC | #1
Hi Fabien,

> From: Fabien DESSENNE <fabien.dessenne@st.com>
> Sent: mercredi 30 octobre 2019 14:39
> 
> Load the optional resource table from the firmware, and write its address in the
> dedicated backup register.
> 
> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>

Acked-by: Patrick Delaunay <patrick.delaunay@st.com>

Thanks

Patrick
Tom Rini Jan. 8, 2020, 8:12 p.m. UTC | #2
On Wed, Oct 30, 2019 at 02:38:33PM +0100, Fabien Dessenne wrote:

> Load the optional resource table from the firmware, and write its
> address in the dedicated backup register.
> 
> Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
> Acked-by: Patrick Delaunay <patrick.delaunay@st.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/remoteproc/stm32_copro.c b/drivers/remoteproc/stm32_copro.c
index dcafa54..c25488f 100644
--- a/drivers/remoteproc/stm32_copro.c
+++ b/drivers/remoteproc/stm32_copro.c
@@ -22,12 +22,14 @@ 
  * @hold_boot_regmap:	regmap for remote processor reset hold boot
  * @hold_boot_offset:	offset of the register controlling the hold boot setting
  * @hold_boot_mask:	bitmask of the register for the hold boot field
+ * @rsc_table_addr:	resource table address
  */
 struct stm32_copro_privdata {
 	struct reset_ctl reset_ctl;
 	struct regmap *hold_boot_regmap;
 	uint hold_boot_offset;
 	uint hold_boot_mask;
+	ulong rsc_table_addr;
 };
 
 /**
@@ -139,6 +141,7 @@  static void *stm32_copro_device_to_virt(struct udevice *dev, ulong da,
 static int stm32_copro_load(struct udevice *dev, ulong addr, ulong size)
 {
 	struct stm32_copro_privdata *priv;
+	ulong rsc_table_size;
 	int ret;
 
 	priv = dev_get_priv(dev);
@@ -153,6 +156,12 @@  static int stm32_copro_load(struct udevice *dev, ulong addr, ulong size)
 		return ret;
 	}
 
+	if (rproc_elf32_load_rsc_table(dev, addr, size, &priv->rsc_table_addr,
+				       &rsc_table_size)) {
+		priv->rsc_table_addr = 0;
+		dev_warn(dev, "No valid resource table for this firmware\n");
+	}
+
 	return rproc_elf32_load_image(dev, addr, size);
 }
 
@@ -163,8 +172,11 @@  static int stm32_copro_load(struct udevice *dev, ulong addr, ulong size)
  */
 static int stm32_copro_start(struct udevice *dev)
 {
+	struct stm32_copro_privdata *priv;
 	int ret;
 
+	priv = dev_get_priv(dev);
+
 	/* move hold boot from true to false start the copro */
 	ret = stm32_copro_set_hold_boot(dev, false);
 	if (ret)
@@ -177,6 +189,10 @@  static int stm32_copro_start(struct udevice *dev)
 	ret = stm32_copro_set_hold_boot(dev, true);
 	writel(ret ? TAMP_COPRO_STATE_OFF : TAMP_COPRO_STATE_CRUN,
 	       TAMP_COPRO_STATE);
+	if (!ret)
+		/* Store rsc_address in bkp register */
+		writel(priv->rsc_table_addr, TAMP_COPRO_RSC_TBL_ADDRESS);
+
 	return ret;
 }