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