diff options
author | Dinh Nguyen <dinguyen@opensource.altera.com> | 2014-10-10 11:21:14 -0400 |
---|---|---|
committer | Philipp Zabel <p.zabel@pengutronix.de> | 2014-10-20 04:11:29 -0400 |
commit | 729de41baf63e2172b9d61de61bbd53f231095ca (patch) | |
tree | 8c04f97eb59f6cd90977f87b5476ec6711546730 | |
parent | f114040e3ea6e07372334ade75d1ee0775c355e1 (diff) |
reset: add reset_control_status helper function
There are cases where a system will want to read a reset status bit before
doing any other toggling. Add a reset_control_status helper function to the
reset controller API.
Signed-off-by: Dinh Nguyen <dinguyen@opensource.altera.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
-rw-r--r-- | drivers/reset/core.c | 15 | ||||
-rw-r--r-- | include/linux/reset-controller.h | 2 | ||||
-rw-r--r-- | include/linux/reset.h | 7 |
3 files changed, 24 insertions, 0 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c index baeaf82d40d9..7955e00d04d4 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c | |||
@@ -126,6 +126,21 @@ int reset_control_deassert(struct reset_control *rstc) | |||
126 | EXPORT_SYMBOL_GPL(reset_control_deassert); | 126 | EXPORT_SYMBOL_GPL(reset_control_deassert); |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * reset_control_status - returns a negative errno if not supported, a | ||
130 | * positive value if the reset line is asserted, or zero if the reset | ||
131 | * line is not asserted. | ||
132 | * @rstc: reset controller | ||
133 | */ | ||
134 | int reset_control_status(struct reset_control *rstc) | ||
135 | { | ||
136 | if (rstc->rcdev->ops->status) | ||
137 | return rstc->rcdev->ops->status(rstc->rcdev, rstc->id); | ||
138 | |||
139 | return -ENOSYS; | ||
140 | } | ||
141 | EXPORT_SYMBOL_GPL(reset_control_status); | ||
142 | |||
143 | /** | ||
129 | * of_reset_control_get - Lookup and obtain a reference to a reset controller. | 144 | * of_reset_control_get - Lookup and obtain a reference to a reset controller. |
130 | * @node: device to be reset by the controller | 145 | * @node: device to be reset by the controller |
131 | * @id: reset line name | 146 | * @id: reset line name |
diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h index 41a4695fde08..ce6b962ffed4 100644 --- a/include/linux/reset-controller.h +++ b/include/linux/reset-controller.h | |||
@@ -12,11 +12,13 @@ struct reset_controller_dev; | |||
12 | * things to reset the device | 12 | * things to reset the device |
13 | * @assert: manually assert the reset line, if supported | 13 | * @assert: manually assert the reset line, if supported |
14 | * @deassert: manually deassert the reset line, if supported | 14 | * @deassert: manually deassert the reset line, if supported |
15 | * @status: return the status of the reset line, if supported | ||
15 | */ | 16 | */ |
16 | struct reset_control_ops { | 17 | struct reset_control_ops { |
17 | int (*reset)(struct reset_controller_dev *rcdev, unsigned long id); | 18 | int (*reset)(struct reset_controller_dev *rcdev, unsigned long id); |
18 | int (*assert)(struct reset_controller_dev *rcdev, unsigned long id); | 19 | int (*assert)(struct reset_controller_dev *rcdev, unsigned long id); |
19 | int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id); | 20 | int (*deassert)(struct reset_controller_dev *rcdev, unsigned long id); |
21 | int (*status)(struct reset_controller_dev *rcdev, unsigned long id); | ||
20 | }; | 22 | }; |
21 | 23 | ||
22 | struct module; | 24 | struct module; |
diff --git a/include/linux/reset.h b/include/linux/reset.h index 349f150ae12c..da5602bd77d7 100644 --- a/include/linux/reset.h +++ b/include/linux/reset.h | |||
@@ -10,6 +10,7 @@ struct reset_control; | |||
10 | int reset_control_reset(struct reset_control *rstc); | 10 | int reset_control_reset(struct reset_control *rstc); |
11 | int reset_control_assert(struct reset_control *rstc); | 11 | int reset_control_assert(struct reset_control *rstc); |
12 | int reset_control_deassert(struct reset_control *rstc); | 12 | int reset_control_deassert(struct reset_control *rstc); |
13 | int reset_control_status(struct reset_control *rstc); | ||
13 | 14 | ||
14 | struct reset_control *reset_control_get(struct device *dev, const char *id); | 15 | struct reset_control *reset_control_get(struct device *dev, const char *id); |
15 | void reset_control_put(struct reset_control *rstc); | 16 | void reset_control_put(struct reset_control *rstc); |
@@ -57,6 +58,12 @@ static inline int reset_control_deassert(struct reset_control *rstc) | |||
57 | return 0; | 58 | return 0; |
58 | } | 59 | } |
59 | 60 | ||
61 | static inline int reset_control_status(struct reset_control *rstc) | ||
62 | { | ||
63 | WARN_ON(1); | ||
64 | return 0; | ||
65 | } | ||
66 | |||
60 | static inline void reset_control_put(struct reset_control *rstc) | 67 | static inline void reset_control_put(struct reset_control *rstc) |
61 | { | 68 | { |
62 | WARN_ON(1); | 69 | WARN_ON(1); |