xref: /linux-6.15/include/linux/reset.h (revision d872bed8)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
261fc4131SPhilipp Zabel #ifndef _LINUX_RESET_H_
361fc4131SPhilipp Zabel #define _LINUX_RESET_H_
461fc4131SPhilipp Zabel 
5d005aa75SRandy Dunlap #include <linux/err.h>
6d005aa75SRandy Dunlap #include <linux/errno.h>
7dfc1d9b2SMasahiro Yamada #include <linux/types.h>
86c96f05cSHans de Goede 
9dfc1d9b2SMasahiro Yamada struct device;
10dfc1d9b2SMasahiro Yamada struct device_node;
1161fc4131SPhilipp Zabel struct reset_control;
1261fc4131SPhilipp Zabel 
1348d71395SPhilipp Zabel /**
1448d71395SPhilipp Zabel  * struct reset_control_bulk_data - Data used for bulk reset control operations.
1548d71395SPhilipp Zabel  *
1648d71395SPhilipp Zabel  * @id: reset control consumer ID
1748d71395SPhilipp Zabel  * @rstc: struct reset_control * to store the associated reset control
1848d71395SPhilipp Zabel  *
1948d71395SPhilipp Zabel  * The reset APIs provide a series of reset_control_bulk_*() API calls as
2048d71395SPhilipp Zabel  * a convenience to consumers which require multiple reset controls.
2148d71395SPhilipp Zabel  * This structure is used to manage data for these calls.
2248d71395SPhilipp Zabel  */
2348d71395SPhilipp Zabel struct reset_control_bulk_data {
2448d71395SPhilipp Zabel 	const char			*id;
2548d71395SPhilipp Zabel 	struct reset_control		*rstc;
2648d71395SPhilipp Zabel };
2748d71395SPhilipp Zabel 
28dad35f7dSPhilipp Zabel #define RESET_CONTROL_FLAGS_BIT_SHARED		BIT(0)	/* not exclusive */
29dad35f7dSPhilipp Zabel #define RESET_CONTROL_FLAGS_BIT_OPTIONAL	BIT(1)
30dad35f7dSPhilipp Zabel #define RESET_CONTROL_FLAGS_BIT_ACQUIRED	BIT(2)	/* iff exclusive, not released */
31*d872bed8SPhilipp Zabel #define RESET_CONTROL_FLAGS_BIT_DEASSERTED	BIT(3)
32dad35f7dSPhilipp Zabel 
33dad35f7dSPhilipp Zabel /**
34dad35f7dSPhilipp Zabel  * enum reset_control_flags - Flags that can be passed to the reset_control_get functions
35dad35f7dSPhilipp Zabel  *                    to determine the type of reset control.
36dad35f7dSPhilipp Zabel  *                    These values cannot be OR'd.
37dad35f7dSPhilipp Zabel  *
38dad35f7dSPhilipp Zabel  * @RESET_CONTROL_EXCLUSIVE:				exclusive, acquired,
39*d872bed8SPhilipp Zabel  * @RESET_CONTROL_EXCLUSIVE_DEASSERTED:			exclusive, acquired, deasserted
40dad35f7dSPhilipp Zabel  * @RESET_CONTROL_EXCLUSIVE_RELEASED:			exclusive, released,
41dad35f7dSPhilipp Zabel  * @RESET_CONTROL_SHARED:				shared
42*d872bed8SPhilipp Zabel  * @RESET_CONTROL_SHARED_DEASSERTED:			shared, deasserted
43dad35f7dSPhilipp Zabel  * @RESET_CONTROL_OPTIONAL_EXCLUSIVE:			optional, exclusive, acquired
44*d872bed8SPhilipp Zabel  * @RESET_CONTROL_OPTIONAL_EXCLUSIVE_DEASSERTED:	optional, exclusive, acquired, deasserted
45dad35f7dSPhilipp Zabel  * @RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED:		optional, exclusive, released
46dad35f7dSPhilipp Zabel  * @RESET_CONTROL_OPTIONAL_SHARED:			optional, shared
47*d872bed8SPhilipp Zabel  * @RESET_CONTROL_OPTIONAL_SHARED_DEASSERTED:		optional, shared, deasserted
48dad35f7dSPhilipp Zabel  */
49dad35f7dSPhilipp Zabel enum reset_control_flags {
50dad35f7dSPhilipp Zabel 	RESET_CONTROL_EXCLUSIVE				= RESET_CONTROL_FLAGS_BIT_ACQUIRED,
51*d872bed8SPhilipp Zabel 	RESET_CONTROL_EXCLUSIVE_DEASSERTED		= RESET_CONTROL_FLAGS_BIT_ACQUIRED |
52*d872bed8SPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_DEASSERTED,
53dad35f7dSPhilipp Zabel 	RESET_CONTROL_EXCLUSIVE_RELEASED		= 0,
54dad35f7dSPhilipp Zabel 	RESET_CONTROL_SHARED				= RESET_CONTROL_FLAGS_BIT_SHARED,
55*d872bed8SPhilipp Zabel 	RESET_CONTROL_SHARED_DEASSERTED			= RESET_CONTROL_FLAGS_BIT_SHARED |
56*d872bed8SPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_DEASSERTED,
57dad35f7dSPhilipp Zabel 	RESET_CONTROL_OPTIONAL_EXCLUSIVE		= RESET_CONTROL_FLAGS_BIT_OPTIONAL |
58dad35f7dSPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_ACQUIRED,
59*d872bed8SPhilipp Zabel 	RESET_CONTROL_OPTIONAL_EXCLUSIVE_DEASSERTED	= RESET_CONTROL_FLAGS_BIT_OPTIONAL |
60*d872bed8SPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_ACQUIRED |
61*d872bed8SPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_DEASSERTED,
62dad35f7dSPhilipp Zabel 	RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED	= RESET_CONTROL_FLAGS_BIT_OPTIONAL,
63dad35f7dSPhilipp Zabel 	RESET_CONTROL_OPTIONAL_SHARED			= RESET_CONTROL_FLAGS_BIT_OPTIONAL |
64dad35f7dSPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_SHARED,
65*d872bed8SPhilipp Zabel 	RESET_CONTROL_OPTIONAL_SHARED_DEASSERTED	= RESET_CONTROL_FLAGS_BIT_OPTIONAL |
66*d872bed8SPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_SHARED |
67*d872bed8SPhilipp Zabel 							  RESET_CONTROL_FLAGS_BIT_DEASSERTED,
68dad35f7dSPhilipp Zabel };
69dad35f7dSPhilipp Zabel 
70b424080aSPhilipp Zabel #ifdef CONFIG_RESET_CONTROLLER
71b424080aSPhilipp Zabel 
7261fc4131SPhilipp Zabel int reset_control_reset(struct reset_control *rstc);
73557acb3dSAmjad Ouled-Ameur int reset_control_rearm(struct reset_control *rstc);
7461fc4131SPhilipp Zabel int reset_control_assert(struct reset_control *rstc);
7561fc4131SPhilipp Zabel int reset_control_deassert(struct reset_control *rstc);
76729de41bSDinh Nguyen int reset_control_status(struct reset_control *rstc);
77c84b0326SPhilipp Zabel int reset_control_acquire(struct reset_control *rstc);
78c84b0326SPhilipp Zabel void reset_control_release(struct reset_control *rstc);
7961fc4131SPhilipp Zabel 
8048d71395SPhilipp Zabel int reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs);
8148d71395SPhilipp Zabel int reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs);
8248d71395SPhilipp Zabel int reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs);
8348d71395SPhilipp Zabel int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs);
8448d71395SPhilipp Zabel void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs);
8548d71395SPhilipp Zabel 
866c96f05cSHans de Goede struct reset_control *__of_reset_control_get(struct device_node *node,
87dad35f7dSPhilipp Zabel 				     const char *id, int index, enum reset_control_flags flags);
8862e24c57SPhilipp Zabel struct reset_control *__reset_control_get(struct device *dev, const char *id,
89dad35f7dSPhilipp Zabel 					  int index, enum reset_control_flags flags);
9061fc4131SPhilipp Zabel void reset_control_put(struct reset_control *rstc);
9148d71395SPhilipp Zabel int __reset_control_bulk_get(struct device *dev, int num_rstcs,
9248d71395SPhilipp Zabel 			     struct reset_control_bulk_data *rstcs,
93dad35f7dSPhilipp Zabel 			     enum reset_control_flags flags);
9448d71395SPhilipp Zabel void reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs);
9548d71395SPhilipp Zabel 
961554bbd4SMasahiro Yamada int __device_reset(struct device *dev, bool optional);
976c96f05cSHans de Goede struct reset_control *__devm_reset_control_get(struct device *dev,
98dad35f7dSPhilipp Zabel 				     const char *id, int index, enum reset_control_flags flags);
9948d71395SPhilipp Zabel int __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
10048d71395SPhilipp Zabel 				  struct reset_control_bulk_data *rstcs,
101dad35f7dSPhilipp Zabel 				  enum reset_control_flags flags);
10261fc4131SPhilipp Zabel 
10317c82e20SVivek Gautam struct reset_control *devm_reset_control_array_get(struct device *dev,
104dad35f7dSPhilipp Zabel 						   enum reset_control_flags flags);
105dad35f7dSPhilipp Zabel struct reset_control *of_reset_control_array_get(struct device_node *np, enum reset_control_flags);
10617c82e20SVivek Gautam 
107eaf91db0SGeert Uytterhoeven int reset_control_get_count(struct device *dev);
108eaf91db0SGeert Uytterhoeven 
109b424080aSPhilipp Zabel #else
110b424080aSPhilipp Zabel 
reset_control_reset(struct reset_control * rstc)111b424080aSPhilipp Zabel static inline int reset_control_reset(struct reset_control *rstc)
112b424080aSPhilipp Zabel {
113b424080aSPhilipp Zabel 	return 0;
114b424080aSPhilipp Zabel }
115b424080aSPhilipp Zabel 
reset_control_rearm(struct reset_control * rstc)11648582b2eSJim Quinlan static inline int reset_control_rearm(struct reset_control *rstc)
11748582b2eSJim Quinlan {
11848582b2eSJim Quinlan 	return 0;
11948582b2eSJim Quinlan }
12048582b2eSJim Quinlan 
reset_control_assert(struct reset_control * rstc)121b424080aSPhilipp Zabel static inline int reset_control_assert(struct reset_control *rstc)
122b424080aSPhilipp Zabel {
123b424080aSPhilipp Zabel 	return 0;
124b424080aSPhilipp Zabel }
125b424080aSPhilipp Zabel 
reset_control_deassert(struct reset_control * rstc)126b424080aSPhilipp Zabel static inline int reset_control_deassert(struct reset_control *rstc)
127b424080aSPhilipp Zabel {
128b424080aSPhilipp Zabel 	return 0;
129b424080aSPhilipp Zabel }
130b424080aSPhilipp Zabel 
reset_control_status(struct reset_control * rstc)131729de41bSDinh Nguyen static inline int reset_control_status(struct reset_control *rstc)
132729de41bSDinh Nguyen {
133729de41bSDinh Nguyen 	return 0;
134729de41bSDinh Nguyen }
135729de41bSDinh Nguyen 
reset_control_acquire(struct reset_control * rstc)136c84b0326SPhilipp Zabel static inline int reset_control_acquire(struct reset_control *rstc)
137c84b0326SPhilipp Zabel {
138c84b0326SPhilipp Zabel 	return 0;
139c84b0326SPhilipp Zabel }
140c84b0326SPhilipp Zabel 
reset_control_release(struct reset_control * rstc)141c84b0326SPhilipp Zabel static inline void reset_control_release(struct reset_control *rstc)
142c84b0326SPhilipp Zabel {
143c84b0326SPhilipp Zabel }
144c84b0326SPhilipp Zabel 
reset_control_put(struct reset_control * rstc)145b424080aSPhilipp Zabel static inline void reset_control_put(struct reset_control *rstc)
146b424080aSPhilipp Zabel {
147b424080aSPhilipp Zabel }
148b424080aSPhilipp Zabel 
__device_reset(struct device * dev,bool optional)1491554bbd4SMasahiro Yamada static inline int __device_reset(struct device *dev, bool optional)
15041136522SDaniel Lezcano {
1511554bbd4SMasahiro Yamada 	return optional ? 0 : -ENOTSUPP;
152b424080aSPhilipp Zabel }
153b424080aSPhilipp Zabel 
__of_reset_control_get(struct device_node * node,const char * id,int index,enum reset_control_flags flags)1546c96f05cSHans de Goede static inline struct reset_control *__of_reset_control_get(
1556c96f05cSHans de Goede 					struct device_node *node,
156dad35f7dSPhilipp Zabel 					const char *id, int index, enum reset_control_flags flags)
1575bcd0b7fSAxel Lin {
158dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
159dad35f7dSPhilipp Zabel 
1600ca10b60SPhilipp Zabel 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
1615bcd0b7fSAxel Lin }
1625bcd0b7fSAxel Lin 
__reset_control_get(struct device * dev,const char * id,int index,enum reset_control_flags flags)16362e24c57SPhilipp Zabel static inline struct reset_control *__reset_control_get(
16462e24c57SPhilipp Zabel 					struct device *dev, const char *id,
165dad35f7dSPhilipp Zabel 					int index, enum reset_control_flags flags)
16662e24c57SPhilipp Zabel {
167dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
168dad35f7dSPhilipp Zabel 
16962e24c57SPhilipp Zabel 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
17062e24c57SPhilipp Zabel }
17162e24c57SPhilipp Zabel 
17248d71395SPhilipp Zabel static inline int
reset_control_bulk_reset(int num_rstcs,struct reset_control_bulk_data * rstcs)17348d71395SPhilipp Zabel reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs)
17448d71395SPhilipp Zabel {
17548d71395SPhilipp Zabel 	return 0;
17648d71395SPhilipp Zabel }
17748d71395SPhilipp Zabel 
17848d71395SPhilipp Zabel static inline int
reset_control_bulk_assert(int num_rstcs,struct reset_control_bulk_data * rstcs)17948d71395SPhilipp Zabel reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs)
18048d71395SPhilipp Zabel {
18148d71395SPhilipp Zabel 	return 0;
18248d71395SPhilipp Zabel }
18348d71395SPhilipp Zabel 
18448d71395SPhilipp Zabel static inline int
reset_control_bulk_deassert(int num_rstcs,struct reset_control_bulk_data * rstcs)18548d71395SPhilipp Zabel reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs)
18648d71395SPhilipp Zabel {
18748d71395SPhilipp Zabel 	return 0;
18848d71395SPhilipp Zabel }
18948d71395SPhilipp Zabel 
19048d71395SPhilipp Zabel static inline int
reset_control_bulk_acquire(int num_rstcs,struct reset_control_bulk_data * rstcs)19148d71395SPhilipp Zabel reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs)
19248d71395SPhilipp Zabel {
19348d71395SPhilipp Zabel 	return 0;
19448d71395SPhilipp Zabel }
19548d71395SPhilipp Zabel 
19648d71395SPhilipp Zabel static inline void
reset_control_bulk_release(int num_rstcs,struct reset_control_bulk_data * rstcs)19748d71395SPhilipp Zabel reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs)
19848d71395SPhilipp Zabel {
19948d71395SPhilipp Zabel }
20048d71395SPhilipp Zabel 
20148d71395SPhilipp Zabel static inline int
__reset_control_bulk_get(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs,enum reset_control_flags flags)20248d71395SPhilipp Zabel __reset_control_bulk_get(struct device *dev, int num_rstcs,
20348d71395SPhilipp Zabel 			 struct reset_control_bulk_data *rstcs,
204dad35f7dSPhilipp Zabel 			 enum reset_control_flags flags)
20548d71395SPhilipp Zabel {
206dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
207dad35f7dSPhilipp Zabel 
20848d71395SPhilipp Zabel 	return optional ? 0 : -EOPNOTSUPP;
20948d71395SPhilipp Zabel }
21048d71395SPhilipp Zabel 
21148d71395SPhilipp Zabel static inline void
reset_control_bulk_put(int num_rstcs,struct reset_control_bulk_data * rstcs)21248d71395SPhilipp Zabel reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs)
21348d71395SPhilipp Zabel {
21448d71395SPhilipp Zabel }
21548d71395SPhilipp Zabel 
__devm_reset_control_get(struct device * dev,const char * id,int index,enum reset_control_flags flags)2166c96f05cSHans de Goede static inline struct reset_control *__devm_reset_control_get(
217bb475230SRamiro Oliveira 					struct device *dev, const char *id,
218dad35f7dSPhilipp Zabel 					int index, enum reset_control_flags flags)
2196c96f05cSHans de Goede {
220dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
221dad35f7dSPhilipp Zabel 
2220ca10b60SPhilipp Zabel 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
2236c96f05cSHans de Goede }
2246c96f05cSHans de Goede 
22548d71395SPhilipp Zabel static inline int
__devm_reset_control_bulk_get(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs,enum reset_control_flags flags)22648d71395SPhilipp Zabel __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
22748d71395SPhilipp Zabel 			      struct reset_control_bulk_data *rstcs,
228dad35f7dSPhilipp Zabel 			      enum reset_control_flags flags)
22948d71395SPhilipp Zabel {
230dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
231dad35f7dSPhilipp Zabel 
23248d71395SPhilipp Zabel 	return optional ? 0 : -EOPNOTSUPP;
23348d71395SPhilipp Zabel }
23448d71395SPhilipp Zabel 
23517c82e20SVivek Gautam static inline struct reset_control *
devm_reset_control_array_get(struct device * dev,enum reset_control_flags flags)236dad35f7dSPhilipp Zabel devm_reset_control_array_get(struct device *dev, enum reset_control_flags flags)
23717c82e20SVivek Gautam {
238dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
239dad35f7dSPhilipp Zabel 
24017c82e20SVivek Gautam 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
24117c82e20SVivek Gautam }
24217c82e20SVivek Gautam 
24317c82e20SVivek Gautam static inline struct reset_control *
of_reset_control_array_get(struct device_node * np,enum reset_control_flags flags)244dad35f7dSPhilipp Zabel of_reset_control_array_get(struct device_node *np, enum reset_control_flags flags)
24517c82e20SVivek Gautam {
246dad35f7dSPhilipp Zabel 	bool optional = flags & RESET_CONTROL_FLAGS_BIT_OPTIONAL;
247dad35f7dSPhilipp Zabel 
24817c82e20SVivek Gautam 	return optional ? NULL : ERR_PTR(-ENOTSUPP);
24917c82e20SVivek Gautam }
25017c82e20SVivek Gautam 
reset_control_get_count(struct device * dev)251eaf91db0SGeert Uytterhoeven static inline int reset_control_get_count(struct device *dev)
252eaf91db0SGeert Uytterhoeven {
253eaf91db0SGeert Uytterhoeven 	return -ENOENT;
254eaf91db0SGeert Uytterhoeven }
255eaf91db0SGeert Uytterhoeven 
2566c96f05cSHans de Goede #endif /* CONFIG_RESET_CONTROLLER */
2576c96f05cSHans de Goede 
device_reset(struct device * dev)2581554bbd4SMasahiro Yamada static inline int __must_check device_reset(struct device *dev)
2591554bbd4SMasahiro Yamada {
2601554bbd4SMasahiro Yamada 	return __device_reset(dev, false);
2611554bbd4SMasahiro Yamada }
2621554bbd4SMasahiro Yamada 
device_reset_optional(struct device * dev)2631554bbd4SMasahiro Yamada static inline int device_reset_optional(struct device *dev)
2641554bbd4SMasahiro Yamada {
2651554bbd4SMasahiro Yamada 	return __device_reset(dev, true);
2661554bbd4SMasahiro Yamada }
2671554bbd4SMasahiro Yamada 
2686c96f05cSHans de Goede /**
269a53e35dbSLee Jones  * reset_control_get_exclusive - Lookup and obtain an exclusive reference
270a53e35dbSLee Jones  *                               to a reset controller.
2716c96f05cSHans de Goede  * @dev: device to be reset by the controller
2726c96f05cSHans de Goede  * @id: reset line name
2736c96f05cSHans de Goede  *
2746c96f05cSHans de Goede  * Returns a struct reset_control or IS_ERR() condition containing errno.
27534845c93SGeert Uytterhoeven  * If this function is called more than once for the same reset_control it will
2760b52297fSHans de Goede  * return -EBUSY.
2770b52297fSHans de Goede  *
278b9e9348dSPhilipp Zabel  * See reset_control_get_shared() for details on shared references to
2790b52297fSHans de Goede  * reset-controls.
2806c96f05cSHans de Goede  *
2816c96f05cSHans de Goede  * Use of id names is optional.
2826c96f05cSHans de Goede  */
283a53e35dbSLee Jones static inline struct reset_control *
reset_control_get_exclusive(struct device * dev,const char * id)284a53e35dbSLee Jones __must_check reset_control_get_exclusive(struct device *dev, const char *id)
2855bcd0b7fSAxel Lin {
286dad35f7dSPhilipp Zabel 	return __reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE);
287c84b0326SPhilipp Zabel }
288c84b0326SPhilipp Zabel 
289c84b0326SPhilipp Zabel /**
29048d71395SPhilipp Zabel  * reset_control_bulk_get_exclusive - Lookup and obtain exclusive references to
29148d71395SPhilipp Zabel  *                                    multiple reset controllers.
29248d71395SPhilipp Zabel  * @dev: device to be reset by the controller
29348d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
29448d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
29548d71395SPhilipp Zabel  *
29648d71395SPhilipp Zabel  * Fills the rstcs array with pointers to exclusive reset controls and
29748d71395SPhilipp Zabel  * returns 0, or an IS_ERR() condition containing errno.
29848d71395SPhilipp Zabel  */
29948d71395SPhilipp Zabel static inline int __must_check
reset_control_bulk_get_exclusive(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)30048d71395SPhilipp Zabel reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
30148d71395SPhilipp Zabel 				 struct reset_control_bulk_data *rstcs)
30248d71395SPhilipp Zabel {
303dad35f7dSPhilipp Zabel 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_EXCLUSIVE);
30448d71395SPhilipp Zabel }
30548d71395SPhilipp Zabel 
30648d71395SPhilipp Zabel /**
307c84b0326SPhilipp Zabel  * reset_control_get_exclusive_released - Lookup and obtain a temoprarily
308c84b0326SPhilipp Zabel  *                                        exclusive reference to a reset
309c84b0326SPhilipp Zabel  *                                        controller.
310c84b0326SPhilipp Zabel  * @dev: device to be reset by the controller
311c84b0326SPhilipp Zabel  * @id: reset line name
312c84b0326SPhilipp Zabel  *
313c84b0326SPhilipp Zabel  * Returns a struct reset_control or IS_ERR() condition containing errno.
314c84b0326SPhilipp Zabel  * reset-controls returned by this function must be acquired via
315c84b0326SPhilipp Zabel  * reset_control_acquire() before they can be used and should be released
316c84b0326SPhilipp Zabel  * via reset_control_release() afterwards.
317c84b0326SPhilipp Zabel  *
318c84b0326SPhilipp Zabel  * Use of id names is optional.
319c84b0326SPhilipp Zabel  */
320c84b0326SPhilipp Zabel static inline struct reset_control *
reset_control_get_exclusive_released(struct device * dev,const char * id)321c84b0326SPhilipp Zabel __must_check reset_control_get_exclusive_released(struct device *dev,
322c84b0326SPhilipp Zabel 						  const char *id)
323c84b0326SPhilipp Zabel {
324dad35f7dSPhilipp Zabel 	return __reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_RELEASED);
3255bcd0b7fSAxel Lin }
3265bcd0b7fSAxel Lin 
3276c96f05cSHans de Goede /**
32848d71395SPhilipp Zabel  * reset_control_bulk_get_exclusive_released - Lookup and obtain temporarily
32948d71395SPhilipp Zabel  *                                    exclusive references to multiple reset
33048d71395SPhilipp Zabel  *                                    controllers.
33148d71395SPhilipp Zabel  * @dev: device to be reset by the controller
33248d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
33348d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
33448d71395SPhilipp Zabel  *
33548d71395SPhilipp Zabel  * Fills the rstcs array with pointers to exclusive reset controls and
33648d71395SPhilipp Zabel  * returns 0, or an IS_ERR() condition containing errno.
33748d71395SPhilipp Zabel  * reset-controls returned by this function must be acquired via
33848d71395SPhilipp Zabel  * reset_control_bulk_acquire() before they can be used and should be released
33948d71395SPhilipp Zabel  * via reset_control_bulk_release() afterwards.
34048d71395SPhilipp Zabel  */
34148d71395SPhilipp Zabel static inline int __must_check
reset_control_bulk_get_exclusive_released(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)34248d71395SPhilipp Zabel reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
34348d71395SPhilipp Zabel 					  struct reset_control_bulk_data *rstcs)
34448d71395SPhilipp Zabel {
345dad35f7dSPhilipp Zabel 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_EXCLUSIVE_RELEASED);
34648d71395SPhilipp Zabel }
34748d71395SPhilipp Zabel 
34848d71395SPhilipp Zabel /**
34948d71395SPhilipp Zabel  * reset_control_bulk_get_optional_exclusive_released - Lookup and obtain optional
35048d71395SPhilipp Zabel  *                                    temporarily exclusive references to multiple
35148d71395SPhilipp Zabel  *                                    reset controllers.
35248d71395SPhilipp Zabel  * @dev: device to be reset by the controller
35348d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
35448d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
35548d71395SPhilipp Zabel  *
35648d71395SPhilipp Zabel  * Optional variant of reset_control_bulk_get_exclusive_released(). If the
35748d71395SPhilipp Zabel  * requested reset is not specified in the device tree, this function returns 0
35848d71395SPhilipp Zabel  * instead of an error and missing rtsc is set to NULL.
35948d71395SPhilipp Zabel  *
36048d71395SPhilipp Zabel  * See reset_control_bulk_get_exclusive_released() for more information.
36148d71395SPhilipp Zabel  */
36248d71395SPhilipp Zabel static inline int __must_check
reset_control_bulk_get_optional_exclusive_released(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)36348d71395SPhilipp Zabel reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
36448d71395SPhilipp Zabel 						   struct reset_control_bulk_data *rstcs)
36548d71395SPhilipp Zabel {
366dad35f7dSPhilipp Zabel 	return __reset_control_bulk_get(dev, num_rstcs, rstcs,
367dad35f7dSPhilipp Zabel 					RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
36848d71395SPhilipp Zabel }
36948d71395SPhilipp Zabel 
37048d71395SPhilipp Zabel /**
3710b52297fSHans de Goede  * reset_control_get_shared - Lookup and obtain a shared reference to a
3720b52297fSHans de Goede  *                            reset controller.
3730b52297fSHans de Goede  * @dev: device to be reset by the controller
3740b52297fSHans de Goede  * @id: reset line name
3750b52297fSHans de Goede  *
3760b52297fSHans de Goede  * Returns a struct reset_control or IS_ERR() condition containing errno.
3770b52297fSHans de Goede  * This function is intended for use with reset-controls which are shared
37812c62b9dSGeert Uytterhoeven  * between hardware blocks.
3790b52297fSHans de Goede  *
3800b52297fSHans de Goede  * When a reset-control is shared, the behavior of reset_control_assert /
3810b52297fSHans de Goede  * deassert is changed, the reset-core will keep track of a deassert_count
3820b52297fSHans de Goede  * and only (re-)assert the reset after reset_control_assert has been called
3830b52297fSHans de Goede  * as many times as reset_control_deassert was called. Also see the remark
3840b52297fSHans de Goede  * about shared reset-controls in the reset_control_assert docs.
3850b52297fSHans de Goede  *
3860b52297fSHans de Goede  * Calling reset_control_assert without first calling reset_control_deassert
3870b52297fSHans de Goede  * is not allowed on a shared reset control. Calling reset_control_reset is
3880b52297fSHans de Goede  * also not allowed on a shared reset control.
3890b52297fSHans de Goede  *
3900b52297fSHans de Goede  * Use of id names is optional.
3910b52297fSHans de Goede  */
reset_control_get_shared(struct device * dev,const char * id)3920b52297fSHans de Goede static inline struct reset_control *reset_control_get_shared(
3930b52297fSHans de Goede 					struct device *dev, const char *id)
3940b52297fSHans de Goede {
395dad35f7dSPhilipp Zabel 	return __reset_control_get(dev, id, 0, RESET_CONTROL_SHARED);
3960b52297fSHans de Goede }
3970b52297fSHans de Goede 
398c2ffa00aSPhilipp Zabel /**
39948d71395SPhilipp Zabel  * reset_control_bulk_get_shared - Lookup and obtain shared references to
40048d71395SPhilipp Zabel  *                                 multiple reset controllers.
40148d71395SPhilipp Zabel  * @dev: device to be reset by the controller
40248d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
40348d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
40448d71395SPhilipp Zabel  *
40548d71395SPhilipp Zabel  * Fills the rstcs array with pointers to shared reset controls and
40648d71395SPhilipp Zabel  * returns 0, or an IS_ERR() condition containing errno.
40748d71395SPhilipp Zabel  */
40848d71395SPhilipp Zabel static inline int __must_check
reset_control_bulk_get_shared(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)40948d71395SPhilipp Zabel reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
41048d71395SPhilipp Zabel 			      struct reset_control_bulk_data *rstcs)
41148d71395SPhilipp Zabel {
412dad35f7dSPhilipp Zabel 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_SHARED);
41348d71395SPhilipp Zabel }
41448d71395SPhilipp Zabel 
41548d71395SPhilipp Zabel /**
416c2ffa00aSPhilipp Zabel  * reset_control_get_optional_exclusive - optional reset_control_get_exclusive()
417c2ffa00aSPhilipp Zabel  * @dev: device to be reset by the controller
418c2ffa00aSPhilipp Zabel  * @id: reset line name
419c2ffa00aSPhilipp Zabel  *
420c2ffa00aSPhilipp Zabel  * Optional variant of reset_control_get_exclusive(). If the requested reset
421c2ffa00aSPhilipp Zabel  * is not specified in the device tree, this function returns NULL instead of
422c2ffa00aSPhilipp Zabel  * an error.
423c2ffa00aSPhilipp Zabel  *
424c2ffa00aSPhilipp Zabel  * See reset_control_get_exclusive() for more information.
425c2ffa00aSPhilipp Zabel  */
reset_control_get_optional_exclusive(struct device * dev,const char * id)426a53e35dbSLee Jones static inline struct reset_control *reset_control_get_optional_exclusive(
4273c35f6edSLee Jones 					struct device *dev, const char *id)
4283c35f6edSLee Jones {
429dad35f7dSPhilipp Zabel 	return __reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
4303c35f6edSLee Jones }
4313c35f6edSLee Jones 
432c2ffa00aSPhilipp Zabel /**
43348d71395SPhilipp Zabel  * reset_control_bulk_get_optional_exclusive - optional
43448d71395SPhilipp Zabel  *                                             reset_control_bulk_get_exclusive()
43548d71395SPhilipp Zabel  * @dev: device to be reset by the controller
43648d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
43748d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
43848d71395SPhilipp Zabel  *
43948d71395SPhilipp Zabel  * Optional variant of reset_control_bulk_get_exclusive(). If any of the
44048d71395SPhilipp Zabel  * requested resets are not specified in the device tree, this function sets
44148d71395SPhilipp Zabel  * them to NULL instead of returning an error.
44248d71395SPhilipp Zabel  *
44348d71395SPhilipp Zabel  * See reset_control_bulk_get_exclusive() for more information.
44448d71395SPhilipp Zabel  */
44548d71395SPhilipp Zabel static inline int __must_check
reset_control_bulk_get_optional_exclusive(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)44648d71395SPhilipp Zabel reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
44748d71395SPhilipp Zabel 					  struct reset_control_bulk_data *rstcs)
44848d71395SPhilipp Zabel {
449dad35f7dSPhilipp Zabel 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
45048d71395SPhilipp Zabel }
45148d71395SPhilipp Zabel 
45248d71395SPhilipp Zabel /**
453c2ffa00aSPhilipp Zabel  * reset_control_get_optional_shared - optional reset_control_get_shared()
454c2ffa00aSPhilipp Zabel  * @dev: device to be reset by the controller
455c2ffa00aSPhilipp Zabel  * @id: reset line name
456c2ffa00aSPhilipp Zabel  *
457c2ffa00aSPhilipp Zabel  * Optional variant of reset_control_get_shared(). If the requested reset
458c2ffa00aSPhilipp Zabel  * is not specified in the device tree, this function returns NULL instead of
459c2ffa00aSPhilipp Zabel  * an error.
460c2ffa00aSPhilipp Zabel  *
461c2ffa00aSPhilipp Zabel  * See reset_control_get_shared() for more information.
462c2ffa00aSPhilipp Zabel  */
reset_control_get_optional_shared(struct device * dev,const char * id)463c33d61a0SLee Jones static inline struct reset_control *reset_control_get_optional_shared(
464c33d61a0SLee Jones 					struct device *dev, const char *id)
465c33d61a0SLee Jones {
466dad35f7dSPhilipp Zabel 	return __reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
467c33d61a0SLee Jones }
468c33d61a0SLee Jones 
4690b52297fSHans de Goede /**
47048d71395SPhilipp Zabel  * reset_control_bulk_get_optional_shared - optional
47148d71395SPhilipp Zabel  *                                             reset_control_bulk_get_shared()
47248d71395SPhilipp Zabel  * @dev: device to be reset by the controller
47348d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
47448d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
47548d71395SPhilipp Zabel  *
47648d71395SPhilipp Zabel  * Optional variant of reset_control_bulk_get_shared(). If the requested resets
47748d71395SPhilipp Zabel  * are not specified in the device tree, this function sets them to NULL
47848d71395SPhilipp Zabel  * instead of returning an error.
47948d71395SPhilipp Zabel  *
48048d71395SPhilipp Zabel  * See reset_control_bulk_get_shared() for more information.
48148d71395SPhilipp Zabel  */
48248d71395SPhilipp Zabel static inline int __must_check
reset_control_bulk_get_optional_shared(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)48348d71395SPhilipp Zabel reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
48448d71395SPhilipp Zabel 				       struct reset_control_bulk_data *rstcs)
48548d71395SPhilipp Zabel {
486dad35f7dSPhilipp Zabel 	return __reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_SHARED);
48748d71395SPhilipp Zabel }
48848d71395SPhilipp Zabel 
48948d71395SPhilipp Zabel /**
490a53e35dbSLee Jones  * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
491a53e35dbSLee Jones  *                                  to a reset controller.
4926c96f05cSHans de Goede  * @node: device to be reset by the controller
4936c96f05cSHans de Goede  * @id: reset line name
4946c96f05cSHans de Goede  *
4956c96f05cSHans de Goede  * Returns a struct reset_control or IS_ERR() condition containing errno.
4966c96f05cSHans de Goede  *
4976c96f05cSHans de Goede  * Use of id names is optional.
4986c96f05cSHans de Goede  */
of_reset_control_get_exclusive(struct device_node * node,const char * id)499a53e35dbSLee Jones static inline struct reset_control *of_reset_control_get_exclusive(
5006c96f05cSHans de Goede 				struct device_node *node, const char *id)
5016c96f05cSHans de Goede {
502dad35f7dSPhilipp Zabel 	return __of_reset_control_get(node, id, 0, RESET_CONTROL_EXCLUSIVE);
5036c96f05cSHans de Goede }
5046c96f05cSHans de Goede 
5056c96f05cSHans de Goede /**
506c4f5b30dSBiju Das  * of_reset_control_get_optional_exclusive - Lookup and obtain an optional exclusive
507c4f5b30dSBiju Das  *                                           reference to a reset controller.
508c4f5b30dSBiju Das  * @node: device to be reset by the controller
509c4f5b30dSBiju Das  * @id: reset line name
510c4f5b30dSBiju Das  *
511c4f5b30dSBiju Das  * Optional variant of of_reset_control_get_exclusive(). If the requested reset
512c4f5b30dSBiju Das  * is not specified in the device tree, this function returns NULL instead of
513c4f5b30dSBiju Das  * an error.
514c4f5b30dSBiju Das  *
515c4f5b30dSBiju Das  * Returns a struct reset_control or IS_ERR() condition containing errno.
516c4f5b30dSBiju Das  *
517c4f5b30dSBiju Das  * Use of id names is optional.
518c4f5b30dSBiju Das  */
of_reset_control_get_optional_exclusive(struct device_node * node,const char * id)519c4f5b30dSBiju Das static inline struct reset_control *of_reset_control_get_optional_exclusive(
520c4f5b30dSBiju Das 				struct device_node *node, const char *id)
521c4f5b30dSBiju Das {
522dad35f7dSPhilipp Zabel 	return __of_reset_control_get(node, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
523c4f5b30dSBiju Das }
524c4f5b30dSBiju Das 
525c4f5b30dSBiju Das /**
52612c62b9dSGeert Uytterhoeven  * of_reset_control_get_shared - Lookup and obtain a shared reference
52740faee8eSLee Jones  *                               to a reset controller.
52840faee8eSLee Jones  * @node: device to be reset by the controller
52940faee8eSLee Jones  * @id: reset line name
53040faee8eSLee Jones  *
53140faee8eSLee Jones  * When a reset-control is shared, the behavior of reset_control_assert /
53240faee8eSLee Jones  * deassert is changed, the reset-core will keep track of a deassert_count
53340faee8eSLee Jones  * and only (re-)assert the reset after reset_control_assert has been called
53440faee8eSLee Jones  * as many times as reset_control_deassert was called. Also see the remark
53540faee8eSLee Jones  * about shared reset-controls in the reset_control_assert docs.
53640faee8eSLee Jones  *
53740faee8eSLee Jones  * Calling reset_control_assert without first calling reset_control_deassert
53840faee8eSLee Jones  * is not allowed on a shared reset control. Calling reset_control_reset is
53940faee8eSLee Jones  * also not allowed on a shared reset control.
54040faee8eSLee Jones  * Returns a struct reset_control or IS_ERR() condition containing errno.
54140faee8eSLee Jones  *
54240faee8eSLee Jones  * Use of id names is optional.
54340faee8eSLee Jones  */
of_reset_control_get_shared(struct device_node * node,const char * id)54440faee8eSLee Jones static inline struct reset_control *of_reset_control_get_shared(
54540faee8eSLee Jones 				struct device_node *node, const char *id)
54640faee8eSLee Jones {
547dad35f7dSPhilipp Zabel 	return __of_reset_control_get(node, id, 0, RESET_CONTROL_SHARED);
54840faee8eSLee Jones }
54940faee8eSLee Jones 
55040faee8eSLee Jones /**
551a53e35dbSLee Jones  * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
552a53e35dbSLee Jones  *                                           reference to a reset controller
553a53e35dbSLee Jones  *                                           by index.
5546c96f05cSHans de Goede  * @node: device to be reset by the controller
5556c96f05cSHans de Goede  * @index: index of the reset controller
5566c96f05cSHans de Goede  *
5576c96f05cSHans de Goede  * This is to be used to perform a list of resets for a device or power domain
5586c96f05cSHans de Goede  * in whatever order. Returns a struct reset_control or IS_ERR() condition
5596c96f05cSHans de Goede  * containing errno.
5606c96f05cSHans de Goede  */
of_reset_control_get_exclusive_by_index(struct device_node * node,int index)561a53e35dbSLee Jones static inline struct reset_control *of_reset_control_get_exclusive_by_index(
5626c96f05cSHans de Goede 					struct device_node *node, int index)
5636c96f05cSHans de Goede {
564dad35f7dSPhilipp Zabel 	return __of_reset_control_get(node, NULL, index, RESET_CONTROL_EXCLUSIVE);
5656c96f05cSHans de Goede }
5666c96f05cSHans de Goede 
5676c96f05cSHans de Goede /**
56812c62b9dSGeert Uytterhoeven  * of_reset_control_get_shared_by_index - Lookup and obtain a shared
56940faee8eSLee Jones  *                                        reference to a reset controller
57040faee8eSLee Jones  *                                        by index.
57140faee8eSLee Jones  * @node: device to be reset by the controller
57240faee8eSLee Jones  * @index: index of the reset controller
57340faee8eSLee Jones  *
57440faee8eSLee Jones  * When a reset-control is shared, the behavior of reset_control_assert /
57540faee8eSLee Jones  * deassert is changed, the reset-core will keep track of a deassert_count
57640faee8eSLee Jones  * and only (re-)assert the reset after reset_control_assert has been called
57740faee8eSLee Jones  * as many times as reset_control_deassert was called. Also see the remark
57840faee8eSLee Jones  * about shared reset-controls in the reset_control_assert docs.
57940faee8eSLee Jones  *
58040faee8eSLee Jones  * Calling reset_control_assert without first calling reset_control_deassert
58140faee8eSLee Jones  * is not allowed on a shared reset control. Calling reset_control_reset is
58240faee8eSLee Jones  * also not allowed on a shared reset control.
58340faee8eSLee Jones  * Returns a struct reset_control or IS_ERR() condition containing errno.
58440faee8eSLee Jones  *
58540faee8eSLee Jones  * This is to be used to perform a list of resets for a device or power domain
58640faee8eSLee Jones  * in whatever order. Returns a struct reset_control or IS_ERR() condition
58740faee8eSLee Jones  * containing errno.
58840faee8eSLee Jones  */
of_reset_control_get_shared_by_index(struct device_node * node,int index)58940faee8eSLee Jones static inline struct reset_control *of_reset_control_get_shared_by_index(
59040faee8eSLee Jones 					struct device_node *node, int index)
59140faee8eSLee Jones {
592dad35f7dSPhilipp Zabel 	return __of_reset_control_get(node, NULL, index, RESET_CONTROL_SHARED);
59340faee8eSLee Jones }
59440faee8eSLee Jones 
59540faee8eSLee Jones /**
596a53e35dbSLee Jones  * devm_reset_control_get_exclusive - resource managed
597a53e35dbSLee Jones  *                                    reset_control_get_exclusive()
5986c96f05cSHans de Goede  * @dev: device to be reset by the controller
5996c96f05cSHans de Goede  * @id: reset line name
6006c96f05cSHans de Goede  *
601a53e35dbSLee Jones  * Managed reset_control_get_exclusive(). For reset controllers returned
602a53e35dbSLee Jones  * from this function, reset_control_put() is called automatically on driver
603a53e35dbSLee Jones  * detach.
604a53e35dbSLee Jones  *
605a53e35dbSLee Jones  * See reset_control_get_exclusive() for more information.
6066c96f05cSHans de Goede  */
607a53e35dbSLee Jones static inline struct reset_control *
devm_reset_control_get_exclusive(struct device * dev,const char * id)608a53e35dbSLee Jones __must_check devm_reset_control_get_exclusive(struct device *dev,
609a53e35dbSLee Jones 					      const char *id)
6106c96f05cSHans de Goede {
611dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE);
612c84b0326SPhilipp Zabel }
613c84b0326SPhilipp Zabel 
614c84b0326SPhilipp Zabel /**
615*d872bed8SPhilipp Zabel  * devm_reset_control_get_exclusive_deasserted - resource managed
616*d872bed8SPhilipp Zabel  *                                    reset_control_get_exclusive() +
617*d872bed8SPhilipp Zabel  *                                    reset_control_deassert()
618*d872bed8SPhilipp Zabel  * @dev: device to be reset by the controller
619*d872bed8SPhilipp Zabel  * @id: reset line name
620*d872bed8SPhilipp Zabel  *
621*d872bed8SPhilipp Zabel  * Managed reset_control_get_exclusive() + reset_control_deassert(). For reset
622*d872bed8SPhilipp Zabel  * controllers returned from this function, reset_control_assert() +
623*d872bed8SPhilipp Zabel  * reset_control_put() is called automatically on driver detach.
624*d872bed8SPhilipp Zabel  *
625*d872bed8SPhilipp Zabel  * See reset_control_get_exclusive() for more information.
626*d872bed8SPhilipp Zabel  */
627*d872bed8SPhilipp Zabel static inline struct reset_control * __must_check
devm_reset_control_get_exclusive_deasserted(struct device * dev,const char * id)628*d872bed8SPhilipp Zabel devm_reset_control_get_exclusive_deasserted(struct device *dev, const char *id)
629*d872bed8SPhilipp Zabel {
630*d872bed8SPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_DEASSERTED);
631*d872bed8SPhilipp Zabel }
632*d872bed8SPhilipp Zabel 
633*d872bed8SPhilipp Zabel /**
63448d71395SPhilipp Zabel  * devm_reset_control_bulk_get_exclusive - resource managed
63548d71395SPhilipp Zabel  *                                         reset_control_bulk_get_exclusive()
63648d71395SPhilipp Zabel  * @dev: device to be reset by the controller
63748d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
63848d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
63948d71395SPhilipp Zabel  *
64048d71395SPhilipp Zabel  * Managed reset_control_bulk_get_exclusive(). For reset controllers returned
64148d71395SPhilipp Zabel  * from this function, reset_control_put() is called automatically on driver
64248d71395SPhilipp Zabel  * detach.
64348d71395SPhilipp Zabel  *
64448d71395SPhilipp Zabel  * See reset_control_bulk_get_exclusive() for more information.
64548d71395SPhilipp Zabel  */
64648d71395SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_exclusive(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)64748d71395SPhilipp Zabel devm_reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
64848d71395SPhilipp Zabel 				      struct reset_control_bulk_data *rstcs)
64948d71395SPhilipp Zabel {
650dad35f7dSPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
651dad35f7dSPhilipp Zabel 					     RESET_CONTROL_EXCLUSIVE);
65248d71395SPhilipp Zabel }
65348d71395SPhilipp Zabel 
65448d71395SPhilipp Zabel /**
655c84b0326SPhilipp Zabel  * devm_reset_control_get_exclusive_released - resource managed
656c84b0326SPhilipp Zabel  *                                             reset_control_get_exclusive_released()
657c84b0326SPhilipp Zabel  * @dev: device to be reset by the controller
658c84b0326SPhilipp Zabel  * @id: reset line name
659c84b0326SPhilipp Zabel  *
660c84b0326SPhilipp Zabel  * Managed reset_control_get_exclusive_released(). For reset controllers
661c84b0326SPhilipp Zabel  * returned from this function, reset_control_put() is called automatically on
662c84b0326SPhilipp Zabel  * driver detach.
663c84b0326SPhilipp Zabel  *
664c84b0326SPhilipp Zabel  * See reset_control_get_exclusive_released() for more information.
665c84b0326SPhilipp Zabel  */
666c84b0326SPhilipp Zabel static inline struct reset_control *
devm_reset_control_get_exclusive_released(struct device * dev,const char * id)667c84b0326SPhilipp Zabel __must_check devm_reset_control_get_exclusive_released(struct device *dev,
668c84b0326SPhilipp Zabel 						       const char *id)
669c84b0326SPhilipp Zabel {
670dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_EXCLUSIVE_RELEASED);
671b424080aSPhilipp Zabel }
672b424080aSPhilipp Zabel 
6730b52297fSHans de Goede /**
67448d71395SPhilipp Zabel  * devm_reset_control_bulk_get_exclusive_released - resource managed
67548d71395SPhilipp Zabel  *                                                  reset_control_bulk_get_exclusive_released()
67648d71395SPhilipp Zabel  * @dev: device to be reset by the controller
67748d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
67848d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
67948d71395SPhilipp Zabel  *
68048d71395SPhilipp Zabel  * Managed reset_control_bulk_get_exclusive_released(). For reset controllers
68148d71395SPhilipp Zabel  * returned from this function, reset_control_put() is called automatically on
68248d71395SPhilipp Zabel  * driver detach.
68348d71395SPhilipp Zabel  *
68448d71395SPhilipp Zabel  * See reset_control_bulk_get_exclusive_released() for more information.
68548d71395SPhilipp Zabel  */
68648d71395SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_exclusive_released(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)68748d71395SPhilipp Zabel devm_reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
68848d71395SPhilipp Zabel 					       struct reset_control_bulk_data *rstcs)
68948d71395SPhilipp Zabel {
690dad35f7dSPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
691dad35f7dSPhilipp Zabel 					     RESET_CONTROL_EXCLUSIVE_RELEASED);
69248d71395SPhilipp Zabel }
69348d71395SPhilipp Zabel 
69448d71395SPhilipp Zabel /**
695d1765575SDmitry Osipenko  * devm_reset_control_get_optional_exclusive_released - resource managed
696d1765575SDmitry Osipenko  *                                                      reset_control_get_optional_exclusive_released()
697d1765575SDmitry Osipenko  * @dev: device to be reset by the controller
698d1765575SDmitry Osipenko  * @id: reset line name
699d1765575SDmitry Osipenko  *
700d1765575SDmitry Osipenko  * Managed-and-optional variant of reset_control_get_exclusive_released(). For
701d1765575SDmitry Osipenko  * reset controllers returned from this function, reset_control_put() is called
702d1765575SDmitry Osipenko  * automatically on driver detach.
703d1765575SDmitry Osipenko  *
704d1765575SDmitry Osipenko  * See reset_control_get_exclusive_released() for more information.
705d1765575SDmitry Osipenko  */
706d1765575SDmitry Osipenko static inline struct reset_control *
devm_reset_control_get_optional_exclusive_released(struct device * dev,const char * id)707d1765575SDmitry Osipenko __must_check devm_reset_control_get_optional_exclusive_released(struct device *dev,
708d1765575SDmitry Osipenko 								const char *id)
709d1765575SDmitry Osipenko {
710dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
711d1765575SDmitry Osipenko }
712d1765575SDmitry Osipenko 
713d1765575SDmitry Osipenko /**
71448d71395SPhilipp Zabel  * devm_reset_control_bulk_get_optional_exclusive_released - resource managed
71548d71395SPhilipp Zabel  *                                                           reset_control_bulk_optional_get_exclusive_released()
71648d71395SPhilipp Zabel  * @dev: device to be reset by the controller
71748d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
71848d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
71948d71395SPhilipp Zabel  *
72048d71395SPhilipp Zabel  * Managed reset_control_bulk_optional_get_exclusive_released(). For reset
72148d71395SPhilipp Zabel  * controllers returned from this function, reset_control_put() is called
72248d71395SPhilipp Zabel  * automatically on driver detach.
72348d71395SPhilipp Zabel  *
72448d71395SPhilipp Zabel  * See reset_control_bulk_optional_get_exclusive_released() for more information.
72548d71395SPhilipp Zabel  */
72648d71395SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_optional_exclusive_released(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)72748d71395SPhilipp Zabel devm_reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
72848d71395SPhilipp Zabel 							struct reset_control_bulk_data *rstcs)
72948d71395SPhilipp Zabel {
730dad35f7dSPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
731dad35f7dSPhilipp Zabel 					     RESET_CONTROL_OPTIONAL_EXCLUSIVE_RELEASED);
73248d71395SPhilipp Zabel }
73348d71395SPhilipp Zabel 
73448d71395SPhilipp Zabel /**
7350b52297fSHans de Goede  * devm_reset_control_get_shared - resource managed reset_control_get_shared()
7360b52297fSHans de Goede  * @dev: device to be reset by the controller
7370b52297fSHans de Goede  * @id: reset line name
7380b52297fSHans de Goede  *
7390b52297fSHans de Goede  * Managed reset_control_get_shared(). For reset controllers returned from
7400b52297fSHans de Goede  * this function, reset_control_put() is called automatically on driver detach.
7410b52297fSHans de Goede  * See reset_control_get_shared() for more information.
7420b52297fSHans de Goede  */
devm_reset_control_get_shared(struct device * dev,const char * id)7430b52297fSHans de Goede static inline struct reset_control *devm_reset_control_get_shared(
7440b52297fSHans de Goede 					struct device *dev, const char *id)
7450b52297fSHans de Goede {
746dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_SHARED);
7470b52297fSHans de Goede }
7480b52297fSHans de Goede 
749c2ffa00aSPhilipp Zabel /**
750*d872bed8SPhilipp Zabel  * devm_reset_control_get_shared_deasserted - resource managed
751*d872bed8SPhilipp Zabel  *                                            reset_control_get_shared() +
752*d872bed8SPhilipp Zabel  *                                            reset_control_deassert()
753*d872bed8SPhilipp Zabel  * @dev: device to be reset by the controller
754*d872bed8SPhilipp Zabel  * @id: reset line name
755*d872bed8SPhilipp Zabel  *
756*d872bed8SPhilipp Zabel  * Managed reset_control_get_shared() + reset_control_deassert(). For reset
757*d872bed8SPhilipp Zabel  * controllers returned from this function, reset_control_assert() +
758*d872bed8SPhilipp Zabel  * reset_control_put() is called automatically on driver detach.
759*d872bed8SPhilipp Zabel  *
760*d872bed8SPhilipp Zabel  * See devm_reset_control_get_shared() for more information.
761*d872bed8SPhilipp Zabel  */
762*d872bed8SPhilipp Zabel static inline struct reset_control * __must_check
devm_reset_control_get_shared_deasserted(struct device * dev,const char * id)763*d872bed8SPhilipp Zabel devm_reset_control_get_shared_deasserted(struct device *dev, const char *id)
764*d872bed8SPhilipp Zabel {
765*d872bed8SPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_SHARED_DEASSERTED);
766*d872bed8SPhilipp Zabel }
767*d872bed8SPhilipp Zabel 
768*d872bed8SPhilipp Zabel /**
76948d71395SPhilipp Zabel  * devm_reset_control_bulk_get_shared - resource managed
77048d71395SPhilipp Zabel  *                                      reset_control_bulk_get_shared()
77148d71395SPhilipp Zabel  * @dev: device to be reset by the controller
77248d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
77348d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
77448d71395SPhilipp Zabel  *
77548d71395SPhilipp Zabel  * Managed reset_control_bulk_get_shared(). For reset controllers returned
77648d71395SPhilipp Zabel  * from this function, reset_control_put() is called automatically on driver
77748d71395SPhilipp Zabel  * detach.
77848d71395SPhilipp Zabel  *
77948d71395SPhilipp Zabel  * See reset_control_bulk_get_shared() for more information.
78048d71395SPhilipp Zabel  */
78148d71395SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_shared(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)78248d71395SPhilipp Zabel devm_reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
78348d71395SPhilipp Zabel 				   struct reset_control_bulk_data *rstcs)
78448d71395SPhilipp Zabel {
785dad35f7dSPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_SHARED);
78648d71395SPhilipp Zabel }
78748d71395SPhilipp Zabel 
78848d71395SPhilipp Zabel /**
789*d872bed8SPhilipp Zabel  * devm_reset_control_bulk_get_shared_deasserted - resource managed
790*d872bed8SPhilipp Zabel  *                                                 reset_control_bulk_get_shared() +
791*d872bed8SPhilipp Zabel  *                                                 reset_control_bulk_deassert()
792*d872bed8SPhilipp Zabel  * @dev: device to be reset by the controller
793*d872bed8SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
794*d872bed8SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
795*d872bed8SPhilipp Zabel  *
796*d872bed8SPhilipp Zabel  * Managed reset_control_bulk_get_shared() + reset_control_bulk_deassert(). For
797*d872bed8SPhilipp Zabel  * reset controllers returned from this function, reset_control_bulk_assert() +
798*d872bed8SPhilipp Zabel  * reset_control_bulk_put() are called automatically on driver detach.
799*d872bed8SPhilipp Zabel  *
800*d872bed8SPhilipp Zabel  * See devm_reset_control_bulk_get_shared() for more information.
801*d872bed8SPhilipp Zabel  */
802*d872bed8SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_shared_deasserted(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)803*d872bed8SPhilipp Zabel devm_reset_control_bulk_get_shared_deasserted(struct device *dev, int num_rstcs,
804*d872bed8SPhilipp Zabel 					      struct reset_control_bulk_data *rstcs)
805*d872bed8SPhilipp Zabel {
806*d872bed8SPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
807*d872bed8SPhilipp Zabel 					     RESET_CONTROL_SHARED_DEASSERTED);
808*d872bed8SPhilipp Zabel }
809*d872bed8SPhilipp Zabel 
810*d872bed8SPhilipp Zabel /**
811c2ffa00aSPhilipp Zabel  * devm_reset_control_get_optional_exclusive - resource managed
812c2ffa00aSPhilipp Zabel  *                                             reset_control_get_optional_exclusive()
813c2ffa00aSPhilipp Zabel  * @dev: device to be reset by the controller
814c2ffa00aSPhilipp Zabel  * @id: reset line name
815c2ffa00aSPhilipp Zabel  *
816c2ffa00aSPhilipp Zabel  * Managed reset_control_get_optional_exclusive(). For reset controllers
817c2ffa00aSPhilipp Zabel  * returned from this function, reset_control_put() is called automatically on
818c2ffa00aSPhilipp Zabel  * driver detach.
819c2ffa00aSPhilipp Zabel  *
820c2ffa00aSPhilipp Zabel  * See reset_control_get_optional_exclusive() for more information.
821c2ffa00aSPhilipp Zabel  */
devm_reset_control_get_optional_exclusive(struct device * dev,const char * id)822a53e35dbSLee Jones static inline struct reset_control *devm_reset_control_get_optional_exclusive(
823b424080aSPhilipp Zabel 					struct device *dev, const char *id)
824b424080aSPhilipp Zabel {
825dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
826b424080aSPhilipp Zabel }
827b424080aSPhilipp Zabel 
828c2ffa00aSPhilipp Zabel /**
829*d872bed8SPhilipp Zabel  * devm_reset_control_get_optional_exclusive_deasserted - resource managed
830*d872bed8SPhilipp Zabel  *                                                        reset_control_get_optional_exclusive() +
831*d872bed8SPhilipp Zabel  *                                                        reset_control_deassert()
832*d872bed8SPhilipp Zabel  * @dev: device to be reset by the controller
833*d872bed8SPhilipp Zabel  * @id: reset line name
834*d872bed8SPhilipp Zabel  *
835*d872bed8SPhilipp Zabel  * Managed reset_control_get_optional_exclusive() + reset_control_deassert().
836*d872bed8SPhilipp Zabel  * For reset controllers returned from this function, reset_control_assert() +
837*d872bed8SPhilipp Zabel  * reset_control_put() is called automatically on driver detach.
838*d872bed8SPhilipp Zabel  *
839*d872bed8SPhilipp Zabel  * See devm_reset_control_get_optional_exclusive() for more information.
840*d872bed8SPhilipp Zabel  */
841*d872bed8SPhilipp Zabel static inline struct reset_control *
devm_reset_control_get_optional_exclusive_deasserted(struct device * dev,const char * id)842*d872bed8SPhilipp Zabel devm_reset_control_get_optional_exclusive_deasserted(struct device *dev, const char *id)
843*d872bed8SPhilipp Zabel {
844*d872bed8SPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_EXCLUSIVE_DEASSERTED);
845*d872bed8SPhilipp Zabel }
846*d872bed8SPhilipp Zabel 
847*d872bed8SPhilipp Zabel /**
84848d71395SPhilipp Zabel  * devm_reset_control_bulk_get_optional_exclusive - resource managed
84948d71395SPhilipp Zabel  *                                                  reset_control_bulk_get_optional_exclusive()
85048d71395SPhilipp Zabel  * @dev: device to be reset by the controller
85148d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
85248d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
85348d71395SPhilipp Zabel  *
85448d71395SPhilipp Zabel  * Managed reset_control_bulk_get_optional_exclusive(). For reset controllers
85548d71395SPhilipp Zabel  * returned from this function, reset_control_put() is called automatically on
85648d71395SPhilipp Zabel  * driver detach.
85748d71395SPhilipp Zabel  *
85848d71395SPhilipp Zabel  * See reset_control_bulk_get_optional_exclusive() for more information.
85948d71395SPhilipp Zabel  */
86048d71395SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_optional_exclusive(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)86148d71395SPhilipp Zabel devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
86248d71395SPhilipp Zabel 					       struct reset_control_bulk_data *rstcs)
86348d71395SPhilipp Zabel {
864dad35f7dSPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs,
865dad35f7dSPhilipp Zabel 					     RESET_CONTROL_OPTIONAL_EXCLUSIVE);
86648d71395SPhilipp Zabel }
86748d71395SPhilipp Zabel 
86848d71395SPhilipp Zabel /**
869c2ffa00aSPhilipp Zabel  * devm_reset_control_get_optional_shared - resource managed
870c2ffa00aSPhilipp Zabel  *                                          reset_control_get_optional_shared()
871c2ffa00aSPhilipp Zabel  * @dev: device to be reset by the controller
872c2ffa00aSPhilipp Zabel  * @id: reset line name
873c2ffa00aSPhilipp Zabel  *
874c2ffa00aSPhilipp Zabel  * Managed reset_control_get_optional_shared(). For reset controllers returned
875c2ffa00aSPhilipp Zabel  * from this function, reset_control_put() is called automatically on driver
876c2ffa00aSPhilipp Zabel  * detach.
877c2ffa00aSPhilipp Zabel  *
878c2ffa00aSPhilipp Zabel  * See reset_control_get_optional_shared() for more information.
879c2ffa00aSPhilipp Zabel  */
devm_reset_control_get_optional_shared(struct device * dev,const char * id)880c33d61a0SLee Jones static inline struct reset_control *devm_reset_control_get_optional_shared(
881c33d61a0SLee Jones 					struct device *dev, const char *id)
882c33d61a0SLee Jones {
883dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED);
884c33d61a0SLee Jones }
885c33d61a0SLee Jones 
8866c96f05cSHans de Goede /**
887*d872bed8SPhilipp Zabel  * devm_reset_control_get_optional_shared_deasserted - resource managed
888*d872bed8SPhilipp Zabel  *                                                     reset_control_get_optional_shared() +
889*d872bed8SPhilipp Zabel  *                                                     reset_control_deassert()
890*d872bed8SPhilipp Zabel  * @dev: device to be reset by the controller
891*d872bed8SPhilipp Zabel  * @id: reset line name
892*d872bed8SPhilipp Zabel  *
893*d872bed8SPhilipp Zabel  * Managed reset_control_get_optional_shared() + reset_control_deassert(). For
894*d872bed8SPhilipp Zabel  * reset controllers returned from this function, reset_control_assert() +
895*d872bed8SPhilipp Zabel  * reset_control_put() is called automatically on driver detach.
896*d872bed8SPhilipp Zabel  *
897*d872bed8SPhilipp Zabel  * See devm_reset_control_get_optional_shared() for more information.
898*d872bed8SPhilipp Zabel  */
899*d872bed8SPhilipp Zabel static inline struct reset_control *
devm_reset_control_get_optional_shared_deasserted(struct device * dev,const char * id)900*d872bed8SPhilipp Zabel devm_reset_control_get_optional_shared_deasserted(struct device *dev, const char *id)
901*d872bed8SPhilipp Zabel {
902*d872bed8SPhilipp Zabel 	return __devm_reset_control_get(dev, id, 0, RESET_CONTROL_OPTIONAL_SHARED_DEASSERTED);
903*d872bed8SPhilipp Zabel }
904*d872bed8SPhilipp Zabel 
905*d872bed8SPhilipp Zabel /**
90648d71395SPhilipp Zabel  * devm_reset_control_bulk_get_optional_shared - resource managed
90748d71395SPhilipp Zabel  *                                               reset_control_bulk_get_optional_shared()
90848d71395SPhilipp Zabel  * @dev: device to be reset by the controller
90948d71395SPhilipp Zabel  * @num_rstcs: number of entries in rstcs array
91048d71395SPhilipp Zabel  * @rstcs: array of struct reset_control_bulk_data with reset line names set
91148d71395SPhilipp Zabel  *
91248d71395SPhilipp Zabel  * Managed reset_control_bulk_get_optional_shared(). For reset controllers
91348d71395SPhilipp Zabel  * returned from this function, reset_control_put() is called automatically on
91448d71395SPhilipp Zabel  * driver detach.
91548d71395SPhilipp Zabel  *
91648d71395SPhilipp Zabel  * See reset_control_bulk_get_optional_shared() for more information.
91748d71395SPhilipp Zabel  */
91848d71395SPhilipp Zabel static inline int __must_check
devm_reset_control_bulk_get_optional_shared(struct device * dev,int num_rstcs,struct reset_control_bulk_data * rstcs)91948d71395SPhilipp Zabel devm_reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
92048d71395SPhilipp Zabel 					    struct reset_control_bulk_data *rstcs)
92148d71395SPhilipp Zabel {
922dad35f7dSPhilipp Zabel 	return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, RESET_CONTROL_OPTIONAL_SHARED);
92348d71395SPhilipp Zabel }
92448d71395SPhilipp Zabel 
92548d71395SPhilipp Zabel /**
926a53e35dbSLee Jones  * devm_reset_control_get_exclusive_by_index - resource managed
927a53e35dbSLee Jones  *                                             reset_control_get_exclusive()
9286c96f05cSHans de Goede  * @dev: device to be reset by the controller
9296c96f05cSHans de Goede  * @index: index of the reset controller
9306c96f05cSHans de Goede  *
931a53e35dbSLee Jones  * Managed reset_control_get_exclusive(). For reset controllers returned from
932a53e35dbSLee Jones  * this function, reset_control_put() is called automatically on driver
933a53e35dbSLee Jones  * detach.
934a53e35dbSLee Jones  *
935a53e35dbSLee Jones  * See reset_control_get_exclusive() for more information.
9366c96f05cSHans de Goede  */
937a53e35dbSLee Jones static inline struct reset_control *
devm_reset_control_get_exclusive_by_index(struct device * dev,int index)938a53e35dbSLee Jones devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
939e3ec0a8cSHans de Goede {
940dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, NULL, index, RESET_CONTROL_EXCLUSIVE);
9410b52297fSHans de Goede }
9420b52297fSHans de Goede 
9430b52297fSHans de Goede /**
9440b52297fSHans de Goede  * devm_reset_control_get_shared_by_index - resource managed
9450b52297fSHans de Goede  *                                          reset_control_get_shared
9460b52297fSHans de Goede  * @dev: device to be reset by the controller
9470b52297fSHans de Goede  * @index: index of the reset controller
9480b52297fSHans de Goede  *
9490b52297fSHans de Goede  * Managed reset_control_get_shared(). For reset controllers returned from
9500b52297fSHans de Goede  * this function, reset_control_put() is called automatically on driver detach.
9510b52297fSHans de Goede  * See reset_control_get_shared() for more information.
9520b52297fSHans de Goede  */
9530bcc0eabSLee Jones static inline struct reset_control *
devm_reset_control_get_shared_by_index(struct device * dev,int index)9540bcc0eabSLee Jones devm_reset_control_get_shared_by_index(struct device *dev, int index)
9550b52297fSHans de Goede {
956dad35f7dSPhilipp Zabel 	return __devm_reset_control_get(dev, NULL, index, RESET_CONTROL_SHARED);
957e3ec0a8cSHans de Goede }
958e3ec0a8cSHans de Goede 
959a53e35dbSLee Jones /*
960a53e35dbSLee Jones  * TEMPORARY calls to use during transition:
961a53e35dbSLee Jones  *
962a53e35dbSLee Jones  *   of_reset_control_get() => of_reset_control_get_exclusive()
963a53e35dbSLee Jones  *
964a53e35dbSLee Jones  * These inline function calls will be removed once all consumers
965a53e35dbSLee Jones  * have been moved over to the new explicit API.
966a53e35dbSLee Jones  */
of_reset_control_get(struct device_node * node,const char * id)967a53e35dbSLee Jones static inline struct reset_control *of_reset_control_get(
968a53e35dbSLee Jones 				struct device_node *node, const char *id)
969a53e35dbSLee Jones {
970a53e35dbSLee Jones 	return of_reset_control_get_exclusive(node, id);
971a53e35dbSLee Jones }
972a53e35dbSLee Jones 
of_reset_control_get_by_index(struct device_node * node,int index)973a53e35dbSLee Jones static inline struct reset_control *of_reset_control_get_by_index(
974a53e35dbSLee Jones 				struct device_node *node, int index)
975a53e35dbSLee Jones {
976a53e35dbSLee Jones 	return of_reset_control_get_exclusive_by_index(node, index);
977a53e35dbSLee Jones }
978a53e35dbSLee Jones 
devm_reset_control_get(struct device * dev,const char * id)979a53e35dbSLee Jones static inline struct reset_control *devm_reset_control_get(
980a53e35dbSLee Jones 				struct device *dev, const char *id)
981a53e35dbSLee Jones {
982a53e35dbSLee Jones 	return devm_reset_control_get_exclusive(dev, id);
983a53e35dbSLee Jones }
984a53e35dbSLee Jones 
devm_reset_control_get_optional(struct device * dev,const char * id)985a53e35dbSLee Jones static inline struct reset_control *devm_reset_control_get_optional(
986a53e35dbSLee Jones 				struct device *dev, const char *id)
987a53e35dbSLee Jones {
988a53e35dbSLee Jones 	return devm_reset_control_get_optional_exclusive(dev, id);
989a53e35dbSLee Jones 
990a53e35dbSLee Jones }
991a53e35dbSLee Jones 
devm_reset_control_get_by_index(struct device * dev,int index)992a53e35dbSLee Jones static inline struct reset_control *devm_reset_control_get_by_index(
993a53e35dbSLee Jones 				struct device *dev, int index)
994a53e35dbSLee Jones {
995a53e35dbSLee Jones 	return devm_reset_control_get_exclusive_by_index(dev, index);
996a53e35dbSLee Jones }
99717c82e20SVivek Gautam 
99817c82e20SVivek Gautam /*
99917c82e20SVivek Gautam  * APIs to manage a list of reset controllers
100017c82e20SVivek Gautam  */
100117c82e20SVivek Gautam static inline struct reset_control *
devm_reset_control_array_get_exclusive(struct device * dev)100217c82e20SVivek Gautam devm_reset_control_array_get_exclusive(struct device *dev)
100317c82e20SVivek Gautam {
1004dad35f7dSPhilipp Zabel 	return devm_reset_control_array_get(dev, RESET_CONTROL_EXCLUSIVE);
100517c82e20SVivek Gautam }
100617c82e20SVivek Gautam 
100717c82e20SVivek Gautam static inline struct reset_control *
devm_reset_control_array_get_shared(struct device * dev)100817c82e20SVivek Gautam devm_reset_control_array_get_shared(struct device *dev)
100917c82e20SVivek Gautam {
1010dad35f7dSPhilipp Zabel 	return devm_reset_control_array_get(dev, RESET_CONTROL_SHARED);
101117c82e20SVivek Gautam }
101217c82e20SVivek Gautam 
101317c82e20SVivek Gautam static inline struct reset_control *
devm_reset_control_array_get_optional_exclusive(struct device * dev)101417c82e20SVivek Gautam devm_reset_control_array_get_optional_exclusive(struct device *dev)
101517c82e20SVivek Gautam {
1016dad35f7dSPhilipp Zabel 	return devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
101717c82e20SVivek Gautam }
101817c82e20SVivek Gautam 
101917c82e20SVivek Gautam static inline struct reset_control *
devm_reset_control_array_get_optional_shared(struct device * dev)102017c82e20SVivek Gautam devm_reset_control_array_get_optional_shared(struct device *dev)
102117c82e20SVivek Gautam {
1022dad35f7dSPhilipp Zabel 	return devm_reset_control_array_get(dev, RESET_CONTROL_OPTIONAL_SHARED);
102317c82e20SVivek Gautam }
102417c82e20SVivek Gautam 
102517c82e20SVivek Gautam static inline struct reset_control *
of_reset_control_array_get_exclusive(struct device_node * node)102617c82e20SVivek Gautam of_reset_control_array_get_exclusive(struct device_node *node)
102717c82e20SVivek Gautam {
1028dad35f7dSPhilipp Zabel 	return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE);
102917c82e20SVivek Gautam }
103017c82e20SVivek Gautam 
103117c82e20SVivek Gautam static inline struct reset_control *
of_reset_control_array_get_exclusive_released(struct device_node * node)103222815f18SThierry Reding of_reset_control_array_get_exclusive_released(struct device_node *node)
103322815f18SThierry Reding {
1034dad35f7dSPhilipp Zabel 	return of_reset_control_array_get(node, RESET_CONTROL_EXCLUSIVE_RELEASED);
103522815f18SThierry Reding }
103622815f18SThierry Reding 
103722815f18SThierry Reding static inline struct reset_control *
of_reset_control_array_get_shared(struct device_node * node)103817c82e20SVivek Gautam of_reset_control_array_get_shared(struct device_node *node)
103917c82e20SVivek Gautam {
1040dad35f7dSPhilipp Zabel 	return of_reset_control_array_get(node, RESET_CONTROL_SHARED);
104117c82e20SVivek Gautam }
104217c82e20SVivek Gautam 
104317c82e20SVivek Gautam static inline struct reset_control *
of_reset_control_array_get_optional_exclusive(struct device_node * node)104417c82e20SVivek Gautam of_reset_control_array_get_optional_exclusive(struct device_node *node)
104517c82e20SVivek Gautam {
1046dad35f7dSPhilipp Zabel 	return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_EXCLUSIVE);
104717c82e20SVivek Gautam }
104817c82e20SVivek Gautam 
104917c82e20SVivek Gautam static inline struct reset_control *
of_reset_control_array_get_optional_shared(struct device_node * node)105017c82e20SVivek Gautam of_reset_control_array_get_optional_shared(struct device_node *node)
105117c82e20SVivek Gautam {
1052dad35f7dSPhilipp Zabel 	return of_reset_control_array_get(node, RESET_CONTROL_OPTIONAL_SHARED);
105317c82e20SVivek Gautam }
105461fc4131SPhilipp Zabel #endif
1055