From patchwork Thu Sep 20 13:49:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artur Petrosyan X-Patchwork-Id: 10607803 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 1943C157B for ; Thu, 20 Sep 2018 13:49:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0851D2D7B6 for ; Thu, 20 Sep 2018 13:49:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F11AB2D7C4; Thu, 20 Sep 2018 13:49:40 +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 8019A2D7B6 for ; Thu, 20 Sep 2018 13:49:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731528AbeITTdO (ORCPT ); Thu, 20 Sep 2018 15:33:14 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.47.9]:40898 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726990AbeITTdO (ORCPT ); Thu, 20 Sep 2018 15:33:14 -0400 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0FC5524E127B; Thu, 20 Sep 2018 06:49:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1537451379; bh=OKs+KPfjw17ED1w5GEMjE7XxTnBQG/xlNZQSj7TIzek=; h=Date:In-Reply-To:References:From:Subject:To:CC:From; b=SjXViTl/HEt7ewXVQ7w3InswJnqgMbzRO9LsUK08xycz0hnX5yZXB/VV5WhuAt3c7 Bbi4g0ekuLxlx6Jel3N0WTYI7ZRYRmBMVnzq7yKks6Tc03jSmAkmZClwP6F7ULrIlk uidBmfUPV11SOCM2TAftP5HbLRVob0ZG1eaZu62bIe96IkqFMaPRquPZkISgUNYZIw IYo8FwfaEMYuPWe8HEZLi7RDHf2GU2XV82/DRq109K16N8jkx1GnOxbj0rUOsDixVa 6zzf0ml+6O4lW9mutXB/SdxsdjfXj+dHpgLTdI6v8h7zYth0FyZKEU8wF0ymUtpjhV C27JmMizpdaGA== Received: from US01WEHTC2.internal.synopsys.com (us01wehtc2.internal.synopsys.com [10.12.239.237]) by mailhost.synopsys.com (Postfix) with ESMTP id F1A2A3FE3; Thu, 20 Sep 2018 06:49:38 -0700 (PDT) Received: from US01WEHTC3.internal.synopsys.com (10.15.84.232) by US01WEHTC2.internal.synopsys.com (10.12.239.237) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 20 Sep 2018 06:49:38 -0700 Received: from arturp-ubuntu (10.13.184.20) by US01WEHTC3.internal.synopsys.com (10.15.84.231) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 20 Sep 2018 06:49:37 -0700 Received: by arturp-ubuntu (sSMTP sendmail emulation); Thu, 20 Sep 2018 09:49:32 -0400 Date: Thu, 20 Sep 2018 09:49:32 -0400 Message-ID: <66bad10fd0f3ff939413981ae7c179f49a542501.1537451080.git.arturp@synopsys.com> In-Reply-To: References: From: Artur Petrosyan Subject: [PATCH 1/3] usb: dwc2: Add default param to control power optimization. To: Felipe Balbi , Greg Kroah-Hartman , Minas Harutyunyan , CC: John Youn , Artur Petrosyan 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 a default param "power_saving" to enable or disable hibernation or partial power down features. - Printed hibernation param in hw_params_show and power_saving param in params_show. Signed-off-by: Artur Petrosyan Signed-off-by: Minas Harutyunyan --- drivers/usb/dwc2/core.h | 3 +++ drivers/usb/dwc2/debugfs.c | 2 ++ drivers/usb/dwc2/params.c | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index cc9c93affa14..2cf5e128cb75 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -373,6 +373,8 @@ enum dwc2_ep0_state { * case. * 0 - No (default) * 1 - Yes + * @power_saving: Specifies if power saving is enabled or not. If it is + * enabled power_down functionality will be enabled. * @power_down: Specifies whether the controller support power_down. * If power_down is enabled, the controller will enter * power_down in both peripheral and host mode when @@ -452,6 +454,7 @@ struct dwc2_core_params { bool uframe_sched; bool external_id_pin_ctl; + unsigned int power_saving:1; int power_down; #define DWC2_POWER_DOWN_PARAM_NONE 0 #define DWC2_POWER_DOWN_PARAM_PARTIAL 1 diff --git a/drivers/usb/dwc2/debugfs.c b/drivers/usb/dwc2/debugfs.c index 22d015b0424f..9f663d42dfe8 100644 --- a/drivers/usb/dwc2/debugfs.c +++ b/drivers/usb/dwc2/debugfs.c @@ -695,6 +695,7 @@ static int params_show(struct seq_file *seq, void *v) print_param_hex(seq, p, ahbcfg); print_param(seq, p, uframe_sched); print_param(seq, p, external_id_pin_ctl); + print_param(seq, p, power_saving); print_param(seq, p, power_down); print_param(seq, p, lpm); print_param(seq, p, lpm_clock_gating); @@ -745,6 +746,7 @@ static int hw_params_show(struct seq_file *seq, void *v) print_param(seq, hw, num_dev_perio_in_ep); print_param(seq, hw, total_fifo_size); print_param(seq, hw, power_optimized); + print_param(seq, hw, hibernation); print_param(seq, hw, utmi_phy_data_width); print_param_hex(seq, hw, snpsid); print_param_hex(seq, hw, dev_ep_dirs); diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index bf7052e037d6..f51b3659511b 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -253,12 +253,18 @@ static void dwc2_set_param_power_down(struct dwc2_hsotg *hsotg) { int val; - if (hsotg->hw_params.hibernation) - val = 2; - else if (hsotg->hw_params.power_optimized) - val = 1; - else - val = 0; + if (!hsotg->params.power_saving) { + val = DWC2_POWER_DOWN_PARAM_NONE; + dev_dbg(hsotg->dev, "%s: Power saving is disabled.\n", + __func__); + } else { + if (hsotg->hw_params.hibernation) + val = DWC2_POWER_DOWN_PARAM_HIBERNATION; + else if (hsotg->hw_params.power_optimized) + val = DWC2_POWER_DOWN_PARAM_PARTIAL; + else + val = DWC2_POWER_DOWN_PARAM_NONE; + } hsotg->params.power_down = val; } @@ -280,6 +286,7 @@ static void dwc2_set_default_params(struct dwc2_hsotg *hsotg) dwc2_set_param_phy_type(hsotg); dwc2_set_param_speed(hsotg); dwc2_set_param_phy_utmi_width(hsotg); + p->power_saving = true; dwc2_set_param_power_down(hsotg); p->phy_ulpi_ddr = false; p->phy_ulpi_ext_vbus = false;