linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Chen <peter.chen@nxp.com>
To: Wesley Cheng <wcheng@codeaurora.org>
Cc: "balbi@kernel.org" <balbi@kernel.org>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"jackp@codeaurora.org" <jackp@codeaurora.org>
Subject: Re: [PATCH 2/3] usb: gadget: composite: Split composite reset and disconnect
Date: Mon, 16 Nov 2020 13:44:44 +0000	[thread overview]
Message-ID: <20201116134415.GE28313@b29397-desktop> (raw)
In-Reply-To: <20201114081247.25063-3-wcheng@codeaurora.org>

On 20-11-14 00:12:46, Wesley Cheng wrote:
> Add a specific composite reset API to differentiate between disconnect and
> reset events.  This is needed for adjusting the current draw accordingly
> based on the USB battery charging specification.  The device is only allowed
> to draw the 500/900 mA (HS/SS) while in the CONFIGURED state, and only 100 mA
> in the connected and UNCONFIGURED state.
> 
> Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>

Reviewed-by: Peter Chen <peter.chen@nxp.com>

Peter
> ---
>  drivers/usb/gadget/composite.c | 21 +++++++++++++++++++--
>  include/linux/usb/composite.h  |  2 ++
>  2 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index 05b176c82cc5..a41f7fe4b518 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -2036,7 +2036,7 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
>  	return value;
>  }
>  
> -void composite_disconnect(struct usb_gadget *gadget)
> +static void __composite_disconnect(struct usb_gadget *gadget)
>  {
>  	struct usb_composite_dev	*cdev = get_gadget_data(gadget);
>  	unsigned long			flags;
> @@ -2053,6 +2053,23 @@ void composite_disconnect(struct usb_gadget *gadget)
>  	spin_unlock_irqrestore(&cdev->lock, flags);
>  }
>  
> +void composite_disconnect(struct usb_gadget *gadget)
> +{
> +	usb_gadget_vbus_draw(gadget, 0);
> +	__composite_disconnect(gadget);
> +}
> +
> +void composite_reset(struct usb_gadget *gadget)
> +{
> +	/*
> +	 * Section 1.4.13 Standard Downstream Port of the USB battery charging
> +	 * specification v1.2 states that a device connected on a SDP shall only
> +	 * draw at max 100mA while in a connected, but unconfigured state.
> +	 */
> +	usb_gadget_vbus_draw(gadget, 100);
> +	__composite_disconnect(gadget);
> +}
> +
>  /*-------------------------------------------------------------------------*/
>  
>  static ssize_t suspended_show(struct device *dev, struct device_attribute *attr,
> @@ -2373,7 +2390,7 @@ static const struct usb_gadget_driver composite_driver_template = {
>  	.unbind		= composite_unbind,
>  
>  	.setup		= composite_setup,
> -	.reset		= composite_disconnect,
> +	.reset		= composite_reset,
>  	.disconnect	= composite_disconnect,
>  
>  	.suspend	= composite_suspend,
> diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
> index 2040696d75b6..0d8a71471512 100644
> --- a/include/linux/usb/composite.h
> +++ b/include/linux/usb/composite.h
> @@ -525,6 +525,8 @@ extern struct usb_string *usb_gstrings_attach(struct usb_composite_dev *cdev,
>  extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
>  
>  extern void composite_disconnect(struct usb_gadget *gadget);
> +extern void composite_reset(struct usb_gadget *gadget);
> +
>  extern int composite_setup(struct usb_gadget *gadget,
>  		const struct usb_ctrlrequest *ctrl);
>  extern void composite_suspend(struct usb_gadget *gadget);
> -- 
> The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
> a Linux Foundation Collaborative Project
> 

-- 

Thanks,
Peter Chen

  reply	other threads:[~2020-11-16 13:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-14  8:12 [PATCH 0/3] Add vbus draw support to DWC3 Wesley Cheng
2020-11-14  8:12 ` [PATCH 1/3] usb: dwc3: gadget: Introduce a DWC3 VBUS draw callback Wesley Cheng
2020-11-16 13:43   ` Peter Chen
2020-11-14  8:12 ` [PATCH 2/3] usb: gadget: composite: Split composite reset and disconnect Wesley Cheng
2020-11-16 13:44   ` Peter Chen [this message]
2020-11-14  8:12 ` [PATCH 3/3] usb: gadget: configfs: Add a specific configFS reset callback Wesley Cheng
2020-11-16 13:55   ` Peter Chen
  -- strict thread matches above, loose matches on Subject: below --
2020-12-29 23:03 [PATCH 0/3] Add vbus draw support to DWC3 Wesley Cheng
2020-12-29 23:03 ` [PATCH 2/3] usb: gadget: composite: Split composite reset and disconnect Wesley Cheng
2021-01-05 13:14   ` Felipe Balbi
2021-01-08  2:19     ` Thinh Nguyen
2021-01-08  8:35       ` Jack Pham
2021-01-08 22:04         ` Thinh Nguyen
2021-01-08  9:13       ` gregkh
2021-01-08 22:13         ` Thinh Nguyen

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=20201116134415.GE28313@b29397-desktop \
    --to=peter.chen@nxp.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackp@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=wcheng@codeaurora.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).