From patchwork Wed Sep 13 06:04:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 13382467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4E30EEB596 for ; Wed, 13 Sep 2023 06:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=A4WwJwvgQlXVdadZvoSLOaFCQfRHspvf/Ymv8KGYRF0=; b=NONuhH/oh/QhAM 6SqUbWyk7K69PYikUI30+P85m2S5X+BhtoyojhE69XYSkrFsQ6ZcppyXW079hgnbnA2/ndtPYcZu6 EzmlPK+fEGVcSYqjOdyQbqM0WhLFrU2QWo05/G/svKpxYJDiOl5PmtaguRRp/ERUeYrxBYiUqeKQz gP3JmtccJZu4uSYkX2hRxB9QP1wSTbaGAUppcLayDZ/n6mnSjC3oYsqxf0PgTE88B2puQLFsuWXEK hgO7uXsdovQrTQbNjB8DpU3BEGTiqJaYnNaq1VgPwJSY4V9duYz06txlLadxBT1EHSefUeciBU3Nc ZoUgDYs5+Rgabvmk7MjA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgIzf-004kAS-1a; Wed, 13 Sep 2023 06:04:55 +0000 Received: from muru.com ([72.249.23.125]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgIzc-004k8L-01 for linux-phy@lists.infradead.org; Wed, 13 Sep 2023 06:04:53 +0000 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 5E6C380FC; Wed, 13 Sep 2023 06:04:48 +0000 (UTC) From: Tony Lindgren To: Vinod Koul , Kishon Vijay Abraham I , Miaoqian Lin Cc: Ivaylo Dimitrov , Merlijn Wajer , Pavel Machek , Sebastian Reichel , linux-phy@lists.infradead.org Subject: [PATCH v2 1/3] phy: mapphone-mdm6600: Fix runtime disable on probe Date: Wed, 13 Sep 2023 09:04:27 +0300 Message-ID: <20230913060433.48373-1-tony@atomide.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230912_230452_113123_837AEB4D X-CRM114-Status: GOOD ( 10.41 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Commit d644e0d79829 ("phy: mapphone-mdm6600: Fix PM error handling in phy_mdm6600_probe") caused a regression where we now unconditionally disable runtime PM at the end of the probe while it is only needed on errors. Cc: Ivaylo Dimitrov Cc: Merlijn Wajer Cc: Miaoqian Lin Cc: Pavel Machek Reviewed-by: Sebastian Reichel Fixes: d644e0d79829 ("phy: mapphone-mdm6600: Fix PM error handling in phy_mdm6600_probe") Signed-off-by: Tony Lindgren --- Changes since v1: - Added Sebastian's Reviewed-by --- drivers/phy/motorola/phy-mapphone-mdm6600.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c --- a/drivers/phy/motorola/phy-mapphone-mdm6600.c +++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c @@ -627,10 +627,12 @@ static int phy_mdm6600_probe(struct platform_device *pdev) pm_runtime_put_autosuspend(ddata->dev); cleanup: - if (error < 0) + if (error < 0) { phy_mdm6600_device_power_off(ddata); - pm_runtime_disable(ddata->dev); - pm_runtime_dont_use_autosuspend(ddata->dev); + pm_runtime_disable(ddata->dev); + pm_runtime_dont_use_autosuspend(ddata->dev); + } + return error; } From patchwork Wed Sep 13 06:04:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 13382468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24B3DEEB597 for ; Wed, 13 Sep 2023 06:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3V4zoGpeogRrv4X8M+QRSo3bnOhX1ze04QH5I/STifE=; b=l3RRLZ2ItB23Jv NFk8EtY3LukBVv2fdBTKV7n/rVNuXoSpMwfqGG3ac3oN0RoqLN+xoYQY0AOBJDzpCCgkJeWbl9Qg/ ZH57Ory8EW60E6EJOoODqbCQ+up8gg6JXYOCJoUJollaoXqtaBoH29nLYX7EP/5D5aF8S1LSrKCIU K6j6Dr9gvkzPoT1Pfv8JTcZvtJRokJNkQdMyB++i4i+h7BDp7updaYjEArppLq46fIrOdIttSTiqE oal1aluvoCJcAM9L9JO9epufbG3Z3BQXOE7c2xTiAAh02fxYP8LPvvY3kUobqtCFOegptS9YAex1d AHZhfBkt5tEVo2lU2+5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgIzg-004kBA-2o; Wed, 13 Sep 2023 06:04:56 +0000 Received: from muru.com ([72.249.23.125]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgIze-004kAE-1q for linux-phy@lists.infradead.org; Wed, 13 Sep 2023 06:04:55 +0000 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 7D3A38106; Wed, 13 Sep 2023 06:04:52 +0000 (UTC) From: Tony Lindgren To: Vinod Koul , Kishon Vijay Abraham I Cc: Ivaylo Dimitrov , Merlijn Wajer , Miaoqian Lin , Pavel Machek , Sebastian Reichel , linux-phy@lists.infradead.org, Sebastian Reichel , Kishon Vijay Abraham I Subject: [PATCH v2 2/3] phy: mapphone-mdm6600: Fix runtime PM for remove Date: Wed, 13 Sep 2023 09:04:28 +0300 Message-ID: <20230913060433.48373-2-tony@atomide.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913060433.48373-1-tony@atomide.com> References: <20230913060433.48373-1-tony@atomide.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230912_230454_685945_88D60965 X-CRM114-Status: UNSURE ( 8.25 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Otherwise we will get an underflow on remove. Cc: Ivaylo Dimitrov Cc: Merlijn Wajer Cc: Pavel Machek Cc: Sebastian Reichel Fixes: f7f50b2a7b05 ("phy: mapphone-mdm6600: Add runtime PM support for n_gsm on USB suspend") Signed-off-by: Tony Lindgren Reviewed-by: Sebastian Reichel --- Changes since v1: - Using pm_runtime_get_noresume() is enough on remove as suggested by Sebastian --- drivers/phy/motorola/phy-mapphone-mdm6600.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c --- a/drivers/phy/motorola/phy-mapphone-mdm6600.c +++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c @@ -641,6 +641,7 @@ static void phy_mdm6600_remove(struct platform_device *pdev) struct phy_mdm6600 *ddata = platform_get_drvdata(pdev); struct gpio_desc *reset_gpio = ddata->ctrl_gpios[PHY_MDM6600_RESET]; + pm_runtime_get_noresume(ddata->dev); pm_runtime_dont_use_autosuspend(ddata->dev); pm_runtime_put_sync(ddata->dev); pm_runtime_disable(ddata->dev); From patchwork Wed Sep 13 06:04:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 13382469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C2AA7EEB597 for ; Wed, 13 Sep 2023 06:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8RBS+zeK1aH5q813nDW7ODF7IAOUlog/i5bM7uuKQBg=; b=P56s1Qe/K9H5Nd Se0Kx9RElUyjfEqGaUQUvKIuvRmB0qXGEKSl7FIOi+UYwxka2I/XFdOW2lPppWtJaUFA8un4zihRY BZqy8x9/LSZStqhYbf/wOdYraEyJwQtyrV4S9jpGoQoLq3cNsJiRuRH1M3jSkhrYRLDkmwqp1/ysT sbcjv1733QcHTCw1SyBcFXIeFv9gbkpW+jw7oAAI8AWWF4+xYUmQqfTwWjypYjzTW88RtepHsOrBd 8IjdpyBXciKnyFLKX5VP2uNPlFoBGx+hNDlj6VvJqrsSKaCo3qZl8xz6EP8AVT9pW1dew883/cwlK ePraSkmjNFLwLfRNrzMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgIzn-004kFk-13; Wed, 13 Sep 2023 06:05:03 +0000 Received: from muru.com ([72.249.23.125]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qgIzj-004kC3-1u for linux-phy@lists.infradead.org; Wed, 13 Sep 2023 06:05:01 +0000 Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 7FE5680FC; Wed, 13 Sep 2023 06:04:57 +0000 (UTC) From: Tony Lindgren To: Vinod Koul , Kishon Vijay Abraham I Cc: Ivaylo Dimitrov , Merlijn Wajer , Miaoqian Lin , Pavel Machek , Sebastian Reichel , linux-phy@lists.infradead.org, Sebastian Reichel , Kishon Vijay Abraham I Subject: [PATCH v2 3/3] phy: mapphone-mdm6600: Fix pinctrl_pm handling for sleep pins Date: Wed, 13 Sep 2023 09:04:29 +0300 Message-ID: <20230913060433.48373-3-tony@atomide.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230913060433.48373-1-tony@atomide.com> References: <20230913060433.48373-1-tony@atomide.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230912_230459_667643_5BE64978 X-CRM114-Status: GOOD ( 17.31 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org Looks like the driver sleep pins configuration is unusable. Adding the sleep pins causes the usb phy to not respond. We need to use the default pins in probe, and only set sleep pins at phy_mdm6600_device_power_off(). As the modem can also be booted to a serial port mode for firmware flashing, let's make the pin changes limited to probe and remove. For probe, we get the default pins automatically. We only need to set the sleep pins in phy_mdm6600_device_power_off() to prevent the modem from waking up because the gpio line glitches. If it turns out that we need a separate state for phy_mdm6600_power_on() and phy_mdm6600_power_off(), we can use the pinctrl idle state. Cc: Ivaylo Dimitrov Cc: Merlijn Wajer Cc: Pavel Machek Cc: Sebastian Reichel Fixes: 2ad2af081622 ("phy: mapphone-mdm6600: Improve phy related runtime PM calls") Signed-off-by: Tony Lindgren Reviewed-by: Sebastian Reichel --- Changes since v1: - Limit the pinctrl state changes to remove for now based on what Sebastian was wondering about --- drivers/phy/motorola/phy-mapphone-mdm6600.c | 29 +++++++++------------ 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/phy/motorola/phy-mapphone-mdm6600.c b/drivers/phy/motorola/phy-mapphone-mdm6600.c --- a/drivers/phy/motorola/phy-mapphone-mdm6600.c +++ b/drivers/phy/motorola/phy-mapphone-mdm6600.c @@ -122,16 +122,10 @@ static int phy_mdm6600_power_on(struct phy *x) { struct phy_mdm6600 *ddata = phy_get_drvdata(x); struct gpio_desc *enable_gpio = ddata->ctrl_gpios[PHY_MDM6600_ENABLE]; - int error; if (!ddata->enabled) return -ENODEV; - error = pinctrl_pm_select_default_state(ddata->dev); - if (error) - dev_warn(ddata->dev, "%s: error with default_state: %i\n", - __func__, error); - gpiod_set_value_cansleep(enable_gpio, 1); /* Allow aggressive PM for USB, it's only needed for n_gsm port */ @@ -160,11 +154,6 @@ static int phy_mdm6600_power_off(struct phy *x) gpiod_set_value_cansleep(enable_gpio, 0); - error = pinctrl_pm_select_sleep_state(ddata->dev); - if (error) - dev_warn(ddata->dev, "%s: error with sleep_state: %i\n", - __func__, error); - return 0; } @@ -456,6 +445,7 @@ static void phy_mdm6600_device_power_off(struct phy_mdm6600 *ddata) { struct gpio_desc *reset_gpio = ddata->ctrl_gpios[PHY_MDM6600_RESET]; + int error; ddata->enabled = false; phy_mdm6600_cmd(ddata, PHY_MDM6600_CMD_BP_SHUTDOWN_REQ); @@ -471,6 +461,17 @@ static void phy_mdm6600_device_power_off(struct phy_mdm6600 *ddata) } else { dev_err(ddata->dev, "Timed out powering down\n"); } + + /* + * Keep reset gpio high with padconf internal pull-up resistor to + * prevent modem from waking up during deeper SoC idle states. The + * gpio bank lines can have glitches if not in the always-on wkup + * domain. + */ + error = pinctrl_pm_select_sleep_state(ddata->dev); + if (error) + dev_warn(ddata->dev, "%s: error with sleep_state: %i\n", + __func__, error); } static void phy_mdm6600_deferred_power_on(struct work_struct *work) @@ -571,12 +572,6 @@ static int phy_mdm6600_probe(struct platform_device *pdev) ddata->dev = &pdev->dev; platform_set_drvdata(pdev, ddata); - /* Active state selected in phy_mdm6600_power_on() */ - error = pinctrl_pm_select_sleep_state(ddata->dev); - if (error) - dev_warn(ddata->dev, "%s: error with sleep_state: %i\n", - __func__, error); - error = phy_mdm6600_init_lines(ddata); if (error) return error;