Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2620639imn; Tue, 2 Aug 2022 09:37:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vY0vys7eHKx25PQB6kvpVsP3hpcLqZxQPSGmpYvdqb/hkH+zPGGJQwGmbwdbQ8BojOLHgu X-Received: by 2002:a05:6402:2804:b0:439:83c2:8be2 with SMTP id h4-20020a056402280400b0043983c28be2mr22059829ede.292.1659458251078; Tue, 02 Aug 2022 09:37:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659458251; cv=none; d=google.com; s=arc-20160816; b=CDjOdh96LqVHN2nb7+S+2oITvsJtO9inyxABWhRVd0bcIBT+MC9ejNCKRby/925nnT ypZcJnFMg7aMs88R170AVhK8bIpZaoqFjY7n8UgOPUO7btSyPZHhwbYt/FIxAWQisZwo YrZKMwaPXjryRCSiZLTE9U4M33YqOLDk3TLB3pyiX/vu2slZQODB72f21CA+vLRRnM5r HS/gPvZSpJ0eShEBlsQoD1nYmguVacDplGGHKGhtKu4hB4ufx69Ufekou5Fed8D/MNz5 q8X68UyiGPE1NKgzc4r/hereDknRX3JlXQRRmXnYujZivlkHpdoVjnqBF2MylPq+jrST ErRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9o477IQ//ggkfK3P3xh5kLO1nJPtDBUvffnBDEHg7OY=; b=z/7d+eS0R/k2vvSKORWfmkjEed3fT4EMl9nughItdkpmdTMtprXl0Ln8iax6vsWIpj kd7I2k+g1BpHHqJcIeQDP9ZIQUMN0lS7xMrsO3qROBQ2CydSmKBRoJsPf16nLn0PGFTd B4TryEhLdaARt9OsgDfJUpzYGyry4JbBetKxrqGWSVlyPSetfJ2R/zd1OrO0zcXb/udn A1PKlQhvFiHndx9RjXXDL5xRRJcHBy9l8w50UNk4Ecj9bI4qRdefWni1vP0050db899c jYXShq/CWFXCXpQp33tp0d8799LM/5im8TWO3RX411vBHG/HOVpswgg6WXq4/cVxU0HT L/sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jlZ95wzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b00730a1d3bb99si2026640ejc.436.2022.08.02.09.37.05; Tue, 02 Aug 2022 09:37:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jlZ95wzA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237295AbiHBPO0 (ORCPT + 99 others); Tue, 2 Aug 2022 11:14:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235854AbiHBPOT (ORCPT ); Tue, 2 Aug 2022 11:14:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0757F15A3C; Tue, 2 Aug 2022 08:14:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9870D60276; Tue, 2 Aug 2022 15:14:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E513FC433C1; Tue, 2 Aug 2022 15:14:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1659453256; bh=/vM1hbYvcMcG5rgPtJ9rOtDS7RIJfleSu0m9KM3s3sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jlZ95wzALbGyX321n1ji2Ck4jAuKFTVOg4FpY+7WMSTTDsG3vh7QBKUWvDaRCt5Rr qdRL7TUySimjCFz+6DzBFSKgIXvNKptyuLW7BSaCB82vskAPh8MUeZxFoL4jqZ1vi3 SD+QT4kDcUy2tUxbxSaqzV6xXo7PAW3b+UHcnHZUqq4kI6ykED3jWtbEwZqL2xWSad Ky/kmHQR/QGPHQp4TA3Wg6sOJMDapfU6Kfe5YV0rclfSh+sbaxWY+bm+SjZspsxU67 soX5Yy5Vlr0N++u82JsxDQ5WekzmPNzPZmxQQmyYvSvNz8Qzybk+0xpVbQZFw1ytD+ DKO6duxbQys7A== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1oItbM-0000Tg-JZ; Tue, 02 Aug 2022 17:14:32 +0200 From: Johan Hovold To: Greg Kroah-Hartman , Felipe Balbi Cc: Rob Herring , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Manivannan Sadhasivam , Konrad Dybcio , Krishna Kurapati , Stephen Boyd , Doug Anderson , "Matthias Kaehlcke" , Pavankumar Kondeti , quic_ppratap@quicinc.com, quic_vpulyala@quicinc.com, linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 7/8] usb: dwc3: qcom: fix wakeup implementation Date: Tue, 2 Aug 2022 17:14:03 +0200 Message-Id: <20220802151404.1797-8-johan+linaro@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220802151404.1797-1-johan+linaro@kernel.org> References: <20220802151404.1797-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is the Qualcomm glue wakeup interrupts that may be able to wake the system from suspend and this can now be described in the devicetree. Move the wakeup-source property handling over from the core driver and instead propagate the capability setting to the core device during probe. This is needed as there is currently no way for the core driver to query the wakeup setting of the glue device, but it is the core driver that manages the PHY power state during suspend. Also don't leave the PHYs enabled when system wakeup has been disabled through sysfs. Fixes: 649f5c842ba3 ("usb: dwc3: core: Host wake up support from system suspend") Signed-off-by: Johan Hovold --- drivers/usb/dwc3/core.c | 5 ++--- drivers/usb/dwc3/dwc3-qcom.c | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 16d1f328775f..8c8e32651473 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1822,7 +1822,6 @@ static int dwc3_probe(struct platform_device *pdev) platform_set_drvdata(pdev, dwc); dwc3_cache_hwparams(dwc); - device_init_wakeup(&pdev->dev, of_property_read_bool(dev->of_node, "wakeup-source")); spin_lock_init(&dwc->lock); mutex_init(&dwc->mutex); @@ -1984,7 +1983,7 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) dwc3_core_exit(dwc); break; case DWC3_GCTL_PRTCAP_HOST: - if (!PMSG_IS_AUTO(msg) && !device_can_wakeup(dwc->dev)) { + if (!PMSG_IS_AUTO(msg) && !device_may_wakeup(dwc->dev)) { dwc3_core_exit(dwc); break; } @@ -2045,7 +2044,7 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) spin_unlock_irqrestore(&dwc->lock, flags); break; case DWC3_GCTL_PRTCAP_HOST: - if (!PMSG_IS_AUTO(msg) && !device_can_wakeup(dwc->dev)) { + if (!PMSG_IS_AUTO(msg) && !device_may_wakeup(dwc->dev)) { ret = dwc3_core_init_for_resume(dwc); if (ret) return ret; diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 57d3a0e6f280..1bd2818b4daa 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -771,6 +771,7 @@ static int dwc3_qcom_probe(struct platform_device *pdev) struct resource *res, *parent_res = NULL; int ret, i; bool ignore_pipe_clk; + bool wakeup_source; qcom = devm_kzalloc(&pdev->dev, sizeof(*qcom), GFP_KERNEL); if (!qcom) @@ -886,7 +887,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev) if (ret) goto interconnect_exit; - device_init_wakeup(&pdev->dev, 1); + wakeup_source = of_property_read_bool(dev->of_node, "wakeup-source"); + device_init_wakeup(&pdev->dev, wakeup_source); + device_init_wakeup(&qcom->dwc3->dev, wakeup_source); + qcom->is_suspended = false; pm_runtime_set_active(dev); pm_runtime_enable(dev); -- 2.35.1