Skip to content

Commit 2bb1acc

Browse files
committed
Merge tag 'reset-for-v6.11-2' of git://git.pengutronix.de/pza/linux into soc/drivers
Reset controller updates for v6.11, part 2 This tag adds USB VBUS regulator control for Renesas RZ/G2L SoCs, which also touches PHY driver and device tree, and pulls in a new regulator_hardware_enable() helper. The Tegra BPMP reset driver can be compiled under COMPILE_TEST now. * tag 'reset-for-v6.11-2' of git://git.pengutronix.de/pza/linux: arm64: dts: renesas: rz-smarc: Replace fixed regulator for USB VBUS phy: renesas: phy-rcar-gen3-usb2: Control VBUS for RZ/G2L SoCs reset: renesas: Add USB VBUS regulator device as child dt-bindings: reset: renesas,rzg2l-usbphy-ctrl: Document USB VBUS regulator reset: tegra-bpmp: allow building under COMPILE_TEST regulator: core: Add helper for allow HW access to enable/disable regulator Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents ee22fbd + c1267e1 commit 2bb1acc

File tree

9 files changed

+95
-11
lines changed

9 files changed

+95
-11
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,20 @@ properties:
4242
0 = Port 1 Phy reset
4343
1 = Port 2 Phy reset
4444
45+
regulator-vbus:
46+
type: object
47+
description: USB VBUS regulator
48+
$ref: /schemas/regulator/regulator.yaml#
49+
unevaluatedProperties: false
50+
4551
required:
4652
- compatible
4753
- reg
4854
- clocks
4955
- resets
5056
- power-domains
5157
- '#reset-cells'
58+
- regulator-vbus
5259

5360
additionalProperties: false
5461

@@ -64,4 +71,7 @@ examples:
6471
resets = <&cpg R9A07G044_USB_PRESETN>;
6572
power-domains = <&cpg>;
6673
#reset-cells = <1>;
74+
regulator-vbus {
75+
regulator-name = "vbus";
76+
};
6777
};

Documentation/power/regulator/consumer.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,9 @@ directly written to the voltage selector register, use::
227227

228228
int regulator_list_hardware_vsel(struct regulator *regulator,
229229
unsigned selector);
230+
231+
To access the hardware for enabling/disabling the regulator, consumers must
232+
use regulator_get_exclusive(), as it can't work if there's more than one
233+
consumer. To enable/disable regulator use::
234+
235+
int regulator_hardware_enable(struct regulator *regulator, bool enable);

arch/arm64/boot/dts/renesas/rz-smarc-common.dtsi

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,6 @@
5454
};
5555
};
5656

57-
usb0_vbus_otg: regulator-usb0-vbus-otg {
58-
compatible = "regulator-fixed";
59-
60-
regulator-name = "USB0_VBUS_OTG";
61-
regulator-min-microvolt = <5000000>;
62-
regulator-max-microvolt = <5000000>;
63-
};
64-
6557
vccq_sdhi1: regulator-vccq-sdhi1 {
6658
compatible = "regulator-gpio";
6759
regulator-name = "SDHI1 VccQ";
@@ -139,6 +131,9 @@
139131

140132
&phyrst {
141133
status = "okay";
134+
usb0_vbus_otg: regulator-vbus {
135+
regulator-name = "vbus";
136+
};
142137
};
143138

144139
&scif0 {

drivers/phy/renesas/phy-rcar-gen3-usb2.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ static void rcar_gen3_enable_vbus_ctrl(struct rcar_gen3_chan *ch, int vbus)
188188

189189
dev_vdbg(ch->dev, "%s: %08x, %d\n", __func__, val, vbus);
190190
if (ch->soc_no_adp_ctrl) {
191+
if (ch->vbus)
192+
regulator_hardware_enable(ch->vbus, vbus);
193+
191194
vbus_ctrl_reg = USB2_VBCTRL;
192195
vbus_ctrl_val = USB2_VBCTRL_VBOUT;
193196
}
@@ -718,7 +721,10 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device *pdev)
718721
phy_set_drvdata(channel->rphys[i].phy, &channel->rphys[i]);
719722
}
720723

