From patchwork Tue Jul 16 18:41:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Radhey Shyam Pandey X-Patchwork-Id: 13734766 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 01A21C3DA59 for ; Tue, 16 Jul 2024 18:41: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:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=eSUO7s9DQjjnCkkAdO8gJZI3UHnkm25mYFEn+EIARNY=; b=iXJY3Wk6PPyHUm3QUAeFPdhx8I /coB1+7RsgrD2EIl5lSSPs+NGkHeDvx8RXvo0WseMNGxOLMKhioStrAAMVQkDgSEShy90spmpn83H WAlzO7NE1nL48jU+JsBE7vJ/atohsDjpJPEJD+3rSJ7lJJuVQEENGJoht4/USVDoNOlY5TJyiwz4W 2jtlrVfqAUJDtXiWYJHl6M3PIOVylthwqKW4YVN/ykBx0pThIQCQNbawT8opJej3Fm2YqjfxzFb5H 2nyIMuDI8BbpI25vrz8l6SiBLslu5AlGHEkm0QClvwtUVueKOkhQYaYeBujgzxuYVFLHUPUvolMUC lxvVfL0A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTn7O-0000000BJMH-24Nd; Tue, 16 Jul 2024 18:41:42 +0000 Received: from mail-dm6nam11on20600.outbound.protection.outlook.com ([2a01:111:f403:2415::600] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sTn73-0000000BJFk-34ul; Tue, 16 Jul 2024 18:41:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RUwMvRmlhWRZSZVIi5Rsp8ljkNvTb5geG7V0v2scSvJly/NTLy0R2RLJbjEwifwo/dnNYayqj/ibRivI2Sc6cCDI9+Kxmyri5Po3yJimuWJcKVruvMUaKYqk8FG5lN0I21k1FNPxEM+4V+wJi9zBd+FIPDTpTJ8THuA1yVU1LDrwspjUOjZMquAkXU1W+roFatsaj7sGGCJ6WM6lkL5+XsVSDmexdx5XP6/6EtDelrexFWiTt5pKo7br4K5qF/iFITXCmG7eCNaeO2tGiPJVz+gZL1St9wHY7BViK+C1frNxBKN6XDppq2nu3KnLdwgc1+SwgO1008V0aHLkhoPDtw== 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=eSUO7s9DQjjnCkkAdO8gJZI3UHnkm25mYFEn+EIARNY=; b=a2wAGLlpRvJrVI5DxI0Gp6W7MJEPW+ZUtBz6+BAO0RHGRkD4Qk+BE3Xvyrc+Q/1xFs869cgKu50lBxbEGe9g68MicBccNbXGN7GBGGpXaFFoS7pkfY7vsYQosjmrh6nfM41b3hCtarUHnNFMslKZSwmzqBOoS0JxychM6UdLi4sQU677bC2G3wlViG5pYPkbmNMWNZ+bs48UwwfNcnegyrZez6EyR4AUcr5l0Eqo9FPxZPuiTa1O5BhVsI4thS0Uwo47mMD6AaMMoDDlF9OTtOt2hvLXM5BVpD3aCELMXdWD0pI6j3el18XTGpCAz1Qb0NEslV3iZ3R6Zs3H00Cm7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=ideasonboard.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eSUO7s9DQjjnCkkAdO8gJZI3UHnkm25mYFEn+EIARNY=; b=TACzYWmYDFuXFbra0J4GwBmKDbpzQWL+yo5dIJ6by8mhAhdg/zT8hBEDBVwIZLoZGR1QHVTQS3yv84co+X2+GOPuCpYVrvgUTXBx6kbHAJhGiRwN0tlPq8lWYJ/q1BS6QGTclQaNxTV37dU5ThIQo1gTvJ3PR2ehgQBCeaB0RXA= Received: from BN8PR16CA0017.namprd16.prod.outlook.com (2603:10b6:408:4c::30) by CY8PR12MB8196.namprd12.prod.outlook.com (2603:10b6:930:78::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28; Tue, 16 Jul 2024 18:41:07 +0000 Received: from BN1PEPF00006002.namprd05.prod.outlook.com (2603:10b6:408:4c:cafe::97) by BN8PR16CA0017.outlook.office365.com (2603:10b6:408:4c::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7762.28 via Frontend Transport; Tue, 16 Jul 2024 18:41:07 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by BN1PEPF00006002.mail.protection.outlook.com (10.167.243.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7784.11 via Frontend Transport; Tue, 16 Jul 2024 18:41:07 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 13:41:06 -0500 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 16 Jul 2024 13:41:06 -0500 Received: from xhdradheys41.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 16 Jul 2024 13:41:04 -0500 From: Radhey Shyam Pandey To: , , , CC: , , , Subject: [PATCH] phy: xilinx: phy-zynqmp: Fix SGMII linkup failure on resume Date: Wed, 17 Jul 2024 00:11:03 +0530 Message-ID: <1721155263-2913528-1-git-send-email-radhey.shyam.pandey@amd.com> X-Mailer: git-send-email 2.1.1 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN1PEPF00006002:EE_|CY8PR12MB8196:EE_ X-MS-Office365-Filtering-Correlation-Id: f637a920-0914-4511-2c5d-08dca5c6dae4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: T27hA39sdMTDyeFiIN27a2H4xuub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/9X/INLO8ty7HWBCPKdtm3UaeqSf96Xre1uHf5MrUgSpViM2qIG4TcA0f28sxCkDVLHjP0FwKr1jYyNsnbIQj5rAmhyyJ/eivxN+qO5SN4S3orvt3ZSjRPAit+nz5YP2lwY3hT/fSOMSYSgVgJ9nLzoeXgzD+SHCrBi3kKE14/PG5KKvfT6Mk9GzF44+N8kvesifkT1YXe4ZQj2mcJhgDnl7mLYoOvVyW5pQ3ghuQfSaa3C6QzSJ7AzVy+ByGUAavLBC4URS9Bz+CuPa2odnWa/f31gCRfsiM6Yx5sbVlbLWJw/nl6SFkuYw4ITSRj1jYds3ur5uB0IToJS08zcQeXILJ4GAP3cKkkF11FVNoyLEQ9qLBZb X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2024 18:41:07.3637 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f637a920-0914-4511-2c5d-08dca5c6dae4 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN1PEPF00006002.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8196 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240716_114121_851041_6C65324E X-CRM114-Status: GOOD ( 16.36 ) 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 From: Piyush Mehta On a few Kria KR260 Robotics Starter Kit the PS-GEM SGMII linkup is not happening after the resume. This is because serdes registers are reset when FPD is off (in suspend state) and needs to be reprogrammed in the resume path with the same default initialization as done in the first stage bootloader psu_init routine. To address the failure introduce a set of serdes registers to be saved in the suspend path and then restore it on resume. Signed-off-by: Piyush Mehta Signed-off-by: Radhey Shyam Pandey --- drivers/phy/xilinx/phy-zynqmp.c | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) base-commit: d67978318827d06f1c0fa4c31343a279e9df6fde diff --git a/drivers/phy/xilinx/phy-zynqmp.c b/drivers/phy/xilinx/phy-zynqmp.c index dc8319bda43d..bdcc8d7c3dfa 100644 --- a/drivers/phy/xilinx/phy-zynqmp.c +++ b/drivers/phy/xilinx/phy-zynqmp.c @@ -165,6 +165,24 @@ /* Timeout values */ #define TIMEOUT_US 1000 +/* Lane 0/1/2/3 offset */ +#define DIG_8(n) ((0x4000 * (n)) + 0x1074) +#define ILL13(n) ((0x4000 * (n)) + 0x1994) +#define DIG_10(n) ((0x4000 * (n)) + 0x107C) +#define RST_DLY(n) ((0x4000 * (n)) + 0x19A4) +#define BYP_15(n) ((0x4000 * (n)) + 0x1038) +#define BYP_12(n) ((0x4000 * (n)) + 0x102C) +#define MISC3(n) ((0x4000 * (n)) + 0x19AC) +#define EQ11(n) ((0x4000 * (n)) + 0x1978) + +static u32 save_reg_address[] = { + /* Lane 0/1/2/3 Register */ + DIG_8(0), ILL13(0), DIG_10(0), RST_DLY(0), BYP_15(0), BYP_12(0), MISC3(0), EQ11(0), + DIG_8(1), ILL13(1), DIG_10(1), RST_DLY(1), BYP_15(1), BYP_12(1), MISC3(1), EQ11(1), + DIG_8(2), ILL13(2), DIG_10(2), RST_DLY(2), BYP_15(2), BYP_12(2), MISC3(2), EQ11(2), + DIG_8(3), ILL13(3), DIG_10(3), RST_DLY(3), BYP_15(3), BYP_12(3), MISC3(3), EQ11(3), +}; + struct xpsgtr_dev; /** @@ -213,6 +231,7 @@ struct xpsgtr_phy { * @tx_term_fix: fix for GT issue * @saved_icm_cfg0: stored value of ICM CFG0 register * @saved_icm_cfg1: stored value of ICM CFG1 register + * @saved_regs: registers to be saved/restored during suspend/resume */ struct xpsgtr_dev { struct device *dev; @@ -225,6 +244,7 @@ struct xpsgtr_dev { bool tx_term_fix; unsigned int saved_icm_cfg0; unsigned int saved_icm_cfg1; + u32 *saved_regs; }; /* @@ -298,6 +318,32 @@ static inline void xpsgtr_clr_set_phy(struct xpsgtr_phy *gtr_phy, writel((readl(addr) & ~clr) | set, addr); } +/** + * xpsgtr_save_lane_regs - Saves registers on suspend + * @gtr_dev: pointer to phy controller context structure + */ +static void xpsgtr_save_lane_regs(struct xpsgtr_dev *gtr_dev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(save_reg_address); i++) + gtr_dev->saved_regs[i] = xpsgtr_read(gtr_dev, + save_reg_address[i]); +} + +/** + * xpsgtr_restore_lane_regs - Restores registers on resume + * @gtr_dev: pointer to phy controller context structure + */ +static void xpsgtr_restore_lane_regs(struct xpsgtr_dev *gtr_dev) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(save_reg_address); i++) + xpsgtr_write(gtr_dev, save_reg_address[i], + gtr_dev->saved_regs[i]); +} + /* * Hardware Configuration */ @@ -837,6 +883,8 @@ static int xpsgtr_runtime_suspend(struct device *dev) gtr_dev->saved_icm_cfg0 = xpsgtr_read(gtr_dev, ICM_CFG0); gtr_dev->saved_icm_cfg1 = xpsgtr_read(gtr_dev, ICM_CFG1); + xpsgtr_save_lane_regs(gtr_dev); + return 0; } @@ -847,6 +895,8 @@ static int xpsgtr_runtime_resume(struct device *dev) unsigned int i; bool skip_phy_init; + xpsgtr_restore_lane_regs(gtr_dev); + icm_cfg0 = xpsgtr_read(gtr_dev, ICM_CFG0); icm_cfg1 = xpsgtr_read(gtr_dev, ICM_CFG1); @@ -992,6 +1042,12 @@ static int xpsgtr_probe(struct platform_device *pdev) return ret; } + gtr_dev->saved_regs = devm_kmalloc(gtr_dev->dev, + sizeof(save_reg_address), + GFP_KERNEL); + if (!gtr_dev->saved_regs) + return -ENOMEM; + return 0; }