]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - rpmsg/rpmsg.git/commitdiff
remoteproc/pru: add pru_rproc_get_id() API to retrieve the PRU id
authorSuman Anna <s-anna@ti.com>
Mon, 26 Nov 2018 07:52:43 +0000 (09:52 +0200)
committerSuman Anna <s-anna@ti.com>
Sun, 24 Feb 2019 01:20:52 +0000 (19:20 -0600)
Export an API pru_rproc_get_id() to allow other PRUSS platform
drivers to clients to retrieve the PRU id from a remoteproc handle
associated with a PRU. The new function takes in a struct rproc
pointer as argument.

Signed-off-by: Suman Anna <s-anna@ti.com>
drivers/remoteproc/pru_rproc.c
include/linux/pruss.h

index 1726c1266e8455985a2ca7df51d313cf9a737176..7ec23b0474030e70f6d6671ddeceb4793ed97768 100644 (file)
@@ -384,6 +384,29 @@ void pru_rproc_put(struct rproc *rproc)
 }
 EXPORT_SYMBOL_GPL(pru_rproc_put);
 
+/**
+ * pru_rproc_get_id() - get PRU id from a previously acquired PRU remoteproc
+ * @rproc: the rproc instance of the PRU
+ *
+ * Returns the PRU id of the PRU remote processor that has been acquired through
+ * a pru_rproc_get(), or a negative value on error
+ */
+enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc)
+{
+       struct pru_rproc *pru;
+
+       if (IS_ERR_OR_NULL(rproc) || !rproc->dev.parent)
+               return -EINVAL;
+
+       /* TODO: replace the crude string based check to make sure it is PRU */
+       if (!strstr(dev_name(rproc->dev.parent), "pru"))
+               return -EINVAL;
+
+       pru = rproc->priv;
+       return pru->id;
+}
+EXPORT_SYMBOL_GPL(pru_rproc_get_id);
+
 /**
  * pru_rproc_set_ctable() - set the constant table index for the PRU
  * @rproc: the rproc instance of the PRU
@@ -906,9 +929,9 @@ static int pru_rproc_set_id(struct pru_rproc *pru)
        u32 mask2 = PRU1_IRAM_ADDR_MASK;
 
        if ((pru->mem_regions[PRU_IOMEM_IRAM].pa & mask1) == mask1)
-               pru->id = 0;
+               pru->id = PRUSS_PRU0;
        else if ((pru->mem_regions[PRU_IOMEM_IRAM].pa & mask2) == mask2)
-               pru->id = 1;
+               pru->id = PRUSS_PRU1;
        else
                ret = -EINVAL;
 
index 7975790b8895b502c4060c9972acc9a33a01fad9..2346e31f70e6e3b7d80a3400b6d86e517ea9b2aa 100644 (file)
@@ -9,6 +9,15 @@
 #ifndef __LINUX_PRUSS_H
 #define __LINUX_PRUSS_H
 
+/**
+ * enum pruss_pru_id - PRU core identifiers
+ */
+enum pruss_pru_id {
+       PRUSS_PRU0 = 0,
+       PRUSS_PRU1,
+       PRUSS_NUM_PRUS,
+};
+
 /**
  * enum pru_ctable_idx - Configurable Constant table index identifiers
  */
@@ -42,6 +51,7 @@ static inline int pruss_intc_trigger(unsigned int irq)
 
 struct rproc *pru_rproc_get(struct device_node *node, int index);
 void pru_rproc_put(struct rproc *rproc);
+enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc);
 int pru_rproc_set_ctable(struct rproc *rproc, enum pru_ctable_idx c, u32 addr);
 
 #else
@@ -53,6 +63,11 @@ static inline struct rproc *pru_rproc_get(struct device_node *node, int index)
 
 static inline void pru_rproc_put(struct rproc *rproc) { }
 
+static inline enum pruss_pru_id pru_rproc_get_id(struct rproc *rproc)
+{
+       return -ENOTSUPP;
+}
+
 static inline int pru_rproc_set_ctable(struct rproc *rproc,
                                       enum pru_ctable_idx c, u32 addr)
 {