diff mbox series

[U-Boot,v2,4/6] remoteproc: stm32: track the coprocessor state in a backup register

Message ID 1572442713-26353-5-git-send-email-fabien.dessenne@st.com
State Accepted
Commit 4a4deb870f9a19569e6b86afe36d0e0fbee4fa61
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
Update the dedicated backup register to track the coprocessor state and
rely on that register to compute the .is_running() value (which expects
a return value of 0 -not 1- if the processor is running).

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

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
> 
> Update the dedicated backup register to track the coprocessor state and rely on
> that register to compute the .is_running() value (which expects a return value of 0
> -not 1- if the processor is running).
> 
> 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:31PM +0100, Fabien Dessenne wrote:

> Update the dedicated backup register to track the coprocessor state and
> rely on that register to compute the .is_running() value (which expects
> a return value of 0 -not 1- if the processor is running).
> 
> 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 40bba37..dcafa54 100644
--- a/drivers/remoteproc/stm32_copro.c
+++ b/drivers/remoteproc/stm32_copro.c
@@ -22,14 +22,12 @@ 
  * @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
- * @is_running:		is the remote processor running
  */
 struct stm32_copro_privdata {
 	struct reset_ctl reset_ctl;
 	struct regmap *hold_boot_regmap;
 	uint hold_boot_offset;
 	uint hold_boot_mask;
-	bool is_running;
 };
 
 /**
@@ -165,11 +163,8 @@  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)
@@ -180,7 +175,8 @@  static int stm32_copro_start(struct udevice *dev)
 	 * rebooting autonomously
 	 */
 	ret = stm32_copro_set_hold_boot(dev, true);
-	priv->is_running = !ret;
+	writel(ret ? TAMP_COPRO_STATE_OFF : TAMP_COPRO_STATE_CRUN,
+	       TAMP_COPRO_STATE);
 	return ret;
 }
 
@@ -206,7 +202,7 @@  static int stm32_copro_reset(struct udevice *dev)
 		return ret;
 	}
 
-	priv->is_running = false;
+	writel(TAMP_COPRO_STATE_OFF, TAMP_COPRO_STATE);
 
 	return 0;
 }
@@ -224,14 +220,11 @@  static int stm32_copro_stop(struct udevice *dev)
 /**
  * stm32_copro_is_running() - Is the STM32 remote processor running
  * @dev:	corresponding STM32 remote processor device
- * @return 1 if the remote processor is running, 0 otherwise
+ * @return 0 if the remote processor is running, 1 otherwise
  */
 static int stm32_copro_is_running(struct udevice *dev)
 {
-	struct stm32_copro_privdata *priv;
-
-	priv = dev_get_priv(dev);
-	return priv->is_running;
+	return (readl(TAMP_COPRO_STATE) == TAMP_COPRO_STATE_OFF);
 }
 
 static const struct dm_rproc_ops stm32_copro_ops = {