xref: /OK3568_Linux_fs/kernel/include/linux/reset.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _LINUX_RESET_H_
3*4882a593Smuzhiyun #define _LINUX_RESET_H_
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/err.h>
6*4882a593Smuzhiyun #include <linux/errno.h>
7*4882a593Smuzhiyun #include <linux/types.h>
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun struct device;
10*4882a593Smuzhiyun struct device_node;
11*4882a593Smuzhiyun struct reset_control;
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #ifdef CONFIG_RESET_CONTROLLER
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun int reset_control_reset(struct reset_control *rstc);
16*4882a593Smuzhiyun int reset_control_assert(struct reset_control *rstc);
17*4882a593Smuzhiyun int reset_control_deassert(struct reset_control *rstc);
18*4882a593Smuzhiyun int reset_control_status(struct reset_control *rstc);
19*4882a593Smuzhiyun int reset_control_acquire(struct reset_control *rstc);
20*4882a593Smuzhiyun void reset_control_release(struct reset_control *rstc);
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun struct reset_control *__of_reset_control_get(struct device_node *node,
23*4882a593Smuzhiyun 				     const char *id, int index, bool shared,
24*4882a593Smuzhiyun 				     bool optional, bool acquired);
25*4882a593Smuzhiyun struct reset_control *__reset_control_get(struct device *dev, const char *id,
26*4882a593Smuzhiyun 					  int index, bool shared,
27*4882a593Smuzhiyun 					  bool optional, bool acquired);
28*4882a593Smuzhiyun void reset_control_put(struct reset_control *rstc);
29*4882a593Smuzhiyun int __device_reset(struct device *dev, bool optional);
30*4882a593Smuzhiyun struct reset_control *__devm_reset_control_get(struct device *dev,
31*4882a593Smuzhiyun 				     const char *id, int index, bool shared,
32*4882a593Smuzhiyun 				     bool optional, bool acquired);
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun struct reset_control *devm_reset_control_array_get(struct device *dev,
35*4882a593Smuzhiyun 						   bool shared, bool optional);
36*4882a593Smuzhiyun struct reset_control *of_reset_control_array_get(struct device_node *np,
37*4882a593Smuzhiyun 						 bool shared, bool optional,
38*4882a593Smuzhiyun 						 bool acquired);
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun int reset_control_get_count(struct device *dev);
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #else
43*4882a593Smuzhiyun 
reset_control_reset(struct reset_control * rstc)44*4882a593Smuzhiyun static inline int reset_control_reset(struct reset_control *rstc)
45*4882a593Smuzhiyun {
46*4882a593Smuzhiyun 	return 0;
47*4882a593Smuzhiyun }
48*4882a593Smuzhiyun 
reset_control_assert(struct reset_control * rstc)49*4882a593Smuzhiyun static inline int reset_control_assert(struct reset_control *rstc)
50*4882a593Smuzhiyun {
51*4882a593Smuzhiyun 	return 0;
52*4882a593Smuzhiyun }
53*4882a593Smuzhiyun 
reset_control_deassert(struct reset_control * rstc)54*4882a593Smuzhiyun static inline int reset_control_deassert(struct reset_control *rstc)
55*4882a593Smuzhiyun {
56*4882a593Smuzhiyun 	return 0;
57*4882a593Smuzhiyun }
58*4882a593Smuzhiyun 
reset_control_status(struct reset_control * rstc)59*4882a593Smuzhiyun static inline int reset_control_status(struct reset_control *rstc)
60*4882a593Smuzhiyun {
61*4882a593Smuzhiyun 	return 0;
62*4882a593Smuzhiyun }
63*4882a593Smuzhiyun 
reset_control_acquire(struct reset_control * rstc)64*4882a593Smuzhiyun static inline int reset_control_acquire(struct reset_control *rstc)
65*4882a593Smuzhiyun {
66*4882a593Smuzhiyun 	return 0;
67*4882a593Smuzhiyun }
68*4882a593Smuzhiyun 
reset_control_release(struct reset_control * rstc)69*4882a593Smuzhiyun static inline void reset_control_release(struct reset_control *rstc)
70*4882a593Smuzhiyun {
71*4882a593Smuzhiyun }
72*4882a593Smuzhiyun 
reset_control_put(struct reset_control * rstc)73*4882a593Smuzhiyun static inline void reset_control_put(struct reset_control *rstc)
74*4882a593Smuzhiyun {
75*4882a593Smuzhiyun }
76*4882a593Smuzhiyun 
__device_reset(struct device * dev,bool optional)77*4882a593Smuzhiyun static inline int __device_reset(struct device *dev, bool optional)
78*4882a593Smuzhiyun {
79*4882a593Smuzhiyun 	return optional ? 0 : -ENOTSUPP;
80*4882a593Smuzhiyun }
81*4882a593Smuzhiyun 
__of_reset_control_get(struct device_node * node,const char * id,int index,bool shared,bool optional,bool acquired)82*4882a593Smuzhiyun static inline struct reset_control *__of_reset_control_get(
83*4882a593Smuzhiyun 					struct device_node *node,
84*4882a593Smuzhiyun 					const char *id, int index, bool shared,
85*4882a593Smuzhiyun 					bool optional, bool acquired)
86*4882a593Smuzhiyun {
87*4882a593Smuzhiyun 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
88*4882a593Smuzhiyun }
89*4882a593Smuzhiyun 
__reset_control_get(struct device * dev,const char * id,int index,bool shared,bool optional,bool acquired)90*4882a593Smuzhiyun static inline struct reset_control *__reset_control_get(
91*4882a593Smuzhiyun 					struct device *dev, const char *id,
92*4882a593Smuzhiyun 					int index, bool shared, bool optional,
93*4882a593Smuzhiyun 					bool acquired)
94*4882a593Smuzhiyun {
95*4882a593Smuzhiyun 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
96*4882a593Smuzhiyun }
97*4882a593Smuzhiyun 
__devm_reset_control_get(struct device * dev,const char * id,int index,bool shared,bool optional,bool acquired)98*4882a593Smuzhiyun static inline struct reset_control *__devm_reset_control_get(
99*4882a593Smuzhiyun 					struct device *dev, const char *id,
100*4882a593Smuzhiyun 					int index, bool shared, bool optional,
101*4882a593Smuzhiyun 					bool acquired)
102*4882a593Smuzhiyun {
103*4882a593Smuzhiyun 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
104*4882a593Smuzhiyun }
105*4882a593Smuzhiyun 
106*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_array_get(struct device * dev,bool shared,bool optional)107*4882a593Smuzhiyun devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
108*4882a593Smuzhiyun {
109*4882a593Smuzhiyun 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
110*4882a593Smuzhiyun }
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun static inline struct reset_control *
of_reset_control_array_get(struct device_node * np,bool shared,bool optional,bool acquired)113*4882a593Smuzhiyun of_reset_control_array_get(struct device_node *np, bool shared, bool optional,
114*4882a593Smuzhiyun 			   bool acquired)
115*4882a593Smuzhiyun {
116*4882a593Smuzhiyun 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
117*4882a593Smuzhiyun }
118*4882a593Smuzhiyun 
reset_control_get_count(struct device * dev)119*4882a593Smuzhiyun static inline int reset_control_get_count(struct device *dev)
120*4882a593Smuzhiyun {
121*4882a593Smuzhiyun 	return -ENOENT;
122*4882a593Smuzhiyun }
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun #endif /* CONFIG_RESET_CONTROLLER */
125*4882a593Smuzhiyun 
device_reset(struct device * dev)126*4882a593Smuzhiyun static inline int __must_check device_reset(struct device *dev)
127*4882a593Smuzhiyun {
128*4882a593Smuzhiyun 	return __device_reset(dev, false);
129*4882a593Smuzhiyun }
130*4882a593Smuzhiyun 
device_reset_optional(struct device * dev)131*4882a593Smuzhiyun static inline int device_reset_optional(struct device *dev)
132*4882a593Smuzhiyun {
133*4882a593Smuzhiyun 	return __device_reset(dev, true);
134*4882a593Smuzhiyun }
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun /**
137*4882a593Smuzhiyun  * reset_control_get_exclusive - Lookup and obtain an exclusive reference
138*4882a593Smuzhiyun  *                               to a reset controller.
139*4882a593Smuzhiyun  * @dev: device to be reset by the controller
140*4882a593Smuzhiyun  * @id: reset line name
141*4882a593Smuzhiyun  *
142*4882a593Smuzhiyun  * Returns a struct reset_control or IS_ERR() condition containing errno.
143*4882a593Smuzhiyun  * If this function is called more than once for the same reset_control it will
144*4882a593Smuzhiyun  * return -EBUSY.
145*4882a593Smuzhiyun  *
146*4882a593Smuzhiyun  * See reset_control_get_shared() for details on shared references to
147*4882a593Smuzhiyun  * reset-controls.
148*4882a593Smuzhiyun  *
149*4882a593Smuzhiyun  * Use of id names is optional.
150*4882a593Smuzhiyun  */
151*4882a593Smuzhiyun static inline struct reset_control *
reset_control_get_exclusive(struct device * dev,const char * id)152*4882a593Smuzhiyun __must_check reset_control_get_exclusive(struct device *dev, const char *id)
153*4882a593Smuzhiyun {
154*4882a593Smuzhiyun 	return __reset_control_get(dev, id, 0, false, false, true);
155*4882a593Smuzhiyun }
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /**
158*4882a593Smuzhiyun  * reset_control_get_exclusive_released - Lookup and obtain a temoprarily
159*4882a593Smuzhiyun  *                                        exclusive reference to a reset
160*4882a593Smuzhiyun  *                                        controller.
161*4882a593Smuzhiyun  * @dev: device to be reset by the controller
162*4882a593Smuzhiyun  * @id: reset line name
163*4882a593Smuzhiyun  *
164*4882a593Smuzhiyun  * Returns a struct reset_control or IS_ERR() condition containing errno.
165*4882a593Smuzhiyun  * reset-controls returned by this function must be acquired via
166*4882a593Smuzhiyun  * reset_control_acquire() before they can be used and should be released
167*4882a593Smuzhiyun  * via reset_control_release() afterwards.
168*4882a593Smuzhiyun  *
169*4882a593Smuzhiyun  * Use of id names is optional.
170*4882a593Smuzhiyun  */
171*4882a593Smuzhiyun static inline struct reset_control *
reset_control_get_exclusive_released(struct device * dev,const char * id)172*4882a593Smuzhiyun __must_check reset_control_get_exclusive_released(struct device *dev,
173*4882a593Smuzhiyun 						  const char *id)
174*4882a593Smuzhiyun {
175*4882a593Smuzhiyun 	return __reset_control_get(dev, id, 0, false, false, false);
176*4882a593Smuzhiyun }
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun /**
179*4882a593Smuzhiyun  * reset_control_get_shared - Lookup and obtain a shared reference to a
180*4882a593Smuzhiyun  *                            reset controller.
181*4882a593Smuzhiyun  * @dev: device to be reset by the controller
182*4882a593Smuzhiyun  * @id: reset line name
183*4882a593Smuzhiyun  *
184*4882a593Smuzhiyun  * Returns a struct reset_control or IS_ERR() condition containing errno.
185*4882a593Smuzhiyun  * This function is intended for use with reset-controls which are shared
186*4882a593Smuzhiyun  * between hardware blocks.
187*4882a593Smuzhiyun  *
188*4882a593Smuzhiyun  * When a reset-control is shared, the behavior of reset_control_assert /
189*4882a593Smuzhiyun  * deassert is changed, the reset-core will keep track of a deassert_count
190*4882a593Smuzhiyun  * and only (re-)assert the reset after reset_control_assert has been called
191*4882a593Smuzhiyun  * as many times as reset_control_deassert was called. Also see the remark
192*4882a593Smuzhiyun  * about shared reset-controls in the reset_control_assert docs.
193*4882a593Smuzhiyun  *
194*4882a593Smuzhiyun  * Calling reset_control_assert without first calling reset_control_deassert
195*4882a593Smuzhiyun  * is not allowed on a shared reset control. Calling reset_control_reset is
196*4882a593Smuzhiyun  * also not allowed on a shared reset control.
197*4882a593Smuzhiyun  *
198*4882a593Smuzhiyun  * Use of id names is optional.
199*4882a593Smuzhiyun  */
reset_control_get_shared(struct device * dev,const char * id)200*4882a593Smuzhiyun static inline struct reset_control *reset_control_get_shared(
201*4882a593Smuzhiyun 					struct device *dev, const char *id)
202*4882a593Smuzhiyun {
203*4882a593Smuzhiyun 	return __reset_control_get(dev, id, 0, true, false, false);
204*4882a593Smuzhiyun }
205*4882a593Smuzhiyun 
206*4882a593Smuzhiyun /**
207*4882a593Smuzhiyun  * reset_control_get_optional_exclusive - optional reset_control_get_exclusive()
208*4882a593Smuzhiyun  * @dev: device to be reset by the controller
209*4882a593Smuzhiyun  * @id: reset line name
210*4882a593Smuzhiyun  *
211*4882a593Smuzhiyun  * Optional variant of reset_control_get_exclusive(). If the requested reset
212*4882a593Smuzhiyun  * is not specified in the device tree, this function returns NULL instead of
213*4882a593Smuzhiyun  * an error.
214*4882a593Smuzhiyun  *
215*4882a593Smuzhiyun  * See reset_control_get_exclusive() for more information.
216*4882a593Smuzhiyun  */
reset_control_get_optional_exclusive(struct device * dev,const char * id)217*4882a593Smuzhiyun static inline struct reset_control *reset_control_get_optional_exclusive(
218*4882a593Smuzhiyun 					struct device *dev, const char *id)
219*4882a593Smuzhiyun {
220*4882a593Smuzhiyun 	return __reset_control_get(dev, id, 0, false, true, true);
221*4882a593Smuzhiyun }
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun /**
224*4882a593Smuzhiyun  * reset_control_get_optional_shared - optional reset_control_get_shared()
225*4882a593Smuzhiyun  * @dev: device to be reset by the controller
226*4882a593Smuzhiyun  * @id: reset line name
227*4882a593Smuzhiyun  *
228*4882a593Smuzhiyun  * Optional variant of reset_control_get_shared(). If the requested reset
229*4882a593Smuzhiyun  * is not specified in the device tree, this function returns NULL instead of
230*4882a593Smuzhiyun  * an error.
231*4882a593Smuzhiyun  *
232*4882a593Smuzhiyun  * See reset_control_get_shared() for more information.
233*4882a593Smuzhiyun  */
reset_control_get_optional_shared(struct device * dev,const char * id)234*4882a593Smuzhiyun static inline struct reset_control *reset_control_get_optional_shared(
235*4882a593Smuzhiyun 					struct device *dev, const char *id)
236*4882a593Smuzhiyun {
237*4882a593Smuzhiyun 	return __reset_control_get(dev, id, 0, true, true, false);
238*4882a593Smuzhiyun }
239*4882a593Smuzhiyun 
240*4882a593Smuzhiyun /**
241*4882a593Smuzhiyun  * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
242*4882a593Smuzhiyun  *                                  to a reset controller.
243*4882a593Smuzhiyun  * @node: device to be reset by the controller
244*4882a593Smuzhiyun  * @id: reset line name
245*4882a593Smuzhiyun  *
246*4882a593Smuzhiyun  * Returns a struct reset_control or IS_ERR() condition containing errno.
247*4882a593Smuzhiyun  *
248*4882a593Smuzhiyun  * Use of id names is optional.
249*4882a593Smuzhiyun  */
of_reset_control_get_exclusive(struct device_node * node,const char * id)250*4882a593Smuzhiyun static inline struct reset_control *of_reset_control_get_exclusive(
251*4882a593Smuzhiyun 				struct device_node *node, const char *id)
252*4882a593Smuzhiyun {
253*4882a593Smuzhiyun 	return __of_reset_control_get(node, id, 0, false, false, true);
254*4882a593Smuzhiyun }
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun /**
257*4882a593Smuzhiyun  * of_reset_control_get_shared - Lookup and obtain a shared reference
258*4882a593Smuzhiyun  *                               to a reset controller.
259*4882a593Smuzhiyun  * @node: device to be reset by the controller
260*4882a593Smuzhiyun  * @id: reset line name
261*4882a593Smuzhiyun  *
262*4882a593Smuzhiyun  * When a reset-control is shared, the behavior of reset_control_assert /
263*4882a593Smuzhiyun  * deassert is changed, the reset-core will keep track of a deassert_count
264*4882a593Smuzhiyun  * and only (re-)assert the reset after reset_control_assert has been called
265*4882a593Smuzhiyun  * as many times as reset_control_deassert was called. Also see the remark
266*4882a593Smuzhiyun  * about shared reset-controls in the reset_control_assert docs.
267*4882a593Smuzhiyun  *
268*4882a593Smuzhiyun  * Calling reset_control_assert without first calling reset_control_deassert
269*4882a593Smuzhiyun  * is not allowed on a shared reset control. Calling reset_control_reset is
270*4882a593Smuzhiyun  * also not allowed on a shared reset control.
271*4882a593Smuzhiyun  * Returns a struct reset_control or IS_ERR() condition containing errno.
272*4882a593Smuzhiyun  *
273*4882a593Smuzhiyun  * Use of id names is optional.
274*4882a593Smuzhiyun  */
of_reset_control_get_shared(struct device_node * node,const char * id)275*4882a593Smuzhiyun static inline struct reset_control *of_reset_control_get_shared(
276*4882a593Smuzhiyun 				struct device_node *node, const char *id)
277*4882a593Smuzhiyun {
278*4882a593Smuzhiyun 	return __of_reset_control_get(node, id, 0, true, false, false);
279*4882a593Smuzhiyun }
280*4882a593Smuzhiyun 
281*4882a593Smuzhiyun /**
282*4882a593Smuzhiyun  * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
283*4882a593Smuzhiyun  *                                           reference to a reset controller
284*4882a593Smuzhiyun  *                                           by index.
285*4882a593Smuzhiyun  * @node: device to be reset by the controller
286*4882a593Smuzhiyun  * @index: index of the reset controller
287*4882a593Smuzhiyun  *
288*4882a593Smuzhiyun  * This is to be used to perform a list of resets for a device or power domain
289*4882a593Smuzhiyun  * in whatever order. Returns a struct reset_control or IS_ERR() condition
290*4882a593Smuzhiyun  * containing errno.
291*4882a593Smuzhiyun  */
of_reset_control_get_exclusive_by_index(struct device_node * node,int index)292*4882a593Smuzhiyun static inline struct reset_control *of_reset_control_get_exclusive_by_index(
293*4882a593Smuzhiyun 					struct device_node *node, int index)
294*4882a593Smuzhiyun {
295*4882a593Smuzhiyun 	return __of_reset_control_get(node, NULL, index, false, false, true);
296*4882a593Smuzhiyun }
297*4882a593Smuzhiyun 
298*4882a593Smuzhiyun /**
299*4882a593Smuzhiyun  * of_reset_control_get_shared_by_index - Lookup and obtain a shared
300*4882a593Smuzhiyun  *                                        reference to a reset controller
301*4882a593Smuzhiyun  *                                        by index.
302*4882a593Smuzhiyun  * @node: device to be reset by the controller
303*4882a593Smuzhiyun  * @index: index of the reset controller
304*4882a593Smuzhiyun  *
305*4882a593Smuzhiyun  * When a reset-control is shared, the behavior of reset_control_assert /
306*4882a593Smuzhiyun  * deassert is changed, the reset-core will keep track of a deassert_count
307*4882a593Smuzhiyun  * and only (re-)assert the reset after reset_control_assert has been called
308*4882a593Smuzhiyun  * as many times as reset_control_deassert was called. Also see the remark
309*4882a593Smuzhiyun  * about shared reset-controls in the reset_control_assert docs.
310*4882a593Smuzhiyun  *
311*4882a593Smuzhiyun  * Calling reset_control_assert without first calling reset_control_deassert
312*4882a593Smuzhiyun  * is not allowed on a shared reset control. Calling reset_control_reset is
313*4882a593Smuzhiyun  * also not allowed on a shared reset control.
314*4882a593Smuzhiyun  * Returns a struct reset_control or IS_ERR() condition containing errno.
315*4882a593Smuzhiyun  *
316*4882a593Smuzhiyun  * This is to be used to perform a list of resets for a device or power domain
317*4882a593Smuzhiyun  * in whatever order. Returns a struct reset_control or IS_ERR() condition
318*4882a593Smuzhiyun  * containing errno.
319*4882a593Smuzhiyun  */
of_reset_control_get_shared_by_index(struct device_node * node,int index)320*4882a593Smuzhiyun static inline struct reset_control *of_reset_control_get_shared_by_index(
321*4882a593Smuzhiyun 					struct device_node *node, int index)
322*4882a593Smuzhiyun {
323*4882a593Smuzhiyun 	return __of_reset_control_get(node, NULL, index, true, false, false);
324*4882a593Smuzhiyun }
325*4882a593Smuzhiyun 
326*4882a593Smuzhiyun /**
327*4882a593Smuzhiyun  * devm_reset_control_get_exclusive - resource managed
328*4882a593Smuzhiyun  *                                    reset_control_get_exclusive()
329*4882a593Smuzhiyun  * @dev: device to be reset by the controller
330*4882a593Smuzhiyun  * @id: reset line name
331*4882a593Smuzhiyun  *
332*4882a593Smuzhiyun  * Managed reset_control_get_exclusive(). For reset controllers returned
333*4882a593Smuzhiyun  * from this function, reset_control_put() is called automatically on driver
334*4882a593Smuzhiyun  * detach.
335*4882a593Smuzhiyun  *
336*4882a593Smuzhiyun  * See reset_control_get_exclusive() for more information.
337*4882a593Smuzhiyun  */
338*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_get_exclusive(struct device * dev,const char * id)339*4882a593Smuzhiyun __must_check devm_reset_control_get_exclusive(struct device *dev,
340*4882a593Smuzhiyun 					      const char *id)
341*4882a593Smuzhiyun {
342*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, id, 0, false, false, true);
343*4882a593Smuzhiyun }
344*4882a593Smuzhiyun 
345*4882a593Smuzhiyun /**
346*4882a593Smuzhiyun  * devm_reset_control_get_exclusive_released - resource managed
347*4882a593Smuzhiyun  *                                             reset_control_get_exclusive_released()
348*4882a593Smuzhiyun  * @dev: device to be reset by the controller
349*4882a593Smuzhiyun  * @id: reset line name
350*4882a593Smuzhiyun  *
351*4882a593Smuzhiyun  * Managed reset_control_get_exclusive_released(). For reset controllers
352*4882a593Smuzhiyun  * returned from this function, reset_control_put() is called automatically on
353*4882a593Smuzhiyun  * driver detach.
354*4882a593Smuzhiyun  *
355*4882a593Smuzhiyun  * See reset_control_get_exclusive_released() for more information.
356*4882a593Smuzhiyun  */
357*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_get_exclusive_released(struct device * dev,const char * id)358*4882a593Smuzhiyun __must_check devm_reset_control_get_exclusive_released(struct device *dev,
359*4882a593Smuzhiyun 						       const char *id)
360*4882a593Smuzhiyun {
361*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, id, 0, false, false, false);
362*4882a593Smuzhiyun }
363*4882a593Smuzhiyun 
364*4882a593Smuzhiyun /**
365*4882a593Smuzhiyun  * devm_reset_control_get_shared - resource managed reset_control_get_shared()
366*4882a593Smuzhiyun  * @dev: device to be reset by the controller
367*4882a593Smuzhiyun  * @id: reset line name
368*4882a593Smuzhiyun  *
369*4882a593Smuzhiyun  * Managed reset_control_get_shared(). For reset controllers returned from
370*4882a593Smuzhiyun  * this function, reset_control_put() is called automatically on driver detach.
371*4882a593Smuzhiyun  * See reset_control_get_shared() for more information.
372*4882a593Smuzhiyun  */
devm_reset_control_get_shared(struct device * dev,const char * id)373*4882a593Smuzhiyun static inline struct reset_control *devm_reset_control_get_shared(
374*4882a593Smuzhiyun 					struct device *dev, const char *id)
375*4882a593Smuzhiyun {
376*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, id, 0, true, false, false);
377*4882a593Smuzhiyun }
378*4882a593Smuzhiyun 
379*4882a593Smuzhiyun /**
380*4882a593Smuzhiyun  * devm_reset_control_get_optional_exclusive - resource managed
381*4882a593Smuzhiyun  *                                             reset_control_get_optional_exclusive()
382*4882a593Smuzhiyun  * @dev: device to be reset by the controller
383*4882a593Smuzhiyun  * @id: reset line name
384*4882a593Smuzhiyun  *
385*4882a593Smuzhiyun  * Managed reset_control_get_optional_exclusive(). For reset controllers
386*4882a593Smuzhiyun  * returned from this function, reset_control_put() is called automatically on
387*4882a593Smuzhiyun  * driver detach.
388*4882a593Smuzhiyun  *
389*4882a593Smuzhiyun  * See reset_control_get_optional_exclusive() for more information.
390*4882a593Smuzhiyun  */
devm_reset_control_get_optional_exclusive(struct device * dev,const char * id)391*4882a593Smuzhiyun static inline struct reset_control *devm_reset_control_get_optional_exclusive(
392*4882a593Smuzhiyun 					struct device *dev, const char *id)
393*4882a593Smuzhiyun {
394*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, id, 0, false, true, true);
395*4882a593Smuzhiyun }
396*4882a593Smuzhiyun 
397*4882a593Smuzhiyun /**
398*4882a593Smuzhiyun  * devm_reset_control_get_optional_shared - resource managed
399*4882a593Smuzhiyun  *                                          reset_control_get_optional_shared()
400*4882a593Smuzhiyun  * @dev: device to be reset by the controller
401*4882a593Smuzhiyun  * @id: reset line name
402*4882a593Smuzhiyun  *
403*4882a593Smuzhiyun  * Managed reset_control_get_optional_shared(). For reset controllers returned
404*4882a593Smuzhiyun  * from this function, reset_control_put() is called automatically on driver
405*4882a593Smuzhiyun  * detach.
406*4882a593Smuzhiyun  *
407*4882a593Smuzhiyun  * See reset_control_get_optional_shared() for more information.
408*4882a593Smuzhiyun  */
devm_reset_control_get_optional_shared(struct device * dev,const char * id)409*4882a593Smuzhiyun static inline struct reset_control *devm_reset_control_get_optional_shared(
410*4882a593Smuzhiyun 					struct device *dev, const char *id)
411*4882a593Smuzhiyun {
412*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, id, 0, true, true, false);
413*4882a593Smuzhiyun }
414*4882a593Smuzhiyun 
415*4882a593Smuzhiyun /**
416*4882a593Smuzhiyun  * devm_reset_control_get_exclusive_by_index - resource managed
417*4882a593Smuzhiyun  *                                             reset_control_get_exclusive()
418*4882a593Smuzhiyun  * @dev: device to be reset by the controller
419*4882a593Smuzhiyun  * @index: index of the reset controller
420*4882a593Smuzhiyun  *
421*4882a593Smuzhiyun  * Managed reset_control_get_exclusive(). For reset controllers returned from
422*4882a593Smuzhiyun  * this function, reset_control_put() is called automatically on driver
423*4882a593Smuzhiyun  * detach.
424*4882a593Smuzhiyun  *
425*4882a593Smuzhiyun  * See reset_control_get_exclusive() for more information.
426*4882a593Smuzhiyun  */
427*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_get_exclusive_by_index(struct device * dev,int index)428*4882a593Smuzhiyun devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
429*4882a593Smuzhiyun {
430*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, NULL, index, false, false, true);
431*4882a593Smuzhiyun }
432*4882a593Smuzhiyun 
433*4882a593Smuzhiyun /**
434*4882a593Smuzhiyun  * devm_reset_control_get_shared_by_index - resource managed
435*4882a593Smuzhiyun  *                                          reset_control_get_shared
436*4882a593Smuzhiyun  * @dev: device to be reset by the controller
437*4882a593Smuzhiyun  * @index: index of the reset controller
438*4882a593Smuzhiyun  *
439*4882a593Smuzhiyun  * Managed reset_control_get_shared(). For reset controllers returned from
440*4882a593Smuzhiyun  * this function, reset_control_put() is called automatically on driver detach.
441*4882a593Smuzhiyun  * See reset_control_get_shared() for more information.
442*4882a593Smuzhiyun  */
443*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_get_shared_by_index(struct device * dev,int index)444*4882a593Smuzhiyun devm_reset_control_get_shared_by_index(struct device *dev, int index)
445*4882a593Smuzhiyun {
446*4882a593Smuzhiyun 	return __devm_reset_control_get(dev, NULL, index, true, false, false);
447*4882a593Smuzhiyun }
448*4882a593Smuzhiyun 
449*4882a593Smuzhiyun /*
450*4882a593Smuzhiyun  * TEMPORARY calls to use during transition:
451*4882a593Smuzhiyun  *
452*4882a593Smuzhiyun  *   of_reset_control_get() => of_reset_control_get_exclusive()
453*4882a593Smuzhiyun  *
454*4882a593Smuzhiyun  * These inline function calls will be removed once all consumers
455*4882a593Smuzhiyun  * have been moved over to the new explicit API.
456*4882a593Smuzhiyun  */
of_reset_control_get(struct device_node * node,const char * id)457*4882a593Smuzhiyun static inline struct reset_control *of_reset_control_get(
458*4882a593Smuzhiyun 				struct device_node *node, const char *id)
459*4882a593Smuzhiyun {
460*4882a593Smuzhiyun 	return of_reset_control_get_exclusive(node, id);
461*4882a593Smuzhiyun }
462*4882a593Smuzhiyun 
of_reset_control_get_by_index(struct device_node * node,int index)463*4882a593Smuzhiyun static inline struct reset_control *of_reset_control_get_by_index(
464*4882a593Smuzhiyun 				struct device_node *node, int index)
465*4882a593Smuzhiyun {
466*4882a593Smuzhiyun 	return of_reset_control_get_exclusive_by_index(node, index);
467*4882a593Smuzhiyun }
468*4882a593Smuzhiyun 
devm_reset_control_get(struct device * dev,const char * id)469*4882a593Smuzhiyun static inline struct reset_control *devm_reset_control_get(
470*4882a593Smuzhiyun 				struct device *dev, const char *id)
471*4882a593Smuzhiyun {
472*4882a593Smuzhiyun 	return devm_reset_control_get_exclusive(dev, id);
473*4882a593Smuzhiyun }
474*4882a593Smuzhiyun 
devm_reset_control_get_optional(struct device * dev,const char * id)475*4882a593Smuzhiyun static inline struct reset_control *devm_reset_control_get_optional(
476*4882a593Smuzhiyun 				struct device *dev, const char *id)
477*4882a593Smuzhiyun {
478*4882a593Smuzhiyun 	return devm_reset_control_get_optional_exclusive(dev, id);
479*4882a593Smuzhiyun 
480*4882a593Smuzhiyun }
481*4882a593Smuzhiyun 
devm_reset_control_get_by_index(struct device * dev,int index)482*4882a593Smuzhiyun static inline struct reset_control *devm_reset_control_get_by_index(
483*4882a593Smuzhiyun 				struct device *dev, int index)
484*4882a593Smuzhiyun {
485*4882a593Smuzhiyun 	return devm_reset_control_get_exclusive_by_index(dev, index);
486*4882a593Smuzhiyun }
487*4882a593Smuzhiyun 
488*4882a593Smuzhiyun /*
489*4882a593Smuzhiyun  * APIs to manage a list of reset controllers
490*4882a593Smuzhiyun  */
491*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_array_get_exclusive(struct device * dev)492*4882a593Smuzhiyun devm_reset_control_array_get_exclusive(struct device *dev)
493*4882a593Smuzhiyun {
494*4882a593Smuzhiyun 	return devm_reset_control_array_get(dev, false, false);
495*4882a593Smuzhiyun }
496*4882a593Smuzhiyun 
497*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_array_get_shared(struct device * dev)498*4882a593Smuzhiyun devm_reset_control_array_get_shared(struct device *dev)
499*4882a593Smuzhiyun {
500*4882a593Smuzhiyun 	return devm_reset_control_array_get(dev, true, false);
501*4882a593Smuzhiyun }
502*4882a593Smuzhiyun 
503*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_array_get_optional_exclusive(struct device * dev)504*4882a593Smuzhiyun devm_reset_control_array_get_optional_exclusive(struct device *dev)
505*4882a593Smuzhiyun {
506*4882a593Smuzhiyun 	return devm_reset_control_array_get(dev, false, true);
507*4882a593Smuzhiyun }
508*4882a593Smuzhiyun 
509*4882a593Smuzhiyun static inline struct reset_control *
devm_reset_control_array_get_optional_shared(struct device * dev)510*4882a593Smuzhiyun devm_reset_control_array_get_optional_shared(struct device *dev)
511*4882a593Smuzhiyun {
512*4882a593Smuzhiyun 	return devm_reset_control_array_get(dev, true, true);
513*4882a593Smuzhiyun }
514*4882a593Smuzhiyun 
515*4882a593Smuzhiyun static inline struct reset_control *
of_reset_control_array_get_exclusive(struct device_node * node)516*4882a593Smuzhiyun of_reset_control_array_get_exclusive(struct device_node *node)
517*4882a593Smuzhiyun {
518*4882a593Smuzhiyun 	return of_reset_control_array_get(node, false, false, true);
519*4882a593Smuzhiyun }
520*4882a593Smuzhiyun 
521*4882a593Smuzhiyun static inline struct reset_control *
of_reset_control_array_get_exclusive_released(struct device_node * node)522*4882a593Smuzhiyun of_reset_control_array_get_exclusive_released(struct device_node *node)
523*4882a593Smuzhiyun {
524*4882a593Smuzhiyun 	return of_reset_control_array_get(node, false, false, false);
525*4882a593Smuzhiyun }
526*4882a593Smuzhiyun 
527*4882a593Smuzhiyun static inline struct reset_control *
of_reset_control_array_get_shared(struct device_node * node)528*4882a593Smuzhiyun of_reset_control_array_get_shared(struct device_node *node)
529*4882a593Smuzhiyun {
530*4882a593Smuzhiyun 	return of_reset_control_array_get(node, true, false, true);
531*4882a593Smuzhiyun }
532*4882a593Smuzhiyun 
533*4882a593Smuzhiyun static inline struct reset_control *
of_reset_control_array_get_optional_exclusive(struct device_node * node)534*4882a593Smuzhiyun of_reset_control_array_get_optional_exclusive(struct device_node *node)
535*4882a593Smuzhiyun {
536*4882a593Smuzhiyun 	return of_reset_control_array_get(node, false, true, true);
537*4882a593Smuzhiyun }
538*4882a593Smuzhiyun 
539*4882a593Smuzhiyun static inline struct reset_control *
of_reset_control_array_get_optional_shared(struct device_node * node)540*4882a593Smuzhiyun of_reset_control_array_get_optional_shared(struct device_node *node)
541*4882a593Smuzhiyun {
542*4882a593Smuzhiyun 	return of_reset_control_array_get(node, true, true, true);
543*4882a593Smuzhiyun }
544*4882a593Smuzhiyun #endif
545