]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - rpmsg/rpmsg.git/commitdiff
soc: ti: pruss: add helper functions to get/set PRUSS_CFG_GPMUX
authorTero Kristo <t-kristo@ti.com>
Tue, 19 Feb 2019 17:41:37 +0000 (11:41 -0600)
committerSuman Anna <s-anna@ti.com>
Sun, 24 Feb 2019 01:20:52 +0000 (19:20 -0600)
Add two new helper functions pruss_cfg_get_gpmux() & pruss_cfg_set_gpmux()
to get and set the GP MUX mode for programming the PRUSS internal wrapper
mux functionality as needed by usecases.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
[s-anna@ti.com: reuse pruss_regmap functions and inline them]
Signed-off-by: Suman Anna <s-anna@ti.com>
include/linux/pruss_driver.h

index 318ae77df37ddcfda223aa94619df10d2fe12040..8a691dad6455dc6cae110831f425f6f896ed2256 100644 (file)
@@ -58,4 +58,41 @@ 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_regmap_read(pruss, PRUSS_SYSCON_CFG,
+                               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_regmap_update(pruss, PRUSS_SYSCON_CFG, PRUSS_CFG_GPCFG(id),
+                                  PRUSS_GPCFG_PRU_MUX_SEL_MASK,
+                                 (u32)mux << PRUSS_GPCFG_PRU_MUX_SEL_SHIFT);
+}
+
 #endif /* _PRUSS_DRIVER_H_ */