From: Lee Jones <lee@kernel.org>
To: Thomas Richard <thomas.richard@bootlin.com>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
Andreas Kemnade <andreas@kemnade.info>,
Kevin Hilman <khilman@baylibre.com>,
Roger Quadros <rogerq@kernel.org>,
Tony Lindgren <tony@atomide.com>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v2 10/11] mfd: omap-usb-host: Add pbias regulator support
Date: Wed, 29 Apr 2026 14:06:04 +0100 [thread overview]
Message-ID: <20260429130604.GD1806155@google.com> (raw)
In-Reply-To: <20260330-omap4-fix-usb-support-v2-10-1c1e11b190dc@bootlin.com>
On Mon, 30 Mar 2026, Thomas Richard wrote:
> Add pbias regulator support to enable SIM_VDDS supply and unlock USB I/O
> cell. Previously, this was handled by the bootloader, now the kernel can
> take responsibility for managing the PBIAS regulator, ensuring correct
> operation regardless of the bootloader.
>
> Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
> ---
> drivers/mfd/omap-usb-host.c | 55 ++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 54 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mfd/omap-usb-host.c b/drivers/mfd/omap-usb-host.c
> index 17a54f0087c3..907fb614d464 100644
> --- a/drivers/mfd/omap-usb-host.c
> +++ b/drivers/mfd/omap-usb-host.c
> @@ -15,6 +15,8 @@
> #include <linux/pm_runtime.h>
> #include <linux/of.h>
> #include <linux/of_platform.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/string_choices.h>
>
> #include "omap-usb.h"
>
> @@ -95,6 +97,8 @@ struct usbhs_hcd_omap {
> struct usbhs_omap_platform_data *pdata;
>
> u32 usbhs_rev;
> +
> + struct regulator *pbias;
> };
> /*-------------------------------------------------------------------------*/
>
> @@ -334,26 +338,60 @@ static int usbhs_clocks_enable(struct device *dev, bool enable)
> return r;
> }
>
> +static int omap_usbhs_set_pbias(struct device *dev, bool power_on)
I think this is a little over-engineered as well.
I'm willing to bet that it saves ~0 LoC.
> +{
> + struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
> + int ret;
> +
> + if (!omap->pbias)
> + return 0;
> +
> + if (power_on)
> + ret = regulator_enable(omap->pbias);
> + else
> + ret = regulator_disable(omap->pbias);
> +
> + if (ret)
> + dev_err(dev, "pbias reg %s failed\n", str_enable_disable(power_on));
> +
> + return ret;
> +}
> +
> static int usbhs_runtime_resume(struct device *dev)
> {
> struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
> struct usbhs_omap_platform_data *pdata = omap->pdata;
> + int ret;
>
> omap_tll_enable(pdata);
>
> - return usbhs_clocks_enable(dev, true);
> + ret = usbhs_clocks_enable(dev, true);
> + if (ret)
> + return ret;
> +
> + return omap_usbhs_set_pbias(dev, true);
... but if you _insist_ on doing it this way, at least define the true
to something meaningful.
> }
>
> static int usbhs_runtime_suspend(struct device *dev)
> {
> struct usbhs_hcd_omap *omap = dev_get_drvdata(dev);
> struct usbhs_omap_platform_data *pdata = omap->pdata;
> + int ret;
>
> usbhs_clocks_enable(dev, false);
>
> omap_tll_disable(pdata);
>
> + ret = omap_usbhs_set_pbias(dev, false);
> + if (ret)
> + goto err;
> +
> return 0;
> +
> +err:
> + omap_tll_enable(pdata);
> + usbhs_clocks_enable(dev, true);
> + return ret;
> }
>
> static unsigned omap_usbhs_rev1_hostconfig(struct usbhs_hcd_omap *omap,
> @@ -562,6 +600,15 @@ static int usbhs_omap_probe(struct platform_device *pdev)
>
> omap->pdata = pdata;
>
> + omap->pbias = devm_regulator_get_optional(dev, "pbias");
> + if (IS_ERR(omap->pbias)) {
> + if (PTR_ERR(omap->pbias) == -ENODEV)
> + omap->pbias = NULL;
> + else
> + return dev_err_probe(dev, PTR_ERR(omap->pbias),
> + "unable to get pbias regulator\n");
> + }
> +
> /* Initialize the TLL subsystem */
> omap_tll_init(pdata);
>
> @@ -757,6 +804,10 @@ static int usbhs_omap_probe(struct platform_device *pdev)
> }
>
> initialize:
> + ret = omap_usbhs_set_pbias(dev, true);
> + if (ret)
> + goto err_mem;
> +
> omap_usbhs_init(dev);
>
> if (dev->of_node) {
> @@ -804,6 +855,8 @@ static void usbhs_omap_remove(struct platform_device *pdev)
> of_platform_depopulate(&pdev->dev);
> else
> device_for_each_child(&pdev->dev, NULL, usbhs_omap_remove_child);
> +
> + omap_usbhs_set_pbias(&pdev->dev, false);
> }
>
> static const struct dev_pm_ops usbhsomap_dev_pm_ops = {
>
> --
> 2.53.0
>
--
Lee Jones
next prev parent reply other threads:[~2026-04-29 13:06 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 13:43 [PATCH v2 00/11] Add SIM pbias regulator support for USB on OMAP4 Thomas Richard
2026-03-30 13:43 ` [PATCH v2 01/11] dt-bindings: regulator: ti,pbias-regulator: Convert to DT schema Thomas Richard
2026-03-31 8:21 ` Krzysztof Kozlowski
2026-04-08 7:57 ` Thomas Richard
2026-04-08 12:38 ` Rob Herring
2026-03-30 13:43 ` [PATCH v2 02/11] dt-bindings: regulator: ti,pbias-regulator: Add pbias_sim_omap4 regulator Thomas Richard
2026-03-31 8:22 ` Krzysztof Kozlowski
2026-04-08 7:58 ` Thomas Richard
2026-04-08 12:41 ` Rob Herring
2026-04-08 13:01 ` Thomas Richard
2026-03-30 13:44 ` [PATCH v2 03/11] regulator: pbias: Add pbias SIM regulator for OMAP4 Thomas Richard
2026-03-30 13:44 ` [PATCH v2 04/11] ARM: dts: ti: omap4: Add pbias SIM regulator Thomas Richard
2026-03-30 13:44 ` [PATCH v2 05/11] mfd: omap-usb-host: Cleanup header includes Thomas Richard
2026-03-30 13:44 ` [PATCH v2 06/11] mfd: omap-usb-host: Sanitize error path in the probe() Thomas Richard
2026-04-29 11:58 ` Lee Jones
2026-03-30 13:44 ` [PATCH v2 07/11] mfd: omap-usb-host: Refactor suspend and resume callbacks Thomas Richard
2026-04-29 12:59 ` Lee Jones
2026-03-30 13:44 ` [PATCH v2 08/11] dt-bindings: mfd: ti,omap-usb-host: Convert to DT schema Thomas Richard
2026-04-08 12:55 ` Rob Herring
2026-03-30 13:44 ` [PATCH v2 09/11] dt-bindings: mfd: ti,omap-usb-host: Add 'pbias-supply' property Thomas Richard
2026-03-30 16:40 ` Thomas Richard
2026-03-30 13:44 ` [PATCH v2 10/11] mfd: omap-usb-host: Add pbias regulator support Thomas Richard
2026-04-29 13:06 ` Lee Jones [this message]
2026-03-30 13:44 ` [PATCH v2 11/11] ARM: dts: ti: omap4: Add pbias regulator to the HS USB Host Thomas Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260429130604.GD1806155@google.com \
--to=lee@kernel.org \
--cc=aaro.koskinen@iki.fi \
--cc=andreas@kemnade.info \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=robh@kernel.org \
--cc=rogerq@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=thomas.richard@bootlin.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox