From patchwork Wed Aug 29 16:59:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A176D175A for ; Wed, 29 Aug 2018 16:59:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F6622B5A6 for ; Wed, 29 Aug 2018 16:59:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8359C2B604; Wed, 29 Aug 2018 16:59:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F0AD2B5A6 for ; Wed, 29 Aug 2018 16:59:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727970AbeH2U5D (ORCPT ); Wed, 29 Aug 2018 16:57:03 -0400 Received: from smtprelay.synopsys.com ([198.182.47.9]:38424 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727785AbeH2U5C (ORCPT ); Wed, 29 Aug 2018 16:57:02 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 45A1E24E04A5; Wed, 29 Aug 2018 09:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535561954; bh=/+urRX9ad+mWNMZfoFI/2PnuuXO157A1T0Ou6wam7Nw=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=diMQwkxOFQkkpp7PeBhhq22yMG+ly+g4BmAdMDLI89F6Qd/0UstNxQaoLD2/U5VUi KMNJ6qrvzs8s6lX8kyJ7wZGUBHLqMsJJN90+YYJJzj+ucBaK6KUmdc+2MBXNikN7Iw itDRllNXtLNzVvZbNSDtro9tCNS4FnpMNCEkLGGUiqJp1kSZl7VnzgJshlwnKTuxVR saooi0tZPvOmCZqrtKPD7hRnEUbMOXMSuk9ze1Kv6/zno+Xe9KwYkAOTd04Tk8PAa4 SBXJujKxwB3fLxlxqHRTERbcKxc7sWDYrvBfX1N7NxhN6KtEcKRUqwqbFJT/U39Xg1 yQFd/Igz4Z88g== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 35BA53BA9; Wed, 29 Aug 2018 09:59:14 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 09:59:14 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 09:59:12 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 20:59:07 +0400 Date: Wed, 29 Aug 2018 20:59:07 +0400 Message-ID: In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 1/9] usb: dwc2: Update registers definitions to support service interval To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added GHWCFG4_SERVICE_INTERVAL_SUPPORTED and DCTL_SERVICE_INTERVAL_SUPPORTED bits definitions to support service interval based scheduling. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/hw.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h index 0ca8e7bc7aaf..524629428439 100644 --- a/drivers/usb/dwc2/hw.h +++ b/drivers/usb/dwc2/hw.h @@ -312,6 +312,7 @@ #define GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT 14 #define GHWCFG4_ACG_SUPPORTED BIT(12) #define GHWCFG4_IPG_ISOC_SUPPORTED BIT(11) +#define GHWCFG4_SERVICE_INTERVAL_SUPPORTED BIT(10) #define GHWCFG4_UTMI_PHY_DATA_WIDTH_8 0 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_16 1 #define GHWCFG4_UTMI_PHY_DATA_WIDTH_8_OR_16 2 @@ -443,6 +444,7 @@ #define DCFG_DEVSPD_FS48 3 #define DCTL HSOTG_REG(0x804) +#define DCTL_SERVICE_INTERVAL_SUPPORTED BIT(19) #define DCTL_PWRONPRGDONE BIT(11) #define DCTL_CGOUTNAK BIT(10) #define DCTL_SGOUTNAK BIT(9) From patchwork Wed Aug 29 16:59:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1BBDE17DB for ; Wed, 29 Aug 2018 16:59:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0899E2A9CE for ; Wed, 29 Aug 2018 16:59:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0B192B62A; Wed, 29 Aug 2018 16:59:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3A262A9CE for ; Wed, 29 Aug 2018 16:59:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728200AbeH2U5c (ORCPT ); Wed, 29 Aug 2018 16:57:32 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:41140 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeH2U5c (ORCPT ); Wed, 29 Aug 2018 16:57:32 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 783D110C05B0; Wed, 29 Aug 2018 09:59:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535561983; bh=YqMfIX9tAR/fk5WY7759PGH5qvOX8oz/LvUHNEk0C/g=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=BOmrrVwxY3IrvQLrzcTNYKAXToTNDGF5jfEhXxLnGfhLQj98oBEydOdErKWor5CVW CsgXiOcYNl5Rl2tBm+5RVw8p7MbVplsyCeLkG2gO97fFRohmgNdBLnHgy9tKDSR3UC CVxGmKQf24E4AiFdJgBsDPmLCQ3Ak5pslpZJnhGIak5f1mTmAUP6wB0spb/f1RWzr0 tu/Bmwn+dEF1C07xo9PMnsHNihU5nKBdwlQk2NksWDi2m6+Ndc54Fhw/zRinFwEDTM kZG7/COd+HcyISApiIuloNhlLG60bBN7FSHZqSyXu9lyK5is/sXRSHjsbTvlLZyKVk ralDaRxv1CboQ== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id 671B054CD; Wed, 29 Aug 2018 09:59:43 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.238) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 09:59:43 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 09:59:38 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 20:59:34 +0400 Date: Wed, 29 Aug 2018 20:59:34 +0400 Message-ID: In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 2/9] usb: dwc2: Add core parameter for service interval support To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added core parameter for service interval based scheduling. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/core.h | 9 +++++++++ drivers/usb/dwc2/debugfs.c | 1 + drivers/usb/dwc2/gadget.c | 4 ++++ drivers/usb/dwc2/params.c | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index cc9c93affa14..2678dc9d559b 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -416,6 +416,9 @@ enum dwc2_ep0_state { * back to DWC2_SPEED_PARAM_HIGH while device is gone. * 0 - No (default) * 1 - Yes + * @service_interval: Enable service interval based scheduling. + * 0 - No + * 1 - Yes * * The following parameters may be specified when starting the module. These * parameters define how the DWC_otg controller should be configured. A @@ -461,6 +464,7 @@ struct dwc2_core_params { bool lpm_clock_gating; bool besl; bool hird_threshold_en; + bool service_interval; u8 hird_threshold; bool activate_stm_fs_transceiver; bool ipg_isoc_en; @@ -605,6 +609,10 @@ struct dwc2_core_params { * FIFO sizing is enabled 16 to 32768 * Actual maximum value is autodetected and also * the default. + * @service_interval_mode: For enabling service interval based scheduling in the + * controller. + * 0 - Disable + * 1 - Enable */ struct dwc2_hw_params { unsigned op_mode:3; @@ -635,6 +643,7 @@ struct dwc2_hw_params { unsigned utmi_phy_data_width:2; unsigned lpm_mode:1; unsigned ipg_isoc_en:1; + unsigned service_interval_mode:1; u32 snpsid; u32 dev_ep_dirs; u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index 22d015b0424f..7f62f4cdc265 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -701,6 +701,7 @@ static int params_show(struct seq_file *seq, void *v) print_param(seq, p, besl); print_param(seq, p, hird_threshold_en); print_param(seq, p, hird_threshold); + print_param(seq, p, service_interval); print_param(seq, p, host_dma); print_param(seq, p, g_dma); print_param(seq, p, g_dma_desc); diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 887bea99dce8..a3129f1e87a7 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3312,6 +3312,10 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, dwc2_set_bit(hsotg, DIEPMSK, DIEPMSK_BNAININTRMSK); } + /* Enable Service Interval mode if supported */ + if (using_desc_dma(hsotg) && hsotg->params.service_interval) + dwc2_set_bit(hsotg, DCTL, DCTL_SERVICE_INTERVAL_SUPPORTED); + dwc2_writel(hsotg, 0, DAINTMSK); dev_dbg(hsotg->dev, "EP0: DIEPCTL0=0x%08x, DOEPCTL0=0x%08x\n", diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index bf7052e037d6..dd3c10d537e2 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -299,6 +299,7 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg) p->hird_threshold_en = true; p->hird_threshold = 4; p->ipg_isoc_en = false; + p->service_interval = false; p->max_packet_count = hw->max_packet_count; p->max_transfer_size = hw->max_transfer_size; p->ahbcfg = GAHBCFG_HBSTLEN_INCR << GAHBCFG_HBSTLEN_SHIFT; @@ -592,6 +593,7 @@ static void dwc2_check_params(struct dwc2_hsotg *hsotg) CHECK_BOOL(besl, (hsotg->hw_params.snpsid >= DWC2_CORE_REV_3_00a)); CHECK_BOOL(hird_threshold_en, hsotg->params.lpm); CHECK_RANGE(hird_threshold, 0, hsotg->params.besl ? 12 : 7, 0); + CHECK_BOOL(service_interval, hw->service_interval_mode); CHECK_RANGE(max_packet_count, 15, hw->max_packet_count, hw->max_packet_count); @@ -780,6 +782,8 @@ int dwc2_get_hwparams(struct dwc2_hsotg *hsotg) GHWCFG4_UTMI_PHY_DATA_WIDTH_SHIFT; hw->acg_enable = !!(hwcfg4 & GHWCFG4_ACG_SUPPORTED); hw->ipg_isoc_en = !!(hwcfg4 & GHWCFG4_IPG_ISOC_SUPPORTED); + hw->service_interval_mode = !!(hwcfg4 & + GHWCFG4_SERVICE_INTERVAL_SUPPORTED); /* fifo sizes */ hw->rx_fifo_size = (grxfsiz & GRXFSIZ_DEPTH_MASK) >> From patchwork Wed Aug 29 17:00:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580655 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86FB65A4 for ; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74EC42B6FD for ; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6984E2B71A; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 200952B6FD for ; Wed, 29 Aug 2018 17:00:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727856AbeH2U6C (ORCPT ); Wed, 29 Aug 2018 16:58:02 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:38470 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727245AbeH2U6C (ORCPT ); Wed, 29 Aug 2018 16:58:02 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2870724E0609; Wed, 29 Aug 2018 10:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562013; bh=wzIPyGGg+FNPfTMcM4jgSrue+K7D3cMhQAjTqd0Z5UI=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=O785GXiteqJfJDI58RVoIhz/sWcCOL/E4l+t1ceSNQR2j4TD/iO3kzg9/GPIrPDPH wkQzE0ohpOKJ+a9XM+zEJqAcHCJ3ApP3MYMXzZYYT8Qw/RisYTH6w1kUBGgYPv0JD3 noB5b+nPKb1+ZiU4HAnaXB15Bpu01OHC1oAV4ywNSw2XxpXU63dv+0SEapgBGnxgm1 46if3gonIdZ1S27pWqp29DYkQBV/14O7GkQy62NyLWmk+lpz93n/M6/FqqDeWTMB7N GlyeuHOBrO6habdluFsnzHpFHp9Xu8pvyImSIeD4gAzmTktnViIdXCOkkyT0mu7A5y sxFlyIWJ7Io6A== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 15CEC5876; Wed, 29 Aug 2018 10:00:13 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:00:12 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:00:08 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:00:03 +0400 Date: Wed, 29 Aug 2018 21:00:03 +0400 Message-ID: <9c2b9d92d4457b3a34a981c5f2dd3e7dad0f871a.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 3/9] usb: dwc2: Add dwc2_gadget_dec_frame_num_by_one() function To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added dwc2_gadget_dec_frame_num_by_one() function in gadget.c. This function will be used to calculate descriptor frame number field value. For service interval mode frame number in descriptor should point to last (u)frame in the interval. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/gadget.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index a3129f1e87a7..58903b5c22a4 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -122,6 +122,24 @@ static inline void dwc2_gadget_incr_frame_num(struct dwc2_hsotg_ep *hs_ep) } } +/** + * dwc2_gadget_dec_frame_num_by_one - Decrements the targeted frame number + * by one. + * @hs_ep: The endpoint. + * + * This function used in service interval based scheduling flow to calculate + * descriptor frame number filed value. For service interval mode frame + * number in descriptor should point to last (u)frame in the interval. + * + */ +static inline void dwc2_gadget_dec_frame_num_by_one(struct dwc2_hsotg_ep *hs_ep) +{ + if (hs_ep->target_frame) + hs_ep->target_frame -= 1; + else + hs_ep->target_frame = DSTS_SOFFN_LIMIT; +} + /** * dwc2_hsotg_en_gsint - enable one or more of the general interrupt * @hsotg: The device state From patchwork Wed Aug 29 17:00:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFAFA17DE for ; Wed, 29 Aug 2018 17:00:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD1A12B682 for ; Wed, 29 Aug 2018 17:00:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A16842B6FD; Wed, 29 Aug 2018 17:00:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CE7D2B682 for ; Wed, 29 Aug 2018 17:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728353AbeH2U6b (ORCPT ); Wed, 29 Aug 2018 16:58:31 -0400 Received: from smtprelay.synopsys.com ([198.182.47.9]:38512 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727970AbeH2U6a (ORCPT ); Wed, 29 Aug 2018 16:58:30 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 9032B24E04A5; Wed, 29 Aug 2018 10:00:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562041; bh=xAkXkOO1X2joe2lL6lV2CJkk23EYo5c4+8KunaAfVyU=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=BbL3IfyZ/f2gvPZVSYKmmCqqH4vHftElLTQ/NU8PFu++f4kuxL1A4acATAsN6LDjH VS59tqqcIWtvqCD8lQ563IaZhwjSuTqv/le9ogcXqdX+QaSmvCZhxOtnbp13BADSms 1Nz5HFFiGsJKJAKGdzmfWTsplctSqrEms9STiCdCZriNpmHmEbcj9Ie+KnxCi8/FLi kjxiKp7aLzVv5/681JsjG5ScEI5o3S3p3ttXD034lA3x/5kj1rEXCCd/X005Bam5yA Lxl3T2eVMwG5VI0buHutTaDeiLVaLIz3bI8A5L2w6qEezu2bmahj2nYNY9T1PlMP86 3r90O1ilZ1BoA== Received: from US01WXQAHTC1.internal.synopsys.com (us01wxqahtc1.internal.synopsys.com [10.12.238.230]) by mailhost.synopsys.com (Postfix) with ESMTP id 817B55BBA; Wed, 29 Aug 2018 10:00:41 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.238) by US01WXQAHTC1.internal.synopsys.com (10.12.238.230) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:00:41 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:00:38 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:00:33 +0400 Date: Wed, 29 Aug 2018 21:00:33 +0400 Message-ID: <92e6668af9b4cb77faa8bcbeca70271f47df94c5.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 4/9] usb: dwc2: Update target (u)frame calculation To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In service interval based scheduling target (u)frame must be set as a last frame in this the service interval. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/gadget.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 58903b5c22a4..004701cad25c 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -2830,6 +2830,23 @@ static void dwc2_gadget_handle_nak(struct dwc2_hsotg_ep *hs_ep) if (using_desc_dma(hsotg)) { hs_ep->target_frame = hsotg->frame_number; dwc2_gadget_incr_frame_num(hs_ep); + + /* In service interval mode target_frame must + * be set to last (u)frame of the service interval. + */ + if (hsotg->params.service_interval) { + /* Set target_frame to the first (u)frame of + * the service interval + */ + hs_ep->target_frame &= ~hs_ep->interval + 1; + + /* Set target_frame to the last (u)frame of + * the service interval + */ + dwc2_gadget_incr_frame_num(hs_ep); + dwc2_gadget_dec_frame_num_by_one(hs_ep); + } + dwc2_gadget_start_isoc_ddma(hs_ep); return; } From patchwork Wed Aug 29 17:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 449585A4 for ; Wed, 29 Aug 2018 17:01:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3163A2B682 for ; Wed, 29 Aug 2018 17:01:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23B852B6FD; Wed, 29 Aug 2018 17:01:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFF8E2B682 for ; Wed, 29 Aug 2018 17:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728052AbeH2U7A (ORCPT ); Wed, 29 Aug 2018 16:59:00 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:41254 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727970AbeH2U7A (ORCPT ); Wed, 29 Aug 2018 16:59:00 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id CE7FB10C0266; Wed, 29 Aug 2018 10:01:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562070; bh=EF0s1Bfgydes1LTAyYHHtoECIi3hDYGM/ipgzrAKqus=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=K4IbWGPtRqFdVXSyRFDcZoQNM3a885ffHdTU5TRQr2TZcZy85uGOjQ9YMaFpJLrVJ R7XdyrjRmnpDYdifKEe1HEj+mcUECijtgC50atd2NYz2vu9QAaPkTDl2McEptnpmyq czGKxpz1G/XdWko7ghK6lKfBWfrfuwsvAOx0pIonp/LwIUtg+0jnKDmg9lOrDtf8Ss n/ocGltZajBZ3/KwpRBrjXu/Zfdfft9AOLgDLZTZzcJk43dOFv+jNU13Viuj3xTCtw oldtOuJi323bph4KpxjvZ8NG0l2oU82hRtbdzOJo5vcOICpDt4tzuj78hm3kIxgmsE I291ExqDRFU5Q== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id BFC2650A4; Wed, 29 Aug 2018 10:01:10 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:01:10 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:01:06 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:01:01 +0400 Date: Wed, 29 Aug 2018 21:01:01 +0400 Message-ID: <7c6b31f4734966dfc98d97f24e7367c68a02fc32.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 5/9] usb: dwc2: Add definitions for new registers To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP New registers were added to dwc otg core. GREFCLK - This register used to control ref_clk parameters. GINTSTS2 - New WKUP_ALERT interrupt was added. GINTMSK2 - Mask register for GINTSTS2. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/hw.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc2/hw.h b/drivers/usb/dwc2/hw.h index 524629428439..2b1ea441b7d4 100644 --- a/drivers/usb/dwc2/hw.h +++ b/drivers/usb/dwc2/hw.h @@ -405,6 +405,19 @@ #define ADPCTL_PRB_DSCHRG_MASK (0x3 << 0) #define ADPCTL_PRB_DSCHRG_SHIFT 0 +#define GREFCLK HSOTG_REG(0x0064) +#define GREFCLK_REFCLKPER_MASK (0x1ffff << 15) +#define GREFCLK_REFCLKPER_SHIFT 15 +#define GREFCLK_REF_CLK_MODE BIT(14) +#define GREFCLK_SOF_CNT_WKUP_ALERT_MASK (0x3ff) +#define GREFCLK_SOF_CNT_WKUP_ALERT_SHIFT 0 + +#define GINTMSK2 HSOTG_REG(0x0068) +#define GINTMSK2_WKUP_ALERT_INT_MSK BIT(0) + +#define GINTSTS2 HSOTG_REG(0x006c) +#define GINTSTS2_WKUP_ALERT_INT BIT(0) + #define HPTXFSIZ HSOTG_REG(0x100) /* Use FIFOSIZE_* constants to access this register */ From patchwork Wed Aug 29 17:01:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 117DE175A for ; Wed, 29 Aug 2018 17:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0B4E2B6FD for ; Wed, 29 Aug 2018 17:01:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3E352B71A; Wed, 29 Aug 2018 17:01:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4F3F2B6FD for ; Wed, 29 Aug 2018 17:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727809AbeH2U73 (ORCPT ); Wed, 29 Aug 2018 16:59:29 -0400 Received: from smtprelay4.synopsys.com ([198.182.47.9]:38580 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727743AbeH2U73 (ORCPT ); Wed, 29 Aug 2018 16:59:29 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 7671F24E0642; Wed, 29 Aug 2018 10:01:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562099; bh=1+GUnh/7QeIRQRkOY4UhkcgM/DYR8DBEuxXgnC66Qd8=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=G61PIjKdbKajeW3LC6f95Dv+AI9DWgmkt5egsm7sqX4CqnbBr21MBRFmu50frmBao coTmx1ZLqFWv7r/p2dsMN70H+BpqpRd7agHeOg11to3NFXXWpab/Kl3fKgfEV8CDaN PD2rBSSE0LfhblA9dQ8IOf5VE2xTvG/It6s8XyZwKnzShvkaXWVn1/FGLP5zZJUmxI biRCl0S+qPebqSO4eOt3dzyM/EY1rOOCJWTx88WNGIGTTiFTms3aYNOuuhb8Lpknyn zfrwEVC2aamCHrGdx4/n76aFMSLa5zbqzhV+4XrmxYmiNbAjx7ynblD4YWRebkV4// JPSGaFhQ+tIBA== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 64BD63659; Wed, 29 Aug 2018 10:01:39 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:01:39 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:01:35 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:01:31 +0400 Date: Wed, 29 Aug 2018 21:01:31 +0400 Message-ID: <81c4c162cc347cb2c2f492e9ccd922a060f2f2f9.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 6/9] usb: dwc2: gadget: Add parameters for GREFCLK register To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added ref_clk_per and sof_cnt_wkup_alert parameters in dwc2_core_params struct and set default values. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/core.h | 18 ++++++++++++++++++ drivers/usb/dwc2/params.c | 2 ++ 2 files changed, 20 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 2678dc9d559b..655f5274e801 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -393,6 +393,20 @@ enum dwc2_ep0_state { * 0 - No * 1 - Yes * @hird_threshold: Value of BESL or HIRD Threshold. + * @ref_clk_per: Indicates in terms of pico seconds the period + * of ref_clk. + * 62500 - 16MHz + * 58823 - 17MHz + * 52083 - 19.2MHz + * 50000 - 20MHz + * 41666 - 24MHz + * 33333 - 30MHz (default) + * 25000 - 40MHz + * @sof_cnt_wkup_alert: Indicates in term of number of SOF's after which + * the controller should generate an interrupt if the + * device had been in L1 state until that period. + * This is used by SW to initiate Remote WakeUp in the + * controller so as to sync to the uF number from the host. * @activate_stm_fs_transceiver: Activate internal transceiver using GGPIO * register. * 0 - Deactivate the transceiver (default) @@ -472,6 +486,10 @@ struct dwc2_core_params { u32 max_transfer_size; u32 ahbcfg; + /* GREFCLK parameters */ + u32 ref_clk_per; + u16 sof_cnt_wkup_alert; + /* Host parameters */ bool host_dma; bool dma_desc_enable; diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index dd3c10d537e2..d150984406ee 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -303,6 +303,8 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg) p->max_packet_count = hw->max_packet_count; p->max_transfer_size = hw->max_transfer_size; p->ahbcfg = GAHBCFG_HBSTLEN_INCR << GAHBCFG_HBSTLEN_SHIFT; + p->ref_clk_per = 33333; + p->sof_cnt_wkup_alert = 100; if ((hsotg->dr_mode == USB_DR_MODE_HOST) || (hsotg->dr_mode == USB_DR_MODE_OTG)) { From patchwork Wed Aug 29 17:01:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580669 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91F885A4 for ; Wed, 29 Aug 2018 17:02:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D7E72B6FD for ; Wed, 29 Aug 2018 17:02:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70A2C2B71A; Wed, 29 Aug 2018 17:02:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10AF12B6FD for ; Wed, 29 Aug 2018 17:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727868AbeH2U75 (ORCPT ); Wed, 29 Aug 2018 16:59:57 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:38642 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727836AbeH2U75 (ORCPT ); Wed, 29 Aug 2018 16:59:57 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 216E724E0543; Wed, 29 Aug 2018 10:02:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562128; bh=jY2shjE95fXDw/SXKyGnqNwqZNpvbou6xTCPP7Xhd+I=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=T5tMjdhpoBpc12+u9k6QBWgJK8uSK1KO8ICtgH+m/xUcsU7kRPtTHNwUMAsy+bEzr eAsa+k32zWtcmbgH/Iymzd/0x4aMGLtnXEP4s6P3fuM6GUAgcWJF5ItGEdWlM+2Y8c 0o0JHsw4ol6KmqrdFLdENSsjQ09srjqL9mAudQPTha6rSFYUg/UAI8kbLCum12YLtV G1e8sxZmWM7jgxacFzNq6tTFSHRXhE3mLEgWDRnxnB+2UL7MxExP759TamJHmRoS7z 0jtlNmoNFqmAuB1d3271I7tEJXEWD9G+Q+wcsQm6kJsMifivwZrEWMGC08XmqxEIqw abrGen0fQdORQ== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id 110503615; Wed, 29 Aug 2018 10:02:08 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:02:07 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:02:04 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:01:59 +0400 Date: Wed, 29 Aug 2018 21:01:59 +0400 Message-ID: <52897a5c119ed044b5bfb29239e565ab203c4352.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 7/9] usb: dwc2: gadget: Program GREFCLK register To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added dwc2_gadget_program_ref_clk function to program GREFCLK register in device mode. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/core.h | 2 ++ drivers/usb/dwc2/gadget.c | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 655f5274e801..30bab8463c96 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -1381,6 +1381,7 @@ int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg); int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg); int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg); void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg); +void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg); #else static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2) { return 0; } @@ -1415,6 +1416,7 @@ static inline int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) static inline int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg) { return 0; } static inline void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) {} +static inline void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) {} #endif #if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 004701cad25c..66401ffeb5a2 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3407,6 +3407,10 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg, /* configure the core to support LPM */ dwc2_gadget_init_lpm(hsotg); + /* program GREFCLK register if needed */ + if (using_desc_dma(hsotg) && hsotg->params.service_interval) + dwc2_gadget_program_ref_clk(hsotg); + /* must be at-least 3ms to allow bus to see disconnect */ mdelay(3); @@ -4985,6 +4989,25 @@ void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG)); } +/** + * dwc2_gadget_program_ref_clk - Program GREFCLK register in device mode + * + * @hsotg: Programming view of DWC_otg controller + * + */ +void dwc2_gadget_program_ref_clk(struct dwc2_hsotg *hsotg) +{ + u32 val = 0; + + val |= GREFCLK_REF_CLK_MODE; + val |= hsotg->params.ref_clk_per << GREFCLK_REFCLKPER_SHIFT; + val |= hsotg->params.sof_cnt_wkup_alert << + GREFCLK_SOF_CNT_WKUP_ALERT_SHIFT; + + dwc2_writel(hsotg, val, GREFCLK); + dev_dbg(hsotg->dev, "GREFCLK=0x%08x\n", dwc2_readl(hsotg, GREFCLK)); +} + /** * dwc2_gadget_enter_hibernation() - Put controller in Hibernation. * From patchwork Wed Aug 29 17:02:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E541B5A4 for ; Wed, 29 Aug 2018 17:02:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF11B2B6FD for ; Wed, 29 Aug 2018 17:02:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C23192B71A; Wed, 29 Aug 2018 17:02:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C7FE2B6FD for ; Wed, 29 Aug 2018 17:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbeH2VA1 (ORCPT ); Wed, 29 Aug 2018 17:00:27 -0400 Received: from smtprelay4.synopsys.com ([198.182.47.9]:38678 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727836AbeH2VA1 (ORCPT ); Wed, 29 Aug 2018 17:00:27 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 3C8E124E0543; Wed, 29 Aug 2018 10:02:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562157; bh=YFq//iR75W4TtkcZzONR+g5x3LlaVHo8TxNQQLDoBPs=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=hZDhFv3/ASgVXHMCrKQedKj2dH9mYoOsXQMMROTYDiQr7RDo6iqXccBWeCYv9fCKp rehdevhupORcQNUhFtTJkg9nCXkOxkyLedV9MapBh0x2/gc0SfMp8WKBCWlLoz9FD7 1lCrC6nVYPf3CP+4ceIIbgbNUh903fjm3a1ZvssFRPVE+hcS3fatCLIfIjS/5UWhMp ObwQuVNHapZmO+HsHVe2lDnRjfmpwNsPIvDILrG/9eATjZjqJ2WvX0MDp9/0KzMTMu GmiGZx9YYom18iG+L0HH8cqjSNj8mgdMUOX+qy+AzgQmezPS8LCOYAiboc2kHEm785 hQIFFX5YKe+aQ== Received: from us01wehtc1.internal.synopsys.com (us01wehtc1-vip.internal.synopsys.com [10.12.239.236]) by mailhost.synopsys.com (Postfix) with ESMTP id 2DC945B25; Wed, 29 Aug 2018 10:02:37 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.238) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:02:36 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:02:32 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:02:28 +0400 Date: Wed, 29 Aug 2018 21:02:28 +0400 Message-ID: <32a922df379136102ace0e6e0e7d964fa1f59e3a.1535561828.git.tovmasya@synopsys.com> In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 8/9] usb: dwc2: gadget: enable WKUP_ALERT interrupt To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP WKUP_ALERT interrupt should be unmask when lpm mode is enabled. This interrupt is asserted when the device is in L1 for the duration mentioned in GREFCLK.SOF_CNN_WKUP_ALERT. This is used to alert SW to initiate Remote wake up so that the device resumes in time in order not to lose sync with the host frame number. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/gadget.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 66401ffeb5a2..4f99f2e44a5b 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -4987,6 +4987,10 @@ void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg) val |= hsotg->params.besl ? GLPMCFG_ENBESL : 0; dwc2_writel(hsotg, val, GLPMCFG); dev_dbg(hsotg->dev, "GLPMCFG=0x%08x\n", dwc2_readl(hsotg, GLPMCFG)); + + /* Unmask WKUP_ALERT Interrupt */ + if (hsotg->params.service_interval) + dwc2_set_bit(hsotg, GINTMSK2, GINTMSK2_WKUP_ALERT_INT_MSK); } /** From patchwork Wed Aug 29 17:02:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grigor Tovmasyan X-Patchwork-Id: 10580673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F5B25A4 for ; Wed, 29 Aug 2018 17:03:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49C6D29428 for ; Wed, 29 Aug 2018 17:03:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B7662A192; Wed, 29 Aug 2018 17:03:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D905629428 for ; Wed, 29 Aug 2018 17:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbeH2VA4 (ORCPT ); Wed, 29 Aug 2018 17:00:56 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:38702 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727836AbeH2VA4 (ORCPT ); Wed, 29 Aug 2018 17:00:56 -0400 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id EFA3924E04A5; Wed, 29 Aug 2018 10:03:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1535562186; bh=QrOki5qXc90EneonGA9JZ+CTlCE8QRJfqZJlZRhtmJc=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=IB8KbpRKqxqXdpVOOZYDczw13het1QVEb7FyEdUJMTJbucKHzjTL8pYjb+bMOvcwU qP5ZSRvhv1n730q4Yy4q82lexHq6c64kuXAJAnTY9Sy5tOGILe5I7uPGfhKlyLzzJb HeiQuX99+u6P7AjsczU6onzWNzKUDFPyxpu6d2vwx4iVcsahR+jPoEtQyyqIhWS3qP i2SDX6cy5sgDavrFvvXK9b0c9ktWprwECsY4EojCXK4ZnxirhX+RsOj6LBHArOUoYI at13ocYaF32lhJCv5m4L0LmIT2ztCxaM7Usuy+StElfLmQoDLV3H7fq3Ni2E6PPbo/ Irf7KRdNftU+Q== Received: from US01WEHTC3.internal.synopsys.com (us01wehtc3.internal.synopsys.com [10.15.84.232]) by mailhost.synopsys.com (Postfix) with ESMTP id E14B95DEB; Wed, 29 Aug 2018 10:03:06 -0700 (PDT) Received: from US01WEHTC2.internal.synopsys.com (10.12.239.237) by US01WEHTC3.internal.synopsys.com (10.15.84.232) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:03:06 -0700 Received: from tovmasya (10.13.184.20) by US01WEHTC2.internal.synopsys.com (10.12.239.238) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Aug 2018 10:03:02 -0700 Received: by tovmasya (sSMTP sendmail emulation); Wed, 29 Aug 2018 21:02:57 +0400 Date: Wed, 29 Aug 2018 21:02:57 +0400 Message-ID: In-Reply-To: References: From: Grigor Tovmasyan Subject: [PATCH 9/9] usb: dwc2: gadget: Add handler for WkupAlert interrupt To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Grigor Tovmasyan MIME-Version: 1.0 X-Originating-IP: [10.13.184.20] Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Added interrupt handler for WkupAlert interrupt. This interrupt should initiate Remote Wake up. Signed-off-by: Grigor Tovmasyan --- drivers/usb/dwc2/gadget.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4f99f2e44a5b..8c558a1b7add 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -245,6 +245,27 @@ int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg) return tx_addr_max - addr; } +/** + * dwc2_gadget_wkup_alert_handler - Handler for WKUP_ALERT interrupt + * + * @hsotg: Programming view of the DWC_otg controller + * + */ +static void dwc2_gadget_wkup_alert_handler(struct dwc2_hsotg *hsotg) +{ + u32 gintsts2; + u32 gintmsk2; + + gintsts2 = dwc2_readl(hsotg, GINTSTS2); + gintmsk2 = dwc2_readl(hsotg, GINTMSK2); + + if (gintsts2 & GINTSTS2_WKUP_ALERT_INT) { + dev_dbg(hsotg->dev, "%s: Wkup_Alert_Int\n", __func__); + dwc2_clear_bit(hsotg, GINTSTS2, GINTSTS2_WKUP_ALERT_INT); + dwc2_set_bit(hsotg, DCFG, DCTL_RMTWKUPSIG); + } +} + /** * dwc2_hsotg_tx_fifo_average_depth - returns average depth of device mode * TX FIFOs @@ -3719,6 +3740,10 @@ static irqreturn_t dwc2_hsotg_irq(int irq, void *pw) if (gintsts & IRQ_RETRY_MASK && --retry_count > 0) goto irq_retry; + /* Check WKUP_ALERT interrupt*/ + if (hsotg->params.service_interval) + dwc2_gadget_wkup_alert_handler(hsotg); + spin_unlock(&hsotg->lock); return IRQ_HANDLED;