1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * PRU-ICSS sub-system specific definitions
5 * Copyright (C) 2014-2020 Texas Instruments Incorporated - http://www.ti.com/
6 * Suman Anna <s-anna@ti.com>
9 #ifndef _PRUSS_DRIVER_H_
10 #define _PRUSS_DRIVER_H_
12 #include <linux/mutex.h>
13 #include <linux/remoteproc/pruss.h>
14 #include <linux/types.h>
15 #include <linux/err.h>
18 * enum pruss_gp_mux_sel - PRUSS GPI/O Mux modes for the
19 * PRUSS_GPCFG0/1 registers
21 * NOTE: The below defines are the most common values, but there
22 * are some exceptions like on 66AK2G, where the RESERVED and MII2
23 * values are interchanged. Also, this bit-field does not exist on
26 enum pruss_gp_mux_sel
{
28 PRUSS_GP_MUX_SEL_ENDAT
,
29 PRUSS_GP_MUX_SEL_RESERVED
,
31 PRUSS_GP_MUX_SEL_MII2
,
36 * enum pruss_gpi_mode - PRUSS GPI configuration modes, used
37 * to program the PRUSS_GPCFG0/1 registers
40 PRUSS_GPI_MODE_DIRECT
,
41 PRUSS_GPI_MODE_PARALLEL
,
42 PRUSS_GPI_MODE_28BIT_SHIFT
,
48 * enum pru_type - PRU core type identifier
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
63 * enum pruss_mem - PRUSS memory range identifiers
73 * struct pruss_mem_region - PRUSS memory region structure
74 * @va: kernel virtual address of the PRUSS memory region
75 * @pa: physical (bus) address of the PRUSS memory region
76 * @size: size of the PRUSS memory region
78 struct pruss_mem_region
{
85 * struct pruss - PRUSS parent structure
86 * @dev: pruss device pointer
87 * @cfg_base: base iomap for CFG region
88 * @cfg_regmap: regmap for config region
89 * @mem_regions: data for each of the PRUSS memory regions
90 * @mem_in_use: to indicate if memory resource is in use
91 * @lock: mutex to serialize access to resources
92 * @core_clk_mux: clk handle for PRUSS CORE_CLK_MUX
93 * @iep_clk_mux: clk handle for PRUSS IEP_CLK_MUX
97 void __iomem
*cfg_base
;
98 struct regmap
*cfg_regmap
;
99 struct pruss_mem_region mem_regions
[PRUSS_MEM_MAX
];
100 struct pruss_mem_region
*mem_in_use
[PRUSS_MEM_MAX
];
101 struct mutex lock
; /* PRU resource lock */
102 struct clk
*core_clk_mux
;
103 struct clk
*iep_clk_mux
;
106 #if IS_ENABLED(CONFIG_TI_PRUSS)
108 struct pruss
*pruss_get(struct rproc
*rproc
);
109 void pruss_put(struct pruss
*pruss
);
110 int pruss_request_mem_region(struct pruss
*pruss
, enum pruss_mem mem_id
,
111 struct pruss_mem_region
*region
);
112 int pruss_release_mem_region(struct pruss
*pruss
,
113 struct pruss_mem_region
*region
);
114 int pruss_cfg_get_gpmux(struct pruss
*pruss
, enum pruss_pru_id pru_id
, u8
*mux
);
115 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
,
124 static inline struct pruss
*pruss_get(struct rproc
*rproc
)
126 return ERR_PTR(-EOPNOTSUPP
);
129 static inline void pruss_put(struct pruss
*pruss
) { }
131 static inline int pruss_request_mem_region(struct pruss
*pruss
,
132 enum pruss_mem mem_id
,
133 struct pruss_mem_region
*region
)
138 static inline int pruss_release_mem_region(struct pruss
*pruss
,
139 struct pruss_mem_region
*region
)
144 static inline int pruss_cfg_get_gpmux(struct pruss
*pruss
,
145 enum pruss_pru_id pru_id
, u8
*mux
)
147 return ERR_PTR(-EOPNOTSUPP
);
150 static inline int pruss_cfg_set_gpmux(struct pruss
*pruss
,
151 enum pruss_pru_id pru_id
, u8 mux
)
153 return ERR_PTR(-EOPNOTSUPP
);
156 static inline int pruss_cfg_gpimode(struct pruss
*pruss
,
157 enum pruss_pru_id pru_id
,
158 enum pruss_gpi_mode mode
)
160 return ERR_PTR(-EOPNOTSUPP
);
163 static inline int pruss_cfg_miirt_enable(struct pruss
*pruss
, bool enable
)
165 return ERR_PTR(-EOPNOTSUPP
);
168 static inline int pruss_cfg_xfr_enable(struct pruss
*pruss
,
169 enum pru_type pru_type
,
172 return ERR_PTR(-EOPNOTSUPP
);
175 #endif /* CONFIG_TI_PRUSS */
177 #endif /* _PRUSS_DRIVER_H_ */