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