Skip to content

Commit 0211cc1

Browse files
sumanannanmenon
authored andcommitted
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>
1 parent 51b5760 commit 0211cc1

File tree

3 files changed

+122
-15
lines changed

3 files changed

+122
-15
lines changed

drivers/remoteproc/pru_rproc.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,6 @@ enum pru_iomem {
8181
PRU_IOMEM_MAX,
8282
};
8383

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-
9984
/**
10085
* struct pru_private_data - device data for a PRU core
10186
* @type: type of the PRU core (PRU, RTU, Tx_PRU)

drivers/soc/ti/pruss.c

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,77 @@ int pruss_cfg_set_gpmux(struct pruss *pruss, enum pruss_pru_id pru_id, u8 mux)
213213
}
214214
EXPORT_SYMBOL_GPL(pruss_cfg_set_gpmux);
215215

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+
216287
static void pruss_of_free_clk_provider(void *data)
217288
{
218289
struct device_node *clk_mux_np = data;

include/linux/pruss_driver.h

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,33 @@ enum pruss_gp_mux_sel {
3232
PRUSS_GP_MUX_SEL_MAX,
3333
};
3434

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+
3562
/*
3663
* enum pruss_mem - PRUSS memory range identifiers
3764
*/
@@ -86,6 +113,11 @@ int pruss_release_mem_region(struct pruss *pruss,
86113
struct pruss_mem_region *region);
87114
int pruss_cfg_get_gpmux(struct pruss *pruss, enum pruss_pru_id pru_id, u8 *mux);
88115
int pruss_cfg_set_gpmux(struct pruss *pruss, enum pruss_pru_id pru_id, u8 mux);
116+
int pruss_cfg_gpimode(struct pruss *pruss, enum pruss_pru_id pru_id,
117+
enum pruss_gpi_mode mode);
118+
int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable);
119+
int pruss_cfg_xfr_enable(struct pruss *pruss, enum pru_type pru_type,
120+
bool enable);
89121

90122
#else
91123

@@ -121,6 +153,25 @@ static inline int pruss_cfg_set_gpmux(struct pruss *pruss,
121153
return ERR_PTR(-EOPNOTSUPP);
122154
}
123155

156+
static inline int pruss_cfg_gpimode(struct pruss *pruss,
157+
enum pruss_pru_id pru_id,
158+
enum pruss_gpi_mode mode)
159+
{
160+
return ERR_PTR(-EOPNOTSUPP);
161+
}
162+
163+
static inline int pruss_cfg_miirt_enable(struct pruss *pruss, bool enable)
164+
{
165+
return ERR_PTR(-EOPNOTSUPP);
166+
}
167+
168+
static inline int pruss_cfg_xfr_enable(struct pruss *pruss,
169+
enum pru_type pru_type,
170+
bool enable);
171+
{
172+
return ERR_PTR(-EOPNOTSUPP);
173+
}
174+
124175
#endif /* CONFIG_TI_PRUSS */
125176

126177
#endif /* _PRUSS_DRIVER_H_ */

0 commit comments

Comments
 (0)