Skip to content

Commit d2fd1dd

Browse files
committed
Merge tag 'reset-for-v5.20' of git://git.pengutronix.de/pza/linux into arm/late
Reset controller updates for v5.20 Allow reset-simple to be selected under EXPERT and reset-a10sr to be built under COMPILE_TEST. Add Renesas RZ/G2UL USBPHY binding and a new driver for the TI TPS380x line of voltage supervisor ICs with manual reset control. A patch to make reset-microchip-sparx5 buildable as a module had to be reverted as that turned out to break MDIO on kswitch-d10. * tag 'reset-for-v5.20' of git://git.pengutronix.de/pza/linux: reset: tps380x: Fix spelling mistake "Voltags" -> "Voltage" reset: tps380x: Add TPS380x device driver supprt dt-bindings: reset: Add TPS380x documentation dt-bindings: reset: renesas,rzg2l-usbphy-ctrl: Document RZ/G2UL USBPHY Control bindings reset: reset-simple should depends on HAS_IOMEM Revert "reset: microchip-sparx5: allow building as a module" reset: a10sr: allow building under COMPILE_TEST reset: allow building of reset simple driver if expert config selected reset: microchip-sparx5: allow building as a module Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 3d7cb6b + d985db8 commit d2fd1dd

File tree

5 files changed

+188
-2
lines changed

5 files changed

+188
-2
lines changed

Documentation/devicetree/bindings/reset/renesas,rzg2l-usbphy-ctrl.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ properties:
1717
compatible:
1818
items:
1919
- enum:
20+
- renesas,r9a07g043-usbphy-ctrl # RZ/G2UL
2021
- renesas,r9a07g044-usbphy-ctrl # RZ/G2{L,LC}
2122
- renesas,r9a07g054-usbphy-ctrl # RZ/V2L
2223
- const: renesas,rzg2l-usbphy-ctrl
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only or BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/reset/ti,tps380x-reset.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: TI TPS380x reset controller node bindings
8+
9+
maintainers:
10+
- Marco Felsch <[email protected]>
11+
12+
description: |
13+
The TPS380x family [1] of supervisory circuits monitor supply voltages to
14+
provide circuit initialization and timing supervision. The devices assert a
15+
RESET signal if the voltage drops below a preset threshold or upon a manual
16+
reset input (MR). The RESET output remains asserted for the factory
17+
programmed delay after the voltage return above its threshold or after the
18+
manual reset input is released.
19+
20+
[1] https://www.ti.com/product/TPS3801
21+
22+
properties:
23+
compatible:
24+
enum:
25+
- ti,tps3801
26+
27+
reset-gpios:
28+
maxItems: 1
29+
description: Reference to the GPIO connected to the MR pin.
30+
31+
"#reset-cells":
32+
const: 0
33+
34+
required:
35+
- compatible
36+
- reset-gpios
37+
- "#reset-cells"
38+
39+
additionalProperties: false
40+
41+
examples:
42+
- |
43+
#include <dt-bindings/gpio/gpio.h>
44+
reset: reset-controller {
45+
compatible = "ti,tps3801";
46+
#reset-cells = <0>;
47+
reset-gpios = <&gpio3 2 GPIO_ACTIVE_LOW>;
48+
};
49+
...

drivers/reset/Kconfig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if RESET_CONTROLLER
1717

1818
config RESET_A10SR
1919
tristate "Altera Arria10 System Resource Reset"
20-
depends on MFD_ALTERA_A10SR
20+
depends on MFD_ALTERA_A10SR || COMPILE_TEST
2121
help
2222
This option enables support for the external reset functions for
2323
peripheral PHYs on the Altera Arria10 System Resource Chip.
@@ -200,8 +200,9 @@ config RESET_SCMI
200200
firmware controlling all the reset signals.
201201

202202
config RESET_SIMPLE
203-
bool "Simple Reset Controller Driver" if COMPILE_TEST
203+
bool "Simple Reset Controller Driver" if COMPILE_TEST || EXPERT
204204
default ARCH_ASPEED || ARCH_BCM4908 || ARCH_BITMAIN || ARCH_REALTEK || ARCH_STM32 || (ARCH_INTEL_SOCFPGA && ARM64) || ARCH_SUNXI || ARC
205+
depends on HAS_IOMEM
205206
help
206207
This enables a simple reset controller driver for reset lines that
207208
that can be asserted and deasserted by toggling bits in a contiguous,
@@ -256,6 +257,14 @@ config RESET_TI_SYSCON
256257
you wish to use the reset framework for such memory-mapped devices,
257258
say Y here. Otherwise, say N.
258259

260+
config RESET_TI_TPS380X
261+
tristate "TI TPS380x Reset Driver"
262+
select GPIOLIB
263+
help
264+
This enables the reset driver support for TI TPS380x devices. If
265+
you wish to use the reset framework for such devices, say Y here.
266+
Otherwise, say N.
267+
259268
config RESET_TN48M_CPLD
260269
tristate "Delta Networks TN48M switch CPLD reset controller"
261270
depends on MFD_TN48M_CPLD || COMPILE_TEST

