From patchwork Thu Apr 18 00:13:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10906423 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 97C6C1932 for ; Thu, 18 Apr 2019 00:15:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 803B028BDE for ; Thu, 18 Apr 2019 00:15:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7419E28BD4; Thu, 18 Apr 2019 00:15:27 +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=unavailable 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 EBFD028BDA for ; Thu, 18 Apr 2019 00:15:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387638AbfDRAO7 (ORCPT ); Wed, 17 Apr 2019 20:14:59 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34992 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729331AbfDRAO6 (ORCPT ); Wed, 17 Apr 2019 20:14:58 -0400 Received: by mail-pf1-f195.google.com with SMTP id t21so242650pfh.2 for ; Wed, 17 Apr 2019 17:14:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kqTM4X13zllIwVukxHiG4L+ohv7hFQSZFxL4FXnl0KE=; b=P3yGxpplISbbAjyh5feqp9pmKDDhUZ6n4aB2skbFqXMwReC1ufBQbAsj4sCAj4J8er IR5cdMUZp8M57uV4tT32Slvzzrm3r3dMK4PTHr0+U7lqtR2mCKQ3YBtQAb1PcJMOTjtx ecFK9YRgTFNqcrrg/UnicukR/zopR1waAk/54= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kqTM4X13zllIwVukxHiG4L+ohv7hFQSZFxL4FXnl0KE=; b=SsXRwteewiJGc0b/75wbZE0sDfwLywC4fbKKiYxEv5xEv8Jv7qhhN8mQ5uFZfja+Sy ZBAULZp+03hUBJXuU8cKs9kpbCMUwIOidGsaVKlCXSuwLLMkxKH9qwksIQ+Qo8v7ZSDC XylYn61gzv0kadrfy2TJiZcJ3tELdjIbA7nQabcyXc0X7CZyakARv1nhhlEI9K6JTH9q YIqmFhuKa36EGea9V1YZgLRrLqEuoy3bp7/v5PQ3zRroi/0FEY4J+2wYf1HG0uVr/mo9 QXGIdlTdr9RPgDScR1O9zcbrDEXfMJnHTdX6HKrCPnk7WC4y7bZ68r9BfOFwwl51vqOn PVXA== X-Gm-Message-State: APjAAAUGKVsOro4yJ+QKJLf+mgvuo48zgKLCQwkaUg8Zsc/J+8Og8CIX QbNS+Cf7/AOoZN+w8PxO4LZPyA== X-Google-Smtp-Source: APXvYqyivasih9sth0BaBOc1OCWFOlMcvZv0okIVjyRZVEgbD74taE1L9rgCQIevhcQzSJ8LltJoPA== X-Received: by 2002:aa7:884b:: with SMTP id k11mr92680149pfo.49.1555546497634; Wed, 17 Apr 2019 17:14:57 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q5sm447668pff.97.2019.04.17.17.14.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 17:14:57 -0700 (PDT) From: Douglas Anderson To: Minas Harutyunyan , Felipe Balbi , heiko@sntech.de Cc: Alan Stern , Artur Petrosyan , amstan@chromium.org, linux-rockchip@lists.infradead.org, William Wu , linux-usb@vger.kernel.org, Stefan Wahren , Randy Li , zyw@rock-chips.com, mka@chromium.org, ryandcase@chromium.org, Amelie Delaunay , jwerner@chromium.org, dinguyen@opensource.altera.com, Elaine Zhang , Douglas Anderson , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/5] usb: dwc2: bus suspend/resume for hosts with DWC2_POWER_DOWN_PARAM_NONE Date: Wed, 17 Apr 2019 17:13:52 -0700 Message-Id: <20190418001356.124334-2-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190418001356.124334-1-dianders@chromium.org> References: <20190418001356.124334-1-dianders@chromium.org> MIME-Version: 1.0 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 This is an attempt to rehash commit 0cf884e819e0 ("usb: dwc2: add bus suspend/resume for dwc2") on ToT. That commit was reverted in commit b0bb9bb6ce01 ("Revert "usb: dwc2: add bus suspend/resume for dwc2"") because apparently it broke the Altera SOCFPGA. With all the changes that have happened to dwc2 in the meantime, it's possible that the Altera SOCFPGA will just magically work with this change now. ...and it would be good to get bus suspend/resume implemented. This change is a forward port of one that's been living in the Chrome OS 3.14 kernel tree. Signed-off-by: Douglas Anderson --- This patch was last posted at: https://lkml.kernel.org/r/1446237173-15263-1-git-send-email-dianders@chromium.org ...and appears to have died the death of silence. Maybe it could get some bake time in linuxnext if we can't find any proactive testing? I will also freely admit that I don't know tons about the theory behind this patch. I'm mostly just re-hashing the original commit from Kever that was reverted since: * Turning on partial power down on rk3288 doesn't "just work". I don't get hotplug events. This is despite dwc2 auto-detecting that we are power optimized. * If we don't do something like this commit we don't get into as low of a power mode. Changes in v2: None drivers/usb/dwc2/hcd.c | 84 ++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index e272d020012e..978232a9e4a8 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c @@ -4482,6 +4482,7 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) unsigned long flags; int ret = 0; u32 hprt0; + u32 pcgctl; spin_lock_irqsave(&hsotg->lock, flags); @@ -4497,7 +4498,7 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) if (hsotg->op_state == OTG_STATE_B_PERIPHERAL) goto unlock; - if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL) + if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) goto skip_power_saving; /* @@ -4506,21 +4507,35 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) */ if (!hsotg->bus_suspended) { hprt0 = dwc2_read_hprt0(hsotg); - hprt0 |= HPRT0_SUSP; - hprt0 &= ~HPRT0_PWR; - dwc2_writel(hsotg, hprt0, HPRT0); - spin_unlock_irqrestore(&hsotg->lock, flags); - dwc2_vbus_supply_exit(hsotg); - spin_lock_irqsave(&hsotg->lock, flags); + if (hprt0 & HPRT0_CONNSTS) { + hprt0 |= HPRT0_SUSP; + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) + hprt0 &= ~HPRT0_PWR; + dwc2_writel(hsotg, hprt0, HPRT0); + } + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { + spin_unlock_irqrestore(&hsotg->lock, flags); + dwc2_vbus_supply_exit(hsotg); + spin_lock_irqsave(&hsotg->lock, flags); + } else { + pcgctl = readl(hsotg->regs + PCGCTL); + pcgctl |= PCGCTL_STOPPCLK; + writel(pcgctl, hsotg->regs + PCGCTL); + } } - /* Enter partial_power_down */ - ret = dwc2_enter_partial_power_down(hsotg); - if (ret) { - if (ret != -ENOTSUPP) - dev_err(hsotg->dev, - "enter partial_power_down failed\n"); - goto skip_power_saving; + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { + /* Enter partial_power_down */ + ret = dwc2_enter_partial_power_down(hsotg); + if (ret) { + if (ret != -ENOTSUPP) + dev_err(hsotg->dev, + "enter partial_power_down failed\n"); + goto skip_power_saving; + } + + /* After entering partial_power_down, hardware is no more accessible */ + clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); } /* Ask phy to be suspended */ @@ -4530,9 +4545,6 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); } - /* After entering partial_power_down, hardware is no more accessible */ - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - skip_power_saving: hsotg->lx_state = DWC2_L2; unlock: @@ -4545,6 +4557,7 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) { struct dwc2_hsotg *hsotg = dwc2_hcd_to_hsotg(hcd); unsigned long flags; + u32 pcgctl; int ret = 0; spin_lock_irqsave(&hsotg->lock, flags); @@ -4555,17 +4568,11 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) if (hsotg->lx_state != DWC2_L2) goto unlock; - if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL) { + if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) { hsotg->lx_state = DWC2_L0; goto unlock; } - /* - * Set HW accessible bit before powering on the controller - * since an interrupt may rise. - */ - set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); - /* * Enable power if not already done. * This must not be spinlocked since duration @@ -4577,10 +4584,23 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_lock_irqsave(&hsotg->lock, flags); } - /* Exit partial_power_down */ - ret = dwc2_exit_partial_power_down(hsotg, true); - if (ret && (ret != -ENOTSUPP)) - dev_err(hsotg->dev, "exit partial_power_down failed\n"); + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { + /* + * Set HW accessible bit before powering on the controller + * since an interrupt may rise. + */ + set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); + + + /* Exit partial_power_down */ + ret = dwc2_exit_partial_power_down(hsotg, true); + if (ret && (ret != -ENOTSUPP)) + dev_err(hsotg->dev, "exit partial_power_down failed\n"); + } else { + pcgctl = readl(hsotg->regs + PCGCTL); + pcgctl &= ~PCGCTL_STOPPCLK; + writel(pcgctl, hsotg->regs + PCGCTL); + } hsotg->lx_state = DWC2_L0; @@ -4592,10 +4612,12 @@ static int _dwc2_hcd_resume(struct usb_hcd *hcd) spin_unlock_irqrestore(&hsotg->lock, flags); dwc2_port_resume(hsotg); } else { - dwc2_vbus_supply_init(hsotg); + if (hsotg->params.power_down == DWC2_POWER_DOWN_PARAM_PARTIAL) { + dwc2_vbus_supply_init(hsotg); - /* Wait for controller to correctly update D+/D- level */ - usleep_range(3000, 5000); + /* Wait for controller to correctly update D+/D- level */ + usleep_range(3000, 5000); + } /* * Clear Port Enable and Port Status changes. From patchwork Thu Apr 18 00:13:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10906419 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 518FA17E6 for ; Thu, 18 Apr 2019 00:15:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DB4628BD5 for ; Thu, 18 Apr 2019 00:15:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31E5E28BD8; Thu, 18 Apr 2019 00:15:27 +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=unavailable 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 C9B5C28BD7 for ; Thu, 18 Apr 2019 00:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387855AbfDRAPR (ORCPT ); Wed, 17 Apr 2019 20:15:17 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:43408 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387687AbfDRAO7 (ORCPT ); Wed, 17 Apr 2019 20:14:59 -0400 Received: by mail-pf1-f196.google.com with SMTP id c8so224304pfd.10 for ; Wed, 17 Apr 2019 17:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FEymG5YLHbrDDzFxo52pdSm6cWs0XYbMN/p1plON6hw=; b=IxvwAG/FD+h3vReXVkO8WN6TgoWmn5hmjEDHCWUqYGymihVRS6a5o1mVUT3QNKxtUS s8WcGVHZle2CbosV4XoPgSRF+m5tBlUbQOt2yAkreM99lgKyKUsc0Fkuy3JlX/HFQ/4d bdAJoUwFWOoAEIZttOkK4YpGJT2cIkcGbSuHs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FEymG5YLHbrDDzFxo52pdSm6cWs0XYbMN/p1plON6hw=; b=l3EouFYzIhru0xbi4cfofZS6ip8Srpgkj3/681BezGq20/Vlr/UpK/3AvusAI/lAj2 yYHt105gK0sNCI113358EjtG7JTzUiFsFMEd8+dBPmUAH5eHo5V0T1PVkfNzmGD/jFoV m/ZhndKD5Wf7NPscrPCTZ4iUPfx4eCpCV3dGUnxw2l/hsW5VT3i+m2XgloQt33v9rw/+ lZIFkxkDLzL14PcSSInQqibpMZxIOPZwLv0gYAw44xCSgXjX9keK5L5MHjcPyHj/wfO0 eq+VkVYpFq12WsnF1MOQAy7XMA5Yr78f114JgEmUxJao3hbLQcPqpCqjr63Rk/B9VFhk nN/A== X-Gm-Message-State: APjAAAXqdB09IS+LXly4H+8mD9UYobMEoJ+Nqot25wnhPxEWts9QUrTR VWn+0gHG9F6yMU8smWkSbs9IaQ== X-Google-Smtp-Source: APXvYqzyMQB6DofPsR3ROmeLa7d3NvmAdljo4RKmr1talzLCVFturW2bHncz7YNf+WhFu2sdhPQ5/g== X-Received: by 2002:a62:aa06:: with SMTP id e6mr2953350pff.254.1555546499283; Wed, 17 Apr 2019 17:14:59 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q5sm447668pff.97.2019.04.17.17.14.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 17:14:58 -0700 (PDT) From: Douglas Anderson To: Minas Harutyunyan , Felipe Balbi , heiko@sntech.de Cc: Alan Stern , Artur Petrosyan , amstan@chromium.org, linux-rockchip@lists.infradead.org, William Wu , linux-usb@vger.kernel.org, Stefan Wahren , Randy Li , zyw@rock-chips.com, mka@chromium.org, ryandcase@chromium.org, Amelie Delaunay , jwerner@chromium.org, dinguyen@opensource.altera.com, Elaine Zhang , Douglas Anderson , Kai-Heng Feng , Nicolas Saenz Julienne , linux-kernel@vger.kernel.org, Nicolas Boichat , Jon Flatley , Greg Kroah-Hartman , Mathias Nyman Subject: [PATCH v2 2/5] USB: Export usb_wakeup_enabled_descendants() Date: Wed, 17 Apr 2019 17:13:53 -0700 Message-Id: <20190418001356.124334-3-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190418001356.124334-1-dianders@chromium.org> References: <20190418001356.124334-1-dianders@chromium.org> MIME-Version: 1.0 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 (e583d9d USB: global suspend and remote wakeup don't mix) we introduced wakeup_enabled_descendants() as a static function. We'd like to use this function in USB controller drivers to know if we should keep the controller on during suspend time, since doing so has a power impact. Signed-off-by: Douglas Anderson --- For relevant prior discussion of this idea, see: https://lkml.kernel.org/r/1436207224-21849-4-git-send-email-dianders@chromium.org If I'm reading all the responses correctly folks were of the opinion that this patch is still the right way to go. Changes in v2: None drivers/usb/core/hub.c | 7 ++++--- include/linux/usb/hcd.h | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 8d4631c81b9f..5e8f3fa7ae5a 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -3174,13 +3174,14 @@ static int usb_disable_remote_wakeup(struct usb_device *udev) } /* Count of wakeup-enabled devices at or below udev */ -static unsigned wakeup_enabled_descendants(struct usb_device *udev) +unsigned usb_wakeup_enabled_descendants(struct usb_device *udev) { struct usb_hub *hub = usb_hub_to_struct_hub(udev); return udev->do_remote_wakeup + (hub ? hub->wakeup_enabled_descendants : 0); } +EXPORT_SYMBOL_GPL(usb_wakeup_enabled_descendants); /* * usb_port_suspend - suspend a usb device's upstream port @@ -3282,7 +3283,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg) * Therefore we will turn on the suspend feature if udev or any of its * descendants is enabled for remote wakeup. */ - else if (PMSG_IS_AUTO(msg) || wakeup_enabled_descendants(udev) > 0) + else if (PMSG_IS_AUTO(msg) || usb_wakeup_enabled_descendants(udev) > 0) status = set_port_feature(hub->hdev, port1, USB_PORT_FEAT_SUSPEND); else { @@ -3687,7 +3688,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) } if (udev) hub->wakeup_enabled_descendants += - wakeup_enabled_descendants(udev); + usb_wakeup_enabled_descendants(udev); } if (hdev->do_remote_wakeup && hub->quirk_check_port_auto_suspend) { diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 695931b03684..ed4fbbd1b35f 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -652,11 +652,16 @@ extern wait_queue_head_t usb_kill_urb_queue; #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) #ifdef CONFIG_PM +extern unsigned usb_wakeup_enabled_descendants(struct usb_device *udev); extern void usb_root_hub_lost_power(struct usb_device *rhdev); extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg); extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); #else +static inline unsigned usb_wakeup_enabled_descendants(struct usb_device *udev) +{ + return 0; +} static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) { return; From patchwork Thu Apr 18 00:13:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10906407 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 15D9814DB for ; Thu, 18 Apr 2019 00:15:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFFF928BD4 for ; Thu, 18 Apr 2019 00:15:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E428A28BD7; Thu, 18 Apr 2019 00:15:16 +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 7EE6428BD4 for ; Thu, 18 Apr 2019 00:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387791AbfDRAPB (ORCPT ); Wed, 17 Apr 2019 20:15:01 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:46161 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387782AbfDRAPB (ORCPT ); Wed, 17 Apr 2019 20:15:01 -0400 Received: by mail-pg1-f195.google.com with SMTP id q1so284834pgv.13 for ; Wed, 17 Apr 2019 17:15:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8a+BZEe7v/lxE++Jk26DJvDIeRtcgS+edmxjVgSar6E=; b=IVSeUaSONgbK9dI1ta/UwuOc1HRfMQvPSCtcNOmVBdiHzUEh6REoeZBCONmL+PZwSV gdii0s7Vx/s52jH8A1PQYwkkHw9YqXyjHxrrr/jGLWyyR7H1KXSZpkgeusUpVeqsGy6D hURXqfMjL0W5jtLLmOK6G1hVPp3iOLlOrIF3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8a+BZEe7v/lxE++Jk26DJvDIeRtcgS+edmxjVgSar6E=; b=BmCSoLXeZzvZgfjcHbivHOSqGqYNapG6CyWM6AYhHolZi/K5hUMGyAx2JwnEEhbi3t /ThZ4ZupItdmMbqMHg5guLdm5emqIocSO9eZtXuLEXexRYbXj7Efcg1sf/btek0Vu77M pHe/18u7xooD6odPDmzxFKkMDQuZIOdrLUirQAIoPFD19fu81Tjt79lfUzhX7WZAqjc0 qT4VFlegtlpJ6DSwNLPnZOwvVi6Sws6HOC7+dLvkncy+h9/yHLycTcKdKQjggylkGEVU WuKD93dssy9eWfP18+BYVhOXy+54KGJ5Ho12rlBtxoIF2iS22e9gap1MNqKYyXq8F3KE CH1w== X-Gm-Message-State: APjAAAVwnpyAVgs2jX3HjNdV2hmtyG7O4FQOKASOuPIBGWAqcnqARRM+ KLBmBwA20Ldc5HbttCDVXmgzGg== X-Google-Smtp-Source: APXvYqxYqSg78iVNlYmCW86sspNg6ANcr7iduniZLCDqL6dcz9Jy0fjB/9qbeZkfU6namPKEZg5IPQ== X-Received: by 2002:a62:6fc6:: with SMTP id k189mr74302179pfc.154.1555546500578; Wed, 17 Apr 2019 17:15:00 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q5sm447668pff.97.2019.04.17.17.14.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 17:15:00 -0700 (PDT) From: Douglas Anderson To: Minas Harutyunyan , Felipe Balbi , heiko@sntech.de Cc: Alan Stern , Artur Petrosyan , amstan@chromium.org, linux-rockchip@lists.infradead.org, William Wu , linux-usb@vger.kernel.org, Stefan Wahren , Randy Li , zyw@rock-chips.com, mka@chromium.org, ryandcase@chromium.org, Amelie Delaunay , jwerner@chromium.org, dinguyen@opensource.altera.com, Elaine Zhang , Douglas Anderson , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Greg Kroah-Hartman , Mark Rutland Subject: [PATCH v2 3/5] Documentation: dt-bindings: Add snps,need-phy-for-wake for dwc2 USB Date: Wed, 17 Apr 2019 17:13:54 -0700 Message-Id: <20190418001356.124334-4-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190418001356.124334-1-dianders@chromium.org> References: <20190418001356.124334-1-dianders@chromium.org> MIME-Version: 1.0 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 Some SoCs with a dwc2 USB controller may need to keep the PHY on to support remote wakeup. Allow specifying this as a device tree property. Signed-off-by: Douglas Anderson --- For relevant prior discussion on this patch, see: https://lkml.kernel.org/r/1435017144-2971-3-git-send-email-dianders@chromium.org I didn't make any changes from the prior version since I never found out what Rob thought of my previous arguments. If folks want a change, perhaps they could choose from these options: 1. Assume that all dwc2 hosts would like to keep their PHY on for suspend if there's a USB wakeup enabled, thus we totally drop this binding. This doesn't seem super great to me since I'd bet that many devices that use dwc2 weren't designed for USB wakeup (they may not keep enough clocks or rails on) so we might be wasting power for nothing. 2. Rename this property to "snps,wakeup-from-suspend-with-phy" to make it more obvious that this property is intended both to document that wakeup from suspend is possible and that we need the PHY for said wakeup. 3. Rename this property to "snps,can-wakeup-from-suspend" and assume it's implicit that if we can wakeup from suspend that we need to keep the PHY on. If/when someone shows that a device exists using dwc2 where we can wakeup from suspend without the PHY they can add a new property. Changes in v2: None Documentation/devicetree/bindings/usb/dwc2.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index f70f3aee4bfc..1c5e29d23c51 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt @@ -37,6 +37,8 @@ Refer to phy/phy-bindings.txt for generic phy consumer properties - g-rx-fifo-size: size of rx fifo size in gadget mode. - g-np-tx-fifo-size: size of non-periodic tx fifo size in gadget mode. - g-tx-fifo-size: size of periodic tx fifo per endpoint (except ep0) in gadget mode. +- snps,need-phy-for-wake: If present indicates that the phy needs to be left + on for remote wakeup during suspend. - snps,reset-phy-on-wake: If present indicates that we need to reset the PHY when we detect a wakeup. This is due to a hardware errata. @@ -53,4 +55,5 @@ Example: clock-names = "otg"; phys = <&usbphy>; phy-names = "usb2-phy"; + snps,need-phy-for-wake; }; From patchwork Thu Apr 18 00:13:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10906403 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 5EDCF14DB for ; Thu, 18 Apr 2019 00:15:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4852A28BD4 for ; Thu, 18 Apr 2019 00:15:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C34228BDA; Thu, 18 Apr 2019 00:15: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 A49E728BD4 for ; Thu, 18 Apr 2019 00:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387810AbfDRAPD (ORCPT ); Wed, 17 Apr 2019 20:15:03 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39674 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387799AbfDRAPD (ORCPT ); Wed, 17 Apr 2019 20:15:03 -0400 Received: by mail-pf1-f196.google.com with SMTP id i17so232962pfo.6 for ; Wed, 17 Apr 2019 17:15:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MIQc6nb78x4dX7zZdpFCr2Ou987p1QUJbog7A/7Fv+o=; b=mixCdUtwMK+XLff4ncol1Q/8d97x7uycyS81jNA6X8UeFFCPVEiwfCbVn3fmxHXH2n WZBSKRzGfuOth7RXk3aT2rquxXh4yZsXZOePcLhgUoWHJ4g7sKlwpO34Mo86+wQ3fMkr PUbwgq85Piz5xEcnPXjzHl7xjl5SuE0gnsEnM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MIQc6nb78x4dX7zZdpFCr2Ou987p1QUJbog7A/7Fv+o=; b=oIZBbddGeshCeAvJjqrlULOcn9Gf6LX1Bf8Nya1GpgK2kzWmJsoIch79DOGPEH2zQ8 3DDZDHPUuZm+DDwv1ztYeKcP7HXRweakA0+jQNVwvWIsdfv/u3cp1ELxhcqMxDihoIz2 5pJIZaiNxJJU75UWAbwJ2TmrMNAKIKGi9XZJ+s0wGuMglonTgEEvW1S43e1+0SGK6EAs AbFqJy05Z5fFDqyMrlhvX4+mMbSO3c5HMfdR7wyLbFAsxhmfzu3b4ZXGZfC3wuQqA/y8 KRkkYVxnu1muMPzT2r4Dp47kR8lXWNGwPwgmKRKeozchtuCImzcCAaAEIUSvRIctWpck J89w== X-Gm-Message-State: APjAAAV3d/JfsBMswaJYaabTFqbyKm767tXoJLGRJXZlIF33lEkg59BQ gcfeoV3ow/taWWCkTTIyapvi5g== X-Google-Smtp-Source: APXvYqxx2dZRVxVNGwedp5XviAZdXPDEUKgfhKXZ+ubd9+S7qL/RTyB90fe0SwHbr45tjLTZpZWzKg== X-Received: by 2002:a63:c746:: with SMTP id v6mr84071022pgg.401.1555546501936; Wed, 17 Apr 2019 17:15:01 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q5sm447668pff.97.2019.04.17.17.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 17:15:01 -0700 (PDT) From: Douglas Anderson To: Minas Harutyunyan , Felipe Balbi , heiko@sntech.de Cc: Alan Stern , Artur Petrosyan , amstan@chromium.org, linux-rockchip@lists.infradead.org, William Wu , linux-usb@vger.kernel.org, Stefan Wahren , Randy Li , zyw@rock-chips.com, mka@chromium.org, ryandcase@chromium.org, Amelie Delaunay , jwerner@chromium.org, dinguyen@opensource.altera.com, Elaine Zhang , Douglas Anderson , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] USB: dwc2: Don't turn off the usbphy in suspend if wakeup is enabled Date: Wed, 17 Apr 2019 17:13:55 -0700 Message-Id: <20190418001356.124334-5-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190418001356.124334-1-dianders@chromium.org> References: <20190418001356.124334-1-dianders@chromium.org> MIME-Version: 1.0 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 If the 'snps,need-phy-for-wake' is set in the device tree then: - We know that we can wakeup, so call device_set_wakeup_capable(). The USB core will use this knowledge to enable wakeup by default. - We know that we should keep the PHY on during suspend if something on our root hub needs remote wakeup. This requires the patch (USB: Export usb_wakeup_enabled_descendants()). Note that we don't keep the PHY on at suspend time if it's not needed because it would be a power draw. If we later find some users of dwc2 that can support wakeup without keeping the PHY on we may want to add a way to call device_set_wakeup_capable() without keeping the PHY on at suspend time. Signed-off-by: Douglas Anderson Signed-off-by: Chris Zhong --- For relevant prior discussion of this idea, see: https://lkml.kernel.org/r/1436207224-21849-4-git-send-email-dianders@chromium.org If I'm reading all the responses correctly folks were of the opinion that this patch is still the right way to go. Changes in v2: - Rebased to mainline atop rk3288 remote wake quirk series. drivers/usb/dwc2/core.h | 5 +++++ drivers/usb/dwc2/platform.c | 43 +++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index f30748f4fe7e..a99fe7851352 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -861,6 +861,9 @@ struct dwc2_hregs_backup { * @hibernated: True if core is hibernated * @reset_phy_on_wake: Quirk saying that we should assert PHY reset on a * remote wakeup. + * @phy_off_for_suspend: Status of whether we turned the PHY off at suspend. + * @need_phy_for_wake: Quirk saying that we should keep the PHY on at + * suspend if we need USB to wake us up. * @frame_number: Frame number read from the core. For both device * and host modes. The value ranges are from 0 * to HFNUM_MAX_FRNUM. @@ -1049,6 +1052,8 @@ struct dwc2_hsotg { unsigned int ll_hw_enabled:1; unsigned int hibernated:1; unsigned int reset_phy_on_wake:1; + unsigned int need_phy_for_wake:1; + unsigned int phy_off_for_suspend:1; u16 frame_number; struct phy *phy; diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c index 9b65b766e0b9..6f0271c5d163 100644 --- a/drivers/usb/dwc2/platform.c +++ b/drivers/usb/dwc2/platform.c @@ -47,7 +47,9 @@ #include #include #include +#include +#include #include #include "core.h" @@ -450,6 +452,10 @@ static int dwc2_driver_probe(struct platform_device *dev) if (retval) goto error; + hsotg->need_phy_for_wake = + of_property_read_bool(dev->dev.of_node, + "snps,need-phy-for-wake"); + /* * Reset before dwc2_get_hwparams() then it could get power-on real * reset value form registers. @@ -481,6 +487,14 @@ static int dwc2_driver_probe(struct platform_device *dev) hsotg->gadget_enabled = 1; } + /* + * If we need PHY for wakeup we must be wakeup capable. + * When we have a device that can wake without the PHY we + * can adjust this condition. + */ + if (hsotg->need_phy_for_wake) + device_set_wakeup_capable(&dev->dev, true); + hsotg->reset_phy_on_wake = of_property_read_bool(dev->dev.of_node, "snps,reset-phy-on-wake"); @@ -516,6 +530,28 @@ static int dwc2_driver_probe(struct platform_device *dev) return retval; } +static bool __maybe_unused dwc2_can_poweroff_phy(struct dwc2_hsotg *dwc2) +{ + struct usb_device *root_hub = dwc2_hsotg_to_hcd(dwc2)->self.root_hub; + + if (!dwc2->ll_hw_enabled) + return false; + + /* If the controller isn't allowed to wakeup then we can power off. */ + if (!device_may_wakeup(dwc2->dev)) + return true; + + /* + * We don't want to power off the PHY if something under the + * root hub has wakeup enabled. + */ + if (usb_wakeup_enabled_descendants(root_hub)) + return false; + + /* No reason to keep the PHY powered, so allow poweroff */ + return true; +} + static int __maybe_unused dwc2_suspend(struct device *dev) { struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev); @@ -524,8 +560,10 @@ static int __maybe_unused dwc2_suspend(struct device *dev) if (dwc2_is_device_mode(dwc2)) dwc2_hsotg_suspend(dwc2); - if (dwc2->ll_hw_enabled) + if (dwc2_can_poweroff_phy(dwc2)) { ret = __dwc2_lowlevel_hw_disable(dwc2); + dwc2->phy_off_for_suspend = true; + } return ret; } @@ -535,11 +573,12 @@ static int __maybe_unused dwc2_resume(struct device *dev) struct dwc2_hsotg *dwc2 = dev_get_drvdata(dev); int ret = 0; - if (dwc2->ll_hw_enabled) { + if (dwc2->phy_off_for_suspend && dwc2->ll_hw_enabled) { ret = __dwc2_lowlevel_hw_enable(dwc2); if (ret) return ret; } + dwc2->phy_off_for_suspend = false; if (dwc2_is_device_mode(dwc2)) ret = dwc2_hsotg_resume(dwc2); From patchwork Thu Apr 18 00:13:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 10906401 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 221AE17E6 for ; Thu, 18 Apr 2019 00:15:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B9F728BD4 for ; Thu, 18 Apr 2019 00:15:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2E1A28BD7; Thu, 18 Apr 2019 00:15: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 937A028BD5 for ; Thu, 18 Apr 2019 00:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387834AbfDRAPH (ORCPT ); Wed, 17 Apr 2019 20:15:07 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46451 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387814AbfDRAPD (ORCPT ); Wed, 17 Apr 2019 20:15:03 -0400 Received: by mail-pl1-f196.google.com with SMTP id y6so249333pll.13 for ; Wed, 17 Apr 2019 17:15:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9dHCbPnlI9BSQxis0+totmB/WamSdFGOvfhVYVfhROQ=; b=g+JqrgM6CtbjdujZ4bhx4uBddKF+4SRVyOciP5srObjxxh8KDMl19YmZbkZRq9D6ro /oQuSYOpqFTsQE5PzmeCMGPnnB5FLYBf00CWcGLWBi2Ml0xUlmRHTB/JAtskaKWlNo5g dQmAwOypdXgrccYfyYUTb/Z2JAOT2ZOBU3IHI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9dHCbPnlI9BSQxis0+totmB/WamSdFGOvfhVYVfhROQ=; b=Hz+gL5Sf/wd6dLtEcA8CCHHVGu5mX4pba2ZIAKHB6l0STHJUPfuFf+Nd3qtFLDdf1U ccqqagleeqYvHBFiGXtOiNFo7vXkWdmUcCpOyPsev++wFHZKN4mwRdg/DcFv7dpWi27e JfImsLPhp8be5ncybc7RsYVJqR95lbpL6niahkjGEPJKDg9PAmd/VJNyQj8SkTl2wl7a tbLZ7OejBxCMthQ0k4iR49ag+it8fUvIrVSSwFqDNYAV488mlaDCsws1fNt7pVbcNaub iGkSJyYJCleLFxtH+e8bS3nCbol4LpMJYic/YIV7zk2N/0tD8nKLm5YAXvmJz2dTy3vy rqaA== X-Gm-Message-State: APjAAAVLMjZQJzSxEO3RSMpUHIpjBMLskieCulwOJF0kaiz/c/bTOpsc V+GyfFE6tAyAQExIOXclkhL5MA== X-Google-Smtp-Source: APXvYqxWk5e1kbmfttQMLubOoAO7jJexKAOokKqYIE8CqxPpp93l2fjdF31N53x3ArHo1fS2mksl/Q== X-Received: by 2002:a17:902:2aeb:: with SMTP id j98mr25482240plb.38.1555546503259; Wed, 17 Apr 2019 17:15:03 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:1:24fa:e766:52c9:e3b2]) by smtp.gmail.com with ESMTPSA id q5sm447668pff.97.2019.04.17.17.15.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Apr 2019 17:15:02 -0700 (PDT) From: Douglas Anderson To: Minas Harutyunyan , Felipe Balbi , heiko@sntech.de Cc: Alan Stern , Artur Petrosyan , amstan@chromium.org, linux-rockchip@lists.infradead.org, William Wu , linux-usb@vger.kernel.org, Stefan Wahren , Randy Li , zyw@rock-chips.com, mka@chromium.org, ryandcase@chromium.org, Amelie Delaunay , jwerner@chromium.org, dinguyen@opensource.altera.com, Elaine Zhang , Douglas Anderson , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Rob Herring , Mark Rutland , linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 5/5] ARM: dts: rockchip: Allow wakeup from rk3288-veyron's dwc2 USB ports Date: Wed, 17 Apr 2019 17:13:56 -0700 Message-Id: <20190418001356.124334-6-dianders@chromium.org> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog In-Reply-To: <20190418001356.124334-1-dianders@chromium.org> References: <20190418001356.124334-1-dianders@chromium.org> MIME-Version: 1.0 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 We want to be able to wake from USB if a device is plugged in that wants remote wakeup. Enable it on both dwc2 controllers. NOTE: this is added specifically to veyron and not to rk3288 in general since it's not known whether all rk3288 boards are designed to support USB wakeup. It is plausible that some boards could shut down important rails in S3. Also note that currently wakeup doesn't seem to happen unless you use the "deep" suspend mode (where SDRAM is turned off). Presumably the shallow suspend mode is gating some sort of clock that's important but I couldn't easily figure out how to get it working. Signed-off-by: Douglas Anderson --- Changes in v2: - rk3288-veyron dts patch new for v2. arch/arm/boot/dts/rk3288-veyron.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/rk3288-veyron.dtsi b/arch/arm/boot/dts/rk3288-veyron.dtsi index 1252522392c7..1d8bfed7830c 100644 --- a/arch/arm/boot/dts/rk3288-veyron.dtsi +++ b/arch/arm/boot/dts/rk3288-veyron.dtsi @@ -424,6 +424,7 @@ &usb_host1 { status = "okay"; + snps,need-phy-for-wake; }; &usb_otg { @@ -432,6 +433,7 @@ assigned-clocks = <&cru SCLK_USBPHY480M_SRC>; assigned-clock-parents = <&usbphy0>; dr_mode = "host"; + snps,need-phy-for-wake; }; &vopb {