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