drivers/reset/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ obj-$(CONFIG_RESET_STARFIVE_JH7100) += reset-starfive-jh7100.o
3333
obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o
3434
obj-$(CONFIG_RESET_TI_SCI) += reset-ti-sci.o
3535
obj-$(CONFIG_RESET_TI_SYSCON) += reset-ti-syscon.o
36+
obj-$(CONFIG_RESET_TI_TPS380X) += reset-tps380x.o
3637
obj-$(CONFIG_RESET_TN48M_CPLD) += reset-tn48m.o
3738
obj-$(CONFIG_RESET_UNIPHIER) += reset-uniphier.o
3839
obj-$(CONFIG_RESET_UNIPHIER_GLUE) += reset-uniphier-glue.o

drivers/reset/reset-tps380x.c

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* TI TPS380x Supply Voltage Supervisor and Reset Controller Driver
4+
*
5+
* Copyright (C) 2022 Pengutronix, Marco Felsch <[email protected]>
6+
*
7+
* Based on Simple Reset Controller Driver
8+
*
9+
* Copyright (C) 2017 Pengutronix, Philipp Zabel <[email protected]>
10+
*/
11+
12+
#include <linux/delay.h>
13+
#include <linux/gpio/consumer.h>
14+
#include <linux/module.h>
15+
#include <linux/of.h>
16+
#include <linux/platform_device.h>
17+
#include <linux/property.h>
18+
#include <linux/reset-controller.h>
19+
20+
struct tps380x_reset {
21+
struct reset_controller_dev rcdev;
22+
struct gpio_desc *reset_gpio;
23+
unsigned int reset_ms;
24+
};
25+
26+
struct tps380x_reset_devdata {
27+
unsigned int min_reset_ms;
28+
unsigned int typ_reset_ms;
29+
unsigned int max_reset_ms;
30+
};
31+
32+
static inline
33+
struct tps380x_reset *to_tps380x_reset(struct reset_controller_dev *rcdev)
34+
{
35+
return container_of(rcdev, struct tps380x_reset, rcdev);
36+
}
37+
38+
static int
39+
tps380x_reset_assert(struct reset_controller_dev *rcdev, unsigned long id)
40+
{
41+
struct tps380x_reset *tps380x = to_tps380x_reset(rcdev);
42+
43+
gpiod_set_value_cansleep(tps380x->reset_gpio, 1);
44+
45+
return 0;
46+
}
47+
48+
static int
49+
tps380x_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id)
50+
{
51+
struct tps380x_reset *tps380x = to_tps380x_reset(rcdev);
52+
53+
gpiod_set_value_cansleep(tps380x->reset_gpio, 0);
54+
msleep(tps380x->reset_ms);
55+
56+
return 0;
57+
}
58+
59+
static const struct reset_control_ops reset_tps380x_ops = {
60+
.assert = tps380x_reset_assert,
61+
.deassert = tps380x_reset_deassert,
62+
};
63+
64+
static int tps380x_reset_of_xlate(struct reset_controller_dev *rcdev,
65+
const struct of_phandle_args *reset_spec)
66+
{
67+
/* No special handling needed, we have only one reset line per device */
68+
return 0;
69+
}
70+
71+
static int tps380x_reset_probe(struct platform_device *pdev)
72+
{
73+
struct device *dev = &pdev->dev;
74+
const struct tps380x_reset_devdata *devdata;
75+
struct tps380x_reset *tps380x;
76+
77+
devdata = device_get_match_data(dev);
78+
if (!devdata)
79+
return -EINVAL;
80+
81+
tps380x = devm_kzalloc(dev, sizeof(*tps380x), GFP_KERNEL);
82+
if (!tps380x)
83+
return -ENOMEM;
84+
85+
tps380x->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
86+
if (IS_ERR(tps380x->reset_gpio))
87+
return dev_err_probe(dev, PTR_ERR(tps380x->reset_gpio),
88+
"Failed to get GPIO\n");
89+
90+
tps380x->reset_ms = devdata->max_reset_ms;
91+
92+
tps380x->rcdev.ops = &reset_tps380x_ops;
93+
tps380x->rcdev.owner = THIS_MODULE;
94+
tps380x->rcdev.dev = dev;
95+
tps380x->rcdev.of_node = dev->of_node;
96+
tps380x->rcdev.of_reset_n_cells = 0;
97+
tps380x->rcdev.of_xlate = tps380x_reset_of_xlate;
98+
tps380x->rcdev.nr_resets = 1;
99+
100+
return devm_reset_controller_register(dev, &tps380x->rcdev);
101+
}
102+
103+
static const struct tps380x_reset_devdata tps3801_reset_data = {
104+
.min_reset_ms = 120,
105+
.typ_reset_ms = 200,
106+
.max_reset_ms = 280,
107+
};
108+
109+
static const struct of_device_id tps380x_reset_dt_ids[] = {
110+
{ .compatible = "ti,tps3801", .data = &tps3801_reset_data },
111+
{ /* sentinel */ },
112+
};
113+
MODULE_DEVICE_TABLE(of, tps380x_reset_dt_ids);
114+
115+
static struct platform_driver tps380x_reset_driver = {
116+
.probe = tps380x_reset_probe,
117+
.driver = {
118+
.name = "tps380x-reset",
119+
.of_match_table = tps380x_reset_dt_ids,
120+
},
121+
};
122+
module_platform_driver(tps380x_reset_driver);
123+
124+
MODULE_AUTHOR("Marco Felsch <[email protected]>");
125+
MODULE_DESCRIPTION("TI TPS380x Supply Voltage Supervisor and Reset Driver");
126+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)