[U-Boot] [PATCH 08/10] remoteproc: pru_rproc: Add is_running support

Greg Leonberg greg.leonberg at sunhillo.com
Wed Jul 27 21:27:55 CEST 2022


An integer flag in the private data structure for the udev was added to
indicate run-state. A function was also added to return that flag in order
for the driver to support the is_running driver function.

This patch depends on patch 0007 of this patch series.

Signed-off-by: Greg Leonberg <greg.leonberg at sunhillo.com>
---
 drivers/remoteproc/pru_rproc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c
index d9b6cc2..94cdbf7 100644
--- a/drivers/remoteproc/pru_rproc.c
+++ b/drivers/remoteproc/pru_rproc.c
@@ -107,6 +107,7 @@ struct pru {
 	int id;
 	struct pruss *prusspriv;
 	const struct pru_private_data *data;
+	int isRunning;
 };
 
 static inline u32 pru_control_read_reg(struct pru *pru, unsigned int reg)
@@ -162,6 +163,23 @@ static int pru_rproc_set_ctable(struct pru *pru, enum pru_ctable_idx c, u32 addr
 }
 
 /**
+ * pru_is_running() - check if the pru is running
+ * @dev:	corresponding remote processor device
+ *
+ * Return: 0 if the pru is running, else 1.
+ */
+static int pru_is_running(struct udevice *dev)
+{
+	struct pru *priv;
+
+	priv = dev_get_priv(dev);
+	if (!priv)
+		return 0;
+
+	return priv->isRunning;
+}
+
+/**
  * pru_start() - start the pru processor
  * @dev:	corresponding k3 remote processor device
  *
@@ -179,6 +197,8 @@ static int pru_start(struct udevice *dev)
 	val = CTRL_CTRL_EN | ((priv->bootaddr >> 2) << 16);
 	writel(val, priv->mem_regions[PRU_MEM_CTRL].pa + PRU_CTRL_CTRL);
 
+	priv->isRunning = 0;
+
 	return 0;
 }
 
@@ -199,6 +219,8 @@ static int pru_stop(struct udevice *dev)
 	val &= ~CTRL_CTRL_EN;
 	writel(val, priv->mem_regions[PRU_MEM_CTRL].pa + PRU_CTRL_CTRL);
 
+	priv->isRunning = 1;
+
 	return 0;
 }
 
@@ -431,6 +453,7 @@ static const struct dm_rproc_ops pru_ops = {
 	.start = pru_start,
 	.stop = pru_stop,
 	.load = pru_load,
+	.is_running = pru_is_running,
 };
 
 static void pru_set_id(struct pru *priv, struct udevice *dev)
@@ -482,6 +505,8 @@ static int pru_probe(struct udevice *dev)
 	}
 	priv->data = data;
 
+	priv->isRunning = 1;
+
 	pru_set_id(priv, dev);
 
 	return 0;
-- 
1.8.3.1



More information about the U-Boot mailing list