aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2014-12-04 10:57:36 -0500
committerArnd Bergmann <arnd@arndb.de>2014-12-04 10:57:36 -0500
commita8afa2645ccf3525409c749c1dc4ec1cf95ff3f5 (patch)
tree0148315475b348246201f4d57b7ed5802f76cfb2
parent136a713d80476fe993284bdf8b21709c179c9965 (diff)
parentf200890f224d9ed0af207145a2279f51c6be230b (diff)
Merge tag 'reset-for-3.19-2' of git://git.pengutronix.de/git/pza/linux into next/drivers
Pull "Reset controller changes for v3.19" from Philipp Zabel: This adds a new driver for the sti soc family, and creates a reset_control_status interface, which is added to the existing drivers. * tag 'reset-for-3.19-2' of git://git.pengutronix.de/git/pza/linux: reset: add socfpga_reset_status reset: sti: Document sti-picophyreset controllers bindings. reset: stih407: Add softreset, powerdown and picophy controllers reset: stih407: Add reset controllers DT bindings reset: add reset_control_status helper function Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--Documentation/devicetree/bindings/reset/st,sti-picophyreset.txt42
-rw-r--r--drivers/reset/core.c15
-rw-r--r--drivers/reset/reset-socfpga.c15
-rw-r--r--drivers/reset/sti/Kconfig4
-rw-r--r--drivers/reset/sti/Makefile1
-rw-r--r--drivers/reset/sti/reset-stih407.c158
-rw-r--r--include/dt-bindings/reset-controller/stih407-resets.h61
-rw-r--r--include/linux/reset-controller.h2
-rw-r--r--include/linux/reset.h7
9 files changed, 305 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/reset/st,sti-picophyreset.txt b/Documentation/devicetree/bindings/reset/st,sti-picophyreset.txt
new file mode 100644
index 000000000000..54ae9f747e45
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/st,sti-picophyreset.txt
@@ -0,0 +1,42 @@
1STMicroelectronics STi family Sysconfig Picophy SoftReset Controller
2=============================================================================
3
4This binding describes a reset controller device that is used to enable and
5disable on-chip PicoPHY USB2 phy(s) using "softreset" control bits found in
6the STi family SoC system configuration registers.
7
8The actual action taken when softreset is asserted is hardware dependent.
9However, when asserted it may not be possible to access the hardware's
10registers and after an assert/deassert sequence the hardware's previous state
11may no longer be valid.
12
13Please refer to Documentation/devicetree/bindings/reset/reset.txt
14for common reset controller binding usage.
15
16Required properties:
17- compatible: Should be "st,stih407-picophyreset"
18- #reset-cells: 1, see below
19
20Example:
21
22 picophyreset: picophyreset-controller {
23 compatible = "st,stih407-picophyreset";
24 #reset-cells = <1>;
25 };
26
27Specifying picophyreset control of devices
28=======================================
29
30Device nodes should specify the reset channel required in their "resets"
31property, containing a phandle to the picophyreset device node and an
32index specifying which channel to use, as described in
33Documentation/devicetree/bindings/reset/reset.txt.
34
35Example:
36
37 usb2_picophy0: usbpicophy@0 {
38 resets = <&picophyreset STIH407_PICOPHY0_RESET>;
39 };
40
41Macro definitions for the supported reset channels can be found in:
42include/dt-bindings/reset-controller/stih407-resets.h
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)
126EXPORT_SYMBOL_GPL(reset_control_deassert); 126EXPORT_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 */
134int 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}
141EXPORT_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/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 79c32ca84ef1..40582089474a 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -76,9 +76,24 @@ static int socfpga_reset_deassert(struct reset_controller_dev *rcdev,
76 return 0; 76 return 0;
77} 77}
78 78
79static int socfpga_reset_status(struct reset_controller_dev *rcdev,
80 unsigned long id)
81{
82 struct socfpga_reset_data *data = container_of(rcdev,
83 struct socfpga_reset_data, rcdev);
84 int bank = id / BITS_PER_LONG;
85 int offset = id % BITS_PER_LONG;
86 u32 reg;
87
88 reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
89
90 return !(reg & BIT(offset));
91}
92
79static struct reset_control_ops socfpga_reset_ops = { 93static struct reset_control_ops socfpga_reset_ops = {
80 .assert = socfpga_reset_assert, 94 .assert = socfpga_reset_assert,
81 .deassert = socfpga_reset_deassert, 95 .deassert = socfpga_reset_deassert,
96 .status = socfpga_reset_status,
82}; 97};
83 98
84static int socfpga_reset_probe(struct platform_device *pdev) 99static int socfpga_reset_probe(struct platform_device *pdev)
diff --git a/drivers/reset/sti/Kconfig b/drivers/reset/sti/Kconfig
index 88d2d0316613..f8c15a37fb35 100644
--- a/drivers/reset/sti/Kconfig
+++ b/drivers/reset/sti/Kconfig
@@ -12,4 +12,8 @@ config STIH416_RESET
12 bool 12 bool
13 select STI_RESET_SYSCFG 13 select STI_RESET_SYSCFG
14 14
15config STIH407_RESET
16 bool
17 select STI_RESET_SYSCFG
18
15endif 19endif
diff --git a/drivers/reset/sti/Makefile b/drivers/reset/sti/Makefile
index be1c97647871..dc85dfbe56a9 100644
--- a/drivers/reset/sti/Makefile
+++ b/drivers/reset/sti/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_STI_RESET_SYSCFG) += reset-syscfg.o
2 2
3obj-$(CONFIG_STIH415_RESET) += reset-stih415.o 3obj-$(CONFIG_STIH415_RESET) += reset-stih415.o
4obj-$(CONFIG_STIH416_RESET) += reset-stih416.o 4obj-$(CONFIG_STIH416_RESET) += reset-stih416.o
5obj-$(CONFIG_STIH407_RESET) += reset-stih407.o
diff --git a/drivers/reset/sti/reset-stih407.c b/drivers/reset/sti/reset-stih407.c
new file mode 100644
index 000000000000..d83db5d72d08
--- /dev/null
+++ b/drivers/reset/sti/reset-stih407.c
@@ -0,0 +1,158 @@
1/*
2 * Copyright (C) 2014 STMicroelectronics (R&D) Limited
3 * Author: Giuseppe Cavallaro <peppe.cavallaro@st.com>
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/module.h>
11#include <linux/of.h>
12#include <linux/of_platform.h>
13#include <linux/platform_device.h>
14#include <dt-bindings/reset-controller/stih407-resets.h>
15#include "reset-syscfg.h"
16
17/* STiH407 Peripheral powerdown definitions. */
18static const char stih407_core[] = "st,stih407-core-syscfg";
19static const char stih407_sbc_reg[] = "st,stih407-sbc-reg-syscfg";
20static const char stih407_lpm[] = "st,stih407-lpm-syscfg";
21
22#define STIH407_PDN_0(_bit) \
23 _SYSCFG_RST_CH(stih407_core, SYSCFG_5000, _bit, SYSSTAT_5500, _bit)
24#define STIH407_PDN_1(_bit) \
25 _SYSCFG_RST_CH(stih407_core, SYSCFG_5001, _bit, SYSSTAT_5501, _bit)
26#define STIH407_PDN_ETH(_bit, _stat) \
27 _SYSCFG_RST_CH(stih407_sbc_reg, SYSCFG_4032, _bit, SYSSTAT_4520, _stat)
28
29/* Powerdown requests control 0 */
30#define SYSCFG_5000 0x0
31#define SYSSTAT_5500 0x7d0
32/* Powerdown requests control 1 (High Speed Links) */
33#define SYSCFG_5001 0x4
34#define SYSSTAT_5501 0x7d4
35
36/* Ethernet powerdown/status/reset */
37#define SYSCFG_4032 0x80
38#define SYSSTAT_4520 0x820
39#define SYSCFG_4002 0x8
40
41static const struct syscfg_reset_channel_data stih407_powerdowns[] = {
42 [STIH407_EMISS_POWERDOWN] = STIH407_PDN_0(1),
43 [STIH407_NAND_POWERDOWN] = STIH407_PDN_0(0),
44 [STIH407_USB3_POWERDOWN] = STIH407_PDN_1(6),
45 [STIH407_USB2_PORT1_POWERDOWN] = STIH407_PDN_1(5),
46 [STIH407_USB2_PORT0_POWERDOWN] = STIH407_PDN_1(4),
47 [STIH407_PCIE1_POWERDOWN] = STIH407_PDN_1(3),
48 [STIH407_PCIE0_POWERDOWN] = STIH407_PDN_1(2),
49 [STIH407_SATA1_POWERDOWN] = STIH407_PDN_1(1),
50 [STIH407_SATA0_POWERDOWN] = STIH407_PDN_1(0),
51 [STIH407_ETH1_POWERDOWN] = STIH407_PDN_ETH(0, 2),
52};
53
54/* Reset Generator control 0/1 */
55#define SYSCFG_5131 0x20c
56#define SYSCFG_5132 0x210
57
58#define LPM_SYSCFG_1 0x4 /* Softreset IRB & SBC UART */
59
60#define STIH407_SRST_CORE(_reg, _bit) \
61 _SYSCFG_RST_CH_NO_ACK(stih407_core, _reg, _bit)
62
63#define STIH407_SRST_SBC(_reg, _bit) \
64 _SYSCFG_RST_CH_NO_ACK(stih407_sbc_reg, _reg, _bit)
65
66#define STIH407_SRST_LPM(_reg, _bit) \
67 _SYSCFG_RST_CH_NO_ACK(stih407_lpm, _reg, _bit)
68
69static const struct syscfg_reset_channel_data stih407_softresets[] = {
70 [STIH407_ETH1_SOFTRESET] = STIH407_SRST_SBC(SYSCFG_4002, 4),
71 [STIH407_MMC1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 3),
72 [STIH407_USB2_PORT0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 28),
73 [STIH407_USB2_PORT1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 29),
74 [STIH407_PICOPHY_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 30),
75 [STIH407_IRB_SOFTRESET] = STIH407_SRST_LPM(LPM_SYSCFG_1, 6),
76 [STIH407_PCIE0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 6),
77 [STIH407_PCIE1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 15),
78 [STIH407_SATA0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 7),
79 [STIH407_SATA1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 16),
80 [STIH407_MIPHY0_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 4),
81 [STIH407_MIPHY1_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 13),
82 [STIH407_MIPHY2_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 22),
83 [STIH407_SATA0_PWR_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 5),
84 [STIH407_SATA1_PWR_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 14),
85 [STIH407_DELTA_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 3),
86 [STIH407_BLITTER_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 10),
87 [STIH407_HDTVOUT_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 11),
88 [STIH407_HDQVDP_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 12),
89 [STIH407_VDP_AUX_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 14),
90 [STIH407_COMPO_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 15),
91 [STIH407_HDMI_TX_PHY_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 21),
92 [STIH407_JPEG_DEC_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 23),
93 [STIH407_VP8_DEC_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 24),
94 [STIH407_GPU_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5131, 30),
95 [STIH407_HVA_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 0),
96 [STIH407_ERAM_HVA_SOFTRESET] = STIH407_SRST_CORE(SYSCFG_5132, 1),
97 [STIH407_LPM_SOFTRESET] = STIH407_SRST_SBC(SYSCFG_4002, 2),
98 [STIH407_KEYSCAN_SOFTRESET] = STIH407_SRST_LPM(LPM_SYSCFG_1, 8),
99};
100
101/* PicoPHY reset/control */
102#define SYSCFG_5061 0x0f4
103
104static const struct syscfg_reset_channel_data stih407_picophyresets[] = {
105 [STIH407_PICOPHY0_RESET] = STIH407_SRST_CORE(SYSCFG_5061, 5),
106 [STIH407_PICOPHY1_RESET] = STIH407_SRST_CORE(SYSCFG_5061, 6),
107 [STIH407_PICOPHY2_RESET] = STIH407_SRST_CORE(SYSCFG_5061, 7),
108};
109
110static const struct syscfg_reset_controller_data stih407_powerdown_controller = {
111 .wait_for_ack = true,
112 .nr_channels = ARRAY_SIZE(stih407_powerdowns),
113 .channels = stih407_powerdowns,
114};
115
116static const struct syscfg_reset_controller_data stih407_softreset_controller = {
117 .wait_for_ack = false,
118 .active_low = true,
119 .nr_channels = ARRAY_SIZE(stih407_softresets),
120 .channels = stih407_softresets,
121};
122
123static const struct syscfg_reset_controller_data stih407_picophyreset_controller = {
124 .wait_for_ack = false,
125 .nr_channels = ARRAY_SIZE(stih407_picophyresets),
126 .channels = stih407_picophyresets,
127};
128
129static struct of_device_id stih407_reset_match[] = {
130 {
131 .compatible = "st,stih407-powerdown",
132 .data = &stih407_powerdown_controller,
133 },
134 {
135 .compatible = "st,stih407-softreset",
136 .data = &stih407_softreset_controller,
137 },
138 {
139 .compatible = "st,stih407-picophyreset",
140 .data = &stih407_picophyreset_controller,
141 },
142 { /* sentinel */ },
143};
144
145static struct platform_driver stih407_reset_driver = {
146 .probe = syscfg_reset_probe,
147 .driver = {
148 .name = "reset-stih407",
149 .of_match_table = stih407_reset_match,
150 },
151};
152
153static int __init stih407_reset_init(void)
154{
155 return platform_driver_register(&stih407_reset_driver);
156}
157
158arch_initcall(stih407_reset_init);
diff --git a/include/dt-bindings/reset-controller/stih407-resets.h b/include/dt-bindings/reset-controller/stih407-resets.h
new file mode 100644
index 000000000000..02d4328fe479
--- /dev/null
+++ b/include/dt-bindings/reset-controller/stih407-resets.h
@@ -0,0 +1,61 @@
1/*
2 * This header provides constants for the reset controller
3 * based peripheral powerdown requests on the STMicroelectronics
4 * STiH407 SoC.
5 */
6#ifndef _DT_BINDINGS_RESET_CONTROLLER_STIH407
7#define _DT_BINDINGS_RESET_CONTROLLER_STIH407
8
9/* Powerdown requests control 0 */
10#define STIH407_EMISS_POWERDOWN 0
11#define STIH407_NAND_POWERDOWN 1
12
13/* Synp GMAC PowerDown */
14#define STIH407_ETH1_POWERDOWN 2
15
16/* Powerdown requests control 1 */
17#define STIH407_USB3_POWERDOWN 3
18#define STIH407_USB2_PORT1_POWERDOWN 4
19#define STIH407_USB2_PORT0_POWERDOWN 5
20#define STIH407_PCIE1_POWERDOWN 6
21#define STIH407_PCIE0_POWERDOWN 7
22#define STIH407_SATA1_POWERDOWN 8
23#define STIH407_SATA0_POWERDOWN 9
24
25/* Reset defines */
26#define STIH407_ETH1_SOFTRESET 0
27#define STIH407_MMC1_SOFTRESET 1
28#define STIH407_PICOPHY_SOFTRESET 2
29#define STIH407_IRB_SOFTRESET 3
30#define STIH407_PCIE0_SOFTRESET 4
31#define STIH407_PCIE1_SOFTRESET 5
32#define STIH407_SATA0_SOFTRESET 6
33#define STIH407_SATA1_SOFTRESET 7
34#define STIH407_MIPHY0_SOFTRESET 8
35#define STIH407_MIPHY1_SOFTRESET 9
36#define STIH407_MIPHY2_SOFTRESET 10
37#define STIH407_SATA0_PWR_SOFTRESET 11
38#define STIH407_SATA1_PWR_SOFTRESET 12
39#define STIH407_DELTA_SOFTRESET 13
40#define STIH407_BLITTER_SOFTRESET 14
41#define STIH407_HDTVOUT_SOFTRESET 15
42#define STIH407_HDQVDP_SOFTRESET 16
43#define STIH407_VDP_AUX_SOFTRESET 17
44#define STIH407_COMPO_SOFTRESET 18
45#define STIH407_HDMI_TX_PHY_SOFTRESET 19
46#define STIH407_JPEG_DEC_SOFTRESET 20
47#define STIH407_VP8_DEC_SOFTRESET 21
48#define STIH407_GPU_SOFTRESET 22
49#define STIH407_HVA_SOFTRESET 23
50#define STIH407_ERAM_HVA_SOFTRESET 24
51#define STIH407_LPM_SOFTRESET 25
52#define STIH407_KEYSCAN_SOFTRESET 26
53#define STIH407_USB2_PORT0_SOFTRESET 27
54#define STIH407_USB2_PORT1_SOFTRESET 28
55
56/* Picophy reset defines */
57#define STIH407_PICOPHY0_RESET 0
58#define STIH407_PICOPHY1_RESET 1
59#define STIH407_PICOPHY2_RESET 2
60
61#endif /* _DT_BINDINGS_RESET_CONTROLLER_STIH407 */
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 */
16struct reset_control_ops { 17struct 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
22struct module; 24struct 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;
10int reset_control_reset(struct reset_control *rstc); 10int reset_control_reset(struct reset_control *rstc);
11int reset_control_assert(struct reset_control *rstc); 11int reset_control_assert(struct reset_control *rstc);
12int reset_control_deassert(struct reset_control *rstc); 12int reset_control_deassert(struct reset_control *rstc);
13int reset_control_status(struct reset_control *rstc);
13 14
14struct reset_control *reset_control_get(struct device *dev, const char *id); 15struct reset_control *reset_control_get(struct device *dev, const char *id);
15void reset_control_put(struct reset_control *rstc); 16void 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
61static inline int reset_control_status(struct reset_control *rstc)
62{
63 WARN_ON(1);
64 return 0;
65}
66
60static inline void reset_control_put(struct reset_control *rstc) 67static inline void reset_control_put(struct reset_control *rstc)
61{ 68{
62 WARN_ON(1); 69 WARN_ON(1);