From: Roger Quadros <rogerq@ti.com>
To: ohad@wizery.com, bjorn.andersson@linaro.org
Cc: tony@atomide.com, robh+dt@kernel.org, bcousson@baylibre.com,
ssantosh@kernel.org, s-anna@ti.com, nsekhar@ti.com,
t-kristo@ti.com, nsaulnier@ti.com, jreeder@ti.com,
m-karicheri2@ti.com, woods.technical@gmail.com,
linux-omap@vger.kernel.org, linux-remoteproc@vger.kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
rogerq@ti.com
Subject: [PATCH 11/16] soc: ti: pruss: add helper functions to set GPI mode, MII_RT_event and XFR
Date: Mon, 26 Nov 2018 09:52:44 +0200 [thread overview]
Message-ID: <1543218769-5507-12-git-send-email-rogerq@ti.com> (raw)
In-Reply-To: <1543218769-5507-1-git-send-email-rogerq@ti.com>
From: Suman Anna <s-anna@ti.com>
The PRUSS CFG module is represented as a syscon node and is currently
managed by the PRUSS platform driver. Add easy accessor functions to set
GPI mode, MII_RT event enable/disable and XFR (XIN XOUT) enable/disable
to enable the PRUSS Ethernet usecase. These functions reuse the generic
pruss_regmap_update() API function.
Signed-off-by: Suman Anna <s-anna@ti.com>
---
include/linux/pruss.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 115 insertions(+)
diff --git a/include/linux/pruss.h b/include/linux/pruss.h
index c0a3b3e..7227aae 100644
--- a/include/linux/pruss.h
+++ b/include/linux/pruss.h
@@ -204,6 +204,69 @@ int pruss_intc_configure(struct pruss *pruss,
int pruss_intc_unconfigure(struct pruss *pruss,
struct pruss_intc_config *intc_config);
+/**
+ * pruss_cfg_get_gpmux() - get the current GPMUX value for a PRU device
+ * @pruss: pruss instance
+ * @id: PRU identifier (0-1)
+ * @mux: pointer to store the current mux value into
+ */
+static inline int pruss_cfg_get_gpmux(struct pruss *pruss,
+ enum pruss_pru_id id, u8 *mux)
+{
+ int ret = 0;
+ u32 val;
+
+ ret = pruss_cfg_read(pruss, PRUSS_CFG_GPCFG(id), &val);
+ if (!ret)
+ *mux = (u8)((val & PRUSS_GPCFG_PRU_MUX_SEL_MASK) >>
+ PRUSS_GPCFG_PRU_MUX_SEL_SHIFT);
+ return ret;
+}
+
+/**
+ * pruss_cfg_set_gpmux() - set the GPMUX value for a PRU device
+ * @pruss: pruss instance
+ * @pru_id: PRU identifier (0-1)
+ * @mux: new mux value for PRU
+ */
+static inline int pruss_cfg_set_gpmux(struct pruss *pruss,
+ enum pruss_pru_id id, u8 mux)
+{
+ if (mux >= PRUSS_GP_MUX_SEL_MAX)
+ return -EINVAL;
+
+ return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(id),
+ PRUSS_GPCFG_PRU_MUX_SEL_MASK,
+ (u32)mux << PRUSS_GPCFG_PRU_MUX_SEL_SHIFT);
+}
+
+/**
+ * pruss_cfg_miirt_enable() - Enable/disable MII RT Events
+ * @pruss: the pruss instance
+ * @enable: enable/disable
+ *
+ * Enable/disable the MII RT Events for the PRUSS.
+ */
+static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable)
+{
+ u32 set = enable ? PRUSS_MII_RT_EVENT_EN : 0;
+
+ return pruss_cfg_update(pruss, PRUSS_CFG_MII_RT,
+ PRUSS_MII_RT_EVENT_EN, set);
+}
+
+/**
+ * pruss_cfg_xfr_enable() - Enable/disable XIN XOUT shift functionality
+ * @pruss: the pruss instance
+ * @enable: enable/disable
+ */
+static inline int pruss_cfg_xfr_enable(struct pruss *pruss, bool enable)
+{
+ u32 set = enable ? PRUSS_SPP_XFER_SHIFT_EN : 0;
+
+ return pruss_cfg_update(pruss, PRUSS_CFG_SPP,
+ PRUSS_SPP_XFER_SHIFT_EN, set);
+}
#else
static inline struct pruss *pruss_get(struct rproc *rproc)
@@ -254,6 +317,28 @@ int pruss_intc_unconfigure(struct pruss *pruss,
return -ENOTSUPP;
}
+static inline int pruss_cfg_get_gpmux(struct pruss *pruss,
+ enum pruss_pru_id id, u8 *mux)
+{
+ return -ENOTSUPP;
+}
+
+static inline int pruss_cfg_set_gpmux(struct pruss *pruss,
+ enum pruss_pru_id id, u8 mux)
+{
+ return -ENOTSUPP;
+}
+
+static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable)
+{
+ return -ENOTSUPP;
+}
+
+static inline int pruss_cfg_xfr_enable(struct pruss *pruss, bool enable)
+{
+ return -ENOTSUPP;
+}
+
#endif /* CONFIG_TI_PRUSS */
#if IS_ENABLED(CONFIG_PRUSS_REMOTEPROC)
@@ -263,6 +348,30 @@ 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);
+/**
+ * pruss_cfg_gpimode() - set the GPI mode of the PRU
+ * @pruss: the pruss instance handle
+ * @pru: the rproc instance handle of the PRU
+ * @mode: GPI mode to set
+ *
+ * Sets the GPI mode for a given PRU by programming the
+ * corresponding PRUSS_CFG_GPCFGx register
+ *
+ * Returns 0 on success, or an error code otherwise
+ */
+static inline int pruss_cfg_gpimode(struct pruss *pruss, struct rproc *pru,
+ enum pruss_gpi_mode mode)
+{
+ enum pruss_pru_id id = pru_rproc_get_id(pru);
+
+ if (id < 0)
+ return -EINVAL;
+
+ return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(id),
+ PRUSS_GPCFG_PRU_GPI_MODE_MASK,
+ mode << PRUSS_GPCFG_PRU_GPI_MODE_SHIFT);
+}
+
#else
static inline struct rproc *pru_rproc_get(struct device_node *node, int index)
@@ -283,6 +392,12 @@ static inline int pru_rproc_set_ctable(struct rproc *rproc,
return -ENOTSUPP;
}
+static inline int pruss_cfg_gpimode(struct pruss *pruss, struct rproc *pru,
+ enum pruss_gpi_mode mode)
+{
+ return -ENOTSUPP;
+}
+
#endif /* CONFIG_PRUSS_REMOTEPROC */
#endif /* __LINUX_PRUSS_H */
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
next prev parent reply other threads:[~2018-11-26 7:52 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-26 7:52 [PATCH 00/16] remoteproc: Add support for TI PRU Roger Quadros
2018-11-26 7:52 ` [PATCH 01/16] remoteproc: Extend rproc_da_to_va() API with a flags parameter Roger Quadros
2018-11-26 21:29 ` David Lechner
2018-11-29 10:29 ` Roger Quadros
2018-11-29 16:12 ` David Lechner
2018-12-04 10:03 ` Roger Quadros
2019-02-14 3:35 ` Suman Anna
2018-11-26 7:52 ` [PATCH 02/16] remoteproc: Add a rproc_set_firmware() API Roger Quadros
2018-11-26 21:41 ` David Lechner
2018-11-29 8:51 ` Roger Quadros
2018-11-26 7:52 ` [PATCH 03/16] remoteproc: Add support to handle device specific resource types Roger Quadros
2018-11-26 7:52 ` [PATCH 04/16] remoteproc/pru: Add PRU remoteproc driver Roger Quadros
2018-11-26 22:32 ` David Lechner
2018-11-29 9:26 ` Roger Quadros
2018-11-30 21:39 ` Dimitar Dimitrov
2018-12-04 8:47 ` Roger Quadros
2018-12-14 9:53 ` Roger Quadros
2018-12-15 13:43 ` Dimitar Dimitrov
2018-11-26 7:52 ` [PATCH 05/16] remoteproc/pru: Add pru-specific debugfs support Roger Quadros
2018-11-26 22:37 ` David Lechner
2018-11-29 10:17 ` Roger Quadros
2018-12-18 15:51 ` Roger Quadros
2018-12-19 12:38 ` Mark Brown
2018-12-19 15:43 ` Roger Quadros
2018-12-19 15:48 ` David Lechner
2018-12-19 17:07 ` Mark Brown
2018-12-19 17:18 ` Tony Lindgren
2018-12-20 8:45 ` Roger Quadros
2018-11-26 7:52 ` [PATCH 06/16] dt-bindings: remoteproc: ti-pruss: Update bindings for supporting rpmsg Roger Quadros
2018-11-26 7:52 ` [PATCH 07/16] remoteproc/pru: Add support for virtio rpmsg stack Roger Quadros
2018-11-26 7:52 ` [PATCH 08/16] remoteproc/pru: Add pru_rproc_set_ctable() function Roger Quadros
2018-11-26 7:52 ` [PATCH 09/16] remoteproc/pru: add APIs to get and put the PRU cores Roger Quadros
2018-11-26 7:52 ` [PATCH 10/16] remoteproc/pru: add pru_rproc_get_id() API to retrieve the PRU id Roger Quadros
2018-11-26 7:52 ` Roger Quadros [this message]
2018-11-26 7:52 ` [PATCH 12/16] dt-bindings: remoteproc: ti-pruss: Document application node bindings Roger Quadros
2018-11-26 23:27 ` David Lechner
2018-11-29 10:07 ` Roger Quadros
2018-11-29 16:33 ` David Lechner
2018-11-30 11:42 ` Roger Quadros
2018-12-11 22:06 ` Rob Herring
2018-12-17 16:03 ` Roger Quadros
2018-11-26 7:52 ` [PATCH 13/16] remoteproc/pru: add support for configuring GPMUX based on client setup Roger Quadros
2018-11-26 7:52 ` [PATCH 14/16] remoteproc/pru: configure firmware " Roger Quadros
2018-11-26 7:52 ` [PATCH 15/16] remoteproc/pru: add support for parsing pru interrupt mapping from DT Roger Quadros
2018-11-26 7:52 ` [PATCH 16/16] remoteproc/pru: Add support for INTC Interrupt map resource Roger Quadros
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1543218769-5507-12-git-send-email-rogerq@ti.com \
--to=rogerq@ti.com \
--cc=bcousson@baylibre.com \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=jreeder@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=m-karicheri2@ti.com \
--cc=nsaulnier@ti.com \
--cc=nsekhar@ti.com \
--cc=ohad@wizery.com \
--cc=robh+dt@kernel.org \
--cc=s-anna@ti.com \
--cc=ssantosh@kernel.org \
--cc=t-kristo@ti.com \
--cc=tony@atomide.com \
--cc=woods.technical@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).