xref: /linux-6.15/include/linux/reset.h (revision db181ce0)
1 #ifndef _LINUX_RESET_H_
2 #define _LINUX_RESET_H_
3 
4 struct device;
5 struct device_node;
6 struct reset_control;
7 
8 #ifdef CONFIG_RESET_CONTROLLER
9 
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 
14 struct reset_control *reset_control_get(struct device *dev, const char *id);
15 void reset_control_put(struct reset_control *rstc);
16 struct reset_control *devm_reset_control_get(struct device *dev, const char *id);
17 
18 int __must_check device_reset(struct device *dev);
19 
20 static inline int device_reset_optional(struct device *dev)
21 {
22 	return device_reset(dev);
23 }
24 
25 static inline struct reset_control *reset_control_get_optional(
26 					struct device *dev, const char *id)
27 {
28 	return reset_control_get(dev, id);
29 }
30 
31 static inline struct reset_control *devm_reset_control_get_optional(
32 					struct device *dev, const char *id)
33 {
34 	return devm_reset_control_get(dev, id);
35 }
36 
37 struct reset_control *of_reset_control_get(struct device_node *node,
38 					   const char *id);
39 
40 #else
41 
42 static inline int reset_control_reset(struct reset_control *rstc)
43 {
44 	WARN_ON(1);
45 	return 0;
46 }
47 
48 static inline int reset_control_assert(struct reset_control *rstc)
49 {
50 	WARN_ON(1);
51 	return 0;
52 }
53 
54 static inline int reset_control_deassert(struct reset_control *rstc)
55 {
56 	WARN_ON(1);
57 	return 0;
58 }
59 
60 static inline void reset_control_put(struct reset_control *rstc)
61 {
62 	WARN_ON(1);
63 }
64 
65 static inline int device_reset_optional(struct device *dev)
66 {
67 	return -ENOSYS;
68 }
69 
70 static inline struct reset_control *reset_control_get_optional(
71 					struct device *dev, const char *id)
72 {
73 	return ERR_PTR(-ENOSYS);
74 }
75 
76 static inline struct reset_control *devm_reset_control_get_optional(
77 					struct device *dev, const char *id)
78 {
79 	return ERR_PTR(-ENOSYS);
80 }
81 
82 static inline struct reset_control *of_reset_control_get(
83 				struct device_node *node, const char *id)
84 {
85 	return ERR_PTR(-ENOSYS);
86 }
87 
88 #endif /* CONFIG_RESET_CONTROLLER */
89 
90 #endif
91