Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 2 | #ifndef _LINUX_RESET_H_ |
| 3 | #define _LINUX_RESET_H_ |
| 4 | |
Masahiro Yamada | dfc1d9b | 2017-10-29 01:50:08 +0900 | [diff] [blame] | 5 | #include <linux/types.h> |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 6 | |
Masahiro Yamada | dfc1d9b | 2017-10-29 01:50:08 +0900 | [diff] [blame] | 7 | struct device; |
| 8 | struct device_node; |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 9 | struct reset_control; |
| 10 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 11 | #ifdef CONFIG_RESET_CONTROLLER |
| 12 | |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 13 | int reset_control_reset(struct reset_control *rstc); |
| 14 | int reset_control_assert(struct reset_control *rstc); |
| 15 | int reset_control_deassert(struct reset_control *rstc); |
Dinh Nguyen | 729de41 | 2014-10-10 10:21:14 -0500 | [diff] [blame] | 16 | int reset_control_status(struct reset_control *rstc); |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 17 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 18 | struct reset_control *__of_reset_control_get(struct device_node *node, |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 19 | const char *id, int index, bool shared, |
| 20 | bool optional); |
Philipp Zabel | 62e24c5 | 2016-02-05 13:41:39 +0100 | [diff] [blame] | 21 | struct reset_control *__reset_control_get(struct device *dev, const char *id, |
| 22 | int index, bool shared, |
| 23 | bool optional); |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 24 | void reset_control_put(struct reset_control *rstc); |
Masahiro Yamada | 1554bbd | 2017-10-29 01:50:06 +0900 | [diff] [blame] | 25 | int __device_reset(struct device *dev, bool optional); |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 26 | struct reset_control *__devm_reset_control_get(struct device *dev, |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 27 | const char *id, int index, bool shared, |
| 28 | bool optional); |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 29 | |
Vivek Gautam | 17c82e2 | 2017-05-22 16:53:25 +0530 | [diff] [blame] | 30 | struct reset_control *devm_reset_control_array_get(struct device *dev, |
| 31 | bool shared, bool optional); |
| 32 | struct reset_control *of_reset_control_array_get(struct device_node *np, |
| 33 | bool shared, bool optional); |
| 34 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 35 | #else |
| 36 | |
| 37 | static inline int reset_control_reset(struct reset_control *rstc) |
| 38 | { |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static inline int reset_control_assert(struct reset_control *rstc) |
| 43 | { |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static inline int reset_control_deassert(struct reset_control *rstc) |
| 48 | { |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 49 | return 0; |
| 50 | } |
| 51 | |
Dinh Nguyen | 729de41 | 2014-10-10 10:21:14 -0500 | [diff] [blame] | 52 | static inline int reset_control_status(struct reset_control *rstc) |
| 53 | { |
Dinh Nguyen | 729de41 | 2014-10-10 10:21:14 -0500 | [diff] [blame] | 54 | return 0; |
| 55 | } |
| 56 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 57 | static inline void reset_control_put(struct reset_control *rstc) |
| 58 | { |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 59 | } |
| 60 | |
Masahiro Yamada | 1554bbd | 2017-10-29 01:50:06 +0900 | [diff] [blame] | 61 | static inline int __device_reset(struct device *dev, bool optional) |
Daniel Lezcano | 4113652 | 2016-04-01 21:38:16 +0200 | [diff] [blame] | 62 | { |
Masahiro Yamada | 1554bbd | 2017-10-29 01:50:06 +0900 | [diff] [blame] | 63 | return optional ? 0 : -ENOTSUPP; |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 64 | } |
| 65 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 66 | static inline struct reset_control *__of_reset_control_get( |
| 67 | struct device_node *node, |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 68 | const char *id, int index, bool shared, |
| 69 | bool optional) |
Axel Lin | 5bcd0b7 | 2015-09-01 07:56:38 +0800 | [diff] [blame] | 70 | { |
Philipp Zabel | 0ca10b6 | 2017-03-20 11:25:16 +0100 | [diff] [blame] | 71 | return optional ? NULL : ERR_PTR(-ENOTSUPP); |
Axel Lin | 5bcd0b7 | 2015-09-01 07:56:38 +0800 | [diff] [blame] | 72 | } |
| 73 | |
Philipp Zabel | 62e24c5 | 2016-02-05 13:41:39 +0100 | [diff] [blame] | 74 | static inline struct reset_control *__reset_control_get( |
| 75 | struct device *dev, const char *id, |
| 76 | int index, bool shared, bool optional) |
| 77 | { |
| 78 | return optional ? NULL : ERR_PTR(-ENOTSUPP); |
| 79 | } |
| 80 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 81 | static inline struct reset_control *__devm_reset_control_get( |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 82 | struct device *dev, const char *id, |
| 83 | int index, bool shared, bool optional) |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 84 | { |
Philipp Zabel | 0ca10b6 | 2017-03-20 11:25:16 +0100 | [diff] [blame] | 85 | return optional ? NULL : ERR_PTR(-ENOTSUPP); |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 86 | } |
| 87 | |
Vivek Gautam | 17c82e2 | 2017-05-22 16:53:25 +0530 | [diff] [blame] | 88 | static inline struct reset_control * |
| 89 | devm_reset_control_array_get(struct device *dev, bool shared, bool optional) |
| 90 | { |
| 91 | return optional ? NULL : ERR_PTR(-ENOTSUPP); |
| 92 | } |
| 93 | |
| 94 | static inline struct reset_control * |
| 95 | of_reset_control_array_get(struct device_node *np, bool shared, bool optional) |
| 96 | { |
| 97 | return optional ? NULL : ERR_PTR(-ENOTSUPP); |
| 98 | } |
| 99 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 100 | #endif /* CONFIG_RESET_CONTROLLER */ |
| 101 | |
Masahiro Yamada | 1554bbd | 2017-10-29 01:50:06 +0900 | [diff] [blame] | 102 | static inline int __must_check device_reset(struct device *dev) |
| 103 | { |
| 104 | return __device_reset(dev, false); |
| 105 | } |
| 106 | |
| 107 | static inline int device_reset_optional(struct device *dev) |
| 108 | { |
| 109 | return __device_reset(dev, true); |
| 110 | } |
| 111 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 112 | /** |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 113 | * reset_control_get_exclusive - Lookup and obtain an exclusive reference |
| 114 | * to a reset controller. |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 115 | * @dev: device to be reset by the controller |
| 116 | * @id: reset line name |
| 117 | * |
| 118 | * Returns a struct reset_control or IS_ERR() condition containing errno. |
Geert Uytterhoeven | 34845c9 | 2018-09-26 15:20:03 +0200 | [diff] [blame] | 119 | * If this function is called more than once for the same reset_control it will |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 120 | * return -EBUSY. |
| 121 | * |
| 122 | * See reset_control_get_shared for details on shared references to |
| 123 | * reset-controls. |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 124 | * |
| 125 | * Use of id names is optional. |
| 126 | */ |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 127 | static inline struct reset_control * |
| 128 | __must_check reset_control_get_exclusive(struct device *dev, const char *id) |
Axel Lin | 5bcd0b7 | 2015-09-01 07:56:38 +0800 | [diff] [blame] | 129 | { |
Philipp Zabel | 62e24c5 | 2016-02-05 13:41:39 +0100 | [diff] [blame] | 130 | return __reset_control_get(dev, id, 0, false, false); |
Axel Lin | 5bcd0b7 | 2015-09-01 07:56:38 +0800 | [diff] [blame] | 131 | } |
| 132 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 133 | /** |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 134 | * reset_control_get_shared - Lookup and obtain a shared reference to a |
| 135 | * reset controller. |
| 136 | * @dev: device to be reset by the controller |
| 137 | * @id: reset line name |
| 138 | * |
| 139 | * Returns a struct reset_control or IS_ERR() condition containing errno. |
| 140 | * This function is intended for use with reset-controls which are shared |
| 141 | * between hardware-blocks. |
| 142 | * |
| 143 | * When a reset-control is shared, the behavior of reset_control_assert / |
| 144 | * deassert is changed, the reset-core will keep track of a deassert_count |
| 145 | * and only (re-)assert the reset after reset_control_assert has been called |
| 146 | * as many times as reset_control_deassert was called. Also see the remark |
| 147 | * about shared reset-controls in the reset_control_assert docs. |
| 148 | * |
| 149 | * Calling reset_control_assert without first calling reset_control_deassert |
| 150 | * is not allowed on a shared reset control. Calling reset_control_reset is |
| 151 | * also not allowed on a shared reset control. |
| 152 | * |
| 153 | * Use of id names is optional. |
| 154 | */ |
| 155 | static inline struct reset_control *reset_control_get_shared( |
| 156 | struct device *dev, const char *id) |
| 157 | { |
Philipp Zabel | 62e24c5 | 2016-02-05 13:41:39 +0100 | [diff] [blame] | 158 | return __reset_control_get(dev, id, 0, true, false); |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 159 | } |
| 160 | |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 161 | static inline struct reset_control *reset_control_get_optional_exclusive( |
Lee Jones | 3c35f6e | 2016-06-06 16:56:49 +0100 | [diff] [blame] | 162 | struct device *dev, const char *id) |
| 163 | { |
Philipp Zabel | 62e24c5 | 2016-02-05 13:41:39 +0100 | [diff] [blame] | 164 | return __reset_control_get(dev, id, 0, false, true); |
Lee Jones | 3c35f6e | 2016-06-06 16:56:49 +0100 | [diff] [blame] | 165 | } |
| 166 | |
Lee Jones | c33d61a | 2016-06-06 16:56:52 +0100 | [diff] [blame] | 167 | static inline struct reset_control *reset_control_get_optional_shared( |
| 168 | struct device *dev, const char *id) |
| 169 | { |
Philipp Zabel | 62e24c5 | 2016-02-05 13:41:39 +0100 | [diff] [blame] | 170 | return __reset_control_get(dev, id, 0, true, true); |
Lee Jones | c33d61a | 2016-06-06 16:56:52 +0100 | [diff] [blame] | 171 | } |
| 172 | |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 173 | /** |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 174 | * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference |
| 175 | * to a reset controller. |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 176 | * @node: device to be reset by the controller |
| 177 | * @id: reset line name |
| 178 | * |
| 179 | * Returns a struct reset_control or IS_ERR() condition containing errno. |
| 180 | * |
| 181 | * Use of id names is optional. |
| 182 | */ |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 183 | static inline struct reset_control *of_reset_control_get_exclusive( |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 184 | struct device_node *node, const char *id) |
| 185 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 186 | return __of_reset_control_get(node, id, 0, false, false); |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /** |
Lee Jones | 40faee8e | 2016-06-06 16:56:51 +0100 | [diff] [blame] | 190 | * of_reset_control_get_shared - Lookup and obtain an shared reference |
| 191 | * to a reset controller. |
| 192 | * @node: device to be reset by the controller |
| 193 | * @id: reset line name |
| 194 | * |
| 195 | * When a reset-control is shared, the behavior of reset_control_assert / |
| 196 | * deassert is changed, the reset-core will keep track of a deassert_count |
| 197 | * and only (re-)assert the reset after reset_control_assert has been called |
| 198 | * as many times as reset_control_deassert was called. Also see the remark |
| 199 | * about shared reset-controls in the reset_control_assert docs. |
| 200 | * |
| 201 | * Calling reset_control_assert without first calling reset_control_deassert |
| 202 | * is not allowed on a shared reset control. Calling reset_control_reset is |
| 203 | * also not allowed on a shared reset control. |
| 204 | * Returns a struct reset_control or IS_ERR() condition containing errno. |
| 205 | * |
| 206 | * Use of id names is optional. |
| 207 | */ |
| 208 | static inline struct reset_control *of_reset_control_get_shared( |
| 209 | struct device_node *node, const char *id) |
| 210 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 211 | return __of_reset_control_get(node, id, 0, true, false); |
Lee Jones | 40faee8e | 2016-06-06 16:56:51 +0100 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | /** |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 215 | * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive |
| 216 | * reference to a reset controller |
| 217 | * by index. |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 218 | * @node: device to be reset by the controller |
| 219 | * @index: index of the reset controller |
| 220 | * |
| 221 | * This is to be used to perform a list of resets for a device or power domain |
| 222 | * in whatever order. Returns a struct reset_control or IS_ERR() condition |
| 223 | * containing errno. |
| 224 | */ |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 225 | static inline struct reset_control *of_reset_control_get_exclusive_by_index( |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 226 | struct device_node *node, int index) |
| 227 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 228 | return __of_reset_control_get(node, NULL, index, false, false); |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /** |
Lee Jones | 40faee8e | 2016-06-06 16:56:51 +0100 | [diff] [blame] | 232 | * of_reset_control_get_shared_by_index - Lookup and obtain an shared |
| 233 | * reference to a reset controller |
| 234 | * by index. |
| 235 | * @node: device to be reset by the controller |
| 236 | * @index: index of the reset controller |
| 237 | * |
| 238 | * When a reset-control is shared, the behavior of reset_control_assert / |
| 239 | * deassert is changed, the reset-core will keep track of a deassert_count |
| 240 | * and only (re-)assert the reset after reset_control_assert has been called |
| 241 | * as many times as reset_control_deassert was called. Also see the remark |
| 242 | * about shared reset-controls in the reset_control_assert docs. |
| 243 | * |
| 244 | * Calling reset_control_assert without first calling reset_control_deassert |
| 245 | * is not allowed on a shared reset control. Calling reset_control_reset is |
| 246 | * also not allowed on a shared reset control. |
| 247 | * Returns a struct reset_control or IS_ERR() condition containing errno. |
| 248 | * |
| 249 | * This is to be used to perform a list of resets for a device or power domain |
| 250 | * in whatever order. Returns a struct reset_control or IS_ERR() condition |
| 251 | * containing errno. |
| 252 | */ |
| 253 | static inline struct reset_control *of_reset_control_get_shared_by_index( |
| 254 | struct device_node *node, int index) |
| 255 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 256 | return __of_reset_control_get(node, NULL, index, true, false); |
Lee Jones | 40faee8e | 2016-06-06 16:56:51 +0100 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | /** |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 260 | * devm_reset_control_get_exclusive - resource managed |
| 261 | * reset_control_get_exclusive() |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 262 | * @dev: device to be reset by the controller |
| 263 | * @id: reset line name |
| 264 | * |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 265 | * Managed reset_control_get_exclusive(). For reset controllers returned |
| 266 | * from this function, reset_control_put() is called automatically on driver |
| 267 | * detach. |
| 268 | * |
| 269 | * See reset_control_get_exclusive() for more information. |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 270 | */ |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 271 | static inline struct reset_control * |
| 272 | __must_check devm_reset_control_get_exclusive(struct device *dev, |
| 273 | const char *id) |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 274 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 275 | return __devm_reset_control_get(dev, id, 0, false, false); |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 276 | } |
| 277 | |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 278 | /** |
| 279 | * devm_reset_control_get_shared - resource managed reset_control_get_shared() |
| 280 | * @dev: device to be reset by the controller |
| 281 | * @id: reset line name |
| 282 | * |
| 283 | * Managed reset_control_get_shared(). For reset controllers returned from |
| 284 | * this function, reset_control_put() is called automatically on driver detach. |
| 285 | * See reset_control_get_shared() for more information. |
| 286 | */ |
| 287 | static inline struct reset_control *devm_reset_control_get_shared( |
| 288 | struct device *dev, const char *id) |
| 289 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 290 | return __devm_reset_control_get(dev, id, 0, true, false); |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 291 | } |
| 292 | |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 293 | static inline struct reset_control *devm_reset_control_get_optional_exclusive( |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 294 | struct device *dev, const char *id) |
| 295 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 296 | return __devm_reset_control_get(dev, id, 0, false, true); |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 297 | } |
| 298 | |
Lee Jones | c33d61a | 2016-06-06 16:56:52 +0100 | [diff] [blame] | 299 | static inline struct reset_control *devm_reset_control_get_optional_shared( |
| 300 | struct device *dev, const char *id) |
| 301 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 302 | return __devm_reset_control_get(dev, id, 0, true, true); |
Lee Jones | c33d61a | 2016-06-06 16:56:52 +0100 | [diff] [blame] | 303 | } |
| 304 | |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 305 | /** |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 306 | * devm_reset_control_get_exclusive_by_index - resource managed |
| 307 | * reset_control_get_exclusive() |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 308 | * @dev: device to be reset by the controller |
| 309 | * @index: index of the reset controller |
| 310 | * |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 311 | * Managed reset_control_get_exclusive(). For reset controllers returned from |
| 312 | * this function, reset_control_put() is called automatically on driver |
| 313 | * detach. |
| 314 | * |
| 315 | * See reset_control_get_exclusive() for more information. |
Hans de Goede | 6c96f05 | 2016-02-23 18:46:24 +0100 | [diff] [blame] | 316 | */ |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 317 | static inline struct reset_control * |
| 318 | devm_reset_control_get_exclusive_by_index(struct device *dev, int index) |
Hans de Goede | e3ec0a8 | 2014-04-13 14:09:15 +0200 | [diff] [blame] | 319 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 320 | return __devm_reset_control_get(dev, NULL, index, false, false); |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 321 | } |
| 322 | |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 323 | /** |
| 324 | * devm_reset_control_get_shared_by_index - resource managed |
| 325 | * reset_control_get_shared |
| 326 | * @dev: device to be reset by the controller |
| 327 | * @index: index of the reset controller |
| 328 | * |
| 329 | * Managed reset_control_get_shared(). For reset controllers returned from |
| 330 | * this function, reset_control_put() is called automatically on driver detach. |
| 331 | * See reset_control_get_shared() for more information. |
| 332 | */ |
Lee Jones | 0bcc0ea | 2016-06-06 16:56:53 +0100 | [diff] [blame] | 333 | static inline struct reset_control * |
| 334 | devm_reset_control_get_shared_by_index(struct device *dev, int index) |
Hans de Goede | 0b52297 | 2016-02-23 18:46:26 +0100 | [diff] [blame] | 335 | { |
Ramiro Oliveira | bb47523 | 2017-01-13 17:57:41 +0000 | [diff] [blame] | 336 | return __devm_reset_control_get(dev, NULL, index, true, false); |
Hans de Goede | e3ec0a8 | 2014-04-13 14:09:15 +0200 | [diff] [blame] | 337 | } |
| 338 | |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 339 | /* |
| 340 | * TEMPORARY calls to use during transition: |
| 341 | * |
| 342 | * of_reset_control_get() => of_reset_control_get_exclusive() |
| 343 | * |
| 344 | * These inline function calls will be removed once all consumers |
| 345 | * have been moved over to the new explicit API. |
| 346 | */ |
Lee Jones | a53e35d | 2016-06-06 16:56:50 +0100 | [diff] [blame] | 347 | static inline struct reset_control *of_reset_control_get( |
| 348 | struct device_node *node, const char *id) |
| 349 | { |
| 350 | return of_reset_control_get_exclusive(node, id); |
| 351 | } |
| 352 | |
| 353 | static inline struct reset_control *of_reset_control_get_by_index( |
| 354 | struct device_node *node, int index) |
| 355 | { |
| 356 | return of_reset_control_get_exclusive_by_index(node, index); |
| 357 | } |
| 358 | |
| 359 | static inline struct reset_control *devm_reset_control_get( |
| 360 | struct device *dev, const char *id) |
| 361 | { |
| 362 | return devm_reset_control_get_exclusive(dev, id); |
| 363 | } |
| 364 | |
| 365 | static inline struct reset_control *devm_reset_control_get_optional( |
| 366 | struct device *dev, const char *id) |
| 367 | { |
| 368 | return devm_reset_control_get_optional_exclusive(dev, id); |
| 369 | |
| 370 | } |
| 371 | |
| 372 | static inline struct reset_control *devm_reset_control_get_by_index( |
| 373 | struct device *dev, int index) |
| 374 | { |
| 375 | return devm_reset_control_get_exclusive_by_index(dev, index); |
| 376 | } |
Vivek Gautam | 17c82e2 | 2017-05-22 16:53:25 +0530 | [diff] [blame] | 377 | |
| 378 | /* |
| 379 | * APIs to manage a list of reset controllers |
| 380 | */ |
| 381 | static inline struct reset_control * |
| 382 | devm_reset_control_array_get_exclusive(struct device *dev) |
| 383 | { |
| 384 | return devm_reset_control_array_get(dev, false, false); |
| 385 | } |
| 386 | |
| 387 | static inline struct reset_control * |
| 388 | devm_reset_control_array_get_shared(struct device *dev) |
| 389 | { |
| 390 | return devm_reset_control_array_get(dev, true, false); |
| 391 | } |
| 392 | |
| 393 | static inline struct reset_control * |
| 394 | devm_reset_control_array_get_optional_exclusive(struct device *dev) |
| 395 | { |
| 396 | return devm_reset_control_array_get(dev, false, true); |
| 397 | } |
| 398 | |
| 399 | static inline struct reset_control * |
| 400 | devm_reset_control_array_get_optional_shared(struct device *dev) |
| 401 | { |
| 402 | return devm_reset_control_array_get(dev, true, true); |
| 403 | } |
| 404 | |
| 405 | static inline struct reset_control * |
| 406 | of_reset_control_array_get_exclusive(struct device_node *node) |
| 407 | { |
| 408 | return of_reset_control_array_get(node, false, false); |
| 409 | } |
| 410 | |
| 411 | static inline struct reset_control * |
| 412 | of_reset_control_array_get_shared(struct device_node *node) |
| 413 | { |
| 414 | return of_reset_control_array_get(node, true, false); |
| 415 | } |
| 416 | |
| 417 | static inline struct reset_control * |
| 418 | of_reset_control_array_get_optional_exclusive(struct device_node *node) |
| 419 | { |
| 420 | return of_reset_control_array_get(node, false, true); |
| 421 | } |
| 422 | |
| 423 | static inline struct reset_control * |
| 424 | of_reset_control_array_get_optional_shared(struct device_node *node) |
| 425 | { |
| 426 | return of_reset_control_array_get(node, true, true); |
| 427 | } |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 428 | #endif |