Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

soc: ti: pruss: Add helper functions to set GPI mode, MII_RT_event and XFR

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_cfg_update() API function.

Signed-off-by: Suman Anna <s-anna@ti.com>
Co-developed-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>
Signed-off-by: Grzegorz Jaszczyk <grzegorz.jaszczyk@linaro.org>
Signed-off-by: Puranjay Mohan <p-mohan@ti.com>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Reviewed-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
Link: https://lore.kernel.org/r/20230414045542.3249939-5-danishanwar@ti.com
Signed-off-by: Nishanth Menon <nm@ti.com>

authored by

Suman Anna and committed by
Nishanth Menon
0211cc1e 51b5760e

+122 -15
-15
drivers/remoteproc/pru_rproc.c
··· 82 82 }; 83 83 84 84 /** 85 - * enum pru_type - PRU core type identifier 86 - * 87 - * @PRU_TYPE_PRU: Programmable Real-time Unit 88 - * @PRU_TYPE_RTU: Auxiliary Programmable Real-Time Unit 89 - * @PRU_TYPE_TX_PRU: Transmit Programmable Real-Time Unit 90 - * @PRU_TYPE_MAX: just keep this one at the end 91 - */ 92 - enum pru_type { 93 - PRU_TYPE_PRU = 0, 94 - PRU_TYPE_RTU, 95 - PRU_TYPE_TX_PRU, 96 - PRU_TYPE_MAX, 97 - }; 98 - 99 - /** 100 85 * struct pru_private_data - device data for a PRU core 101 86 * @type: type of the PRU core (PRU, RTU, Tx_PRU) 102 87 * @is_k3: flag used to identify the need for special load handling
+71
drivers/soc/ti/pruss.c
··· 213 213 } 214 214 EXPORT_SYMBOL_GPL(pruss_cfg_set_gpmux); 215 215 216 + /** 217 + * pruss_cfg_gpimode() - set the GPI mode of the PRU 218 + * @pruss: the pruss instance handle 219 + * @pru_id: id of the PRU core within the PRUSS 220 + * @mode: GPI mode to set 221 + * 222 + * Sets the GPI mode for a given PRU by programming the 223 + * corresponding PRUSS_CFG_GPCFGx register 224 + * 225 + * Return: 0 on success, or an error code otherwise 226 + */ 227 + int pruss_cfg_gpimode(struct pruss *pruss, enum pruss_pru_id pru_id, 228 + enum pruss_gpi_mode mode) 229 + { 230 + if (pru_id >= PRUSS_NUM_PRUS || mode >= PRUSS_GPI_MODE_MAX) 231 + return -EINVAL; 232 + 233 + return pruss_cfg_update(pruss, PRUSS_CFG_GPCFG(pru_id), 234 + PRUSS_GPCFG_PRU_GPI_MODE_MASK, 235 + mode << PRUSS_GPCFG_PRU_GPI_MODE_SHIFT); 236 + } 237 + EXPORT_SYMBOL_GPL(pruss_cfg_gpimode); 238 + 239 + /** 240 + * pruss_cfg_miirt_enable() - Enable/disable MII RT Events 241 + * @pruss: the pruss instance 242 + * @enable: enable/disable 243 + * 244 + * Enable/disable the MII RT Events for the PRUSS. 245 + * 246 + * Return: 0 on success, or an error code otherwise 247 + */ 248 + int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable) 249 + { 250 + u32 set = enable ? PRUSS_MII_RT_EVENT_EN : 0; 251 + 252 + return pruss_cfg_update(pruss, PRUSS_CFG_MII_RT, 253 + PRUSS_MII_RT_EVENT_EN, set); 254 + } 255 + EXPORT_SYMBOL_GPL(pruss_cfg_miirt_enable); 256 + 257 + /** 258 + * pruss_cfg_xfr_enable() - Enable/disable XIN XOUT shift functionality 259 + * @pruss: the pruss instance 260 + * @pru_type: PRU core type identifier 261 + * @enable: enable/disable 262 + * 263 + * Return: 0 on success, or an error code otherwise 264 + */ 265 + int pruss_cfg_xfr_enable(struct pruss *pruss, enum pru_type pru_type, 266 + bool enable) 267 + { 268 + u32 mask, set; 269 + 270 + switch (pru_type) { 271 + case PRU_TYPE_PRU: 272 + mask = PRUSS_SPP_XFER_SHIFT_EN; 273 + break; 274 + case PRU_TYPE_RTU: 275 + mask = PRUSS_SPP_RTU_XFR_SHIFT_EN; 276 + break; 277 + default: 278 + return -EINVAL; 279 + } 280 + 281 + set = enable ? mask : 0; 282 + 283 + return pruss_cfg_update(pruss, PRUSS_CFG_SPP, mask, set); 284 + } 285 + EXPORT_SYMBOL_GPL(pruss_cfg_xfr_enable); 286 + 216 287 static void pruss_of_free_clk_provider(void *data) 217 288 { 218 289 struct device_node *clk_mux_np = data;
+51
include/linux/pruss_driver.h
··· 33 33 }; 34 34 35 35 /* 36 + * enum pruss_gpi_mode - PRUSS GPI configuration modes, used 37 + * to program the PRUSS_GPCFG0/1 registers 38 + */ 39 + enum pruss_gpi_mode { 40 + PRUSS_GPI_MODE_DIRECT, 41 + PRUSS_GPI_MODE_PARALLEL, 42 + PRUSS_GPI_MODE_28BIT_SHIFT, 43 + PRUSS_GPI_MODE_MII, 44 + PRUSS_GPI_MODE_MAX, 45 + }; 46 + 47 + /** 48 + * enum pru_type - PRU core type identifier 49 + * 50 + * @PRU_TYPE_PRU: Programmable Real-time Unit 51 + * @PRU_TYPE_RTU: Auxiliary Programmable Real-Time Unit 52 + * @PRU_TYPE_TX_PRU: Transmit Programmable Real-Time Unit 53 + * @PRU_TYPE_MAX: just keep this one at the end 54 + */ 55 + enum pru_type { 56 + PRU_TYPE_PRU, 57 + PRU_TYPE_RTU, 58 + PRU_TYPE_TX_PRU, 59 + PRU_TYPE_MAX, 60 + }; 61 + 62 + /* 36 63 * enum pruss_mem - PRUSS memory range identifiers 37 64 */ 38 65 enum pruss_mem { ··· 113 86 struct pruss_mem_region *region); 114 87 int pruss_cfg_get_gpmux(struct pruss *pruss, enum pruss_pru_id pru_id, u8 *mux); 115 88 int pruss_cfg_set_gpmux(struct pruss *pruss, enum pruss_pru_id pru_id, u8 mux); 89 + int pruss_cfg_gpimode(struct pruss *pruss, enum pruss_pru_id pru_id, 90 + enum pruss_gpi_mode mode); 91 + int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable); 92 + int pruss_cfg_xfr_enable(struct pruss *pruss, enum pru_type pru_type, 93 + bool enable); 116 94 117 95 #else 118 96 ··· 149 117 150 118 static inline int pruss_cfg_set_gpmux(struct pruss *pruss, 151 119 enum pruss_pru_id pru_id, u8 mux) 120 + { 121 + return ERR_PTR(-EOPNOTSUPP); 122 + } 123 + 124 + static inline int pruss_cfg_gpimode(struct pruss *pruss, 125 + enum pruss_pru_id pru_id, 126 + enum pruss_gpi_mode mode) 127 + { 128 + return ERR_PTR(-EOPNOTSUPP); 129 + } 130 + 131 + static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable) 132 + { 133 + return ERR_PTR(-EOPNOTSUPP); 134 + } 135 + 136 + static inline int pruss_cfg_xfr_enable(struct pruss *pruss, 137 + enum pru_type pru_type, 138 + bool enable); 152 139 { 153 140 return ERR_PTR(-EOPNOTSUPP); 154 141 }