]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - include/linux/reset.h
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 - Lookup and obtain an exclusive reference to a
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
*__must_check
reset_control_get(
102 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);
110 static inline struct reset_control
*reset_control_get_optional(
111 struct device
*dev
, const char *id
)
113 return __of_reset_control_get(dev
? dev
->of_node
: NULL
, id
, 0, 0);
117 * reset_control_get_shared - Lookup and obtain a shared reference to a
119 * @dev: device to be reset by the controller
120 * @id: reset line name
122 * Returns a struct reset_control or IS_ERR() condition containing errno.
123 * This function is intended for use with reset-controls which are shared
124 * between hardware-blocks.
126 * When a reset-control is shared, the behavior of reset_control_assert /
127 * deassert is changed, the reset-core will keep track of a deassert_count
128 * and only (re-)assert the reset after reset_control_assert has been called
129 * as many times as reset_control_deassert was called. Also see the remark
130 * about shared reset-controls in the reset_control_assert docs.
132 * Calling reset_control_assert without first calling reset_control_deassert
133 * is not allowed on a shared reset control. Calling reset_control_reset is
134 * also not allowed on a shared reset control.
136 * Use of id names is optional.
138 static inline struct reset_control
*reset_control_get_shared(
139 struct device
*dev
, const char *id
)
141 return __of_reset_control_get(dev
? dev
->of_node
: NULL
, id
, 0, 1);
145 * of_reset_control_get - Lookup and obtain an exclusive reference to a
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(
155 struct device_node
*node
, const char *id
)
157 return __of_reset_control_get(node
, id
, 0, 0);
161 * of_reset_control_get_by_index - Lookup and obtain an exclusive reference to
162 * a reset controller by index.
163 * @node: device to be reset by the controller
164 * @index: index of the reset controller
166 * This is to be used to perform a list of resets for a device or power domain
167 * in whatever order. Returns a struct reset_control or IS_ERR() condition
170 static inline struct reset_control
*of_reset_control_get_by_index(
171 struct device_node
*node
, int index
)
173 return __of_reset_control_get(node
, NULL
, index
, 0);
177 * devm_reset_control_get - resource managed reset_control_get()
178 * @dev: device to be reset by the controller
179 * @id: reset line name
181 * Managed reset_control_get(). For reset controllers returned from this
182 * function, reset_control_put() is called automatically on driver detach.
183 * See reset_control_get() for more information.
185 static inline struct reset_control
*__must_check
devm_reset_control_get(
186 struct device
*dev
, const char *id
)
188 #ifndef CONFIG_RESET_CONTROLLER
191 return __devm_reset_control_get(dev
, id
, 0, 0);
194 static inline struct reset_control
*devm_reset_control_get_optional(
195 struct device
*dev
, const char *id
)
197 return __devm_reset_control_get(dev
, id
, 0, 0);
201 * devm_reset_control_get_by_index - resource managed reset_control_get
202 * @dev: device to be reset by the controller
203 * @index: index of the reset controller
205 * Managed reset_control_get(). For reset controllers returned from this
206 * function, reset_control_put() is called automatically on driver detach.
207 * See reset_control_get() for more information.
209 static inline struct reset_control
*devm_reset_control_get_by_index(
210 struct device
*dev
, int index
)
212 return __devm_reset_control_get(dev
, NULL
, index
, 0);
216 * devm_reset_control_get_shared - resource managed reset_control_get_shared()
217 * @dev: device to be reset by the controller
218 * @id: reset line name
220 * Managed reset_control_get_shared(). For reset controllers returned from
221 * this function, reset_control_put() is called automatically on driver detach.
222 * See reset_control_get_shared() for more information.
224 static inline struct reset_control
*devm_reset_control_get_shared(
225 struct device
*dev
, const char *id
)
227 return __devm_reset_control_get(dev
, id
, 0, 1);
231 * devm_reset_control_get_shared_by_index - resource managed
232 * reset_control_get_shared
233 * @dev: device to be reset by the controller
234 * @index: index of the reset controller
236 * Managed reset_control_get_shared(). For reset controllers returned from
237 * this function, reset_control_put() is called automatically on driver detach.
238 * See reset_control_get_shared() for more information.
240 static inline struct reset_control
*devm_reset_control_get_shared_by_index(
241 struct device
*dev
, int index
)
243 return __devm_reset_control_get(dev
, NULL
, index
, 1);