aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlof Johansson <olof@lixom.net>2017-01-29 17:29:23 -0500
committerOlof Johansson <olof@lixom.net>2017-01-29 17:29:23 -0500
commita6589b44b077bcd615127aa1e574564029c8f4b1 (patch)
treee3a7c1b7ffb1c5000652aebe0aa16746ab60bae9
parent0ff6454b2aa09c5ec0ba9007704a7706d476e2c8 (diff)
parentbb475230b8e59a547ab66ac3b02572df21a580e9 (diff)
Merge tag 'reset-for-4.11' of git://git.pengutronix.de/pza/linux into next/drivers
Reset controller changes for v4.11 - fix ti_syscon reset_status reporting - add Hisilicon Hi3660 reset controller driver - add ZTE ZX2967 reset controller driver - add LD11 SD-reset block to uniphier reset controller driver - typo and correctness fixes - make reset_control_get variants return NULL instead of an error for optional, not specified resets and have the other reset API functions silently ignore rstc == NULL parameters. * tag 'reset-for-4.11' of git://git.pengutronix.de/pza/linux: reset: make optional functions really optional reset: Change shared flag from int to bool reset: uniphier: add compatible string for LD11 SD-reset block reset: zx2967: add reset controller driver for ZTE's zx2967 family MAINTAINERS: add zx2967 reset controller driver to ARM ZTE architecture dt: bindings: add documentation for zx2967 family reset controller Documentation: dt: reset: Revise typos in TI syscon reset example reset: constify reset_control_ops structures reset: hisilicon: add reset-hi3660 dt-bindings: Document the hi3660 reset bindings reset: ti_syscon: fix a ti_syscon_reset_status issue Signed-off-by: Olof Johansson <olof@lixom.net>
-rw-r--r--Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt43
-rw-r--r--Documentation/devicetree/bindings/reset/ti-syscon-reset.txt8
-rw-r--r--Documentation/devicetree/bindings/reset/uniphier-reset.txt47
-rw-r--r--Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt20
-rw-r--r--MAINTAINERS2
-rw-r--r--drivers/reset/Kconfig6
-rw-r--r--drivers/reset/Makefile1
-rw-r--r--drivers/reset/core.c53
-rw-r--r--drivers/reset/hisilicon/Kconfig7
-rw-r--r--drivers/reset/hisilicon/Makefile1
-rw-r--r--drivers/reset/hisilicon/reset-hi3660.c126
-rw-r--r--drivers/reset/reset-ti-syscon.c6
-rw-r--r--drivers/reset/reset-uniphier.c4
-rw-r--r--drivers/reset/reset-zx2967.c106
-rw-r--r--include/linux/reset.h45
15 files changed, 414 insertions, 61 deletions
diff --git a/Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt b/Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt
new file mode 100644
index 000000000000..2bf3344b2a02
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/hisilicon,hi3660-reset.txt
@@ -0,0 +1,43 @@
1Hisilicon System Reset Controller
2======================================
3
4Please also refer to reset.txt in this directory for common reset
5controller binding usage.
6
7The reset controller registers are part of the system-ctl block on
8hi3660 SoC.
9
10Required properties:
11- compatible: should be
12 "hisilicon,hi3660-reset"
13- hisi,rst-syscon: phandle of the reset's syscon.
14- #reset-cells : Specifies the number of cells needed to encode a
15 reset source. The type shall be a <u32> and the value shall be 2.
16
17 Cell #1 : offset of the reset assert control
18 register from the syscon register base
19 offset + 4: deassert control register
20 offset + 8: status control register
21 Cell #2 : bit position of the reset in the reset control register
22
23Example:
24 iomcu: iomcu@ffd7e000 {
25 compatible = "hisilicon,hi3660-iomcu", "syscon";
26 reg = <0x0 0xffd7e000 0x0 0x1000>;
27 };
28
29 iomcu_rst: iomcu_rst_controller {
30 compatible = "hisilicon,hi3660-reset";
31 hisi,rst-syscon = <&iomcu>;
32 #reset-cells = <2>;
33 };
34
35Specifying reset lines connected to IP modules
36==============================================
37example:
38
39 i2c0: i2c@..... {
40 ...
41 resets = <&iomcu_rst 0x20 3>; /* offset: 0x20; bit: 3 */
42 ...
43 };
diff --git a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
index 164c7f34c451..c516d24959f2 100644
--- a/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
+++ b/Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
@@ -63,7 +63,7 @@ Example:
63-------- 63--------
64The following example demonstrates a syscon node, the reset controller node 64The following example demonstrates a syscon node, the reset controller node
65using the syscon node, and a consumer (a DSP device) on the TI Keystone 2 65using the syscon node, and a consumer (a DSP device) on the TI Keystone 2
66Edison SoC. 6666AK2E SoC.
67 67
68/ { 68/ {
69 soc { 69 soc {
@@ -71,13 +71,13 @@ Edison SoC.
71 compatible = "syscon", "simple-mfd"; 71 compatible = "syscon", "simple-mfd";
72 reg = <0x02350000 0x1000>; 72 reg = <0x02350000 0x1000>;
73 73
74 pscrst: psc-reset { 74 pscrst: reset-controller {
75 compatible = "ti,k2e-pscrst", "ti,syscon-reset"; 75 compatible = "ti,k2e-pscrst", "ti,syscon-reset";
76 #reset-cells = <1>; 76 #reset-cells = <1>;
77 77
78 ti,reset-bits = < 78 ti,reset-bits = <
79 0xa3c 8 0xa3c 8 0x83c 8 (ASSERT_SET|DEASSERT_CLEAR|STATUS_SET) /* 0: pcrst-dsp0 */ 79 0xa3c 8 0xa3c 8 0x83c 8 (ASSERT_CLEAR | DEASSERT_SET | STATUS_CLEAR) /* 0: dsp0 */
80 0xa40 5 0xa44 3 0 0 (ASSERT_SET|DEASSERT_CLEAR|STATUS_NONE) /* 1: pcrst-example */ 80 0xa40 5 0xa44 3 0 0 (ASSERT_SET | DEASSERT_CLEAR | STATUS_NONE) /* 1: example */
81 >; 81 >;
82 }; 82 };
83 }; 83 };
diff --git a/Documentation/devicetree/bindings/reset/uniphier-reset.txt b/Documentation/devicetree/bindings/reset/uniphier-reset.txt
index 5020524cddeb..83ab0f599c40 100644
--- a/Documentation/devicetree/bindings/reset/uniphier-reset.txt
+++ b/Documentation/devicetree/bindings/reset/uniphier-reset.txt
@@ -6,14 +6,14 @@ System reset
6 6
7Required properties: 7Required properties:
8- compatible: should be one of the following: 8- compatible: should be one of the following:
9 "socionext,uniphier-sld3-reset" - for sLD3 SoC. 9 "socionext,uniphier-sld3-reset" - for sLD3 SoC
10 "socionext,uniphier-ld4-reset" - for LD4 SoC. 10 "socionext,uniphier-ld4-reset" - for LD4 SoC
11 "socionext,uniphier-pro4-reset" - for Pro4 SoC. 11 "socionext,uniphier-pro4-reset" - for Pro4 SoC
12 "socionext,uniphier-sld8-reset" - for sLD8 SoC. 12 "socionext,uniphier-sld8-reset" - for sLD8 SoC
13 "socionext,uniphier-pro5-reset" - for Pro5 SoC. 13 "socionext,uniphier-pro5-reset" - for Pro5 SoC
14 "socionext,uniphier-pxs2-reset" - for PXs2/LD6b SoC. 14 "socionext,uniphier-pxs2-reset" - for PXs2/LD6b SoC
15 "socionext,uniphier-ld11-reset" - for LD11 SoC. 15 "socionext,uniphier-ld11-reset" - for LD11 SoC
16 "socionext,uniphier-ld20-reset" - for LD20 SoC. 16 "socionext,uniphier-ld20-reset" - for LD20 SoC
17- #reset-cells: should be 1. 17- #reset-cells: should be 1.
18 18
19Example: 19Example:
@@ -37,14 +37,15 @@ Media I/O (MIO) reset, SD reset
37 37
38Required properties: 38Required properties:
39- compatible: should be one of the following: 39- compatible: should be one of the following:
40 "socionext,uniphier-sld3-mio-reset" - for sLD3 SoC. 40 "socionext,uniphier-sld3-mio-reset" - for sLD3 SoC
41 "socionext,uniphier-ld4-mio-reset" - for LD4 SoC. 41 "socionext,uniphier-ld4-mio-reset" - for LD4 SoC
42 "socionext,uniphier-pro4-mio-reset" - for Pro4 SoC. 42 "socionext,uniphier-pro4-mio-reset" - for Pro4 SoC
43 "socionext,uniphier-sld8-mio-reset" - for sLD8 SoC. 43 "socionext,uniphier-sld8-mio-reset" - for sLD8 SoC
44 "socionext,uniphier-pro5-sd-reset" - for Pro5 SoC. 44 "socionext,uniphier-pro5-sd-reset" - for Pro5 SoC
45 "socionext,uniphier-pxs2-sd-reset" - for PXs2/LD6b SoC. 45 "socionext,uniphier-pxs2-sd-reset" - for PXs2/LD6b SoC
46 "socionext,uniphier-ld11-mio-reset" - for LD11 SoC. 46 "socionext,uniphier-ld11-mio-reset" - for LD11 SoC (MIO)
47 "socionext,uniphier-ld20-sd-reset" - for LD20 SoC. 47 "socionext,uniphier-ld11-sd-reset" - for LD11 SoC (SD)
48 "socionext,uniphier-ld20-sd-reset" - for LD20 SoC
48- #reset-cells: should be 1. 49- #reset-cells: should be 1.
49 50
50Example: 51Example:
@@ -68,13 +69,13 @@ Peripheral reset
68 69
69Required properties: 70Required properties:
70- compatible: should be one of the following: 71- compatible: should be one of the following:
71 "socionext,uniphier-ld4-peri-reset" - for LD4 SoC. 72 "socionext,uniphier-ld4-peri-reset" - for LD4 SoC
72 "socionext,uniphier-pro4-peri-reset" - for Pro4 SoC. 73 "socionext,uniphier-pro4-peri-reset" - for Pro4 SoC
73 "socionext,uniphier-sld8-peri-reset" - for sLD8 SoC. 74 "socionext,uniphier-sld8-peri-reset" - for sLD8 SoC
74 "socionext,uniphier-pro5-peri-reset" - for Pro5 SoC. 75 "socionext,uniphier-pro5-peri-reset" - for Pro5 SoC
75 "socionext,uniphier-pxs2-peri-reset" - for PXs2/LD6b SoC. 76 "socionext,uniphier-pxs2-peri-reset" - for PXs2/LD6b SoC
76 "socionext,uniphier-ld11-peri-reset" - for LD11 SoC. 77 "socionext,uniphier-ld11-peri-reset" - for LD11 SoC
77 "socionext,uniphier-ld20-peri-reset" - for LD20 SoC. 78 "socionext,uniphier-ld20-peri-reset" - for LD20 SoC
78- #reset-cells: should be 1. 79- #reset-cells: should be 1.
79 80
80Example: 81Example:
diff --git a/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
new file mode 100644
index 000000000000..b015508f9780
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
@@ -0,0 +1,20 @@
1ZTE zx2967 SoCs Reset Controller
2=======================================
3
4Please also refer to reset.txt in this directory for common reset
5controller binding usage.
6
7Required properties:
8- compatible: should be one of the following.
9 * zte,zx296718-reset
10- reg: physical base address of the controller and length of memory mapped
11 region.
12- #reset-cells: must be 1.
13
14example:
15
16 reset: reset-controller@1461060 {
17 compatible = "zte,zx296718-reset";
18 reg = <0x01461060 0x8>;
19 #reset-cells = <1>;
20 };
diff --git a/MAINTAINERS b/MAINTAINERS
index 5f0420a0da5b..0b1b2687bc04 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1985,8 +1985,10 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
1985S: Maintained 1985S: Maintained
1986F: arch/arm/mach-zx/ 1986F: arch/arm/mach-zx/
1987F: drivers/clk/zte/ 1987F: drivers/clk/zte/
1988F: drivers/reset/reset-zx2967.c
1988F: Documentation/devicetree/bindings/arm/zte.txt 1989F: Documentation/devicetree/bindings/arm/zte.txt
1989F: Documentation/devicetree/bindings/clock/zx296702-clk.txt 1990F: Documentation/devicetree/bindings/clock/zx296702-clk.txt
1991F: Documentation/devicetree/bindings/reset/zte,zx2967-reset.txt
1990 1992
1991ARM/ZYNQ ARCHITECTURE 1993ARM/ZYNQ ARCHITECTURE
1992M: Michal Simek <michal.simek@xilinx.com> 1994M: Michal Simek <michal.simek@xilinx.com>
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 172dc966a01f..f4cdfe94b9ec 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -86,6 +86,12 @@ config RESET_UNIPHIER
86 Say Y if you want to control reset signals provided by System Control 86 Say Y if you want to control reset signals provided by System Control
87 block, Media I/O block, Peripheral Block. 87 block, Media I/O block, Peripheral Block.
88 88
89config RESET_ZX2967
90 bool "ZTE ZX2967 Reset Driver"
91 depends on ARCH_ZX || COMPILE_TEST
92 help
93 This enables the reset controller driver for ZTE's zx2967 family.
94
89config RESET_ZYNQ 95config RESET_ZYNQ
90 bool "ZYNQ Reset Driver" if COMPILE_TEST 96 bool "ZYNQ Reset Driver" if COMPILE_TEST
91 default ARCH_ZYNQ 97 default ARCH_ZYNQ
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index 13b346e03d84..2cd3f6c45165 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -13,4 +13,5 @@ obj-$(CONFIG_RESET_STM32) += reset-stm32.o
13obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o 13obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
14obj-$(CONFIG_TI_SYSCON_RESET) += reset-ti-syscon.o 14obj-$(CONFIG_TI_SYSCON_RESET) += reset-ti-syscon.o
15obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o 15obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
16obj-$(CONFIG_RESET_ZX2967) += reset-zx2967.o
16obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o 17obj-$(CONFIG_RESET_ZYNQ) += reset-zynq.o
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 10368ed8fd13..c79cce3a7b6d 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -41,7 +41,7 @@ struct reset_control {
41 struct list_head list; 41 struct list_head list;
42 unsigned int id; 42 unsigned int id;
43 unsigned int refcnt; 43 unsigned int refcnt;
44 int shared; 44 bool shared;
45 atomic_t deassert_count; 45 atomic_t deassert_count;
46 atomic_t triggered_count; 46 atomic_t triggered_count;
47}; 47};
@@ -143,12 +143,18 @@ EXPORT_SYMBOL_GPL(devm_reset_controller_register);
143 * a no-op. 143 * a no-op.
144 * Consumers must not use reset_control_(de)assert on shared reset lines when 144 * Consumers must not use reset_control_(de)assert on shared reset lines when
145 * reset_control_reset has been used. 145 * reset_control_reset has been used.
146 *
147 * If rstc is NULL it is an optional reset and the function will just
148 * return 0.
146 */ 149 */
147int reset_control_reset(struct reset_control *rstc) 150int reset_control_reset(struct reset_control *rstc)
148{ 151{
149 int ret; 152 int ret;
150 153
151 if (WARN_ON(IS_ERR_OR_NULL(rstc))) 154 if (!rstc)
155 return 0;
156
157 if (WARN_ON(IS_ERR(rstc)))
152 return -EINVAL; 158 return -EINVAL;
153 159
154 if (!rstc->rcdev->ops->reset) 160 if (!rstc->rcdev->ops->reset)
@@ -182,10 +188,17 @@ EXPORT_SYMBOL_GPL(reset_control_reset);
182 * internal state to be reset, but must be prepared for this to happen. 188 * internal state to be reset, but must be prepared for this to happen.
183 * Consumers must not use reset_control_reset on shared reset lines when 189 * Consumers must not use reset_control_reset on shared reset lines when
184 * reset_control_(de)assert has been used. 190 * reset_control_(de)assert has been used.
191 * return 0.
192 *
193 * If rstc is NULL it is an optional reset and the function will just
194 * return 0.
185 */ 195 */
186int reset_control_assert(struct reset_control *rstc) 196int reset_control_assert(struct reset_control *rstc)
187{ 197{
188 if (WARN_ON(IS_ERR_OR_NULL(rstc))) 198 if (!rstc)
199 return 0;
200
201 if (WARN_ON(IS_ERR(rstc)))
189 return -EINVAL; 202 return -EINVAL;
190 203
191 if (!rstc->rcdev->ops->assert) 204 if (!rstc->rcdev->ops->assert)
@@ -213,10 +226,17 @@ EXPORT_SYMBOL_GPL(reset_control_assert);
213 * After calling this function, the reset is guaranteed to be deasserted. 226 * After calling this function, the reset is guaranteed to be deasserted.
214 * Consumers must not use reset_control_reset on shared reset lines when 227 * Consumers must not use reset_control_reset on shared reset lines when
215 * reset_control_(de)assert has been used. 228 * reset_control_(de)assert has been used.
229 * return 0.
230 *
231 * If rstc is NULL it is an optional reset and the function will just
232 * return 0.
216 */ 233 */
217int reset_control_deassert(struct reset_control *rstc) 234int reset_control_deassert(struct reset_control *rstc)
218{ 235{
219 if (WARN_ON(IS_ERR_OR_NULL(rstc))) 236 if (!rstc)
237 return 0;
238
239 if (WARN_ON(IS_ERR(rstc)))
220 return -EINVAL; 240 return -EINVAL;
221 241
222 if (!rstc->rcdev->ops->deassert) 242 if (!rstc->rcdev->ops->deassert)
@@ -237,12 +257,15 @@ EXPORT_SYMBOL_GPL(reset_control_deassert);
237/** 257/**
238 * reset_control_status - returns a negative errno if not supported, a 258 * reset_control_status - returns a negative errno if not supported, a
239 * positive value if the reset line is asserted, or zero if the reset 259 * positive value if the reset line is asserted, or zero if the reset
240 * line is not asserted. 260 * line is not asserted or if the desc is NULL (optional reset).
241 * @rstc: reset controller 261 * @rstc: reset controller
242 */ 262 */
243int reset_control_status(struct reset_control *rstc) 263int reset_control_status(struct reset_control *rstc)
244{ 264{
245 if (WARN_ON(IS_ERR_OR_NULL(rstc))) 265 if (!rstc)
266 return 0;
267
268 if (WARN_ON(IS_ERR(rstc)))
246 return -EINVAL; 269 return -EINVAL;
247 270
248 if (rstc->rcdev->ops->status) 271 if (rstc->rcdev->ops->status)
@@ -254,7 +277,7 @@ EXPORT_SYMBOL_GPL(reset_control_status);
254 277
255static struct reset_control *__reset_control_get( 278static struct reset_control *__reset_control_get(
256 struct reset_controller_dev *rcdev, 279 struct reset_controller_dev *rcdev,
257 unsigned int index, int shared) 280 unsigned int index, bool shared)
258{ 281{
259 struct reset_control *rstc; 282 struct reset_control *rstc;
260 283
@@ -299,7 +322,8 @@ static void __reset_control_put(struct reset_control *rstc)
299} 322}
300 323
301struct reset_control *__of_reset_control_get(struct device_node *node, 324struct reset_control *__of_reset_control_get(struct device_node *node,
302 const char *id, int index, int shared) 325 const char *id, int index, bool shared,
326 bool optional)
303{ 327{
304 struct reset_control *rstc; 328 struct reset_control *rstc;
305 struct reset_controller_dev *r, *rcdev; 329 struct reset_controller_dev *r, *rcdev;
@@ -313,14 +337,18 @@ struct reset_control *__of_reset_control_get(struct device_node *node,
313 if (id) { 337 if (id) {
314 index = of_property_match_string(node, 338 index = of_property_match_string(node,
315 "reset-names", id); 339 "reset-names", id);
340 if (index == -EILSEQ)
341 return ERR_PTR(index);
316 if (index < 0) 342 if (index < 0)
317 return ERR_PTR(-ENOENT); 343 return optional ? NULL : ERR_PTR(-ENOENT);
318 } 344 }
319 345
320 ret = of_parse_phandle_with_args(node, "resets", "#reset-cells", 346 ret = of_parse_phandle_with_args(node, "resets", "#reset-cells",
321 index, &args); 347 index, &args);
322 if (ret) 348 if (ret == -EINVAL)
323 return ERR_PTR(ret); 349 return ERR_PTR(ret);
350 if (ret)
351 return optional ? NULL : ERR_PTR(ret);
324 352
325 mutex_lock(&reset_list_mutex); 353 mutex_lock(&reset_list_mutex);
326 rcdev = NULL; 354 rcdev = NULL;
@@ -379,7 +407,8 @@ static void devm_reset_control_release(struct device *dev, void *res)
379} 407}
380 408
381struct reset_control *__devm_reset_control_get(struct device *dev, 409struct reset_control *__devm_reset_control_get(struct device *dev,
382 const char *id, int index, int shared) 410 const char *id, int index, bool shared,
411 bool optional)
383{ 412{
384 struct reset_control **ptr, *rstc; 413 struct reset_control **ptr, *rstc;
385 414
@@ -389,7 +418,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev,
389 return ERR_PTR(-ENOMEM); 418 return ERR_PTR(-ENOMEM);
390 419
391 rstc = __of_reset_control_get(dev ? dev->of_node : NULL, 420 rstc = __of_reset_control_get(dev ? dev->of_node : NULL,
392 id, index, shared); 421 id, index, shared, optional);
393 if (!IS_ERR(rstc)) { 422 if (!IS_ERR(rstc)) {
394 *ptr = rstc; 423 *ptr = rstc;
395 devres_add(dev, ptr); 424 devres_add(dev, ptr);
diff --git a/drivers/reset/hisilicon/Kconfig b/drivers/reset/hisilicon/Kconfig
index 1ff8b0c80980..10134dc03fe0 100644
--- a/drivers/reset/hisilicon/Kconfig
+++ b/drivers/reset/hisilicon/Kconfig
@@ -1,3 +1,10 @@
1config COMMON_RESET_HI3660
2 tristate "Hi3660 Reset Driver"
3 depends on ARCH_HISI || COMPILE_TEST
4 default ARCH_HISI
5 help
6 Build the Hisilicon Hi3660 reset driver.
7
1config COMMON_RESET_HI6220 8config COMMON_RESET_HI6220
2 tristate "Hi6220 Reset Driver" 9 tristate "Hi6220 Reset Driver"
3 depends on ARCH_HISI || COMPILE_TEST 10 depends on ARCH_HISI || COMPILE_TEST
diff --git a/drivers/reset/hisilicon/Makefile b/drivers/reset/hisilicon/Makefile
index c932f86e2f10..ab8a7bfcbd8d 100644
--- a/drivers/reset/hisilicon/Makefile
+++ b/drivers/reset/hisilicon/Makefile
@@ -1 +1,2 @@
1obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o 1obj-$(CONFIG_COMMON_RESET_HI6220) += hi6220_reset.o
2obj-$(CONFIG_COMMON_RESET_HI3660) += reset-hi3660.o
diff --git a/drivers/reset/hisilicon/reset-hi3660.c b/drivers/reset/hisilicon/reset-hi3660.c
new file mode 100644
index 000000000000..17d8bb128e6e
--- /dev/null
+++ b/drivers/reset/hisilicon/reset-hi3660.c
@@ -0,0 +1,126 @@
1/*
2 * Copyright (c) 2016-2017 Linaro Ltd.
3 * Copyright (c) 2016-2017 HiSilicon Technologies Co., Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10#include <linux/kernel.h>
11#include <linux/mfd/syscon.h>
12#include <linux/module.h>
13#include <linux/of_device.h>
14#include <linux/platform_device.h>
15#include <linux/regmap.h>
16#include <linux/reset-controller.h>
17
18struct hi3660_reset_controller {
19 struct reset_controller_dev rst;
20 struct regmap *map;
21};
22
23#define to_hi3660_reset_controller(_rst) \
24 container_of(_rst, struct hi3660_reset_controller, rst)
25
26static int hi3660_reset_program_hw(struct reset_controller_dev *rcdev,
27 unsigned long idx, bool assert)
28{
29 struct hi3660_reset_controller *rc = to_hi3660_reset_controller(rcdev);
30 unsigned int offset = idx >> 8;
31 unsigned int mask = BIT(idx & 0x1f);
32
33 if (assert)
34 return regmap_write(rc->map, offset, mask);
35 else
36 return regmap_write(rc->map, offset + 4, mask);
37}
38
39static int hi3660_reset_assert(struct reset_controller_dev *rcdev,
40 unsigned long idx)
41{
42 return hi3660_reset_program_hw(rcdev, idx, true);
43}
44
45static int hi3660_reset_deassert(struct reset_controller_dev *rcdev,
46 unsigned long idx)
47{
48 return hi3660_reset_program_hw(rcdev, idx, false);
49}
50
51static int hi3660_reset_dev(struct reset_controller_dev *rcdev,
52 unsigned long idx)
53{
54 int err;
55
56 err = hi3660_reset_assert(rcdev, idx);
57 if (err)
58 return err;
59
60 return hi3660_reset_deassert(rcdev, idx);
61}
62
63static struct reset_control_ops hi3660_reset_ops = {
64 .reset = hi3660_reset_dev,
65 .assert = hi3660_reset_assert,
66 .deassert = hi3660_reset_deassert,
67};
68
69static int hi3660_reset_xlate(struct reset_controller_dev *rcdev,
70 const struct of_phandle_args *reset_spec)
71{
72 unsigned int offset, bit;
73
74 offset = reset_spec->args[0];
75 bit = reset_spec->args[1];
76
77 return (offset << 8) | bit;
78}
79
80static int hi3660_reset_probe(struct platform_device *pdev)
81{
82 struct hi3660_reset_controller *rc;
83 struct device_node *np = pdev->dev.of_node;
84 struct device *dev = &pdev->dev;
85
86 rc = devm_kzalloc(dev, sizeof(*rc), GFP_KERNEL);
87 if (!rc)
88 return -ENOMEM;
89
90 rc->map = syscon_regmap_lookup_by_phandle(np, "hisi,rst-syscon");
91 if (IS_ERR(rc->map)) {
92 dev_err(dev, "failed to get hi3660,rst-syscon\n");
93 return PTR_ERR(rc->map);
94 }
95
96 rc->rst.ops = &hi3660_reset_ops,
97 rc->rst.of_node = np;
98 rc->rst.of_reset_n_cells = 2;
99 rc->rst.of_xlate = hi3660_reset_xlate;
100
101 return reset_controller_register(&rc->rst);
102}
103
104static const struct of_device_id hi3660_reset_match[] = {
105 { .compatible = "hisilicon,hi3660-reset", },
106 {},
107};
108MODULE_DEVICE_TABLE(of, hi3660_reset_match);
109
110static struct platform_driver hi3660_reset_driver = {
111 .probe = hi3660_reset_probe,
112 .driver = {
113 .name = "hi3660-reset",
114 .of_match_table = hi3660_reset_match,
115 },
116};
117
118static int __init hi3660_reset_init(void)
119{
120 return platform_driver_register(&hi3660_reset_driver);
121}
122arch_initcall(hi3660_reset_init);
123
124MODULE_LICENSE("GPL");
125MODULE_ALIAS("platform:hi3660-reset");
126MODULE_DESCRIPTION("HiSilicon Hi3660 Reset Driver");
diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c
index 47f0ffd3b013..99520b0a1329 100644
--- a/drivers/reset/reset-ti-syscon.c
+++ b/drivers/reset/reset-ti-syscon.c
@@ -154,11 +154,11 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
154 if (ret) 154 if (ret)
155 return ret; 155 return ret;
156 156
157 return (reset_state & BIT(control->status_bit)) && 157 return !(reset_state & BIT(control->status_bit)) ==
158 (control->flags & STATUS_SET); 158 !(control->flags & STATUS_SET);
159} 159}
160 160
161static struct reset_control_ops ti_syscon_reset_ops = { 161static const struct reset_control_ops ti_syscon_reset_ops = {
162 .assert = ti_syscon_reset_assert, 162 .assert = ti_syscon_reset_assert,
163 .deassert = ti_syscon_reset_deassert, 163 .deassert = ti_syscon_reset_deassert,
164 .status = ti_syscon_reset_status, 164 .status = ti_syscon_reset_status,
diff --git a/drivers/reset/reset-uniphier.c b/drivers/reset/reset-uniphier.c
index 968c3ae4535c..9c11be3d3450 100644
--- a/drivers/reset/reset-uniphier.c
+++ b/drivers/reset/reset-uniphier.c
@@ -390,6 +390,10 @@ static const struct of_device_id uniphier_reset_match[] = {
390 .data = uniphier_sld3_mio_reset_data, 390 .data = uniphier_sld3_mio_reset_data,
391 }, 391 },
392 { 392 {
393 .compatible = "socionext,uniphier-ld11-sd-reset",
394 .data = uniphier_pro5_sd_reset_data,
395 },
396 {
393 .compatible = "socionext,uniphier-ld20-sd-reset", 397 .compatible = "socionext,uniphier-ld20-sd-reset",
394 .data = uniphier_pro5_sd_reset_data, 398 .data = uniphier_pro5_sd_reset_data,
395 }, 399 },
diff --git a/drivers/reset/reset-zx2967.c b/drivers/reset/reset-zx2967.c
new file mode 100644
index 000000000000..5d821513aa3e
--- /dev/null
+++ b/drivers/reset/reset-zx2967.c
@@ -0,0 +1,106 @@
1/*
2 * ZTE's zx2967 family reset controller driver
3 *
4 * Copyright (C) 2017 ZTE Ltd.
5 *
6 * Author: Baoyou Xie <baoyou.xie@linaro.org>
7 *
8 * License terms: GNU General Public License (GPL) version 2
9 */
10
11#include <linux/module.h>
12#include <linux/of_address.h>
13#include <linux/platform_device.h>
14#include <linux/reset-controller.h>
15
16struct zx2967_reset {
17 void __iomem *reg_base;
18 spinlock_t lock;
19 struct reset_controller_dev rcdev;
20};
21
22static int zx2967_reset_act(struct reset_controller_dev *rcdev,
23 unsigned long id, bool assert)
24{
25 struct zx2967_reset *reset = NULL;
26 int bank = id / 32;
27 int offset = id % 32;
28 u32 reg;
29 unsigned long flags;
30
31 reset = container_of(rcdev, struct zx2967_reset, rcdev);
32
33 spin_lock_irqsave(&reset->lock, flags);
34
35 reg = readl_relaxed(reset->reg_base + (bank * 4));
36 if (assert)
37 reg &= ~BIT(offset);
38 else
39 reg |= BIT(offset);
40 writel_relaxed(reg, reset->reg_base + (bank * 4));
41
42 spin_unlock_irqrestore(&reset->lock, flags);
43
44 return 0;
45}
46
47static int zx2967_reset_assert(struct reset_controller_dev *rcdev,
48 unsigned long id)
49{
50 return zx2967_reset_act(rcdev, id, true);
51}
52
53static int zx2967_reset_deassert(struct reset_controller_dev *rcdev,
54 unsigned long id)
55{
56 return zx2967_reset_act(rcdev, id, false);
57}
58
59static struct reset_control_ops zx2967_reset_ops = {
60 .assert = zx2967_reset_assert,
61 .deassert = zx2967_reset_deassert,
62};
63
64static int zx2967_reset_probe(struct platform_device *pdev)
65{
66 struct zx2967_reset *reset;
67 struct resource *res;
68
69 reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL);
70 if (!reset)
71 return -ENOMEM;
72
73 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
74 reset->reg_base = devm_ioremap_resource(&pdev->dev, res);
75 if (IS_ERR(reset->reg_base))
76 return PTR_ERR(reset->reg_base);
77
78 spin_lock_init(&reset->lock);
79
80 reset->rcdev.owner = THIS_MODULE;
81 reset->rcdev.nr_resets = resource_size(res) * 8;
82 reset->rcdev.ops = &zx2967_reset_ops;
83 reset->rcdev.of_node = pdev->dev.of_node;
84
85 return devm_reset_controller_register(&pdev->dev, &reset->rcdev);
86}
87
88static const struct of_device_id zx2967_reset_dt_ids[] = {
89 { .compatible = "zte,zx296718-reset", },
90 {},
91};
92MODULE_DEVICE_TABLE(of, zx2967_reset_dt_ids);
93
94static struct platform_driver zx2967_reset_driver = {
95 .probe = zx2967_reset_probe,
96 .driver = {
97 .name = "zx2967-reset",
98 .of_match_table = zx2967_reset_dt_ids,
99 },
100};
101
102builtin_platform_driver(zx2967_reset_driver);
103
104MODULE_AUTHOR("Baoyou Xie <baoyou.xie@linaro.org>");
105MODULE_DESCRIPTION("ZTE zx2967 Reset Controller Driver");
106MODULE_LICENSE("GPL");
diff --git a/include/linux/reset.h b/include/linux/reset.h
index 5daff15722d3..86b4ed75359e 100644
--- a/include/linux/reset.h
+++ b/include/linux/reset.h
@@ -13,10 +13,12 @@ int reset_control_deassert(struct reset_control *rstc);
13int reset_control_status(struct reset_control *rstc); 13int reset_control_status(struct reset_control *rstc);
14 14
15struct reset_control *__of_reset_control_get(struct device_node *node, 15struct reset_control *__of_reset_control_get(struct device_node *node,
16 const char *id, int index, int shared); 16 const char *id, int index, bool shared,
17 bool optional);
17void reset_control_put(struct reset_control *rstc); 18void reset_control_put(struct reset_control *rstc);
18struct reset_control *__devm_reset_control_get(struct device *dev, 19struct reset_control *__devm_reset_control_get(struct device *dev,
19 const char *id, int index, int shared); 20 const char *id, int index, bool shared,
21 bool optional);
20 22
21int __must_check device_reset(struct device *dev); 23int __must_check device_reset(struct device *dev);
22 24
@@ -69,14 +71,15 @@ static inline int device_reset_optional(struct device *dev)
69 71
70static inline struct reset_control *__of_reset_control_get( 72static inline struct reset_control *__of_reset_control_get(
71 struct device_node *node, 73 struct device_node *node,
72 const char *id, int index, int shared) 74 const char *id, int index, bool shared,
75 bool optional)
73{ 76{
74 return ERR_PTR(-ENOTSUPP); 77 return ERR_PTR(-ENOTSUPP);
75} 78}
76 79
77static inline struct reset_control *__devm_reset_control_get( 80static inline struct reset_control *__devm_reset_control_get(
78 struct device *dev, 81 struct device *dev, const char *id,
79 const char *id, int index, int shared) 82 int index, bool shared, bool optional)
80{ 83{
81 return ERR_PTR(-ENOTSUPP); 84 return ERR_PTR(-ENOTSUPP);
82} 85}
@@ -104,7 +107,8 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id)
104#ifndef CONFIG_RESET_CONTROLLER 107#ifndef CONFIG_RESET_CONTROLLER
105 WARN_ON(1); 108 WARN_ON(1);
106#endif 109#endif
107 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0); 110 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false,
111 false);
108} 112}
109 113
110/** 114/**
@@ -132,19 +136,22 @@ __must_check reset_control_get_exclusive(struct device *dev, const char *id)
132static inline struct reset_control *reset_control_get_shared( 136static inline struct reset_control *reset_control_get_shared(
133 struct device *dev, const char *id) 137 struct device *dev, const char *id)
134{ 138{
135 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1); 139 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true,
140 false);
136} 141}
137 142
138static inline struct reset_control *reset_control_get_optional_exclusive( 143static inline struct reset_control *reset_control_get_optional_exclusive(
139 struct device *dev, const char *id) 144 struct device *dev, const char *id)
140{ 145{
141 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 0); 146 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, false,
147 true);
142} 148}
143 149
144static inline struct reset_control *reset_control_get_optional_shared( 150static inline struct reset_control *reset_control_get_optional_shared(
145 struct device *dev, const char *id) 151 struct device *dev, const char *id)
146{ 152{
147 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, 1); 153 return __of_reset_control_get(dev ? dev->of_node : NULL, id, 0, true,
154 true);
148} 155}
149 156
150/** 157/**
@@ -160,7 +167,7 @@ static inline struct reset_control *reset_control_get_optional_shared(
160static inline struct reset_control *of_reset_control_get_exclusive( 167static inline struct reset_control *of_reset_control_get_exclusive(
161 struct device_node *node, const char *id) 168 struct device_node *node, const char *id)
162{ 169{
163 return __of_reset_control_get(node, id, 0, 0); 170 return __of_reset_control_get(node, id, 0, false, false);
164} 171}
165 172
166/** 173/**
@@ -185,7 +192,7 @@ static inline struct reset_control *of_reset_control_get_exclusive(
185static inline struct reset_control *of_reset_control_get_shared( 192static inline struct reset_control *of_reset_control_get_shared(
186 struct device_node *node, const char *id) 193 struct device_node *node, const char *id)
187{ 194{
188 return __of_reset_control_get(node, id, 0, 1); 195 return __of_reset_control_get(node, id, 0, true, false);
189} 196}
190 197
191/** 198/**
@@ -202,7 +209,7 @@ static inline struct reset_control *of_reset_control_get_shared(
202static inline struct reset_control *of_reset_control_get_exclusive_by_index( 209static inline struct reset_control *of_reset_control_get_exclusive_by_index(
203 struct device_node *node, int index) 210 struct device_node *node, int index)
204{ 211{
205 return __of_reset_control_get(node, NULL, index, 0); 212 return __of_reset_control_get(node, NULL, index, false, false);
206} 213}
207 214
208/** 215/**
@@ -230,7 +237,7 @@ static inline struct reset_control *of_reset_control_get_exclusive_by_index(
230static inline struct reset_control *of_reset_control_get_shared_by_index( 237static inline struct reset_control *of_reset_control_get_shared_by_index(
231 struct device_node *node, int index) 238 struct device_node *node, int index)
232{ 239{
233 return __of_reset_control_get(node, NULL, index, 1); 240 return __of_reset_control_get(node, NULL, index, true, false);
234} 241}
235 242
236/** 243/**
@@ -252,7 +259,7 @@ __must_check devm_reset_control_get_exclusive(struct device *dev,
252#ifndef CONFIG_RESET_CONTROLLER 259#ifndef CONFIG_RESET_CONTROLLER
253 WARN_ON(1); 260 WARN_ON(1);
254#endif 261#endif
255 return __devm_reset_control_get(dev, id, 0, 0); 262 return __devm_reset_control_get(dev, id, 0, false, false);
256} 263}
257 264
258/** 265/**
@@ -267,19 +274,19 @@ __must_check devm_reset_control_get_exclusive(struct device *dev,
267static inline struct reset_control *devm_reset_control_get_shared( 274static inline struct reset_control *devm_reset_control_get_shared(
268 struct device *dev, const char *id) 275 struct device *dev, const char *id)
269{ 276{
270 return __devm_reset_control_get(dev, id, 0, 1); 277 return __devm_reset_control_get(dev, id, 0, true, false);
271} 278}
272 279
273static inline struct reset_control *devm_reset_control_get_optional_exclusive( 280static inline struct reset_control *devm_reset_control_get_optional_exclusive(
274 struct device *dev, const char *id) 281 struct device *dev, const char *id)
275{ 282{
276 return __devm_reset_control_get(dev, id, 0, 0); 283 return __devm_reset_control_get(dev, id, 0, false, true);
277} 284}
278 285
279static inline struct reset_control *devm_reset_control_get_optional_shared( 286static inline struct reset_control *devm_reset_control_get_optional_shared(
280 struct device *dev, const char *id) 287 struct device *dev, const char *id)
281{ 288{
282 return __devm_reset_control_get(dev, id, 0, 1); 289 return __devm_reset_control_get(dev, id, 0, true, true);
283} 290}
284 291
285/** 292/**
@@ -297,7 +304,7 @@ static inline struct reset_control *devm_reset_control_get_optional_shared(
297static inline struct reset_control * 304static inline struct reset_control *
298devm_reset_control_get_exclusive_by_index(struct device *dev, int index) 305devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
299{ 306{
300 return __devm_reset_control_get(dev, NULL, index, 0); 307 return __devm_reset_control_get(dev, NULL, index, false, false);
301} 308}
302 309
303/** 310/**
@@ -313,7 +320,7 @@ devm_reset_control_get_exclusive_by_index(struct device *dev, int index)
313static inline struct reset_control * 320static inline struct reset_control *
314devm_reset_control_get_shared_by_index(struct device *dev, int index) 321devm_reset_control_get_shared_by_index(struct device *dev, int index)
315{ 322{
316 return __devm_reset_control_get(dev, NULL, index, 1); 323 return __devm_reset_control_get(dev, NULL, index, true, false);
317} 324}
318 325
319/* 326/*