diff options
Diffstat (limited to 'drivers/reset')
-rw-r--r-- | drivers/reset/Makefile | 1 | ||||
-rw-r--r-- | drivers/reset/core.c | 10 | ||||
-rw-r--r-- | drivers/reset/hisilicon/hi6220_reset.c | 6 | ||||
-rw-r--r-- | drivers/reset/reset-ath79.c | 2 | ||||
-rw-r--r-- | drivers/reset/reset-berlin.c | 5 | ||||
-rw-r--r-- | drivers/reset/reset-lpc18xx.c | 2 | ||||
-rw-r--r-- | drivers/reset/reset-pistachio.c | 154 | ||||
-rw-r--r-- | drivers/reset/reset-socfpga.c | 2 | ||||
-rw-r--r-- | drivers/reset/reset-sunxi.c | 2 | ||||
-rw-r--r-- | drivers/reset/reset-zynq.c | 2 | ||||
-rw-r--r-- | drivers/reset/sti/reset-syscfg.c | 2 |
11 files changed, 170 insertions, 18 deletions
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index 4d7178e46afa..a1fc8eda79f3 100644 --- a/drivers/reset/Makefile +++ b/drivers/reset/Makefile | |||
@@ -2,6 +2,7 @@ obj-y += core.o | |||
2 | obj-$(CONFIG_ARCH_LPC18XX) += reset-lpc18xx.o | 2 | obj-$(CONFIG_ARCH_LPC18XX) += reset-lpc18xx.o |
3 | obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o | 3 | obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o |
4 | obj-$(CONFIG_ARCH_BERLIN) += reset-berlin.o | 4 | obj-$(CONFIG_ARCH_BERLIN) += reset-berlin.o |
5 | obj-$(CONFIG_MACH_PISTACHIO) += reset-pistachio.o | ||
5 | obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o | 6 | obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o |
6 | obj-$(CONFIG_ARCH_STI) += sti/ | 7 | obj-$(CONFIG_ARCH_STI) += sti/ |
7 | obj-$(CONFIG_ARCH_HISI) += hisilicon/ | 8 | obj-$(CONFIG_ARCH_HISI) += hisilicon/ |
diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 87376638948d..f15f150b79da 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c | |||
@@ -45,9 +45,6 @@ struct reset_control { | |||
45 | static int of_reset_simple_xlate(struct reset_controller_dev *rcdev, | 45 | static int of_reset_simple_xlate(struct reset_controller_dev *rcdev, |
46 | const struct of_phandle_args *reset_spec) | 46 | const struct of_phandle_args *reset_spec) |
47 | { | 47 | { |
48 | if (WARN_ON(reset_spec->args_count != rcdev->of_reset_n_cells)) | ||
49 | return -EINVAL; | ||
50 | |||
51 | if (reset_spec->args[0] >= rcdev->nr_resets) | 48 | if (reset_spec->args[0] >= rcdev->nr_resets) |
52 | return -EINVAL; | 49 | return -EINVAL; |
53 | 50 | ||
@@ -152,7 +149,7 @@ EXPORT_SYMBOL_GPL(reset_control_status); | |||
152 | struct reset_control *of_reset_control_get_by_index(struct device_node *node, | 149 | struct reset_control *of_reset_control_get_by_index(struct device_node *node, |
153 | int index) | 150 | int index) |
154 | { | 151 | { |
155 | struct reset_control *rstc = ERR_PTR(-EPROBE_DEFER); | 152 | struct reset_control *rstc; |
156 | struct reset_controller_dev *r, *rcdev; | 153 | struct reset_controller_dev *r, *rcdev; |
157 | struct of_phandle_args args; | 154 | struct of_phandle_args args; |
158 | int rstc_id; | 155 | int rstc_id; |
@@ -178,6 +175,11 @@ struct reset_control *of_reset_control_get_by_index(struct device_node *node, | |||
178 | return ERR_PTR(-EPROBE_DEFER); | 175 | return ERR_PTR(-EPROBE_DEFER); |
179 | } | 176 | } |
180 | 177 | ||
178 | if (WARN_ON(args.args_count != rcdev->of_reset_n_cells)) { | ||
179 | mutex_unlock(&reset_controller_list_mutex); | ||
180 | return ERR_PTR(-EINVAL); | ||
181 | } | ||
182 | |||
181 | rstc_id = rcdev->of_xlate(rcdev, &args); | 183 | rstc_id = rcdev->of_xlate(rcdev, &args); |
182 | if (rstc_id < 0) { | 184 | if (rstc_id < 0) { |
183 | mutex_unlock(&reset_controller_list_mutex); | 185 | mutex_unlock(&reset_controller_list_mutex); |
diff --git a/drivers/reset/hisilicon/hi6220_reset.c b/drivers/reset/hisilicon/hi6220_reset.c index 7787a9b1cc67..8f55fd4a2630 100644 --- a/drivers/reset/hisilicon/hi6220_reset.c +++ b/drivers/reset/hisilicon/hi6220_reset.c | |||
@@ -57,7 +57,7 @@ static int hi6220_reset_deassert(struct reset_controller_dev *rc_dev, | |||
57 | return 0; | 57 | return 0; |
58 | } | 58 | } |
59 | 59 | ||
60 | static struct reset_control_ops hi6220_reset_ops = { | 60 | static const struct reset_control_ops hi6220_reset_ops = { |
61 | .assert = hi6220_reset_assert, | 61 | .assert = hi6220_reset_assert, |
62 | .deassert = hi6220_reset_deassert, | 62 | .deassert = hi6220_reset_deassert, |
63 | }; | 63 | }; |
@@ -83,9 +83,7 @@ static int hi6220_reset_probe(struct platform_device *pdev) | |||
83 | data->rc_dev.ops = &hi6220_reset_ops; | 83 | data->rc_dev.ops = &hi6220_reset_ops; |
84 | data->rc_dev.of_node = pdev->dev.of_node; | 84 | data->rc_dev.of_node = pdev->dev.of_node; |
85 | 85 | ||
86 | reset_controller_register(&data->rc_dev); | 86 | return reset_controller_register(&data->rc_dev); |
87 | |||
88 | return 0; | ||
89 | } | 87 | } |
90 | 88 | ||
91 | static const struct of_device_id hi6220_reset_match[] = { | 89 | static const struct of_device_id hi6220_reset_match[] = { |
diff --git a/drivers/reset/reset-ath79.c b/drivers/reset/reset-ath79.c index 692fc890e94b..ccb940a8d9fb 100644 --- a/drivers/reset/reset-ath79.c +++ b/drivers/reset/reset-ath79.c | |||
@@ -70,7 +70,7 @@ static int ath79_reset_status(struct reset_controller_dev *rcdev, | |||
70 | return !!(val & BIT(id)); | 70 | return !!(val & BIT(id)); |
71 | } | 71 | } |
72 | 72 | ||
73 | static struct reset_control_ops ath79_reset_ops = { | 73 | static const struct reset_control_ops ath79_reset_ops = { |
74 | .assert = ath79_reset_assert, | 74 | .assert = ath79_reset_assert, |
75 | .deassert = ath79_reset_deassert, | 75 | .deassert = ath79_reset_deassert, |
76 | .status = ath79_reset_status, | 76 | .status = ath79_reset_status, |
diff --git a/drivers/reset/reset-berlin.c b/drivers/reset/reset-berlin.c index 970b1ad60293..369f3917fd8e 100644 --- a/drivers/reset/reset-berlin.c +++ b/drivers/reset/reset-berlin.c | |||
@@ -46,7 +46,7 @@ static int berlin_reset_reset(struct reset_controller_dev *rcdev, | |||
46 | return 0; | 46 | return 0; |
47 | } | 47 | } |
48 | 48 | ||
49 | static struct reset_control_ops berlin_reset_ops = { | 49 | static const struct reset_control_ops berlin_reset_ops = { |
50 | .reset = berlin_reset_reset, | 50 | .reset = berlin_reset_reset, |
51 | }; | 51 | }; |
52 | 52 | ||
@@ -55,9 +55,6 @@ static int berlin_reset_xlate(struct reset_controller_dev *rcdev, | |||
55 | { | 55 | { |
56 | unsigned offset, bit; | 56 | unsigned offset, bit; |
57 | 57 | ||
58 | if (WARN_ON(reset_spec->args_count != rcdev->of_reset_n_cells)) | ||
59 | return -EINVAL; | ||
60 | |||
61 | offset = reset_spec->args[0]; | 58 | offset = reset_spec->args[0]; |
62 | bit = reset_spec->args[1]; | 59 | bit = reset_spec->args[1]; |
63 | 60 | ||
diff --git a/drivers/reset/reset-lpc18xx.c b/drivers/reset/reset-lpc18xx.c index 70922e9ac27f..3b8a4f5a1ff6 100644 --- a/drivers/reset/reset-lpc18xx.c +++ b/drivers/reset/reset-lpc18xx.c | |||
@@ -136,7 +136,7 @@ static int lpc18xx_rgu_status(struct reset_controller_dev *rcdev, | |||
136 | return !(readl(rc->base + offset) & bit); | 136 | return !(readl(rc->base + offset) & bit); |
137 | } | 137 | } |
138 | 138 | ||
139 | static struct reset_control_ops lpc18xx_rgu_ops = { | 139 | static const struct reset_control_ops lpc18xx_rgu_ops = { |
140 | .reset = lpc18xx_rgu_reset, | 140 | .reset = lpc18xx_rgu_reset, |
141 | .assert = lpc18xx_rgu_assert, | 141 | .assert = lpc18xx_rgu_assert, |
142 | .deassert = lpc18xx_rgu_deassert, | 142 | .deassert = lpc18xx_rgu_deassert, |
diff --git a/drivers/reset/reset-pistachio.c b/drivers/reset/reset-pistachio.c new file mode 100644 index 000000000000..72a97a15a4c8 --- /dev/null +++ b/drivers/reset/reset-pistachio.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * Pistachio SoC Reset Controller driver | ||
3 | * | ||
4 | * Copyright (C) 2015 Imagination Technologies Ltd. | ||
5 | * | ||
6 | * Author: Damien Horsley <Damien.Horsley@imgtec.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify it | ||
9 | * under the terms and conditions of the GNU General Public License, | ||
10 | * version 2, as published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/of.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/regmap.h> | ||
17 | #include <linux/reset-controller.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/mfd/syscon.h> | ||
20 | |||
21 | #include <dt-bindings/reset/pistachio-resets.h> | ||
22 | |||
23 | #define PISTACHIO_SOFT_RESET 0 | ||
24 | |||
25 | struct pistachio_reset_data { | ||
26 | struct reset_controller_dev rcdev; | ||
27 | struct regmap *periph_regs; | ||
28 | }; | ||
29 | |||
30 | static inline int pistachio_reset_shift(unsigned long id) | ||
31 | { | ||
32 | switch (id) { | ||
33 | case PISTACHIO_RESET_I2C0: | ||
34 | case PISTACHIO_RESET_I2C1: | ||
35 | case PISTACHIO_RESET_I2C2: | ||
36 | case PISTACHIO_RESET_I2C3: | ||
37 | case PISTACHIO_RESET_I2S_IN: | ||
38 | case PISTACHIO_RESET_PRL_OUT: | ||
39 | case PISTACHIO_RESET_SPDIF_OUT: | ||
40 | case PISTACHIO_RESET_SPI: | ||
41 | case PISTACHIO_RESET_PWM_PDM: | ||
42 | case PISTACHIO_RESET_UART0: | ||
43 | case PISTACHIO_RESET_UART1: | ||
44 | case PISTACHIO_RESET_QSPI: | ||
45 | case PISTACHIO_RESET_MDC: | ||
46 | case PISTACHIO_RESET_SDHOST: | ||
47 | case PISTACHIO_RESET_ETHERNET: | ||
48 | case PISTACHIO_RESET_IR: | ||
49 | case PISTACHIO_RESET_HASH: | ||
50 | case PISTACHIO_RESET_TIMER: | ||
51 | return id; | ||
52 | case PISTACHIO_RESET_I2S_OUT: | ||
53 | case PISTACHIO_RESET_SPDIF_IN: | ||
54 | case PISTACHIO_RESET_EVT: | ||
55 | return id + 6; | ||
56 | case PISTACHIO_RESET_USB_H: | ||
57 | case PISTACHIO_RESET_USB_PR: | ||
58 | case PISTACHIO_RESET_USB_PHY_PR: | ||
59 | case PISTACHIO_RESET_USB_PHY_PON: | ||
60 | return id + 7; | ||
61 | default: | ||
62 | return -EINVAL; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | static int pistachio_reset_assert(struct reset_controller_dev *rcdev, | ||
67 | unsigned long id) | ||
68 | { | ||
69 | struct pistachio_reset_data *rd; | ||
70 | u32 mask; | ||
71 | int shift; | ||
72 | |||
73 | rd = container_of(rcdev, struct pistachio_reset_data, rcdev); | ||
74 | shift = pistachio_reset_shift(id); | ||
75 | if (shift < 0) | ||
76 | return shift; | ||
77 | mask = BIT(shift); | ||
78 | |||
79 | return regmap_update_bits(rd->periph_regs, PISTACHIO_SOFT_RESET, | ||
80 | mask, mask); | ||
81 | } | ||
82 | |||
83 | static int pistachio_reset_deassert(struct reset_controller_dev *rcdev, | ||
84 | unsigned long id) | ||
85 | { | ||
86 | struct pistachio_reset_data *rd; | ||
87 | u32 mask; | ||
88 | int shift; | ||
89 | |||
90 | rd = container_of(rcdev, struct pistachio_reset_data, rcdev); | ||
91 | shift = pistachio_reset_shift(id); | ||
92 | if (shift < 0) | ||
93 | return shift; | ||
94 | mask = BIT(shift); | ||
95 | |||
96 | return regmap_update_bits(rd->periph_regs, PISTACHIO_SOFT_RESET, | ||
97 | mask, 0); | ||
98 | } | ||
99 | |||
100 | static const struct reset_control_ops pistachio_reset_ops = { | ||
101 | .assert = pistachio_reset_assert, | ||
102 | .deassert = pistachio_reset_deassert, | ||
103 | }; | ||
104 | |||
105 | static int pistachio_reset_probe(struct platform_device *pdev) | ||
106 | { | ||
107 | struct pistachio_reset_data *rd; | ||
108 | struct device *dev = &pdev->dev; | ||
109 | struct device_node *np = pdev->dev.of_node; | ||
110 | |||
111 | rd = devm_kzalloc(dev, sizeof(*rd), GFP_KERNEL); | ||
112 | if (!rd) | ||
113 | return -ENOMEM; | ||
114 | |||
115 | rd->periph_regs = syscon_node_to_regmap(np->parent); | ||
116 | if (IS_ERR(rd->periph_regs)) | ||
117 | return PTR_ERR(rd->periph_regs); | ||
118 | |||
119 | rd->rcdev.owner = THIS_MODULE; | ||
120 | rd->rcdev.nr_resets = PISTACHIO_RESET_MAX + 1; | ||
121 | rd->rcdev.ops = &pistachio_reset_ops; | ||
122 | rd->rcdev.of_node = np; | ||
123 | |||
124 | return reset_controller_register(&rd->rcdev); | ||
125 | } | ||
126 | |||
127 | static int pistachio_reset_remove(struct platform_device *pdev) | ||
128 | { | ||
129 | struct pistachio_reset_data *data = platform_get_drvdata(pdev); | ||
130 | |||
131 | reset_controller_unregister(&data->rcdev); | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | static const struct of_device_id pistachio_reset_dt_ids[] = { | ||
137 | { .compatible = "img,pistachio-reset", }, | ||
138 | { /* sentinel */ }, | ||
139 | }; | ||
140 | MODULE_DEVICE_TABLE(of, pistachio_reset_dt_ids); | ||
141 | |||
142 | static struct platform_driver pistachio_reset_driver = { | ||
143 | .probe = pistachio_reset_probe, | ||
144 | .remove = pistachio_reset_remove, | ||
145 | .driver = { | ||
146 | .name = "pistachio-reset", | ||
147 | .of_match_table = pistachio_reset_dt_ids, | ||
148 | }, | ||
149 | }; | ||
150 | module_platform_driver(pistachio_reset_driver); | ||
151 | |||
152 | MODULE_AUTHOR("Damien Horsley <Damien.Horsley@imgtec.com>"); | ||
153 | MODULE_DESCRIPTION("Pistacho Reset Controller Driver"); | ||
154 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c index b7d773d9248c..cd05a7032b17 100644 --- a/drivers/reset/reset-socfpga.c +++ b/drivers/reset/reset-socfpga.c | |||
@@ -90,7 +90,7 @@ static int socfpga_reset_status(struct reset_controller_dev *rcdev, | |||
90 | return !(reg & BIT(offset)); | 90 | return !(reg & BIT(offset)); |
91 | } | 91 | } |
92 | 92 | ||
93 | static struct reset_control_ops socfpga_reset_ops = { | 93 | static const struct reset_control_ops socfpga_reset_ops = { |
94 | .assert = socfpga_reset_assert, | 94 | .assert = socfpga_reset_assert, |
95 | .deassert = socfpga_reset_deassert, | 95 | .deassert = socfpga_reset_deassert, |
96 | .status = socfpga_reset_status, | 96 | .status = socfpga_reset_status, |
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index 8d41a18da17f..677f86555212 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c | |||
@@ -70,7 +70,7 @@ static int sunxi_reset_deassert(struct reset_controller_dev *rcdev, | |||
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | static struct reset_control_ops sunxi_reset_ops = { | 73 | static const struct reset_control_ops sunxi_reset_ops = { |
74 | .assert = sunxi_reset_assert, | 74 | .assert = sunxi_reset_assert, |
75 | .deassert = sunxi_reset_deassert, | 75 | .deassert = sunxi_reset_deassert, |
76 | }; | 76 | }; |
diff --git a/drivers/reset/reset-zynq.c b/drivers/reset/reset-zynq.c index c6b3cd8b40ad..a7e87bc45885 100644 --- a/drivers/reset/reset-zynq.c +++ b/drivers/reset/reset-zynq.c | |||
@@ -86,7 +86,7 @@ static int zynq_reset_status(struct reset_controller_dev *rcdev, | |||
86 | return !!(reg & BIT(offset)); | 86 | return !!(reg & BIT(offset)); |
87 | } | 87 | } |
88 | 88 | ||
89 | static struct reset_control_ops zynq_reset_ops = { | 89 | static const struct reset_control_ops zynq_reset_ops = { |
90 | .assert = zynq_reset_assert, | 90 | .assert = zynq_reset_assert, |
91 | .deassert = zynq_reset_deassert, | 91 | .deassert = zynq_reset_deassert, |
92 | .status = zynq_reset_status, | 92 | .status = zynq_reset_status, |
diff --git a/drivers/reset/sti/reset-syscfg.c b/drivers/reset/sti/reset-syscfg.c index 1600cc7557f5..9bd57a5eee72 100644 --- a/drivers/reset/sti/reset-syscfg.c +++ b/drivers/reset/sti/reset-syscfg.c | |||
@@ -134,7 +134,7 @@ static int syscfg_reset_status(struct reset_controller_dev *rcdev, | |||
134 | return rst->active_low ? !ret_val : !!ret_val; | 134 | return rst->active_low ? !ret_val : !!ret_val; |
135 | } | 135 | } |
136 | 136 | ||
137 | static struct reset_control_ops syscfg_reset_ops = { | 137 | static const struct reset_control_ops syscfg_reset_ops = { |
138 | .reset = syscfg_reset_dev, | 138 | .reset = syscfg_reset_dev, |
139 | .assert = syscfg_reset_assert, | 139 | .assert = syscfg_reset_assert, |
140 | .deassert = syscfg_reset_deassert, | 140 | .deassert = syscfg_reset_deassert, |