From patchwork Fri Jul 26 11:32:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13742682 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 09F2EC3DA7F for ; Fri, 26 Jul 2024 11:34:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-Type: Content-Transfer-Encoding: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=mc8GqDn4aissjR0kH4vFaFrtaqYPqnSkoWdeaJsETiM=; b=HQJBsxhfhSd7ptLYoxIlIq9ktl EauzzL5sZD8o7NGbFAO2N3ZC9vz5NlsTZLob5GUnUd/omZ5CzeUCBrEoQCFlXFakEY27WYJU0ERLj flThKtZpUky0f6R7kxn5JFRIPHH+vV/JiZP0IcqDn8Wwa+wmgUmR+7MOst6szbMPuW3qF0of8mDXu xVgJV4ypMOYARZzy8467QNbPyViXBn0fBYV/53EMdG7v9Dis6n5IWB4fbB8aJ/RLCfIDO3xOxXBRJ NK2SPPIT9i2gxh7iM5mcjA7XQD1W8lQVvgIJbffnr/9TZ6lIPC0Li+7+wq+hKQHpkCK9rqWoIri0H 372pOc9Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXJD3-00000003ju8-3B9b; Fri, 26 Jul 2024 11:34:05 +0000 Received: from mail-westeuropeazlp170100000.outbound.protection.outlook.com ([2a01:111:f403:c201::] helo=AM0PR83CU005.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sXJBH-00000003jR2-3PXN; Fri, 26 Jul 2024 11:32:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=g3OCTXA6gV2ZuEI97oeHg5O42w+oRIUI7HNjyNRxujPXgdVDMs2X0tGdeSEsTpEBDsMWUASLtDQR7OPzt4OH5I/IPCDFW/iwoFxRtBBNKyMjSHmMA8wx8xz1Wgi3VAn4RVDsxBnszQjrr7IgmP/bSvlgrPfep3KsKHV8XDHf8+1tFPKjoTt4x/ZmMt+q14uoAKxJBsazaDv3szX4zIIFw/w7PwKTsA/WZAImEWN2aSuD4ZbujbV5hqXWy/f90EMMfceuu6P9LfUZmcDuhQIN0L60YD3WoyIiwUF5t/4KPQR5NUSYpCIf1OL5buO5TokA3zh4R3usvKTOJbWI/rjIyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mc8GqDn4aissjR0kH4vFaFrtaqYPqnSkoWdeaJsETiM=; b=FnlWsmbBMt0PA6F+iZ3G0RgGi/YX7ECjaCzZc4JDjhvyhYoSXl+BjcNHAzXRiVXwZ++4uxe1ZUveOnMy8aCVV9rrRFEx+oRXn91phMK6EW9B2jQsom8e0SJUnR8fSxwXO1Zwae8oSIq6qNJvXjsVg5FPJrlL/22K6g64Z/wSfKfCWMgn9F+hZW0RtaymeWm4jvJiGwdRBF+JL3FM8lP6jfqKlX4sl9LilOwzYyiOAeUCdC61tMRjyujeM9lmw2YogCcoABwCYlfu+KtIa4D9F+hL6qQzW/XsM7mrV292dcW9Fo73gqKGEKaXkkYicv+Gp6D36ZI1EpnE20r6IBA9PQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mc8GqDn4aissjR0kH4vFaFrtaqYPqnSkoWdeaJsETiM=; b=YRm8oPMDzhdCfhcm9PA0Pr682nEbRz2VUoK+Au2g+5GWwUBB7bBvEvW36zHKcIInEVehbZiNjlIh2ZHesNvbpe8hoobvsDZNZbL04NBAhMCvPamFXmomWw0BYWCqznBTgJ31LDuuX4ISMDgSu2v3qrVHLM87/++M62mdT1Hiq+kJVQFADShfHHeXfQUdtKWKjtRAvQp/WPU6TQO8DbojfEPQqd+dmcdaASBeC25b6hY7T6q5jFFWZylbR5ijrOcBNdUuux79PlHRurLw6p09VctosLnO/fV0BwHyMJVGjQG4J3mCn7IJoD+Xzo1whOLcS0o5ZrYtPnk6hZ0QWKyUKA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by AM8PR04MB7875.eurprd04.prod.outlook.com (2603:10a6:20b:236::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.29; Fri, 26 Jul 2024 11:32:12 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7%5]) with mapi id 15.20.7784.016; Fri, 26 Jul 2024 11:32:12 +0000 From: Xu Yang To: vkoul@kernel.org, kishon@kernel.org, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, gregkh@linuxfoundation.org, peter.chen@kernel.org, herve.codina@bootlin.com Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-usb@vger.kernel.org, jun.li@nxp.com Subject: [PATCH v2 5/6] usb: phy: mxs: enable weak 1p1 regulator for imx6ul during suspend Date: Fri, 26 Jul 2024 19:32:06 +0800 Message-Id: <20240726113207.3393247-5-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240726113207.3393247-1-xu.yang_2@nxp.com> References: <20240726113207.3393247-1-xu.yang_2@nxp.com> X-ClientProxiedBy: SI1PR02CA0047.apcprd02.prod.outlook.com (2603:1096:4:1f5::15) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AM8PR04MB7875:EE_ X-MS-Office365-Filtering-Correlation-Id: 20b70f7c-2c6e-4070-1dc6-08dcad6697c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|52116014|366016|7416014|376014|921020|38350700014; X-Microsoft-Antispam-Message-Info: T3jb3f610K0D2x8TohSTbxaO8jx97HZDY2OCBE9FQNXeVsP0t5i7kqhdxAGLxIB3AUEELm8lQD0YdhJuqwoKw3V7/Qqhqm24GZtDXXUR9yXrCDButjCRpLcAiQHsy8GI9GesR4KLpMppK42PDyP1qQ25Yb7eydInVYO/tEIn8nsm9z6Hm8nJvu95WbP089ZJMwwHA4kIwpg5sK1nsM3MtXuCfUtscNFDwfLwwfeduBXazobRUfRhmJjt2AzvIQlIc8tND5Q0LnaNJET1UfeBxnc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3Om2Wv6aDd+7svMf9V+F5qZauW9iMfpG8gp+uMgiYWM2yVkNITJK9Bn0B06ybnoo9z2gURRvt9pBRdyzyo4kxA= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8822.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(52116014)(366016)(7416014)(376014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7j/wlND+iKHJp4P6H/HHfYoTS3A3XcbmJ2VenPBx4rzzeBpL/DujAcGr+dVEsi5Nl45l+Ss8oMxK6h2M59Y5JosxDU8X8wD7ungtwOt08RpnpTO58z/idIODXeBfZE7bxdKgkYE6oL2DCuRarCkDGWnE+2/5nEGc1BFsMI/r/nu+yHv2NutvSQh30DUq1EmxVjUvTufuPolQEbSmZTnd1ha9yFq6U9ktGowY9zP0r+n6aWFQNo44l4494hcpLj8x1tyP5U1iFHMdxvfPerfhnG+rvXGHHRABFriuyY2Mc7LdjOgBkNsILfDCWvmhe67yKNsbv8/ppS7nTaRXyCE9f+5JgGY0timV6mVjA1EAu5sMEx5fATZowAdOUKlyC2SnQV8O7w+EjAjOUFCTRYgms5TbuvEyEOJndmgdWlFbjf9AB5yhIKso4zlJG+/rjCxM+0vP4CO1sgeGrpynIJ2v1OzWYahJ5JeKMPSqtM8Lsi7TPbsj3F676tAYnyH9+hhnvWK5LNEcXql1ZNjmBfs7m0PxC5F/J5CZCbw3RkMW2HdAz2Or+CKBVoIMWT/HLBK6+sKsoSiaicFeEgPpt/YMEgYDpBtcNWHAXPqo0f+p4xnhRCHTYYuVImQp7+I6eo8SxPRhU5ypheNeK/Rp5tsd8CXATMYYJWmb+CiLmEGxzdFeoYS3bS3iF72mXUguNTq9ju92pPLWsq4wfFN5VIa2ZMfm1wIjnuMmT+tHOtnRnrGH9a3d9Np8SC7b3RLHCZamf2FzBqn9gT801LMkLUATM9Bqo1Z62vD3/yVsIwwqorHTH+QpHGDv+JnOCGrVrOKzH9nnm/7DpzuTAkVubO2zjxPoo8mPVgaWJ+jArLKwDkIdf9lKrdWhgh+mLnRYcrRq+fuClVpmi3ExkTa1WlGz6kmPmC/VR4H0uDimrmRse3iDMOw0tZE0QBfsdk17CHYOc06jEyHOlrbsPeDIuuf+h9sxI8OtqURWUcaPtvZROsWJ6DcbUqKz98lgYGVX4oZXGnlY66gHpWkErVAVNqUbrtXIaN61bigqgg898nzOFw8jbsy6LW2BRNW74b7P5YU5T1zkFzmLPLNWhCJ+qNusZIFrB6rowGfXMpH8Lx4P3TfXyYKa+FhDQzkMwQbHzRBCUi9nwuKiFfgyqv92CgBy4a2WWVzd1/gVTHwFFXs8O+LjO+WM0f+mrtWCf9hfgzhGFIJ/VObldFtVdd8VhMhlvK54QjFLtsCB7WLqiQyKLGDUUzCwduxFsR5eIU74awmaj3xgZCDP/dEN5+iAJwdO3Zg2nTCJnL5jPn7EndsKeJE59tL+LBuxdKEfgEnEVDEOb0n0dLQExgDe/9SUA4dKIt7i5nPVgb+UD3z7YyZk+OQk5cVN5u2lGfo17amcizyaaSNiHUnADKQD02Seu/Ckh3js6BjEV9DICnHILAdj9NsOeAj4vRHuojpWDeaMLP/Xlk0H6aAOagxIE+qSS+SwwYkadMkTbekz69WYOxJgL4cCkebnmLHDg3hqBGzNZpH5R3M1EVi33mFxWU1GUyHB97rtFuMNNW0Iwsb3jF26GdVQoSeWi42hVv8/ROpD40at X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20b70f7c-2c6e-4070-1dc6-08dcad6697c4 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2024 11:32:12.5986 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1dxP1SW1KTQKFN5Y2baL35VcL7GS4acc+GLyT6Py5+kZn6+B/tngGtjeW7mGCkACZl72A2/d0KWvYbK9Gkatsg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7875 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240726_043215_882684_A6ACBC39 X-CRM114-Status: GOOD ( 15.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 1p1 is off when the system enters suspend at i.MX6UL. It cause the PHY get wrong USB DP/DM value, then unexpected wakeup may occur if USB wakeup enabled. This will enable weak 1p1 during PHY suspend if vbus exist. So USB DP/DM is correct when system suspend. Signed-off-by: Xu Yang --- Changes in v2: - modify commit message --- drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index acaae22df3ba..cc4156c1b148 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -71,6 +71,9 @@ #define BM_USBPHY_PLL_EN_USB_CLKS BIT(6) /* Anatop Registers */ +#define ANADIG_REG_1P1_SET 0x114 +#define ANADIG_REG_1P1_CLR 0x118 + #define ANADIG_ANA_MISC0 0x150 #define ANADIG_ANA_MISC0_SET 0x154 #define ANADIG_ANA_MISC0_CLR 0x158 @@ -123,6 +126,9 @@ #define USB_PHY_VLLS_WAKEUP_EN BIT(0) +#define BM_ANADIG_REG_1P1_ENABLE_WEAK_LINREG BIT(18) +#define BM_ANADIG_REG_1P1_TRACK_VDD_SOC_CAP BIT(19) + #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy) /* Do disconnection between PHY and controller without vbus */ @@ -196,7 +202,8 @@ static const struct mxs_phy_data imx6sx_phy_data = { }; static const struct mxs_phy_data imx6ul_phy_data = { - .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS, + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | + MXS_PHY_HARDWARE_CONTROL_PHY2_CLK, }; static const struct mxs_phy_data imx7ulp_phy_data = { @@ -241,6 +248,11 @@ static inline bool is_imx7ulp_phy(struct mxs_phy *mxs_phy) return mxs_phy->data == &imx7ulp_phy_data; } +static inline bool is_imx6ul_phy(struct mxs_phy *mxs_phy) +{ + return mxs_phy->data == &imx6ul_phy_data; +} + /* * PHY needs some 32K cycles to switch from 32K clock to * bus (such as AHB/AXI, etc) clock. @@ -884,18 +896,30 @@ static void mxs_phy_wakeup_enable(struct mxs_phy *mxs_phy, bool on) static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on) { - unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; + unsigned int reg; + u32 value; /* If the SoCs don't have anatop, quit */ if (!mxs_phy->regmap_anatop) return; - if (is_imx6q_phy(mxs_phy)) + if (is_imx6q_phy(mxs_phy)) { + reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; regmap_write(mxs_phy->regmap_anatop, reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG); - else if (is_imx6sl_phy(mxs_phy)) + } else if (is_imx6sl_phy(mxs_phy)) { + reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR; regmap_write(mxs_phy->regmap_anatop, reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL); + } else if (is_imx6ul_phy(mxs_phy)) { + reg = on ? ANADIG_REG_1P1_SET : ANADIG_REG_1P1_CLR; + value = BM_ANADIG_REG_1P1_ENABLE_WEAK_LINREG | + BM_ANADIG_REG_1P1_TRACK_VDD_SOC_CAP; + if (mxs_phy_get_vbus_status(mxs_phy) && on) + regmap_write(mxs_phy->regmap_anatop, reg, value); + else if (!on) + regmap_write(mxs_phy->regmap_anatop, reg, value); + } } static int mxs_phy_system_suspend(struct device *dev)