1 From 0325b48d6149e131c90ed6ec77458f4d2df73898 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime.ripard@free-electrons.com>
3 Date: Fri, 20 Dec 2013 22:41:07 +0100
4 Subject: [PATCH] reset: Add of_reset_control_get
6 In some cases, you might need to deassert from reset an hardware block that
7 doesn't associated to a struct device (CPUs, timers, etc.).
9 Add a small helper to retrieve the reset controller from the device tree
10 without the need to pass a struct device.
12 Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
14 drivers/reset/core.c | 39 ++++++++++++++++++++++++++++++---------
15 include/linux/reset.h | 4 ++++
16 2 files changed, 34 insertions(+), 9 deletions(-)
18 --- a/drivers/reset/core.c
19 +++ b/drivers/reset/core.c
20 @@ -127,15 +127,16 @@ int reset_control_deassert(struct reset_
21 EXPORT_SYMBOL_GPL(reset_control_deassert);
24 - * reset_control_get - Lookup and obtain a reference to a reset controller.
25 - * @dev: device to be reset by the controller
26 + * of_reset_control_get - Lookup and obtain a reference to a reset controller.
27 + * @node: device to be reset by the controller
28 * @id: reset line name
30 * Returns a struct reset_control or IS_ERR() condition containing errno.
32 * Use of id names is optional.
34 -struct reset_control *reset_control_get(struct device *dev, const char *id)
35 +struct reset_control *of_reset_control_get(struct device_node *node,
38 struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER);
39 struct reset_controller_dev *r, *rcdev;
40 @@ -144,13 +145,10 @@ struct reset_control *reset_control_get(
45 - return ERR_PTR(-EINVAL);
48 - index = of_property_match_string(dev->of_node,
49 + index = of_property_match_string(node,
51 - ret = of_parse_phandle_with_args(dev->of_node, "resets", "#reset-cells",
52 + ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
56 @@ -185,12 +183,35 @@ struct reset_control *reset_control_get(
57 return ERR_PTR(-ENOMEM);
66 +EXPORT_SYMBOL_GPL(of_reset_control_get);
69 + * reset_control_get - Lookup and obtain a reference to a reset controller.
70 + * @dev: device to be reset by the controller
71 + * @id: reset line name
73 + * Returns a struct reset_control or IS_ERR() condition containing errno.
75 + * Use of id names is optional.
77 +struct reset_control *reset_control_get(struct device *dev, const char *id)
79 + struct reset_control *rstc;
82 + return ERR_PTR(-EINVAL);
84 + rstc = of_reset_control_get(dev->of_node, id);
90 EXPORT_SYMBOL_GPL(reset_control_get);
93 --- a/include/linux/reset.h
94 +++ b/include/linux/reset.h
96 #ifndef _LINUX_RESET_H_
97 #define _LINUX_RESET_H_
99 +#include <linux/of.h>
102 struct reset_control;
104 @@ -8,6 +10,8 @@ int reset_control_reset(struct reset_con
105 int reset_control_assert(struct reset_control *rstc);
106 int reset_control_deassert(struct reset_control *rstc);
108 +struct reset_control *of_reset_control_get(struct device_node *node,
110 struct reset_control *reset_control_get(struct device *dev, const char *id);
111 void reset_control_put(struct reset_control *rstc);
112 struct reset_control *devm_reset_control_get(struct device *dev, const char *id);