fd69240907c83c13cd35c361e900b41410f54755
1 #ifndef _LINUX_RESET_H_
2 #define _LINUX_RESET_H_
4 #include <linux/device.h>
8 #ifdef CONFIG_RESET_CONTROLLER
10 int reset_control_reset(struct reset_control
*rstc
);
11 int reset_control_assert(struct reset_control
*rstc
);
12 int reset_control_deassert(struct reset_control
*rstc
);
13 int reset_control_status(struct reset_control
*rstc
);
15 struct reset_control
*__of_reset_control_get(struct device_node
*node
,
16 const char *id
, int index
, int shared
);
17 void reset_control_put(struct reset_control
*rstc
);
18 struct reset_control
*__devm_reset_control_get(struct device
*dev
,
19 const char *id
, int index
, int shared
);
21 int __must_check
device_reset(struct device
*dev
);
23 static inline int device_reset_optional(struct device
*dev
)
25 return device_reset(dev
);
30 static inline int reset_control_reset(struct reset_control
*rstc
)
36 static inline int reset_control_assert(struct reset_control
*rstc
)
42 static inline int reset_control_deassert(struct reset_control
*rstc
)
48 static inline int reset_control_status(struct reset_control
*rstc
)
54 static inline void reset_control_put(struct reset_control
*rstc
)
59 static inline int __must_check
device_reset(struct device
*dev
)
65 static inline int device_reset_optional(struct device
*dev
)
70 static inline struct reset_control
*__of_reset_control_get(
71 struct device_node
*node
,
72 const char *id
, int index
, int shared
)
74 return ERR_PTR(-EINVAL
);
77 static inline struct reset_control
*__devm_reset_control_get(
79 const char *id
, int index
, int shared
)
81 return ERR_PTR(-EINVAL
);
84 #endif /* CONFIG_RESET_CONTROLLER */
87 * reset_control_get_exclusive - Lookup and obtain an exclusive reference
88 * to a reset controller.
89 * @dev: device to be reset by the controller
90 * @id: reset line name
92 * Returns a struct reset_control or IS_ERR() condition containing errno.
93 * If this function is called more then once for the same reset_control it will
96 * See reset_control_get_shared for details on shared references to
99 * Use of id names is optional.
101 static inline struct reset_control
*
102 __must_check
reset_control_get_exclusive(struct device
*dev
, const char *id
)
104 #ifndef CONFIG_RESET_CONTROLLER
107 return __of_reset_control_get(dev
? dev
->of_node
: NULL
, id
, 0, 0);
111 * reset_control_get_shared - Lookup and obtain a shared reference to a
113 * @dev: device to be reset by the controller
114 * @id: reset line name
116 * Returns a struct reset_control or IS_ERR() condition containing errno.
117 * This function is intended for use with reset-controls which are shared
118 * between hardware-blocks.
120 * When a reset-control is shared, the behavior of reset_control_assert /
121 * deassert is changed, the reset-core will keep track of a deassert_count
122 * and only (re-)assert the reset after reset_control_assert has been called
123 * as many times as reset_control_deassert was called. Also see the remark
124 * about shared reset-controls in the reset_control_assert docs.
126 * Calling reset_control_assert without first calling reset_control_deassert
127 * is not allowed on a shared reset control. Calling reset_control_reset is
128 * also not allowed on a shared reset control.
130 * Use of id names is optional.
132 static inline struct reset_control
*reset_control_get_shared(
133 struct device
*dev
, const char *id
)
135 return __of_reset_control_get(dev
? dev
->of_node
: NULL
, id
, 0, 1);
138 static inline struct reset_control
*reset_control_get_optional_exclusive(
139 struct device
*dev
, const char *id
)
141 return __of_reset_control_get(dev
? dev
->of_node
: NULL
, id
, 0, 0);
145 * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
146 * to a reset controller.
147 * @node: device to be reset by the controller
148 * @id: reset line name
150 * Returns a struct reset_control or IS_ERR() condition containing errno.
152 * Use of id names is optional.
154 static inline struct reset_control
*of_reset_control_get_exclusive(
155 struct device_node
*node
, const char *id
)
157 return __of_reset_control_get(node
, id
, 0, 0);
161 * of_reset_control_get_shared - Lookup and obtain an shared reference
162 * to a reset controller.
163 * @node: device to be reset by the controller
164 * @id: reset line name
166 * When a reset-control is shared, the behavior of reset_control_assert /
167 * deassert is changed, the reset-core will keep track of a deassert_count
168 * and only (re-)assert the reset after reset_control_assert has been called
169 * as many times as reset_control_deassert was called. Also see the remark
170 * about shared reset-controls in the reset_control_assert docs.
172 * Calling reset_control_assert without first calling reset_control_deassert
173 * is not allowed on a shared reset control. Calling reset_control_reset is
174 * also not allowed on a shared reset control.
175 * Returns a struct reset_control or IS_ERR() condition containing errno.
177 * Use of id names is optional.
179 static inline struct reset_control
*of_reset_control_get_shared(
180 struct device_node
*node
, const char *id
)
182 return __of_reset_control_get(node
, id
, 0, 1);
186 * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
187 * reference to a reset controller
189 * @node: device to be reset by the controller
190 * @index: index of the reset controller
192 * This is to be used to perform a list of resets for a device or power domain
193 * in whatever order. Returns a struct reset_control or IS_ERR() condition
196 static inline struct reset_control
*of_reset_control_get_exclusive_by_index(
197 struct device_node
*node
, int index
)
199 return __of_reset_control_get(node
, NULL
, index
, 0);
203 * of_reset_control_get_shared_by_index - Lookup and obtain an shared
204 * reference to a reset controller
206 * @node: device to be reset by the controller
207 * @index: index of the reset controller
209 * When a reset-control is shared, the behavior of reset_control_assert /
210 * deassert is changed, the reset-core will keep track of a deassert_count
211 * and only (re-)assert the reset after reset_control_assert has been called
212 * as many times as reset_control_deassert was called. Also see the remark
213 * about shared reset-controls in the reset_control_assert docs.
215 * Calling reset_control_assert without first calling reset_control_deassert
216 * is not allowed on a shared reset control. Calling reset_control_reset is
217 * also not allowed on a shared reset control.
218 * Returns a struct reset_control or IS_ERR() condition containing errno.
220 * This is to be used to perform a list of resets for a device or power domain
221 * in whatever order. Returns a struct reset_control or IS_ERR() condition
224 static inline struct reset_control
*of_reset_control_get_shared_by_index(
225 struct device_node
*node
, int index
)
227 return __of_reset_control_get(node
, NULL
, index
, 1);
231 * devm_reset_control_get_exclusive - resource managed
232 * reset_control_get_exclusive()
233 * @dev: device to be reset by the controller
234 * @id: reset line name
236 * Managed reset_control_get_exclusive(). For reset controllers returned
237 * from this function, reset_control_put() is called automatically on driver
240 * See reset_control_get_exclusive() for more information.
242 static inline struct reset_control
*
243 __must_check
devm_reset_control_get_exclusive(struct device
*dev
,
246 #ifndef CONFIG_RESET_CONTROLLER
249 return __devm_reset_control_get(dev
, id
, 0, 0);
253 * devm_reset_control_get_shared - resource managed reset_control_get_shared()
254 * @dev: device to be reset by the controller
255 * @id: reset line name
257 * Managed reset_control_get_shared(). For reset controllers returned from
258 * this function, reset_control_put() is called automatically on driver detach.
259 * See reset_control_get_shared() for more information.
261 static inline struct reset_control
*devm_reset_control_get_shared(
262 struct device
*dev
, const char *id
)
264 return __devm_reset_control_get(dev
, id
, 0, 1);
267 static inline struct reset_control
*devm_reset_control_get_optional_exclusive(
268 struct device
*dev
, const char *id
)
270 return __devm_reset_control_get(dev
, id
, 0, 0);
274 * devm_reset_control_get_exclusive_by_index - resource managed
275 * reset_control_get_exclusive()
276 * @dev: device to be reset by the controller
277 * @index: index of the reset controller
279 * Managed reset_control_get_exclusive(). For reset controllers returned from
280 * this function, reset_control_put() is called automatically on driver
283 * See reset_control_get_exclusive() for more information.
285 static inline struct reset_control
*
286 devm_reset_control_get_exclusive_by_index(struct device
*dev
, int index
)
288 return __devm_reset_control_get(dev
, NULL
, index
, 0);
292 * devm_reset_control_get_shared_by_index - resource managed
293 * reset_control_get_shared
294 * @dev: device to be reset by the controller
295 * @index: index of the reset controller
297 * Managed reset_control_get_shared(). For reset controllers returned from
298 * this function, reset_control_put() is called automatically on driver detach.
299 * See reset_control_get_shared() for more information.
301 static inline struct reset_control
*devm_reset_control_get_shared_by_index(
302 struct device
*dev
, int index
)
304 return __devm_reset_control_get(dev
, NULL
, index
, 1);
308 * TEMPORARY calls to use during transition:
310 * of_reset_control_get() => of_reset_control_get_exclusive()
312 * These inline function calls will be removed once all consumers
313 * have been moved over to the new explicit API.
315 static inline struct reset_control
*reset_control_get(
316 struct device
*dev
, const char *id
)
318 return reset_control_get_exclusive(dev
, id
);
321 static inline struct reset_control
*reset_control_get_optional(
322 struct device
*dev
, const char *id
)
324 return reset_control_get_optional_exclusive(dev
, id
);
327 static inline struct reset_control
*of_reset_control_get(
328 struct device_node
*node
, const char *id
)
330 return of_reset_control_get_exclusive(node
, id
);
333 static inline struct reset_control
*of_reset_control_get_by_index(
334 struct device_node
*node
, int index
)
336 return of_reset_control_get_exclusive_by_index(node
, index
);
339 static inline struct reset_control
*devm_reset_control_get(
340 struct device
*dev
, const char *id
)
342 return devm_reset_control_get_exclusive(dev
, id
);
345 static inline struct reset_control
*devm_reset_control_get_optional(
346 struct device
*dev
, const char *id
)
348 return devm_reset_control_get_optional_exclusive(dev
, id
);
352 static inline struct reset_control
*devm_reset_control_get_by_index(
353 struct device
*dev
, int index
)
355 return devm_reset_control_get_exclusive_by_index(dev
, index
);
This page took 0.061936 seconds and 4 git commands to generate.