diff options
author | Antoine Tenart <antoine.tenart@free-electrons.com> | 2015-05-15 18:41:25 -0400 |
---|---|---|
committer | Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> | 2015-05-18 11:52:36 -0400 |
commit | aed6f3cadc860ddeec598ed82041c1f3773071b1 (patch) | |
tree | c2fc81b12b390ae6b4d7b09e667493a30e659188 /drivers/reset/reset-berlin.c | |
parent | ffcc33a5d496d03a0ccd7542f9b65a7aec67072d (diff) |
reset: berlin: convert to a platform driver
The Berlin reset controller was introduced without being a platform
driver because of a needed DT rework: the node describing the reset
controller also describes the pinctrl and clk controllers...
Prepare conversion by adding a platform driver probe to a new
compatible "marvell,berlin2-reset" with syscon regmap.
Signed-off-by: Antoine Tenart <antoine.tenart@free-electrons.com>
Acked-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Diffstat (limited to 'drivers/reset/reset-berlin.c')
-rw-r--r-- | drivers/reset/reset-berlin.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c index f8b48a13cf0b..d43bc163dd02 100644 --- a/drivers/reset/reset-berlin.c +++ b/drivers/reset/reset-berlin.c | |||
@@ -11,10 +11,12 @@ | |||
11 | 11 | ||
12 | #include <linux/delay.h> | 12 | #include <linux/delay.h> |
13 | #include <linux/io.h> | 13 | #include <linux/io.h> |
14 | #include <linux/mfd/syscon.h> | ||
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/of.h> | 16 | #include <linux/of.h> |
16 | #include <linux/of_address.h> | 17 | #include <linux/of_address.h> |
17 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
19 | #include <linux/regmap.h> | ||
18 | #include <linux/reset-controller.h> | 20 | #include <linux/reset-controller.h> |
19 | #include <linux/slab.h> | 21 | #include <linux/slab.h> |
20 | #include <linux/types.h> | 22 | #include <linux/types.h> |
@@ -27,6 +29,7 @@ | |||
27 | struct berlin_reset_priv { | 29 | struct berlin_reset_priv { |
28 | void __iomem *base; | 30 | void __iomem *base; |
29 | unsigned int size; | 31 | unsigned int size; |
32 | struct regmap *regmap; | ||
30 | struct reset_controller_dev rcdev; | 33 | struct reset_controller_dev rcdev; |
31 | }; | 34 | }; |
32 | 35 | ||
@@ -37,7 +40,10 @@ static int berlin_reset_reset(struct reset_controller_dev *rcdev, | |||
37 | int offset = id >> 8; | 40 | int offset = id >> 8; |
38 | int mask = BIT(id & 0x1f); | 41 | int mask = BIT(id & 0x1f); |
39 | 42 | ||
40 | writel(mask, priv->base + offset); | 43 | if (priv->regmap) |
44 | regmap_write(priv->regmap, offset, mask); | ||
45 | else | ||
46 | writel(mask, priv->base + offset); | ||
41 | 47 | ||
42 | /* let the reset be effective */ | 48 | /* let the reset be effective */ |
43 | udelay(10); | 49 | udelay(10); |
@@ -70,6 +76,51 @@ static int berlin_reset_xlate(struct reset_controller_dev *rcdev, | |||
70 | return (offset << 8) | bit; | 76 | return (offset << 8) | bit; |
71 | } | 77 | } |
72 | 78 | ||
79 | static int berlin2_reset_probe(struct platform_device *pdev) | ||
80 | { | ||
81 | struct device_node *parent_np = of_get_parent(pdev->dev.of_node); | ||
82 | struct berlin_reset_priv *priv; | ||
83 | |||
84 | priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); | ||
85 | if (!priv) | ||
86 | return -ENOMEM; | ||
87 | |||
88 | priv->regmap = syscon_node_to_regmap(parent_np); | ||
89 | of_node_put(parent_np); | ||
90 | if (IS_ERR(priv->regmap)) | ||
91 | return PTR_ERR(priv->regmap); | ||
92 | |||
93 | priv->rcdev.owner = THIS_MODULE; | ||
94 | priv->rcdev.ops = &berlin_reset_ops; | ||
95 | priv->rcdev.of_node = pdev->dev.of_node; | ||
96 | priv->rcdev.of_reset_n_cells = 2; | ||
97 | priv->rcdev.of_xlate = berlin_reset_xlate; | ||
98 | |||
99 | reset_controller_register(&priv->rcdev); | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | |||
104 | static const struct of_device_id berlin_reset_dt_match[] = { | ||
105 | { .compatible = "marvell,berlin2-reset" }, | ||
106 | { }, | ||
107 | }; | ||
108 | MODULE_DEVICE_TABLE(of, berlin_reset_dt_match); | ||
109 | |||
110 | static struct platform_driver berlin_reset_driver = { | ||
111 | .probe = berlin2_reset_probe, | ||
112 | .driver = { | ||
113 | .name = "berlin2-reset", | ||
114 | .of_match_table = berlin_reset_dt_match, | ||
115 | }, | ||
116 | }; | ||
117 | module_platform_driver(berlin_reset_driver); | ||
118 | |||
119 | MODULE_AUTHOR("Antoine Tenart <antoine.tenart@free-electrons.com>"); | ||
120 | MODULE_AUTHOR("Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>"); | ||
121 | MODULE_DESCRIPTION("Marvell Berlin reset driver"); | ||
122 | MODULE_LICENSE("GPL"); | ||
123 | |||
73 | static int __berlin_reset_init(struct device_node *np) | 124 | static int __berlin_reset_init(struct device_node *np) |
74 | { | 125 | { |
75 | struct berlin_reset_priv *priv; | 126 | struct berlin_reset_priv *priv; |