blob: ff7580f38056a242b853de95b8533a3b515bf9ee [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001// SPDX-License-Identifier: GPL-2.0-or-later
Masahiro Yamada54e991b2016-08-02 13:18:29 +09002/*
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada54e991b2016-08-02 13:18:29 +09005 */
6
7#include <linux/mfd/syscon.h>
8#include <linux/module.h>
9#include <linux/of.h>
10#include <linux/of_device.h>
11#include <linux/platform_device.h>
12#include <linux/regmap.h>
13#include <linux/reset-controller.h>
14
15struct uniphier_reset_data {
16 unsigned int id;
17 unsigned int reg;
18 unsigned int bit;
19 unsigned int flags;
20#define UNIPHIER_RESET_ACTIVE_LOW BIT(0)
21};
22
Philipp Zabelb19a5ae2021-03-04 17:03:09 +010023#define UNIPHIER_RESET_ID_END ((unsigned int)(-1))
Masahiro Yamada54e991b2016-08-02 13:18:29 +090024
25#define UNIPHIER_RESET_END \
26 { .id = UNIPHIER_RESET_ID_END }
27
28#define UNIPHIER_RESET(_id, _reg, _bit) \
29 { \
30 .id = (_id), \
31 .reg = (_reg), \
32 .bit = (_bit), \
33 }
34
35#define UNIPHIER_RESETX(_id, _reg, _bit) \
36 { \
37 .id = (_id), \
38 .reg = (_reg), \
39 .bit = (_bit), \
40 .flags = UNIPHIER_RESET_ACTIVE_LOW, \
41 }
42
43/* System reset data */
Masahiro Yamada52810362017-08-06 11:44:01 +090044static const struct uniphier_reset_data uniphier_ld4_sys_reset_data[] = {
45 UNIPHIER_RESETX(2, 0x2000, 2), /* NAND */
46 UNIPHIER_RESETX(8, 0x2000, 10), /* STDMAC (Ether, HSC, MIO) */
Masahiro Yamada54e991b2016-08-02 13:18:29 +090047 UNIPHIER_RESET_END,
48};
49
Wei Yongjun716adfe2017-02-08 15:56:20 +000050static const struct uniphier_reset_data uniphier_pro4_sys_reset_data[] = {
Masahiro Yamada52810362017-08-06 11:44:01 +090051 UNIPHIER_RESETX(2, 0x2000, 2), /* NAND */
Kunihiko Hayashi4c05c4a2017-08-28 18:59:38 +090052 UNIPHIER_RESETX(6, 0x2000, 12), /* Ether */
Masahiro Yamada52810362017-08-06 11:44:01 +090053 UNIPHIER_RESETX(8, 0x2000, 10), /* STDMAC (HSC, MIO, RLE) */
Masahiro Yamadadec173c2017-08-06 11:44:02 +090054 UNIPHIER_RESETX(12, 0x2000, 6), /* GIO (Ether, SATA, USB3) */
55 UNIPHIER_RESETX(14, 0x2000, 17), /* USB30 */
56 UNIPHIER_RESETX(15, 0x2004, 17), /* USB31 */
Kunihiko Hayashi78636712018-03-30 18:44:44 +090057 UNIPHIER_RESETX(28, 0x2000, 18), /* SATA0 */
58 UNIPHIER_RESETX(29, 0x2004, 18), /* SATA1 */
59 UNIPHIER_RESETX(30, 0x2000, 19), /* SATA-PHY */
Katsuhiro Suzukib06b6312018-03-08 17:09:29 +090060 UNIPHIER_RESETX(40, 0x2000, 13), /* AIO */
Masahiro Yamada54e991b2016-08-02 13:18:29 +090061 UNIPHIER_RESET_END,
62};
63
Wei Yongjun716adfe2017-02-08 15:56:20 +000064static const struct uniphier_reset_data uniphier_pro5_sys_reset_data[] = {
Masahiro Yamada52810362017-08-06 11:44:01 +090065 UNIPHIER_RESETX(2, 0x2000, 2), /* NAND */
66 UNIPHIER_RESETX(8, 0x2000, 10), /* STDMAC (HSC) */
Masahiro Yamadadec173c2017-08-06 11:44:02 +090067 UNIPHIER_RESETX(12, 0x2000, 6), /* GIO (PCIe, USB3) */
68 UNIPHIER_RESETX(14, 0x2000, 17), /* USB30 */
69 UNIPHIER_RESETX(15, 0x2004, 17), /* USB31 */
Kunihiko Hayashifdc0f232018-03-30 18:44:43 +090070 UNIPHIER_RESETX(24, 0x2008, 2), /* PCIe */
Katsuhiro Suzukib06b6312018-03-08 17:09:29 +090071 UNIPHIER_RESETX(40, 0x2000, 13), /* AIO */
Masahiro Yamada54e991b2016-08-02 13:18:29 +090072 UNIPHIER_RESET_END,
73};
74
Wei Yongjun716adfe2017-02-08 15:56:20 +000075static const struct uniphier_reset_data uniphier_pxs2_sys_reset_data[] = {
Masahiro Yamada52810362017-08-06 11:44:01 +090076 UNIPHIER_RESETX(2, 0x2000, 2), /* NAND */
Kunihiko Hayashi4c05c4a2017-08-28 18:59:38 +090077 UNIPHIER_RESETX(6, 0x2000, 12), /* Ether */
Masahiro Yamada52810362017-08-06 11:44:01 +090078 UNIPHIER_RESETX(8, 0x2000, 10), /* STDMAC (HSC, RLE) */
Masahiro Yamadadec173c2017-08-06 11:44:02 +090079 UNIPHIER_RESETX(14, 0x2000, 17), /* USB30 */
80 UNIPHIER_RESETX(15, 0x2004, 17), /* USB31 */
Masahiro Yamada54e991b2016-08-02 13:18:29 +090081 UNIPHIER_RESETX(16, 0x2014, 4), /* USB30-PHY0 */
82 UNIPHIER_RESETX(17, 0x2014, 0), /* USB30-PHY1 */
83 UNIPHIER_RESETX(18, 0x2014, 2), /* USB30-PHY2 */
84 UNIPHIER_RESETX(20, 0x2014, 5), /* USB31-PHY0 */
85 UNIPHIER_RESETX(21, 0x2014, 1), /* USB31-PHY1 */
86 UNIPHIER_RESETX(28, 0x2014, 12), /* SATA */
Kunihiko Hayashi78636712018-03-30 18:44:44 +090087 UNIPHIER_RESET(30, 0x2014, 8), /* SATA-PHY (active high) */
Katsuhiro Suzukib06b6312018-03-08 17:09:29 +090088 UNIPHIER_RESETX(40, 0x2000, 13), /* AIO */
Masahiro Yamada54e991b2016-08-02 13:18:29 +090089 UNIPHIER_RESET_END,
90};
91
Wei Yongjun716adfe2017-02-08 15:56:20 +000092static const struct uniphier_reset_data uniphier_ld11_sys_reset_data[] = {
Masahiro Yamadadec173c2017-08-06 11:44:02 +090093 UNIPHIER_RESETX(2, 0x200c, 0), /* NAND */
94 UNIPHIER_RESETX(4, 0x200c, 2), /* eMMC */
Kunihiko Hayashi4c05c4a2017-08-28 18:59:38 +090095 UNIPHIER_RESETX(6, 0x200c, 6), /* Ether */
Masahiro Yamadadec173c2017-08-06 11:44:02 +090096 UNIPHIER_RESETX(8, 0x200c, 8), /* STDMAC (HSC, MIO) */
Katsuhiro Suzukid7bab652018-04-27 09:41:21 +090097 UNIPHIER_RESETX(9, 0x200c, 9), /* HSC */
Katsuhiro Suzuki94e10c22017-08-13 18:00:41 +090098 UNIPHIER_RESETX(40, 0x2008, 0), /* AIO */
99 UNIPHIER_RESETX(41, 0x2008, 1), /* EVEA */
Katsuhiro Suzuki0f195432017-08-13 18:00:42 +0900100 UNIPHIER_RESETX(42, 0x2010, 2), /* EXIV */
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900101 UNIPHIER_RESET_END,
102};
103
Wei Yongjun716adfe2017-02-08 15:56:20 +0000104static const struct uniphier_reset_data uniphier_ld20_sys_reset_data[] = {
Masahiro Yamadadec173c2017-08-06 11:44:02 +0900105 UNIPHIER_RESETX(2, 0x200c, 0), /* NAND */
106 UNIPHIER_RESETX(4, 0x200c, 2), /* eMMC */
Kunihiko Hayashi4c05c4a2017-08-28 18:59:38 +0900107 UNIPHIER_RESETX(6, 0x200c, 6), /* Ether */
Masahiro Yamadadec173c2017-08-06 11:44:02 +0900108 UNIPHIER_RESETX(8, 0x200c, 8), /* STDMAC (HSC) */
Katsuhiro Suzukid7bab652018-04-27 09:41:21 +0900109 UNIPHIER_RESETX(9, 0x200c, 9), /* HSC */
Masahiro Yamadae6914362018-04-12 11:16:10 +0900110 UNIPHIER_RESETX(14, 0x200c, 5), /* USB30 */
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900111 UNIPHIER_RESETX(16, 0x200c, 12), /* USB30-PHY0 */
112 UNIPHIER_RESETX(17, 0x200c, 13), /* USB30-PHY1 */
113 UNIPHIER_RESETX(18, 0x200c, 14), /* USB30-PHY2 */
114 UNIPHIER_RESETX(19, 0x200c, 15), /* USB30-PHY3 */
Kunihiko Hayashifdc0f232018-03-30 18:44:43 +0900115 UNIPHIER_RESETX(24, 0x200c, 4), /* PCIe */
Katsuhiro Suzuki94e10c22017-08-13 18:00:41 +0900116 UNIPHIER_RESETX(40, 0x2008, 0), /* AIO */
117 UNIPHIER_RESETX(41, 0x2008, 1), /* EVEA */
Katsuhiro Suzuki0f195432017-08-13 18:00:42 +0900118 UNIPHIER_RESETX(42, 0x2010, 2), /* EXIV */
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900119 UNIPHIER_RESET_END,
120};
121
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900122static const struct uniphier_reset_data uniphier_pxs3_sys_reset_data[] = {
123 UNIPHIER_RESETX(2, 0x200c, 0), /* NAND */
124 UNIPHIER_RESETX(4, 0x200c, 2), /* eMMC */
Kunihiko Hayashi5573fe82018-03-23 14:12:34 +0900125 UNIPHIER_RESETX(6, 0x200c, 9), /* Ether0 */
126 UNIPHIER_RESETX(7, 0x200c, 10), /* Ether1 */
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900127 UNIPHIER_RESETX(8, 0x200c, 12), /* STDMAC */
Masahiro Yamadae6914362018-04-12 11:16:10 +0900128 UNIPHIER_RESETX(12, 0x200c, 4), /* USB30 link */
129 UNIPHIER_RESETX(13, 0x200c, 5), /* USB31 link */
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900130 UNIPHIER_RESETX(16, 0x200c, 16), /* USB30-PHY0 */
131 UNIPHIER_RESETX(17, 0x200c, 18), /* USB30-PHY1 */
132 UNIPHIER_RESETX(18, 0x200c, 20), /* USB30-PHY2 */
133 UNIPHIER_RESETX(20, 0x200c, 17), /* USB31-PHY0 */
134 UNIPHIER_RESETX(21, 0x200c, 19), /* USB31-PHY1 */
Kunihiko Hayashifdc0f232018-03-30 18:44:43 +0900135 UNIPHIER_RESETX(24, 0x200c, 3), /* PCIe */
Kunihiko Hayashi78636712018-03-30 18:44:44 +0900136 UNIPHIER_RESETX(28, 0x200c, 7), /* SATA0 */
137 UNIPHIER_RESETX(29, 0x200c, 8), /* SATA1 */
138 UNIPHIER_RESETX(30, 0x200c, 21), /* SATA-PHY */
Kunihiko Hayashi300d2472021-10-05 11:10:40 +0900139 UNIPHIER_RESETX(40, 0x2008, 0), /* AIO */
140 UNIPHIER_RESETX(42, 0x2010, 2), /* EXIV */
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900141 UNIPHIER_RESET_END,
142};
143
Kunihiko Hayashi3440b8f2021-10-05 11:10:42 +0900144static const struct uniphier_reset_data uniphier_nx1_sys_reset_data[] = {
145 UNIPHIER_RESETX(4, 0x2008, 8), /* eMMC */
146 UNIPHIER_RESETX(6, 0x200c, 0), /* Ether */
147 UNIPHIER_RESETX(12, 0x200c, 16), /* USB30 link */
148 UNIPHIER_RESETX(16, 0x200c, 24), /* USB30-PHY0 */
149 UNIPHIER_RESETX(17, 0x200c, 25), /* USB30-PHY1 */
150 UNIPHIER_RESETX(18, 0x200c, 26), /* USB30-PHY2 */
151 UNIPHIER_RESETX(24, 0x200c, 8), /* PCIe */
152 UNIPHIER_RESETX(52, 0x2010, 0), /* VOC */
153 UNIPHIER_RESETX(58, 0x2010, 8), /* HDMI-Tx */
154 UNIPHIER_RESET_END,
155};
156
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900157/* Media I/O reset data */
158#define UNIPHIER_MIO_RESET_SD(id, ch) \
159 UNIPHIER_RESETX((id), 0x110 + 0x200 * (ch), 0)
160
161#define UNIPHIER_MIO_RESET_SD_BRIDGE(id, ch) \
162 UNIPHIER_RESETX((id), 0x110 + 0x200 * (ch), 26)
163
164#define UNIPHIER_MIO_RESET_EMMC_HW_RESET(id, ch) \
165 UNIPHIER_RESETX((id), 0x80 + 0x200 * (ch), 0)
166
167#define UNIPHIER_MIO_RESET_USB2(id, ch) \
168 UNIPHIER_RESETX((id), 0x114 + 0x200 * (ch), 0)
169
170#define UNIPHIER_MIO_RESET_USB2_BRIDGE(id, ch) \
171 UNIPHIER_RESETX((id), 0x110 + 0x200 * (ch), 24)
172
173#define UNIPHIER_MIO_RESET_DMAC(id) \
174 UNIPHIER_RESETX((id), 0x110, 17)
175
Masahiro Yamada52810362017-08-06 11:44:01 +0900176static const struct uniphier_reset_data uniphier_ld4_mio_reset_data[] = {
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900177 UNIPHIER_MIO_RESET_SD(0, 0),
178 UNIPHIER_MIO_RESET_SD(1, 1),
179 UNIPHIER_MIO_RESET_SD(2, 2),
180 UNIPHIER_MIO_RESET_SD_BRIDGE(3, 0),
181 UNIPHIER_MIO_RESET_SD_BRIDGE(4, 1),
182 UNIPHIER_MIO_RESET_SD_BRIDGE(5, 2),
183 UNIPHIER_MIO_RESET_EMMC_HW_RESET(6, 1),
184 UNIPHIER_MIO_RESET_DMAC(7),
185 UNIPHIER_MIO_RESET_USB2(8, 0),
186 UNIPHIER_MIO_RESET_USB2(9, 1),
187 UNIPHIER_MIO_RESET_USB2(10, 2),
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900188 UNIPHIER_MIO_RESET_USB2_BRIDGE(12, 0),
189 UNIPHIER_MIO_RESET_USB2_BRIDGE(13, 1),
190 UNIPHIER_MIO_RESET_USB2_BRIDGE(14, 2),
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900191 UNIPHIER_RESET_END,
192};
193
Wei Yongjun716adfe2017-02-08 15:56:20 +0000194static const struct uniphier_reset_data uniphier_pro5_sd_reset_data[] = {
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900195 UNIPHIER_MIO_RESET_SD(0, 0),
196 UNIPHIER_MIO_RESET_SD(1, 1),
197 UNIPHIER_MIO_RESET_EMMC_HW_RESET(6, 1),
198 UNIPHIER_RESET_END,
199};
200
201/* Peripheral reset data */
202#define UNIPHIER_PERI_RESET_UART(id, ch) \
203 UNIPHIER_RESETX((id), 0x114, 19 + (ch))
204
205#define UNIPHIER_PERI_RESET_I2C(id, ch) \
206 UNIPHIER_RESETX((id), 0x114, 5 + (ch))
207
208#define UNIPHIER_PERI_RESET_FI2C(id, ch) \
209 UNIPHIER_RESETX((id), 0x114, 24 + (ch))
210
Kunihiko Hayashif4aec222019-11-29 13:19:19 +0900211#define UNIPHIER_PERI_RESET_SCSSI(id, ch) \
212 UNIPHIER_RESETX((id), 0x110, 17 + (ch))
Kunihiko Hayashi6b39fd52018-07-19 15:18:53 +0900213
214#define UNIPHIER_PERI_RESET_MCSSI(id) \
215 UNIPHIER_RESETX((id), 0x114, 14)
216
Wei Yongjun716adfe2017-02-08 15:56:20 +0000217static const struct uniphier_reset_data uniphier_ld4_peri_reset_data[] = {
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900218 UNIPHIER_PERI_RESET_UART(0, 0),
219 UNIPHIER_PERI_RESET_UART(1, 1),
220 UNIPHIER_PERI_RESET_UART(2, 2),
221 UNIPHIER_PERI_RESET_UART(3, 3),
222 UNIPHIER_PERI_RESET_I2C(4, 0),
223 UNIPHIER_PERI_RESET_I2C(5, 1),
224 UNIPHIER_PERI_RESET_I2C(6, 2),
225 UNIPHIER_PERI_RESET_I2C(7, 3),
226 UNIPHIER_PERI_RESET_I2C(8, 4),
Kunihiko Hayashif4aec222019-11-29 13:19:19 +0900227 UNIPHIER_PERI_RESET_SCSSI(11, 0),
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900228 UNIPHIER_RESET_END,
229};
230
Wei Yongjun716adfe2017-02-08 15:56:20 +0000231static const struct uniphier_reset_data uniphier_pro4_peri_reset_data[] = {
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900232 UNIPHIER_PERI_RESET_UART(0, 0),
233 UNIPHIER_PERI_RESET_UART(1, 1),
234 UNIPHIER_PERI_RESET_UART(2, 2),
235 UNIPHIER_PERI_RESET_UART(3, 3),
236 UNIPHIER_PERI_RESET_FI2C(4, 0),
237 UNIPHIER_PERI_RESET_FI2C(5, 1),
238 UNIPHIER_PERI_RESET_FI2C(6, 2),
239 UNIPHIER_PERI_RESET_FI2C(7, 3),
240 UNIPHIER_PERI_RESET_FI2C(8, 4),
241 UNIPHIER_PERI_RESET_FI2C(9, 5),
242 UNIPHIER_PERI_RESET_FI2C(10, 6),
Kunihiko Hayashif4aec222019-11-29 13:19:19 +0900243 UNIPHIER_PERI_RESET_SCSSI(11, 0),
244 UNIPHIER_PERI_RESET_SCSSI(12, 1),
245 UNIPHIER_PERI_RESET_SCSSI(13, 2),
246 UNIPHIER_PERI_RESET_SCSSI(14, 3),
247 UNIPHIER_PERI_RESET_MCSSI(15),
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900248 UNIPHIER_RESET_END,
249};
250
Katsuhiro Suzukiac0c7352017-08-13 18:00:43 +0900251/* Analog signal amplifiers reset data */
252static const struct uniphier_reset_data uniphier_ld11_adamv_reset_data[] = {
253 UNIPHIER_RESETX(0, 0x10, 6), /* EVEA */
254 UNIPHIER_RESET_END,
255};
256
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900257/* core implementaton */
258struct uniphier_reset_priv {
259 struct reset_controller_dev rcdev;
260 struct device *dev;
261 struct regmap *regmap;
262 const struct uniphier_reset_data *data;
263};
264
265#define to_uniphier_reset_priv(_rcdev) \
266 container_of(_rcdev, struct uniphier_reset_priv, rcdev)
267
268static int uniphier_reset_update(struct reset_controller_dev *rcdev,
269 unsigned long id, int assert)
270{
271 struct uniphier_reset_priv *priv = to_uniphier_reset_priv(rcdev);
272 const struct uniphier_reset_data *p;
273
274 for (p = priv->data; p->id != UNIPHIER_RESET_ID_END; p++) {
275 unsigned int mask, val;
276
277 if (p->id != id)
278 continue;
279
280 mask = BIT(p->bit);
281
282 if (assert)
283 val = mask;
284 else
285 val = ~mask;
286
287 if (p->flags & UNIPHIER_RESET_ACTIVE_LOW)
288 val = ~val;
289
290 return regmap_write_bits(priv->regmap, p->reg, mask, val);
291 }
292
293 dev_err(priv->dev, "reset_id=%lu was not handled\n", id);
294 return -EINVAL;
295}
296
297static int uniphier_reset_assert(struct reset_controller_dev *rcdev,
298 unsigned long id)
299{
300 return uniphier_reset_update(rcdev, id, 1);
301}
302
303static int uniphier_reset_deassert(struct reset_controller_dev *rcdev,
304 unsigned long id)
305{
306 return uniphier_reset_update(rcdev, id, 0);
307}
308
309static int uniphier_reset_status(struct reset_controller_dev *rcdev,
310 unsigned long id)
311{
312 struct uniphier_reset_priv *priv = to_uniphier_reset_priv(rcdev);
313 const struct uniphier_reset_data *p;
314
315 for (p = priv->data; p->id != UNIPHIER_RESET_ID_END; p++) {
316 unsigned int val;
317 int ret, asserted;
318
319 if (p->id != id)
320 continue;
321
322 ret = regmap_read(priv->regmap, p->reg, &val);
323 if (ret)
324 return ret;
325
326 asserted = !!(val & BIT(p->bit));
327
328 if (p->flags & UNIPHIER_RESET_ACTIVE_LOW)
329 asserted = !asserted;
330
331 return asserted;
332 }
333
334 dev_err(priv->dev, "reset_id=%lu was not found\n", id);
335 return -EINVAL;
336}
337
338static const struct reset_control_ops uniphier_reset_ops = {
339 .assert = uniphier_reset_assert,
340 .deassert = uniphier_reset_deassert,
341 .status = uniphier_reset_status,
342};
343
344static int uniphier_reset_probe(struct platform_device *pdev)
345{
346 struct device *dev = &pdev->dev;
347 struct uniphier_reset_priv *priv;
348 const struct uniphier_reset_data *p, *data;
349 struct regmap *regmap;
350 struct device_node *parent;
351 unsigned int nr_resets = 0;
352
353 data = of_device_get_match_data(dev);
354 if (WARN_ON(!data))
355 return -EINVAL;
356
357 parent = of_get_parent(dev->of_node); /* parent should be syscon node */
358 regmap = syscon_node_to_regmap(parent);
359 of_node_put(parent);
360 if (IS_ERR(regmap)) {
361 dev_err(dev, "failed to get regmap (error %ld)\n",
362 PTR_ERR(regmap));
363 return PTR_ERR(regmap);
364 }
365
366 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
367 if (!priv)
368 return -ENOMEM;
369
370 for (p = data; p->id != UNIPHIER_RESET_ID_END; p++)
371 nr_resets = max(nr_resets, p->id + 1);
372
373 priv->rcdev.ops = &uniphier_reset_ops;
374 priv->rcdev.owner = dev->driver->owner;
375 priv->rcdev.of_node = dev->of_node;
376 priv->rcdev.nr_resets = nr_resets;
377 priv->dev = dev;
378 priv->regmap = regmap;
379 priv->data = data;
380
381 return devm_reset_controller_register(&pdev->dev, &priv->rcdev);
382}
383
384static const struct of_device_id uniphier_reset_match[] = {
385 /* System reset */
386 {
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900387 .compatible = "socionext,uniphier-ld4-reset",
Masahiro Yamada52810362017-08-06 11:44:01 +0900388 .data = uniphier_ld4_sys_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900389 },
390 {
391 .compatible = "socionext,uniphier-pro4-reset",
392 .data = uniphier_pro4_sys_reset_data,
393 },
394 {
395 .compatible = "socionext,uniphier-sld8-reset",
Masahiro Yamada52810362017-08-06 11:44:01 +0900396 .data = uniphier_ld4_sys_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900397 },
398 {
399 .compatible = "socionext,uniphier-pro5-reset",
400 .data = uniphier_pro5_sys_reset_data,
401 },
402 {
403 .compatible = "socionext,uniphier-pxs2-reset",
404 .data = uniphier_pxs2_sys_reset_data,
405 },
406 {
407 .compatible = "socionext,uniphier-ld11-reset",
408 .data = uniphier_ld11_sys_reset_data,
409 },
410 {
411 .compatible = "socionext,uniphier-ld20-reset",
412 .data = uniphier_ld20_sys_reset_data,
413 },
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900414 {
415 .compatible = "socionext,uniphier-pxs3-reset",
416 .data = uniphier_pxs3_sys_reset_data,
417 },
Kunihiko Hayashi3440b8f2021-10-05 11:10:42 +0900418 {
419 .compatible = "socionext,uniphier-nx1-reset",
420 .data = uniphier_nx1_sys_reset_data,
421 },
Masahiro Yamada19eb4a42016-10-19 17:23:49 +0900422 /* Media I/O reset, SD reset */
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900423 {
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900424 .compatible = "socionext,uniphier-ld4-mio-reset",
Masahiro Yamada52810362017-08-06 11:44:01 +0900425 .data = uniphier_ld4_mio_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900426 },
427 {
428 .compatible = "socionext,uniphier-pro4-mio-reset",
Masahiro Yamada52810362017-08-06 11:44:01 +0900429 .data = uniphier_ld4_mio_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900430 },
431 {
432 .compatible = "socionext,uniphier-sld8-mio-reset",
Masahiro Yamada52810362017-08-06 11:44:01 +0900433 .data = uniphier_ld4_mio_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900434 },
435 {
Masahiro Yamada19eb4a42016-10-19 17:23:49 +0900436 .compatible = "socionext,uniphier-pro5-sd-reset",
437 .data = uniphier_pro5_sd_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900438 },
439 {
Masahiro Yamada19eb4a42016-10-19 17:23:49 +0900440 .compatible = "socionext,uniphier-pxs2-sd-reset",
441 .data = uniphier_pro5_sd_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900442 },
443 {
444 .compatible = "socionext,uniphier-ld11-mio-reset",
Masahiro Yamada52810362017-08-06 11:44:01 +0900445 .data = uniphier_ld4_mio_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900446 },
447 {
Masahiro Yamada88a7f522017-01-15 04:04:46 +0900448 .compatible = "socionext,uniphier-ld11-sd-reset",
449 .data = uniphier_pro5_sd_reset_data,
450 },
451 {
Masahiro Yamada19eb4a42016-10-19 17:23:49 +0900452 .compatible = "socionext,uniphier-ld20-sd-reset",
453 .data = uniphier_pro5_sd_reset_data,
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900454 },
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900455 {
456 .compatible = "socionext,uniphier-pxs3-sd-reset",
457 .data = uniphier_pro5_sd_reset_data,
458 },
Kunihiko Hayashi3440b8f2021-10-05 11:10:42 +0900459 {
460 .compatible = "socionext,uniphier-nx1-sd-reset",
461 .data = uniphier_pro5_sd_reset_data,
462 },
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900463 /* Peripheral reset */
464 {
465 .compatible = "socionext,uniphier-ld4-peri-reset",
466 .data = uniphier_ld4_peri_reset_data,
467 },
468 {
469 .compatible = "socionext,uniphier-pro4-peri-reset",
470 .data = uniphier_pro4_peri_reset_data,
471 },
472 {
473 .compatible = "socionext,uniphier-sld8-peri-reset",
474 .data = uniphier_ld4_peri_reset_data,
475 },
476 {
477 .compatible = "socionext,uniphier-pro5-peri-reset",
478 .data = uniphier_pro4_peri_reset_data,
479 },
480 {
481 .compatible = "socionext,uniphier-pxs2-peri-reset",
482 .data = uniphier_pro4_peri_reset_data,
483 },
484 {
485 .compatible = "socionext,uniphier-ld11-peri-reset",
486 .data = uniphier_pro4_peri_reset_data,
487 },
488 {
489 .compatible = "socionext,uniphier-ld20-peri-reset",
490 .data = uniphier_pro4_peri_reset_data,
491 },
Masahiro Yamada2a158f82017-10-05 11:30:57 +0900492 {
493 .compatible = "socionext,uniphier-pxs3-peri-reset",
494 .data = uniphier_pro4_peri_reset_data,
495 },
Kunihiko Hayashi3440b8f2021-10-05 11:10:42 +0900496 {
497 .compatible = "socionext,uniphier-nx1-peri-reset",
498 .data = uniphier_pro4_peri_reset_data,
499 },
Katsuhiro Suzukiac0c7352017-08-13 18:00:43 +0900500 /* Analog signal amplifiers reset */
501 {
502 .compatible = "socionext,uniphier-ld11-adamv-reset",
503 .data = uniphier_ld11_adamv_reset_data,
504 },
505 {
506 .compatible = "socionext,uniphier-ld20-adamv-reset",
507 .data = uniphier_ld11_adamv_reset_data,
508 },
Masahiro Yamada54e991b2016-08-02 13:18:29 +0900509 { /* sentinel */ }
510};
511MODULE_DEVICE_TABLE(of, uniphier_reset_match);
512
513static struct platform_driver uniphier_reset_driver = {
514 .probe = uniphier_reset_probe,
515 .driver = {
516 .name = "uniphier-reset",
517 .of_match_table = uniphier_reset_match,
518 },
519};
520module_platform_driver(uniphier_reset_driver);
521
522MODULE_AUTHOR("Masahiro Yamada <yamada.masahiro@socionext.com>");
523MODULE_DESCRIPTION("UniPhier Reset Controller Driver");
524MODULE_LICENSE("GPL");