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 device_reset_optional(struct device
*dev
)
64 static inline struct reset_control
*__of_reset_control_get(
65 struct device_node
*node
,
66 const char *id
, int index
, int shared
)
68 return ERR_PTR(-EINVAL
);
71 static inline struct reset_control
*__devm_reset_control_get(
73 const char *id
, int index
, int shared
)
75 return ERR_PTR(-EINVAL
);
78 #endif /* CONFIG_RESET_CONTROLLER */
81 * reset_control_get - Lookup and obtain an exclusive reference to a
83 * @dev: device to be reset by the controller
84 * @id: reset line name
86 * Returns a struct reset_control or IS_ERR() condition containing errno.
87 * If this function is called more then once for the same reset_control it will
90 * See reset_control_get_shared for details on shared references to
93 * Use of id names is optional.
95 static inline struct reset_control
*__must_check
reset_control_get(
96 struct device
*dev
, const char *id
)
98 #ifndef CONFIG_RESET_CONTROLLER
101 return __of_reset_control_get(dev
? dev
->of_node
: NULL
, id
, 0, 0);
104 static inline struct reset_control
*reset_control_get_optional(
105 struct device
*dev
, const char *id
)
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);
139 * of_reset_control_get - Lookup and obtain an exclusive reference to a
141 * @node: device to be reset by the controller
142 * @id: reset line name
144 * Returns a struct reset_control or IS_ERR() condition containing errno.
146 * Use of id names is optional.
148 static inline struct reset_control
*of_reset_control_get(
149 struct device_node
*node
, const char *id
)
151 return __of_reset_control_get(node
, id
, 0, 0);
155 * of_reset_control_get_by_index - Lookup and obtain an exclusive reference to
156 * a reset controller by index.
157 * @node: device to be reset by the controller
158 * @index: index of the reset controller
160 * This is to be used to perform a list of resets for a device or power domain
161 * in whatever order. Returns a struct reset_control or IS_ERR() condition
164 static inline struct reset_control
*of_reset_control_get_by_index(
165 struct device_node
*node
, int index
)
167 return __of_reset_control_get(node
, NULL
, index
, 0);
171 * devm_reset_control_get - resource managed reset_control_get()
172 * @dev: device to be reset by the controller
173 * @id: reset line name
175 * Managed reset_control_get(). For reset controllers returned from this
176 * function, reset_control_put() is called automatically on driver detach.
177 * See reset_control_get() for more information.
179 static inline struct reset_control
*__must_check
devm_reset_control_get(
180 struct device
*dev
, const char *id
)
182 #ifndef CONFIG_RESET_CONTROLLER
185 return __devm_reset_control_get(dev
, id
, 0, 0);
188 static inline struct reset_control
*devm_reset_control_get_optional(
189 struct device
*dev
, const char *id
)
191 return __devm_reset_control_get(dev
, id
, 0, 0);
195 * devm_reset_control_get_by_index - resource managed reset_control_get
196 * @dev: device to be reset by the controller
197 * @index: index of the reset controller
199 * Managed reset_control_get(). For reset controllers returned from this
200 * function, reset_control_put() is called automatically on driver detach.
201 * See reset_control_get() for more information.
203 static inline struct reset_control
*devm_reset_control_get_by_index(
204 struct device
*dev
, int index
)
206 return __devm_reset_control_get(dev
, NULL
, index
, 0);
210 * devm_reset_control_get_shared - resource managed reset_control_get_shared()
211 * @dev: device to be reset by the controller
212 * @id: reset line name
214 * Managed reset_control_get_shared(). For reset controllers returned from
215 * this function, reset_control_put() is called automatically on driver detach.
216 * See reset_control_get_shared() for more information.
218 static inline struct reset_control
*devm_reset_control_get_shared(
219 struct device
*dev
, const char *id
)
221 return __devm_reset_control_get(dev
, id
, 0, 1);
225 * devm_reset_control_get_shared_by_index - resource managed
226 * reset_control_get_shared
227 * @dev: device to be reset by the controller
228 * @index: index of the reset controller
230 * Managed reset_control_get_shared(). For reset controllers returned from
231 * this function, reset_control_put() is called automatically on driver detach.
232 * See reset_control_get_shared() for more information.
234 static inline struct reset_control
*devm_reset_control_get_shared_by_index(
235 struct device
*dev
, int index
)
237 return __devm_reset_control_get(dev
, NULL
, index
, 1);
This page took 0.035374 seconds and 6 git commands to generate.