From: Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com>
To: Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: John Youn <John.Youn@synopsys.com>,
Sevak Arakelyan <SEVAK.ARAKELYAN@synopsys.com>
Subject: [PATCH 8/9] [HSLPM] usb: gadget: Allow a non-SuperSpeed gadget to support LPM
Date: Fri, 28 Apr 2017 12:55:20 +0400 [thread overview]
Message-ID: <a58f6795ac2e72d65133e2b37546b48adf4359b0.1493369198.git.sevaka@synopsys.com> (raw)
In-Reply-To: <cover.1493369198.git.sevaka@synopsys.com>
From: John Youn <johnyoun@synopsys.com>
This commit allows a gadget that does not support SuperSpeed to indicate
that it supports LPM. It does this by setting the 'lpm_capable' flag in
the gadget structure.
If a gadget sets this, the composite gadget framework will set the
bcdUSB to 0x0201 to indicate that this supports BOS descriptors, and
also return a USB 2.0 Extension descriptor as part of the BOS descriptor
set.
See USB 2.0 LPM ECN Section 3.
Signed-off-by: John Youn <johnyoun@synopsys.com>
Signed-off-by: Sevak Arakelyan <sevaka@synopsys.com>
---
drivers/usb/gadget/composite.c | 8 ++++++--
include/linux/usb/gadget.h | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index abec93ab81ee..d62f53d7f418 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1608,7 +1608,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
cdev->desc.bcdUSB = cpu_to_le16(0x0210);
}
} else {
- cdev->desc.bcdUSB = cpu_to_le16(0x0200);
+ if (gadget->lpm_capable)
+ cdev->desc.bcdUSB = cpu_to_le16(0x0201);
+ else
+ cdev->desc.bcdUSB = cpu_to_le16(0x0200);
}
value = min(w_length, (u16) sizeof cdev->desc);
@@ -1639,7 +1642,8 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
value = min(w_length, (u16) value);
break;
case USB_DT_BOS:
- if (gadget_is_superspeed(gadget)) {
+ if (gadget_is_superspeed(gadget) ||
+ gadget->lpm_capable) {
value = bos_desc(cdev);
value = min(w_length, (u16) value);
}
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index e4516e9ded0f..927df464100d 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -352,6 +352,8 @@ struct usb_gadget_ops {
* @deactivated: True if gadget is deactivated - in deactivated state it cannot
* be connected.
* @connected: True if gadget is connected.
+ * @lpm_capable: If the gadget max_speed is FULL or HIGH, this flag
+ * indicates that it supports LPM as per the LPM ECN & errata.
*
* Gadgets have a mostly-portable "gadget driver" implementing device
* functions, handling all usb configurations and interfaces. Gadget
@@ -404,6 +406,7 @@ struct usb_gadget {
unsigned is_selfpowered:1;
unsigned deactivated:1;
unsigned connected:1;
+ unsigned lpm_capable:1;
};
#define work_to_gadget(w) (container_of((w), struct usb_gadget, work))
--
2.11.0
next prev parent reply other threads:[~2017-04-28 8:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-28 8:46 [PATCH 0/9] usb: dwc2: gadget: Add LPM functionality Sevak Arakelyan
2017-04-28 8:47 ` [PATCH 1/9] usb: dwc2: Fix GLPMCFG... definitions Sevak Arakelyan
2017-04-28 8:48 ` [PATCH 2/9] usb: dwc2: Add core parameters for LPM support Sevak Arakelyan
2017-04-28 8:48 ` [PATCH 3/9] usb: dwc2: gadget: Add functionality to exit from LPM L1 state Sevak Arakelyan
2017-04-28 8:48 ` [PATCH 4/9] usb: dwc2: gadget: LPM interrupt handler Sevak Arakelyan
2017-04-28 8:55 ` [PATCH 5/9] usb: dwc2: Enable LPM Transaction Received interrupt Sevak Arakelyan
2017-04-28 8:55 ` [PATCH 6/9] usb: dwc2: gadget: Configure the core to enable LPM Sevak Arakelyan
2017-04-28 8:55 ` [PATCH 7/9] [HSLPM] usb: gadget: composite: Exclude SS Dev Cap Desc Sevak Arakelyan
2017-04-28 8:55 ` Sevak Arakelyan [this message]
2017-04-28 8:56 ` [PATCH 9/9] [HSLPM] usb: dwc2: Enable LPM Sevak Arakelyan
2017-04-28 9:24 ` Greg Kroah-Hartman
2017-06-02 8:20 ` Felipe Balbi
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=a58f6795ac2e72d65133e2b37546b48adf4359b0.1493369198.git.sevaka@synopsys.com \
--to=sevak.arakelyan@synopsys.com \
--cc=John.Youn@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.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
all inboxes | Powered by JetHome®