Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 1 | #ifndef _LINUX_RESET_H_ |
| 2 | #define _LINUX_RESET_H_ |
| 3 | |
| 4 | struct device; |
Hans de Goede | e3ec0a8 | 2014-04-13 14:09:15 +0200 | [diff] [blame] | 5 | struct device_node; |
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 | |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 15 | struct reset_control *reset_control_get(struct device *dev, const char *id); |
| 16 | void reset_control_put(struct reset_control *rstc); |
| 17 | struct reset_control *devm_reset_control_get(struct device *dev, const char *id); |
| 18 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 19 | int __must_check device_reset(struct device *dev); |
| 20 | |
| 21 | static inline int device_reset_optional(struct device *dev) |
| 22 | { |
| 23 | return device_reset(dev); |
| 24 | } |
| 25 | |
| 26 | static inline struct reset_control *reset_control_get_optional( |
| 27 | struct device *dev, const char *id) |
| 28 | { |
| 29 | return reset_control_get(dev, id); |
| 30 | } |
| 31 | |
| 32 | static inline struct reset_control *devm_reset_control_get_optional( |
| 33 | struct device *dev, const char *id) |
| 34 | { |
| 35 | return devm_reset_control_get(dev, id); |
| 36 | } |
| 37 | |
Hans de Goede | e3ec0a8 | 2014-04-13 14:09:15 +0200 | [diff] [blame] | 38 | struct reset_control *of_reset_control_get(struct device_node *node, |
| 39 | const char *id); |
| 40 | |
Vince Hsu | c0a13aa | 2015-07-13 13:39:39 +0100 | [diff] [blame] | 41 | struct reset_control *of_reset_control_get_by_index( |
| 42 | struct device_node *node, int index); |
| 43 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 44 | #else |
| 45 | |
| 46 | static inline int reset_control_reset(struct reset_control *rstc) |
| 47 | { |
| 48 | WARN_ON(1); |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | static inline int reset_control_assert(struct reset_control *rstc) |
| 53 | { |
| 54 | WARN_ON(1); |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | static inline int reset_control_deassert(struct reset_control *rstc) |
| 59 | { |
| 60 | WARN_ON(1); |
| 61 | return 0; |
| 62 | } |
| 63 | |
Dinh Nguyen | 729de41 | 2014-10-10 10:21:14 -0500 | [diff] [blame] | 64 | static inline int reset_control_status(struct reset_control *rstc) |
| 65 | { |
| 66 | WARN_ON(1); |
| 67 | return 0; |
| 68 | } |
| 69 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 70 | static inline void reset_control_put(struct reset_control *rstc) |
| 71 | { |
| 72 | WARN_ON(1); |
| 73 | } |
| 74 | |
| 75 | static inline int device_reset_optional(struct device *dev) |
| 76 | { |
Philipp Zabel | 39b4da7 | 2015-10-29 09:55:00 +0100 | [diff] [blame] | 77 | return -ENOTSUPP; |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Axel Lin | 5bcd0b7 | 2015-09-01 07:56:38 +0800 | [diff] [blame] | 80 | static inline struct reset_control *__must_check reset_control_get( |
| 81 | struct device *dev, const char *id) |
| 82 | { |
| 83 | WARN_ON(1); |
| 84 | return ERR_PTR(-EINVAL); |
| 85 | } |
| 86 | |
| 87 | static inline struct reset_control *__must_check devm_reset_control_get( |
| 88 | struct device *dev, const char *id) |
| 89 | { |
| 90 | WARN_ON(1); |
| 91 | return ERR_PTR(-EINVAL); |
| 92 | } |
| 93 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 94 | static inline struct reset_control *reset_control_get_optional( |
| 95 | struct device *dev, const char *id) |
| 96 | { |
Philipp Zabel | 39b4da7 | 2015-10-29 09:55:00 +0100 | [diff] [blame] | 97 | return ERR_PTR(-ENOTSUPP); |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | static inline struct reset_control *devm_reset_control_get_optional( |
| 101 | struct device *dev, const char *id) |
| 102 | { |
Philipp Zabel | 39b4da7 | 2015-10-29 09:55:00 +0100 | [diff] [blame] | 103 | return ERR_PTR(-ENOTSUPP); |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 104 | } |
| 105 | |
Hans de Goede | e3ec0a8 | 2014-04-13 14:09:15 +0200 | [diff] [blame] | 106 | static inline struct reset_control *of_reset_control_get( |
| 107 | struct device_node *node, const char *id) |
| 108 | { |
Philipp Zabel | 39b4da7 | 2015-10-29 09:55:00 +0100 | [diff] [blame] | 109 | return ERR_PTR(-ENOTSUPP); |
Hans de Goede | e3ec0a8 | 2014-04-13 14:09:15 +0200 | [diff] [blame] | 110 | } |
| 111 | |
Vince Hsu | c0a13aa | 2015-07-13 13:39:39 +0100 | [diff] [blame] | 112 | static inline struct reset_control *of_reset_control_get_by_index( |
| 113 | struct device_node *node, int index) |
| 114 | { |
| 115 | return ERR_PTR(-ENOTSUPP); |
| 116 | } |
| 117 | |
Philipp Zabel | b424080 | 2014-03-07 15:18:47 +0100 | [diff] [blame] | 118 | #endif /* CONFIG_RESET_CONTROLLER */ |
Philipp Zabel | 61fc413 | 2012-11-19 17:23:13 +0100 | [diff] [blame] | 119 | |
| 120 | #endif |