devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Nagarjuna Kristam <nkristam@nvidia.com>
Cc: balbi@kernel.org, gregkh@linuxfoundation.org,
	jonathanh@nvidia.com, mark.rutland@arm.com, robh+dt@kernel.org,
	kishon@ti.com, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-usb@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH V2 2/8] usb: gadget: tegra-xudc: Add vbus_draw support
Date: Tue, 28 Apr 2020 11:59:56 +0200	[thread overview]
Message-ID: <20200428095956.GB3592148@ulmo> (raw)
In-Reply-To: <1586939108-10075-3-git-send-email-nkristam@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]

On Wed, Apr 15, 2020 at 01:55:02PM +0530, Nagarjuna Kristam wrote:
> Register vbus_draw to gadget ops and update corresponding vbus
> draw current to usb_phy.
> 
> Signed-off-by: Nagarjuna Kristam <nkristam@nvidia.com>
> ---
> V2:
>  - Patch re-based.
> ---
>  drivers/usb/gadget/udc/tegra-xudc.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c
> index 52a6add..9d3c109 100644
> --- a/drivers/usb/gadget/udc/tegra-xudc.c
> +++ b/drivers/usb/gadget/udc/tegra-xudc.c
> @@ -492,6 +492,7 @@ struct tegra_xudc {
>  	bool powergated;
>  
>  	struct usb_phy **usbphy;
> +	struct usb_phy *curr_usbphy;
>  	struct notifier_block vbus_nb;
>  
>  	struct completion disconnect_complete;
> @@ -719,6 +720,7 @@ static int tegra_xudc_vbus_notify(struct notifier_block *nb,
>  	if (!xudc->suspended && phy_index != -1) {
>  		xudc->curr_utmi_phy = xudc->utmi_phy[phy_index];
>  		xudc->curr_usb3_phy = xudc->usb3_phy[phy_index];
> +		xudc->curr_usbphy = usbphy;
>  		schedule_work(&xudc->usb_role_sw_work);
>  	}
>  
> @@ -2042,6 +2044,19 @@ static int tegra_xudc_gadget_stop(struct usb_gadget *gadget)
>  	return 0;
>  }
>  
> +static int tegra_xudc_gadget_vbus_draw(struct usb_gadget *gadget,
> +						unsigned int m_a)
> +{
> +	struct tegra_xudc *xudc = to_xudc(gadget);
> +
> +	dev_dbg(xudc->dev, "%s: %u mA\n", __func__, m_a);
> +
> +	if (xudc->curr_usbphy->chg_type == SDP_TYPE)
> +		usb_phy_set_power(xudc->curr_usbphy, m_a);

Do we need to propagate the error code here in case the USB PHY for some
reason doesn't support the given current? Or is it guaranteed that we
always do support whatever is passed in here?

Regardless of whether we support it or not, it might still be useful to
add proper handling, if for nothing else but to set a good example.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-04-28 10:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  8:25 [PATCH V2 0/8] Tegra XUSB charger detect support Nagarjuna Kristam
2020-04-15  8:25 ` [PATCH V2 1/8] dt-bindings: phy: tegra-xusb: Add charger-detect property Nagarjuna Kristam
2020-04-28  9:57   ` Thierry Reding
2020-04-15  8:25 ` [PATCH V2 2/8] usb: gadget: tegra-xudc: Add vbus_draw support Nagarjuna Kristam
2020-04-28  9:59   ` Thierry Reding [this message]
2020-05-04  4:10     ` Nagarjuna Kristam
2020-04-15  8:25 ` [PATCH V2 3/8] phy: tegra: xusb: Add support for UTMI pad power control Nagarjuna Kristam
2020-04-28 10:04   ` Thierry Reding
2020-04-28 10:16   ` Thierry Reding
2020-04-15  8:25 ` [PATCH V2 4/8] phy: tegra: xusb: Add USB2 pad power control support for Tegra210 Nagarjuna Kristam
2020-04-28 10:06   ` Thierry Reding
2020-04-28 10:17   ` Thierry Reding
2020-04-15  8:25 ` [PATCH V2 5/8] phy: tegra: xusb: Add soc ops API to enable UTMI PAD protection Nagarjuna Kristam
2020-04-28 10:15   ` Thierry Reding
2020-05-04 10:26     ` Nagarjuna Kristam
2020-04-15  8:25 ` [PATCH V2 6/8] phy: tegra: xusb: Add support for charger detect Nagarjuna Kristam
2020-04-28 10:55   ` Thierry Reding
2020-05-04  9:02     ` Nagarjuna Kristam
2020-05-04 15:50       ` Thierry Reding
2020-05-11  3:19         ` Nagarjuna Kristam
2020-04-15  8:25 ` [PATCH V2 7/8] phy: tegra: xusb: Enable charger detect for Tegra186 Nagarjuna Kristam
2020-04-28 10:56   ` Thierry Reding
2020-04-15  8:25 ` [PATCH V2 8/8] phy: tegra: xusb: Enable charger detect for Tegra210 Nagarjuna Kristam
2020-04-28 10:56   ` Thierry Reding

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=20200428095956.GB3592148@ulmo \
    --to=thierry.reding@gmail.com \
    --cc=balbi@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jonathanh@nvidia.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nkristam@nvidia.com \
    --cc=robh+dt@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).