summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8c84a06)
raw | patch | inline | side by side (parent: 8c84a06)
author | Suman Anna <s-anna@ti.com> | |
Mon, 26 Nov 2018 07:52:43 +0000 (09:52 +0200) | ||
committer | Suman 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 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 | patch | blob | history | |
include/linux/pruss.h | patch | blob | history |
index 1726c1266e8455985a2ca7df51d313cf9a737176..7ec23b0474030e70f6d6671ddeceb4793ed97768 100644 (file)
}
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
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;
diff --git a/include/linux/pruss.h b/include/linux/pruss.h
index 7975790b8895b502c4060c9972acc9a33a01fad9..2346e31f70e6e3b7d80a3400b6d86e517ea9b2aa 100644 (file)
--- a/include/linux/pruss.h
+++ b/include/linux/pruss.h
#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
*/
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
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)
{