From patchwork Fri Jul 26 11:32:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13742656 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011052.outbound.protection.outlook.com [52.101.65.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50DAE17A59A for ; Fri, 26 Jul 2024 11:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.52 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721993522; cv=fail; b=pU4Eeok2aZjzfiotz/b1K9OFoCLZzlElPKDX1MW+PD9ISTF7UbKiaEgz7WqxBVwtg+z3VIywKIoR4AJSwFIS+o2gVnHp30hQfRtCDe5NnFxAcTDb8+nMTDHwtM2z4qXoap6ZWnhQLzclbAyxZsHmm/IucjcOAA/YBuuo1XEi2OQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721993522; c=relaxed/simple; bh=gIUhgs4AMHVuSZYgp+TUGvPuNHABTsr4VFyBSl3ps+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=bTUM/J82l6UaNJj3CI6styvHvibBDVSdoPChANZafv6EdBfiC4smjknI0DzPnqDYnTRhXIFO+qhOHN5rnNAZRKZ4A8GJrBdUNAudzIVkFM5BOgOBb+vY3c2BEVjWlT00FCZa/4oaZiAq1pL3x8+9GxMTyIZFX1d5Eo1q9Ugdof4= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=k59mmxVf; arc=fail smtp.client-ip=52.101.65.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="k59mmxVf" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jstDzqRtk1Q8J8OOimjeEadH1nAtSBeJYHGXotsZnEjMS0khoU7FHZn1zb/9QLvOOKDvpdtL+QFk2CXpblsi2LmBj7BS9y2W/UKQNaGQ1MeEjqgxTG5ecSw967rTsWZ3BVQi9r0liS0cOYVgL/g+77TPqZsZQbVPeo53R7dsrVtqX/NSKJlL1VcdOK2XelwaO81JV+u2sqzrPrQA1iXePZ69thwrb5PMvabj4TmTykjy2irND90FNEAorctey5LN2XgwrGt1UgCWiExrRczHgiOt1P+P0Rcge/be+ZvwGzI3o5HJdM5fcdp6eyfz7zUaQ3poPYR4ZKMn2x2pNueh5Q== 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=082CBnKqQey2usj2e1lYqAFijkTNNrz6CRtE3R6EVEA=; b=UtuOYFCGLtSIHv/jI3a2vatGn3Mqy2bVXTL/xzT+r0deVhaVA2FZzH7obE3hNmemsEVsYqFpcbqkC8BjjEihX9pz2V/AMqiwHFA06audJLL8gXOs+Nlm2OY4paUWzp0a6MRIFbUp8dKf2KFSi929q6qjZrkF635pMrds37bBJ7HYfwUMCG7wqCEK6utkGfa/3YjYQz5uu1Q0J+KQE6e9iS64DrNZGqDYTbMdQsnZ6HlIMO1DxT3SbnUHwuyNussSM+ya46COtnOn/pKMEGoqJK7cN+mDyh3BNQShsMrf6a2fg8Wfnavz4kdQf51YdlJ5gaV4Bh3PjJgfZKOgKR6oUw== 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=082CBnKqQey2usj2e1lYqAFijkTNNrz6CRtE3R6EVEA=; b=k59mmxVfLjtDQSsjHVlPkesDTvTcFOFHORCGDEfFJZa9xajIf8j3PFP7JAzWllujFAY9U0CGqn5z5Mj8cE0x2TmRmAFKk9br4t+2b+qvPFvwytZbszX5uaCWbwSEOXUD9fmfHm6f7Ho8whrSTWzMmcCKAGBYaeZPBOKPMP3x0HEDP9Yq0sGb2m8rvi/AmkXCAIR2Z0liJXqaZ2rB5+FUWNmSLfN0CFM23+3KdMRwW+svVGP2DQ0WMNyKS/Q8GIyaV2vIUbBlam9w/Gh32YYvIP4y373F5kIT1p9OE2VubJ8Z62q5JkZa4rf7WMfchcjhWUiDP2rC20ts4MvrR4AFXQ== 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:31:56 +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:31:56 +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 2/6] usb: phy: mxs: keep USBPHY2's clk always on Date: Fri, 26 Jul 2024 19:32:03 +0800 Message-Id: <20240726113207.3393247-2-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) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|AM8PR04MB7875:EE_ X-MS-Office365-Filtering-Correlation-Id: 5966199e-628d-4282-1d00-08dcad668e4f 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: kBYjgdiHQd8zPsL7RidDZWWXEZNEA5bFHNSNSOnkznaIiyPNele9DquJuTLbR09BhYmBY8pyRtyj1s03qzvq6Il0QoG4dxQU2CaQ9DcupbgjmB9WAH4B6Cc7/3OKNHGjMnEuj99frMUMeonZ7RvptU+cvZVslL29jkkYTcq9xwkE52hKvgScKhAtFwG6LOnEPxyaY+aYC8MeI4+P40AZw5Ro4YXYokRkus6bbG8Q8l2xqPkcg7pjSKhntAJUROI21SPHKRcG+5o5PIDZVlBk6sP2monyCk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lu4KxT6hhObI3Dmy6j4KzUQ+jyiyesHVCXePuuOqiSTA/5r1R9mqyPmro+HKnMfKonKndPLKKGehL7HxHESnzD9YgXA8gdGVVM= 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: uQ+U5UugBJrEh9MdAh6qKZbftP+7+7mEIl/Sv5UxuJaSBGGa5DPu5fYzccfVra3bH5iXMySGl2RrMqd/8BCRW92pKZo5kM5hyPNwrMYmqxKj7s4Yuc3VboE/xjXHWGtrWOA6YCWMz55e/rZTYztCNaQGHH6t4VUpLPCE5whs1VWodINi1Kg7RJP8Cev7wVlUqdd1/z3J31KWPij/tN6O448wqYN9ochH7bn9n//TeGGS87jyBSqy3aJjzS2qF+ZPBt3cMdImvVgZMvOBOl3831YrxD9+Z1TjaJQF0cOiFIQN2Lc4bqu+TO8qI/hq0dSpUg4dAOi1p7fxHyuDcRrtnSZQO6Q0wvr9lxAObH3aI9dI3lmVgB1kXwTMbTyInC+KNU2fE5vYQ2mmqmpbn/TwF4qPdhJWvVsCGtOKL7qhBQH7EXSJC4i0tkOZUOm95AND/Fkv5UrJ1ZOYJH97K2+lBOfwRXk/jgdg6d7bCtxk50CpkBg+urN/o3Y/elbmQVH7o35XIhUUtAzhFu312xe2HXrNfB5RjKZ9WDsc86cxEyJs3RTS8oBqWhO68ioU03VroGor7QqGdoQW0GgKsVReH2birNtD8kI1OYlzOG7AXukqq/Lyr44esxKMxCOTeNgdGXbR0VEtru4mgKu3XTSM6MdRhbEhCw7DLrxCsTJlbUdAS350fgimXL4fZoq6c/VpMvIqY2kcAfLNchqPpsb+7WTv8O++xZd2comMtwXcYR/RtH+ivRaqACXhExNEIgzH17SiaK2er4yfjXBow4i8EsgDYEzkJGHTYQ2oyJwTo/urTFpAWIFEDu+ucejW01QhdRATYDOA//O/g/GQkFArOBN6zXp4ShnY0RXKq9Fch6WrtWQ3W2AccZyWJXrLNLuge7EHyXFhc+cBvV+o5ystoyW8PMpY1RxJREfRFKgjS4LVH84WuQHOatMyYAWH10UU+ZWf4fP20Wk39VndfShfpELoO29x1OOERr+O+yYaK+gtqNQkl6TwDzk+jdavbXQ2XE+mVQCUXjY1+JGWBNeCejw/RWnPqSApAabe6J72hm20lfBkOnfwLbQF8K4gsPD6BklwYBBz7IYWZPfleTBAiM+kNlTJb75yOG2KwKXDSc5+wuYQ7N5D6wPKwdz2SfVSBj6ttKqSSmM/bUUNVyNSIlA++8bNIwQVWrNCnBFxd0/H7JcfNgEVZA6dn7efLVtSU4IQufEsOkza76wRqqn67frj6mbJPm09Wvl2jcVvWvesIiSZT+3UvbownCS1V9+Ss18HOG/ncQPFlExqarqvuJQ0t6qdbY8nZEy6WN9OdOcnmzPVyuqxdQn7HjcAPYoAhX5TIKBaq3S5zWzWqPTqXIOuBSuKBkgOcN2QCyokgRZ7wysLGyQI5mplMZfzsafS3ZLhi7KFr5qbleaO9TnHA7Fq43hebqClHHXNsyIxpj00u1P57W4aH/vgLycs5v+x/XAYpOeGiK+9xn6GwYHAqxrcDk4Ow8ktvH4n5qa/cCQQZXgUw2BCLfnT5+9sLw77277wKzecrwF9TElO5AV+fZZzqiaQPS6fyQpo9JXpoMKDqdW05AfCyr6rrBjlBvdz X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5966199e-628d-4282-1d00-08dcad668e4f 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:31:56.8755 (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: /EfCex7wd4fDVy6sASvCibj4xVNdAUMSZ+jOGU6gPcrQ+AS6M1MCbcWEDDbDyX41cC3oinn+PfhAdU6CEwpAFw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7875 IP require keep USBPHY2's clk always on, so USBPHY2 (PLL7) power can be controlled by suspend signal. USB remote wakeup needs resume signal be sent out as soon as possible to match USB requirements. Signed-off-by: Xu Yang Reviewed-by: Peter Chen --- Changes in v2: - modify commit message - remove hardware_control_phy2_clk --- drivers/usb/phy/phy-mxs-usb.c | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index d9d29f0b37de..e172af75f602 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -150,6 +150,15 @@ #define MXS_PHY_TX_D_CAL_MIN 79 #define MXS_PHY_TX_D_CAL_MAX 119 +/* + * At imx6q/6sl/6sx, the PHY2's clock is controlled by hardware directly, + * eg, according to PHY's suspend status. In these PHYs, we only need to + * open the clock at the initialization and close it at its shutdown routine. + * These PHYs can send resume signal without software interfere if not + * gate clock. + */ +#define MXS_PHY_HARDWARE_CONTROL_PHY2_CLK BIT(4) + struct mxs_phy_data { unsigned int flags; }; @@ -161,12 +170,14 @@ static const struct mxs_phy_data imx23_phy_data = { static const struct mxs_phy_data imx6q_phy_data = { .flags = MXS_PHY_SENDING_SOF_TOO_FAST | MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | - MXS_PHY_NEED_IP_FIX, + MXS_PHY_NEED_IP_FIX | + MXS_PHY_HARDWARE_CONTROL_PHY2_CLK, }; static const struct mxs_phy_data imx6sl_phy_data = { .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS | - MXS_PHY_NEED_IP_FIX, + MXS_PHY_NEED_IP_FIX | + MXS_PHY_HARDWARE_CONTROL_PHY2_CLK, }; static const struct mxs_phy_data vf610_phy_data = { @@ -175,7 +186,8 @@ static const struct mxs_phy_data vf610_phy_data = { }; static const struct mxs_phy_data imx6sx_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 imx6ul_phy_data = { @@ -518,12 +530,19 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend) } writel(BM_USBPHY_CTRL_CLKGATE, x->io_priv + HW_USBPHY_CTRL_SET); - clk_disable_unprepare(mxs_phy->clk); + if (!(mxs_phy->port_id == 1 && + (mxs_phy->data->flags & + MXS_PHY_HARDWARE_CONTROL_PHY2_CLK))) + clk_disable_unprepare(mxs_phy->clk); } else { mxs_phy_clock_switch_delay(); - ret = clk_prepare_enable(mxs_phy->clk); - if (ret) - return ret; + if (!(mxs_phy->port_id == 1 && + (mxs_phy->data->flags & + MXS_PHY_HARDWARE_CONTROL_PHY2_CLK))) { + ret = clk_prepare_enable(mxs_phy->clk); + if (ret) + return ret; + } writel(BM_USBPHY_CTRL_CLKGATE, x->io_priv + HW_USBPHY_CTRL_CLR); writel(0, x->io_priv + HW_USBPHY_PWD);