From patchwork Tue Aug 20 01:35:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11102559 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 497651398 for ; Tue, 20 Aug 2019 01:35:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2736122D37 for ; Tue, 20 Aug 2019 01:35:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="JuKZ2//r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728982AbfHTBfz (ORCPT ); Mon, 19 Aug 2019 21:35:55 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.47.102]:50112 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728627AbfHTBfy (ORCPT ); Mon, 19 Aug 2019 21:35:54 -0400 Received: from mailhost.synopsys.com (dc8-mailhost2.synopsys.com [10.13.135.210]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id D53A5C0134; Tue, 20 Aug 2019 01:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1566264953; bh=nP/C/1XlWZRgQzsMF6HxKTSTYMg2hn7UfB6YhKNB2xg=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=JuKZ2//rvh5qDTygFPKiIOhgt962HW8nNF7tve5TI9yP1NGRQvr+OGBPwMBPLKyK6 aggqiWEubljDbNCKAihcpceK+K21YtgHWDoEslt3/iUeXgWQ8o2T1wqJcn/02hfTwU VTCTaGDPJ/UCxlld7ZeXEHaJe3VcmWPaYWdz/Xs1zM6pN3OG8NED8cpzLR0FGPfcgp YN8KkXeHyLpdhSr4PdZa2egyHWAUg3jXxX0/O0WazybFNmc+Rbcw+rUt62qkY2q9/5 NX6DrRfaX2CBBABOIKfrzvao3SawcwsLGyBgleoUk93WzV49cUv+QD9dDF3QZ6uXTX xHC7IcB+hHDvg== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 9E6BAA0068; Tue, 20 Aug 2019 01:35:53 +0000 (UTC) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by us01wehtc1.internal.synopsys.com (10.12.239.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:35:53 -0700 Received: from te-lab16 (10.13.184.19) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:35:47 -0700 Received: by te-lab16 (sSMTP sendmail emulation); Mon, 19 Aug 2019 18:35:47 -0700 Date: Mon, 19 Aug 2019 18:35:47 -0700 Message-ID: <58310eda9c265f7cffcc130ccea10c496ec303dd.1566263914.git.thinhn@synopsys.com> In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 1/4] usb: gadget: Export recommended BESL values To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.19] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Currently there's no option for the controller driver to report the recommended Best Effort Service Latency (BESL) when operating with LPM support. Add new fields in usb_dcd_config_params to export the recommended baseline and deep BESL values for the function drivers to set the proper BESL value in the BOS descriptor. Signed-off-by: Thinh Nguyen --- include/linux/usb/gadget.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index fb19141151d8..124462d65eac 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -291,6 +291,9 @@ struct usb_dcd_config_params { #define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01 /* Less then 1 microsec */ __le16 bU2DevExitLat; /* U2 Device exit Latency */ #define USB_DEFAULT_U2_DEV_EXIT_LAT 0x1F4 /* Less then 500 microsec */ + __u8 besl_baseline; /* Recommended baseline BESL (0-15) */ + __u8 besl_deep; /* Recommended deep BESL (0-15) */ +#define USB_DEFAULT_BESL_UNSPECIFIED 0xFF /* No recommended value */ }; From patchwork Tue Aug 20 01:35:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11102561 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AE3B11395 for ; Tue, 20 Aug 2019 01:36:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8DC7522D37 for ; Tue, 20 Aug 2019 01:36:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="SHFG9cfN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728846AbfHTBgB (ORCPT ); Mon, 19 Aug 2019 21:36:01 -0400 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102]:50132 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728809AbfHTBgB (ORCPT ); Mon, 19 Aug 2019 21:36:01 -0400 Received: from mailhost.synopsys.com (dc8-mailhost1.synopsys.com [10.13.135.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id 6E138C039E; Tue, 20 Aug 2019 01:36:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1566264961; bh=OnOxp4i1P6lyaoXQrxq3LlGqEaga2wnIm2gNF17zvBg=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=SHFG9cfNWmhUIFc7hqvz+SGiVwCrEyYUC/4OB2OrZJSaevXakN85pAAtMlRUikUDr QP70kVuuvF+imaAtL63f6gSehRmw0tpYrroQ/pUtVCf8n0aMfqc49nH6Y8p2QXna/i zSpfyJsGD/SwzdbcIpZyBVtHrz1JB4PPFU0mpkptxkSquEVtg/aXYBtUK18gRJDXHs SqSogwoNek08Ft8B8exVdFicwflmEPLymkAJbnRVvjsVMoBs8ho2P3E6oGH4RI/MXK LuqxVrA+NQSp7r9fS7/suzTf968zpElA9rfi81Tn05dneYOzcCtS1Y2R7JM1xrhZLC Qwa4PUBsrOH4g== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id 234F7A023B; Tue, 20 Aug 2019 01:36:01 +0000 (UTC) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:36:00 -0700 Received: from te-lab16 (10.13.184.19) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:35:58 -0700 Received: by te-lab16 (sSMTP sendmail emulation); Mon, 19 Aug 2019 18:35:58 -0700 Date: Mon, 19 Aug 2019 18:35:58 -0700 Message-ID: <6527c4dfde0bf135a085050f24ba28180b20dc5e.1566263914.git.thinhn@synopsys.com> In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 2/4] usb: dwc3: Separate field holding multiple properties To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.19] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org dwc->hird_threshold field should store "snps,hird_threshold" property only and not a combination of multiple properties. Remove the value of "snps,is-utmi-l1-suspend" property from the field dwc->hird_threshold. Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/core.c | 3 +-- drivers/usb/dwc3/gadget.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 30ebf3c65a63..f56d5058a66c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1321,8 +1321,7 @@ static void dwc3_get_properties(struct dwc3 *dwc) dwc->lpm_nyet_threshold = lpm_nyet_threshold; dwc->tx_de_emphasis = tx_de_emphasis; - dwc->hird_threshold = hird_threshold - | (dwc->is_utmi_l1_suspend << 4); + dwc->hird_threshold = hird_threshold; dwc->rx_thr_num_pkt_prd = rx_thr_num_pkt_prd; dwc->rx_max_burst_prd = rx_max_burst_prd; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 173f5329d3d9..afc2ddb080ae 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2868,7 +2868,8 @@ static void dwc3_gadget_conndone_interrupt(struct dwc3 *dwc) reg = dwc3_readl(dwc->regs, DWC3_DCTL); reg &= ~(DWC3_DCTL_HIRD_THRES_MASK | DWC3_DCTL_L1_HIBER_EN); - reg |= DWC3_DCTL_HIRD_THRES(dwc->hird_threshold); + reg |= DWC3_DCTL_HIRD_THRES(dwc->hird_threshold | + (dwc->is_utmi_l1_suspend << 4)); /* * When dwc3 revisions >= 2.40a, LPM Erratum is enabled and From patchwork Tue Aug 20 01:36:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11102563 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19F941398 for ; Tue, 20 Aug 2019 01:37:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED88022DA8 for ; Tue, 20 Aug 2019 01:37:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="TOMmR1u8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728809AbfHTBhI (ORCPT ); Mon, 19 Aug 2019 21:37:08 -0400 Received: from dc2-smtprelay2.synopsys.com ([198.182.61.142]:51746 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728741AbfHTBhI (ORCPT ); Mon, 19 Aug 2019 21:37:08 -0400 Received: from mailhost.synopsys.com (dc8-mailhost1.synopsys.com [10.13.135.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id BD0EDC03B2; Tue, 20 Aug 2019 01:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1566265027; bh=m0XsAmBepkxRRCI3gsasvFaDh9h6o2+8FioCDynUx18=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=TOMmR1u8u9PM7VYrTWXp6XN80Iuz1eOVOPtcNJkhzJJP9l57a5MrC6DEJV/D8azUi QcWmM3SP9lAFxgMZ8UxXgVRyYR7hzLYVuy2kRqEgZwckW+fk/iwEKyWaCx2y5l63cN brLKs0mmweS5m2LNdJFS0lUEpF20F1kqWPqNh7BGcKhqoV3Fj7iG2u+N3yYfdm5Pl6 wl5aJpOgHc4XHF2vFzDxj2cRIqdbLvFpAfz25LKENquDAYDJBBXxRSeauhgP3wOJ89 /pdY7/QTBqo8w5cbJiHjnm80lrifMYgxzNfCxk9uqh1MSsZ15n+CzD+L7S03ZSvCxW thFBiaQKQiw9g== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id ADEE8A023B; Tue, 20 Aug 2019 01:37:07 +0000 (UTC) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:36:06 -0700 Received: from te-lab16 (10.13.184.19) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:36:06 -0700 Received: by te-lab16 (sSMTP sendmail emulation); Mon, 19 Aug 2019 18:36:06 -0700 Date: Mon, 19 Aug 2019 18:36:06 -0700 Message-ID: In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 3/4] usb: dwc3: gadget: Set BESL config parameter To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.19] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org When operating with LPM signals, the controller asserts the deep low-power signal (utmi_l1_suspend_n) to the phy when the BESL value of the LPM token is equal to or greater than DCTL.HIRD_Thres[3:0] (and with DCTL.HIRD_Thres[4] set). Otherwise, the shallow low-power signal (utmi_sleep_n) is asserted. Set the recommended deep BESL equal to the controller's DCTL.HIRD_Thres[3:0] setting, and set the baseline BESL to 0 for the shallow low-power signal. This maximizes the opportunity for L1 residency and optimizes power savings. Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index afc2ddb080ae..8ac024c5147a 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2078,6 +2078,16 @@ static void dwc3_gadget_config_params(struct usb_gadget *g, { struct dwc3 *dwc = gadget_to_dwc(g); + params->besl_baseline = USB_DEFAULT_BESL_UNSPECIFIED; + params->besl_deep = USB_DEFAULT_BESL_UNSPECIFIED; + + /* Recommended BESL */ + if (!dwc->dis_enblslpm_quirk) { + params->besl_baseline = 0; + if (dwc->is_utmi_l1_suspend) + params->besl_deep = min_t(u8, dwc->hird_threshold, 15); + } + /* U1 Device exit Latency */ if (dwc->dis_u1_entry_quirk) params->bU1devExitLat = 0; From patchwork Tue Aug 20 01:36:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11102565 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 800AF1395 for ; Tue, 20 Aug 2019 01:37:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6006822DA9 for ; Tue, 20 Aug 2019 01:37:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="kplzLE5N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728830AbfHTBhI (ORCPT ); Mon, 19 Aug 2019 21:37:08 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.61.142]:51752 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbfHTBhI (ORCPT ); Mon, 19 Aug 2019 21:37:08 -0400 Received: from mailhost.synopsys.com (dc8-mailhost1.synopsys.com [10.13.135.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id C1DC2C03C4; Tue, 20 Aug 2019 01:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1566265027; bh=VlZDTO/BRBEHD15Vt263ZxdlPukJfCSaXmqQS6GIOgc=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=kplzLE5N4y56OePkOfqoFlAjBjXqiTE91boOTu3NUiBmRwjMQjPRTY9C3dUwJnxPb robRalIV3yixyV2pkLZDXYG4y0cCTq3x3BkqZtFrxON+oeeF26JanZHqmNEx+bjRcK bbogUgIepya4Gqf0MxxP7z/uLeaR8biqik7DsKN9krodmdkQ8pPeqJEJFuuz2URwkH cU+1Dype2dbvTBQbk15sNFcnhJeReDKZjPiySXoC4+Fx7qMrnMVs8Mm/uPkY2hPBoh Q3iwVOKWRMCg28YSCOpPy4+GVGFV4zk9d8tCns4cYpS6SOVIbqMOBYt6IviYWgOfTo TV1I0JW0UjpIg== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPS id AFA8FA023C; Tue, 20 Aug 2019 01:37:07 +0000 (UTC) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:36:13 -0700 Received: from te-lab16 (10.13.184.19) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 19 Aug 2019 18:36:12 -0700 Received: by te-lab16 (sSMTP sendmail emulation); Mon, 19 Aug 2019 18:36:12 -0700 Date: Mon, 19 Aug 2019 18:36:12 -0700 Message-ID: <9e58a83fe6dab6778c48f40e77d03dc25e14f396.1566263914.git.thinhn@synopsys.com> In-Reply-To: References: From: Thinh Nguyen Subject: [PATCH 4/4] usb: gadget: composite: Set recommended BESL values To: Felipe Balbi , Greg Kroah-Hartman , Thinh Nguyen , CC: John Youn MIME-Version: 1.0 X-Originating-IP: [10.13.184.19] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Set the recommended BESL deep and baseline values based on the gadget's configuration parameters to the extended BOS descriptor. This feature helps to optimize power savings by maximizing the opportunity for longer L1 residency time. Signed-off-by: Thinh Nguyen --- drivers/usb/gadget/composite.c | 38 ++++++++++++++++++++++++++------------ include/uapi/linux/usb/ch9.h | 2 ++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 9118b42c70b6..7ed009dc0f92 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -612,6 +612,7 @@ static int bos_desc(struct usb_composite_dev *cdev) struct usb_ext_cap_descriptor *usb_ext; struct usb_dcd_config_params dcd_config_params; struct usb_bos_descriptor *bos = cdev->req->buf; + unsigned int besl = 0; bos->bLength = USB_DT_BOS_SIZE; bos->bDescriptorType = USB_DT_BOS; @@ -619,6 +620,29 @@ static int bos_desc(struct usb_composite_dev *cdev) bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE); bos->bNumDeviceCaps = 0; + /* Get Controller configuration */ + if (cdev->gadget->ops->get_config_params) { + cdev->gadget->ops->get_config_params(cdev->gadget, + &dcd_config_params); + } else { + dcd_config_params.besl_baseline = + USB_DEFAULT_BESL_UNSPECIFIED; + dcd_config_params.besl_deep = + USB_DEFAULT_BESL_UNSPECIFIED; + dcd_config_params.bU1devExitLat = + USB_DEFAULT_U1_DEV_EXIT_LAT; + dcd_config_params.bU2DevExitLat = + cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT); + } + + if (dcd_config_params.besl_baseline != USB_DEFAULT_BESL_UNSPECIFIED) + besl = USB_BESL_BASELINE_VALID | + USB_SET_BESL_BASELINE(dcd_config_params.besl_baseline); + + if (dcd_config_params.besl_deep != USB_DEFAULT_BESL_UNSPECIFIED) + besl |= USB_BESL_DEEP_VALID | + USB_SET_BESL_DEEP(dcd_config_params.besl_deep); + /* * A SuperSpeed device shall include the USB2.0 extension descriptor * and shall support LPM when operating in USB2.0 HS mode. @@ -629,7 +653,8 @@ static int bos_desc(struct usb_composite_dev *cdev) usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; - usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT); + usb_ext->bmAttributes = cpu_to_le32(USB_LPM_SUPPORT | + USB_BESL_SUPPORT | besl); /* * The Superspeed USB Capability descriptor shall be implemented by all @@ -650,17 +675,6 @@ static int bos_desc(struct usb_composite_dev *cdev) USB_HIGH_SPEED_OPERATION | USB_5GBPS_OPERATION); ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION; - - /* Get Controller configuration */ - if (cdev->gadget->ops->get_config_params) { - cdev->gadget->ops->get_config_params(cdev->gadget, - &dcd_config_params); - } else { - dcd_config_params.bU1devExitLat = - USB_DEFAULT_U1_DEV_EXIT_LAT; - dcd_config_params.bU2DevExitLat = - cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT); - } ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat; ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat; } diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h index d5a5caec8fbc..2b623f36af6b 100644 --- a/include/uapi/linux/usb/ch9.h +++ b/include/uapi/linux/usb/ch9.h @@ -894,6 +894,8 @@ struct usb_ext_cap_descriptor { /* Link Power Management */ #define USB_BESL_SUPPORT (1 << 2) /* supports BESL */ #define USB_BESL_BASELINE_VALID (1 << 3) /* Baseline BESL valid*/ #define USB_BESL_DEEP_VALID (1 << 4) /* Deep BESL valid */ +#define USB_SET_BESL_BASELINE(p) (((p) & 0xf) << 8) +#define USB_SET_BESL_DEEP(p) (((p) & 0xf) << 12) #define USB_GET_BESL_BASELINE(p) (((p) & (0xf << 8)) >> 8) #define USB_GET_BESL_DEEP(p) (((p) & (0xf << 12)) >> 12) } __attribute__((packed));