]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - rpmsg/rpmsg.git/commitdiff
soc: ti: pruss: add helper functions to set GPI mode, MII_RT_event and XFR
authorSuman Anna <s-anna@ti.com>
Thu, 15 Feb 2018 02:01:14 +0000 (20:01 -0600)
committerSuman Anna <s-anna@ti.com>
Sun, 24 Feb 2019 01:20:52 +0000 (19:20 -0600)
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

index daaed0c3e7b35a595c76d91289091af92d8bdb47..a50eeceb7a7b43fdaac9c8845cf7a1a4a5cf052a 100644 (file)
@@ -239,4 +239,56 @@ static inline int pru_rproc_set_ctable(struct rproc *rproc,
 
 #endif /* CONFIG_PRU_REMOTEPROC */
 
+/**
+ * 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_regmap_update(pruss, PRUSS_SYSCON_CFG, PRUSS_CFG_GPCFG(id),
+                                  PRUSS_GPCFG_PRU_GPI_MODE_MASK,
+                                  mode << PRUSS_GPCFG_PRU_GPI_MODE_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_regmap_update(pruss, PRUSS_SYSCON_CFG, 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_regmap_update(pruss, PRUSS_SYSCON_CFG, PRUSS_CFG_SPP,
+                                  PRUSS_SPP_XFER_SHIFT_EN, set);
+}
+
 #endif /* __LINUX_PRUSS_H */