Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_RESET_H_
0003 #define _LINUX_RESET_H_
0004 
0005 #include <linux/err.h>
0006 #include <linux/errno.h>
0007 #include <linux/types.h>
0008 
0009 struct device;
0010 struct device_node;
0011 struct reset_control;
0012 
0013 /**
0014  * struct reset_control_bulk_data - Data used for bulk reset control operations.
0015  *
0016  * @id: reset control consumer ID
0017  * @rstc: struct reset_control * to store the associated reset control
0018  *
0019  * The reset APIs provide a series of reset_control_bulk_*() API calls as
0020  * a convenience to consumers which require multiple reset controls.
0021  * This structure is used to manage data for these calls.
0022  */
0023 struct reset_control_bulk_data {
0024     const char          *id;
0025     struct reset_control        *rstc;
0026 };
0027 
0028 #ifdef CONFIG_RESET_CONTROLLER
0029 
0030 int reset_control_reset(struct reset_control *rstc);
0031 int reset_control_rearm(struct reset_control *rstc);
0032 int reset_control_assert(struct reset_control *rstc);
0033 int reset_control_deassert(struct reset_control *rstc);
0034 int reset_control_status(struct reset_control *rstc);
0035 int reset_control_acquire(struct reset_control *rstc);
0036 void reset_control_release(struct reset_control *rstc);
0037 
0038 int reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs);
0039 int reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs);
0040 int reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs);
0041 int reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs);
0042 void reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs);
0043 
0044 struct reset_control *__of_reset_control_get(struct device_node *node,
0045                      const char *id, int index, bool shared,
0046                      bool optional, bool acquired);
0047 struct reset_control *__reset_control_get(struct device *dev, const char *id,
0048                       int index, bool shared,
0049                       bool optional, bool acquired);
0050 void reset_control_put(struct reset_control *rstc);
0051 int __reset_control_bulk_get(struct device *dev, int num_rstcs,
0052                  struct reset_control_bulk_data *rstcs,
0053                  bool shared, bool optional, bool acquired);
0054 void reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs);
0055 
0056 int __device_reset(struct device *dev, bool optional);
0057 struct reset_control *__devm_reset_control_get(struct device *dev,
0058                      const char *id, int index, bool shared,
0059                      bool optional, bool acquired);
0060 int __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
0061                   struct reset_control_bulk_data *rstcs,
0062                   bool shared, bool optional, bool acquired);
0063 
0064 struct reset_control *devm_reset_control_array_get(struct device *dev,
0065                            bool shared, bool optional);
0066 struct reset_control *of_reset_control_array_get(struct device_node *np,
0067                          bool shared, bool optional,
0068                          bool acquired);
0069 
0070 int reset_control_get_count(struct device *dev);
0071 
0072 #else
0073 
0074 static inline int reset_control_reset(struct reset_control *rstc)
0075 {
0076     return 0;
0077 }
0078 
0079 static inline int reset_control_rearm(struct reset_control *rstc)
0080 {
0081     return 0;
0082 }
0083 
0084 static inline int reset_control_assert(struct reset_control *rstc)
0085 {
0086     return 0;
0087 }
0088 
0089 static inline int reset_control_deassert(struct reset_control *rstc)
0090 {
0091     return 0;
0092 }
0093 
0094 static inline int reset_control_status(struct reset_control *rstc)
0095 {
0096     return 0;
0097 }
0098 
0099 static inline int reset_control_acquire(struct reset_control *rstc)
0100 {
0101     return 0;
0102 }
0103 
0104 static inline void reset_control_release(struct reset_control *rstc)
0105 {
0106 }
0107 
0108 static inline void reset_control_put(struct reset_control *rstc)
0109 {
0110 }
0111 
0112 static inline int __device_reset(struct device *dev, bool optional)
0113 {
0114     return optional ? 0 : -ENOTSUPP;
0115 }
0116 
0117 static inline struct reset_control *__of_reset_control_get(
0118                     struct device_node *node,
0119                     const char *id, int index, bool shared,
0120                     bool optional, bool acquired)
0121 {
0122     return optional ? NULL : ERR_PTR(-ENOTSUPP);
0123 }
0124 
0125 static inline struct reset_control *__reset_control_get(
0126                     struct device *dev, const char *id,
0127                     int index, bool shared, bool optional,
0128                     bool acquired)
0129 {
0130     return optional ? NULL : ERR_PTR(-ENOTSUPP);
0131 }
0132 
0133 static inline int
0134 reset_control_bulk_reset(int num_rstcs, struct reset_control_bulk_data *rstcs)
0135 {
0136     return 0;
0137 }
0138 
0139 static inline int
0140 reset_control_bulk_assert(int num_rstcs, struct reset_control_bulk_data *rstcs)
0141 {
0142     return 0;
0143 }
0144 
0145 static inline int
0146 reset_control_bulk_deassert(int num_rstcs, struct reset_control_bulk_data *rstcs)
0147 {
0148     return 0;
0149 }
0150 
0151 static inline int
0152 reset_control_bulk_acquire(int num_rstcs, struct reset_control_bulk_data *rstcs)
0153 {
0154     return 0;
0155 }
0156 
0157 static inline void
0158 reset_control_bulk_release(int num_rstcs, struct reset_control_bulk_data *rstcs)
0159 {
0160 }
0161 
0162 static inline int
0163 __reset_control_bulk_get(struct device *dev, int num_rstcs,
0164              struct reset_control_bulk_data *rstcs,
0165              bool shared, bool optional, bool acquired)
0166 {
0167     return optional ? 0 : -EOPNOTSUPP;
0168 }
0169 
0170 static inline void
0171 reset_control_bulk_put(int num_rstcs, struct reset_control_bulk_data *rstcs)
0172 {
0173 }
0174 
0175 static inline struct reset_control *__devm_reset_control_get(
0176                     struct device *dev, const char *id,
0177                     int index, bool shared, bool optional,
0178                     bool acquired)
0179 {
0180     return optional ? NULL : ERR_PTR(-ENOTSUPP);
0181 }
0182 
0183 static inline int
0184 __devm_reset_control_bulk_get(struct device *dev, int num_rstcs,
0185                   struct reset_control_bulk_data *rstcs,
0186                   bool shared, bool optional, bool acquired)
0187 {
0188     return optional ? 0 : -EOPNOTSUPP;
0189 }
0190 
0191 static inline struct reset_control *
0192 devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
0193 {
0194     return optional ? NULL : ERR_PTR(-ENOTSUPP);
0195 }
0196 
0197 static inline struct reset_control *
0198 of_reset_control_array_get(struct device_node *np, bool shared, bool optional,
0199                bool acquired)
0200 {
0201     return optional ? NULL : ERR_PTR(-ENOTSUPP);
0202 }
0203 
0204 static inline int reset_control_get_count(struct device *dev)
0205 {
0206     return -ENOENT;
0207 }
0208 
0209 #endif /* CONFIG_RESET_CONTROLLER */
0210 
0211 static inline int __must_check device_reset(struct device *dev)
0212 {
0213     return __device_reset(dev, false);
0214 }
0215 
0216 static inline int device_reset_optional(struct device *dev)
0217 {
0218     return __device_reset(dev, true);
0219 }
0220 
0221 /**
0222  * reset_control_get_exclusive - Lookup and obtain an exclusive reference
0223  *                               to a reset controller.
0224  * @dev: device to be reset by the controller
0225  * @id: reset line name
0226  *
0227  * Returns a struct reset_control or IS_ERR() condition containing errno.
0228  * If this function is called more than once for the same reset_control it will
0229  * return -EBUSY.
0230  *
0231  * See reset_control_get_shared() for details on shared references to
0232  * reset-controls.
0233  *
0234  * Use of id names is optional.
0235  */
0236 static inline struct reset_control *
0237 __must_check reset_control_get_exclusive(struct device *dev, const char *id)
0238 {
0239     return __reset_control_get(dev, id, 0, false, false, true);
0240 }
0241 
0242 /**
0243  * reset_control_bulk_get_exclusive - Lookup and obtain exclusive references to
0244  *                                    multiple reset controllers.
0245  * @dev: device to be reset by the controller
0246  * @num_rstcs: number of entries in rstcs array
0247  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0248  *
0249  * Fills the rstcs array with pointers to exclusive reset controls and
0250  * returns 0, or an IS_ERR() condition containing errno.
0251  */
0252 static inline int __must_check
0253 reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
0254                  struct reset_control_bulk_data *rstcs)
0255 {
0256     return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, true);
0257 }
0258 
0259 /**
0260  * reset_control_get_exclusive_released - Lookup and obtain a temoprarily
0261  *                                        exclusive reference to a reset
0262  *                                        controller.
0263  * @dev: device to be reset by the controller
0264  * @id: reset line name
0265  *
0266  * Returns a struct reset_control or IS_ERR() condition containing errno.
0267  * reset-controls returned by this function must be acquired via
0268  * reset_control_acquire() before they can be used and should be released
0269  * via reset_control_release() afterwards.
0270  *
0271  * Use of id names is optional.
0272  */
0273 static inline struct reset_control *
0274 __must_check reset_control_get_exclusive_released(struct device *dev,
0275                           const char *id)
0276 {
0277     return __reset_control_get(dev, id, 0, false, false, false);
0278 }
0279 
0280 /**
0281  * reset_control_bulk_get_exclusive_released - Lookup and obtain temporarily
0282  *                                    exclusive references to multiple reset
0283  *                                    controllers.
0284  * @dev: device to be reset by the controller
0285  * @num_rstcs: number of entries in rstcs array
0286  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0287  *
0288  * Fills the rstcs array with pointers to exclusive reset controls and
0289  * returns 0, or an IS_ERR() condition containing errno.
0290  * reset-controls returned by this function must be acquired via
0291  * reset_control_bulk_acquire() before they can be used and should be released
0292  * via reset_control_bulk_release() afterwards.
0293  */
0294 static inline int __must_check
0295 reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
0296                       struct reset_control_bulk_data *rstcs)
0297 {
0298     return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, false);
0299 }
0300 
0301 /**
0302  * reset_control_bulk_get_optional_exclusive_released - Lookup and obtain optional
0303  *                                    temporarily exclusive references to multiple
0304  *                                    reset controllers.
0305  * @dev: device to be reset by the controller
0306  * @num_rstcs: number of entries in rstcs array
0307  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0308  *
0309  * Optional variant of reset_control_bulk_get_exclusive_released(). If the
0310  * requested reset is not specified in the device tree, this function returns 0
0311  * instead of an error and missing rtsc is set to NULL.
0312  *
0313  * See reset_control_bulk_get_exclusive_released() for more information.
0314  */
0315 static inline int __must_check
0316 reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
0317                            struct reset_control_bulk_data *rstcs)
0318 {
0319     return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, false);
0320 }
0321 
0322 /**
0323  * reset_control_get_shared - Lookup and obtain a shared reference to a
0324  *                            reset controller.
0325  * @dev: device to be reset by the controller
0326  * @id: reset line name
0327  *
0328  * Returns a struct reset_control or IS_ERR() condition containing errno.
0329  * This function is intended for use with reset-controls which are shared
0330  * between hardware blocks.
0331  *
0332  * When a reset-control is shared, the behavior of reset_control_assert /
0333  * deassert is changed, the reset-core will keep track of a deassert_count
0334  * and only (re-)assert the reset after reset_control_assert has been called
0335  * as many times as reset_control_deassert was called. Also see the remark
0336  * about shared reset-controls in the reset_control_assert docs.
0337  *
0338  * Calling reset_control_assert without first calling reset_control_deassert
0339  * is not allowed on a shared reset control. Calling reset_control_reset is
0340  * also not allowed on a shared reset control.
0341  *
0342  * Use of id names is optional.
0343  */
0344 static inline struct reset_control *reset_control_get_shared(
0345                     struct device *dev, const char *id)
0346 {
0347     return __reset_control_get(dev, id, 0, true, false, false);
0348 }
0349 
0350 /**
0351  * reset_control_bulk_get_shared - Lookup and obtain shared references to
0352  *                                 multiple reset controllers.
0353  * @dev: device to be reset by the controller
0354  * @num_rstcs: number of entries in rstcs array
0355  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0356  *
0357  * Fills the rstcs array with pointers to shared reset controls and
0358  * returns 0, or an IS_ERR() condition containing errno.
0359  */
0360 static inline int __must_check
0361 reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
0362                   struct reset_control_bulk_data *rstcs)
0363 {
0364     return __reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, false);
0365 }
0366 
0367 /**
0368  * reset_control_get_optional_exclusive - optional reset_control_get_exclusive()
0369  * @dev: device to be reset by the controller
0370  * @id: reset line name
0371  *
0372  * Optional variant of reset_control_get_exclusive(). If the requested reset
0373  * is not specified in the device tree, this function returns NULL instead of
0374  * an error.
0375  *
0376  * See reset_control_get_exclusive() for more information.
0377  */
0378 static inline struct reset_control *reset_control_get_optional_exclusive(
0379                     struct device *dev, const char *id)
0380 {
0381     return __reset_control_get(dev, id, 0, false, true, true);
0382 }
0383 
0384 /**
0385  * reset_control_bulk_get_optional_exclusive - optional
0386  *                                             reset_control_bulk_get_exclusive()
0387  * @dev: device to be reset by the controller
0388  * @num_rstcs: number of entries in rstcs array
0389  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0390  *
0391  * Optional variant of reset_control_bulk_get_exclusive(). If any of the
0392  * requested resets are not specified in the device tree, this function sets
0393  * them to NULL instead of returning an error.
0394  *
0395  * See reset_control_bulk_get_exclusive() for more information.
0396  */
0397 static inline int __must_check
0398 reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
0399                       struct reset_control_bulk_data *rstcs)
0400 {
0401     return __reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true);
0402 }
0403 
0404 /**
0405  * reset_control_get_optional_shared - optional reset_control_get_shared()
0406  * @dev: device to be reset by the controller
0407  * @id: reset line name
0408  *
0409  * Optional variant of reset_control_get_shared(). If the requested reset
0410  * is not specified in the device tree, this function returns NULL instead of
0411  * an error.
0412  *
0413  * See reset_control_get_shared() for more information.
0414  */
0415 static inline struct reset_control *reset_control_get_optional_shared(
0416                     struct device *dev, const char *id)
0417 {
0418     return __reset_control_get(dev, id, 0, true, true, false);
0419 }
0420 
0421 /**
0422  * reset_control_bulk_get_optional_shared - optional
0423  *                                             reset_control_bulk_get_shared()
0424  * @dev: device to be reset by the controller
0425  * @num_rstcs: number of entries in rstcs array
0426  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0427  *
0428  * Optional variant of reset_control_bulk_get_shared(). If the requested resets
0429  * are not specified in the device tree, this function sets them to NULL
0430  * instead of returning an error.
0431  *
0432  * See reset_control_bulk_get_shared() for more information.
0433  */
0434 static inline int __must_check
0435 reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
0436                        struct reset_control_bulk_data *rstcs)
0437 {
0438     return __reset_control_bulk_get(dev, num_rstcs, rstcs, true, true, false);
0439 }
0440 
0441 /**
0442  * of_reset_control_get_exclusive - Lookup and obtain an exclusive reference
0443  *                                  to a reset controller.
0444  * @node: device to be reset by the controller
0445  * @id: reset line name
0446  *
0447  * Returns a struct reset_control or IS_ERR() condition containing errno.
0448  *
0449  * Use of id names is optional.
0450  */
0451 static inline struct reset_control *of_reset_control_get_exclusive(
0452                 struct device_node *node, const char *id)
0453 {
0454     return __of_reset_control_get(node, id, 0, false, false, true);
0455 }
0456 
0457 /**
0458  * of_reset_control_get_optional_exclusive - Lookup and obtain an optional exclusive
0459  *                                           reference to a reset controller.
0460  * @node: device to be reset by the controller
0461  * @id: reset line name
0462  *
0463  * Optional variant of of_reset_control_get_exclusive(). If the requested reset
0464  * is not specified in the device tree, this function returns NULL instead of
0465  * an error.
0466  *
0467  * Returns a struct reset_control or IS_ERR() condition containing errno.
0468  *
0469  * Use of id names is optional.
0470  */
0471 static inline struct reset_control *of_reset_control_get_optional_exclusive(
0472                 struct device_node *node, const char *id)
0473 {
0474     return __of_reset_control_get(node, id, 0, false, true, true);
0475 }
0476 
0477 /**
0478  * of_reset_control_get_shared - Lookup and obtain a shared reference
0479  *                               to a reset controller.
0480  * @node: device to be reset by the controller
0481  * @id: reset line name
0482  *
0483  * When a reset-control is shared, the behavior of reset_control_assert /
0484  * deassert is changed, the reset-core will keep track of a deassert_count
0485  * and only (re-)assert the reset after reset_control_assert has been called
0486  * as many times as reset_control_deassert was called. Also see the remark
0487  * about shared reset-controls in the reset_control_assert docs.
0488  *
0489  * Calling reset_control_assert without first calling reset_control_deassert
0490  * is not allowed on a shared reset control. Calling reset_control_reset is
0491  * also not allowed on a shared reset control.
0492  * Returns a struct reset_control or IS_ERR() condition containing errno.
0493  *
0494  * Use of id names is optional.
0495  */
0496 static inline struct reset_control *of_reset_control_get_shared(
0497                 struct device_node *node, const char *id)
0498 {
0499     return __of_reset_control_get(node, id, 0, true, false, false);
0500 }
0501 
0502 /**
0503  * of_reset_control_get_exclusive_by_index - Lookup and obtain an exclusive
0504  *                                           reference to a reset controller
0505  *                                           by index.
0506  * @node: device to be reset by the controller
0507  * @index: index of the reset controller
0508  *
0509  * This is to be used to perform a list of resets for a device or power domain
0510  * in whatever order. Returns a struct reset_control or IS_ERR() condition
0511  * containing errno.
0512  */
0513 static inline struct reset_control *of_reset_control_get_exclusive_by_index(
0514                     struct device_node *node, int index)
0515 {
0516     return __of_reset_control_get(node, NULL, index, false, false, true);
0517 }
0518 
0519 /**
0520  * of_reset_control_get_shared_by_index - Lookup and obtain a shared
0521  *                                        reference to a reset controller
0522  *                                        by index.
0523  * @node: device to be reset by the controller
0524  * @index: index of the reset controller
0525  *
0526  * When a reset-control is shared, the behavior of reset_control_assert /
0527  * deassert is changed, the reset-core will keep track of a deassert_count
0528  * and only (re-)assert the reset after reset_control_assert has been called
0529  * as many times as reset_control_deassert was called. Also see the remark
0530  * about shared reset-controls in the reset_control_assert docs.
0531  *
0532  * Calling reset_control_assert without first calling reset_control_deassert
0533  * is not allowed on a shared reset control. Calling reset_control_reset is
0534  * also not allowed on a shared reset control.
0535  * Returns a struct reset_control or IS_ERR() condition containing errno.
0536  *
0537  * This is to be used to perform a list of resets for a device or power domain
0538  * in whatever order. Returns a struct reset_control or IS_ERR() condition
0539  * containing errno.
0540  */
0541 static inline struct reset_control *of_reset_control_get_shared_by_index(
0542                     struct device_node *node, int index)
0543 {
0544     return __of_reset_control_get(node, NULL, index, true, false, false);
0545 }
0546 
0547 /**
0548  * devm_reset_control_get_exclusive - resource managed
0549  *                                    reset_control_get_exclusive()
0550  * @dev: device to be reset by the controller
0551  * @id: reset line name
0552  *
0553  * Managed reset_control_get_exclusive(). For reset controllers returned
0554  * from this function, reset_control_put() is called automatically on driver
0555  * detach.
0556  *
0557  * See reset_control_get_exclusive() for more information.
0558  */
0559 static inline struct reset_control *
0560 __must_check devm_reset_control_get_exclusive(struct device *dev,
0561                           const char *id)
0562 {
0563     return __devm_reset_control_get(dev, id, 0, false, false, true);
0564 }
0565 
0566 /**
0567  * devm_reset_control_bulk_get_exclusive - resource managed
0568  *                                         reset_control_bulk_get_exclusive()
0569  * @dev: device to be reset by the controller
0570  * @num_rstcs: number of entries in rstcs array
0571  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0572  *
0573  * Managed reset_control_bulk_get_exclusive(). For reset controllers returned
0574  * from this function, reset_control_put() is called automatically on driver
0575  * detach.
0576  *
0577  * See reset_control_bulk_get_exclusive() for more information.
0578  */
0579 static inline int __must_check
0580 devm_reset_control_bulk_get_exclusive(struct device *dev, int num_rstcs,
0581                       struct reset_control_bulk_data *rstcs)
0582 {
0583     return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, true);
0584 }
0585 
0586 /**
0587  * devm_reset_control_get_exclusive_released - resource managed
0588  *                                             reset_control_get_exclusive_released()
0589  * @dev: device to be reset by the controller
0590  * @id: reset line name
0591  *
0592  * Managed reset_control_get_exclusive_released(). For reset controllers
0593  * returned from this function, reset_control_put() is called automatically on
0594  * driver detach.
0595  *
0596  * See reset_control_get_exclusive_released() for more information.
0597  */
0598 static inline struct reset_control *
0599 __must_check devm_reset_control_get_exclusive_released(struct device *dev,
0600                                const char *id)
0601 {
0602     return __devm_reset_control_get(dev, id, 0, false, false, false);
0603 }
0604 
0605 /**
0606  * devm_reset_control_bulk_get_exclusive_released - resource managed
0607  *                                                  reset_control_bulk_get_exclusive_released()
0608  * @dev: device to be reset by the controller
0609  * @num_rstcs: number of entries in rstcs array
0610  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0611  *
0612  * Managed reset_control_bulk_get_exclusive_released(). For reset controllers
0613  * returned from this function, reset_control_put() is called automatically on
0614  * driver detach.
0615  *
0616  * See reset_control_bulk_get_exclusive_released() for more information.
0617  */
0618 static inline int __must_check
0619 devm_reset_control_bulk_get_exclusive_released(struct device *dev, int num_rstcs,
0620                            struct reset_control_bulk_data *rstcs)
0621 {
0622     return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, false, false);
0623 }
0624 
0625 /**
0626  * devm_reset_control_get_optional_exclusive_released - resource managed
0627  *                                                      reset_control_get_optional_exclusive_released()
0628  * @dev: device to be reset by the controller
0629  * @id: reset line name
0630  *
0631  * Managed-and-optional variant of reset_control_get_exclusive_released(). For
0632  * reset controllers returned from this function, reset_control_put() is called
0633  * automatically on driver detach.
0634  *
0635  * See reset_control_get_exclusive_released() for more information.
0636  */
0637 static inline struct reset_control *
0638 __must_check devm_reset_control_get_optional_exclusive_released(struct device *dev,
0639                                 const char *id)
0640 {
0641     return __devm_reset_control_get(dev, id, 0, false, true, false);
0642 }
0643 
0644 /**
0645  * devm_reset_control_bulk_get_optional_exclusive_released - resource managed
0646  *                                                           reset_control_bulk_optional_get_exclusive_released()
0647  * @dev: device to be reset by the controller
0648  * @num_rstcs: number of entries in rstcs array
0649  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0650  *
0651  * Managed reset_control_bulk_optional_get_exclusive_released(). For reset
0652  * controllers returned from this function, reset_control_put() is called
0653  * automatically on driver detach.
0654  *
0655  * See reset_control_bulk_optional_get_exclusive_released() for more information.
0656  */
0657 static inline int __must_check
0658 devm_reset_control_bulk_get_optional_exclusive_released(struct device *dev, int num_rstcs,
0659                             struct reset_control_bulk_data *rstcs)
0660 {
0661     return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, false);
0662 }
0663 
0664 /**
0665  * devm_reset_control_get_shared - resource managed reset_control_get_shared()
0666  * @dev: device to be reset by the controller
0667  * @id: reset line name
0668  *
0669  * Managed reset_control_get_shared(). For reset controllers returned from
0670  * this function, reset_control_put() is called automatically on driver detach.
0671  * See reset_control_get_shared() for more information.
0672  */
0673 static inline struct reset_control *devm_reset_control_get_shared(
0674                     struct device *dev, const char *id)
0675 {
0676     return __devm_reset_control_get(dev, id, 0, true, false, false);
0677 }
0678 
0679 /**
0680  * devm_reset_control_bulk_get_shared - resource managed
0681  *                                      reset_control_bulk_get_shared()
0682  * @dev: device to be reset by the controller
0683  * @num_rstcs: number of entries in rstcs array
0684  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0685  *
0686  * Managed reset_control_bulk_get_shared(). For reset controllers returned
0687  * from this function, reset_control_put() is called automatically on driver
0688  * detach.
0689  *
0690  * See reset_control_bulk_get_shared() for more information.
0691  */
0692 static inline int __must_check
0693 devm_reset_control_bulk_get_shared(struct device *dev, int num_rstcs,
0694                    struct reset_control_bulk_data *rstcs)
0695 {
0696     return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, false, false);
0697 }
0698 
0699 /**
0700  * devm_reset_control_get_optional_exclusive - resource managed
0701  *                                             reset_control_get_optional_exclusive()
0702  * @dev: device to be reset by the controller
0703  * @id: reset line name
0704  *
0705  * Managed reset_control_get_optional_exclusive(). For reset controllers
0706  * returned from this function, reset_control_put() is called automatically on
0707  * driver detach.
0708  *
0709  * See reset_control_get_optional_exclusive() for more information.
0710  */
0711 static inline struct reset_control *devm_reset_control_get_optional_exclusive(
0712                     struct device *dev, const char *id)
0713 {
0714     return __devm_reset_control_get(dev, id, 0, false, true, true);
0715 }
0716 
0717 /**
0718  * devm_reset_control_bulk_get_optional_exclusive - resource managed
0719  *                                                  reset_control_bulk_get_optional_exclusive()
0720  * @dev: device to be reset by the controller
0721  * @num_rstcs: number of entries in rstcs array
0722  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0723  *
0724  * Managed reset_control_bulk_get_optional_exclusive(). For reset controllers
0725  * returned from this function, reset_control_put() is called automatically on
0726  * driver detach.
0727  *
0728  * See reset_control_bulk_get_optional_exclusive() for more information.
0729  */
0730 static inline int __must_check
0731 devm_reset_control_bulk_get_optional_exclusive(struct device *dev, int num_rstcs,
0732                            struct reset_control_bulk_data *rstcs)
0733 {
0734     return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, false, true, true);
0735 }
0736 
0737 /**
0738  * devm_reset_control_get_optional_shared - resource managed
0739  *                                          reset_control_get_optional_shared()
0740  * @dev: device to be reset by the controller
0741  * @id: reset line name
0742  *
0743  * Managed reset_control_get_optional_shared(). For reset controllers returned
0744  * from this function, reset_control_put() is called automatically on driver
0745  * detach.
0746  *
0747  * See reset_control_get_optional_shared() for more information.
0748  */
0749 static inline struct reset_control *devm_reset_control_get_optional_shared(
0750                     struct device *dev, const char *id)
0751 {
0752     return __devm_reset_control_get(dev, id, 0, true, true, false);
0753 }
0754 
0755 /**
0756  * devm_reset_control_bulk_get_optional_shared - resource managed
0757  *                                               reset_control_bulk_get_optional_shared()
0758  * @dev: device to be reset by the controller
0759  * @num_rstcs: number of entries in rstcs array
0760  * @rstcs: array of struct reset_control_bulk_data with reset line names set
0761  *
0762  * Managed reset_control_bulk_get_optional_shared(). For reset controllers
0763  * returned from this function, reset_control_put() is called automatically on
0764  * driver detach.
0765  *
0766  * See reset_control_bulk_get_optional_shared() for more information.
0767  */
0768 static inline int __must_check
0769 devm_reset_control_bulk_get_optional_shared(struct device *dev, int num_rstcs,
0770                         struct reset_control_bulk_data *rstcs)
0771 {
0772     return __devm_reset_control_bulk_get(dev, num_rstcs, rstcs, true, true, false);
0773 }
0774 
0775 /**
0776  * devm_reset_control_get_exclusive_by_index - resource managed
0777  *                                             reset_control_get_exclusive()
0778  * @dev: device to be reset by the controller
0779  * @index: index of the reset controller
0780  *
0781  * Managed reset_control_get_exclusive(). For reset controllers returned from
0782  * this function, reset_control_put() is called automatically on driver
0783  * detach.
0784  *
0785  * See reset_control_get_exclusive() for more information.
0786  */
0787 static inline struct reset_control *
0788 devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
0789 {
0790     return __devm_reset_control_get(dev, NULL, index, false, false, true);
0791 }
0792 
0793 /**
0794  * devm_reset_control_get_shared_by_index - resource managed
0795  *                                          reset_control_get_shared
0796  * @dev: device to be reset by the controller
0797  * @index: index of the reset controller
0798  *
0799  * Managed reset_control_get_shared(). For reset controllers returned from
0800  * this function, reset_control_put() is called automatically on driver detach.
0801  * See reset_control_get_shared() for more information.
0802  */
0803 static inline struct reset_control *
0804 devm_reset_control_get_shared_by_index(struct device *dev, int index)
0805 {
0806     return __devm_reset_control_get(dev, NULL, index, true, false, false);
0807 }
0808 
0809 /*
0810  * TEMPORARY calls to use during transition:
0811  *
0812  *   of_reset_control_get() => of_reset_control_get_exclusive()
0813  *
0814  * These inline function calls will be removed once all consumers
0815  * have been moved over to the new explicit API.
0816  */
0817 static inline struct reset_control *of_reset_control_get(
0818                 struct device_node *node, const char *id)
0819 {
0820     return of_reset_control_get_exclusive(node, id);
0821 }
0822 
0823 static inline struct reset_control *of_reset_control_get_by_index(
0824                 struct device_node *node, int index)
0825 {
0826     return of_reset_control_get_exclusive_by_index(node, index);
0827 }
0828 
0829 static inline struct reset_control *devm_reset_control_get(
0830                 struct device *dev, const char *id)
0831 {
0832     return devm_reset_control_get_exclusive(dev, id);
0833 }
0834 
0835 static inline struct reset_control *devm_reset_control_get_optional(
0836                 struct device *dev, const char *id)
0837 {
0838     return devm_reset_control_get_optional_exclusive(dev, id);
0839 
0840 }
0841 
0842 static inline struct reset_control *devm_reset_control_get_by_index(
0843                 struct device *dev, int index)
0844 {
0845     return devm_reset_control_get_exclusive_by_index(dev, index);
0846 }
0847 
0848 /*
0849  * APIs to manage a list of reset controllers
0850  */
0851 static inline struct reset_control *
0852 devm_reset_control_array_get_exclusive(struct device *dev)
0853 {
0854     return devm_reset_control_array_get(dev, false, false);
0855 }
0856 
0857 static inline struct reset_control *
0858 devm_reset_control_array_get_shared(struct device *dev)
0859 {
0860     return devm_reset_control_array_get(dev, true, false);
0861 }
0862 
0863 static inline struct reset_control *
0864 devm_reset_control_array_get_optional_exclusive(struct device *dev)
0865 {
0866     return devm_reset_control_array_get(dev, false, true);
0867 }
0868 
0869 static inline struct reset_control *
0870 devm_reset_control_array_get_optional_shared(struct device *dev)
0871 {
0872     return devm_reset_control_array_get(dev, true, true);
0873 }
0874 
0875 static inline struct reset_control *
0876 of_reset_control_array_get_exclusive(struct device_node *node)
0877 {
0878     return of_reset_control_array_get(node, false, false, true);
0879 }
0880 
0881 static inline struct reset_control *
0882 of_reset_control_array_get_exclusive_released(struct device_node *node)
0883 {
0884     return of_reset_control_array_get(node, false, false, false);
0885 }
0886 
0887 static inline struct reset_control *
0888 of_reset_control_array_get_shared(struct device_node *node)
0889 {
0890     return of_reset_control_array_get(node, true, false, true);
0891 }
0892 
0893 static inline struct reset_control *
0894 of_reset_control_array_get_optional_exclusive(struct device_node *node)
0895 {
0896     return of_reset_control_array_get(node, false, true, true);
0897 }
0898 
0899 static inline struct reset_control *
0900 of_reset_control_array_get_optional_shared(struct device_node *node)
0901 {
0902     return of_reset_control_array_get(node, true, true, true);
0903 }
0904 #endif