lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200128174506.GE2293590@ulmo>
Date:   Tue, 28 Jan 2020 18:45:06 +0100
From:   Thierry Reding <thierry.reding@...il.com>
To:     Nagarjuna Kristam <nkristam@...dia.com>
Cc:     balbi@...nel.org, gregkh@...uxfoundation.org, jonathanh@...dia.com,
        mark.rutland@....com, robh+dt@...nel.org, kishon@...com,
        devicetree@...r.kernel.org, linux-tegra@...r.kernel.org,
        linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [Patch V3 07/18] phy: tegra: xusb: Add set_mode support for utmi
 phy on Tegra186

On Mon, Dec 30, 2019 at 04:39:44PM +0530, Nagarjuna Kristam wrote:
> Add support for set_mode on utmi phy. This allow XUSB host/device mode
> drivers to configure the hardware to corresponding modes.

"utmi" -> "UTMI" in the subject and the commit message.

> 
> Signed-off-by: Nagarjuna Kristam <nkristam@...dia.com>
> ---
> V2-V3:
>  - No changes in this version
> ---
>  drivers/phy/tegra/xusb-tegra186.c | 109 ++++++++++++++++++++++++++++++--------
>  1 file changed, 87 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/phy/tegra/xusb-tegra186.c b/drivers/phy/tegra/xusb-tegra186.c
> index 84c2739..9a45160 100644
> --- a/drivers/phy/tegra/xusb-tegra186.c
> +++ b/drivers/phy/tegra/xusb-tegra186.c
> @@ -301,6 +301,92 @@ static void tegra_phy_xusb_utmi_pad_power_down(struct phy *phy)
>  	tegra186_utmi_bias_pad_power_off(padctl);
>  }
>  
> +static int tegra186_xusb_padctl_vbus_override(struct tegra_xusb_padctl *padctl,
> +					       bool status)
> +{
> +	u32 value;
> +
> +	dev_dbg(padctl->dev, "%s vbus override\n", status ? "set" : "clear");
> +
> +	value = padctl_readl(padctl, USB2_VBUS_ID);
> +
> +	if (status) {
> +		value |= VBUS_OVERRIDE;
> +		value &= ~ID_OVERRIDE(~0);
> +		value |= ID_OVERRIDE_FLOATING;
> +	} else {
> +		value &= ~VBUS_OVERRIDE;
> +	}
> +
> +	padctl_writel(padctl, value, USB2_VBUS_ID);
> +
> +	return 0;
> +}
> +
> +static int tegra186_xusb_padctl_id_override(struct tegra_xusb_padctl *padctl,
> +					    bool status)
> +{
> +	u32 value;
> +
> +	dev_dbg(padctl->dev, "%s id override\n", status ? "set" : "clear");
> +
> +	value = padctl_readl(padctl, USB2_VBUS_ID);
> +
> +	if (status) {
> +		if (value & VBUS_OVERRIDE) {
> +			value &= ~VBUS_OVERRIDE;
> +			padctl_writel(padctl, value, USB2_VBUS_ID);
> +			usleep_range(1000, 2000);
> +
> +			value = padctl_readl(padctl, USB2_VBUS_ID);
> +		}
> +
> +		value &= ~ID_OVERRIDE(~0);
> +		value |= ID_OVERRIDE_GROUNDED;
> +	} else {
> +		value &= ~ID_OVERRIDE(~0);
> +		value |= ID_OVERRIDE_FLOATING;
> +	}
> +
> +	padctl_writel(padctl, value, USB2_VBUS_ID);
> +
> +	return 0;
> +}
> +
> +static int tegra186_utmi_phy_set_mode(struct phy *phy, enum phy_mode mode,
> +				      int submode)
> +{
> +	struct tegra_xusb_lane *lane = phy_get_drvdata(phy);
> +	struct tegra_xusb_padctl *padctl = lane->pad->padctl;
> +	struct tegra_xusb_usb2_port *port = tegra_xusb_find_usb2_port(padctl,
> +								lane->index);
> +	int err = 0;
> +
> +	mutex_lock(&padctl->lock);
> +
> +	dev_dbg(&port->base.dev, "%s: mode %d", __func__, mode);
> +
> +	if (mode == PHY_MODE_USB_OTG) {
> +		if (submode == USB_ROLE_HOST) {
> +			tegra186_xusb_padctl_id_override(padctl, true);
> +
> +			err = regulator_enable(port->supply);
> +		} else if (submode == USB_ROLE_DEVICE) {
> +			tegra186_xusb_padctl_vbus_override(padctl, true);
> +		} else if (submode == USB_ROLE_NONE) {
> +			if (regulator_is_enabled(port->supply))

I vaguely recall that we discussed this before, but I don't recall. Why
do we need to check that the regulator is enabled? Regulators are
reference-counted, so as long as the reference count is balanced, there
should be no need to check for this.

If there's really no way to avoid this check, perhaps add a comment that
points out exactly why this is needed?

With that fixed:

Acked-by: Thierry Reding <treding@...dia.com>

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