721-
channel->vbus = devm_regulator_get_optional(dev, "vbus");
724+
if (channel->soc_no_adp_ctrl && channel->is_otg_channel)
725+
channel->vbus = devm_regulator_get_exclusive(dev, "vbus");
726+
else
727+
channel->vbus = devm_regulator_get_optional(dev, "vbus");
722728
if (IS_ERR(channel->vbus)) {
723729
if (PTR_ERR(channel->vbus) == -EPROBE_DEFER) {
724730
ret = PTR_ERR(channel->vbus);

drivers/regulator/core.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3408,6 +3408,34 @@ int regulator_list_hardware_vsel(struct regulator *regulator,
34083408
}
34093409
EXPORT_SYMBOL_GPL(regulator_list_hardware_vsel);
34103410

3411+
/**
3412+
* regulator_hardware_enable - access the HW for enable/disable regulator
3413+
* @regulator: regulator source
3414+
* @enable: true for enable, false for disable
3415+
*
3416+
* Request that the regulator be enabled/disabled with the regulator output at
3417+
* the predefined voltage or current value.
3418+
*
3419+
* On success 0 is returned, otherwise a negative errno is returned.
3420+
*/
3421+
int regulator_hardware_enable(struct regulator *regulator, bool enable)
3422+
{
3423+
struct regulator_dev *rdev = regulator->rdev;
3424+
const struct regulator_ops *ops = rdev->desc->ops;
3425+
int ret = -EOPNOTSUPP;
3426+
3427+
if (!rdev->exclusive || !ops || !ops->enable || !ops->disable)
3428+
return ret;
3429+
3430+
if (enable)
3431+
ret = ops->enable(rdev);
3432+
else
3433+
ret = ops->disable(rdev);
3434+
3435+
return ret;
3436+
}
3437+
EXPORT_SYMBOL_GPL(regulator_hardware_enable);
3438+
34113439
/**
34123440
* regulator_get_linear_step - return the voltage step size between VSEL values
34133441
* @regulator: regulator source

drivers/reset/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ obj-y += core.o
33
obj-y += hisilicon/
44
obj-y += starfive/
55
obj-y += sti/
6-
obj-$(CONFIG_ARCH_TEGRA) += tegra/
6+
obj-y += tegra/
77
obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
88
obj-$(CONFIG_RESET_ATH79) += reset-ath79.o
99
obj-$(CONFIG_RESET_AXS10X) += reset-axs10x.o

drivers/reset/reset-rzg2l-usbphy-ctrl.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
#include <linux/of.h>
1111
#include <linux/platform_device.h>
1212
#include <linux/pm_runtime.h>
13+
#include <linux/regmap.h>
1314
#include <linux/reset.h>
1415
#include <linux/reset-controller.h>
1516

1617
#define RESET 0x000
18+
#define VBENCTL 0x03c
1719

1820
#define RESET_SEL_PLLRESET BIT(12)
1921
#define RESET_PLLRESET BIT(8)
@@ -32,6 +34,7 @@ struct rzg2l_usbphy_ctrl_priv {
3234
struct reset_controller_dev rcdev;
3335
struct reset_control *rstc;
3436
void __iomem *base;
37+
struct platform_device *vdev;
3538

3639
spinlock_t lock;
3740
};
@@ -100,10 +103,19 @@ static const struct reset_control_ops rzg2l_usbphy_ctrl_reset_ops = {
100103
.status = rzg2l_usbphy_ctrl_status,
101104
};
102105

106+
static const struct regmap_config rzg2l_usb_regconf = {
107+
.reg_bits = 32,
108+
.val_bits = 32,
109+
.reg_stride = 4,
110+
.max_register = 1,
111+
};
112+
103113
static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
104114
{
105115
struct device *dev = &pdev->dev;
106116
struct rzg2l_usbphy_ctrl_priv *priv;
117+
struct platform_device *vdev;
118+
struct regmap *regmap;
107119
unsigned long flags;
108120
int error;
109121
u32 val;
@@ -116,6 +128,10 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
116128
if (IS_ERR(priv->base))
117129
return PTR_ERR(priv->base);
118130

131+
regmap = devm_regmap_init_mmio(dev, priv->base + VBENCTL, &rzg2l_usb_regconf);
132+
if (IS_ERR(regmap))
133+
return PTR_ERR(regmap);
134+
119135
priv->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
120136
if (IS_ERR(priv->rstc))
121137
return dev_err_probe(dev, PTR_ERR(priv->rstc),
@@ -152,8 +168,22 @@ static int rzg2l_usbphy_ctrl_probe(struct platform_device *pdev)
152168
if (error)
153169
goto err_pm_runtime_put;
154170

171+
vdev = platform_device_alloc("rzg2l-usb-vbus-regulator", pdev->id);
172+
if (!vdev) {
173+
error = -ENOMEM;
174+
goto err_pm_runtime_put;
175+
}
176+
vdev->dev.parent = dev;
177+
priv->vdev = vdev;
178+
179+
error = platform_device_add(vdev);
180+
if (error)
181+
goto err_device_put;
182+
155183
return 0;
156184

185+
err_device_put:
186+
platform_device_put(vdev);
157187
err_pm_runtime_put:
158188
pm_runtime_put(&pdev->dev);
159189
err_pm_disable_reset_deassert:
@@ -166,6 +196,7 @@ static int rzg2l_usbphy_ctrl_remove(struct platform_device *pdev)
166196
{
167197
struct rzg2l_usbphy_ctrl_priv *priv = dev_get_drvdata(&pdev->dev);
168198

199+
platform_device_unregister(priv->vdev);
169200
pm_runtime_put(&pdev->dev);
170201
pm_runtime_disable(&pdev->dev);
171202
reset_control_assert(priv->rstc);

drivers/reset/tegra/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
config RESET_TEGRA_BPMP
3-
def_bool TEGRA_BPMP
3+
bool "Tegra BPMP Reset Driver" if COMPILE_TEST
4+
default TEGRA_BPMP

include/linux/regulator/consumer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ int regulator_get_hardware_vsel_register(struct regulator *regulator,
250250
unsigned *vsel_mask);
251251
int regulator_list_hardware_vsel(struct regulator *regulator,
252252
unsigned selector);
253+
int regulator_hardware_enable(struct regulator *regulator, bool enable);
253254

254255
/* regulator notifier block */
255256
int regulator_register_notifier(struct regulator *regulator,
@@ -571,6 +572,12 @@ static inline int regulator_list_hardware_vsel(struct regulator *regulator,
571572
return -EOPNOTSUPP;
572573
}
573574

575+
static inline int regulator_hardware_enable(struct regulator *regulator,
576+
bool enable)
577+
{
578+
return -EOPNOTSUPP;
579+
}
580+
574581
static inline int regulator_register_notifier(struct regulator *regulator,
575582
struct notifier_block *nb)
576583
{

0 commit comments

Comments
 (0)