From patchwork Wed Dec 6 09:31:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872511 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Z7/hcXFv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXHH1bs7z1ySd for ; Wed, 6 Dec 2023 20:32:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CC95886EEE; Wed, 6 Dec 2023 10:32:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Z7/hcXFv"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6325086FB0; Wed, 6 Dec 2023 10:32:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::61c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8E53486CF4 for ; Wed, 6 Dec 2023 10:32:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q75+0/zoy8Fi/dbbTYCnBIKEKmGXBFy4nMfhgZGJTpnE/JvER8JUnETsZKv1d0hRZdHAHaOjtEugsMzzclvHKk5/9/hQQmEc0A/F0dnOQQNIbRUw0ZlygyHGR8ElCf5m3vefQNwnG2KSgyQBT5NxSC13oi8dpNvbtDHxeY7po8ASbOgGwj/fFQOMg/Kf9p5XwM4Ojd+oJyHEU1VXUC3KJQxflrtiNiqslwJaJ2WYfOHgNyt7XEolUduRELxjRCH5si48I3F+KcRSZkd7hoEDY1+rmGCAaESg0rZISrBEvV7ruVAgXoJ2rtl1rOPf/z0wd180yLGMV7hN+RdoQ+WQ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=hQktOBXApMvtN7i7URHWTj6cOCmsb+sM4fC+LzSSDqY=; b=iXpmBy6aYyCUmxeM08OrCtbwwjXb5cp6VVgi4KuTQd0CrYLtgCcL+0XRIK70vjwJZ+5N39oGhBeREttezfEuRAEQ+WgMSz8QOIwQK5SFrNVb+WuUi+mIuL0bmpsnChGZhhPAvARIVtruonHK+TXkMXAUC8U0vZrdMtqPQCNTGUCtyy09wB87yb+AmOxHlGRw/x9RHwOstnDkzrSQKagRZNYldLi/UtBAWjEdZxun1t97ZsHSczg9wVVMysj0CufVGbbf1/IIL8sX5PXkuNs0b/4ug6jCeaLqda3a95bDp1v3aQlA9r6CnRVOS9TaykIHvBdEGSgNtmt/BpgtmH/fFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=hQktOBXApMvtN7i7URHWTj6cOCmsb+sM4fC+LzSSDqY=; b=Z7/hcXFvluknIhlCE1S/FRAZCyxTqIETENK0tLjzV41bdDpM1a7AlIOULhsOPWmhSj1x159sr+ZyFuEkTwmGx4WTzC/54q4yyKetXtGQ0T/JLmT+ouRCBdMgkhVR+InWRKocxbxF4bHDRQP4K/QUUez3FV6m31yl+2YcaUTbDjs= Received: from BLAPR03CA0014.namprd03.prod.outlook.com (2603:10b6:208:32b::19) by MN0PR12MB6149.namprd12.prod.outlook.com (2603:10b6:208:3c7::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:31:59 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::a2) by BLAPR03CA0014.outlook.office365.com (2603:10b6:208:32b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.22 via Frontend Transport; Wed, 6 Dec 2023 09:31:59 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:31:59 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:31:58 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:31:58 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:31:56 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH v2 01/30] mtd: spi-nor: Add config to enable flash DTR Date: Wed, 6 Dec 2023 15:01:12 +0530 Message-ID: <86732ea5dfb703525e50bfbfbdeea188832611c1.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB59:EE_|MN0PR12MB6149:EE_ X-MS-Office365-Filtering-Correlation-Id: ae1fa56b-5736-4f9d-5233-08dbf63e320c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u+kENnNhsYGA11wG1STo8/IPe8z4NrQuIMIvJRr38iev2MO0l87d63zHC+HM3sUGeNDOSMsCuXhG++BqH4q6IaZEhAv1gmlzHbcND+LU0s9+BaSG48BG+g2ictJeykNE3zMiUYS6gMsXLpFKVV/E9aU6hPB/VMQzxBEH1p3Uar4DvtqagkAsiqkVslmWeI1LYqSYGNlNy1OaUZ/BLcAmf6SsVfB66pXSncclwKXLnYfGqbu20DTKKnmvvTmi0WXcUTmdHlXgdhrFDgBnpqTU9o9hj6w4jvPFGK1R24Vb8xvbACeHV9nhbxeuDwlqFGDYJbl9V9gTtRrXcDE7qJYbarc1frSPhi5jYq2sUTbcXm0QNb9F9tldHo3XDjx5JwSzplh6CkSVj64ylw1Fcuqb3Uh7Rhomlvrs6og2ACpaQiSy+x62zB/d+z9frvlM0gTXT9HFJexGa6oqQYcD6FHeZl/jtZhns8l/WAuHFwntYUUjkAWGxEaz81mCQhdqEyDrFOC3XT7M0TwL0DSkH4xSadsTL+VB8yvoJzb46E8gwwHN0fHg+ZLc5JOeXh2ugJ1r/XiKobtlor5mSgHTmH2VFoLHZ41XARtGIdbX5pSLJGiT0N22XhU56gSFgDro1fMNTZiF8BVYi00mgchIyWZtcBC4qHfx0Yjqkx+/TV0V3/x6cvCLJAzI9qgYZRDp4DT3mI7pi8Xq6AxOZwmyLPrd1u4i32m/NoysAbGa7gy3/gHcWvIICYryrvb+Re20iLGwxd6BppCHOL1SguPqBK5DMA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(136003)(346002)(376002)(230922051799003)(82310400011)(64100799003)(1800799012)(451199024)(186009)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(36860700001)(47076005)(81166007)(356005)(2906002)(5660300002)(82740400003)(83380400001)(336012)(426003)(6666004)(26005)(2616005)(70586007)(70206006)(478600001)(36756003)(41300700001)(54906003)(6916009)(4326008)(316002)(8676002)(86362001)(8936002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:31:59.0818 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae1fa56b-5736-4f9d-5233-08dbf63e320c 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6149 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy The spi-nor framework will set up the flash parameters by reading the flash id table flags, which include cmd opcodes, address width, dummy bytes, and bus width. In case, flash supports octal DTR mode and the controller does not support the DTR. There is no process to switch back to SDR mode. To avoid this issue, create a Kconfig option SPI_FLASH_DTR_ENABLE to explicitly specify to enable/disable flash DTR support. This config is disabled by default. Do not initialize the mt35xu512aba post sfdp fixups unless SPI_FLASH_DTR_ENABLE is enabled to avoid configuring DTR. Signed-off-by: T Karthik Reddy Co-developed-by: Tejas Bhumkar Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/Kconfig | 7 +++++++ drivers/mtd/spi/spi-nor-core.c | 12 +++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/spi/Kconfig b/drivers/mtd/spi/Kconfig index 732b076045..e0898074a2 100644 --- a/drivers/mtd/spi/Kconfig +++ b/drivers/mtd/spi/Kconfig @@ -202,6 +202,13 @@ config SPI_FLASH_MT35XU because the fixup hooks for this flash add extra size overhead. Boards that don't use the flash can disable this to save space. +config SPI_FLASH_DTR_ENABLE + bool "Enable Flash DTR support" + help + Select this config to enable DTR mode by spi-nor framework. + This config provides an option to explicitly enable/disable the DTR + support even though the flash id flags specify flash supports DTR mode. + config SPI_FLASH_SST bool "SST SPI flash support" help diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 5c3ffc80eb..473d9f41f3 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -2962,7 +2962,8 @@ static int spi_nor_init_params(struct spi_nor *nor, SNOR_PROTO_1_1_8); } - if (info->flags & SPI_NOR_OCTAL_DTR_READ) { + if (CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE) && + info->flags & SPI_NOR_OCTAL_DTR_READ) { params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8_8_8_DTR], 0, 20, SPINOR_OP_READ_FAST, @@ -2978,8 +2979,10 @@ static int spi_nor_init_params(struct spi_nor *nor, * Since xSPI Page Program opcode is backward compatible with * Legacy SPI, use Legacy SPI opcode there as well. */ - spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_8_8_8_DTR], - SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); + if (CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE)) { + spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_8_8_8_DTR], + SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); + } if (info->flags & SPI_NOR_QUAD_READ) { params->hwcaps.mask |= SNOR_HWCAPS_PP_1_1_4; @@ -4011,6 +4014,9 @@ static void mt35xu512aba_default_init(struct spi_nor *nor) static void mt35xu512aba_post_sfdp_fixup(struct spi_nor *nor, struct spi_nor_flash_parameter *params) { + if (!CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE)) + return; + /* Set the Fast Read settings. */ params->hwcaps.mask |= SNOR_HWCAPS_READ_8_8_8_DTR; spi_nor_set_read_settings(¶ms->reads[SNOR_CMD_READ_8_8_8_DTR], From patchwork Wed Dec 6 09:31:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872513 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=ot3H/0C3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXHd5NMBz1ySd for ; Wed, 6 Dec 2023 20:32:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C6F8886F64; Wed, 6 Dec 2023 10:32:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="ot3H/0C3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C3928756E; Wed, 6 Dec 2023 10:32:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::611]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E454786F64 for ; Wed, 6 Dec 2023 10:32:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QQY/iK13M9SI+Nix8/y4feVSXzF3P0I9CcduP/fTuT6Dac57eXioXhouZ+zsXQbqBw+cAi5U1VvrITwavo7s++lu9GSaZtSnXaWil1q+k/Y4i8yOG6sUO6UUBPl0Vvyj4g73dhrgZc17bJcvZomXeNJ2+u1WF/nFAE+Tj5QP+UsWSYc9JrLZa/fXV6xk86pR1rxeOr7QaUVXo0NJ4U5eID2f6IluFixvlSdmjUfqa28Joxko0bRpzcNdD5hlFQggKNJhuPdHy0UlkqVWxNLXZCn+Gsh615oWHLka3lKU7YTyiZZ09zn+G3hxGGGYKaIgyeLGy3OoEhfK7Lhfe6F5xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FTMxzbWUFvz0qsB7IkJnou34n9auXirQqy5KtfSlb0w=; b=Axx1qW729cJLCgZTe+W1P2REuIzx5C8IVp60sbT8kUzcfyHqygAzzwEOAKfpIWGgQ3HN0T5bH4BbnMHpYxqI6Zt+O3+H054ehHLyo+wzhI6HeMrYRzPyUyEq2vsd7FDCJOnTE7BStmoWgHFmpdQpeaONxpYXs7HY8eWs2LswG5ylnLP6Mzyq7LYok/yegWP3GXXUsPv06cKzIMu4nrOAR/rupU3XX3Y6j28URI78S/EFMwwjbnsRsXIMzms+WcgW0ZS2n/8RFfJkvA0tbMvHgU0mBylM3jeDSc/TZhvIC2bpkZreqZPf+42agkD0iczdq1/EN/pHLC2hUKtA+oGlMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=FTMxzbWUFvz0qsB7IkJnou34n9auXirQqy5KtfSlb0w=; b=ot3H/0C38p9EEuydAbnRS6RS5Pir96CRHBKBNxH7fIm5DVtUVXELoe8jJIbMfRukQRA3WnOH/cvlMtQNXbebhKN3naMrRdgewch+XXIcS4HN+9tTSw9CkhNSTr5bwxwGfoJdO+vIbirv0Nkl6p/h6NMsf6FO/C1V0tN51mZAsFw= Received: from BL1PR13CA0391.namprd13.prod.outlook.com (2603:10b6:208:2c2::6) by MN2PR12MB4206.namprd12.prod.outlook.com (2603:10b6:208:1d5::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.36; Wed, 6 Dec 2023 09:32:05 +0000 Received: from BL6PEPF0001AB54.namprd02.prod.outlook.com (2603:10b6:208:2c2:cafe::ea) by BL1PR13CA0391.outlook.office365.com (2603:10b6:208:2c2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.24 via Frontend Transport; Wed, 6 Dec 2023 09:32:05 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB54.mail.protection.outlook.com (10.167.241.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:05 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:01 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:32:01 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:31:58 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Ashok Reddy Soma Subject: [PATCH v2 02/30] mtd: spi-nor-core: Set dummy buswidth equal to data buswidth Date: Wed, 6 Dec 2023 15:01:13 +0530 Message-ID: <50ce979f7ac4859e36ae17b4a168f79fb1e2dc34.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB54:EE_|MN2PR12MB4206:EE_ X-MS-Office365-Filtering-Correlation-Id: 11fc2f8f-8321-4de1-ce49-08dbf63e35c1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: klOc2rZQaaqO/0laBiafkTxauxlftB1QBbb6HxzE0wwFGAXdZdeoUx9Us0NEPwIeo1KhJ4lV5c0H8DoXhbEhh2xkmHsAhYKmhfdQ6oj9DLhWxKv4aGTz1WbR0kM2YBtKTHourCMFTDXR+PrgYVo5foKtEo6e76tj/m1LoG3Lzu/lIkAHl2WGwi3pdbtwAw18qeyTIq2bMnr5ql5uFdnWOUkxxS6ugUL7b+CxdwvOnt0E5Dy3hnkiG5kD/s+pt31XFdHC5rq40vbe+EGUSOhmYPp0r3zlHjBpVF+W4S4W0SK/cgbW10x3zElMNrdNx5PoDQQbPAUYJiRdYW0GzzfeWQ1U872kv/e3Ry8no2BkfQ6dND91OfM55G8wh9M4e4DH1r9eze0DpkI2ATAIQGWv/uo2PH1LNY4yeHHA49i3td1v/sAHlWugM/xED+yV6e9aT4g//A9ULRp+qOe/TocmbBja3OHCqCU4C5LR8eDHwbf5NyuwQVxTFHCJI8z8U9j11srPE262paoUovXjZxPAWyyNRYhn+PM0NOv8Nrv4JdmrOXmsRupPNNKvq7Amrwwde+CCdCIQEfVqyQmBzhACQwD2YGAeMvECXjBOxDOAiH4I0Z88ni+eTIdzLe5K+jzv/dth3AltGxF87K8kU+3V92SeHPHl1zi6F46hWDb3aYhR/yTqKGfYIq+9wwO5HWNshZZFUfSk5le79heM7Z2o2IzLuCa2UORtFqvOuKfCG6+mHiOA6c73y9XhqGYGdX2gXzqElBSyEs7thc0VYekgxg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(36840700001)(40470700004)(46966006)(70586007)(70206006)(36860700001)(356005)(83380400001)(82740400003)(426003)(336012)(26005)(2616005)(6666004)(478600001)(316002)(6916009)(54906003)(86362001)(8676002)(4326008)(8936002)(5660300002)(2906002)(40480700001)(36756003)(41300700001)(47076005)(81166007)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:05.2574 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11fc2f8f-8321-4de1-ce49-08dbf63e35c1 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB54.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4206 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy In current implementation dummy buswidth is set equal to address buswidth. In case of quad spi (mode 1-1-4), where address width is 1 the dummy bytes will be calculated to 1(8 dummy cycles) and dummy buswidth is set to 1. Due to this, the controller driver will introduce 8 dummy cycles on data line(D0) during read operation. But since we are using 4 data lines in case of qspi, we need to change this dummy bus width to 4. This will make dummy bytes to 4 inplace of 1. This will be taken care in controller driver by dividing with dummy buswidth again as in below code, which makes dummy cycles to 8 as earlier. dummy_cycles = op->dummy.nbytes * 8 / op->dummy.buswidth; So with this change dummy cycles will be on all data lines(D0-D3) and it is taken care for all the configurations(single, dual, quad and octal). Signed-off-by: Ashok Reddy Soma Signed-off-by: T Karthik Reddy Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 473d9f41f3..8949dab548 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -260,7 +260,7 @@ void spi_nor_setup_op(const struct spi_nor *nor, op->addr.buswidth = spi_nor_get_protocol_addr_nbits(proto); if (op->dummy.nbytes) - op->dummy.buswidth = spi_nor_get_protocol_addr_nbits(proto); + op->dummy.buswidth = spi_nor_get_protocol_data_nbits(proto); if (op->data.nbytes) op->data.buswidth = spi_nor_get_protocol_data_nbits(proto); From patchwork Wed Dec 6 09:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872514 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=GuUofXxB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXHr3VFsz1ySd for ; Wed, 6 Dec 2023 20:32:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38FA78764D; Wed, 6 Dec 2023 10:32:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="GuUofXxB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABAB887630; Wed, 6 Dec 2023 10:32:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20630.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e83::630]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 723F18753C for ; Wed, 6 Dec 2023 10:32:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UORcoJsfvndfy8SMmiEPAcfgprHf0SmqksRODoAPahXxd3XoBISvt0rL6u2yAPpjwP0XWhNzAx0Ek0ilMVVkJSzg0Ra9argSFJ4gp4gguDOpnNwg56/4O8aDIxDkpId8jdWiMTsfwafN4RrbXjPNS7JAX8tfge9MeBrwLfjLdWSiCU97HhqdNLNGuSpREF4bT6QURIcam9x9hvFjhihxGzpiAjyyVTAJLmCHKp7dAf5MPzQS1Am67SR+1bTCb0neoitB9f9Sas4j+Tgpi+SmRqpWCp4WrrrDjWPimhEUeGCmZdc4UtrmyDO7zo/azt6r6h269E1WA57v/ksjjjgv1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=U3EQGPJlUUXN1TmTgPut+mR6jFDIQNHbaVZtkjbqmqw=; b=n6Ja81qPTH2gBTS0EMwtnz0CXPy77UJueI0gn2/5qlLzdsTAdmlX6gYEsxyk3RN+s7povPuj2VGi35Zh3ADq1/8swue2uaeRv1B0kd9nADFRy3dR6R80LwZ/65hebLBu6qQ+2hPXRmRqTz9Xnx+oHlyUlg8mbItRmMKj7lt8mRQHQI2xQWwIY9YV9A7UWP+Vci3ER80E9hitSOlBHmgWyo10+1teN87MKYngNHbZrj5vGOA+mn4FUkO6FbzjWkLOJHfxrAknU4UcUI+LiiunBgQreYnes+SxnblsgpxdNYWeICyWNV7xKHGXkgNzQCTOGW7LjFH+3LDypr/dh/CkSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=U3EQGPJlUUXN1TmTgPut+mR6jFDIQNHbaVZtkjbqmqw=; b=GuUofXxB+kGHOFJlaABCl+/nzVXOD9oWjwWM3qGFLqSnM69LEAiRS0CFaTu/sVEjJaeSMoBR+hPeEYYRun5tz2zzuNV+oIJKCjBx3LXjDkQ/+5oMWj2TN/VtviSOnE2Lt52AF+j9tBo0qLHfrtWu64MpuwKAXfc9h3haz+irEsY= Received: from DM6PR18CA0007.namprd18.prod.outlook.com (2603:10b6:5:15b::20) by MN0PR12MB6294.namprd12.prod.outlook.com (2603:10b6:208:3c1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.22; Wed, 6 Dec 2023 09:32:11 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::7e) by DM6PR18CA0007.outlook.office365.com (2603:10b6:5:15b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:32:11 +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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.34; Wed, 6 Dec 2023 03:32:04 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:32:03 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:01 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH v2 03/30] arm64: versal: Enable defconfig for Micron octal flashes Date: Wed, 6 Dec 2023 15:01:14 +0530 Message-ID: <338f4590131b94517c49b26190499e3cda7a8f7e.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|MN0PR12MB6294:EE_ X-MS-Office365-Filtering-Correlation-Id: 59b3fe3c-37bb-4bab-cd4a-08dbf63e3952 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cpzGEQ2ZXwRLKySqd1bL6hsQoCiWapo174fFQbPgbqhV4CKIJXDCzN+jyFHH76ummmduB0FcvqdgN3Li3V47gEqyfvI7A++UEuIQFk4jO3vJ962e7c9XUDWzzUbmKOd8uJ7BPu+kMJzKNge8IqhEfsD6BZdUiKHnViRL1bV0VuZam3402VaveknY5rZpAUm6TFCyHSbOLrfwxRiXuGKwbAqpH5vzTeBDIBljswrWGfYjD4qwNB2/xuV97Hc+0zzx21qDm0kYCDI4QQ4zbU/9Of8VDTOmpHXxK5uJGhccqt3Oc5SbtdRbkB8AmpqX7Tml+PDLlmRAu+fHJI/ab/5bZOcjm22QNe4lc4pk437lyVHhAAuWpD5aWH+bq7Vl1Pc5xYJ5Jkejk+dfrvBkoMcui+Fi5lE7NCeclILYRqmul7jFOXLmBbioLY2mgijI12ArLUw7bHZfxDrMaf9HuSwtBWSnPkjyH89hjjJY7Bqu131tYXbe3Bor5k3MKbDvxMx7qNb4kqZIWitmZoa2eFduzVJ0+f0dHjSabMR+A9vjarAf/INuuKLj09CMQH9gKWUgyrZKkusdM9F9/QiseMVrLzh9Yzf4dLe+Th1uTWf9yVgDUFWbImauZPlniwxUegHjYqRQzEMf16K1PS1n7jIvhI9phsuWm2YAVH3k6i4gDwo3fKBeFlZUORFPjiqegBNlnk/yW1PpggsTZsY5Hk3Vxx0IvFFD4hbEiXqHbwrXmKZcxnZQO8eXX/Pc3qOVvwWgmlysGdJbOGfEMHLnVfQ1nA== 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:(13230031)(4636009)(346002)(376002)(396003)(136003)(39860400002)(230922051799003)(451199024)(186009)(1800799012)(82310400011)(64100799003)(46966006)(40470700004)(36840700001)(81166007)(83380400001)(40460700003)(356005)(47076005)(2906002)(5660300002)(26005)(2616005)(107886003)(54906003)(86362001)(70586007)(6916009)(8936002)(4326008)(70206006)(8676002)(6666004)(478600001)(316002)(4744005)(41300700001)(336012)(426003)(36860700001)(36756003)(82740400003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:11.1783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59b3fe3c-37bb-4bab-cd4a-08dbf63e3952 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6294 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The Micron MT35 series octal flashes can be activated through the configuration option CONFIG_SPI_FLASH_MT35XU. To ensure their detection, enable this option in the default defconfig for octal flashes. Signed-off-by: Tejas Bhumkar --- configs/xilinx_versal_virt_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index 6a2c03ccdd..ec7caacca0 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -95,6 +95,7 @@ CONFIG_MMC_SDHCI_ZYNQ=y CONFIG_ZYNQ_SDHCI_MIN_FREQ=100000 CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_MT35XU=y CONFIG_SPI_FLASH_GIGADEVICE=y CONFIG_SPI_FLASH_ISSI=y CONFIG_SPI_FLASH_MACRONIX=y From patchwork Wed Dec 6 09:31:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872515 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=qCC4Ogby; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXJ26WK5z1ySd for ; Wed, 6 Dec 2023 20:32:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9D63487654; Wed, 6 Dec 2023 10:32:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="qCC4Ogby"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 17C378764D; Wed, 6 Dec 2023 10:32:20 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::629]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0E8CF875EE for ; Wed, 6 Dec 2023 10:32:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhzaSXjUoSWuERxAKgwYHESq1glSvIZgWpy1+1CwCrbtONhCEZFOc+bGsEEbw9SKaaKnmRdoSrJgRLFPU0xoPrtmI4KiMXc4+JVl4z6lOLNgkjYAYWsoXSL/JgalG/Z+S5snWoowbzQH6mnYVMt3gkDrVQoaR9mR7SGlzuZLrrPkghiFmIYmoyhXDm+Q+xTjJdlPwcELJJ+pwW7P2OSmwf+3EMNw0U4vzda8gkekkDrSxL9etxywBdE9/MNl053Div1yWx/PaFvEmU2aSqKLE30ZW4JXPlZdp8PsrNJPI+weJHlMHfIFNBRU3Csaya4my/Y2IZg/SEAoz/y2HWSm3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=4oPu4QdFFbrQ6wLibqYplciXx9ZJAiJ9KGQEtt6qPS8=; b=Q0ZDxMf4JtnNPWMYuUH4tBjKn/TtYjA+yN7c1uaFGIDQK+W3KSvK1ZXUmvLr/hTiQYiXftwfkjw5MwnyQc14PyECvUYXLETBtDz6sKnrb5oaXBr3XHaD2adaq2l2Vizek6I5ZM2WfOnLGPFZSW5t/o7ztj6YSp1glW/cV9fFK6UNYPjtFm0FHujEZ+E0+oxDfdunP6bcM+YS4/2fLHlChCoZNTo4aol9xXhs3lHYhabgge2qDUWezkeHIaqmaOVneEzuB4e25ysmyvwd9Es1mBHh2mOkbROcmXWtqaCww2UY6suK1tm87iA0kNOVu/moK3gPzgBaX5o+Q6FKnwAq4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=4oPu4QdFFbrQ6wLibqYplciXx9ZJAiJ9KGQEtt6qPS8=; b=qCC4Ogbyfj8SCTFi1KP9gEZp4i+izT5zqU98McePIIEktX/lYKnmwWOPxFKUqn6SV001N+OXtlWx2ojIAbPo8Zr1/xEq7YgYlQAHk25cx1gxIYpQtWPCsD8oBs2pRmwIW9cJzbKusWTF8re6l8W6Nym/FspBUeRM+PLCf5yoD+M= Received: from DM6PR18CA0011.namprd18.prod.outlook.com (2603:10b6:5:15b::24) by MW4PR12MB7000.namprd12.prod.outlook.com (2603:10b6:303:20a::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:32:12 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::b) by DM6PR18CA0011.outlook.office365.com (2603:10b6:5:15b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33 via Frontend Transport; Wed, 6 Dec 2023 09:32:12 +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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:11 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.34; Wed, 6 Dec 2023 03:32:06 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:32:06 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:04 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 04/30] mtd: spi-nor: Enable mt35xu512aba_fixups for all mt35xx flashes Date: Wed, 6 Dec 2023 15:01:15 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|MW4PR12MB7000:EE_ X-MS-Office365-Filtering-Correlation-Id: 6aec1c28-031f-42a2-2b29-08dbf63e39b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zyDn/NWJh/wR5avmp3wSC1h2Br4n5R4r05IycYDw6AL+Z6SB2FPbGHU+aTaFrOZNDHvzuV5NTbr8YYDGjCfz6wZxlxP6RZ1EabwW7LAsue/Iafg00MTN9nRiLWGpHTaMKu0QzLEIlhWEDXbBmRijgZNQoR0KDUK/3juDwPwfj/4/uHOFNDHTXImKG1JeKTaa2+4pXbyCSkWcyekP+Boq+l5ZDWsA1EQsjyzkBUgY4ubxVQ6unGxkSgc0oZ6HkVi4GgBnnpktO7ZC8pnD6MXj1NY79N82O1wvxNNItlde9yuE+DyTOtI1i1OLV+xQy/y5T0tlm0XLkpQaBKy0tOuE6yKhBYM3htK92RzNi+YWiOLzFJdPZLcyCtQxVmoSgIBRnCtek7lxbuy5u98OnYb2GeTRBw+/W5MYKhQKAqv18SbRAa2KqopSXbxMh6HCVGy9J+Ikq634lVOIK0CgxGNQOxFdnuEpqR1a53RtMzUPt5UTKtmidnRntd4CoJwndDH/W0z7qjf89pGfYbOgrK3sDQ5HpJON0vb4wb0wFLDe4kcl6+nUBcjlcK9AzkdgmrbKEVhH9mYpQqzVfKO45jBODQ7kQiIbPwnk4jITs8zwKVMi5DYg8qtPb9uKpXy8IC+Ww50nh/5eYVbN7i6N0P53JtwrqgMJuAb2tvjSUCCT/Rq7ggdVjknYo7JgQ4fF4bmfiu+xlKwqDFp2F1KYr0eSGi+cbYRhcMB+xOwBilfY1Yj4o8Xa4TwH9NINdVPbRCS9mirywEym6leji0By2NGj8A== 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:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(36840700001)(40470700004)(46966006)(70586007)(70206006)(36860700001)(356005)(83380400001)(82740400003)(426003)(336012)(26005)(2616005)(6666004)(478600001)(316002)(6916009)(54906003)(86362001)(8676002)(4326008)(8936002)(5660300002)(2906002)(40480700001)(36756003)(41300700001)(47076005)(81166007)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:11.8190 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6aec1c28-031f-42a2-2b29-08dbf63e39b2 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7000 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Enable mt35xu512aba_fixups for all mt35 series flashes to work in DTR mode, and return after nor->fixups is updated, otherwise it will get overwritten with macronix_octal_fixups. This flash works in DTR mode only if CONFIG_SPI_FLASH_MT35XU is enabled and SPI_NOR_OCTAL_DTR_READ flag is set in id table. Additionally, a new flag, "SPI_XFER_SET_DDR," has been introduced to instruct the Ospi controller driver to switch to DDR mode. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 8 +++++++- include/spi.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 8949dab548..e505648e5d 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -3991,6 +3991,7 @@ static int spi_nor_micron_octal_dtr_enable(struct spi_nor *nor) if (ret) return ret; + nor->spi->flags |= SPI_XFER_SET_DDR; buf = SPINOR_MT_OCT_DTR; op = (struct spi_mem_op) SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_MT_WR_ANY_REG, 1), @@ -4305,8 +4306,13 @@ void spi_nor_set_fixups(struct spi_nor *nor) #endif #ifdef CONFIG_SPI_FLASH_MT35XU - if (!strcmp(nor->info->name, "mt35xu512aba")) + if (!strcmp(nor->info->name, "mt35xu512aba") || + !strcmp(nor->info->name, "mt35xl512aba") || + !strcmp(nor->info->name, "mt35xu01g") || + !strcmp(nor->info->name, "mt35xu02g")) { nor->fixups = &mt35xu512aba_fixups; + return; + } #endif #if CONFIG_IS_ENABLED(SPI_FLASH_MACRONIX) diff --git a/include/spi.h b/include/spi.h index 6bc8808bb9..eb015ecbf5 100644 --- a/include/spi.h +++ b/include/spi.h @@ -171,6 +171,7 @@ struct spi_slave { #define SPI_XFER_ONCE (SPI_XFER_BEGIN | SPI_XFER_END) #define SPI_XFER_U_PAGE BIT(4) #define SPI_XFER_STACKED BIT(5) +#define SPI_XFER_SET_DDR BIT(6) /* * Flag indicating that the spi-controller has multi chip select * capability and can assert/de-assert more than one chip select From patchwork Wed Dec 6 09:31:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872516 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=gSBifXKJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXJD3LHPz1ySd for ; Wed, 6 Dec 2023 20:33:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2FDD4876D9; Wed, 6 Dec 2023 10:32:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="gSBifXKJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CB8286D85; Wed, 6 Dec 2023 10:32:21 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2061d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::61d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E70028753C for ; Wed, 6 Dec 2023 10:32:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AQEbjk0cTAe48z12YzH4VzGNUxwLW9YLe1LDgV/G0bvlvpPTYi65xU1M5LKm/CBD6jRo/lhcFb4jvz00kHo2MnCGT0B6oRqu1oT8Y2ZdHLX2O0XmibI2JWJMaH1RKN2ezVf4eqzsYsABEJi36XuIQqRPTzQbMNibPIlO247I3zrFcThVjxYAnVQmMwfGIinvDdrnJHUa0g9Du2lwl4dcyPqckyHxbIA2QMSgjgyQFRBvAeZPFozpeGxwIUGskIGu8MWQbHa6i8n2jcLS6DY/sZvdWuumln2pG47CzrGQcCb8v32LGUDvSWmL3btYzJNfj0eHrdTGyTQ33Ic74xYBHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=bG+VRGfKAl45USZcFAExKOVlH9sDLFZFmNk/+xUbsBI=; b=InsnX7nLDbqWW0ABvDQLn4PumVDMJRusivDYYKbiElOlcEjxJowqnG45EWR6f8J513eox3jyew+mOoeI6taMPxsWT60mI0buoLGAZn9aPn1yTs4o54XNbZBXdsSmZdQxiAYvg+NdmwVT4Yqp5xMasIYh8QGOV4gZc7j+cL1cBi2DsU7d0W2H4c/obMtEixgyKqw9vJT95WsDd74cFvJVnCdo2jzjDUmURLqMpCCMZ3tpF06IhNqaHPz7xi8ka8O9OYUI2XeIhiDEmc2aHe08kC6sjJ8CqyCNkeHC2Q579cwJ5fLoH+UFEMECiI3jinpEYflotONDA06D9aBLoQPjHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=bG+VRGfKAl45USZcFAExKOVlH9sDLFZFmNk/+xUbsBI=; b=gSBifXKJnmCB8fWf8bntjC2ceiPgRRyRTdHvZQIHsKLgQfN/69TMUV3aINDMv1Rxrx3b+/vtVyEK4aquKYZwb+7vNSZikGipJ0lRHHYYWf3XcNpTqGVK1iKZW3LOvRcjzA9xa15pQfeHIDd62XgWj2Z4KataXX8MUQWqs6LIpRw= Received: from BLAPR03CA0012.namprd03.prod.outlook.com (2603:10b6:208:32b::17) by SN7PR12MB6885.namprd12.prod.outlook.com (2603:10b6:806:263::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:32:16 +0000 Received: from BL6PEPF0001AB59.namprd02.prod.outlook.com (2603:10b6:208:32b:cafe::32) by BLAPR03CA0012.outlook.office365.com (2603:10b6:208:32b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7002.32 via Frontend Transport; Wed, 6 Dec 2023 09:32:15 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB59.mail.protection.outlook.com (10.167.241.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:15 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:09 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:09 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:06 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" , Michal Simek Subject: [PATCH v2 05/30] mtd: spi-nor: Add support for cross die read in dual flash configuration Date: Wed, 6 Dec 2023 15:01:16 +0530 Message-ID: <025b915f46b4aeffd0a224dae195de36fe68a9f7.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB59:EE_|SN7PR12MB6885:EE_ X-MS-Office365-Filtering-Correlation-Id: 8da05c80-8500-4a04-0750-08dbf63e3c01 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h2x4v34xGZ05VQEBd44gwSBxo/Fw47EJ3bE20UlNyi06KoKkD48Li2ZIAObjVa/E+JlN5IpcBsnpc9i+6V6aYsHHWYEpVqeklv0jbG5GNDhlkKSpr5SinyYchjUxfLJ4ypIscngCIX5RH1CoBgfaWCX3an6o6fuhbGcg8LfmAxGgPlDW+JFnhAKfFakeUZGmGSgngjEFfciv8WhVHnT+mYgZyuX7Mbzgj3Cb+UpYyRg8yIBhWZKkLWF2gfvzjt+1iPR3R3RNdnlE5Cydsq6zYVD80sn52hWvVqRR4hQ10IsEd/JPTx2bAcOo5BpiIDsknLaPZ811uFFoVxEwpycaeRW0GloYbw71borFaesidIHHTxvE6uElF8+XB3Tk9xuUlHFrRwc3cLZMMeAvWO2TU39+ncPKRvj2Bhemi4CrMfWVm02oxnAi0YstWENVVbgJc2sVnMF/SudLFbMOoscttzEwnp5QcqDoTPDyTey9f5wWQpU4qseMcSkiitfTk3HUR/s1M08o8ILd82SpPQrFEuRcQIQbmu1V+2ur7DIv9oV/cKqKgA0WKnRY2mrvshjwyVx2HXvbpkiCatacogUMDdGYhnN/ET+fsN7ThitDTLe9F8jaVJElgl2gXmiL9J5JedoQsyKfqvughsnrrswWbGRbmrh18pFSyPZSw0jPP0uPGZfiwGRMrhwA73kM52JVTC3Lc76vIJ4iB0RsVGlLRpNlaS6puC9ABW6uEd6x0jkrctgB7KjdbGwf6Xj7KtfuIB6jH7ACnLv7PLO8PTI/Ug== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(230922051799003)(82310400011)(186009)(1800799012)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(2906002)(5660300002)(36756003)(41300700001)(86362001)(4326008)(8936002)(8676002)(316002)(70586007)(6916009)(54906003)(70206006)(40480700001)(36860700001)(47076005)(82740400003)(356005)(81166007)(478600001)(40460700003)(426003)(83380400001)(6666004)(336012)(26005)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:15.7537 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8da05c80-8500-4a04-0750-08dbf63e3c01 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB59.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6885 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma In a dual parallel configuration, halve the read offset. Determine whether the read offset points to the lower or upper flash in a dual stacked configuration and set the corresponding flags accordingly. Include support for cases where the read involves an odd number of bytes. Extend support for cross-die reads in flash memory devices that contain multiple dies within them. Signed-off-by: Ashok Reddy Soma Signed-off-by: Michal Simek Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 61 ++++++++++++++++++++++++++++++---- include/spi.h | 3 +- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index e505648e5d..f6e7592458 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -1503,11 +1503,8 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, struct spi_nor *nor = mtd_to_spi_nor(mtd); int ret; u32 offset = from; - u32 stack_shift = 0; - u32 read_len = 0; - u32 rem_bank_len = 0; - u8 bank; - u8 is_ofst_odd = 0; + u32 bank_size, stack_shift = 0, read_len = 0, rem_bank_len = 0; + u8 bank, cur_bank, nxt_bank, is_ofst_odd = 0; dev_dbg(nor->dev, "from 0x%08x, len %zd\n", (u32)from, len); @@ -1541,6 +1538,40 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, } } + if (nor->addr_width == 4) { + /* + * Some flash devices like N25Q512 have multiple dies + * in it. Read operation in these devices is bounded + * by its die segment. In a continuous read, across + * multiple dies, when the last byte of the selected + * die segment is read, the next byte read is the + * first byte of the same die segment. This is Die + * cross over issue. So to handle this issue, split + * a read transaction, that spans across multiple + * banks, into one read per bank. Bank size is 16MB + * for single and dual stacked mode and 32MB for dual + * parallel mode. + */ + if (nor->spi && nor->spi->multi_die) { + bank_size = SZ_16M; + if (nor->flags & SNOR_F_HAS_PARALLEL) + bank_size <<= 1; + cur_bank = offset / bank_size; + nxt_bank = (offset + len) / bank_size; + if (cur_bank != nxt_bank) + rem_bank_len = (bank_size * + (cur_bank + 1)) - + offset; + else + rem_bank_len = (mtd->size >> + stack_shift) - + offset; + } else { + rem_bank_len = (mtd->size >> stack_shift) - + offset; + } + } + if (nor->flags & SNOR_F_HAS_PARALLEL) offset /= 2; @@ -1552,6 +1583,15 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, #endif } + if (len < rem_bank_len) + read_len = len; + else + read_len = rem_bank_len; + + ret = spi_nor_wait_till_ready(nor); + if (ret) + goto read_err; + ret = nor->read(nor, offset, read_len, buf); if (ret == 0) { /* We shouldn't see 0-length reads */ @@ -1561,8 +1601,15 @@ static int spi_nor_read(struct mtd_info *mtd, loff_t from, size_t len, if (ret < 0) goto read_err; - *retlen += ret; - buf += ret; + if (is_ofst_odd == 1) { + memcpy(buf, (buf + 1), (len - 1)); + *retlen += (ret - 1); + buf += ret - 1; + is_ofst_odd = 0; + } else { + *retlen += ret; + buf += ret; + } from += ret; len -= ret; } diff --git a/include/spi.h b/include/spi.h index eb015ecbf5..9014066ee3 100644 --- a/include/spi.h +++ b/include/spi.h @@ -165,7 +165,7 @@ struct spi_slave { unsigned int max_write_size; void *memory_map; - u8 flags; + u32 flags; #define SPI_XFER_BEGIN BIT(0) /* Assert CS before transfer */ #define SPI_XFER_END BIT(1) /* Deassert CS after transfer */ #define SPI_XFER_ONCE (SPI_XFER_BEGIN | SPI_XFER_END) @@ -179,6 +179,7 @@ struct spi_slave { */ bool multi_cs_cap; u32 bytemode; + bool multi_die; /* flash with multiple dies */ }; /** From patchwork Wed Dec 6 09:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872517 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=J9CDxrwl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXJK357fz1ySd for ; Wed, 6 Dec 2023 20:33:05 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AF076876F0; Wed, 6 Dec 2023 10:32:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="J9CDxrwl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0B5208761C; Wed, 6 Dec 2023 10:32:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::603]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id EA472875EB for ; Wed, 6 Dec 2023 10:32:18 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VAlQNaSkdmNkd2R+Iws7mbVUmDQOhTIdUi9/1YCCedA6JwLJM84hWeAWNOSf7bH3RgEIhE8PLt0pA8f4t2m5CjnqIkepwdC+SVU7niDpqHHoz9Miy26YIgqrB7nzU/VnGyemBysuduFv8MqNgx1nWKiX7VElstUaDDaMB+QWSejSYybKTcXBC10RPvtMrgQClhGCPIXNVvJZKBNUduxmitg0Lj+UJuO18ZsCTuicUYHSDpbjwdIgCLtx5XA5XycJyZ+FZwnmZXi1D1IoM3La5fhJAHrKOY+73GLnwRcZF6En1CYo7WoWiFn/hOOzwJnJf+2iQHJVOdFDrXAf7/gC3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ANX0Gx4eC3ZQE+igfD++HTnS8mUZkM08G2/TUUwP0wk=; b=GYU0JByt6RaDiGN1qhFA2FAZfbWqVEEF9d6HSFzEnH1SM8k5GekYS4GiHjmptxaam/4nGOGASPlDX388OEyQ2z811MszOWDSVOgnc7/ZOmJ5QbqwWLWXUolfn/3Pq3wYrH1ZPZTy9tNwDkoPDz6NwqaIBFumftzq98Dc3thP52X1qeMWH7xXnPSwpXFs4bbb3ogi4dtxypStkcwxhlkwFCDVECx9ihL7DMXIpjuQ/ORv2quH53Tu/jjGX1bxYJfzlbnzcNbaDIkwyuGohRic/MUpWiXQde+pL8UJUh+sNeLnXmTcxqTWvol74fEyerewcu818fDNGDCQL6dpKBse5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=ANX0Gx4eC3ZQE+igfD++HTnS8mUZkM08G2/TUUwP0wk=; b=J9CDxrwl2rhlG+w6VokPKJG57pQqvWL9nEhf2F6enjT73MPQ8GX8GPL5ZV2Ne28HoA0Ou9sxF9IzMjtZ0zy+a2FwkSAQcAalXFJfRB1SZrm7rW+9erQEGDVJapXDf9aEcCXRa/ScweuFV8Gnb8r0JbSJKPjitjLRShLxa/wfp1A= Received: from CY5PR19CA0129.namprd19.prod.outlook.com (2603:10b6:930:64::27) by PH7PR12MB6719.namprd12.prod.outlook.com (2603:10b6:510:1b2::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:32:15 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:930:64:cafe::8b) by CY5PR19CA0129.outlook.office365.com (2603:10b6:930:64::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25 via Frontend Transport; Wed, 6 Dec 2023 09:32:15 +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 CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:15 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Wed, 6 Dec 2023 03:32:12 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:11 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:09 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 06/30] mtd: spi-nor: Enable DTR octal flash program Date: Wed, 6 Dec 2023 15:01:17 +0530 Message-ID: <2155cd92f92b60ae7cb53b2323dca01c9bd9ba45.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|PH7PR12MB6719:EE_ X-MS-Office365-Filtering-Correlation-Id: 20022f6b-2043-4cf8-da76-08dbf63e3bdb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n4v1OD7DzXgDaDcNpCi4et3utsti8Ddh5dV9sWTYEc8cljJ28VIE02hrOyski587tXTBO4RSUlKOEjl2Ctwd3wPodZZMOuTxY9k5r3hvTo3eOMAzeYAHa5CzawnBR6x5lo947UyviEygXH7misjoOuH8NsgJN1+SS30yn8Cv9sDOSa/gZ2BVZtTyNCk/xb/+l6BIA7sAQZ+ljgaT1X1PPtcTSKdNIc/7twsftNQCKBrYZyfFs4Wzf30Xze3zuZblUhDYaTP/v91wFU6qjvcBIvS0yB69NOOToe+igAePKB8BFpfRQWjnIIZsbAw0q42pvpFqb/UfED/ugtfVjWZouVhdEQ7UdN56ElGpsfy9AS4HwI5F/LSQrNEOosnS+BugXRu/mMcMwNEqkcK7hakVY6/GHt386yNn3ECJj90hTlQIU9sfu0yuWQE7VfAyKZz9uucpD4WmA2dKbbtnEOAjqY5wKntF/8w2G6sdakIURbh83hLH29XXSCeWw23ZrnQw/6MpkV23z4ZAsgmdh6UflV7bS2t7LJpCQGRsQdg0MgpXc6WShwpHfRkD1hQGwZKAnsaYyYSx3B+qjugxedN8wrl298Yx/SFeg24eLMgvAGbRKS6jJybBew2h1ZK1ynciloVD1iVuSlC+ekOHyTKezQk7xB+VsYwcwW1QszIHiIziV7qhgm3hFX/4I1fMbcUzs0XPHdfSR4nNeRkevx9SDmmKVdAr/SQGjoYn5yaxHoo22gzyG/6qKsCDnjjx0+kuR+UwHNLvPqmYdrVyPMAlVQ== 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:(13230031)(4636009)(396003)(136003)(346002)(39860400002)(376002)(230922051799003)(451199024)(186009)(64100799003)(82310400011)(1800799012)(46966006)(40470700004)(36840700001)(82740400003)(5660300002)(2906002)(36860700001)(41300700001)(86362001)(356005)(36756003)(478600001)(81166007)(2616005)(6666004)(26005)(47076005)(8936002)(8676002)(70586007)(426003)(70206006)(336012)(6916009)(54906003)(83380400001)(316002)(4326008)(40460700003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:15.4476 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20022f6b-2043-4cf8-da76-08dbf63e3bdb 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: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6719 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Define a flag SPI_NOR_OCTAL_DTR_PP and if enabled in spi-nor-ids table, enable octal DTR page program in the framework. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/spi-nor-core.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index d3ef69ec74..9c09f97ce2 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -69,6 +69,7 @@ struct flash_info { #define SPI_NOR_HAS_SST26LOCK BIT(15) /* Flash supports lock/unlock via BPR */ #define SPI_NOR_OCTAL_READ BIT(16) /* Flash supports Octal Read */ #define SPI_NOR_OCTAL_DTR_READ BIT(17) /* Flash supports Octal DTR Read */ +#define SPI_NOR_OCTAL_DTR_PP BIT(18) /* Flash supports Octal DTR page program */ }; extern const struct flash_info spi_nor_ids[]; diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index f6e7592458..63f78baaf4 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -3026,7 +3026,8 @@ static int spi_nor_init_params(struct spi_nor *nor, * Since xSPI Page Program opcode is backward compatible with * Legacy SPI, use Legacy SPI opcode there as well. */ - if (CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE)) { + if (CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE) && info->flags & SPI_NOR_OCTAL_DTR_PP) { + params->hwcaps.mask |= SNOR_HWCAPS_PP_8_8_8_DTR; spi_nor_set_pp_settings(¶ms->page_programs[SNOR_CMD_PP_8_8_8_DTR], SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); } From patchwork Wed Dec 6 09:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872519 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=fhiSKLwx; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXJd5ddtz1ySd for ; Wed, 6 Dec 2023 20:33:21 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78AB0875EB; Wed, 6 Dec 2023 10:32:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="fhiSKLwx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C3716871D7; Wed, 6 Dec 2023 10:32:24 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::620]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 98D788761C for ; Wed, 6 Dec 2023 10:32:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=arYTK+pnFHwPFJ5PhVQ2oG1BivMb8q7wGoFytim/0LnfiWHfBx8XI9EWPPzIyXM+FnjC/3QeJZlk3LgRkehVV1zRzExiSpha+6dd5mY6ZpGLtLPl9P3dQTKp068OLBo2FM5G707eMCNPomDLpRjPX1374zxuMa7dQ5Ad9mfxPOrHpMlWywYq/zno2D06muZ8biJb70JZSWd4tlhTpXRZ9G3QhK0uzUPE+UsTvcJg+cDCWgQodqf/mhCaY31lzZEFC0Qc+OikYL7hjFoOvMWFLyFKsq/FfVnB7hXSZbzfVZwG6eHrXpKqWY/lVn/XqLHmO3RFy/H7gTqG3kf8U1va6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=gqBJRaeByGb+I+hyhX9O54Cs/hVOi01imTQWmnMj5/U=; b=kx6yit0qk/3VC8QkC7wTcEK9w02frAd3KreDM3ZBhzK5yj1rRiDJ7DfdRQ3wHOouEmMpFJMmKX/FzsPFeXrVWCeQ5mtmcopmd/jwt6OLP3q4GkafvAQ7KRO9wqEbxAHHjVO1Pvj1P08G0lc/Wn5kBWzwQNkUMqqrjn3hkNYkGcVddlvNw8WzMLiM0e7dyHqI95povkwrhTZAeNnYbUvp447h2eLzoPAnXf6+1RGSg3gBXS4mFtfdCazHocbZ73PkTf1snwosq0npkqy2HouXWDnPCUpgxxfcO5xVEVLHVFXT6WTOwJk/geKyNbE9TSDXRkWoMX8laahY438e8rh2bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=gqBJRaeByGb+I+hyhX9O54Cs/hVOi01imTQWmnMj5/U=; b=fhiSKLwxhtbHZnr17cFQ638Bbm4DVETPJnd/CQ76yXxrGvJvdEVRLrl6CNcoGi+PUxaGDsJr1PVv6+LeeWCQMs/EnSRS4BeekGj88EnEMjI7TVXmeQp9C3cVmHrlm4CMBnVYdPGLFy1/imM7Gk1+iacmBG3B+1/wEkVYysl/9bg= Received: from CY5PR19CA0130.namprd19.prod.outlook.com (2603:10b6:930:64::17) by PH0PR12MB7471.namprd12.prod.outlook.com (2603:10b6:510:1e9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:32:17 +0000 Received: from CY4PEPF0000EE39.namprd03.prod.outlook.com (2603:10b6:930:64:cafe::e2) by CY5PR19CA0130.outlook.office365.com (2603:10b6:930:64::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:32:17 +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 CY4PEPF0000EE39.mail.protection.outlook.com (10.167.242.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:17 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.34; Wed, 6 Dec 2023 03:32:15 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:32:14 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:12 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Ashok Reddy Soma Subject: [PATCH v2 07/30] spi: mtd: Use split reads if multi-die flag is set Date: Wed, 6 Dec 2023 15:01:18 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE39:EE_|PH0PR12MB7471:EE_ X-MS-Office365-Filtering-Correlation-Id: 833c2757-8bb5-4ecb-cc1b-08dbf63e3d11 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rTVCNQaI66GBdmpru0MTKst/NpKIxEE6Acst7dIL+gofm+Sp8q7C7uDv7fsdzmWe0Z/1Q38+erBNtHwoFenzOD5tvrsFsQKhMW8WA87a+Vf3oOz1vhCt71lf56SxgkrdczOC2XtVwpWV5nwL5Y6XKK7Gggbaa2sDxGYRCK6oPMCeIvHtkFdufWimbDbIBQbDKYC349lfJ9CoP5uxFru2vDeW+Ta0VaBufQTtJUTxQC2/8RZtkyXguhVcw99W+cGUaTL0qjuwRd4xeftFMyScoKMBf1YabPaMvmYUmpEUTgs+AtbjZ5Dx+pI27xEbEkFHJObfCh/0KfjJSq+HEXaBR2KgdibyzMVeJM9fZe+c32bUm4Q6EoRZnYwIeKQLuThaEVTB1Mj5alv1F3fa+d7AdNc3LCJYzODglJtSHa692ZcBrXFCkrgdV740U8GGjDGyFbhlpyq/g+YsZmyLQrJxgWop4XN1Lxx1G0XV5VZdHChWGN6xLIbihTyRwY5igPKSHLrbcrVr+rCZHkhFVtQoSAy3fxCr6E2F5SwtBIHTBU5HfEvP8uUo2+DWWzReaJzweq1n12N26HH/kATJ1pvpNFDNvm+j8yWkFalfBpXXBBCXBzmixNE6e7TLlS6REqVWX1ngoVARxLHAORNu5ndxFARUpGJdZyf5hCvhNHzK7rvl0FfLIhO800qnd2fXHf3XB0TvdFUn+oNmAkG4CBrqk5bB8Uyxs/AfdsWPWT3PKbDAZCo0aQsZ0eOjEl39fj/jTIwE4bBEkowZk4CgK9L28Q== 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:(13230031)(4636009)(136003)(346002)(39860400002)(376002)(396003)(230922051799003)(64100799003)(1800799012)(186009)(82310400011)(451199024)(40470700004)(36840700001)(46966006)(40480700001)(2906002)(26005)(336012)(426003)(356005)(86362001)(47076005)(82740400003)(81166007)(36860700001)(40460700003)(5660300002)(36756003)(2616005)(8936002)(8676002)(4326008)(41300700001)(6916009)(70206006)(316002)(70586007)(54906003)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:17.4945 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 833c2757-8bb5-4ecb-cc1b-08dbf63e3d11 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: CY4PEPF0000EE39.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7471 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy Some flash devices have multiple dies in it & has die cross over issue. When SPI_NOR_MULTI_DIE flag is set in flash id table use it to enable split reads to avoid above issue. Define SPI_NOR_MULTI_DIE new flag to flash id flags. Remove SPI_FLASH_SPLIT_READ config and related code from the zynq and zynqmp qspi drivers as it is redundant. Signed-off-by: T Karthik Reddy Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/sf_internal.h | 1 + drivers/mtd/spi/spi-nor-core.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 9c09f97ce2..2cbdea60b0 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -70,6 +70,7 @@ struct flash_info { #define SPI_NOR_OCTAL_READ BIT(16) /* Flash supports Octal Read */ #define SPI_NOR_OCTAL_DTR_READ BIT(17) /* Flash supports Octal DTR Read */ #define SPI_NOR_OCTAL_DTR_PP BIT(18) /* Flash supports Octal DTR page program */ +#define SPI_NOR_MULTI_DIE BIT(19) /* Flash has multi dies & need split reads*/ }; extern const struct flash_info spi_nor_ids[]; diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 63f78baaf4..ace5da9591 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -4485,6 +4485,9 @@ int spi_nor_scan(struct spi_nor *nor) if (info->flags & SPI_NOR_NO_ERASE) mtd->flags |= MTD_NO_ERASE; + if (info->flags & SPI_NOR_MULTI_DIE) + nor->spi->multi_die = true; + nor->page_size = params.page_size; mtd->writebufsize = nor->page_size; From patchwork Wed Dec 6 09:31:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872521 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2UC8MUSw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXK13GXmz23nQ for ; Wed, 6 Dec 2023 20:33:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DB6588770C; Wed, 6 Dec 2023 10:32:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="2UC8MUSw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90B818761C; Wed, 6 Dec 2023 10:32:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20612.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::612]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 06E97876E2 for ; Wed, 6 Dec 2023 10:32:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hQmr1TGR030MbLHp4N72OQAX1a75c1ivOHh4w+cS2+K7MAneeKcR3/3mwq+qKRXD/JLD0jL+lBtYzR6BNU2+rJNFG3Qy7CW1T9HvCTlWdAmGTmguIqbLHxljyfikIF9DMYGmlVsUqPMr99xTCmKHXy4E2h4czIVoTCNmP2l44Z5tCcuS4u39T+rRjmb/UwWyicQ21QibHpgqAfrUYJDxwvu3ui1qp9rO48rwXPUHIQ6ZI/jVJGi/ouggBcxLQZeAKuaaDmjP2WewdV8lCTMmVqB+PMxApX/mWDvmKrEK0NRyAS91SNGTllBWulo8quQ2pgcVdwOCNdi7pJrxkp5ATg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=psV13rOWnDHJ9n5KGqXPAHb9q9jy5lBS8ada9GoDx9M=; b=Ebo/yCi3dm0FZNerHchhLXWbyWvTkr/jIPUHEOoJOfrU2cBHUPhavlqRVypfiuJ5Gsbp/7p0s6SFRd1UOR69LldLZsSC6bs8lWfyGxnpEez05dyj8SY3U4t6z/vKnuftTeyJb1AVBjrw1p86aix4PRNGTZ/fEbkv1c5MDnXJKt6QIbGb9J3cfThB5iqoDtaB2qrUZdTobFjVH89FqRtF9chnEVvBQysgSCiN9ZEflRmtKGdta+oDmiUi4ex1AWNnoIsqwc+W9gvVALNv+suzLNVqPcYRnSFsYvgjUyQA8KqczuKFZLvZq+8K1API60GMDI/XdL3tano5dshQQKpYew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=psV13rOWnDHJ9n5KGqXPAHb9q9jy5lBS8ada9GoDx9M=; b=2UC8MUSweYtOjGbW9NzGZjxz2BVa/oaA1aZkLnLOijV/yY6tBwHjmGztuSA6AdX5Q57pDO3gtq+aavh1zvbDtgig83ubVcWRhQbcptWvhmqIzCngwYFdA5pcuk10PcBrFmEJiW7KyIupX5uS5+a7T5HUYZHXeGiphiujWuF/gWg= Received: from MN2PR05CA0048.namprd05.prod.outlook.com (2603:10b6:208:236::17) by DS7PR12MB5765.namprd12.prod.outlook.com (2603:10b6:8:74::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.36; Wed, 6 Dec 2023 09:32:19 +0000 Received: from BL6PEPF0001AB53.namprd02.prod.outlook.com (2603:10b6:208:236:cafe::61) by MN2PR05CA0048.outlook.office365.com (2603:10b6:208:236::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.24 via Frontend Transport; Wed, 6 Dec 2023 09:32:18 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB53.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:18 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:17 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:32:17 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:15 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH v2 08/30] mtd: spi-nor: Update block protection flags for flash parts Date: Wed, 6 Dec 2023 15:01:19 +0530 Message-ID: <4159302a33e26eb940b340402159916b6f9302b4.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB53:EE_|DS7PR12MB5765:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a01522c-0e41-4a54-272b-08dbf63e3dba X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8iCrLgFfbHjL6aoM4S9kET+K4CzuUROh9ncC4zjL+5lSHJnkvcyCLB8LCBnsfRHhZlZOzGBCfzMkewfCPbR2HemIKEknFdhueJ9tEFLVn5qA5govKJRXjTgJolJ9yRpbJjn9ZhOgFSCnZ+I7MOBVnzMluUrapnCjGSuakpsJULtkYP8VfffzBBMd+K+1fQToFRuXrvtnMHKwglbQ7sfd0B+zybegpzytlP8ogi/JqNc7uE8HKMH0F3EIp+p3pzwi8z/ZSmUFb4KgxnuJdjG+GKm2OwHynx64McdqIf2tu895tpcv5yuJ4q+BWL+L695xJJ5LzpK/txacro12wDRy10MZmbsk5zf7rmAPo498pIOcIkfj8kCPDk4FV2TRzcfPyJL+rUiXp0AWsEVe/eVMzbfJlRh9KMVi2g4O/U+FCWvhtZQOQVrnj21yTK3TOpI9QfW9mUAx5ipdnlwpv5OqjXAYxcyXaMt3hqwPnuu4O7B2o1KiaHysbOpP47xO4vQpokoUxz1DNoO4FAQdXdGPo+jHXkHaTCaxcVgI5dAa7W+ijJgX6bzeO6aRA4WxLlAuk+IyZyN0UPLy6tMMfaohSDYwu+s3hidW4LDXbANHSb9HaXN+heBRMSJtdG5hIvgcaFoH06zV7RdCsi8wDp+z06EQf21wNYoOoRQepqzNrEioi1mNIVv2lE7qVpCeyTmYN/CUYtlMkUOSMFD8y432EbG2OTNMcVwNW631A7Te5mM3QBCJJ8mJYUfsH1MRvt+Qxm/Nu2O3lxIw/Nit+yn+cA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(230922051799003)(82310400011)(186009)(1800799012)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(2906002)(5660300002)(36756003)(41300700001)(86362001)(4326008)(8936002)(8676002)(316002)(70586007)(6916009)(54906003)(70206006)(40480700001)(36860700001)(47076005)(82740400003)(356005)(81166007)(478600001)(40460700003)(426003)(83380400001)(336012)(26005)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:18.6603 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a01522c-0e41-4a54-272b-08dbf63e3dba 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB53.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5765 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Venkatesh Yadav Abbarapu The block protection flags for Gigadevice, Spansion, and ISSI flash memory have been modified. Additionally, new flags for SPI_NOR_OCTAL_DTR_READ and octal DTR page programming have been introduced for Micron OSPI flashes. Furthermore, the flashes mt35xu01g and mt35xu02g have been incorporated into the CONFIG_SPI_FLASH_MT35XU configuration, so that in driver mt35xu512aba_fixups will be applied. Signed-off-by: Venkatesh Yadav Abbarapu Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-ids.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index 3cb132dcff..0dbd385265 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -122,9 +122,9 @@ const struct flash_info spi_nor_ids[] = { {INFO("gd25b256", 0xc84019, 0, 64 * 1024, 512, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES) }, {INFO("gd25b512", 0xc8471A, 0, 64 * 1024, 1024, SECT_4K | - SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES)}, + SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES | SPI_NOR_HAS_TB)}, {INFO("gd55b01g", 0xc8471B, 0, 64 * 1024, 2048, SECT_4K | - SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES)}, + SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES | SPI_NOR_HAS_TB)}, {INFO("gd55b02g", 0xc8471C, 0, 64 * 1024, 4096, SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES)}, {INFO("gd25f64", 0xc84317, 0, 64 * 1024, 128, SECT_4K | @@ -212,11 +212,11 @@ const struct flash_info spi_nor_ids[] = { { INFO("is25lp128", 0x9d6018, 0, 64 * 1024, 256, SECT_4K | SPI_NOR_DUAL_READ) }, { INFO("is25lp256", 0x9d6019, 0, 64 * 1024, 512, - SECT_4K | SPI_NOR_DUAL_READ) }, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_HAS_TB) }, { INFO("is25lp512", 0x9d601a, 0, 64 * 1024, 1024, - SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_TB) }, { INFO("is25lp01g", 0x9d601b, 0, 64 * 1024, 2048, - SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_TB) }, { INFO("is25wp008", 0x9d7014, 0, 64 * 1024, 16, SPI_NOR_QUAD_READ) }, { INFO("is25wp016", 0x9d7015, 0, 64 * 1024, 32, SPI_NOR_QUAD_READ) }, { INFO("is25wp032", 0x9d7016, 0, 64 * 1024, 64, @@ -312,11 +312,15 @@ const struct flash_info spi_nor_ids[] = { { INFO("mt25qu02g", 0x20bb22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE) }, { INFO("mt25ql02g", 0x20ba22, 0, 64 * 1024, 4096, SECT_4K | USE_FSR | SPI_NOR_QUAD_READ | NO_CHIP_ERASE | SPI_NOR_4B_OPCODES) }, #ifdef CONFIG_SPI_FLASH_MT35XU - { INFO("mt35xl512aba", 0x2c5a1a, 0, 128 * 1024, 512, USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | SPI_NOR_OCTAL_DTR_READ) }, - { INFO("mt35xu512aba", 0x2c5b1a, 0, 128 * 1024, 512, USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | SPI_NOR_OCTAL_DTR_READ) }, + { INFO("mt35xl512aba", 0x2c5a1a, 0, 128 * 1024, 512, + USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | SPI_NOR_OCTAL_DTR_READ | SPI_NOR_OCTAL_DTR_PP) }, + { INFO("mt35xu512aba", 0x2c5b1a, 0, 128 * 1024, 512, + USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | SPI_NOR_OCTAL_DTR_READ | SPI_NOR_OCTAL_DTR_PP) }, + { INFO6("mt35xu01g", 0x2c5b1b, 0x104100, 128 * 1024, 1024, + USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | SPI_NOR_OCTAL_DTR_READ | SPI_NOR_OCTAL_DTR_PP) }, + { INFO("mt35xu02g", 0x2c5b1c, 0, 128 * 1024, 2048, + USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | SPI_NOR_OCTAL_DTR_READ | SPI_NOR_OCTAL_DTR_PP) }, #endif /* CONFIG_SPI_FLASH_MT35XU */ - { INFO6("mt35xu01g", 0x2c5b1b, 0x104100, 128 * 1024, 1024, USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES) }, - { INFO("mt35xu02g", 0x2c5b1c, 0, 128 * 1024, 2048, USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES) }, #endif #ifdef CONFIG_SPI_FLASH_SPANSION /* SPANSION */ /* Spansion/Cypress -- single (large) sector size only, at least @@ -325,8 +329,8 @@ const struct flash_info spi_nor_ids[] = { { INFO("s25sl032p", 0x010215, 0x4d00, 64 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("s25sl064p", 0x010216, 0x4d00, 64 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("s25fl256s0", 0x010219, 0x4d00, 256 * 1024, 128, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, - { INFO("s25fl256s1", 0x010219, 0x4d01, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, - { INFO6("s25fl512s", 0x010220, 0x4d0080, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, + { INFO("s25fl256s1", 0x010219, 0x4d01, 64 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR | SPI_NOR_HAS_TB) }, + { INFO6("s25fl512s", 0x010220, 0x4d0080, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR | SPI_NOR_HAS_TB) }, { INFO6("s25fs512s", 0x010220, 0x4d0081, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, { INFO("s25fl512s_256k", 0x010220, 0x4d00, 256 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, { INFO("s25fl512s_64k", 0x010220, 0x4d01, 64 * 1024, 1024, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, @@ -334,7 +338,7 @@ const struct flash_info spi_nor_ids[] = { { INFO("s70fs01gs_256k", 0x010221, 0x4d00, 256 * 1024, 512, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("s25sl12800", 0x012018, 0x0300, 256 * 1024, 64, 0) }, { INFO("s25sl12801", 0x012018, 0x0301, 64 * 1024, 256, 0) }, - { INFO6("s25fl128s", 0x012018, 0x4d0180, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, + { INFO6("s25fl128s", 0x012018, 0x4d0180, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR | SPI_NOR_HAS_TB) }, { INFO("s25fl129p0", 0x012018, 0x4d00, 256 * 1024, 64, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, { INFO("s25fl129p1", 0x012018, 0x4d01, 64 * 1024, 256, SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | USE_CLSR) }, { INFO("s25sl008a", 0x010213, 0, 64 * 1024, 16, 0) }, From patchwork Wed Dec 6 09:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872520 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Rrh9o6py; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXJq1BLQz1ySd for ; Wed, 6 Dec 2023 20:33:31 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 792B4876E2; Wed, 6 Dec 2023 10:32:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Rrh9o6py"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3E758871D7; Wed, 6 Dec 2023 10:32:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::629]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D4AE2876F4 for ; Wed, 6 Dec 2023 10:32:23 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g6GA2mUmiH9acny2ilpLRR9nt2F7+9FJcmbspgPMiimUpYNRVyfti0L8b2bSsTlHenR/0YcLNwjULVS9jyBrKd2E3YbKgbPk7AGmjahZlxEVIY59e0Igmrs+hkElsnX4xuoeWsUsnfoffU3mQ3JFoi3u9EVAxhKNPHenxOTz5ziP8HAsE7U6EJYeuq2ldRHCbF69VR5+4f/BzCMfcSt+ppq0MpeMDK04+uyIfCJwvQDZ6qVvTkMK916V83X+EJqH2VdMl+o4FdG+uFri1dnGqj+2Casnk5N9kJphPm6otdWcOWheVKVFB3sG9IC87HlRAcMN8zkO5ykj/AUmSnDKtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=FdxayJW/Q7ePaUdtYoRRLuMsmtr5yDtixj+hr7zWiI8=; b=M9e8tX3abSn3ems2YiCCDs/YHQJNOKkHyb5NTYsxnAtWTVtRZce5Iw+6iw/VzFxQf9T0BHWoExE58nTSg6uNGTZTeB9423poQd1tYaCEG7tD+uyskT/TZjZ0asbDdzn2DjwO8A55iKzGidtubQS1Lbs+RtvmFa8JJDRuBJeDnhOnlyKxzHi+TeqnMNSjzdSXDtBKMaGttc/UFvvIhz7jK6/jOv5yA1tqSxCLPE6q0niwOrrYxqig5hM8bsj/LONwcij8kBsAwtaBhxJPeictLYpLXJ4X/edvRhPs/Jup6Hmqjkdy4CA4jXjHLZv8VgHDxOsKW/JBee4vTTljiSue5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=FdxayJW/Q7ePaUdtYoRRLuMsmtr5yDtixj+hr7zWiI8=; b=Rrh9o6pyKRHbij7Bl3isBpWOwnwjceIfpoRfmIi50u1zTdQL3lwNM772S5dt/s80fGFu32hdxt05DqOPmFApJzoWn0hV9bYjhwfCvk8DXx7GQPidMm/0fkdvKSeg4cDqYxAQW5DjmnuOdD1LklacpUZeVUT7SgAJfSjJErPtK8Q= Received: from MN2PR05CA0042.namprd05.prod.outlook.com (2603:10b6:208:236::11) by DM4PR12MB6063.namprd12.prod.outlook.com (2603:10b6:8:b1::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:32:21 +0000 Received: from BL6PEPF0001AB53.namprd02.prod.outlook.com (2603:10b6:208:236:cafe::a9) by MN2PR05CA0042.outlook.office365.com (2603:10b6:208:236::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25 via Frontend Transport; Wed, 6 Dec 2023 09:32:21 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB53.mail.protection.outlook.com (10.167.241.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:21 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:20 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:20 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:17 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Algapally Santosh Sagar" , Ashok Reddy Soma Subject: [PATCH v2 09/30] mtd: spi-nor-ids: Add support for W25Q02NW Date: Wed, 6 Dec 2023 15:01:20 +0530 Message-ID: <1d090458a47c8651b7051ed7bfe637111fee58cf.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB53:EE_|DM4PR12MB6063:EE_ X-MS-Office365-Filtering-Correlation-Id: d2f5fae7-c7f3-4ec7-77b3-08dbf63e3f4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 73WuK4tV47WMz/DNuQNxlrQYQ0tiuJtASr/HjUl9EHyH05MN0ViAcItiqtTv5rTAfA2PcguUUXKTutoukLq7UfJOmTyoh8o1QrRAZxXZyb0vZ6Tl3b57ve+y3RqBmXTxKLcZ3v/CIGZougShp0Xf3nUdzEcV9Ip1VgvJHyZ5IfLnLDjTg/IfEzEMJjVV6qbBed4slIrYz90Say+5xQwYaSWR1X2DXUbr/9k6eHCYFQPuPf6KONC6bqCsdWMJ/BWTDBkxJ5ZGuSjSaZM9uvpuWNmsATkK8LFMJ5yrysM7SJYhxyPODBPRdv5oPng5ll9uCmq4RHf2u6y8tpXv8v0GGuNKoiTszOh8KKxj+0sMRD5WAeyVIQMeKyiXxeY5vyqav5NAuWQAUtJdcws5PiIsmmtFKOJWUA41T0j9ZlpiCLxQPu3EWMVC0HYvQXmzll6xyP+WBn2ouquaINeNMI353tOvM8/POFKm4lzAxI7iiWDFXKJ5dnwrsZsvFTYA7CEx9UJ2E1c9Ye51dfcvcOWWrs5z4JknPRwKR0bzv/kIErk1Xx7I+TstU1CEVY1z0zacAH9Nw+SMAf0lQm4h8SurBSYdtQ9rB+v1M1jzDsc3hehyf3BUhuTlXDTNkTf7nnfW/T1YUjtbNIJr9p9KyL/6r3uqs/tGdJrieE1W4zodURxNyZkqGgOpq48YDM33z+YoTsjbtEExADoB+798F8wjsT4nYrJjTccxrdPzpyxpQC7Lw/lzRdHit3m1jpVK/uywyEw9woa9/8FTBdc4wTDYyg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(39860400002)(376002)(136003)(396003)(230922051799003)(451199024)(82310400011)(186009)(1800799012)(64100799003)(36840700001)(46966006)(40470700004)(2616005)(316002)(40460700003)(426003)(83380400001)(336012)(6916009)(26005)(70586007)(70206006)(54906003)(478600001)(6666004)(36860700001)(5660300002)(40480700001)(82740400003)(47076005)(2906002)(356005)(81166007)(4326008)(86362001)(41300700001)(36756003)(8936002)(8676002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:21.2853 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d2f5fae7-c7f3-4ec7-77b3-08dbf63e3f4f 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB53.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6063 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Algapally Santosh Sagar Add support for Winbond 256MB flash W25Q02NW which supports 4byte opcodes and also dual and quad read. Signed-off-by: Algapally Santosh Sagar Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-ids.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index 0dbd385265..51e8cce407 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -517,6 +517,12 @@ const struct flash_info spi_nor_ids[] = { SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, + { + INFO("w25q02nw", 0xef8022, 0, 64 * 1024, 4096, + SECT_4K | SPI_NOR_QUAD_READ | SPI_NOR_DUAL_READ | + SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_4B_OPCODES | + SPI_NOR_MULTI_DIE) + }, { INFO("w25q80", 0xef5014, 0, 64 * 1024, 16, SECT_4K) }, { INFO("w25q80bl", 0xef4014, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("w25q16cl", 0xef4015, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, From patchwork Wed Dec 6 09:31:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872522 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=o0Mu3yzJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXKD2rrGz1ySd for ; Wed, 6 Dec 2023 20:33:52 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 60064876D3; Wed, 6 Dec 2023 10:32:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="o0Mu3yzJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 933D7876D3; Wed, 6 Dec 2023 10:32:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::60e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 600CB86CF4 for ; Wed, 6 Dec 2023 10:32:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lQSqSj+1XldTRlVknB30M29uu8YicKDw86dhvQcodpGeV8WAFxtEFrLhpKB9yi8lt/7kRr7bmKkUy6p65qApsJrixHTnLcd2ALoPQ3m35wXEqJ1scL9aI8iOZagxvddWgNa6WFcRBTqAgnDXRWy+OAzMNTdAGVY89PcYhwsYWIq3IB6e/ngF+cmuWu2Ea1jF44Ut1lSP1inqT7Biuo0hkSDqA71JpyifvFe71Hc8xeMPSNeGAHTrzaMRSJ2J4sqSieMerLVsSOnWV8ZYtR2jQhW9rLRbXShDJrcu4EFtZGJYgbvGbpHan/AMqYRvGZS9jU2wRClQ9d9GSTzobnVm8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0To8FOLfmZ6HSpwWfS6IxGRqt7AdfIWbOOTiZ67/Jco=; b=OUUL6vVNAET4HYCyN1BAFc04KoRB8wId/UV4/X7IzPv122aDtsWqgFAsfYkEAUwGcz0RcpxSwvPghpTiLkcp7V7dOQFKsOAJLODBht6z+1b1Vi2xG42uRBcipGA1Ak3kMeil54oTjyceNNKiQs9jn41Ny61e+QWk7L71/ZxfEVXQj/+O6ZS1/guQYU26yJw+Xl2uL0upts4bLnkCldnDHzQie4IG6UY4EednKLDsIryrrrUg67lDl0twi3GT0QugUUqkCF7vIR6hU1adhQP+r2y1v1KjL3E0vOqjpvBAOWXiUORODyU1ejx8jVQYTxFWMWQoz2kyMUyaDbvjiU2zwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=0To8FOLfmZ6HSpwWfS6IxGRqt7AdfIWbOOTiZ67/Jco=; b=o0Mu3yzJJ9uMoYBeCfPwSOLuX8nKz5nA/eUFHFVayDUgLm17u1106szYIezfmiLcV9/NYBF0A15N7rcCKYR078ASbLbXt0N6IdICH7Z8xRZ3uW+WjxcFdk+4TTexGn0yTuscPuucxtICGwJnFEbg83dvNHXzW/sEr/Z+bvPNZ0M= Received: from DM6PR18CA0032.namprd18.prod.outlook.com (2603:10b6:5:15b::45) by DM4PR12MB5373.namprd12.prod.outlook.com (2603:10b6:5:39d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:32:24 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::b7) by DM6PR18CA0032.outlook.office365.com (2603:10b6:5:15b::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33 via Frontend Transport; Wed, 6 Dec 2023 09:32:24 +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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:24 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.34; Wed, 6 Dec 2023 03:32:23 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:21 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH v2 10/30] mtd: spi-nor: program quad enable bit for winbond flashes Date: Wed, 6 Dec 2023 15:01:21 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|DM4PR12MB5373:EE_ X-MS-Office365-Filtering-Correlation-Id: 1383e13c-163b-4e7f-a7f1-08dbf63e412c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J0tNtJpBlS9u8dC2BIOSkdiLTx610qzo0xeovXrixWG0l1v7CSMz7qYtpQkhD7uPB2bOU1iPFKWT3/sS4NyZsGSTVCFH4sVP/U/H8X4QYV7SRKKidwC5PD+eKN5TWP2JVaPggbC8xUcKQjGR28JdG9MYIVUycaTpaTCFXL55KqTbLXoCagfKpaBB5dzmDH6Qj+hOHzdTJHUZA8k7RAwqK8/JjnOy4DIMnwFJtCDvVIt7EG/o8dKEw5HxL6S1gGa5d7IYOkxcwpZJrXhQDEtCUIgHtebBNTiagdo5sdtZzUzCXvZcERbAvPHp6ADm3SAkuvZD4hUoC1v6KLKUxFOlHkWxBSN1638X5B/7Rxys/P3dCrWW24fHn6QNumOp+zZB7wXg83yB6OwAmeLKV0SD3KMP93371XE1JuHG/FrT2vgqLh/OTJRb0f3NvoAbR/u4ajJzbAhsJFWdoYxOVv/Ub6jfPGRaHhDO5lSnr/BKM1efzz6QLidWNH7NQHJb0V4bnUsXia1bF+Q9euoscVtXR2kehgxqKmyTifvOCXmlSp2jjfJT08J6dL5szLaxwr3NaEkWFaehkbb0RpHoTH86kyZoeiiEj6vccfmm+q9ym3RcR/tEeIMWpe8mUkwBHQeoTfWtpLw1QaPdDPiQ2tPUDoUtqM7jKaUAhYLi6b0O4C8VGZFZkiawkpTMLjQr2KfOb1NzrUVuTCARTX2awKtXxwLFMWbZeLeka5STvR9sYXIfzKah8iwOP+1gBsMLiutUEz+92EZEBm4fSoxM6EWUsg== 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:(13230031)(4636009)(396003)(376002)(136003)(39860400002)(346002)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(46966006)(36840700001)(40470700004)(40460700003)(5660300002)(82740400003)(2906002)(36860700001)(36756003)(86362001)(356005)(41300700001)(47076005)(2616005)(4326008)(8676002)(26005)(81166007)(478600001)(70586007)(70206006)(336012)(426003)(6916009)(54906003)(316002)(8936002)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:24.3657 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1383e13c-163b-4e7f-a7f1-08dbf63e412c 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5373 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy Added support to program quad enable bit for Winbond flash memory. Previously, the quad enable function from Spansion was used for this purpose. However, for Winbond flash memory, the quad enable bit is configured by programming the Write Status Register-2 (SR-2) rather than the Configuration Register (CR). Signed-off-by: T Karthik Reddy Co-developed-by: Tejas Bhumkar Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 48 ++++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index ace5da9591..454ae6cd4e 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -2141,6 +2141,49 @@ static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) return 0; } +/** + * winbond_quad_enable() - Set QE bit in status register-2 + * @nor: pointer to a 'struct spi_nor' + * + * Return: 0 on success, -errno otherwise. + */ +static int winbond_quad_enable(struct spi_nor *nor) +{ + int ret; + u8 cr = 0; + + /* Check current Quad Enable bit value. */ + cr = read_cr(nor); + if (cr < 0) { + dev_dbg(nor->dev, + "error while reading configuration register\n"); + return -EINVAL; + } + + if (cr & SR2_QUAD_EN_BIT1) + return 0; + + cr |= SR2_QUAD_EN_BIT1; + + write_enable(nor); + + ret = nor->write_reg(nor, SPINOR_OP_WIN_WRSR2, &cr, 1); + if (ret < 0) { + dev_dbg(nor->dev, + "error while writing configuration register\n"); + return -EINVAL; + } + + ret = spi_nor_wait_till_ready(nor); + if (ret) { + dev_dbg(nor->dev, + "timeout while writing configuration register\n"); + return ret; + } + + return write_disable(nor); +} + /** * spansion_read_cr_quad_enable() - set QE bit in Configuration Register. * @nor: pointer to a 'struct spi_nor' @@ -3052,6 +3095,11 @@ static int spi_nor_init_params(struct spi_nor *nor, case SNOR_MFR_MICRON: break; +#if defined(CONFIG_SPI_FLASH_WINBOND) + case SNOR_MFR_WINBOND: + params->quad_enable = winbond_quad_enable; + break; +#endif default: #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND) /* Kept only for backward compatibility purpose. */ diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 72206f51ad..34e0aedc24 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -48,6 +48,7 @@ #define SPINOR_OP_WRSR 0x01 /* Write status register 1 byte */ #define SPINOR_OP_RDSR2 0x3f /* Read status register 2 */ #define SPINOR_OP_WRSR2 0x3e /* Write status register 2 */ +#define SPINOR_OP_WIN_WRSR2 0x31 /* Winbond Write status register 2 */ #define SPINOR_OP_READ 0x03 /* Read data bytes (low frequency) */ #define SPINOR_OP_READ_FAST 0x0b /* Read data bytes (high frequency) */ #define SPINOR_OP_READ_1_1_2 0x3b /* Read data bytes (Dual Output SPI) */ @@ -187,6 +188,7 @@ /* Status Register 2 bits. */ #define SR2_QUAD_EN_BIT7 BIT(7) +#define SR2_QUAD_EN_BIT1 BIT(1) /* Winbond Quad I/O */ /* * Maximum number of flashes that can be connected From patchwork Wed Dec 6 09:31:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872523 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=aAYDr5Sn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXKQ5yy5z1ySd for ; Wed, 6 Dec 2023 20:34:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E07F987737; Wed, 6 Dec 2023 10:32:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="aAYDr5Sn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7584E87736; Wed, 6 Dec 2023 10:32:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f403:2416::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2FA41876F4 for ; Wed, 6 Dec 2023 10:32:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e9Hb9Q5LLkbiRwPlLgSAa31cKoKRboG138B7+xdGINUw4k7Iz2kP621sOQoUxYaMWxI39l3+zZywYiM82yb5jqEq4T+EzI0qr/cQjFXSOpxXtmFXjSl2VOc0zRAveqHuFHRRQ16OTrYu/G/rttKlS2/CqnpCqfJYZwwpwAu1xMplPM7SXIhj3hJ6ZLRu5+MSJYRy+FWapEVsoyYYacvzHXBPY6XPmlynoqOBg3bLXtmhwXirSJKWHv6asiK7+5uiyNeofZluPwY1TKJftFC3h/2pwmhPLGwM3r6jhY4T/sfPcC0tACFRdM+l/B8OH1rHJbSb4QVfRUFz875d4ACcXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=naXvD4xYEVWBAvpwru5R2DFlL4rkkKOiEHMTWrRdhlA=; b=NFrfr7/8wdD1TaHTPhIOIbgf2maYIbJKOj5OfWGfJQpSemlcC4zp9jLfzv2ubqkYMJijMxawgDrCfcVi3dED8yk8oV1BtZk1gcFYbvIb6axKuKx7lT0SpPWPEpB5nZysyV4DCmwW4ATnyh3k5vGDn5/gwmbWjPb92mPWU8qMP1KxjzTBu8zWxPUrAt3avL03p4Dx3GgTo9ddXXd/RNKxgmuvMAIQWD2FcK8EbFimY47nON7F3WujM1EC4O5Z8k5+7DCVgw86xjyEZQGBEEPyx/vm8YKks+byxlflkMlQiUZSsdbpRfdySxsS93lxJiYaF0/5u4ej2Nr72Ue9YmfqZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=naXvD4xYEVWBAvpwru5R2DFlL4rkkKOiEHMTWrRdhlA=; b=aAYDr5SniC7fhfsLRQqva02J3fUJXNCljidmcE9xmMuRNHmGK7y5BQrX7szUafCuwBpiXMKA6GQImC0Sjn4ahsMyYBMAZfOKL+b7CsJ5lSjgcHW3MolMwo0dPsODElVymqt+6/Imi/EPfMcPgyPDE1KER/maOARrae1WOYvUrhg= Received: from DM6PR18CA0007.namprd18.prod.outlook.com (2603:10b6:5:15b::20) by LV2PR12MB5919.namprd12.prod.outlook.com (2603:10b6:408:173::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:32:27 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::2a) by DM6PR18CA0007.outlook.office365.com (2603:10b6:5:15b::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:32:27 +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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:27 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Wed, 6 Dec 2023 03:32:27 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:26 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:23 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" , Amit Kumar Mahapatra Subject: [PATCH v2 11/30] mtd: spi-nor: Send write disable cmd after every write enable Date: Wed, 6 Dec 2023 15:01:22 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|LV2PR12MB5919:EE_ X-MS-Office365-Filtering-Correlation-Id: b6c04af0-6ed2-475d-2d89-08dbf63e431a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NTmMiM3X2ol4X8X2IdetTNNFSdhaxVlHVly//hPVx1FZ/SSGQaUZbXHtujUdgEG0qm50aga+mZ77/DGImw18A5TI86VedioaP2pC2CSHaf2o+6EcWkgYJzP+q6xIbNGnD5SMywrYYOKitde3zDzBJXS3S3Qp+tTsP5NANbVpuZ6R2VTGVLq30oXxDqaqR/DTEYaF3d3Ar8cLktPs2ZnPGA4f5gg/cTn92ZDAsMd4nnCCwzsclJUS3JyNEI22ZWP0C/ApMyL+T1LTe3n0qTyJUrtFkExfibCrVUEDdktK/qjL0NtlY1cvLVHfwXYUhV0KwXBpAd2ch/enoZk2pBFbvA61E+Scaojkru9uyR9ZQ+JnY9uFiijk5o4auSuKlX9SXKzRsf6o/RjF5pryYjRzWMZ3vxyDs6x7JAP/VvWI6hYgX57t4C3LH1xQQwCLrQsHcccPK0z4oXy3m6bZl0E9fJfPEYu9DiWKHwa0Rj2cE+l5IS2Bxnibp6XcK2WHX23lIcOZAS6Y49oUSHKysdSKQ/Fr380nLkDulhKFKe5iSWwk5q37OAH0c6OjD+qFBhH4Yy1ez9F+QtkZO8UAIQ83t6HhZIT2KKxHMbcdOEDvLxBQAy6+5z/K7opZ1P7sFyq9WsXOxezwG9Oj5sJA/klrHMz206TocQLqy81ZuvasybR7GFM3dFsErQmT8J4C9kKs2OUxYWRL0VUf5VznWMRScVaRqhpPw/tKuLYcq81TuI9Rs201bND0sMLve9euHJknkKSAHCDBKQWYZOQuni6vwg== 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:(13230031)(4636009)(39860400002)(346002)(376002)(396003)(136003)(230922051799003)(186009)(82310400011)(1800799012)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(70206006)(336012)(6916009)(70586007)(54906003)(316002)(40460700003)(4326008)(86362001)(8936002)(36756003)(8676002)(81166007)(478600001)(356005)(2906002)(2616005)(83380400001)(26005)(47076005)(41300700001)(426003)(36860700001)(82740400003)(5660300002)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:27.6157 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6c04af0-6ed2-475d-2d89-08dbf63e431a 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5919 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Write enable(06h) command will be sent to a flash device to set the write enable latch bit before every program, erase, write command. After that write disable command (04h) needs to be sent to clear the write enable latch. This write_disable() is missing at the majority of the places in the driver, add it to clear write enable latch. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar Acked-by: Amit Kumar Mahapatra --- drivers/mtd/spi/spi-nor-core.c | 47 +++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 454ae6cd4e..d790116994 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -873,6 +873,7 @@ static int spi_nor_wait_till_ready(struct spi_nor *nor) static int clean_bar(struct spi_nor *nor) { u8 cmd, bank_sel = 0; + int ret; if (nor->bank_curr == 0) return 0; @@ -880,7 +881,11 @@ static int clean_bar(struct spi_nor *nor) nor->bank_curr = 0; write_enable(nor); - return nor->write_reg(nor, cmd, &bank_sel, 1); + ret = nor->write_reg(nor, cmd, &bank_sel, 1); + if (ret) + return ret; + + return write_disable(nor); } static int write_bar(struct spi_nor *nor, u32 offset) @@ -1070,11 +1075,15 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) nor->spi->flags &= ~SPI_XFER_U_PAGE; } } + if (nor->addr_width == 3) { #ifdef CONFIG_SPI_FLASH_BAR - ret = write_bar(nor, addr); - if (ret < 0) - goto erase_err; + /* Update Extended Address Register */ + ret = write_bar(nor, addr); + if (ret < 0) + goto erase_err; #endif + } + ret = write_enable(nor); if (ret < 0) goto erase_err; @@ -1195,6 +1204,10 @@ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) if (ret) return ret; + ret = write_disable(nor); + if (ret) + return ret; + ret = read_sr(nor); if (ret < 0) return ret; @@ -1758,13 +1771,18 @@ static int sst26_lock_ctl(struct spi_nor *nor, loff_t ofs, uint64_t len, enum lo if (ctl == SST26_CTL_CHECK) return 0; + /* Write latch enable before write operation */ + ret = write_enable(nor); + if (ret) + return ret; + ret = nor->write_reg(nor, SPINOR_OP_WRITE_BPR, bpr_buff, bpr_size); if (ret < 0) { dev_err(nor->dev, "fail to write block-protection register\n"); return ret; } - return 0; + return write_disable(nor); } static int sst26_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) @@ -2138,7 +2156,7 @@ static int write_sr_cr(struct spi_nor *nor, u8 *sr_cr) return ret; } - return 0; + return write_disable(nor); } /** @@ -4248,6 +4266,7 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *nor) static int spi_nor_init(struct spi_nor *nor) { + u8 sr2; int err; if (nor->flags & SNOR_F_HAS_PARALLEL) @@ -4271,6 +4290,22 @@ static int spi_nor_init(struct spi_nor *nor) write_enable(nor); write_sr(nor, 0); spi_nor_wait_till_ready(nor); + + if (JEDEC_MFR(nor->info) == SNOR_MFR_WINBOND) { + write_enable(nor); + sr2 = 0; + err = nor->write_reg(nor, + SPINOR_OP_WIN_WRSR2, &sr2, 1); + if (err < 0) { + dev_dbg(nor->dev, + "error while writing SR-2 register\n"); + return -EINVAL; + } + spi_nor_wait_till_ready(nor); + } + err = write_disable(nor); + if (err) + return err; } if (nor->quad_enable) { From patchwork Wed Dec 6 09:31:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872524 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=UVe4CcaC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXKc65sbz1ySd for ; Wed, 6 Dec 2023 20:34:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1B32876F4; Wed, 6 Dec 2023 10:32:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="UVe4CcaC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2AD928774E; Wed, 6 Dec 2023 10:32:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on20610.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::610]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 815E7871D7 for ; Wed, 6 Dec 2023 10:32:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KhlRCgE7qqEtvTsFcXpFajEHxlPEaNetot4fwvEQIZ16ejX0pavPXsjy5HUGPHBTruesjuJaRVaHEnqc1afcZOeAu5EOuV8KMcknUe4QtDtGMNYCntRrRjRjWyGNqjhlWWeR/LNTzKF6M3Tmk/pO7zgsjTWbEkdp77003PVnSNmnCOkLMlWny4YECzznYSS0VLqLv2blJpqy3urtTf88ihHa5Kg82STiHEGZ0xb4okd/agMipR7UG9ymz7DrDJmHD5rmxnmW7cxxVzMJaSE4wE+ydlOWeUK4SXHCXCwmAeFvN7vCc+vVZKzjI5z3Rzdf55VmtrjzPS3zZPrIu13uEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=37KMg7rdKxOezDj5+ToXT+phTsTTCsUSc6zqKwz/H04=; b=OyWuk7dkEcluvWoFnW0GiNtCwMRGn/RCrrsmtd7G3iV7Jx2XaS3gmIPyoNQwhJ+r/5f4xJWYmHmAZbtvDKOvWIDE2NUkHhW/LHDQerTwFsqqcsAP5EIekT5JpO5jsIrHKMunIWNfF0R0JmdWK5vb95PD0EPSe6Tw7ZuwLAnx3RWVLiJDhRu9meI0lqoJPdS5y9zluC4E9/1V3oOTuzAPjWfy7P+qzdbOBpgasl3tkxNQsokvwX8M7IZMbDpiEOJyNNDW6PQmTG45vgCYVbnz6pN52odMDwNBUQS36Io1Sx3Bms9oVVEpqr+78aQyGSHpK3FLDrEWGGmOcucOteKrnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=37KMg7rdKxOezDj5+ToXT+phTsTTCsUSc6zqKwz/H04=; b=UVe4CcaCVsbwAZZjs2ohO/+1EIXlFAc+yooq1yMUwRP64Y1gyPU5ZgZGgPFDU/wMRpa5f7DtRNYGQZ+lhYdwF7qyxWIPt9Q4sLr172SB4E6Wa9cGppO0WuV91rL/sjKBhteCgw5Hp3gpGFfAiabyi8urE3TyuqHiu3y+piWH/LE= Received: from DM6PR10CA0002.namprd10.prod.outlook.com (2603:10b6:5:60::15) by DM3PR12MB9436.namprd12.prod.outlook.com (2603:10b6:8:1af::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.37; Wed, 6 Dec 2023 09:32:31 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:5:60:cafe::15) by DM6PR10CA0002.outlook.office365.com (2603:10b6:5:60::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:32:30 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:30 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Wed, 6 Dec 2023 03:32:29 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:29 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:27 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH v2 12/30] mtd: spi-nor: Update erase operation function Date: Wed, 6 Dec 2023 15:01:23 +0530 Message-ID: <3668c374b4c13124ef4bf697aeab62159a1ba9df.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|DM3PR12MB9436:EE_ X-MS-Office365-Filtering-Correlation-Id: 8259c06c-8dcb-41ca-63eb-08dbf63e44b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+AumDPgKtKyJf+6raRkl9MmHpToaRT6KUp65Koa9WUpKFPgtMirLXc4O/DFQrt/3rzWCV3hvNsQq1TrogPgqD3iF00zrmLPOtDIYAlYrIvrjQPdmq8poUGEs2P5m/p3VAlFA4lVgUV6jOuAMgVwSVjOj3gnH3pbnFH+4pa4GcyTQxt0Xyr3c2mdBXs2yXmLCw0E8VWHYcxmbhjkp5r4QC0EyVtp3Qp3JbKAKfAWDwRvDjY+TkfkqI0syzG1VDwrbKYcF1iHFAWMP3Xx+sr7QsDVcO2PFmCT1qs3TRM4rczPeAOTkd0nCHOYr/YcgRqE9af0P3yjiJ302DDOu/mI+VOkNsU4l1r4erV/DPDFbberUauH+Fo9ryXcdPt+JDTKCm2Zvn8sIbjYGnP46PwQYUCPUkTYMvy5KXnHwgmd8l/RiyEUAWtKDXMcKT4euylWzo4eQLRPnWSbPab4JemI+2oUrrWen8Ngz9OItZzVVzCzdTkeYaZgg3DnmvKq51hB1IAiQYEgqJkYQA31JyG2Qurw/2yNpNdnJx+Z1p/l7P8ArmpQWD/TVnpuVLI38VCI70WsWWi1KKjjLgvnvx5YmzJQUk3KRz/7IkM/mTzKYMBNZfnDugNMHjQ3Oc1O5qhx1ECnBRkeuFEGubaUiqA0mmKY5HEENciW2dRVo/PCENCZRa/S9am1WXHdT+8Q/PG9sIFW9xdF8SO7ujxFo5k4K3F5hujb/X6HqD3DD0Vr+gzOEz9vW7fclxu6VRVT3AkhqJhim4EZbhXbfoT7n2hqqQ== 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:(13230031)(4636009)(136003)(39860400002)(376002)(346002)(396003)(230922051799003)(451199024)(186009)(64100799003)(82310400011)(1800799012)(40470700004)(46966006)(36840700001)(6916009)(70586007)(70206006)(54906003)(66899024)(8676002)(8936002)(4326008)(316002)(478600001)(40460700003)(6666004)(5660300002)(15650500001)(41300700001)(36756003)(2906002)(86362001)(426003)(336012)(26005)(2616005)(107886003)(40480700001)(83380400001)(82740400003)(36860700001)(81166007)(356005)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:30.2819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8259c06c-8dcb-41ca-63eb-08dbf63e44b3 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR12MB9436 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean If the system is in a dual parallel configuration, it's necessary to halve the erase size since the erase command operates on two flashes simultaneously. When dealing with a dual-stacked configuration, determine whether the erase offset refers to the top or bottom flash, and subsequently, adjust the flag for the relevant flash. Consequently, the argument for the spi_nor_erase_sector function has been modified from addr to offset. Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index d790116994..43435e79cc 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -1078,7 +1078,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) if (nor->addr_width == 3) { #ifdef CONFIG_SPI_FLASH_BAR /* Update Extended Address Register */ - ret = write_bar(nor, addr); + ret = write_bar(nor, offset); if (ret < 0) goto erase_err; #endif @@ -1092,7 +1092,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) !(nor->flags & SNOR_F_NO_OP_CHIP_ERASE)) { ret = spi_nor_erase_chip(nor); } else { - ret = spi_nor_erase_sector(nor, addr); + ret = spi_nor_erase_sector(nor, offset); } if (ret < 0) goto erase_err; From patchwork Wed Dec 6 09:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872525 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2K5W1idi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXKr0998z1ySd for ; Wed, 6 Dec 2023 20:34:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2191886EEE; Wed, 6 Dec 2023 10:32:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="2K5W1idi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1655E86CF4; Wed, 6 Dec 2023 10:32:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F269887771 for ; Wed, 6 Dec 2023 10:32:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cpMDHneoa3HvIjXWEntFCbEKzW/6IHyi85ueGcy7bCW4w1QWLY8NVbGq2S+NBI243uoITVTn2snMcVc7K4biDOjvdugzmSRynoA/ElYtp88AcHlNUv8Nficff3ZSID2FgZ1bN5LYRUJQAwO5j1KJujmxuSyPg1km8C3fIJnDvPqUN+q6lqzL6QfMQjslHUti+UVWy1QumS8WLThBG6BsyXqfcPUgnWlvl1XvVTRebcKQzo29KkLM5IVp90s2CC+KwhsOs8TCaa/wciQCKWQDE/8VQJBwDn+O3XppRV/rOnfb7rjn1maZ+zXdQ2a/hvGG2GRq2mwtMVx0UShCZMJJ0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0IRSubOpM741MuPWxoyEHPROr10vNA5mqzQNVj454C0=; b=Cu0oC/DZrpDFY23weoLAcFZSQDmpuJmxRpdTIZIRGJjhawikiNpqoJkVb/zsCTXeiIdgmImNfqS8aQJyDComkD+5vHfMpCycGmDop4ZIJyJUjKjrUl0F8KnDGGe37UM4u/Yv45pQkLldDb0yU23gXUdwlzIRK9kOuTtM6+wI1KQK4tkvEQ8zbOfVo1e8hjxP0Um3Ry+MtRrv5z3zPLV5Gp5fdG4U6tqWLLrVaABf0f49fre1ThYX0ks5DNhL1H2Z/4Vg+14Iel+WxI0z8f+bJKpUCON+W9+W8zdGUfN2RzU1XSOo6KyC5NR5SuePITcXo46Y6kPEDQ2GVKSeKLZx7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=0IRSubOpM741MuPWxoyEHPROr10vNA5mqzQNVj454C0=; b=2K5W1idi57AmopyjP/KE4c3eeIX2jSd6TZtD/2m/VCUMOt4K4QAWtPxWEx+doc4WnC+gOr4SBeY2vty7sUMfcgDy5/jWG+O5WJFIsm2vBjmWVKw+QSLQjuCZr3YL3tvHrx3nfNm42yqbVqjpYLdpg+bjlTrwpeaD+nnW65aocPM= Received: from CYZPR02CA0012.namprd02.prod.outlook.com (2603:10b6:930:a1::7) by SJ0PR12MB8113.namprd12.prod.outlook.com (2603:10b6:a03:4e0::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.36; Wed, 6 Dec 2023 09:32:33 +0000 Received: from CY4PEPF0000EE3A.namprd03.prod.outlook.com (2603:10b6:930:a1:cafe::bc) by CYZPR02CA0012.outlook.office365.com (2603:10b6:930:a1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25 via Frontend Transport; Wed, 6 Dec 2023 09:32:33 +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 CY4PEPF0000EE3A.mail.protection.outlook.com (10.167.242.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:33 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Wed, 6 Dec 2023 03:32:32 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:31 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:29 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 13/30] mtd: spi-nor: Check SNOR_F_IO_MODE_EN_VOLATILE only if SFDP is enabled Date: Wed, 6 Dec 2023 15:01:24 +0530 Message-ID: <283fdb83bc6d91c1598d6fb56b21f9651932acd3.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3A:EE_|SJ0PR12MB8113:EE_ X-MS-Office365-Filtering-Correlation-Id: e1a0b6c0-1437-46a3-feae-08dbf63e4692 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: L9EywoCQYiH5EHi1qF91e6ppJ0+DARQQjy7/F14W0dZm8esGATTqsrBrq72SLhrizkj1A7jy3gbEt8fUT3cw18bW1QeX1JKHjukqE0y+QIskv5iNM/nmmV52TOeXsABxWUkRRsyJKhdmtEJrONOlQ+6sjlpRvGWiU2VyKXQTgKDxorFYRAwiazeF/VQpCJzweelCKIu2HNUv7AlHDpyiWoQ4xOKutr0HLtLv4O6gE1IhucG7ed71/MD7u+j/bYEzErtJTdEO/BiL26cRGBWwELxG0giwbjW4mD11ytlh5vABNFhI2o1ozyr9ilztDyYC+YI3iva/+4yQcE768ahBZn/7kFzRITwneGzXBjypM5bLmwo6P9dW0VWxzAsy/vpv/VeAMexPzGQKrTk8aGQ8UVXiLEJEgapE+KvgVydDQJeWFtGMi8eUIJCTWD1IDE6PTiQQOPMJ9DTTNQx/tn+7rsoIdBczCWbZwPEE+Hg6VlmRbl8EftEx5lpcCTkCw2ZeFvHn1JeiM8REANohHBLKu2daE9Pj5Ah0XcpZd5r5bKPh8+uFoU2KeXGuwRAEeW+2JnS8W89lxHuOSqSEr2V5VftDAGlEW8hDRLImU+7vSh7DH7JBSI4WfWhscDUoj5Un/CBh9ZLbp1548Vc8HmXfVOA6DHzN5hQwLYZlBbRzkufaTfxY3M22UlNlboNHJuuD6g8DtgtEQFCvajDQow7i4Vmmj0mjYaTQiB/BFyrcbjCtaGu7CGIcoz7bLc1pJ+NCucqKeho0yPyVYZJ6jMoJlw== 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:(13230031)(4636009)(136003)(376002)(396003)(39860400002)(346002)(230922051799003)(82310400011)(186009)(64100799003)(451199024)(1800799012)(40470700004)(46966006)(36840700001)(5660300002)(41300700001)(2906002)(54906003)(6916009)(316002)(4326008)(8676002)(8936002)(40480700001)(478600001)(6666004)(336012)(36860700001)(426003)(26005)(83380400001)(2616005)(70206006)(40460700003)(47076005)(70586007)(82740400003)(356005)(81166007)(86362001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:33.0813 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e1a0b6c0-1437-46a3-feae-08dbf63e4692 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: CY4PEPF0000EE3A.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB8113 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma With 'commit bebdc237507c ("mtd: spi-nor: Parse SFDP SCCR Map")', support for spi_nor_parse_sccr is added under SFDP. But the flag SNOR_F_IO_MODE_EN_VOLATILE in spi_nor_octal_dtr_enable is always checked. Check this flag only if SPI_FLASH_SFDP_SUPPORT enabled. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 43435e79cc..ccda722df5 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -4252,8 +4252,9 @@ static int spi_nor_octal_dtr_enable(struct spi_nor *nor) nor->write_proto == SNOR_PROTO_8_8_8_DTR)) return 0; - if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE)) - return 0; + if (CONFIG_IS_ENABLED(SPI_FLASH_SFDP_SUPPORT)) + if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE)) + return 0; ret = nor->octal_dtr_enable(nor); if (ret) From patchwork Wed Dec 6 09:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872527 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2++FmUJn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (unknown [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXLV4G7tz1ySd for ; Wed, 6 Dec 2023 20:34:58 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 765E087717; Wed, 6 Dec 2023 10:32:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="2++FmUJn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 278CA8775A; Wed, 6 Dec 2023 10:32:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::605]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4156B87796 for ; Wed, 6 Dec 2023 10:32:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IsVQFvpC0ls5FNise0+yt1gLI3QB64k9SkCNTOROnckvxA+kRlUmwcIvk2duiOLFRADeKTmULnTrTDJLFKJnghtPf9uul5sLaqMZOmxYKBkSn7EFfHP7YjZttpmi+NE63wmUT2Wb3Sem30/EpXymr8AWC7fHZWCyI/CoJk4haVSywaDhgF0RjWBfAkbaFMa3BKruT/JbnslhbAHNu/7hXxVs0eOvT245T4/vU01xd4QibLR1pavoBrPaXXUIrNIsRdyifa29DmykDlT1TCxl6EMIL7/4yrjJAlWGLjbxEsF78Uy1z/brhOU8E8bV/L2zTFsDARi2egTgOeUUbsq+WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=QPekjedamzi/kBt0qC3u3Teka5WYvjawg6gHGuSIdfM=; b=bTS2b4jMgS4ypAeueZSSE2sSOFBYt9+9uzXUKwPgpNYIvncnixF9PX2oKTgDnPJ5cA+3OU/ad1GMk01/tOCq3r5A6+UobVNr6C/lv0zJoeJ/I4QRorpd7YKP+Ns1Q/1uj4rTnO2t2iFpQEGQ6IbaHnBIK9VxW78EFpA27W/ZDZtGNSrjzwIFYM591dteI0E0Mr2FqjhnjuNwR/eIEZJnMPIB3BxK8LUlohdhdc2qzp34GHyG8FuPFMJjwxe0IKm0Bod+PmJTWLgaZA+KkgDwYVC6pg3CwBnDcv0lwXkWLyrx+myU114NsYjAtyHMdA5mZA9hBeStHDSaANA0Lcs2fQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=QPekjedamzi/kBt0qC3u3Teka5WYvjawg6gHGuSIdfM=; b=2++FmUJnFW7vzT5rSbAOoMqZVmxpqjyUeSKgRG+UJ8RRCfeBizVreeoXSD8TaswwbLBUbzLdwAIavcYahdkVKovHrLLSYEWdOZE35chQeHhwCdCGoN+imiiqqLdugS3ZivaEwAsPf4pEhb6FUXFUVoEhvpo5R0jUGy165qwtr+w= Received: from BL0PR01CA0013.prod.exchangelabs.com (2603:10b6:208:71::26) by PH8PR12MB6721.namprd12.prod.outlook.com (2603:10b6:510:1cc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:32:37 +0000 Received: from BL6PEPF0001AB55.namprd02.prod.outlook.com (2603:10b6:208:71:cafe::d1) by BL0PR01CA0013.outlook.office365.com (2603:10b6:208:71::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.30 via Frontend Transport; Wed, 6 Dec 2023 09:32:36 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB55.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:36 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:35 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:34 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:32 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Ashok Reddy Soma Subject: [PATCH v2 14/30] spi: cadence_qspi: Setup ddr mode in cadence qspi driver Date: Wed, 6 Dec 2023 15:01:25 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB55:EE_|PH8PR12MB6721:EE_ X-MS-Office365-Filtering-Correlation-Id: 2bfe1c3a-e337-4f69-8e09-08dbf63e4833 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dL4lfUZszR1y1+NvsB4bP5vlAjjgY9LXt3gHBkmCKl+OoIXJNFLSjNAyyaDkXr9VY6FppD8x+NwRafhTBdHfRIV23Fh9E6mKACCbScjpxkKjoVs9sqDk8Ta0SOKQadciB4YoFo21FaqnEuJQ3zeUCecPxDTdAi/KdnCWKOZjnA3KNhcWvQJYPI0pQlrPkYQQO3ySTJr/+IU9svWNqIcSXZqyE9Ex8NMlOQ/D//p9EO8vd/pDprDzu/2LbobEYD5iQL//Nsy8qrkonxSTyoCrmvGbRRI1AvdXVU//AYgEZPAvfaDxt7FRrHALaUwdB7d26mmLQozPvKtPLaPaYRbUQgDFFX3DAYyZaR6kYvU6/htHh/qPxavcgpKwjicYrqQObLAOAPuROfHaRAs3xGjxKKWxT6rAwE+dck0vIQiAPPQkDUpFvvWzQYnwCQQY9uDwom7yqjvc2MWUSEdMD+ROzwPn1r0732PQSopIbZCSXXaVJx4y4ZouCFFLSNmJ7piTWA0WOoqdfyAywyjIcbIFZXsb1Bp3w5x1mcJ0e7pcD/kIpsDBh1//g7qwBHTojOdaAq4N/nPEvb7o6u+XBirJHngcmdnYUf4mimI1RxSNzI9g1yrsYdDdJv7u6JEL+QGKAZ2fqOsFsYxYOFNkO0RBQkaDU13h/PGg6/okk96fBet4IbPO1odFB7TYFRM8X2n/43qdrHtiCnNExDrB4ZgAy1mmJ/jFZlpy8St2vpWTW9ZTqLgc3M+v9FbZ6S/nTgl/ip2JlGMfvKXkPPxhvFbgoA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(346002)(39860400002)(376002)(230922051799003)(451199024)(186009)(64100799003)(82310400011)(1800799012)(46966006)(40470700004)(36840700001)(82740400003)(30864003)(5660300002)(2906002)(36860700001)(41300700001)(86362001)(356005)(36756003)(478600001)(81166007)(2616005)(6666004)(26005)(47076005)(8936002)(8676002)(70586007)(426003)(70206006)(336012)(6916009)(54906003)(83380400001)(316002)(4326008)(40460700003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:36.1863 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2bfe1c3a-e337-4f69-8e09-08dbf63e4833 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB55.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB6721 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy To switch the OSPI controller from SDR to DDR mode, the RX delay should be configured through flash tuning. Begin by establishing a constant value for the TX delay and then increase the RX delay by inspecting the flash IDs. To fine-tune the RX delay, compare the flash IDs with a set of predetermined "golden" flash IDs. This tuning process is borrowed from the Linux Cadence driver. Moreover, make the necessary adjustments in the DDR PHY setup to facilitate the transition from SDR to DDR mode within the OSPI controller. Signed-off-by: Ashok Reddy Soma Signed-off-by: T Karthik Reddy Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_ospi_versal.c | 25 +++ drivers/spi/cadence_qspi.c | 321 +++++++++++++++++++++++++++++- drivers/spi/cadence_qspi.h | 52 +++++ drivers/spi/cadence_qspi_apb.c | 33 ++- 4 files changed, 416 insertions(+), 15 deletions(-) diff --git a/drivers/spi/cadence_ospi_versal.c b/drivers/spi/cadence_ospi_versal.c index e02a3b3de3..74994a690d 100644 --- a/drivers/spi/cadence_ospi_versal.c +++ b/drivers/spi/cadence_ospi_versal.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "cadence_qspi.h" #include @@ -129,6 +130,30 @@ int cadence_qspi_apb_wait_for_dma_cmplt(struct cadence_spi_priv *priv) return 0; } +static const struct soc_attr matches[] = { + { .family = "Versal", .revision = "v2" }, + { } +}; + +/* + * cadence_qspi_versal_set_dll_mode checks for silicon version + * and set the DLL mode. + * Returns 0 in case of success, -ENOTSUPP in case of failure. + */ +int cadence_qspi_versal_set_dll_mode(struct udevice *dev) +{ + struct cadence_spi_priv *priv = dev_get_priv(dev); + const struct soc_attr *attr; + + attr = soc_device_match(matches); + if (attr) { + priv->dll_mode = CQSPI_DLL_MODE_MASTER; + return 0; + } + + return -ENOTSUPP; +} + #if defined(CONFIG_DM_GPIO) int cadence_qspi_versal_flash_reset(struct udevice *dev) { diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c index cc3a54f295..32f91825fd 100644 --- a/drivers/spi/cadence_qspi.c +++ b/drivers/spi/cadence_qspi.c @@ -89,11 +89,21 @@ static int spi_calibration(struct udevice *bus, uint hz) /* Enable QSPI */ cadence_qspi_apb_controller_enable(base); - /* read the ID which will be our golden value */ - err = cadence_spi_read_id(priv, 3, (u8 *)&idcode); - if (err) { - puts("SF: Calibration failed (read)\n"); - return err; + if (!priv->ddr_init) { + /* read the ID which will be our golden value */ + err = cadence_spi_read_id(priv, CQSPI_READ_ID_LEN, (u8 *)&idcode); + if (err) { + puts("SF: Calibration failed (read)\n"); + return err; + } + + /* Save flash id's for further use */ + priv->device_id[0] = (u8)idcode; + priv->device_id[1] = (u8)(idcode >> 8); + priv->device_id[2] = (u8)(idcode >> 16); + } else { + idcode = priv->device_id[0] | priv->device_id[1] << 8 | + priv->device_id[2] << 16; } /* use back the intended clock and find low range */ @@ -109,7 +119,7 @@ static int spi_calibration(struct udevice *bus, uint hz) cadence_qspi_apb_controller_enable(base); /* issue a RDID to get the ID value */ - err = cadence_spi_read_id(priv, 3, (u8 *)&temp); + err = cadence_spi_read_id(priv, CQSPI_READ_ID_LEN, (u8 *)&temp); if (err) { puts("SF: Calibration failed (read)\n"); return err; @@ -190,6 +200,20 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz) return 0; } +static int cadence_spi_child_pre_probe(struct udevice *bus) +{ + struct spi_slave *slave = dev_get_parent_priv(bus); + + slave->bytemode = SPI_4BYTE_MODE; + + return 0; +} + +__weak int cadence_qspi_versal_set_dll_mode(struct udevice *dev) +{ + return -ENOTSUPP; +} + static int cadence_spi_probe(struct udevice *bus) { struct cadence_spi_plat *plat = dev_get_plat(bus); @@ -247,6 +271,14 @@ static int cadence_spi_probe(struct udevice *bus) priv->qspi_is_init = 1; } + priv->edge_mode = CQSPI_EDGE_MODE_SDR; + priv->dll_mode = CQSPI_DLL_MODE_BYPASS; + + /* Select dll mode */ + ret = cadence_qspi_versal_set_dll_mode(bus); + if (ret == -ENOTSUPP) + debug("DLL mode set to bypass mode : %x\n", ret); + priv->wr_delay = 50 * DIV_ROUND_UP(NSEC_PER_SEC, priv->ref_clk_hz); /* Versal and Versal-NET use spi calibration to set read delay */ @@ -290,6 +322,279 @@ static int cadence_spi_set_mode(struct udevice *bus, uint mode) return 0; } +static int cadence_qspi_rx_dll_tuning(struct cadence_spi_priv *priv, + u32 txtap, u8 extra_dummy) +{ + void *regbase = priv->regbase; + int ret, i, j; + u8 id[CQSPI_READ_ID_LEN + 1], min_rxtap = 0, max_rxtap = 0, avg_rxtap, + max_tap, windowsize, dummy_flag = 0, max_index = 0, min_index = 0; + s8 max_windowsize = -1; + bool id_matched, rxtapfound = false; + struct spi_mem_op op = + SPI_MEM_OP(SPI_MEM_OP_CMD(CQSPI_READ_ID | (CQSPI_READ_ID << 8), 8), + SPI_MEM_OP_NO_ADDR, + SPI_MEM_OP_DUMMY(8, 8), + SPI_MEM_OP_DATA_IN(CQSPI_READ_ID_LEN, id, 8)); + + op.cmd.nbytes = 2; + op.dummy.nbytes *= 2; + op.cmd.dtr = true; + op.addr.dtr = true; + op.data.dtr = true; + + max_tap = CQSPI_MAX_DLL_TAPS; + /* + * Rx dll tuning is done by setting tx delay and increment rx + * delay and check for correct flash id's by reading from flash. + */ + for (i = 0; i <= max_tap; i++) { + /* Set DLL reset bit */ + writel((txtap | i | CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK), + regbase + CQSPI_REG_PHY_CONFIG); + /* + * Re-synchronisation delay lines to update them + * with values from TX DLL Delay and RX DLL Delay fields + */ + writel((CQSPI_REG_PHY_CONFIG_RESYNC_FLD_MASK | txtap | i | + CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK), + regbase + CQSPI_REG_PHY_CONFIG); + /* Check lock of loopback */ + if (priv->dll_mode == CQSPI_DLL_MODE_MASTER) { + ret = wait_for_bit_le32 + (regbase + CQSPI_REG_DLL_LOWER, + CQSPI_REG_DLL_LOWER_LPBK_LOCK_MASK, 1, + CQSPI_TIMEOUT_MS, 0); + if (ret) { + printf("LOWER_DLL_LOCK bit err: %i\n", ret); + return ret; + } + } + + ret = cadence_qspi_apb_command_read_setup(priv, &op); + if (!ret) { + ret = cadence_qspi_apb_command_read(priv, &op); + if (ret < 0) { + printf("error %d reading JEDEC ID\n", ret); + return ret; + } + } + + id_matched = true; + for (j = 0; j < CQSPI_READ_ID_LEN; j++) { + if (priv->device_id[j] != id[j]) { + id_matched = false; + break; + } + } + + if (id_matched && !rxtapfound) { + if (priv->dll_mode == CQSPI_DLL_MODE_MASTER) { + min_rxtap = + readl(regbase + CQSPI_REG_DLL_OBSVBLE_UPPER) & + CQSPI_REG_DLL_UPPER_RX_FLD_MASK; + max_rxtap = min_rxtap; + max_index = i; + min_index = i; + } else { + min_rxtap = i; + max_rxtap = i; + } + rxtapfound = true; + } + + if (id_matched && rxtapfound) { + if (priv->dll_mode == CQSPI_DLL_MODE_MASTER) { + max_rxtap = + readl(regbase + + CQSPI_REG_DLL_OBSVBLE_UPPER) & + CQSPI_REG_DLL_UPPER_RX_FLD_MASK; + max_index = i; + } else { + max_rxtap = i; + } + } + + if ((!id_matched || i == max_tap) && rxtapfound) { + windowsize = max_rxtap - min_rxtap + 1; + if (windowsize > max_windowsize) { + dummy_flag = extra_dummy; + max_windowsize = windowsize; + if (priv->dll_mode == CQSPI_DLL_MODE_MASTER) + avg_rxtap = (max_index + min_index); + else + avg_rxtap = (max_rxtap + min_rxtap); + avg_rxtap /= 2; + } + + if (windowsize >= 3) + i = max_tap; + + rxtapfound = false; + } + } + + if (!extra_dummy) { + rxtapfound = false; + min_rxtap = 0; + max_rxtap = 0; + } + + if (!dummy_flag) + priv->extra_dummy = false; + + if (max_windowsize < 3) + return -EINVAL; + + return avg_rxtap; +} + +static int cadence_spi_setdlldelay(struct udevice *bus) +{ + struct cadence_spi_priv *priv = dev_get_priv(bus); + void *regbase = priv->regbase; + u32 txtap; + int ret, rxtap; + u8 extra_dummy; + + ret = wait_for_bit_le32(regbase + CQSPI_REG_CONFIG, + 1 << CQSPI_REG_CONFIG_IDLE_LSB, + 1, CQSPI_TIMEOUT_MS, 0); + if (ret) { + printf("spi_wait_idle error : 0x%x\n", ret); + return ret; + } + + if (priv->dll_mode == CQSPI_DLL_MODE_MASTER) { + /* Drive DLL reset bit to low */ + writel(0, regbase + CQSPI_REG_PHY_CONFIG); + + /* Set initial delay value */ + writel(CQSPI_REG_PHY_INITIAL_DLY, + regbase + CQSPI_REG_PHY_MASTER_CTRL); + /* Set DLL reset bit */ + writel(CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK, + regbase + CQSPI_REG_PHY_CONFIG); + + /* Check for loopback lock */ + ret = wait_for_bit_le32(regbase + CQSPI_REG_DLL_LOWER, + CQSPI_REG_DLL_LOWER_LPBK_LOCK_MASK, + 1, CQSPI_TIMEOUT_MS, 0); + if (ret) { + printf("Loopback lock bit error (%i)\n", ret); + return ret; + } + + /* Re-synchronize slave DLLs */ + writel(CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK, + regbase + CQSPI_REG_PHY_CONFIG); + writel(CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK | + CQSPI_REG_PHY_CONFIG_RESYNC_FLD_MASK, + regbase + CQSPI_REG_PHY_CONFIG); + + txtap = CQSPI_TX_TAP_MASTER << + CQSPI_REG_PHY_CONFIG_TX_DLL_DLY_LSB; + } + + priv->extra_dummy = false; + for (extra_dummy = 0; extra_dummy <= 1; extra_dummy++) { + if (extra_dummy) + priv->extra_dummy = true; + + rxtap = cadence_qspi_rx_dll_tuning(priv, txtap, extra_dummy); + if (extra_dummy && rxtap < 0) { + printf("Failed RX dll tuning\n"); + return rxtap; + } + } + debug("RXTAP: %d\n", rxtap); + + writel((txtap | rxtap | CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK), + regbase + CQSPI_REG_PHY_CONFIG); + writel((CQSPI_REG_PHY_CONFIG_RESYNC_FLD_MASK | txtap | rxtap | + CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK), + regbase + CQSPI_REG_PHY_CONFIG); + + if (priv->dll_mode == CQSPI_DLL_MODE_MASTER) { + ret = wait_for_bit_le32(regbase + CQSPI_REG_DLL_LOWER, + CQSPI_REG_DLL_LOWER_LPBK_LOCK_MASK, + 1, CQSPI_TIMEOUT_MS, 0); + if (ret) { + printf("LOWER_DLL_LOCK bit err: %i\n", ret); + return ret; + } + } + + return 0; +} + +static int priv_setup_ddrmode(struct udevice *bus) +{ + struct cadence_spi_priv *priv = dev_get_priv(bus); + void *regbase = priv->regbase; + int ret; + + ret = wait_for_bit_le32(regbase + CQSPI_REG_CONFIG, + 1 << CQSPI_REG_CONFIG_IDLE_LSB, + 1, CQSPI_TIMEOUT_MS, 0); + if (ret) { + printf("spi_wait_idle error : 0x%x\n", ret); + return ret; + } + + /* Disable QSPI */ + cadence_qspi_apb_controller_disable(regbase); + + /* Disable DAC mode */ + if (priv->use_dac_mode) { + clrbits_le32(regbase + CQSPI_REG_CONFIG, + CQSPI_REG_CONFIG_DIRECT); + priv->use_dac_mode = false; + } + + setbits_le32(regbase + CQSPI_REG_CONFIG, + CQSPI_REG_CONFIG_PHY_ENABLE_MASK); + + /* Program POLL_CNT */ + clrsetbits_le32(regbase + CQSPI_REG_WRCOMPLETION, + CQSPI_REG_WRCOMPLETION_POLLCNT_MASK, + CQSPI_REG_WRCOMPLETION_POLLCNT << + CQSPI_REG_WRCOMPLETION_POLLCNY_LSB); + + setbits_le32(regbase + CQSPI_REG_CONFIG, + CQSPI_REG_CONFIG_DTR_PROT_EN_MASK); + + clrsetbits_le32(regbase + CQSPI_REG_RD_DATA_CAPTURE, + (CQSPI_REG_RD_DATA_CAPTURE_DELAY_MASK << + CQSPI_REG_RD_DATA_CAPTURE_DELAY_LSB), + CQSPI_REG_READCAPTURE_DQS_ENABLE); + + /* Enable QSPI */ + cadence_qspi_apb_controller_enable(regbase); + + return 0; +} + +static int cadence_spi_setup_ddrmode(struct udevice *bus) +{ + struct cadence_spi_priv *priv = dev_get_priv(bus); + int ret; + + ret = priv_setup_ddrmode(bus); + if (ret) + return ret; + + priv->edge_mode = CQSPI_EDGE_MODE_DDR; + ret = cadence_spi_setdlldelay(bus); + if (ret) { + printf("DDR tuning failed with error %d\n", ret); + return ret; + } + priv->ddr_init = 1; + + return 0; +} + static int cadence_spi_mem_exec_op(struct spi_slave *spi, const struct spi_mem_op *op) { @@ -350,6 +655,9 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi, break; } + if (!priv->ddr_init && (spi->flags & SPI_XFER_SET_DDR)) + err = cadence_spi_setup_ddrmode(bus); + return err; } @@ -466,6 +774,7 @@ U_BOOT_DRIVER(cadence_spi) = { .plat_auto = sizeof(struct cadence_spi_plat), .priv_auto = sizeof(struct cadence_spi_priv), .probe = cadence_spi_probe, + .child_pre_probe = cadence_spi_child_pre_probe, .remove = cadence_spi_remove, .flags = DM_FLAG_OS_PREPARE, }; diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h index 1c59d1a9d9..eec090a7ed 100644 --- a/drivers/spi/cadence_qspi.h +++ b/drivers/spi/cadence_qspi.h @@ -10,6 +10,7 @@ #include #include #include +#include #define CQSPI_IS_ADDR(cmd_len) (cmd_len > 1 ? 1 : 0) @@ -21,6 +22,8 @@ #define CQSPI_REG_RETRY 10000 #define CQSPI_POLL_IDLE_RETRY 3 +#define CQSPI_TIMEOUT_MS 1000 + /* Transfer mode */ #define CQSPI_INST_TYPE_SINGLE 0 #define CQSPI_INST_TYPE_DUAL 1 @@ -33,6 +36,23 @@ #define CQSPI_DUMMY_BYTES_MAX 4 #define CQSPI_DUMMY_CLKS_MAX 31 +#define CQSPI_TX_TAP_MASTER 0x1E +#define CQSPI_MAX_DLL_TAPS 127 + +#define CQSPI_DLL_MODE_MASTER 0 +#define CQSPI_DLL_MODE_BYPASS 1 + +#define CQSPI_EDGE_MODE_SDR 0 +#define CQSPI_EDGE_MODE_DDR 1 + +#define SILICON_VER_MASK 0xFF +#define SILICON_VER_1 0x10 + +#define CQSPI_READ_ID 0x9F +#define CQSPI_READ_ID_LEN 3 +#define CQSPI_READID_LOOP_MAX 10 +#define TERA_MACRO 1000000000000l + /**************************************************************************** * Controller's configuration and status register (offset from QSPI_BASE) ****************************************************************************/ @@ -65,6 +85,7 @@ #define CQSPI_REG_RD_INSTR_TYPE_ADDR_MASK 0x3 #define CQSPI_REG_RD_INSTR_TYPE_DATA_MASK 0x3 #define CQSPI_REG_RD_INSTR_DUMMY_MASK 0x1F +#define CQSPI_REG_RD_INSTR_DDR_ENABLE BIT(10) #define CQSPI_REG_WR_INSTR 0x08 #define CQSPI_REG_WR_INSTR_OPCODE_LSB 0 @@ -109,9 +130,14 @@ #define CQSPI_REG_WR_COMPLETION_CTRL 0x38 #define CQSPI_REG_WR_DISABLE_AUTO_POLL BIT(14) +#define CQSPI_REG_WRCOMPLETION 0x38 +#define CQSPI_REG_WRCOMPLETION_POLLCNT_MASK 0xFF0000 +#define CQSPI_REG_WRCOMPLETION_POLLCNY_LSB 16 +#define CQSPI_REG_WRCOMPLETION_POLLCNT 3 #define CQSPI_REG_IRQSTATUS 0x40 #define CQSPI_REG_IRQMASK 0x44 +#define CQSPI_REG_ECO 0x48 #define CQSPI_REG_INDIRECTRD 0x60 #define CQSPI_REG_INDIRECTRD_START BIT(0) @@ -162,7 +188,31 @@ #define CQSPI_REG_OP_EXT_STIG_LSB 0 #define CQSPI_REG_PHY_CONFIG 0xB4 +#define CQSPI_REG_PHY_CONFIG_RESYNC_FLD_MASK 0x80000000 #define CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK 0x40000000 +#define CQSPI_REG_PHY_CONFIG_TX_DLL_DLY_LSB 16 + +#define CQSPI_REG_PHY_MASTER_CTRL 0xB8 +#define CQSPI_REG_PHY_INITIAL_DLY 0x4 +#define CQSPI_REG_DLL_LOWER 0xBC +#define CQSPI_REG_DLL_LOWER_LPBK_LOCK_MASK 0x8000 +#define CQSPI_REG_DLL_LOWER_DLL_LOCK_MASK 0x1 + +#define CQSPI_REG_DLL_OBSVBLE_UPPER 0xC0 +#define CQSPI_REG_DLL_UPPER_RX_FLD_MASK 0x7F + +#define CQSPI_REG_EXT_OP_LOWER 0xE0 +#define CQSPI_REG_EXT_STIG_OP_MASK 0xFF +#define CQSPI_REG_EXT_READ_OP_MASK 0xFF000000 +#define CQSPI_REG_EXT_READ_OP_SHIFT 24 +#define CQSPI_REG_EXT_WRITE_OP_MASK 0xFF0000 +#define CQSPI_REG_EXT_WRITE_OP_SHIFT 16 +#define CQSPI_REG_DMA_SRC_ADDR 0x1000 +#define CQSPI_REG_DMA_DST_ADDR 0x1800 +#define CQSPI_REG_DMA_DST_SIZE 0x1804 +#define CQSPI_REG_DMA_DST_STS 0x1808 +#define CQSPI_REG_DMA_DST_CTRL 0x180C +#define CQSPI_REG_DMA_DST_CTRL_VAL 0xF43FFA00 #define CQSPI_DMA_DST_ADDR_REG 0x1800 #define CQSPI_DMA_DST_SIZE_REG 0x1804 @@ -247,6 +297,7 @@ struct cadence_spi_priv { u32 tsd2d_ns; u32 tchsh_ns; u32 tslch_ns; + u8 device_id[CQSPI_READ_ID_LEN]; u8 edge_mode; u8 dll_mode; bool extra_dummy; @@ -304,6 +355,7 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv, int cadence_qspi_apb_wait_for_dma_cmplt(struct cadence_spi_priv *priv); int cadence_qspi_apb_exec_flash_cmd(void *reg_base, unsigned int reg); int cadence_qspi_versal_flash_reset(struct udevice *dev); +int cadence_qspi_versal_set_dll_mode(struct udevice *dev); void cadence_qspi_apb_enable_linear_mode(bool enable); #endif /* __CADENCE_QSPI_H__ */ diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 9ce2c0f254..d1a5a4c679 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -465,6 +465,9 @@ int cadence_qspi_apb_command_read(struct cadence_spi_priv *priv, unsigned int dummy_clk; u8 opcode; + if (priv->dtr) + rxlen = ((rxlen % 2) != 0) ? (rxlen + 1) : rxlen; + if (priv->dtr) opcode = op->cmd.opcode >> 8; else @@ -477,6 +480,9 @@ int cadence_qspi_apb_command_read(struct cadence_spi_priv *priv, if (dummy_clk > CQSPI_DUMMY_CLKS_MAX) return -ENOTSUPP; + if (priv->extra_dummy) + dummy_clk++; + if (dummy_clk) reg |= (dummy_clk & CQSPI_REG_CMDCTRL_DUMMY_MASK) << CQSPI_REG_CMDCTRL_DUMMY_LSB; @@ -553,6 +559,9 @@ int cadence_qspi_apb_command_write(struct cadence_spi_priv *priv, void *reg_base = priv->regbase; u8 opcode; + reg = cadence_qspi_calc_rdreg(priv); + writel(reg, reg_base + CQSPI_REG_RD_INSTR); + if (priv->dtr) opcode = op->cmd.opcode >> 8; else @@ -609,7 +618,6 @@ int cadence_qspi_apb_command_write(struct cadence_spi_priv *priv, int cadence_qspi_apb_read_setup(struct cadence_spi_priv *priv, const struct spi_mem_op *op) { - unsigned int reg; unsigned int rd_reg; unsigned int dummy_clk; unsigned int dummy_bytes = op->dummy.nbytes; @@ -647,6 +655,9 @@ int cadence_qspi_apb_read_setup(struct cadence_spi_priv *priv, if (dummy_clk > CQSPI_DUMMY_CLKS_MAX) return -ENOTSUPP; + if (priv->extra_dummy) + dummy_clk++; + if (dummy_clk) rd_reg |= (dummy_clk & CQSPI_REG_RD_INSTR_DUMMY_MASK) << CQSPI_REG_RD_INSTR_DUMMY_LSB; @@ -655,10 +666,10 @@ int cadence_qspi_apb_read_setup(struct cadence_spi_priv *priv, writel(rd_reg, priv->regbase + CQSPI_REG_RD_INSTR); /* set device size */ - reg = readl(priv->regbase + CQSPI_REG_SIZE); - reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK; - reg |= (op->addr.nbytes - 1); - writel(reg, priv->regbase + CQSPI_REG_SIZE); + clrsetbits_le32(priv->regbase + CQSPI_REG_SIZE, + CQSPI_REG_SIZE_ADDRESS_MASK, + op->addr.nbytes - 1); + return 0; } @@ -828,10 +839,10 @@ int cadence_qspi_apb_write_setup(struct cadence_spi_priv *priv, writel(reg, priv->regbase + CQSPI_REG_WR_COMPLETION_CTRL); } - reg = readl(priv->regbase + CQSPI_REG_SIZE); - reg &= ~CQSPI_REG_SIZE_ADDRESS_MASK; - reg |= (op->addr.nbytes - 1); - writel(reg, priv->regbase + CQSPI_REG_SIZE); + clrsetbits_le32(priv->regbase + CQSPI_REG_SIZE, + CQSPI_REG_SIZE_ADDRESS_MASK, + op->addr.nbytes - 1); + return 0; } @@ -846,6 +857,10 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, unsigned int write_bytes; int ret; + if (priv->edge_mode == CQSPI_EDGE_MODE_DDR && (n_tx % 2) != 0) + n_tx++; + remaining = n_tx; + /* * Use bounce buffer for non 32 bit aligned txbuf to avoid data * aborts From patchwork Wed Dec 6 09:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872526 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=R6aSTsG9; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXL31SFKz1ySd for ; Wed, 6 Dec 2023 20:34:35 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C8E498775A; Wed, 6 Dec 2023 10:32:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="R6aSTsG9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5D5E5877A9; Wed, 6 Dec 2023 10:32:45 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::625]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1B3928775A for ; Wed, 6 Dec 2023 10:32:43 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VuTuJqso296j9iFnL2yqefaWAgSoK9EQMTCMxamMLB9I/OpQ4jOOlyFq/J1/VkyYZOMOretcc+pJ9dwPjfCddAu++IICEGeU4tpqt8A6M3xUCTrT4IaUqW9UtxmuETF0ZLueV9l/Y1mfbaSS4UsSw6mCt2SGK8Xsybg4tRJ6TowlnxvqC+PUIh3O9779k5GeJctZgYFL0XtANy81xlzchA5aMQgK7sygWyBO2rKDqeipxTA7g/15iMyn69uzczoJCnZ4ik17ArPojbYkHUKAYy27m+1hYq+Bgd7/d+niyrYl4vo0aSaoITvrU0MXH3NBOSJS4Iqk2cP78OAdYWJ5Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0Bm7Anvx0H4sVksCOtZ+M4IHETLOzgcVCUYIIYch9Rw=; b=TQ6P5x35MMTcXyxn8sIbFUIsn5CGltketV3f7xHsJ1W2tkma5b22QrnnOOSmNXZ6jGICRy+OlrLSegzRqX3q6jx9QzJUY+24QBx9n7e9/kZih4PGJ7NmKURnwpJ1xbd2arVb5YyB0E0h/dWOOZRBMzMca6IyIqaUEOK3H0+R1S6nyjBJJZSLyQv8JSTE+lJUs2Lf3nP6rrS9Bna48se1QqFp9F+VTg61itjHZt2KsZbTrBrpgGxZTXHIATZiDOrXHbIlz3PRRKJ61LEhwkrd3rHMXNR0iP8tlnRpieCHm+Z71q6y/Vo7vf5YlfrRTBz5Axw5ks+nde9KouSxs+fslA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=0Bm7Anvx0H4sVksCOtZ+M4IHETLOzgcVCUYIIYch9Rw=; b=R6aSTsG92YQU4s4ECEJCPOM75AD6onPQa/zPf/GvLVVE7mT1cshXFHtwj7PW/C06r+DAGtEgzSmpuI+mYNB15EpRa/Z2VJQIIN60SVPgxgkd8TCKIfHyWSEYz4Tj7e7izSuRNujqUA9dweQWWETWRVr5O/a/MNGVnnuN0nAT2rQ= Received: from DM6PR18CA0005.namprd18.prod.outlook.com (2603:10b6:5:15b::18) by CYYPR12MB8962.namprd12.prod.outlook.com (2603:10b6:930:c4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:32:39 +0000 Received: from CY4PEPF0000EE3D.namprd03.prod.outlook.com (2603:10b6:5:15b:cafe::80) by DM6PR18CA0005.outlook.office365.com (2603:10b6:5:15b::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.33 via Frontend Transport; Wed, 6 Dec 2023 09:32:39 +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 CY4PEPF0000EE3D.mail.protection.outlook.com (10.167.242.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:39 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.34; Wed, 6 Dec 2023 03:32:38 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:37 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:35 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH v2 15/30] spi: cadence-qspi: Switch SDR/DTR using SPI_FLASH_DTR_ENABLE config Date: Wed, 6 Dec 2023 15:01:26 +0530 Message-ID: <0fd76122836e0bcf5a2dbc1554d3a8942f851b31.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3D:EE_|CYYPR12MB8962:EE_ X-MS-Office365-Filtering-Correlation-Id: 74ed3613-d72b-4c97-4f34-08dbf63e49f7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ob5TyYr39s046a0dBvNDHM5ibYzpMOMFAVNfFWA/oh2x8q+5qgV0OjV+3SjXQmt2S9AS+6r3zKvvAG9VMqU+9OP68kMdGIPMIeDvgPgRF32urRj+b8UM22Ui/2vIzGEF8BoljFpNB7JgaF/fr5g5i684Rtm9HuuNSI9qsRkvm17ynWm63xTxc5/iLWd70NH+ulXwPhFobZsJ3PlNR/S8/f8PJ6kyn3q0Q1eM4kTjhxgxvyGOW/sjxw7EiVc99aNAuRJUQR+TLOt2jJf1rjieQbWGlOM7O6ilFN+KJsrtb2RLZTpOxOtJB/04P4QixWrun9pzKdt9lj2Nh2oKq3koB78EOTj63kqHNvVk7tpV0x1zXsWmE9+IxSNQolPhwA1GMrtosclt8wUhgfjqCgcaaSKG+7YFNdZNrqpGvnaF0iyH0a27F2q1xbUqcPujFvsvmwYquwTEUNucha7g5ltC6Wpp4wO2VnktY9z6OMqEa5wwqjZFyLSQlQeuZMvK7gN8qIrbcbd/mNHKWTCMZq/jZ67zC2nZj4uY/XGj7OhucMGzPcb/vD1foUSdF1Fb1OBochhnqRZA5oHVtOkXVQwiegAAXWRtWmlpLOGPtGLtE+vM4sSqjBLeyQEhMfUGXNCByknClGLrgmLTFGhRaDXAJ5DdFTRSzabaZsF9sA95e9WPf990BPMxCegC6WD2Ity5mF7JstzkFDeI9JgJNuqN9WtQh5fWqewiKSJy4fCseG7WpJgPuYVYEKiEGsrXhUEApizRcGHd/CRt97khnWRQ6A== 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:(13230031)(4636009)(376002)(39860400002)(396003)(346002)(136003)(230922051799003)(82310400011)(186009)(1800799012)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(2906002)(5660300002)(36756003)(41300700001)(86362001)(4326008)(8936002)(8676002)(316002)(70586007)(6916009)(54906003)(70206006)(40480700001)(36860700001)(47076005)(82740400003)(356005)(81166007)(478600001)(40460700003)(426003)(83380400001)(6666004)(336012)(26005)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:39.1469 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 74ed3613-d72b-4c97-4f34-08dbf63e49f7 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: CY4PEPF0000EE3D.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8962 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy Cadence driver need to switch from SDR to DTR and vice versa based on the commands from spi-nor framework and based on SPI_FLASH_DTR_ENABLE config. If SPI_FLASH_DTR_ENABLE is not defined, do not switch to DTR mode as it represents that controller does not support DTR. Also do not reinitilize the SDR/DTR tuning if it is already done. Also added the functionality to reset the controller when switching from DTR to STR mode. Use reset_assert, reset_deassert api's to reset the ospi controller. In mini U-Boot case as ZYNQMP_FIRMWARE config is disabled, reset the controller directly using register writes. The configuration of the chip select in the Cadence QSPI driver is now determined based on the flags received from SPI-NOR framework. Signed-off-by: T Karthik Reddy Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_ospi_versal.c | 29 +++++++++++++ drivers/spi/cadence_qspi.c | 69 ++++++++++++++++++++++++++++--- drivers/spi/cadence_qspi.h | 7 ++++ 3 files changed, 99 insertions(+), 6 deletions(-) diff --git a/drivers/spi/cadence_ospi_versal.c b/drivers/spi/cadence_ospi_versal.c index 74994a690d..243de6efaf 100644 --- a/drivers/spi/cadence_ospi_versal.c +++ b/drivers/spi/cadence_ospi_versal.c @@ -154,6 +154,35 @@ int cadence_qspi_versal_set_dll_mode(struct udevice *dev) return -ENOTSUPP; } +int cadence_spi_versal_ctrl_reset(struct cadence_spi_priv *priv) +{ + int ret; + + if (CONFIG_IS_ENABLED(ZYNQMP_FIRMWARE)) { + /* Assert ospi controller */ + ret = reset_assert(priv->resets->resets); + if (ret) + return ret; + + udelay(10); + + /* Deassert ospi controller */ + ret = reset_deassert(priv->resets->resets); + if (ret) + return ret; + } else { + /* Assert ospi controller */ + setbits_le32((u32 *)OSPI_CTRL_RST, 1); + + udelay(10); + + /* Deassert ospi controller */ + clrbits_le32((u32 *)OSPI_CTRL_RST, 1); + } + + return 0; +} + #if defined(CONFIG_DM_GPIO) int cadence_qspi_versal_flash_reset(struct udevice *dev) { diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c index 32f91825fd..710c4a532d 100644 --- a/drivers/spi/cadence_qspi.c +++ b/drivers/spi/cadence_qspi.c @@ -154,7 +154,7 @@ static int spi_calibration(struct udevice *bus, uint hz) /* just to ensure we do once only when speed or chip select change */ priv->qspi_calibrated_hz = hz; - priv->qspi_calibrated_cs = spi_chip_select(bus); + priv->qspi_calibrated_cs = priv->cs; return 0; } @@ -179,7 +179,7 @@ static int cadence_spi_set_speed(struct udevice *bus, uint hz) priv->read_delay); } else if (priv->previous_hz != hz || priv->qspi_calibrated_hz != hz || - priv->qspi_calibrated_cs != spi_chip_select(bus)) { + priv->qspi_calibrated_cs != priv->cs) { /* * Calibration required for different current SCLK speed, * requested SCLK speed or chip select @@ -580,6 +580,9 @@ static int cadence_spi_setup_ddrmode(struct udevice *bus) struct cadence_spi_priv *priv = dev_get_priv(bus); int ret; + if (priv->ddr_init) + return 0; + ret = priv_setup_ddrmode(bus); if (ret) return ret; @@ -590,7 +593,47 @@ static int cadence_spi_setup_ddrmode(struct udevice *bus) printf("DDR tuning failed with error %d\n", ret); return ret; } - priv->ddr_init = 1; + priv->ddr_init = true; + + return 0; +} + +static int cadence_spi_setup_strmode(struct udevice *bus) +{ + struct cadence_spi_priv *priv = dev_get_priv(bus); + void *base = priv->regbase; + int ret; + + if (!priv->ddr_init) + return 0; + + /* Reset ospi controller */ + ret = cadence_spi_versal_ctrl_reset(priv); + if (ret) { + printf("Cadence ctrl reset failed err: %d\n", ret); + return ret; + } + + ret = wait_for_bit_le32(base + CQSPI_REG_CONFIG, + BIT(CQSPI_REG_CONFIG_IDLE_LSB), + 1, CQSPI_TIMEOUT_MS, 0); + if (ret) { + printf("spi_wait_idle error : 0x%x\n", ret); + return ret; + } + + cadence_qspi_apb_controller_init(priv); + priv->edge_mode = CQSPI_EDGE_MODE_SDR; + priv->extra_dummy = 0; + priv->previous_hz = 0; + priv->qspi_calibrated_hz = 0; + + /* Setup default speed and calibrate */ + ret = cadence_spi_set_speed(bus, 0); + if (ret) + return ret; + + priv->ddr_init = false; return 0; } @@ -604,9 +647,22 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi, int err = 0; u32 mode; + if (!op->cmd.dtr) { + err = cadence_spi_setup_strmode(bus); + if (err) + return err; + } + + if (!CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE) && op->cmd.dtr) + return 0; + + if (spi->flags & SPI_XFER_U_PAGE) + priv->cs = CQSPI_CS1; + else + priv->cs = CQSPI_CS0; + /* Set Chip select */ - cadence_qspi_apb_chipselect(base, spi_chip_select(spi->dev), - priv->is_decoded_cs); + cadence_qspi_apb_chipselect(base, priv->cs, priv->is_decoded_cs); if (op->data.dir == SPI_MEM_DATA_IN && op->data.buf.in) { /* @@ -655,7 +711,8 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi, break; } - if (!priv->ddr_init && (spi->flags & SPI_XFER_SET_DDR)) + if (CONFIG_IS_ENABLED(SPI_FLASH_DTR_ENABLE) && + (spi->flags & SPI_XFER_SET_DDR)) err = cadence_spi_setup_ddrmode(bus); return err; diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h index eec090a7ed..505f59bed9 100644 --- a/drivers/spi/cadence_qspi.h +++ b/drivers/spi/cadence_qspi.h @@ -18,6 +18,9 @@ #define CQSPI_DECODER_MAX_CS 16 #define CQSPI_READ_CAPTURE_MAX_DELAY 16 +#define CQSPI_CS0 0 +#define CQSPI_CS1 1 + #define CQSPI_REG_POLL_US 1 /* 1us */ #define CQSPI_REG_RETRY 10000 #define CQSPI_POLL_IDLE_RETRY 3 @@ -53,6 +56,8 @@ #define CQSPI_READID_LOOP_MAX 10 #define TERA_MACRO 1000000000000l +#define OSPI_CTRL_RST 0xF1260304 + /**************************************************************************** * Controller's configuration and status register (offset from QSPI_BASE) ****************************************************************************/ @@ -284,6 +289,7 @@ struct cadence_spi_priv { size_t data_len; int qspi_is_init; + unsigned int cs; unsigned int qspi_calibrated_hz; unsigned int qspi_calibrated_cs; unsigned int previous_hz; @@ -357,5 +363,6 @@ int cadence_qspi_apb_exec_flash_cmd(void *reg_base, unsigned int reg); int cadence_qspi_versal_flash_reset(struct udevice *dev); int cadence_qspi_versal_set_dll_mode(struct udevice *dev); void cadence_qspi_apb_enable_linear_mode(bool enable); +int cadence_spi_versal_ctrl_reset(struct cadence_spi_priv *priv); #endif /* __CADENCE_QSPI_H__ */ From patchwork Wed Dec 6 09:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872528 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=C6qp8ZjV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXLW6wsjz1ySd for ; Wed, 6 Dec 2023 20:34:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F0AA2877A2; Wed, 6 Dec 2023 10:32:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="C6qp8ZjV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6664D87227; Wed, 6 Dec 2023 10:32:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::62a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 29E1C877A2 for ; Wed, 6 Dec 2023 10:32:45 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gg/j5b41yqFyzo6AcWJbwhWEdaVlaaR1figr4wyHY4VEtlP37xczMCV/wMAi9MMTNP4SAUb1kNZX2QjDeOGoa1F+GiaNTZTfn55lWYaHhwhm4kd6DA14sDxtcTr2l4wenTDGYeoNSWluQ0HdngPpyyYWARGwnr2CVwY86GVZX00pm7z/KD8iXcBYzLN8uzwVPme2OTNGNh190DMn1yZTeseIXpWY2r6z+BbSeVVxgzzUDaTK8wGZLj37QR2AGkyFLTPByv3KVs3OKztw99iOSscOVwOPc9/kcuGs/GR8CHqdC3//COnh3/0t65NufGLshSeUCEGa+XHMmDPcepDzXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=XDDsM5Vjpi7JKtq+CZ/2eVN1UBPO5eUSm14130fPsAE=; b=AXN8J9XHsBSUNa2l8wSmA2MhRnSwG1P+jbQyN2FfxMyCSzdUAdMssBd/gV4v1Y/eagSp0nOfqa/KmxutApBve53H2l0j6ojtqVBOI02BqovrcjDbBkuqYhmnyRPSG21JnJtwKfgX0YXkNndk0FYF65hqzDwMZ25ss5KYBjhy5R5x0NliJ7/PhChqQ/j9y4R9lum5q4RjOlD3wiQMo8+ekckOBB3ii2HUYzGQUqfAhiP7MDEr08oMRmZdlDNPQchIyiVnGscQFnJcktSZZ5stLFe7H5nqlvojrsnJj2GE1YEAJPt4scxniWCcLpOuBwWPzAeARlrTLO2nq2F1+LS3Uw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=XDDsM5Vjpi7JKtq+CZ/2eVN1UBPO5eUSm14130fPsAE=; b=C6qp8ZjVUmNUPbeSDXNadxiewTiBeHvtcTEmcTFCv2AHE/Qr1GupozrzUlhJt87os/Gbn/MfyWdWFgRTXMJuFT0m9IiK+kbj+jE3kZcfxR/2zVyKsRl1JMZiP8c3YIx77VXmtCka4nbTf2EtsZSREAZQlNUqeSXlOFFz/ue9ers= Received: from CY5P221CA0161.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:6a::15) by MN2PR12MB4453.namprd12.prod.outlook.com (2603:10b6:208:260::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:32:42 +0000 Received: from CY4PEPF0000EE3C.namprd03.prod.outlook.com (2603:10b6:930:6a:cafe::ce) by CY5P221CA0161.outlook.office365.com (2603:10b6:930:6a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:32:41 +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 CY4PEPF0000EE3C.mail.protection.outlook.com (10.167.242.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:32:41 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.34; Wed, 6 Dec 2023 03:32:40 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:38 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH v2 16/30] spi: cadence_ospi_versal: ospi ddr changes in cadence ospi versal driver Date: Wed, 6 Dec 2023 15:01:27 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3C:EE_|MN2PR12MB4453:EE_ X-MS-Office365-Filtering-Correlation-Id: 33de86ad-7f19-47ea-913e-08dbf63e4b7e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2o8fPSvyXrOO1w9D2vZTVkXxY0yZ/aKHZM7DoY6GxORpu0yjjJr44sV+WSjDbu9OA/0z+YJ4Shj2Y4HLDhuXThGbmCNrkTVCp8zDs5ZmDHImsRB3gUH9CZEp5akp8HMwf+1fWS+7PJVm8SjfjbqEwylimySR5gxvvsyGMdMMQ/w1foCysN40rgQ3mItkXinnu0+MOLwgOfyb1131EJzcNyJ9uDF6fdJgjjG4oWkhr/WTZM9H65rd4PpY9vruW5WhEUhPLdZQQdcVCP+oZhA8DpGYWbo5Juqmc4bD4phhXh7l5xQOwmShGxoMZxp8g3RbN2yscrdV26FE8iZCvmT58feIj098ZJbn4znZxNPToQBnQzi2yTUqlSZCErxrPS8eDS9vopNGtC/lU5qKCPr5UI8Edq/qCfUZGjwMZQJUjOBAw3YXwcFRw1DKW3tzs0yJEZOO5aWzz9c+H0ihYPnTmAgqoUmHWo4EB9tKvr/0LvjD10VWstqe5BvDlcjHHgDBM39g8Q2i+LPv9+fe+oKyJiM2V8VpXHU6+UCssH2JLMJBw9IPbPvUw9F2UfinUkXtJm+axFs0hJ65/fYdl6zjBeK9nBV9odnimT1syYM/Xom6g6nUGWUEGtqpLarm7TnctZvnbzEJ+DURYuTTO4sACLnbTaw6kf7k55c8UxkISZPYKGRH7hA5DH/M/FA+XYvqPzcOGmiSk5MGbBNAwiZBIXi7aIVn4tGUTCb9GeKEiudV8zAS+yA37gqK3/IOJP7bireDm5hxew+bJa1i2Z/xKQ== 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:(13230031)(4636009)(396003)(39860400002)(136003)(376002)(346002)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(82310400011)(40470700004)(36840700001)(46966006)(81166007)(356005)(47076005)(83380400001)(6666004)(478600001)(82740400003)(8676002)(36860700001)(8936002)(316002)(54906003)(70206006)(70586007)(40480700001)(26005)(336012)(2616005)(426003)(6916009)(5660300002)(40460700003)(2906002)(4326008)(41300700001)(36756003)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:32:41.6798 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33de86ad-7f19-47ea-913e-08dbf63e4b7e 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: CY4PEPF0000EE3C.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4453 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy Set cmd, address & data buswidth to octal. Handle dummy clock cycles incase of reads & writes. Convert odd bytes to even bytes lengths in ddr mode, as we cannot rx/tx odd data in ddr mode. Disable the DMA once the transfer is done to avoid disabling it at other places. Signed-off-by: T Karthik Reddy Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_ospi_versal.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/spi/cadence_ospi_versal.c b/drivers/spi/cadence_ospi_versal.c index 243de6efaf..9db1911110 100644 --- a/drivers/spi/cadence_ospi_versal.c +++ b/drivers/spi/cadence_ospi_versal.c @@ -21,12 +21,13 @@ #define CMD_4BYTE_READ 0x13 #define CMD_4BYTE_FAST_READ 0x0C +#define CMD_4BYTE_OCTAL_READ 0x7c int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv, const struct spi_mem_op *op) { u32 reg, ret, rx_rem, n_rx, bytes_to_dma, data; - u8 opcode, addr_bytes, *rxbuf, dummy_cycles; + u8 opcode, addr_bytes, *rxbuf, dummy_cycles, unaligned_byte; n_rx = op->data.nbytes; rxbuf = op->data.buf.in; @@ -70,13 +71,14 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv, writel(CQSPI_REG_INDIRECTRD_DONE, priv->regbase + CQSPI_REG_INDIRECTRD); rxbuf += bytes_to_dma; - } - if (rx_rem) { + /* Disable DMA on completion */ reg = readl(priv->regbase + CQSPI_REG_CONFIG); reg &= ~CQSPI_REG_CONFIG_ENBL_DMA; writel(reg, priv->regbase + CQSPI_REG_CONFIG); + } + if (rx_rem) { reg = readl(priv->regbase + CQSPI_REG_INDIRECTRDSTARTADDR); reg += bytes_to_dma; writel(reg, priv->regbase + CQSPI_REG_CMDADDRESS); @@ -84,10 +86,10 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv, addr_bytes = readl(priv->regbase + CQSPI_REG_SIZE) & CQSPI_REG_SIZE_ADDRESS_MASK; - opcode = CMD_4BYTE_FAST_READ; - dummy_cycles = 8; - writel((dummy_cycles << CQSPI_REG_RD_INSTR_DUMMY_LSB) | opcode, - priv->regbase + CQSPI_REG_RD_INSTR); + opcode = (u8)readl(priv->regbase + CQSPI_REG_RD_INSTR); + if (opcode == CMD_4BYTE_OCTAL_READ && + priv->edge_mode != CQSPI_EDGE_MODE_DDR) + opcode = CMD_4BYTE_FAST_READ; reg = opcode << CQSPI_REG_CMDCTRL_OPCODE_LSB; reg |= (0x1 << CQSPI_REG_CMDCTRL_RD_EN_LSB); @@ -99,7 +101,12 @@ int cadence_qspi_apb_dma_read(struct cadence_spi_priv *priv, CQSPI_REG_RD_INSTR_DUMMY_MASK; reg |= (dummy_cycles & CQSPI_REG_CMDCTRL_DUMMY_MASK) << CQSPI_REG_CMDCTRL_DUMMY_LSB; - reg |= (((rx_rem - 1) & CQSPI_REG_CMDCTRL_RD_BYTES_MASK) << + if (priv->edge_mode == CQSPI_EDGE_MODE_DDR && (rx_rem % 2) != 0) + unaligned_byte = 1; + else + unaligned_byte = 0; + reg |= (((rx_rem - 1 + unaligned_byte) & + CQSPI_REG_CMDCTRL_RD_BYTES_MASK) << CQSPI_REG_CMDCTRL_RD_BYTES_LSB); ret = cadence_qspi_apb_exec_flash_cmd(priv->regbase, reg); if (ret) From patchwork Wed Dec 6 09:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872531 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=p845QCe3; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXM60db0z23mf for ; Wed, 6 Dec 2023 20:35:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8C507876F0; Wed, 6 Dec 2023 10:33:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="p845QCe3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BBEB08784C; Wed, 6 Dec 2023 10:33:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20614.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::614]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 530C08764D for ; Wed, 6 Dec 2023 10:33:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jgoYu4ds1wjYZPWR1s6NFw2wSYjWq0qgSPRQx+sNBxoswy4se5ESsU8Hs2ciA+CCtZGy1N0eh5TITYh8oAo2NYEVPAQ1ms2nWLTKhGgRw3xfGqdCOgq5LX3fh2vk+c14tPfSgGSp3MsK2aHESLsHJsE/Nx7P3NLn9ZRO7/Yhg+OENCrKvQYINf7mqh3pqBH8RPBV5gI3EzugtFHnbpfihaGumhJf34i4zjdqZ0WP2pgYk5m13fJWsYUQfMX1fV0p2hc1JEy4SU8dWc/wVqL1Lgdc8Pd8adYS+YPado6oeLow36jAMYWi17EXd+4eFld3aP/6mBnDJ5YSVrvW2+2Luw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=F85zAwA1eTOPtdt9kHZ45TxpQnMiT1siy0sAX0OPlhE=; b=dhTxt3TL1q3zyG6SUg1JNkOe4vxl85+zCGOliskhGPFQ72kIQ827xqUHSDmNI5EGolDW+/YSFbI/MwqaeEo2P+9tgysa6P6W4Y/q+U4BXU7MdobCROTa72vJwQvWjl0FPE6QYLlRUFulF0XyPAJuYC76tlCYpMemn6lP2x+pthptiUaHYqQVOdsGMUjh60PqKkw6gNJWN7vFmhnA0E9/BWihIqZ+IND4RPOxrpTf7w9uJX+hlj56hYWI4fyhFPh6isMO7UXcIiNQWjQoS3q9IX8tl73IflY6au1/yQVI5GFaytN0oAsUhKBY0rssR9BOLaBMUKb+6YynUZn4l0SMHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=F85zAwA1eTOPtdt9kHZ45TxpQnMiT1siy0sAX0OPlhE=; b=p845QCe3d3ldlPTh/s7+kTSPu8E4qAKowO7suqFtkA+TpxHLgSQt6rqQ49V/XueZirIrC3s1u/zPIhM530Dl11m8Es45Q78nrVZbCNint2ikw+J3pfm5VDRO5uywVD45pGO/EfwCl1vMEPwCQ+AEiJFM+5BLl0UVSMqXeZBh10M= Received: from DM5PR07CA0083.namprd07.prod.outlook.com (2603:10b6:4:ad::48) by DS7PR12MB5982.namprd12.prod.outlook.com (2603:10b6:8:7d::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:29 +0000 Received: from DS3PEPF000099D6.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::26) by DM5PR07CA0083.outlook.office365.com (2603:10b6:4:ad::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:29 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D6.mail.protection.outlook.com (10.167.17.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:29 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:21 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:32:43 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:32:41 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH v2 17/30] spi: cadence_qspi: Fix versal ospi indirect write timed out issue Date: Wed, 6 Dec 2023 15:01:28 +0530 Message-ID: <9cd21aabccc87850290009a4feb0db0fbcb46ace.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D6:EE_|DS7PR12MB5982:EE_ X-MS-Office365-Filtering-Correlation-Id: d82ae59f-e7f4-4daa-5d41-08dbf63e680a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Uq43+Zjodx28sEFj5YlKaw1ZuZrW46eYRyEiBwTBf9cr1ASZ7dVfDTdCLsml7zzA5Vje9JL0nEVjhT4IAjKANmnXJDueycmSlcXtGYLgQefvAvbn23p24r4b3sMQ/a9URb+QNbUSJOHZZT4yG5wBOcuowYeZdRZ2Xdr0Xj8abI4/x32mBHl1y47D1FJs0hHSX24GcwiQNpOv4aszS3nFGzeqkqsun7TD6TpJh40TNOltx3IW4kS3Z/YChhNP4THx7UYI38CLpddm0j8GgMnsY2AjbxZV/bhdhA89fGjRsZ/2M0z0/XzrZXrrzypZsB6/pF0ENFhPZlpJI8mTsU5qflXErOhr1NucxqOIVqSk1PBGkWPaocCrkdP1/4MoaX+QmeERdGikuWKxinA6Mqff9FxB/rrspNJOZVazW3h+dh296xUHgPgDidI+Docwe4KdwZqQn3d00EbhJXNYsc4bf3OM10me2FVSD4uqpOKXFXUuLn7CB49ieKfVqiWHOLVz/jhU354dnykjFAhBvvDaM+RQsWD/zpiKEjUo7vuGO2cf52q+XrAM7DDoqN8uj1esJZCL4nzLM5QwyZOT8OP3Mdf5vKmXKbgLLa9REvoDZ4WxZWyDzAy9H83Pzvzs15ptVINirPxR2hywupDbdSbNZ1Pi1tXFFMgwXt3og8kNIySddwe6HQ35hbJO4ZTRYWuC1E/jlObHc2YAzeUtrmPzQMQECl3sMdURsvNxnq2Xzi5DGJPY1nxnQ1qLFpEOuZ3XpHIMaMnRbMGJVRnQzIrprQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(39860400002)(136003)(396003)(376002)(230922051799003)(186009)(64100799003)(1800799012)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(40480700001)(36756003)(356005)(47076005)(81166007)(82740400003)(2906002)(36860700001)(83380400001)(336012)(2616005)(426003)(41300700001)(26005)(107886003)(5660300002)(6666004)(86362001)(40460700003)(478600001)(8936002)(4326008)(6916009)(316002)(54906003)(8676002)(70206006)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:29.6034 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d82ae59f-e7f4-4daa-5d41-08dbf63e680a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D6.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5982 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean To reduce the CPU load in waiting for the OSPI internal SRAM to clear in indirect mode, it's better to use the CQSPI_REG_IRQSTATUS register to check for indirect operation to complete. Enabled interrupt for Indirect Complete and Transfer Watermark Breach interrupt status register bits and using readl_poll_timeout function to poll for Indirect Operation Complete bit gets set. Here not enabling IRQ coming to GIC, only IRQ from IP itself is able to poll bits. It is observed that the Indirect Operation Complete bit is getting set at an average time of 0.172 usec. Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi.h | 11 +++++++++++ drivers/spi/cadence_qspi_apb.c | 24 +++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h index 505f59bed9..73ef44fc1c 100644 --- a/drivers/spi/cadence_qspi.h +++ b/drivers/spi/cadence_qspi.h @@ -252,6 +252,17 @@ (((readl((reg_base) + CQSPI_REG_SDRAMLEVEL)) >> \ CQSPI_REG_SDRAMLEVEL_WR_LSB) & CQSPI_REG_SDRAMLEVEL_WR_MASK) +/* Interrupt status bits */ +#define CQSPI_REG_IRQ_UNDERFLOW BIT(1) +#define CQSPI_REG_IRQ_IND_COMP BIT(2) +#define CQSPI_REG_IRQ_WATERMARK BIT(6) + +#define CQSPI_IRQ_MASK_WR (CQSPI_REG_IRQ_IND_COMP | \ + CQSPI_REG_IRQ_WATERMARK | \ + CQSPI_REG_IRQ_UNDERFLOW) + +#define CQSPI_IRQ_STATUS_MASK GENMASK(16, 0) + struct cadence_spi_plat { unsigned int max_hz; void *regbase; diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index d1a5a4c679..1b649abf21 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -855,7 +856,7 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, const u8 *bb_txbuf = txbuf; void *bounce_buf = NULL; unsigned int write_bytes; - int ret; + int ret, cr; if (priv->edge_mode == CQSPI_EDGE_MODE_DDR && (n_tx % 2) != 0) n_tx++; @@ -873,9 +874,15 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, bb_txbuf = bounce_buf; } - /* Configure the indirect read transfer bytes */ + /* Configure the indirect write transfer bytes */ writel(n_tx, priv->regbase + CQSPI_REG_INDIRECTWRBYTES); + /* Clear all interrupts */ + writel(CQSPI_IRQ_STATUS_MASK, priv->regbase + CQSPI_REG_IRQSTATUS); + + /* Enable interrupt for corresponding interrupt status register bit's */ + writel(CQSPI_IRQ_MASK_WR, priv->regbase + CQSPI_REG_IRQMASK); + /* Start the indirect write transfer */ writel(CQSPI_REG_INDIRECTWR_START, priv->regbase + CQSPI_REG_INDIRECTWR); @@ -894,9 +901,10 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, bb_txbuf + rounddown(write_bytes, 4), write_bytes % 4); - ret = wait_for_bit_le32(priv->regbase + CQSPI_REG_SDRAMLEVEL, - CQSPI_REG_SDRAMLEVEL_WR_MASK << - CQSPI_REG_SDRAMLEVEL_WR_LSB, 0, 10, 0); + /* Wait up to Indirect Operation Complete bit to set */ + ret = readl_poll_timeout(priv->regbase + CQSPI_REG_IRQSTATUS, cr, + cr & CQSPI_REG_IRQ_IND_COMP, 10); + if (ret) { printf("Indirect write timed out (%i)\n", ret); goto failwr; @@ -914,6 +922,9 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, goto failwr; } + /* Disable interrupt. */ + writel(0, priv->regbase + CQSPI_REG_IRQMASK); + /* Clear indirect completion status */ writel(CQSPI_REG_INDIRECTWR_DONE, priv->regbase + CQSPI_REG_INDIRECTWR); @@ -931,6 +942,9 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, return 0; failwr: + /* Disable interrupt. */ + writel(0, priv->regbase + CQSPI_REG_IRQMASK); + /* Cancel the indirect write */ writel(CQSPI_REG_INDIRECTWR_CANCEL, priv->regbase + CQSPI_REG_INDIRECTWR); From patchwork Wed Dec 6 09:31:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872532 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=GZeFWQxX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXMJ0Nzjz23mf for ; Wed, 6 Dec 2023 20:35:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 093B28764D; Wed, 6 Dec 2023 10:33:39 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="GZeFWQxX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CE83D876D9; Wed, 6 Dec 2023 10:33:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2062e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::62e]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9F5848779E for ; Wed, 6 Dec 2023 10:33:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PpgaiZ+EOj+Mw/orNuAix7xvKn2iT//OWIgu8M6neLMjJnct0BTSuQIu0dUowrpCW3PRDcV4hO4th5uI8exTM8pu9hIcVwSEPTGLMaH+onGHpg1yiZPC8WlV+wNw4dRHaiG7yMaE2vrX6ggfooe5eka8liv2vw4OROplWibLxClsbFuF0uk3Wy3OEflubwOKTHxEo2Vj0WgjTWkDj4f0/U4ilLlTG2khjugOqPmPkabGdnA6wiDD9wRWc/Er4/nN9j1LAwKV5FcaYQZ9pQZ/D5Ggu4CeM5onuU6V/1zIGfDiMm9GjEpswcJ5/oTp3ccG6GYmr1nspnBkhTzcnepulw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=RlybIRd3dgqBt58XjLdd4KvLoJpo79Iz9gSYOxKxh44=; b=WY/o/pp5QI109QedGvrAdozhEKrllSXZ6ooQWnLAasRN+4Qc41Ne9CmfmmIZZrkKKup09GgKnsRDnRjRGYSTIFS66lBrhlq7ZPie2kyAjCiz18k+IG6eMp07pxBWV4t1/In14wv0G2YnfAnhlZuDx4VBoB5U8JP1lqN/zTWHXJKj6erTODcUlcaMSORsTp02Ap4L2KxCsu1RZqHiF1aOLKajR2Z3qScEF8sSMbEswfF5MS016bSjj4Grvn3cq/8eC1M85i0AurMysYFibDSK99lwBpWkMmMbi12F5pyNzM1edDhmuQtS2LwgWjK0K/LZzkG7nUsq0X8uC56pvqwQlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=RlybIRd3dgqBt58XjLdd4KvLoJpo79Iz9gSYOxKxh44=; b=GZeFWQxXJ3gEkZMdrVZdqp1nLocqvOisJ4fYEOEhGffXwxXzz9sFPw5esNWf3pcgAid1xPMEihPYpX9Hk+IK3gIbq9dDcVKfXAI7m2xqqnH6JKt1YLyn9QPSu0/ACUKcK+ysQ13f77nLKqfs+bkTHeBMC89hWmbQaoZgJikhnmA= Received: from DM5PR07CA0065.namprd07.prod.outlook.com (2603:10b6:4:ad::30) by SJ2PR12MB9115.namprd12.prod.outlook.com (2603:10b6:a03:55c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:30 +0000 Received: from DS3PEPF000099D6.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::8b) by DM5PR07CA0065.outlook.office365.com (2603:10b6:4:ad::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:30 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D6.mail.protection.outlook.com (10.167.17.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:29 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:23 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:20 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 18/30] spi: cadence_qspi: Set tshsl_ns to at least one sclk_ns Date: Wed, 6 Dec 2023 15:01:29 +0530 Message-ID: <270d9c8b0e2578a45317693c843ae22d2d409219.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D6:EE_|SJ2PR12MB9115:EE_ X-MS-Office365-Filtering-Correlation-Id: 3084e3d5-58b3-4a8a-f7ed-08dbf63e6845 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iIPu7OUAmSHH47jzYRWCmNX0XKdWMmnMwrWOjXWDjIDnHMu7E/lkGddI7Jyn5JEWGqazPjrChBAmPq0sftXMfCPGYoqU45vuIS9SJIueXlseRJrm2QWp4TbBhl6hC91OaBc8iz3blyGxvPU6vGzQ57sXTy38DvbHGCvEShg/5yFQHvBcUEjstm/3MN+621FODalslEjOXbmLk4E/fAu5ZgbA7K8qonb1CQLkWkRGcPAtO6ZNFSTb+p3/rpJFRR+CesIpsGirj1QQKuUYcGNDSqSvg4EdpIZGM8EsWE4+2gl7oOHvCvpZ36GMN9ctEzQTv2IXR3jfHejpOxmujEHFLb1v6WcutksiNQCrcvyXiKyVf8p42Wefrsh+co66CmmdWrYPe2GC/hiN34ILaxhdMtH2hXjms1EREhQyiwY9YxTORzDrNXpkqNuxwQJHOBsz8dsfSSwIGibxiCRJm66p7Nm26BQBq5xb3z61+a2IRI3IJlx+7JJ6FpzDENbXrAXmQ5MJ9Z7ZSsoxdj9/dt0RqJygepwSwA5BtdJOkfA/Nq9DRbj01Ewd9BTMKs6T/3mifqiLZw1PGlE7VQcDHRumR8pveXljXsKhNO9QmVu+9es3GbrSyjsTjOSPG+Xu5mERDlbRvY7xLrEDnt5ff7+E2L3xn/fsCfVaskjiOX9+lLk1T3DA+nF+7Uwj9WFnOZDMGAExYhH2zQ93tZsES9s4prap2Jlo0vYaTzGTIWRdSnY47IRS0e+GWlHq81LP5GCq9fKe8crYkz09c6qGfcCV2Q== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(230922051799003)(1800799012)(82310400011)(186009)(451199024)(64100799003)(36840700001)(40470700004)(46966006)(83380400001)(82740400003)(40480700001)(336012)(426003)(41300700001)(36756003)(47076005)(81166007)(356005)(36860700001)(2906002)(26005)(2616005)(478600001)(40460700003)(5660300002)(70586007)(70206006)(86362001)(54906003)(316002)(6916009)(8676002)(8936002)(4326008)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:29.9940 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3084e3d5-58b3-4a8a-f7ed-08dbf63e6845 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D6.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9115 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma tshsl_ns is the clock delay for chip select deassert. This is the delay in master reference clocks for the length that the master mode chip select outputs are de-asserted between transactions. The minimum delay is always SCLK period to ensure the chip select is never re-asserted within one SCLK period. That is why tshsl_ns delay should be at least one sclk_ns value. If it is less than sclk_ns, set it equal to sclk_ns. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi_apb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 1b649abf21..0bb46f6ac2 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -306,6 +306,10 @@ void cadence_qspi_apb_delay(void *reg_base, tshsl_ns -= sclk_ns + ref_clk_ns; if (tchsh_ns >= sclk_ns + 3 * ref_clk_ns) tchsh_ns -= sclk_ns + 3 * ref_clk_ns; + + if (tshsl_ns < sclk_ns) + tshsl_ns = sclk_ns; + tshsl = DIV_ROUND_UP(tshsl_ns, ref_clk_ns); tchsh = DIV_ROUND_UP(tchsh_ns, ref_clk_ns); tslch = DIV_ROUND_UP(tslch_ns, ref_clk_ns); From patchwork Wed Dec 6 09:31:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872529 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=2E0t3Gfw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXLj0ph6z23mf for ; Wed, 6 Dec 2023 20:35:09 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A0C75877E9; Wed, 6 Dec 2023 10:33:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="2E0t3Gfw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B2EEA876F0; Wed, 6 Dec 2023 10:33:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 91E2B86CF4 for ; Wed, 6 Dec 2023 10:33:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MJAtxKVFMnz9PJaQIvZS6Ocldea8l229NqB5Rn3wdp4yFC5FpDMeHoJFW5xJulvdPvwI5iT7kPgEvykgJN59HuvOgHZiLRTVbTJwL8YKQ6FFoC+M9nvzihT0Qc2g/G/0MqaPNt8DnFwwZ9UVq1m168ugjOGE2urQMfI/GsnayYowL/7L8ee9irRUnYIV/dhxuAK5uETYQ751U7SuCJZNWn0JoEydnBkdyblQibzElyMr2lW6WLKZHjk/LTV6zte3hlQaTuXi9vNP1+jhL3qbQL0m7YWkZqUh7uQEj1iIqQvNSBRTnekEWmeelFucIi0a60silRXMA7AH2Z7nYt5O+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wTB6NFMd/a06XzZearT9AOP0NxB8B2KGvAHJP+JjBLI=; b=SPYorC6NbEW9wJYR+PR3WFPPFhq9EpnVpXNh+P9QdZckm+V39XXNg4F0bPE29JQogDd9Furzu+w6jxRQRZR66CW4A2cDjzPuGDuxH7KhvyBT1zqe9gut+xxwnqME/1Z4GmPP+o5r4tWzoHqokYM0InIhEgDrukN3fdOb5tj+zvcs/NAWqkDqdU6euJuqZc9jnXXEdvWyZVcpjz5xzoarB2oT/8+fd/EJC3LQ3e+7kX63DxW5e3MUnnlrRx6pd2LmaqeMibh9ei6akuCYX0/aTsaTf4Kox2fWWbEhBGRi5yhkHyCm063wYOruymZIyQ7YdQ4U9kdMS8o9DQxFCJJI9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=wTB6NFMd/a06XzZearT9AOP0NxB8B2KGvAHJP+JjBLI=; b=2E0t3GfwM2WPz/tRB5LxQSwemkTqkoogEMcCf4gPcDDmlaHBDDOcFOk1ZHA3Dzt6I4NUIfzuavN3puoRCyPBq8t9XuG/l2WQzmH8QPAn7bwPTJDN1n/P94qr5ao2zT4JZn5r/+zIT8vw6beXTpLpcgnNY+1h1AeYP1btnwmpjRE= Received: from DS7PR03CA0223.namprd03.prod.outlook.com (2603:10b6:5:3ba::18) by CH2PR12MB4040.namprd12.prod.outlook.com (2603:10b6:610:ac::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:33:30 +0000 Received: from DS3PEPF000099D3.namprd04.prod.outlook.com (2603:10b6:5:3ba:cafe::a9) by DS7PR03CA0223.outlook.office365.com (2603:10b6:5:3ba::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:30 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D3.mail.protection.outlook.com (10.167.17.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:30 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:25 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:23 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 19/30] spi: cadence_qspi: Clean up registers in init Date: Wed, 6 Dec 2023 15:01:30 +0530 Message-ID: <05ef7927ad845ba74385adcf92706616e8647590.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D3:EE_|CH2PR12MB4040:EE_ X-MS-Office365-Filtering-Correlation-Id: 1a34792e-b5b1-41e5-add9-08dbf63e684d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 50RudengTaQKp48rpzTq7dI4EPJvG6cHKj8+Xo+9mRJMprSdFgUnUsKXu4o/eQCFyq27ZGwv7kisFWEi7MDM4rSwUKfq5okVfUFszf+ZZRs8By2Fz1QXS9m8x9t8W9RDf6Oqwbv2BKe7JmW2wTsVUBhm4Kri3Sd4D9p7UqTWeksvXgtoMnfif1AZ2DEvixBRxGs8XwBcnxTz+gkGu+JJQfQbeqeZ+ZCFQXWBe4UfZVIgAS3mfH21diOr8do5f9ah+6YF1hmc/8gP6FH/CoNJNHnZaf3mWfcSpwJiRuDYDfSVs/61iAfRhijN8OeUSmzhSe9uMNfxXNjLzaSdgjnejRf5lT5BtwBndyuNLiAvq+hKkoY8QFpj4TrFR+qqLAZQmzXFlt3eNw/akSiV1VXjziFl0d7AId2cDg4bDQ18MfxtJhUZGyyjb5VpVXUjP+UokHu6t0umRSlbVuiWBd5cTuJQ6zDF5u2igJxuZimVSkLDSzLlVyNaqijeQzjgZbJmTDMVNT2QDRXylGcS39TfdmKCyMeApXpRNP+grMkAH1j85tSzAvuQN89k4pDtFV6oQmi4SG1r5v+Opu8uZtEOG9FyE5Um+iK9/xBOZn3yqnmlzIZHI42LYWmpDSIRgPQ2nMwqycCTx0Ul8w2Zu31kBVewlFyWzgGzXiwl/eQRHm291jy/wwLycJ5gmn+Lj1W6JqmdutiyEtCdpI1xSmGyjzV4H51mBJHxnnrleFTFbLmGKluNoZbEDmbj9PEuwPb+iO6HhGW1EVs4Wf3nB3zMWg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(39860400002)(346002)(376002)(396003)(230922051799003)(1800799012)(82310400011)(186009)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(36860700001)(47076005)(5660300002)(356005)(81166007)(82740400003)(6666004)(86362001)(36756003)(8676002)(8936002)(4326008)(41300700001)(40480700001)(2906002)(426003)(40460700003)(26005)(70206006)(70586007)(2616005)(478600001)(316002)(336012)(6916009)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:30.0602 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1a34792e-b5b1-41e5-add9-08dbf63e684d 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D3.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4040 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma This patch cleans up the cadence qspi registers in the init. The register contents may be invalid if this controller is used in previous boot and comes to uboot after a softreset (no power on reset). This may cause issues in uboot. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi_apb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 0bb46f6ac2..5fc5279061 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -346,12 +346,34 @@ void cadence_qspi_apb_controller_init(struct cadence_spi_priv *priv) /* Configure the remap address register, no remap */ writel(0, priv->regbase + CQSPI_REG_REMAP); + /* Clear instruction read config register */ + writel(0, priv->regbase + CQSPI_REG_RD_INSTR); + + /* Reset the Delay lines */ + writel(CQSPI_REG_PHY_CONFIG_RESET_FLD_MASK, + priv->regbase + CQSPI_REG_PHY_CONFIG); + + reg = readl(priv->regbase + CQSPI_REG_RD_DATA_CAPTURE); + reg &= ~CQSPI_REG_READCAPTURE_DQS_ENABLE; + reg &= ~(CQSPI_REG_RD_DATA_CAPTURE_DELAY_MASK + << CQSPI_REG_RD_DATA_CAPTURE_DELAY_LSB); + writel(reg, priv->regbase + CQSPI_REG_RD_DATA_CAPTURE); + /* Indirect mode configurations */ writel(priv->fifo_depth / 2, priv->regbase + CQSPI_REG_SRAMPARTITION); /* Disable all interrupts */ writel(0, priv->regbase + CQSPI_REG_IRQMASK); + reg = readl(priv->regbase + CQSPI_REG_CONFIG); + reg &= ~CQSPI_REG_CONFIG_DTR_PROT_EN_MASK; + reg &= ~CQSPI_REG_CONFIG_PHY_ENABLE_MASK; + reg &= ~CQSPI_REG_CONFIG_DIRECT; + reg &= ~(CQSPI_REG_CONFIG_CHIPSELECT_MASK + << CQSPI_REG_CONFIG_CHIPSELECT_LSB); + + writel(reg, priv->regbase + CQSPI_REG_CONFIG); + cadence_qspi_apb_controller_enable(priv->regbase); } From patchwork Wed Dec 6 09:31:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872530 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=yBIEFqsp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXLv5rN2z23mf for ; Wed, 6 Dec 2023 20:35:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1251287860; Wed, 6 Dec 2023 10:33:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="yBIEFqsp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 59509877DA; Wed, 6 Dec 2023 10:33:36 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::60b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4698F87227 for ; Wed, 6 Dec 2023 10:33:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Dey35TnF+Fy4D/3YDGyLYnfql4Aa3HV0skvo9c5ihnfQL5ETqFXJnaXeygWfZhtM0m2WOUuCvr/fb+yrX+n8ix7utfbg1THHRBb8QUJ+xbJfD4MQ7TkCGj3y8biaYe7CN6ZjrVJLBeBL7vh4S7WcnJnEQ/lZGMJ8r1aR0LotBK12CZgdGcEP8oDRKoLj1o3q7BavK7FpkMNoGoXPGKjxNdIEOfMJoTWb+xFINGSCf+vXHHeDqxXD5cNmdAwe9w38my8R0z98PKX7V96p8pRkbG0+mcXaWCKVFfL97letpIfnbq9pEiHKP6qHJtoG0FwPULnYnEl67opFF+mX+l3b7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=ChZc/OlT5tg+fOWmP24IbIlL+pLus2CinvGuG2JUimE=; b=FwU6T9FstoF2zZvYVKZZWfj8u2cU2neC9d9MHY3G0VoeYQCRYYLjydRdLHPfzpHv6p/vky7Tp3I9vfuRRWtcPJzPge1V/JeWaZESKzTanGLHLlIXdhN/86Y92UXAvFV5E3QyoM41hRT7A3ZQaCDupcVHF/ZsEkazScZKc45qRdEoHu77RgraF6lBp/L/w//mWJAj/mS1SOuOBGBaLODmvQXxzS68BMt4RcdmDh229bkR0H4h2hAI/632/DuL/JO+1a+3nsplx6RRciU/PIWwKx4YFRHWc2AaXsc/U8RypQMeU3ty7++gGVSZawq41qguGNfllVGkTyfCYwAzkIoLKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=ChZc/OlT5tg+fOWmP24IbIlL+pLus2CinvGuG2JUimE=; b=yBIEFqspNrqKp/GAL0X4Kjsm3cx8cYFnstxE0W8yaY+LLLwI2hy8DSnf21fObbSQOyOPfJUWXH6Zn+4ITWgWewywBhI4HImTZeF4mpuC9taq4mX7V6qpf0FJGB765QVYuzu56IiF4y2WkHQQbAxUijvIm23HOvpAaVy3hIVJqtA= Received: from DM5PR07CA0062.namprd07.prod.outlook.com (2603:10b6:4:ad::27) by DS0PR12MB7771.namprd12.prod.outlook.com (2603:10b6:8:138::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:31 +0000 Received: from DS3PEPF000099D6.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::94) by DM5PR07CA0062.outlook.office365.com (2603:10b6:4:ad::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25 via Frontend Transport; Wed, 6 Dec 2023 09:33:30 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D6.mail.protection.outlook.com (10.167.17.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:30 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:28 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:26 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 20/30] spi: cadence_qspi: Initialize read and write watermark registers Date: Wed, 6 Dec 2023 15:01:31 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D6:EE_|DS0PR12MB7771:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f20d827-4007-4687-7b69-08dbf63e68cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hDaV1GJY1UjyCk3owE1590DCxhwB4d++pD0DmorIBMTcnjKP7xSsetQlib9MtHTCw4DvdOPLjDczyDyB4jBlJpNzzsBjzBzUg5112ThC4kiSzH72tPxEEnk4vrLQtm49avpP99oY/7Qfs91HLPj66RE8hP2CnXlxQOyksN507ZsJNQ4S+YT3XQTaB/Vh6VsFzGICLQTPgGiy0eLtPjy8Zw5E//Nlvnd+S7SIgjuacFLCRSg1erb9i11GaCU40o7W43M3nfcAZhgLOHj6MEL4VlA4JaGmqVL2zQgS3a84DbcNrvNXSVghPoeNeTXZkzax8plj9hVmXHY6niDoKmpsCnscPZ2ElYz+N1XZFDNpBMNnmh3TRiGVx5p62OMcToy2FOKNtH4bUL1Ua1Wv6y9KXl8Z9eSJABR7yxPc67DGdLr43k0WrhxgIJ1nGgz5EYvWl+Qz6MzSPaKtZcmTNHWO77IF+KDcnv1cbeuZkAOVLGnG4hlD7zahFWXxujvGLEHFuxVYBckftIgwKc/cR6Gwdyf5FDes9l6LoUN4HWJroj4ZN2ExhpN/3XaRY6vobQgl3nSI9qGd28vFs8Mfea3xt4rVvcSiPV7Vw14Q13VY48t1C2aEvKKPupboFb9pe20bi/AmMrYGQAj+JrHpQ86AxPxmMQMMQscqLNCurRNt51XoWxOEfo5Q9YV+MKn54pnEITWKgUvFKYNlkSY72FbizYfnbCqltE9cRcQnkG1BstdJwy2tq1PVUtIzHFcbCokG6m4Ov+4Rs/Yyzd+ZOIc22g== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(1800799012)(186009)(82310400011)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(36860700001)(40480700001)(6666004)(478600001)(54906003)(81166007)(70586007)(70206006)(356005)(316002)(26005)(2616005)(47076005)(4326008)(6916009)(8676002)(8936002)(426003)(336012)(82740400003)(5660300002)(2906002)(40460700003)(41300700001)(86362001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:30.8690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f20d827-4007-4687-7b69-08dbf63e68cb 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D6.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7771 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Read and Write watermark registers are not initialized. Set read watermark to half of the FIFO and write watermark to 1/8 of the FIFO size. Read watermark indicates if SRAM fill level is above this watermark, interrupt will be generated and read or DMA can be performed. Write watermark indicates the maximum fill level of SRAM when write is performed to device. These values of 1/2 for read and 1/8 for write are chosen similar to Linux driver. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi_apb.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 5fc5279061..052d7a1766 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -362,6 +362,14 @@ void cadence_qspi_apb_controller_init(struct cadence_spi_priv *priv) /* Indirect mode configurations */ writel(priv->fifo_depth / 2, priv->regbase + CQSPI_REG_SRAMPARTITION); + /* Program read watermark -- 1/2 of the FIFO. */ + writel(priv->fifo_depth * priv->fifo_width / 2, + priv->regbase + CQSPI_REG_INDIRECTRDWATERMARK); + + /* Program write watermark -- 1/8 of the FIFO. */ + writel(priv->fifo_depth * priv->fifo_width / 8, + priv->regbase + CQSPI_REG_INDIRECTWRWATERMARK); + /* Disable all interrupts */ writel(0, priv->regbase + CQSPI_REG_IRQMASK); From patchwork Wed Dec 6 09:31:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872533 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=nYYqt0IN; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXMV3ft9z23mf for ; Wed, 6 Dec 2023 20:35:50 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6AA0D8779E; Wed, 6 Dec 2023 10:33:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="nYYqt0IN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 731C287879; Wed, 6 Dec 2023 10:33:38 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8c::601]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3B769877BC for ; Wed, 6 Dec 2023 10:33:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bl0xu8an7JCyLmM5L2sGtiarRM+Xf6fVAxLcTaE2klchFi08cenQWEcGJ3vZV8kVet9qYtaNYhLBn3tLzoiB9wEW3dlOckx4FZLJvNgkKFSK61ndBjAaqGSOAdeZEGWny75PiT7gDn5dkP3T9Pw6uABbaYDHnI4S76s6VAWD+AMHVby4Crr/4TclOvUcFsMOiZLG9BAJDE1gru04JOpWWhK3K4Jf/BdrxrUarrNB12dubmpR7BsuTes5DrbobfsGZxoY8TYkXbrnj79+TZ0YzrFbwir87luUUyKScxhZj/1rULIxnGi5CQzozVCRI+Grol2tiU3bOEUlGI+TrTrGag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=2TAmB6Yz5h98xFccnM5g68u1Scl9jfq4y1eKw6dYSR0=; b=M0GyTBbroJCZV1Z/bIrx16eKpJR4/9ejU13wUhhEc0fnaoJ/vsuEVbtRPRDO+/nwhRHhWkWFTewWLfy2KsTo31YFw+4AMY/8QNxrZp61ZorUtP3uy7/Q55KkumyZ4+TTMbDEDQxZfSAjZNjA4CC+xKLY341WUt4+05K7xulssCB7yDOfFuut9lf8GHDwq/KJImw0ClRDi7G9ciu2u//oA5dVQPuX2DYScQdgtJ2UolNc9i2datHKqj9M/xNAO+BrvxE4mrK/AeX8w3eThS/NNmMlNWZ47RxwnCtoV2tE9ixkW+8wuV4gfQJVjJCTdn5K7d4bpTRHe0DP1mxDN027Dg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=2TAmB6Yz5h98xFccnM5g68u1Scl9jfq4y1eKw6dYSR0=; b=nYYqt0INqHUBN92sMQYzLnIXsbnOHCE7pPahjg86tX/gohYGdjifHKti/QeCg9EJF0GdpOevFoZ3WWvbgryWKnWW3PM9WMwqdrSLJ7/sxAEm607SZvF1BLghFBHxuDRiD9OTarlGNPPsD371EOtDjnEcOS9houongStjQrtiD+k= Received: from DM5PR07CA0074.namprd07.prod.outlook.com (2603:10b6:4:ad::39) by PH7PR12MB7426.namprd12.prod.outlook.com (2603:10b6:510:201::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:32 +0000 Received: from DS3PEPF000099D6.namprd04.prod.outlook.com (2603:10b6:4:ad:cafe::1a) by DM5PR07CA0074.outlook.office365.com (2603:10b6:4:ad::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:32 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D6.mail.protection.outlook.com (10.167.17.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:32 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:31 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) 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.34; Wed, 6 Dec 2023 03:33:30 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:29 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 21/30] spi: cadence_qspi: Enable ECO bit for higher frequencies Date: Wed, 6 Dec 2023 15:01:32 +0530 Message-ID: <06e7b0cfecbc30d26429bc5d4989a287a5e812dd.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D6:EE_|PH7PR12MB7426:EE_ X-MS-Office365-Filtering-Correlation-Id: 871a1cd8-ecb0-4bac-fbe7-08dbf63e698e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1QX2apspMsnDqOunC/Uo/EHnkfjiL0qgP1U06ya/BaDM+JTYNzKa7qEC3Hq09RwGTfFbXQ8nOMKd+ZQ1z1qMqdpbayzzd9qlmX7Z5/VEvZ2oOvW+ImkDQoiC/lZ8kaktqJ5gaAk4a0Tu0zARNqTnnSkvAnMH95S9i/2l3DG+Ghd405I1xAURWAZ3R6zYtDe3KfpmalfjYgoejgWummj8h+I/blC6F20RpXMZrqXW2oYGxLFibZr716FpTt3Pc9Huv+WvjnIx+ap9Ca2CVAUkgligpJorqpYLogfg77LEZ9Snh3SAsVmkrbK/th/FRR+/SNlCdDffoTBWICESL22ZAAvrxN8r7A1b7ItwD9s2N+/HRrI1xnU4s1vD07CdxpnfEy8807cXeAnWFe6g9Bkllcj8drSc6vZMvNzyHKsh57saZSja3D0iM2ZrbxIqVrS/my9QjQZqiiBvu9L1+HAH73pSlTDLm4XMtEpCGMg9xW09W+kg8888tHa1ljOcLjucDTGDrmqA5d8vc93St0GW/+8L4M1GaqN1FC5FmnhNOXxWrdJU6wMu1DhdiklNG09TubV124Qe/HHLUovZKlIicNFOiM3LFJe8AMrDcyjzen+cU/f6IdjmxH5+T2IyO36E5MjAuAtI/ADqUjeG/AhLn2tP9qPbUeHG6oXqgy+zyNlMH05CPOgj1y0mUtDTgAW//+mdyatIhOV5w3wsRCJ3RFePRmtVGxJwrKRD1a3S25p2Z3j98EUfvAIIrEAFanhdysYU/sOcB8zOTwiBSDZwNQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(346002)(136003)(376002)(230922051799003)(1800799012)(186009)(82310400011)(451199024)(64100799003)(36840700001)(46966006)(40470700004)(36860700001)(40480700001)(6666004)(478600001)(54906003)(81166007)(70586007)(70206006)(356005)(316002)(26005)(2616005)(47076005)(4326008)(6916009)(8676002)(8936002)(426003)(336012)(82740400003)(5660300002)(2906002)(40460700003)(41300700001)(86362001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:32.1503 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 871a1cd8-ecb0-4bac-fbe7-08dbf63e698e 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D6.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7426 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Enable ECO bit for Versal for frequencies above 120Mhz for octal spi to work properly. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi.h | 1 + drivers/spi/cadence_qspi_apb.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/drivers/spi/cadence_qspi.h b/drivers/spi/cadence_qspi.h index 73ef44fc1c..4906b9ef96 100644 --- a/drivers/spi/cadence_qspi.h +++ b/drivers/spi/cadence_qspi.h @@ -55,6 +55,7 @@ #define CQSPI_READ_ID_LEN 3 #define CQSPI_READID_LOOP_MAX 10 #define TERA_MACRO 1000000000000l +#define TAP_GRAN_SEL_MIN_FREQ 120000000 #define OSPI_CTRL_RST 0xF1260304 diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 052d7a1766..43dc4c6e70 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -382,6 +382,10 @@ void cadence_qspi_apb_controller_init(struct cadence_spi_priv *priv) writel(reg, priv->regbase + CQSPI_REG_CONFIG); + if (IS_ENABLED(CONFIG_ARCH_VERSAL) && + priv->ref_clk_hz >= TAP_GRAN_SEL_MIN_FREQ) + writel(1, priv->regbase + CQSPI_REG_ECO); + cadence_qspi_apb_controller_enable(priv->regbase); } From patchwork Wed Dec 6 09:31:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872534 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=eX6uW16r; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXMh26Yzz23mf for ; Wed, 6 Dec 2023 20:36:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CDC9687884; Wed, 6 Dec 2023 10:33:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="eX6uW16r"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A13F587884; Wed, 6 Dec 2023 10:33:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::62a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 79C9E86F64 for ; Wed, 6 Dec 2023 10:33:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lGQpy1eLB12iOoqPmGIIT62FhGaA0mz9ajrXHFPPTgD6vzlQ2LbtqTW83t/YLULfzEe2GcBqMgndKfz8PDB1fgLcVdPxbOjp+0lxKLaMnZKfbM81Hx3x4nBPdznarwzMd+IvIp/Sv9h4InbnI6intE3a50k6EKIhq4n61FOhVb49LvE5U315jm2Z/wHjgXeFgDfK6FC4+9JUOt0SQShEw/zcghnAkyj2XqKBJT5XXgxJreC94u/y64ujNm8LaKOF4Y5U2qpSzNI5DBj2ny5cqwdTQZToLtunJZJ/MRU0ofQJwuo0HAhBUsYkIScMdtCvD+dXoIivJkXlh78yMu7kBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Rg1Sur1rkRIAz4YlIZHiJx0/GGwSVH8HPtBDANkDUZM=; b=TZR3cndoXl+HJPmZITLYwmJYaKXJIqTPuBuc2fE7C9TM/QPh8apLPctmSngpmsczqBJkpGbUO62Cd+xp+obTTD9MPrOw9V2hcwBULIBxClxKvMCfNBsNB7YrkPfPiPiMats/OaefUtPg1AbQxt3unhi7rHAuV8MW4wVMJXlChxF9IgZ8vAMHqRTkY0XCtYATixB0YUxjofnvoDw4QP1PjnMgZMNMCzl7TIHbhe3k/a2M/8nnmOgQ/+Pa4DdLg+Hj9FSH/uA8BLGqisdFJuRCEwPWkLfdvySU8FzdpwkTXayA7robFZOs6MnLapnFiCA5a5RU05vdBj4PDIMvvEFC3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=Rg1Sur1rkRIAz4YlIZHiJx0/GGwSVH8HPtBDANkDUZM=; b=eX6uW16rmdtqaWwNCeHOVAL1tUvdp+l9SWyXbSX1wND2p78yqlXoFJhmN8aIipQqA6Is1Yf+C5Jd5PLffa0UDy9TWM8zIHh/ELrUqZ1Nblg4eDUOHLu8/rctoYvwrE/IbycwCTClpjSuONTJxop8i/VcN+Sjd4+qnj537VaJpMw= Received: from CH0PR03CA0410.namprd03.prod.outlook.com (2603:10b6:610:11b::22) by BY1PR12MB8445.namprd12.prod.outlook.com (2603:10b6:a03:523::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:33:35 +0000 Received: from DS3PEPF000099D7.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::3a) by CH0PR03CA0410.outlook.office365.com (2603:10b6:610:11b::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:34 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D7.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:34 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:33 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:31 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH v2 22/30] spi: cadence_qspi: Add spi mem dtr support ops Date: Wed, 6 Dec 2023 15:01:33 +0530 Message-ID: <0be5d24a4068ef3bb1d8df92d78886f4e0879362.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D7:EE_|BY1PR12MB8445:EE_ X-MS-Office365-Filtering-Correlation-Id: d87683ca-f6bd-409b-94bf-08dbf63e6b1c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BUyw8woNYeQp0h6mR/goPqg6wABW6sSo4VAb1KLi+z6SgpQgI4ztLtVsy6x+8pkWHmsLZZCnWRE1F1t51BePRW5vg9yzHe37GrMHy2fnOivCTCib5ihVW9dHUQCOmCok2XjkseCosLbFhYg6UTIryITs8yM+nLmv0VPVXYFDF/sLXHUO/fG/b2+1/oHnEpN4pxyb9Pvo6/Eu6ciUz8AaEYheUXM6By58vyXPTPwK/dumL+mFOsR9yiStWr6cjW3Vp0AUg7Otv9my/q7ylsrcqIjAql55RmMwbw0SnSJRukx21DJo+E3F6mWOxq3SkN3ZSfrFmOupSxnEGa/cKrqTGmMUc3vYOJyjmvoa4JcW0Jl3mUqEakZuizrOAn0O5lmn5lSiTmDsMFb9CBO4QaGabmC7T+q99MexkjJ9QdZZCB4RmtbiXXpJZJVsiQ/Ht4TACkLj2sydy7o+b8STq4TIajAc+sJAF7tPl2T1MS+3rKycEqtt+bVOISicyM201UdL5DiIB4mMkQ+Zcz4+AX/Q1CdWWvQ0uJJVSdN0xFH5fgooc4912pm/is5EgGa/Nip5UwS+F9Bpp1prOIumUjLV0iC4tVffWXSs87jzIuvmcr3W44F13GvJpyoDNuBdSGSQmoZXXwbWnab3DI22YJrNgs/KEZZ5BOvcLigDnvpkYbon8rih3MCAoVbR2dqJnbqfi6GDJCRgdCoZO9bx8r/XCs77ae9tkTgNMNOsOFPPVBYFaaVOh622v5AKIanQdgMh2VhB1mMk5ifOt7oi4bdaiQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(39860400002)(136003)(346002)(376002)(230922051799003)(186009)(1800799012)(451199024)(64100799003)(82310400011)(46966006)(36840700001)(40470700004)(83380400001)(426003)(26005)(336012)(36756003)(40460700003)(41300700001)(86362001)(4326008)(8936002)(2906002)(8676002)(5660300002)(6916009)(54906003)(70206006)(316002)(70586007)(2616005)(478600001)(81166007)(36860700001)(356005)(40480700001)(47076005)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:34.7560 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d87683ca-f6bd-409b-94bf-08dbf63e6b1c 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR12MB8445 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy In DDR mode, current default spi_mem_dtr_supports_op() function does not allow mixed DTR operation functionality. So implement cadence specific cadence_spi_mem_dtr_supports_op() function to verifying only the command buswidth and command opcode bytes which satisfies the DTR protocol. Signed-off-by: T Karthik Reddy Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/spi/cadence_qspi.c b/drivers/spi/cadence_qspi.c index 710c4a532d..282028c845 100644 --- a/drivers/spi/cadence_qspi.c +++ b/drivers/spi/cadence_qspi.c @@ -718,6 +718,21 @@ static int cadence_spi_mem_exec_op(struct spi_slave *spi, return err; } +static bool cadence_spi_mem_dtr_supports_op(struct spi_slave *slave, + const struct spi_mem_op *op) +{ + /* + * In DTR mode, except op->cmd all other parameters like address, + * dummy and data could be 0. + * So lets only check if the cmd buswidth and number of opcode bytes + * are true for DTR to support. + */ + if (op->cmd.buswidth == 8 && op->cmd.nbytes % 2) + return false; + + return true; +} + static bool cadence_spi_mem_supports_op(struct spi_slave *slave, const struct spi_mem_op *op) { @@ -740,7 +755,7 @@ static bool cadence_spi_mem_supports_op(struct spi_slave *slave, return false; if (all_true) - return spi_mem_dtr_supports_op(slave, op); + return cadence_spi_mem_dtr_supports_op(slave, op); else return spi_mem_default_supports_op(slave, op); } From patchwork Wed Dec 6 09:31:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872535 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=lUFJGthE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXMt2KV7z23mf for ; Wed, 6 Dec 2023 20:36:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38E8A8787B; Wed, 6 Dec 2023 10:33:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="lUFJGthE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBB2B86CF4; Wed, 6 Dec 2023 10:33:43 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::623]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id AE19D8787B for ; Wed, 6 Dec 2023 10:33:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=djHFUU5ERgcOfNL6kYdq3vq7+L/2Fjzd1yoX0VqSPfZh8pOffRgde2Kz1XLf8IeBWV2VGf5095LJKTe4suoq8e+r8uYYiV0TnAbai+I8wa2oDvRHXDs9Va7PzIfl0Y/Z1//M5hyIxbP+qwhyw1W/OocXw673+ogufA3crFAuUQYxu2X1y15M9/DX041NavafZ1K/Hwz2WIXfsFvNjfD4UDtz2K9nPji/m3jM0cjQUfj17rScQivfav1FP9tNvlt9Sro0tTiml+f0mXB7TWG4Z4NgESWC0z8MM2fzbWH9w3pKqoyFyO2t9DmFXc6MIym/epEG9RQNIbOcwc3p8UgiWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=Z0XUqSqybeRAgvEfeu9FIEziBIIS85pKuAEThLv90wk=; b=WH63s2BAlO8cshNAcZ0/gTzf4CxXqjpsJRV9iFoHX8k+bV6nubK79ZeSjcYNraGhK3u57RLcyqmhhieoqaw8uUmiY81jm4lCcYOx1Z+pjco2QZ6niFIU6/ZybHhDqzYx7pJV7MVjGCKQOIoWsiPFE+6jFkr5D01VCRaRcOuc/hTpGzcTBO4CD63gOUQJeSGGjhFwLEXItJNfKhY4F7KebtnHvalhuCmfTwkoBLgxk/DrL7hnRubHmarecuv3rfYSIWch3USq+0EPGgnOu9mOmBtRLJPQiUvUTM8SZ5ttnzaQChZMYxf8uLGnkVuIYrKSN1n8YEqTT7VvwBPI69cgBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=Z0XUqSqybeRAgvEfeu9FIEziBIIS85pKuAEThLv90wk=; b=lUFJGthEPulvvgscfHlbUVRQmZ1XgU8XslRH6Edh21TCzw1TNMwEHHLyrB5HteR2SUHoNJW4r8a1XK5xfqjIwmeH/VMSickbvtovZ2uEFWw8EEYLmkmZyf3OkQdcskEZG6v1/+D0HFWtydwR3AXdyMBUVWLYEDZKu6jeLYq3pcg= Received: from DM6PR07CA0074.namprd07.prod.outlook.com (2603:10b6:5:337::7) by IA1PR12MB6259.namprd12.prod.outlook.com (2603:10b6:208:3e5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:37 +0000 Received: from DS3PEPF000099DA.namprd04.prod.outlook.com (2603:10b6:5:337:cafe::7a) by DM6PR07CA0074.outlook.office365.com (2603:10b6:5:337::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:37 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099DA.mail.protection.outlook.com (10.167.17.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:37 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:36 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:34 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH v2 23/30] spi: cadence_qspi: Write aligned byte length to ahbbase Date: Wed, 6 Dec 2023 15:01:34 +0530 Message-ID: <4ee70ae802be4841b64c7f64d9b3a4538e110869.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099DA:EE_|IA1PR12MB6259:EE_ X-MS-Office365-Filtering-Correlation-Id: b816dde3-e6a5-418a-e4d3-08dbf63e6cbd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XO0y225h5YmqBt1o2W4lU/WMMHJoK24SyqAYQ0322OzIaFuNwCAZ2oV4KGF7bPPnqmXxXsKN5PSIGVxJutGXDYhGgmF6pwW1WVG9XEWa2EkkiE0DcyebF9HH7FCqzJKFd4ACda2iHn6Y8X5fPJfDyYNwH7/Tc698XTVPbEX6im6jLgb2GmOYxxgohceWwag3Wxj96xqJXbZyg8fTm5wBZE5Tgt0KrYo7ld0k5iQVsnSLUYOQpteB8B9ikOhEooTKoy9X0nJBrnseLPOc8eHdkO7dqzPqungk8qEqszdKDqVO0RM2TVPJROUscbi+X8KEENQx4RFjFOgzpw7sUxnK2BIQRCjyIFTjdEo9pdXZ9B6H17eWp+R617GYyd0Yr3aupxoWlTM05XF0KkaOmy+qR2Sv9q86d30Oi+yEVPOMoI8i1N/zd0yuByc6eDbvWekNufu1a2vyiGA2E1sx9h5d/lM3h2bCUegVBeT2KaFdy/GTKY1SiVvq9EwgoVAgws1zS1/LsTP1+EYd7w9G26nORuvRc5LRtBNI1JuVwHbrydt2Vt33AgD0xA3uHb1hoUq6Qvu09vsRtr/otrXERzJqnAnOK7SveggSlOfYZoVVd/6pn7wZo6xc9wREnRL+KoqHJw7eJm+OHzNY+vIy/HSsrRFGGQmTc6vGAmqNZERT+Kqq6eZ13yKK0cgbWTHiuO6F+KXWuV92qi4kDYts68W1eMLHYAzQiBObqGCARytGpHn/IdAs7g5dZ1b4YecWUlcsOy1lzExk6W8z0sI5xTXzMA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(136003)(346002)(396003)(39860400002)(230922051799003)(64100799003)(451199024)(82310400011)(1800799012)(186009)(46966006)(40470700004)(36840700001)(40460700003)(5660300002)(82740400003)(2906002)(36756003)(41300700001)(86362001)(478600001)(40480700001)(36860700001)(83380400001)(2616005)(26005)(47076005)(336012)(426003)(8676002)(4326008)(6916009)(8936002)(81166007)(70206006)(70586007)(356005)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:37.5065 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b816dde3-e6a5-418a-e4d3-08dbf63e6cbd 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099DA.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6259 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Ashok Reddy Soma Incase of non-aligned length of flash data, ahbbase address is written directly with byte count. This is causing AHB bus error's sometimes and resulting in kernel crash while booting linux. To avoid this write 4 byte aligned byte count to ahbbase address. Also use a temporary variable with 0xffffffff data and overwrite this temp with unaligned bytes data before writing to ahbbase. The value 0xffffffff is chosen as this is flash memory, worst case we will write 0xff to any location which doesn't effect any bits. Signed-off-by: Ashok Reddy Soma Signed-off-by: Tejas Bhumkar --- drivers/spi/cadence_qspi_apb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/spi/cadence_qspi_apb.c b/drivers/spi/cadence_qspi_apb.c index 43dc4c6e70..1d0e6c2180 100644 --- a/drivers/spi/cadence_qspi_apb.c +++ b/drivers/spi/cadence_qspi_apb.c @@ -934,10 +934,12 @@ cadence_qspi_apb_indirect_write_execute(struct cadence_spi_priv *priv, while (remaining > 0) { write_bytes = remaining > page_size ? page_size : remaining; writesl(priv->ahbbase, bb_txbuf, write_bytes >> 2); - if (write_bytes % 4) - writesb(priv->ahbbase, - bb_txbuf + rounddown(write_bytes, 4), - write_bytes % 4); + if (write_bytes % 4) { + unsigned int temp = 0xffffffff; + + memcpy(&temp, bb_txbuf + rounddown(write_bytes, 4), write_bytes % 4); + writel(temp, priv->ahbbase); + } /* Wait up to Indirect Operation Complete bit to set */ ret = readl_poll_timeout(priv->regbase + CQSPI_REG_IRQSTATUS, cr, From patchwork Wed Dec 6 09:31:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872536 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=di4P2OmD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXN44Q8Dz23mf for ; Wed, 6 Dec 2023 20:36:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9A22A87896; Wed, 6 Dec 2023 10:33:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="di4P2OmD"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BA9387890; Wed, 6 Dec 2023 10:33:46 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::625]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0D1DA86CF4 for ; Wed, 6 Dec 2023 10:33:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYlEikpmiu/XfwJnqcbIUzYGN4ct5PO/9L6mf6OgTqiTd1meGQup4vTFuMp4NcLafN2UDGy9KBgKY2srVJxVznVh9PgyXXVEz/SeBy0d8no7FN9r7RM4Bup1/9NudgAPFzSiMvKMrqhe80AHSd9+Pz0Zuz7VQ+cP0E4G8tkxAinIbjmFevhhTaKwUqo3ol7+9K/ST2tL/GdSf+mhRau1yRkNt/FnU42xPJGEGOsvs8sBA8pexAm4ao2ic8quF+ArDfv7wsMskXpmFME5rDyCsF5+J9ZpYv3QP/d7Tg/6wL5QIq1YFle/Yw5CfuU0e52366BeVkhsVwNa8sEmq7UDRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=1RhWx2Z5GG4Qt/4vk/WG6Rol49RvR0Q+eKE6lqk/WJc=; b=CbbqqTi+7FsHWlc3y4fO/vtWlC2Q5mrhX5l3ha9uNdSwLhNR8hCFt7t79JgJAOOZW85z9WiDaj7tBWICWzcPnVkYKkyUC0rL2qAh3bqppT6/mLbSyvtMfg6FnM4T4b/R/yx46G7+Z/9qWzwccrZTs7uLbokASP9PXx3gbYRlD62LiYMg4rZpiwLgrDyOiXnZt4h8ESehiNns2v5kZyi2OKY5W4fLUrnoVtyqVAeO55n2Ob5udgiF88MRCDCYdD/Rg+cIOT72ClxXaMtxOmaZCrawZV2GF0ir7YHnvsdqhbET/Alz9hvY8pNWiiogE8P2BkIGsZLZtZWaEr9EJ3xqog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=1RhWx2Z5GG4Qt/4vk/WG6Rol49RvR0Q+eKE6lqk/WJc=; b=di4P2OmD2tbsQC1XzQGyPOqVzlAOnTGtEZVh/wdIaAiXH2NxKE7Ci56ngp1CLsX8GYh7I0c6EKhjyfImebcwguG8xuwDTNZj65VEM4Ifh32vYecLRQYNWozehoRubJrpKwGqeJ4ixBnHPmvLGlmbWzVkCYtHEA1rc7n64iK6AkE= Received: from DM5PR08CA0046.namprd08.prod.outlook.com (2603:10b6:4:60::35) by SN7PR12MB7299.namprd12.prod.outlook.com (2603:10b6:806:2af::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:40 +0000 Received: from DS3PEPF000099D5.namprd04.prod.outlook.com (2603:10b6:4:60:cafe::a4) by DM5PR08CA0046.outlook.office365.com (2603:10b6:4:60::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:40 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D5.mail.protection.outlook.com (10.167.17.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:40 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:39 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:37 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH v2 24/30] arm64: versal: Enable soft reset support for xspi flashes Date: Wed, 6 Dec 2023 15:01:35 +0530 Message-ID: <2d016a05ace4d4d09400074a5e4363e57528dee5.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D5:EE_|SN7PR12MB7299:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e8951de-f932-46fc-1aa9-08dbf63e6e5a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pHVZlxgu5Do56aZpl04WJSgh/jZsoUxk2JmuD4+HLCKOjWIwBH/Oebrxp8Gyuk7CIu2GM1K2DhmV5Hbh9ceMYgHcU9dg5r4rAWZni4MegzpCkhjUCm68HjCIFTC1rmrq7JJsYHMFJAWC5lJsW+4vbZvYUHFm9JeAHl4Mq2F4VbSK/L7bnJswegxpGexkbBXFuw65Jn5icxCGfiFIKdikGqCkNF2PnZEoZ7lOaGGhmEMNbsRohRCUmYDoUV3l9UElHGUHJ9HVYSJoFbygQ6W4P2YM7qhN7JnGo5myWyOqfCKXXIoJegcUy/13sgAq7LzFPAxrbgesnMFIRRNkP808rk/Q8+31y2xxaYfnZ1VJapPO2FQGatNBMkuyQpam6IggWoWTmkNtLk5rlH7ggfFztpsfP3AA3/ud4JC6YrN8CxxSDTDjTXSsYXplaeawMXWMo42lxJ63qy88wdI77OTyxdFpum5AZedQaR3+oc81yH6ic8/Si/c9pDBMSz2Se4y3jFhj+zcxQvuCSOW9G63v3cPNt7zBp+9dwIo8gEMFsUTbzPHpYG3lTHRFO5dQIjwziC8L686dQhg2oR1qnSFZd9MZhBTWvTSY+2Sn8DGqCWtd0VlxEe0/mzx741X0po6spKNYv7TsHqpEpvowKwECZBtJOuDfq8q+XZ5viKYkdGSjjzP8OshYK6fagSPdVVWcTj5YkKyMbpS3Ev1U3Tjn19+ACJRJ+LsKEIgOjPMX9EZtxG3p1KYBswxsVWTOAA26+fk1itcoqJ/lmXDoGaLqRA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(346002)(396003)(376002)(230922051799003)(1800799012)(64100799003)(451199024)(82310400011)(186009)(46966006)(40470700004)(36840700001)(40460700003)(478600001)(316002)(54906003)(4326008)(8676002)(6916009)(86362001)(8936002)(70586007)(70206006)(41300700001)(36756003)(5660300002)(2906002)(4744005)(81166007)(47076005)(36860700001)(356005)(26005)(83380400001)(82740400003)(336012)(426003)(40480700001)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:40.1923 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e8951de-f932-46fc-1aa9-08dbf63e6e5a 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7299 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Activate the xSPI Software Reset support, which will be utilized to transition from octal DTR mode to legacy mode during shutdown and boot (if enabled). Signed-off-by: T Karthik Reddy Signed-off-by: Tejas Bhumkar --- configs/xilinx_versal_virt_defconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index ec7caacca0..ee247b905f 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -95,6 +95,8 @@ CONFIG_MMC_SDHCI_ZYNQ=y CONFIG_ZYNQ_SDHCI_MIN_FREQ=100000 CONFIG_MTD=y CONFIG_DM_SPI_FLASH=y +CONFIG_SPI_FLASH_SOFT_RESET=y +CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y CONFIG_SPI_FLASH_MT35XU=y CONFIG_SPI_FLASH_GIGADEVICE=y CONFIG_SPI_FLASH_ISSI=y From patchwork Wed Dec 6 09:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872537 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=zT1X5osj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXNG4RtNz23mf for ; Wed, 6 Dec 2023 20:36:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16BFB8789B; Wed, 6 Dec 2023 10:33:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="zT1X5osj"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E67D08789B; Wed, 6 Dec 2023 10:33:48 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8c::61b]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A281386CF4 for ; Wed, 6 Dec 2023 10:33:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eelg0i+Okt4uAVKGTOmYdQ3PcxlrYYaqk5BxAD6+h9/3o4s1wnyiwJ/RKYk1IjyHYbBz/QrMA3yQAgpGZr+e6mcjOIPzQKQLF8s1wmk8snrNEzQRzjpUoT+qLuqnhRZ4rEwkK0+VKbSFtK6XLXDrV09/b1F0qnyPtoqAEe+RxQhRDq/fWPyjNE1u8pPJXNhUM7wg9e5t+/9V15liDnl7IMpNh4FHoH1/fau5Kqoy16EZKcLzoz1QX38VjwLXrvJn9OptgdxV2pHaaJchiFQPcV9y/RQeauf6+IkldNhVjE9W1caxSIhJvtxWl+B5ipcldQh+baODdWZCmrBVznhRqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=I2l5FhzsUA8aU5d0uHnyzBdztUFh36esFtNte5Y0XR8=; b=CrleKfgdWxkTu/Zt0KqTEGmssv8by2SnsCgAjGXzKuk6U0gZRNsrEMLgvuGL1MT/V4YmquDZ488UnpCfGfjMunuzisAYAxcI/uE23/x/HVIvYuFxefoUpwzg7jYTCcMp/fWB+LbQhaI7IzzLg1zFAqLmfnoIUigvGk1Z/MdrVn2nNZNNbMCV9oTvRdXtMcwc30REwO770TE2kT3fWulAkodELhcoSiPbZDWnALdEbeX29gthSNuRShAPNJQkyP92rigwql0bzYxf1650Tg9Z3KtLFHnnRqMfR0mXUGy3iIR55jNsoq9XUGcdeVSPWV0fVz5RuRbWjES0vGNPSc53ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=I2l5FhzsUA8aU5d0uHnyzBdztUFh36esFtNte5Y0XR8=; b=zT1X5osjlqKx+nwUw5mA5Lo440iuXTQWYERXY8CTHADPrQhPTSbMxbmMUvsyi+6uC92m54vcXf26lP+VOClFeGQF18nXaVGgJ3EHM61WrxQUOxbyR+p25pcQDD1zSwsAgO6t9SQDSxyUot1z1tygUlQrwkrM+7kND635GaFfwPo= Received: from CH0PR03CA0402.namprd03.prod.outlook.com (2603:10b6:610:11b::23) by PH7PR12MB5925.namprd12.prod.outlook.com (2603:10b6:510:1d8::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.27; Wed, 6 Dec 2023 09:33:43 +0000 Received: from DS3PEPF000099D7.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::5d) by CH0PR03CA0402.outlook.office365.com (2603:10b6:610:11b::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:42 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D7.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:42 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:41 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:39 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH v2 25/30] arm64: versal: Enable octal DTR mode Date: Wed, 6 Dec 2023 15:01:36 +0530 Message-ID: <810266c0acfd767c9598976a9faf839515ddeabd.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D7:EE_|PH7PR12MB5925:EE_ X-MS-Office365-Filtering-Correlation-Id: 653361d8-0c55-451b-fca0-08dbf63e6fd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZhtZaM2f3Q31zbi+R70K7D2P6MG9R3eW2nUEpOICVUm7fACp9bj0joFADPhQDl3tE1MeASX/yhWR/865BMzR7+nTfV9QWXQG14dJlU0LCBVMyIekbSXUvIwykA/TTHOaFJvlc9JhGw1rIPlPVi9y4bra7THOCjwP+ZACwoxAJ/gus0tmTk22z7hcKYmyeZbeVvnLW06IyJrlVfcEwfL+Xxpo0CaUQGSCRllrznQrcts+qZ3ybx7tcR0kuxk5ie+XWL4Lx/Lp5lbJzjJScFE77fn7quB4l/h6/QqEzHcmbUeB0lXdtIp3mz25jnSs/Mtuwc9Ibq9wFS9I/Vuic6epc7RGJKqh9tMquPZyHhDcsI133EjkUHp77lW/FKW/GJkzW1S6Zj0C8RTOSodzCaDouNH+Ru2Rg5zcmFsRU+igA0ZRAwZJambB4YfFWYok91P1aq8CZ+IqRx4bfOoojaGCJlf1GCfGdcBfv4//t/Rjc4EtZnoWvLWYbFeV+2djneGZOM8f+dApWNCQtRh2amuBxw6fnHPfgpeXIdQbGjB8XTX2E//i57Ds7kGv9YC2FtFzPCy3R01SAPE8Ib94HnIpqN4Obd8KdpkbrL9JxDECI0bFu6YoYPBL3WA/BzTDxNUgzH9x2yB/z1mbJ8OGQvNfUu1f0KD7i0WyRe/7PBSFE/AICjeDMuinIQwcGitlWybxxD80irRvRFBi8raabX3MRxVVbvV41WxGkcxQaVLGvViwKLAa8Q6VqXRmcJRYYSpWYOq614t7pBH00OEFn0/kbA== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(376002)(39860400002)(346002)(136003)(230922051799003)(186009)(64100799003)(1800799012)(451199024)(82310400011)(36840700001)(46966006)(40470700004)(36756003)(6666004)(107886003)(2616005)(86362001)(4326008)(40480700001)(6916009)(70206006)(54906003)(70586007)(26005)(336012)(316002)(8936002)(8676002)(426003)(47076005)(36860700001)(82740400003)(5660300002)(478600001)(356005)(2906002)(4744005)(81166007)(41300700001)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:42.6623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 653361d8-0c55-451b-fca0-08dbf63e6fd2 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5925 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The Cadence driver must switch between SDR and DTR modes based on commands from the SPI-NOR framework and the configuration set by SPI_FLASH_DTR_ENABLE. If SPI_FLASH_DTR_ENABLE is enabled, the driver should transition to DTR mode; if it is not defined, the driver should avoid switching to DTR mode, signaling that the controller does not support DTR. Signed-off-by: Tejas Bhumkar --- configs/xilinx_versal_virt_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/xilinx_versal_virt_defconfig b/configs/xilinx_versal_virt_defconfig index ee247b905f..69835fce55 100644 --- a/configs/xilinx_versal_virt_defconfig +++ b/configs/xilinx_versal_virt_defconfig @@ -98,6 +98,7 @@ CONFIG_DM_SPI_FLASH=y CONFIG_SPI_FLASH_SOFT_RESET=y CONFIG_SPI_FLASH_SOFT_RESET_ON_BOOT=y CONFIG_SPI_FLASH_MT35XU=y +CONFIG_SPI_FLASH_DTR_ENABLE=y CONFIG_SPI_FLASH_GIGADEVICE=y CONFIG_SPI_FLASH_ISSI=y CONFIG_SPI_FLASH_MACRONIX=y From patchwork Wed Dec 6 09:31:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872538 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=GVhcnQsR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXNT3275z23mf for ; Wed, 6 Dec 2023 20:36:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7BD6387890; Wed, 6 Dec 2023 10:33:53 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="GVhcnQsR"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C4D3F878A4; Wed, 6 Dec 2023 10:33:51 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20625.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::625]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id F16D286CF4 for ; Wed, 6 Dec 2023 10:33:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emoNrs4xV87R1pAjFpE5/nbOcGfLiLqw/AELLXG6CJ1YoCRU9bBYrRzT33hqag/b35R7ZMLQebZfbPLWkTUT0lpQXAQcObTVcGdGHwA9GJXN5BsOULG+eFQPnHoQlv/k0Ryz1OkO3tnqqyKvVRIRw9/NFNrsvVs9Q0ILdGEv0T0Fp2f2vM4FzJdgRnMYtSxftajbltV6tB2mQy/gT7FmFzYfnY/+SXFeA5+x8VsKYnBlKHE5msPYcirJZyJxUwsTkUBZ0wrOzzEQGDmVMF/NuAFKcC55xMUAeea/e5BTkglGb6ABQYqW+5LDw4kNzimgI0Eq+7JPCiyIU/OY0zDwCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=bbL647UcEHlj0GiXoNktZv2UVy5GWTfSY+rtkn/2hq4=; b=hPmob+djzY3TZH0OR8pj9H9q4//azCkQa0bD7Y2Rv2EhvyOwMCfwkyBhFO5T831wFz9v8oxEoXch90FKijBlYzP3CxKZNtBjz9MFUHZxpOaVhGb0uDuxt/5zvKJ7OHzdXhh0oOuagoP7A3MYQNXNwrpQ/+Mxz0cY/JirH6nCRQdsjlSZffAQHn3GZSliK6GD8OYRdxIfGX56LHx9o7g3oVxygQg9LUJuB7Gh5vE6SzuNNT+OBn+0Z5Q02BswNBviXDLEwoziQc0koGDSh530U11tM46dDwxg9fbY+aXf7uc9SE/b3zEy6TCkKyo9MWqQfT+UBUEsg1ismROVZD6kdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=bbL647UcEHlj0GiXoNktZv2UVy5GWTfSY+rtkn/2hq4=; b=GVhcnQsR13OxIeiVxRfT9yewEaY0rnVHH6Z0ry+pNpY4MaZ/f+ndC5tVNIDh3FfZU9laERTINPo2XCsy8YdpHLLUC5Wbnl6HxrvVKGwPxU6yszWb5bInMc/vFAil92UhP8NGCJc2Kj8LePbPdGR5cgBYh1s0vRnpMC9DFkMRlTU= Received: from DS7PR03CA0089.namprd03.prod.outlook.com (2603:10b6:5:3bb::34) by DM4PR12MB7600.namprd12.prod.outlook.com (2603:10b6:8:108::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:46 +0000 Received: from DS3PEPF000099D4.namprd04.prod.outlook.com (2603:10b6:5:3bb:cafe::42) by DS7PR03CA0089.outlook.office365.com (2603:10b6:5:3bb::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:46 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D4.mail.protection.outlook.com (10.167.17.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:46 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:45 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:42 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Siva Durga Prasad Paladugu , Ashok Reddy Soma , Venkatesh Yadav Abbarapu Subject: [PATCH v2 26/30] mtd: spi-nor: Add block protection support for micron flashes Date: Wed, 6 Dec 2023 15:01:37 +0530 Message-ID: <886de839948e46e7ef20089d87cb1da2bb4a3e43.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D4:EE_|DM4PR12MB7600:EE_ X-MS-Office365-Filtering-Correlation-Id: 201f9fac-7d20-4191-23ef-08dbf63e71de X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oVyZP8MiJlkmyU+/zmcJk//0/IZqQwkePR38BiVsgHKc06XcBwUFSNT4GfT12HkKOoPRcvzm7OXhI74mcF0S82DCHJLcjAclJ9YMG2Xg96hiyp/ZTxOv/ha+iGZb2jSNCNyXQAONXcMHQnSG6UjTKVcKJooJqFh9Z5YHQej7lvnELzj6vrXlakryfm/QKZFpEGqwfPqHwCUQ389ViarpyhYGl7B8YFWi2egbs9mo0SDbCFRXPYAkxYjcF+ZiEThQr5m/AtkN/QpVUBajTq+y3P+pFeZrCuCpM1AJyRwrVUa1dqaLjO4RVP7pQKCw7zygU+EWh2DxQhUie5W8aDH0u7B8RNiVLt7BRs5pRhBCmzhrsxpqwfLlemtXf4MU0cE49UsuUb36bOPfaq/LH2Gu9qVpxUa3CKOFGOm8gCPjEXvDLQNO6oZsqfZfZ1D1AVkwSRDjUH1xYnb3TX9aAjhBPo4VfDXXfJHm1b/ixthnshRBn16loJEPjrIeO3465foDagQI52OVc/P8qbk55h8huNodt6UVksKrhNsSPn5GbFUQHO5BWjxmIvmEVmtRm+Vox8X03kAy2uTIT1TnlPY4H5QuHz3I8snl89GgIF86rrQOfRFyJjAsvoJvM25L7fwFWUFRrH8CV2mPOIZNn93xqvVcwegIfYUJ6YbPozvsdtjtUz3d7l7QiZMVLZ64oa+lhe7ZeVxquHx428ef1SleJdTQt4NiZr/cu1tfzGh4lRoXQz9cFIaD9QRPI1gvLsSCa4OvlKH0M0l2wQr3wJnDRg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(39860400002)(376002)(396003)(230922051799003)(82310400011)(451199024)(1800799012)(64100799003)(186009)(46966006)(40470700004)(36840700001)(36756003)(86362001)(5660300002)(40460700003)(2906002)(41300700001)(356005)(47076005)(81166007)(26005)(2616005)(40480700001)(8936002)(82740400003)(478600001)(83380400001)(336012)(426003)(8676002)(4326008)(6666004)(6916009)(54906003)(316002)(36860700001)(70586007)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:46.0908 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 201f9fac-7d20-4191-23ef-08dbf63e71de 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D4.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7600 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: T Karthik Reddy Micron nor flashes provide block protection support using BP0, BP1, BP2, BP3 & TB bits in status register. This patch supports for micron nor flashes with manufacturer id 0x20 and 0x2c. Where BP(Block Protection) bits defines memory to be software protected against PROGRAM or ERASE operations. When one or more block protect bits are set to 1, a designated memory area is protected from PROGRAM and ERASE operations. TB(Top/Bottom) bit determines whether the protected memory area defined by the block protect bits starts from the top or bottom of the memory array. Block Protection table for N25Q00AA with size 128MB, sector size 64KB and with 2048 sectors. Top protection: -------------- TB BP3 BP2 BP1 BP0 Protected Area Un-Protected Area 0 0 0 0 0 None All sectors 0 0 0 0 1 Sector 2047 Sectors (0 to 2046) 0 0 0 1 0 Sectors (2046 to 2047) Sectors (0 to 2045) 0 0 0 1 1 Sectors (2044 to 2047) Sectors (0 to 2043) 0 0 1 0 0 Sectors (2040 to 2047) Sectors (0 to 2039) 0 0 1 0 1 Sectors (2032 to 2047) Sectors (0 to 2031) 0 0 1 1 0 Sectors (2016 to 2047) Sectors (0 to 2015) 0 0 1 1 1 Sectors (1984 to 2047) Sectors (0 to 1983) 0 1 0 0 0 Sectors (1920 to 2047) Sectors (0 to 1919) 0 1 0 0 1 Sectors (1792 to 2047) Sectors (0 to 1791) 0 1 0 1 0 Sectors (1936 to 2047) Sectors (0 to 1535) 0 1 0 1 1 Sectors (1024 to 2047) None Bottom protection: ----------------- TB BP3 BP2 BP1 BP0 Protected Area Un-protected Area 1 0 0 0 0 None All sectors 1 0 0 0 1 sector 0 Sectors (1 to 2047) 1 0 0 1 0 Sectors (0 to 1) Sectors (2 to 2047) 1 0 0 1 1 Sectors (0 to 3) Sectors (4 to 2047) 1 0 1 0 0 Sectors (0 to 7) Sectors (8 to 2047) 1 0 1 0 1 Sectors (0 to 15) Sectors (16 to 2047) 1 0 1 1 0 Sectors (0 to 31) Sectors (32 to 2047) 1 0 1 1 1 Sectors (0 to 63) Sectors (64 to 2047) 1 1 0 0 0 Sectors (0 to 127) Sectors (128 to 2047) 1 1 0 0 1 Sectors (0 to 255) Sectors (256 to 2047) 1 1 0 1 0 Sectors (0 to 511) Sectors (512 to 2047) 1 1 0 1 1 Sectors (0 to 1023) Sectors (1024 to 2047) Signed-off-by: Siva Durga Prasad Paladugu Signed-off-by: Ashok Reddy Soma Signed-off-by: T Karthik Reddy Signed-off-by: Venkatesh Yadav Abbarapu Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 255 +++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 7 + 2 files changed, 262 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index ccda722df5..c40899a281 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -4336,6 +4336,253 @@ static int spi_nor_init(struct spi_nor *nor) return 0; } +#if defined(CONFIG_SPI_FLASH_LOCK) +#if defined(CONFIG_SPI_FLASH_STMICRO) +static inline uint16_t min_lockable_sectors(struct spi_nor *nor, + uint16_t n_sectors) +{ + /* lock granularity */ + return 1; +} + +static inline uint32_t get_protected_area_start(struct spi_nor *nor, + u8 lock_bits, + bool is_bottom) +{ + u16 n_sectors; + u32 sector_size, flash_size; + int ret; + + sector_size = nor->sector_size; + + if (nor->flags & SNOR_F_HAS_PARALLEL) { + n_sectors = (nor->size >> 0x01) / sector_size; + flash_size = nor->size >> 0x01; + } else { + n_sectors = nor->size / sector_size; + flash_size = nor->size; + } + + if (!is_bottom) + ret = flash_size - ((1 << (lock_bits - 1)) * sector_size * + min_lockable_sectors(nor, n_sectors)); + else + ret = (1 << (lock_bits - 1)) * sector_size * + min_lockable_sectors(nor, n_sectors); + + return ret; +} + +static uint8_t min_protected_area_including_offset(struct spi_nor *nor, + u32 offset, + bool is_bottom) +{ + u8 lock_bits, lockbits_limit; + + lockbits_limit = MAX_LOCKBITS; + + for (lock_bits = 1; lock_bits < lockbits_limit; lock_bits++) { + if (!is_bottom) { + /* top protection */ + if (offset >= get_protected_area_start(nor, + lock_bits, + is_bottom)) + break; + } else { + /* bottom protection */ + if (offset <= get_protected_area_start(nor, + lock_bits, + is_bottom)) + break; + } + } + return lock_bits; +} + +static int write_sr_modify_protection(struct spi_nor *nor, u8 status, + u8 lock_bits, bool is_bottom) +{ + u8 status_new, bp_mask; + int ret; + + status_new = status & ~BP_MASK; + bp_mask = (lock_bits << BP_SHIFT) & BP_MASK; + + status_new &= ~SR_BP3; + /* Protected area starts from top */ + status_new &= ~SR_TB; + + /* If bottom area is to be Protected set SR_TB */ + if (is_bottom) + status_new |= SR_TB; + + if (lock_bits > 7) + bp_mask |= SR_BP3; + + status_new |= bp_mask; + + write_enable(nor); + + nor->spi->flags |= SPI_XFER_LOWER; + + ret = write_sr(nor, status_new); + if (ret) + return ret; + + if (nor->flags & SNOR_F_HAS_PARALLEL) { + nor->spi->flags |= SPI_XFER_UPPER; + ret = write_sr(nor, status_new); + if (ret) + return ret; + } + + return write_disable(nor); +} + +static void micron_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, + uint64_t *len) +{ + u8 mask = SR_BP0 | SR_BP1 | SR_BP2; + int shift = ffs(mask) - 1; + int pow; + u64 norsize = nor->size; + + if (nor->flags & SNOR_F_HAS_PARALLEL) + norsize /= 2; + + if (!(sr & (mask | SR_BP3))) { + /* No protection */ + *ofs = 0; + *len = 0; + } else { + pow = (sr & mask) >> shift; + pow |= sr & SR_BP3 ? BIT(3) : 0; + + if (pow) + pow--; + + *len = nor->sector_size << pow; + if (*len >= norsize) + *len = norsize; + + if (!(sr & SR_TB)) + *ofs = norsize - *len; + else + *ofs = 0; + + debug("%s, ofs:0x%lx, len:0x%lx\n", __func__, + (unsigned long)*ofs, (unsigned long)*len); + } +} + +static int micron_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + loff_t lock_offs; + u64 lock_len; + int given_range, locked_range; + bool locked_value = false; + bool offset_value = false; + + if (nor->flags & SNOR_F_HAS_PARALLEL) + ofs /= 2; + + /* Avoid dividing by 2 of data length for size 1 */ + if (nor->flags & SNOR_F_HAS_PARALLEL && len != 1) + len /= 2; + + debug("%s, ofs:0x%lx, len:0x%lx\n", __func__, + (unsigned long)ofs, + (unsigned long)len); + + micron_get_locked_range(nor, sr, &lock_offs, &lock_len); + + given_range = ofs + len; + locked_range = lock_offs + lock_len; + + if (given_range <= locked_range) + locked_value = true; + + if (ofs >= lock_offs) + offset_value = true; + + if (sr & SR_TB) + return !locked_value; + + return !(locked_value && offset_value); +} + +static int micron_flash_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + u8 status_old, status_old_up; + u8 lock_bits; + loff_t lock_len; + int ret = 0; + bool is_bottom = false; /* Use TOP protection by default */ + + if (nor->flags & SNOR_F_HAS_PARALLEL) + nor->spi->flags |= SPI_XFER_LOWER; + + status_old = read_sr(nor); + if (status_old < 0) + return status_old; + + if (nor->flags & SNOR_F_HAS_PARALLEL) { + nor->spi->flags |= SPI_XFER_UPPER; + status_old_up = read_sr(nor); + if (status_old_up < 0) + return status_old_up; + if ((status_old & BPTB_MASK) != (status_old_up & BPTB_MASK)) { + printf("BP is different in both flashes lo:0x%x, up:0x%x\n", + status_old, status_old_up); + return -EINVAL; + } + } + + if (ofs < nor->size / 2) + is_bottom = true; /* Change it to bottom protection */ + + debug("Status in both flashes lo:0x%x, up:0x%x\n", + status_old, status_old_up); + + if (nor->flags & SNOR_F_HAS_PARALLEL) { + ofs /= 2; + len /= 2; + } + + if (!is_bottom) + lock_len = ofs; + else + lock_len = ofs + len; + + lock_bits = min_protected_area_including_offset(nor, lock_len, + is_bottom); + + if (lock_bits > ((status_old & (BP_MASK << BP_SHIFT)) >> 2)) + ret = write_sr_modify_protection(nor, status_old, lock_bits, + is_bottom); + + return ret; +} + +static int micron_flash_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + return write_sr_modify_protection(nor, 0, 0, 0); +} + +static int micron_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int status; + + status = read_sr(nor); + if (status < 0) + return status; + + return micron_is_unlocked_sr(nor, ofs, len, status); +} +#endif /* CONFIG_SPI_FLASH_STMICRO */ +#endif /* CONFIG_SPI_FLASH_LOCK */ + #ifdef CONFIG_SPI_FLASH_SOFT_RESET /** * spi_nor_soft_reset() - perform the JEDEC Software Reset sequence @@ -4545,6 +4792,14 @@ int spi_nor_scan(struct spi_nor *nor) } #endif +#if defined(CONFIG_SPI_FLASH_STMICRO) + if (JEDEC_MFR(info) == SNOR_MFR_ST || JEDEC_MFR(info) == SNOR_MFR_MICRON) { + nor->flash_lock = micron_flash_lock; + nor->flash_unlock = micron_flash_unlock; + nor->flash_is_unlocked = micron_is_unlocked; + } +#endif + #ifdef CONFIG_SPI_FLASH_SST /* * sst26 series block protection implementation differs from other diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 34e0aedc24..03413063ae 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -166,8 +166,15 @@ #define SR_BP0 BIT(2) /* Block protect 0 */ #define SR_BP1 BIT(3) /* Block protect 1 */ #define SR_BP2 BIT(4) /* Block protect 2 */ +#define SR_BP3 BIT(6) /* Block protect 3 */ #define SR_TB BIT(5) /* Top/Bottom protect */ #define SR_SRWD BIT(7) /* SR write protect */ + +#define BPTB_MASK 0x7C /* BP & TB bits mask */ +#define BP_MASK 0x1C /* BP bits mask */ +#define BP_SHIFT 0x2 /* BP shift*/ +#define MAX_LOCKBITS 15 + /* Spansion/Cypress specific status bits */ #define SR_E_ERR BIT(5) #define SR_P_ERR BIT(6) From patchwork Wed Dec 6 09:31:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872539 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=vqeyuSlE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXNg2kJjz23mf for ; Wed, 6 Dec 2023 20:36:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0988D8787C; Wed, 6 Dec 2023 10:33:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="vqeyuSlE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D8AD0875EB; Wed, 6 Dec 2023 10:33:56 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20610.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e83::610]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 6415B878AA for ; Wed, 6 Dec 2023 10:33:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eSLI3A1c4MWQXKdIw685eF4C2Pay1dYT5Ub84YiIF4Rfmc4PPdTC+fHXJfPYXhXF3Ar/xIJYyZ4DO78JEvsTopP862BkA+yeTRPa6XGI+8MaS5POc7XpfqfqPSoHq9xPUxPTigi6BFC5118xX0eIodICY/q+WT80UJRX84Qc44cNJtZ4Qam9fM821EEDEfqPnVQfs5ir06AL/af7ljBLzbZ7XxIoHSgnOZN7cpRkqq/L4IZAGiZBpPWf6oM0HGMUNdrzUhMXw8lt/QiSxvL0Q6vnZDD9BRt9L5e0fR6F6U4nRmagbTqGtYZyuNvpD5WBM3OSrdWm4NkeatR5mAGUfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=AxoHgbVIt495oMyqcXaHf4T9G6zFlgAa5hqq6TdMiLs=; b=KPkhm9sgjrioWNttUEvjSc6m5n62tV+VM7RLKDqxKTncxJo4MRCvjUFV4NXVuiT5mqGx3OkNVaoefSNmeL6bqAE9TJhn5gYNMe/nEFJHB7r6Evd2zb6Uu3iXubN+NEfT6UDVROmkjQTjSI82C/fklucZPHHN8jCpVNeFLg8la8OceKI6kM3wQr/ODc8t48ERGe2MAV0xbHDtrDJt1tXVALRCLqG6FyEuc7weAnK/TaeZGf/+5PDgQRwbCsMZBrolKcL9+dXdelRv/i4iO2nPIFX798SbuJ4Xk7zpPx9y2+Kz+Zgo3T9DGCz8UPQJRvrhAn2BFg/Araeh52JPTigK1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=AxoHgbVIt495oMyqcXaHf4T9G6zFlgAa5hqq6TdMiLs=; b=vqeyuSlE/cLP0QJ5RvQ+XQrUwrhtTM/k/9kHwoeNbJLUQflFBg8bJZcDwadyG+SNtA3/5nkDLM//fe060w/Q1YOudnHSYAkKPjvQP8hTRd8hib9gX4pLxeqEeUNwpMfQwElk1Dt4XSoRdNrkGDsRbrGT1/fXUvjoTxLiac5AmUw= Received: from DM6PR03CA0095.namprd03.prod.outlook.com (2603:10b6:5:333::28) by PH0PR12MB7486.namprd12.prod.outlook.com (2603:10b6:510:1e9::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:49 +0000 Received: from DS3PEPF000099D8.namprd04.prod.outlook.com (2603:10b6:5:333:cafe::3c) by DM6PR03CA0095.outlook.office365.com (2603:10b6:5:333::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:49 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D8.mail.protection.outlook.com (10.167.17.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:48 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:48 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:33:47 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:45 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH v2 27/30] mtd: spi-nor: Add support for locking on Macronix nor flashes Date: Wed, 6 Dec 2023 15:01:38 +0530 Message-ID: <0085dc3bd6374e39a7792db4150ac3cf2aa4a0d8.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D8:EE_|PH0PR12MB7486:EE_ X-MS-Office365-Filtering-Correlation-Id: 6fc398f3-2796-4056-7286-08dbf63e738b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GNVSLnc2+I21gPV3sxW2nhWBW+JndN8JtA6rDieVMRQ34GrEzrCl0XWO8uEp653bhdp/ZmQEneJiBkHkkQA0Qg8OW3wW+R9AvxYxVeKU5VpJyGJZoYwHE4LRAzzXD/RJQRo2Bv0P4Q1TemQv8yvigsrT93nPondwtYkjEY+VXwMUZd9csvHVIDbp+v7+Xi7GEzEHSv9oHcwQbnmq+H4AWOYpQXkuCcBkgt6r4/R5kZL/YsEo5Wv20u+0WJIDjAOk2J+cGbl0SymB/yf7AWoE8kV3GqxnJnaJsgAISuXygYKE1szYwluT6jzDl2vy6LY9As2BFSRWq+NkhdWtsRfpIbPn6DIIKNQTZUiheEStWKelNjG3JtagWo3PtraN2lC6JcD4ACTMSyP6fv9/3HgQTd4EqRyurMMtaT2McKHmD3XzE8Lmle85/Chi86j8iJQpx2IT0DkIk80PMiu81e2u0t0dDxmB5XSEs4UMk1zoV3PLovLBbE75nNXnq9rLf4sODFMJ8kcBYqYjdORs69TJ3TXnnO5NzALQpmdhohrA9JE7tDxezJrRERdnibt6KUJt1dnbtL399sbV1Rh3GwqqvMlWQd3F9hB/xFjW5Grkg3oGlxpi25ih/SGE9uSTujhWMXMMcQfE7JCKh9FvAyet1CG0A5Y4oyAwJlZQMIQWxFtHWiQA65m+rgZ1hkGQerBT6TIjdp6FqQPjU7/enfyH4effk7/yddxGetG4E4dBy8S28teyIANSXKdP8xLGYbYhWvZ18ao/80yw/NjNOPnxVw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(396003)(39860400002)(346002)(136003)(230922051799003)(1800799012)(451199024)(186009)(82310400011)(64100799003)(46966006)(36840700001)(40470700004)(40460700003)(426003)(478600001)(83380400001)(2616005)(26005)(336012)(6666004)(316002)(6916009)(54906003)(36756003)(8676002)(86362001)(8936002)(70206006)(41300700001)(4326008)(70586007)(36860700001)(40480700001)(2906002)(5660300002)(82740400003)(81166007)(356005)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:48.9043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6fc398f3-2796-4056-7286-08dbf63e738b 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D8.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7486 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Venkatesh Yadav Abbarapu Macronix chips implements locking in (power-of-two multiple of) 64K blocks, not as a fraction of the chip's size. Bit 5 in the status register is not a top/bottom select bit, but instead a fourth value bit, allowing locking between 2^0 and 2^14 64K blocks (so up to 1GiB), either from top or bottom. The top/bottom select is instead done via a bit in the configuration register, which is OTP, so once set to use bottom protect, one cannot use top. On top of that, reading the configuration register uses a different opcode (0x15) than the existing SPINOR_OP_RDCR (0x35). Here's an attempt to implement locking support for Macronix flash memory devices. This implementation has been tested and confirmed to work on the specific chip used on our boards. Additionally, based on the information from data sheets of various other Macronix chips, suggest they behave in the same way. Used bottom protect to test the locking and unlocking functionality on the zc1751+dc1 board. Signed-off-by: Venkatesh Yadav Abbarapu Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 259 +++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 3 + 2 files changed, 262 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index c40899a281..08f6fb66be 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -4581,6 +4581,257 @@ static int micron_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) return micron_is_unlocked_sr(nor, ofs, len, status); } #endif /* CONFIG_SPI_FLASH_STMICRO */ + +#if defined(CONFIG_SPI_FLASH_MACRONIX) +/** + * mx_write_sr_cr() - write status and configuration register + * @nor: pointer to a 'struct spi_nor' + * @sr_cr: pointer status and configuration register + * + * Write status Register and configuration register with 2 bytes + * The first byte will be written to the status register, while the + * second byte will be written to the configuration register. + * + * Return: 0 on success, -errno if error occurred. + */ +static int mx_write_sr_cr(struct spi_nor *nor, u8 *sr_cr) +{ + int ret; + + write_enable(nor); + + ret = nor->write_reg(nor, SPINOR_OP_WRSR, sr_cr, 2); + if (ret < 0) { + dev_dbg(nor->dev, + "error while writing configuration register\n"); + return -EINVAL; + } + + ret = spi_nor_wait_till_ready(nor); + if (ret) { + dev_dbg(nor->dev, + "timeout while writing configuration register\n"); + return ret; + } + + ret = write_disable(nor); + if (ret) + return ret; + + return 0; +} + +static int mx_read_cr(struct spi_nor *nor) +{ + int ret; + u8 val; + + ret = nor->read_reg(nor, SPINOR_OP_RDCR_MX, &val, 1); + if (ret < 0) { + dev_dbg(nor->dev, "error %d reading CR\n", ret); + return ret; + } + + return val; +} + +/** + * mx_get_locked_range() - get the locked range + * @nor: pointer to a 'struct spi_nor' + * @sr: status register + * @cr: configuration register + * @ofs: flash offset + * @len: length to be locked + * + * Macronix flashes do not work by locking some 1/2^k fraction of the + * flash - instead, the BP{0,1,2,3} bits define a number of protected + * 64K blocks. + */ +static void mx_get_locked_range(struct spi_nor *nor, u8 sr, u8 cr, + loff_t *ofs, uint64_t *len) +{ + struct mtd_info *mtd = &nor->mtd; + int pow, shift; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_MX; + + shift = ffs(mask) - 1; + + pow = ((sr & mask) >> shift) - 1; + if (pow < 0) { + /* No protection */ + *ofs = 0; + *len = 0; + } else { + *len = (uint64_t)SZ_64K << pow; + if (*len > mtd->size) + *len = mtd->size; + if (cr & CR_TB_MX) + *ofs = 0; + else + *ofs = mtd->size - *len; + } +} + +/** + * mx_check_lock_status() - check the locked status + * @nor: pointer to a 'struct spi_nor' + * @ofs: flash offset + * @len: length to be locked + * @sr: status register + * @cr: configuration register + * @locked: locked:1 unlocked:0 value + * + * Return: 1 if the entire region is locked (if @locked is true) or unlocked (if + * @locked is false); 0 otherwise. + */ +static int mx_check_lock_status(struct spi_nor *nor, loff_t ofs, u64 len, + u8 sr, u8 cr, bool locked) +{ + loff_t lock_offs; + u64 lock_len; + + if (!len) + return 1; + + mx_get_locked_range(nor, sr, cr, &lock_offs, &lock_len); + + if (locked) + /* Requested range is a sub-range of locked range */ + return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs); + + /* Requested range does not overlap with locked range */ + return (ofs >= lock_offs + lock_len) || (ofs + len <= lock_offs); +} + +static int mx_lock_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len, bool lock) +{ + struct mtd_info *mtd = &nor->mtd; + int sr, cr, ret, val; + loff_t lock_len, blocks; + bool can_be_top, can_be_bottom, use_top; + u8 sr_cr[2], shift; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_MX; + + shift = ffs(mask) - 1; + + sr = read_sr(nor); + if (sr < 0) + return sr; + + cr = mx_read_cr(nor); + if (cr < 0) + return cr; + + log_debug("SPI Protection: %s\n", (cr & CR_TB_MX) ? "bottom" : "top"); + + /* CR_TB is OTP, so we can't use 'top' protection if that is already set. */ + can_be_top = !(cr & CR_TB_MX); + can_be_bottom = true; + + /* If the whole range is already locked (unlocked), we don't need to do anything */ + if (mx_check_lock_status(nor, ofs, len, sr, cr, lock)) + return 0; + + /* To use 'bottom' ('top') protection, everything below us must be locked (unlocked). */ + if (!mx_check_lock_status(nor, 0, ofs, sr, cr, lock)) { + if (lock) + can_be_bottom = false; + else + can_be_top = false; + } + + /* To use 'top' ('bottom') protection, everything above us must be locked (unlocked). */ + if (!mx_check_lock_status(nor, ofs + len, mtd->size - (ofs + len), sr, cr, lock)) { + if (lock) + can_be_top = false; + else + can_be_bottom = false; + } + + if (!can_be_bottom && !can_be_top) + return -EINVAL; + + /* Prefer top, if both are valid */ + use_top = can_be_top; + + /* lock_len: length of region that should end up locked */ + if (lock) + lock_len = use_top ? mtd->size - ofs : ofs + len; + else + lock_len = use_top ? mtd->size - (ofs + len) : ofs; + + /* lock_len must be a power-of-2 (2^0 .. 2^14) multiple of 64K, or 0 */ + if (lock_len & (SZ_64K - 1)) + return -EINVAL; + + blocks = lock_len / SZ_64K; + if ((blocks != 0 && !is_power_of_2(blocks)) || blocks > 1 << 14) + return -EINVAL; + + /* Compute new values of sr/cr */ + val = blocks ? ilog2(blocks) + 1 : 0; + sr_cr[0] = sr & ~mask; + sr_cr[0] |= val << shift; + /* + * Disallow further writes if WP pin is asserted, but remove + * that bit if we unlocked the whole chip. + */ + if (lock_len) + sr_cr[0] |= SR_SRWD; + else + sr_cr[0] &= ~SR_SRWD; + + sr_cr[1] = cr | (use_top ? 0 : CR_TB_MX); + + /* Don't bother if they're the same */ + if (sr == sr_cr[0] && cr == sr_cr[1]) + return 0; + + ret = mx_write_sr_cr(nor, sr_cr); + if (ret) + return ret; + + /* Check that the bits got written as expected */ + sr = read_sr(nor); + if (sr < 0) + return sr; + + cr = mx_read_cr(nor); + if (cr < 0) + return cr; + + if ((sr & mask) != (sr_cr[0] & mask) || + (cr & CR_TB_MX) != (sr_cr[1] & CR_TB_MX)) + return -EIO; + + return 0; +} + +static int mx_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + return mx_lock_unlock(nor, ofs, len, true); +} + +static int mx_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + return mx_lock_unlock(nor, ofs, len, false); +} + +static int mx_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int sr, cr; + + sr = read_sr(nor); + if (sr < 0) + return sr; + + cr = mx_read_cr(nor); + if (cr < 0) + return cr; + + return mx_check_lock_status(nor, ofs, len, sr, cr, false); +} +#endif /* CONFIG_SPI_FLASH_MACRONIX */ #endif /* CONFIG_SPI_FLASH_LOCK */ #ifdef CONFIG_SPI_FLASH_SOFT_RESET @@ -4800,6 +5051,14 @@ int spi_nor_scan(struct spi_nor *nor) } #endif +#if defined(CONFIG_SPI_FLASH_MACRONIX) + if (JEDEC_MFR(info) == SNOR_MFR_MACRONIX) { + nor->flash_lock = mx_lock; + nor->flash_unlock = mx_unlock; + nor->flash_is_unlocked = mx_is_unlocked; + } +#endif + #ifdef CONFIG_SPI_FLASH_SST /* * sst26 series block protection implementation differs from other diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 03413063ae..8ca874068a 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -70,6 +70,7 @@ #define SPINOR_OP_RDID 0x9f /* Read JEDEC ID */ #define SPINOR_OP_RDSFDP 0x5a /* Read SFDP */ #define SPINOR_OP_RDCR 0x35 /* Read configuration register */ +#define SPINOR_OP_RDCR_MX 0x15 /* Read configuration register (Macronix) */ #define SPINOR_OP_RDFSR 0x70 /* Read flag status register */ #define SPINOR_OP_CLFSR 0x50 /* Clear flag status register */ #define SPINOR_OP_RDEAR 0xc8 /* Read Extended Address Register */ @@ -167,6 +168,7 @@ #define SR_BP1 BIT(3) /* Block protect 1 */ #define SR_BP2 BIT(4) /* Block protect 2 */ #define SR_BP3 BIT(6) /* Block protect 3 */ +#define SR_BP3_MX BIT(5) /* Block protect 3 (Macronix) */ #define SR_TB BIT(5) /* Top/Bottom protect */ #define SR_SRWD BIT(7) /* SR write protect */ @@ -192,6 +194,7 @@ /* Configuration Register bits. */ #define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ +#define CR_TB_MX BIT(3) /* Macronix Top/Bottom protect */ /* Status Register 2 bits. */ #define SR2_QUAD_EN_BIT7 BIT(7) From patchwork Wed Dec 6 09:31:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872540 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=3yC35syl; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXNv00dmz23mf for ; Wed, 6 Dec 2023 20:37:02 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7DDFA878B0; Wed, 6 Dec 2023 10:34:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="3yC35syl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C14AA875EB; Wed, 6 Dec 2023 10:34:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2062a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::62a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 17361878A2 for ; Wed, 6 Dec 2023 10:33:58 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aeuVnIuk+spADUq6aszgKYvYSRYzkiZzVCdvCqj1MLMxYV2HtGdCrmwX29k/eAAd9h0bcanawXa7gMMJjCc8duS6DNrm0bCn8Ula6vtph4fzr4MMHPykHunbwoJKorC9stcJ2BJKplyqRW58UdsO9bOH0j3uAd3FTA9NPdDfIPcsudL6+lNfzkubAlc/NRTHCH96hSjGA5F61nxpLiZTLMKL30CDVicsGPjqFuKpy+m8BEyqQl1y2hsuBRyB6HD84PEp8RWWg3rIOrsOIO1dacBybV5X3Ws6BB/bhfVVus5BQeAx58s/q0LIMFn+f24+mWeG6BZHUZgEPNV4cvAjBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lZQgfw/kQadVzfl28kAct8jBXQTiaToF5eTOHG85dFE=; b=fwg2q16na9Wlxp+9DHsm9HJ6RWoxvWUiK+m/T+9vYaLBWnmwtZbe1sASARqcC/bPI9eOihk1oidfHxEfuwca6mha2ziR9IN9Oy834JvuJqt2NqtfKZOysYV43QTgPM8lcL92tmoI2EXMHrQucVOYEplgzi248SxLgD+0FPAGZJlpXNUkNsbvTNwwyZoJuMPBgehcNy06KMHr3AhmoyVkgfssvyYxR2gUcu3zo0jaybXGvM5fUgNfKbH3HcmeQw53XyyJZA36oOgq7J4yl1aJpNOxAIl6/IRlpok0b5DlH2dr96VrUKcTzfUQTjYC33141Eg2nGErRINJ/UUKiQMwPg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=lZQgfw/kQadVzfl28kAct8jBXQTiaToF5eTOHG85dFE=; b=3yC35sylVGf4cLievnnyaKU5ALwm1wJHTUbMDNFbMGsxYmi5QOSvFP49BfSg0X3N96Rorm1UOnvSZvlpGXyZoUqj0HVZz8goOV4nJbntoQh76/exeui8tfniEBYBW2EncvxyZxu1o3oLzpDpHxAW0/1+0T7RF8c5k1If+YbR3tc= Received: from CH0PR03CA0406.namprd03.prod.outlook.com (2603:10b6:610:11b::14) by CH3PR12MB7545.namprd12.prod.outlook.com (2603:10b6:610:146::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:33:54 +0000 Received: from DS3PEPF000099D7.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::e3) by CH0PR03CA0406.outlook.office365.com (2603:10b6:610:11b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25 via Frontend Transport; Wed, 6 Dec 2023 09:33:54 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D7.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:54 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:50 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:48 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH v2 28/30] mtd: spi-nor: Add support for locking on ISSI nor flashes Date: Wed, 6 Dec 2023 15:01:39 +0530 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D7:EE_|CH3PR12MB7545:EE_ X-MS-Office365-Filtering-Correlation-Id: 7fe5ed90-0dc7-4e96-d2ca-08dbf63e76fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wEWkv4YsuTrKF6V8ZMmiOD0Foe3cJ2dtbiZt6mEjXmZpBlZrmz2eOca+qsG8cazdATxnxuZXHF8vG1jcjOa0ffe4c3HviqpvNl3m+NoctclWWbU04ITmMU/1w/Vl7tLmgfGahOnv6zUlRfhrS53Y7dwGOdnSbTsdc4ClKgPqNrOWQ4iPlMoafKksgNvJdyOl2ux1Y40Ec0sjGmNhqYadCFDmfTudlwhhYQxE3KbKseX5BWykzI7NMdCHbOqVKJFTiDbRxLYRPGWUPCcX0goQ+wePrna71pKWL0AHOyRtRuYab1Df1arWl0LMphTa4JgZMaxRAE9+UcSlFcg+wWpOfhST5OmKqSuvOv5t0S+LppGVgIjEM/VRIbCww56hEbWTQS4DSBbbydDJJL6FHdEe5hgbF0oAGwSwTE6x7QgVEo/vdLTXCIUmXBfWUCksb7Y4WBskzR+l4TMvtqqf6oR0g2LGMdR6CVQx2Qg4mC38h7zNDRi8UbIBJhn8Z6yp2hvxw2oAjjFbrxfytjEpB10f0oHswexL/BpL/j9oaTtG3wJ2nWHFmE5tngeYxSrXw6Y+cTkisMgCaw1Blr14GxC3/e7Mqter00v4QfwJIeJH2gl+uEDxBVqt/nHiusPa+kInp3f3/+1+xjqQyy84jSjbTR6+Qf+v1Lnbet56mVAPGOdG/eZ0q/DJnj9H4S/X/w5z513F6qgqvvDyHdp0KU6wEbhv8RJksWK11uasjbNUjbZN1dNJOre79YatYIQLM/K88uCo/BGkxlZ8T42kD8r6v5LjS7Uj7JATtTy+FWqxtcE= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(346002)(39860400002)(376002)(230922051799003)(64100799003)(1800799012)(82310400011)(186009)(451199024)(36840700001)(46966006)(40470700004)(81166007)(356005)(82740400003)(2906002)(30864003)(86362001)(26005)(336012)(426003)(83380400001)(47076005)(40480700001)(36860700001)(40460700003)(5660300002)(478600001)(36756003)(6666004)(8936002)(2616005)(8676002)(4326008)(41300700001)(54906003)(6916009)(316002)(70586007)(70206006)(69594002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:54.6936 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7fe5ed90-0dc7-4e96-d2ca-08dbf63e76fe 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7545 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Venkatesh Yadav Abbarapu ISSI chips implements locking in (power-of-two multiple of) 64K blocks, not as a fraction of the chip's size. Bit 5 in the status register is not a top/bottom select bit, but instead a fourth value bit, allowing locking between 2^0 and 2^14 64K blocks (so up to 1GiB), either from top or bottom. The top/bottom select is instead done via a bit in the function register, which is OTP, so once set to use bottom protect, one cannot use top. On top of that, reading the function register uses a opcode SPINOR_OP_RDFR (0x48) and writing to the function register uses the opcode SPINOR_OP_WRFR(0x42). Here's an attempt at implementing a locking feature for ISSI flash memory devices. This implementation has been rigorously tested and proven to work on the chip used in our boards. Additionally, after examining data sheets for various other ISSI chips, it appears that they follow a similar behavior. Used "bottom protect" to test the lock and unlock functionality on the Versal Tenzing board. Please note that the Block Protection table is specific to the IS25LP01G, which has a size of 128MB, a sector size of 64KB, and comprises 2048 sectors. Signed-off-by: Venkatesh Yadav Abbarapu Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/sf_internal.h | 6 + drivers/mtd/spi/spi-nor-core.c | 340 +++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 7 + 3 files changed, 353 insertions(+) diff --git a/drivers/mtd/spi/sf_internal.h b/drivers/mtd/spi/sf_internal.h index 2cbdea60b0..aaa8520838 100644 --- a/drivers/mtd/spi/sf_internal.h +++ b/drivers/mtd/spi/sf_internal.h @@ -71,6 +71,12 @@ struct flash_info { #define SPI_NOR_OCTAL_DTR_READ BIT(17) /* Flash supports Octal DTR Read */ #define SPI_NOR_OCTAL_DTR_PP BIT(18) /* Flash supports Octal DTR page program */ #define SPI_NOR_MULTI_DIE BIT(19) /* Flash has multi dies & need split reads*/ +#define SPI_NOR_HAS_BP3 BIT(20) /* Flash SR has block protect bits + * for lock/unlock purpose, few support + * BP0-BP2 while few support BP0-BP3. + * This flag identifies devices that + * support BP3 bit. + */ }; extern const struct flash_info spi_nor_ids[]; diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 08f6fb66be..3bf1e5471b 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -4832,6 +4832,338 @@ static int mx_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) return mx_check_lock_status(nor, ofs, len, sr, cr, false); } #endif /* CONFIG_SPI_FLASH_MACRONIX */ + +#if defined(CONFIG_SPI_FLASH_ISSI) +/** + * spi_nor_read_fr() - read function register + * @nor: pointer to a 'struct spi_nor'. + * + * ISSI devices have top/bottom area protection bits selection into function + * reg. The bits in FR are OTP. So once it's written, it cannot be changed. + * + * Return: Value in function register or negative if error. + */ +static int spi_nor_read_fr(struct spi_nor *nor) +{ + int ret; + u8 val; + + ret = nor->read_reg(nor, SPINOR_OP_RDFR, &val, 1); + if (ret < 0) { + dev_dbg(nor->dev, "error %d reading FR\n", ret); + return ret; + } + + return val; +} + +static void issi_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, + uint64_t *len) +{ + struct mtd_info *mtd = &nor->mtd; + u8 mask = 0, fr = 0; + int pow, shift; + u32 sector_size; + + mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_ISSI; + shift = ffs(mask) - 1; + sector_size = nor->sector_size; + + if (nor->flags & SNOR_F_HAS_PARALLEL) + sector_size >>= 1; + + if (!(sr & mask)) { + /* No protection */ + *ofs = 0; + *len = 0; + } else { + pow = ((sr & mask) >> shift) - 1; + *len = sector_size << pow; + if (*len > mtd->size) + *len = mtd->size; + /* ISSI device's have top/bottom select bit in function reg */ + fr = spi_nor_read_fr(nor); + if (fr & FR_TB) + *ofs = 0; + else + *ofs = mtd->size - *len; + } +} + +/** + * issi_check_lock_status_sr() - check the status register and return + * the region is locked or unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * @locked: locked:1 unlocked:0 value + * + * Return: 1 if the entire region is locked (if @locked is true) or unlocked (if + * @locked is false); 0 otherwise. + */ +static int issi_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, u64 len, + u8 sr, bool locked) +{ + loff_t lock_offs; + u64 lock_len; + + if (!len) + return 1; + + issi_get_locked_range(nor, sr, &lock_offs, &lock_len); + if (locked) + /* Requested range is a sub-range of locked range */ + return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs); + + /* Requested range does not overlap with locked range */ + return (ofs >= lock_offs + lock_len) || (ofs + len <= lock_offs); +} + +/** + * spi_nor_is_locked_sr() - check if the memory region is locked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * + * Check if memory region is locked. + * + * Return: false if region is locked 0 otherwise. + */ +static int spi_nor_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + return issi_check_lock_status_sr(nor, ofs, len, sr, true); +} + +/** + * spi_nor_is_unlocked_sr() - check if the memory region is unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * + * Check if memory region is unlocked. + * + * Return: false if region is locked 0 otherwise. + */ +static int spi_nor_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + return issi_check_lock_status_sr(nor, ofs, len, sr, false); +} + +/** + * issi_is_unlocked() - check if the memory region is unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * + * Check if memory region is unlocked + * + * Return: false if region is locked 0 otherwise. + */ +static int issi_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int sr; + + sr = read_sr(nor); + if (sr < 0) + return sr; + + return issi_check_lock_status_sr(nor, ofs, len, sr, false); +} + +/** + * spi_nor_select_zone() - Select top area or bottom area to lock/unlock + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to lock memory. + * @len: number of bytes to unlock. + * @sr: status register + * @tb: pointer to top/bottom bool used in caller function + * @op: zone selection is for lock/unlock operation. 1: lock 0:unlock + * + * Select the top area / bottom area pattern to protect memory blocks. + * + * Return: negative on errors, 0 on success. + */ +static int spi_nor_select_zone(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr, bool *tb, bool op) +{ + int retval = 1; + bool can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB, can_be_top = true; + + if (op) { + /* Select for lock zone operation */ + + /* + * If nothing in our range is unlocked, we don't need + * to do anything. + */ + if (spi_nor_is_locked_sr(nor, ofs, len, sr)) + return 0; + + /* + * If anything below us is unlocked, we can't use 'bottom' + * protection. + */ + if (!spi_nor_is_locked_sr(nor, 0, ofs, sr)) + can_be_bottom = false; + + /* + * If anything above us is unlocked, we can't use 'top' + * protection. + */ + if (!spi_nor_is_locked_sr(nor, ofs + len, + nor->mtd.size - (ofs + len), sr)) + can_be_top = false; + } else { + /* Select unlock zone */ + + /* + * If nothing in our range is locked, we don't need to + * do anything. + */ + if (spi_nor_is_unlocked_sr(nor, ofs, len, sr)) + return 0; + + /* + * If anything below us is locked, we can't use 'top' + * protection + */ + if (!spi_nor_is_unlocked_sr(nor, 0, ofs, sr)) + can_be_top = false; + + /* + * If anything above us is locked, we can't use 'bottom' + * protection + */ + if (!spi_nor_is_unlocked_sr(nor, ofs + len, + nor->mtd.size - (ofs + len), sr)) + can_be_bottom = false; + } + + if (!can_be_bottom && !can_be_top) + return -EINVAL; + + /* Prefer top, if both are valid */ + *tb = can_be_top; + return retval; +} + +/** + * issi_flash_lock() - set BP[0123] write-protection. + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to lock memory. + * @len: number of bytes to unlock. + * + * Lock a region of the flash.Implementation is based on stm_lock + * Supports the block protection bits BP{0,1,2,3} in status register + * + * Return: 0 on success, -errno otherwise. + */ +static int issi_flash_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + u32 sector_size; + u16 n_sectors; + unsigned int bp_slots, bp_slots_needed; + int status_old, status_new, blk_prot, fr, shift; + loff_t lock_len; + u8 pow, ret; + bool use_top = false; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_ISSI; + + shift = ffs(mask) - 1; + + status_old = read_sr(nor); + /* if status reg is Write protected don't update bit protection */ + if (status_old & SR_SRWD) { + dev_err(nor->dev, + "SR is write protected, can't update BP bits...\n"); + return -EINVAL; + } + + fr = spi_nor_read_fr(nor); + log_debug("SPI Protection: %s\n", (fr & FR_TB) ? "bottom" : "top"); + + ret = spi_nor_select_zone(nor, ofs, len, status_old, &use_top, 1); + /* Older protected blocks include the new requested block's */ + if (ret <= 0) + return ret; + + /* lock_len: length of region that should end up locked */ + if (use_top) + lock_len = nor->mtd.size - ofs; + else + lock_len = ofs + len; + + sector_size = nor->sector_size; + n_sectors = (nor->size) / sector_size; + + bp_slots = (1 << hweight8(mask)) - 2; + bp_slots_needed = ilog2(n_sectors); + + if (bp_slots_needed > bp_slots) + sector_size <<= (bp_slots_needed - bp_slots); + + pow = ilog2(lock_len) - ilog2(sector_size) + 1; + blk_prot = pow << shift; + status_new = status_old | blk_prot; + if (status_old == status_new) + return 0; + + return write_sr_and_check(nor, status_new, mask); +} + +/** + * issi_flash_unlock() - clear BP[0123] write-protection. + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to unlock memory. + * @len: number of bytes to unlock. + * + * Bits [2345] of the Status Register are BP[0123]. + * ISSI chips use a different block protection scheme than other chips. + * Just disable the write-protect unilaterally. + * + * Return: 0 on success, -errno otherwise. + */ +static int issi_flash_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int ret, val; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_ISSI; + + val = read_sr(nor); + if (val < 0) + return val; + + if (!(val & mask)) + return 0; + + write_enable(nor); + + write_sr(nor, val & ~mask); + + ret = spi_nor_wait_till_ready(nor); + if (ret) + return ret; + + ret = write_disable(nor); + if (ret) + return ret; + + ret = read_sr(nor); + if (ret > 0 && !(ret & mask)) { + dev_info(nor->dev, "ISSI block protect bits cleared SR: 0x%x\n", + ret); + ret = 0; + } else { + dev_err(nor->dev, "ISSI block protect bits not cleared\n"); + ret = -EINVAL; + } + return ret; +} +#endif /* CONFIG_SPI_FLASH_ISSI */ #endif /* CONFIG_SPI_FLASH_LOCK */ #ifdef CONFIG_SPI_FLASH_SOFT_RESET @@ -5059,6 +5391,14 @@ int spi_nor_scan(struct spi_nor *nor) } #endif +#if defined(CONFIG_SPI_FLASH_ISSI) + if (JEDEC_MFR(info) == SNOR_MFR_ISSI) { + nor->flash_lock = issi_flash_lock; + nor->flash_unlock = issi_flash_unlock; + nor->flash_is_unlocked = issi_is_unlocked; + } +#endif + #ifdef CONFIG_SPI_FLASH_SST /* * sst26 series block protection implementation differs from other diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 8ca874068a..9a560d94a2 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -77,6 +77,8 @@ #define SPINOR_OP_WREAR 0xc5 /* Write Extended Address Register */ #define SPINOR_OP_SRSTEN 0x66 /* Software Reset Enable */ #define SPINOR_OP_SRST 0x99 /* Software Reset */ +#define SPINOR_OP_RDFR 0x48 /* Read Function register */ +#define SPINOR_OP_WRFR 0x42 /* Write Function register 1 byte */ /* 4-byte address opcodes - used on Spansion and some Macronix flashes. */ #define SPINOR_OP_READ_4B 0x13 /* Read data bytes (low frequency) */ @@ -169,6 +171,7 @@ #define SR_BP2 BIT(4) /* Block protect 2 */ #define SR_BP3 BIT(6) /* Block protect 3 */ #define SR_BP3_MX BIT(5) /* Block protect 3 (Macronix) */ +#define SR_BP3_ISSI BIT(5) /* Block protect 3 (ISSI) */ #define SR_TB BIT(5) /* Top/Bottom protect */ #define SR_SRWD BIT(7) /* SR write protect */ @@ -192,6 +195,9 @@ #define FSR_P_ERR BIT(4) /* Program operation status */ #define FSR_PT_ERR BIT(1) /* Protection error bit */ +/* Function register bit */ +#define FR_TB BIT(1) /*ISSI: Top/Bottom protect */ + /* Configuration Register bits. */ #define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ #define CR_TB_MX BIT(3) /* Macronix Top/Bottom protect */ @@ -322,6 +328,7 @@ enum spi_nor_option_flags { SNOR_F_IO_MODE_EN_VOLATILE = BIT(8), SNOR_F_HAS_STACKED = BIT(9), SNOR_F_HAS_PARALLEL = BIT(10), + SNOR_F_HAS_BP3 = BIT(11), }; struct spi_nor; From patchwork Wed Dec 6 09:31:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872543 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=Q+PvCJWZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXPK4rccz23mf for ; Wed, 6 Dec 2023 20:37:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 59128878AD; Wed, 6 Dec 2023 10:34:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="Q+PvCJWZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 57545878AF; Wed, 6 Dec 2023 10:34:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::623]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 52BD6878AD for ; Wed, 6 Dec 2023 10:34:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WvvPDhE9o/pCJ6MSvhxSh3Udgq/Ha3C0aahXhTLZgsmA5RtuFFHC8FOQHgdPYVPk4teinj7hh93zpaeCsk/GeTSantbVpBeFhQnAVf+xejZlvqW0EYjIn+OSYtIrlyRY64CJaNJBPUwb8100gGZFXmlKn4hnSraDJ0xKLo7XQvS1DDQkNAlOiZKkaF8jhf/sSkRxJ01jXl1bVr8uodDzooB2hdQabmhpCdtwT8wWqgaT7BzD4j3gNZ8yZYbKxc9iaVXd3PR363H3HASbrYMb04cCiZ14IP8UobTveEN1qtGc4Y2HzwryuV8C361FA1qQu6kz44Tk6tJq320kKZF7qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=O8z3alzYiQiRYQJ74JUHCx6SVAr3CYoc/Z0A+ooF580=; b=DCA3U4sByC/3BW6dbrw8NIItRZlSUwJ3uYvetLzTeNVd3R8bXlBNkDR54nSf9Zryeg4A10v576FF/jKBm1KcLNzNc9Jr8ICTQcPSSsrfO4q4a7kFENtvEimQlgxaVAQ6uwzXFJ7XMAVaDfHChq2Nz/mdVK6Eb2TfBLIVKUXC+dDJyksYo1OipeDd9ZyLrHdzxvk8OedGEPn2T2n2kJfEvvvlgBWm3hpLbYcxKpgMTPr4pm/A9Dq9EcvPGBm2O+v4iRHqBCob7EAJssaEZX96Aje42FFYay3mDgwu28i1vCAEOpzUjYboY1Pm9vflEYGM/JRtXuEl4VgNmaWS/QHffw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=O8z3alzYiQiRYQJ74JUHCx6SVAr3CYoc/Z0A+ooF580=; b=Q+PvCJWZsfWhJsxMEaPdn9BvWwZeFFWUd3WuD2H+1bJ7cOWpjmp4G6ZgLxapEcwdrpE+zhdxTomYmHzW0cSOr0E9MvL1AdZKf1O77qKRoc1DSAmxBedrn46Mj+bvesu/2uyC2OTSuRZjHK7c1czpn+LbQ9lllxaQcy675uNhbb4= Received: from CH0PR03CA0405.namprd03.prod.outlook.com (2603:10b6:610:11b::15) by CH2PR12MB4168.namprd12.prod.outlook.com (2603:10b6:610:a8::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25; Wed, 6 Dec 2023 09:33:58 +0000 Received: from DS3PEPF000099D7.namprd04.prod.outlook.com (2603:10b6:610:11b:cafe::ee) by CH0PR03CA0405.outlook.office365.com (2603:10b6:610:11b::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.25 via Frontend Transport; Wed, 6 Dec 2023 09:33:57 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS3PEPF000099D7.mail.protection.outlook.com (10.167.17.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:57 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Wed, 6 Dec 2023 03:33:53 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:33:53 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:51 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH v2 29/30] mtd: spi-nor: Add support for locking on GIGADEVICE nor flashes Date: Wed, 6 Dec 2023 15:01:40 +0530 Message-ID: <1e991a2dcc6fac0c6be16a7573deddffaa83026a.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099D7:EE_|CH2PR12MB4168:EE_ X-MS-Office365-Filtering-Correlation-Id: 69df38fc-44d0-4293-6e70-08dbf63e78e0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u5zz6/k4OH5gdCNSVIkkuOfwFHTxf/K6nN6GvtAoZzKhfKd7wj29E8aJtWq6lO9dlhmdXlgH+KnDRBrGmU1yguJB/ScOjuF72OqOsQogX6tYvomUJqqD3jX2IWHVfTNBvEBQaUcvE+db7yR7iZxpl5SR8/vXcZ+7Gwud+5xQ+A7c38Fsr/oxLaO1CI94DXgzi/Cms1xBGl0UnF8DluNvK6xKmeB5fjXBPFthfiyn0XMD4gQ0gwBKfC3zPu5UHouGOGGqj46EwfFvhHMie2Hm+tnJYEfualO4iY+JLmoxQOBpRXbf0dFrMw9GZiEnh3QRyJf/zf3PgrfXGf+N314ceFUswlFa7ClPd/YtUqQuDJJxyNzNX8bKSx3vXfvEi6YEwx4QkojkO34lIZk1w+TtlULJe255jSUtUne1H9G6EtISNyQgzTcwTsrGS0kpRcxXHTAlibSqzNCDO0j8Krh1rwU9cTX1gUdMAr2M5PLby0qErz6jEtIipwM+sKGEIAXeDsL1+yHTfqYXizj8kgKOIsCVsXT3HjgCXgdxqYoUE4z3XzsH4kyaAtb/w/3dKjkBUbcYalRD3LvYi8hcA7zlJqYmL1kMxjCdPGXh8z+4WaqOiAF/zkA4e0fGEUf/2raBhwvpWn1EanNb7Xg8MMbgN+tXpATWv1nquhNjye2Qakf5f3yz5Eonfc0DafXKr5yq3svKKm7xzyu51csvgIK1x5bLoUxMhTVDB0zGJTwfNcCVA9ytsMFPM4TtIVraBxEY1imXaKEP7qsMkQ5IIv2hFQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(39860400002)(376002)(346002)(230922051799003)(186009)(451199024)(64100799003)(82310400011)(1800799012)(46966006)(40470700004)(36840700001)(40480700001)(40460700003)(36860700001)(81166007)(47076005)(356005)(2906002)(5660300002)(82740400003)(83380400001)(336012)(426003)(6666004)(26005)(2616005)(478600001)(70206006)(70586007)(54906003)(36756003)(41300700001)(4326008)(8676002)(6916009)(8936002)(316002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:57.3655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 69df38fc-44d0-4293-6e70-08dbf63e78e0 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099D7.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4168 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Venkatesh Yadav Abbarapu GIGADEVICE nor flashes provide block protection support using BP0, BP1, BP2, BP3 & TB bits in status register. BP(Block Protection) bits defines memory to be software protected against PROGRAM or ERASE operations. When one or more block protect bits are set to 1, a designated memory area is protected from PROGRAM and ERASE operations. TB(Top/Bottom) bit determines whether the protected memory area defined by the block protect bits starts from the top or bottom of the memory array. Used bottom/top protect to test lock/unlock on zc1751+dc1 board. Signed-off-by: Venkatesh Yadav Abbarapu Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 309 +++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 2 + 2 files changed, 311 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 3bf1e5471b..3e2491cc3e 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -5164,6 +5164,307 @@ static int issi_flash_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) return ret; } #endif /* CONFIG_SPI_FLASH_ISSI */ + +#if defined(CONFIG_SPI_FLASH_GIGADEVICE) +static void giga_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, + uint64_t *len) +{ + struct mtd_info *mtd = &nor->mtd; + int shift = 0; + int pow; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_GIGA; + u32 sector_size; + + sector_size = nor->sector_size; + if (nor->flags & SNOR_F_HAS_PARALLEL) + sector_size >>= 1; + + shift = ffs(mask) - 1; + + if (!(sr & mask)) { + /* No protection */ + *ofs = 0; + *len = 0; + } else { + pow = ((sr & mask) >> shift) - 1; + *len = sector_size << pow; + if (*len > mtd->size) + *len = mtd->size; + /* GIGA device's have top/bottom select bit in status reg */ + if (nor->flags & SNOR_F_HAS_SR_TB && sr & SR_TB_GIGA) + *ofs = 0; + else + *ofs = mtd->size - *len; + } +} + +/** + * giga_check_lock_status_sr() - check the status register and return + * the region is locked or unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * @locked: locked:1 unlocked:0 value + * + * Return: 1 if the entire region is locked (if @locked is true) or unlocked (if + * @locked is false); 0 otherwise. + */ +static int giga_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, u64 len, + u8 sr, bool locked) +{ + loff_t lock_offs; + u64 lock_len; + + if (!len) + return 1; + + giga_get_locked_range(nor, sr, &lock_offs, &lock_len); + if (locked) + /* Requested range is a sub-range of locked range */ + return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs); + + /* Requested range does not overlap with locked range */ + return (ofs >= lock_offs + lock_len) || (ofs + len <= lock_offs); +} + +/** + * giga_is_locked_sr() - check if the memory region is locked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * + * Check if memory region is locked. + * + * Return: false if region is locked 0 otherwise. + */ +static int giga_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + return giga_check_lock_status_sr(nor, ofs, len, sr, true); +} + +/** + * giga_is_unlocked_sr() - check if the memory region is unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * + * Check if memory region is unlocked. + * + * Return: false if region is locked 0 otherwise. + */ +static int giga_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + return giga_check_lock_status_sr(nor, ofs, len, sr, false); +} + +/** + * giga_is_unlocked() - check if the memory region is unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * + * Check if memory region is unlocked + * + * Return: false if region is locked 0 otherwise. + */ +static int giga_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int sr; + + sr = read_sr(nor); + if (sr < 0) + return sr; + + return giga_check_lock_status_sr(nor, ofs, len, sr, false); +} + +/** + * giga_nor_select_zone() - Select top area or bottom area to lock/unlock + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to lock memory. + * @len: number of bytes to unlock. + * @sr: status register + * @tb: pointer to top/bottom bool used in caller function + * @op: zone selection is for lock/unlock operation. 1: lock 0:unlock + * + * Select the top area / bottom area pattern to protect memory blocks. + * + * Return: negative on errors, 0 on success. + */ +static int giga_nor_select_zone(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr, bool *tb, bool op) +{ + int retval = 1; + bool can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB, can_be_top = true; + + if (op) { + /* Select for lock zone operation */ + + /* + * If nothing in our range is unlocked, we don't need + * to do anything. + */ + if (giga_is_locked_sr(nor, ofs, len, sr)) + return 0; + + /* + * If anything below us is unlocked, we can't use 'bottom' + * protection. + */ + if (!giga_is_locked_sr(nor, 0, ofs, sr)) + can_be_bottom = false; + + /* + * If anything above us is unlocked, we can't use 'top' + * protection. + */ + if (!giga_is_locked_sr(nor, ofs + len, + nor->mtd.size - (ofs + len), sr)) + can_be_top = false; + } else { + /* Select unlock zone */ + + /* + * If nothing in our range is locked, we don't need to + * do anything. + */ + if (giga_is_unlocked_sr(nor, ofs, len, sr)) + return 0; + + /* + * If anything below us is locked, we can't use 'top' + * protection + */ + if (!giga_is_unlocked_sr(nor, 0, ofs, sr)) + can_be_top = false; + + /* + * If anything above us is locked, we can't use 'bottom' + * protection + */ + if (!giga_is_unlocked_sr(nor, ofs + len, + nor->mtd.size - (ofs + len), sr)) + can_be_bottom = false; + } + + if (!can_be_bottom && !can_be_top) + return -EINVAL; + + /* Prefer top, if both are valid */ + *tb = can_be_top; + return retval; +} + +/** + * giga_flash_lock() - set BP[0123] write-protection. + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to lock memory. + * @len: number of bytes to unlock. + * + * Lock a region of the flash.Implementation is based on stm_lock + * Supports the block protection bits BP{0,1,2,3} in status register + * + * Return: 0 on success, -errno otherwise. + */ +static int giga_flash_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int status_old, status_new, blk_prot; + loff_t lock_len; + u8 pow, ret, shift; + bool use_top = false; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_GIGA; + + shift = ffs(mask) - 1; + + status_old = read_sr(nor); + /* if status reg is Write protected don't update bit protection */ + if (status_old & SR_SRWD) { + dev_err(nor->dev, + "SR is write protected, can't update BP bits...\n"); + return -EINVAL; + } + + log_debug("SPI Protection: %s\n", (status_old & SR_TB_GIGA) ? "bottom" : "top"); + + ret = giga_nor_select_zone(nor, ofs, len, status_old, &use_top, 1); + /* Older protected blocks include the new requested block's */ + if (ret <= 0) + return ret; + + /* lock_len: length of region that should end up locked */ + if (use_top) + lock_len = nor->mtd.size - ofs; + else + lock_len = ofs + len; + + pow = order_base_2(lock_len); + blk_prot = mask & (((pow + 1) & 0xf) << shift); + if (lock_len <= 0) { + dev_err(nor->dev, "invalid Length to protect"); + return -EINVAL; + } + + status_new = status_old | blk_prot; + if (!use_top) + status_new |= SR_TB_GIGA; + else + status_new &= ~SR_TB_GIGA; + + if (status_old == status_new) + return 0; + + return write_sr_and_check(nor, status_new, mask); +} + +/** + * giga_flash_unlock() - clear BP[0123] write-protection. + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to unlock memory. + * @len: number of bytes to unlock. + * + * Bits [2345] of the Status Register are BP[0123]. + * Clear the corresponding BP status bits. + * + * Return: 0 on success, -errno otherwise. + */ +static int giga_flash_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int ret, val; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2 | SR_BP3_GIGA; + + val = read_sr(nor); + if (val < 0) + return val; + + if (!(val & mask)) + return 0; + + write_enable(nor); + + write_sr(nor, val & ~mask); + + ret = spi_nor_wait_till_ready(nor); + if (ret) + return ret; + + ret = write_disable(nor); + if (ret) + return ret; + + ret = read_sr(nor); + if (ret > 0 && !(ret & mask)) { + dev_info(nor->dev, "block protect bits cleared SR: 0x%x\n", + ret); + ret = 0; + } + return ret; +} +#endif /* CONFIG_SPI_FLASH_GIGADEVICE */ #endif /* CONFIG_SPI_FLASH_LOCK */ #ifdef CONFIG_SPI_FLASH_SOFT_RESET @@ -5399,6 +5700,14 @@ int spi_nor_scan(struct spi_nor *nor) } #endif +#if defined(CONFIG_SPI_FLASH_GIGADEVICE) + if (JEDEC_MFR(info) == SNOR_MFR_GIGADEVICE) { + nor->flash_lock = giga_flash_lock; + nor->flash_unlock = giga_flash_unlock; + nor->flash_is_unlocked = giga_is_unlocked; + } +#endif + #ifdef CONFIG_SPI_FLASH_SST /* * sst26 series block protection implementation differs from other diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 9a560d94a2..797f0f275a 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -172,6 +172,8 @@ #define SR_BP3 BIT(6) /* Block protect 3 */ #define SR_BP3_MX BIT(5) /* Block protect 3 (Macronix) */ #define SR_BP3_ISSI BIT(5) /* Block protect 3 (ISSI) */ +#define SR_TB_GIGA BIT(6) /* Top/Bottom protect (GIGADEVICE)*/ +#define SR_BP3_GIGA BIT(5) /* Block protect 3 (GIGADEVICE) */ #define SR_TB BIT(5) /* Top/Bottom protect */ #define SR_SRWD BIT(7) /* SR write protect */ From patchwork Wed Dec 6 09:31:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bhumkar, Tejas Arvind" X-Patchwork-Id: 1872542 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.a=rsa-sha256 header.s=selector1 header.b=oEN+Ul9x; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlXP604d7z23mf for ; Wed, 6 Dec 2023 20:37:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E1B8E87626; Wed, 6 Dec 2023 10:34:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amd.com header.i=@amd.com header.b="oEN+Ul9x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A4304878B7; Wed, 6 Dec 2023 10:34:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2062d.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8c::62d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0D20C875EB for ; Wed, 6 Dec 2023 10:34:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ECh+x5cIrpv2PFXlsv1ql54lM8bHo7UnMGnfs27MjOisWbs/n06nv1sdx8OXdavtVt1JHbGvfPbJTqS9s7orEzJsYDReB4oTUPuvuw2W1+S2b2MX5QeoZMle9IoHxpe4QfPwIY9mWKhgd74yP/dYsqheNR1yagrV2usYw0+EvWI4+L5KtDaJP4YPl3+21ju7Yv1J1fA9DO01rTZ/Qvhc3eFcj7qatuM5V1oXccjL8Vfzu8kxa+VyxCGT45lG9IREVZExt8Co9TntELdLrIHUYEjQpuMGlJIIlM5/p2Y2/PIlP1SjygypwXfaXIIS85cPKddwSDD2eidwWGXdVU9wOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wTJuQjLKzVV1Ev3noRcjUcY1QFgrSZH5SKs5nmf8Nbc=; b=PamaP0eGmpPjQ4RIfMdJ44R4bvzRNuOl3ic1VDrxMVgbN36KRtF+fiqM2+mISGEd3bb/s39dzfzlIIpLNpvRF/8JoxUrnijMOdnJQWADdhp+Kt2XXbp1WODrCdyTA3O2+bTf0Dd+0kJOrhL34dIJ8ZoCv4Bf0qA3vHMkOfembXbmm3bQA/3ut8EcRqHKrxJ4HmGjjHkIZAE1yd/CDRCKCmvrmLp0j0Fw5vw3ToIGxosp5o1VRm5V3Q4N6ox4UnW8wiEK/5fi9oZvN9Z/O/dOY+MCJJVaWMquyrB2DAgXMTeLhByvBmutRk5XV6JVQh4zeEHRsBVwook/KtxZzBBHyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.denx.de 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=wTJuQjLKzVV1Ev3noRcjUcY1QFgrSZH5SKs5nmf8Nbc=; b=oEN+Ul9xg3ToiVNxjzVHRkUJbnALGPrhv5W12puoFMttD4LYoUPFETQXvJ/U82C3IVLD4U44Y8Y9YIl7tOPw+IIXpdOWwXRZEYUpzrPciuM7ceeS2GLGhfaRGzoUZ8sx7kFC5S0SzkuhnH2EQQL5oSUklIFVS00t5bw10CADKeg= Received: from DM6PR10CA0022.namprd10.prod.outlook.com (2603:10b6:5:60::35) by PH7PR12MB9201.namprd12.prod.outlook.com (2603:10b6:510:2e8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Wed, 6 Dec 2023 09:33:57 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:5:60:cafe::39) by DM6PR10CA0022.outlook.office365.com (2603:10b6:5:60::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34 via Frontend Transport; Wed, 6 Dec 2023 09:33:57 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7068.20 via Frontend Transport; Wed, 6 Dec 2023 09:33:57 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) 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.34; Wed, 6 Dec 2023 03:33:56 -0600 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Wed, 6 Dec 2023 01:33:55 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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.34 via Frontend Transport; Wed, 6 Dec 2023 03:33:53 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH v2 30/30] mtd: spi-nor: Add support for locking on Spansion nor flashes Date: Wed, 6 Dec 2023 15:01:41 +0530 Message-ID: <838871412b1e0e0c13e33e054eca42570b992a29.1701853668.git.tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|PH7PR12MB9201:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f141f86-8958-4ea9-aae3-08dbf63e7876 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +4NelhpGztM/vIzUSEN58H9CejJb0wW/cfxMaCciQ6pDKcXDfy2ZDRPGnZ3ha05t7UaalEaWpgxDsR7SKGBIt6gImR2HpelZh2O2Lcz3mwEozSpd0U5rwPsYA5HMvekYOd6eI/iDmjZmp6BHQFbcNxhZ1SsmVHAfnwb8LVPdCRconyyekRRXXL0ohHJ+1DqVJ4FbhHQY0O7I2Og71zIZ79+01ZHis3UzVSLAvSRWp1c9hfC6MzFsAOHLSKsmTFeA6iWRBUwwWhy719PN18+1EANS6qiBUAQQuuetLsptxPG7nYEKgzGExoTnUD7/CHhLYP62wdM1Ko0wtVeQmwxJ/oxngxMfpe3N0zcXblyr39pGMVW29QCGIaPRspemYLqxNHjqqzazz4L2u/jSVAZdIs/XIqbkpKdLrssYAa7/ysoVLX3hR38fUAFW5UbBLXeZKJsJ7mN/XK4CP7KzmhPg4PxyWSlSjjbqf5wQSsDPmOQ568Gp3RmgcQEW5G6MOF2NxppTGWAAlnO2VTkIC27hiDHnIkfGOSDxXdeX5gbJMtITuxwrXw8GW7k4pwHvuEJfXjXU4uB1+1QivBPJOXPIiZhoIizPGPCAp1Ghxe7GS+cgYs8BQTnlJmQbaUVdfP1zQ50bq1bwHBGS1Pg2LDfCQX06dJCXieOT1dHlcVmGIAzjHA8X38R/LCmyAJ8OOMsDzg274cJ2nFbdqReSI4/D+IMTUl2HVLSNSSGsEsK04GdsjTEEs6ajfzXmE9Bgc1BH55uLlYaCGmuQ19KN/lASAg== 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:(13230031)(4636009)(376002)(136003)(346002)(396003)(39860400002)(230922051799003)(64100799003)(451199024)(82310400011)(1800799012)(186009)(46966006)(40470700004)(36840700001)(40460700003)(5660300002)(82740400003)(2906002)(30864003)(36756003)(41300700001)(86362001)(478600001)(40480700001)(36860700001)(6666004)(83380400001)(2616005)(26005)(47076005)(336012)(426003)(8676002)(4326008)(6916009)(8936002)(81166007)(70206006)(70586007)(356005)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 09:33:57.1255 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f141f86-8958-4ea9-aae3-08dbf63e7876 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9201 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Venkatesh Yadav Abbarapu Spansion nor flashes provide block protection support using BP0, BP1, BP2 bits in status register. The top/bottom select is instead done via a bit in the configuration register, which is OTP, so once set to use bottom protect, one cannot use top. On top of that, reading the configuration register uses a different opcode (0x15) than the existing SPINOR_OP_RDCR (0x35). Used bottom protect to test s25fl512s flash part lock/unlock on zc1751+dc1 board. Signed-off-by: Venkatesh Yadav Abbarapu Signed-off-by: Tejas Bhumkar --- drivers/mtd/spi/spi-nor-core.c | 372 +++++++++++++++++++++++++++++++++ include/linux/mtd/spi-nor.h | 1 + 2 files changed, 373 insertions(+) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 3e2491cc3e..42483caaaa 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -5465,6 +5465,370 @@ static int giga_flash_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) return ret; } #endif /* CONFIG_SPI_FLASH_GIGADEVICE */ + +#if defined(CONFIG_SPI_FLASH_SPANSION) +/** + * spansion_read_cr() - read configuration register + * @nor: pointer to a 'struct spi_nor'. + * + * Spansion devices have top/bottom area protection bits selection into + * configuration reg. The bits in CR are OTP. So once it's written, + * it cannot be changed. + * + * Return: Value in configuration register or negative if error. + */ +static int spansion_read_cr(struct spi_nor *nor) +{ + int ret; + u8 val; + + ret = nor->read_reg(nor, SPINOR_OP_RDCR, &val, 1); + if (ret < 0) { + dev_dbg(nor->dev, "error %d reading CR\n", ret); + return ret; + } + + return val; +} + +static void spansion_get_locked_range(struct spi_nor *nor, u8 sr, loff_t *ofs, + uint64_t *len) +{ + struct mtd_info *mtd = &nor->mtd; + int pow, cr; + int shift = 0; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2; + + shift = ffs(mask) - 1; + + cr = spansion_read_cr(nor); + if (!(sr & mask)) { + /* No protection */ + *ofs = 0; + *len = 0; + } else { + pow = ((sr & mask) ^ mask) >> shift; + *len = mtd->size >> pow; + /* SPANSION device's have top/bottom select bit in configuration reg */ + if (nor->flags & SNOR_F_HAS_SR_TB && cr & CR_TB_SPAN) + *ofs = 0; + else + *ofs = mtd->size - *len; + } +} + +/** + * spansion_check_lock_status_sr() - check the status register and return + * the region is locked or unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * @locked: locked:1 unlocked:0 value + * + * Return: 1 if the entire region is locked (if @locked is true) or unlocked (if + * @locked is false); 0 otherwise. + */ +static int spansion_check_lock_status_sr(struct spi_nor *nor, loff_t ofs, u64 len, + u8 sr, bool locked) +{ + loff_t lock_offs; + u64 lock_len; + + if (!len) + return 1; + + spansion_get_locked_range(nor, sr, &lock_offs, &lock_len); + if (locked) + /* Requested range is a sub-range of locked range */ + return (ofs + len <= lock_offs + lock_len) && (ofs >= lock_offs); + + /* Requested range does not overlap with locked range */ + return (ofs >= lock_offs + lock_len) || (ofs + len <= lock_offs); +} + +/** + * spansion_is_locked_sr() - check if the memory region is locked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * + * Check if memory region is locked. + * + * Return: false if region is locked 0 otherwise. + */ +static int spansion_is_locked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + return spansion_check_lock_status_sr(nor, ofs, len, sr, true); +} + +/** + * spansion_is_unlocked_sr() - check if the memory region is unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * @sr: status register + * + * Check if memory region is unlocked. + * + * Return: false if region is locked 0 otherwise. + */ +static int spansion_is_unlocked_sr(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr) +{ + return spansion_check_lock_status_sr(nor, ofs, len, sr, false); +} + +/** + * spansion_is_unlocked() - check if the memory region is unlocked + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset of the flash + * @len: length to be locked + * + * check if memory region is unlocked + * + * Return: false if region is locked 0 otherwise. + */ +static int spansion_is_unlocked(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int sr; + + sr = read_sr(nor); + if (sr < 0) + return sr; + + return spansion_check_lock_status_sr(nor, ofs, len, sr, false); +} + +/** + * spansion_nor_select_zone() - Select top area or bottom area to lock/unlock + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to lock memory. + * @len: number of bytes to unlock. + * @sr: status register + * @tb: pointer to top/bottom bool used in caller function + * @op: zone selection is for lock/unlock operation. 1: lock 0:unlock + * + * Select the top area / bottom area pattern to protect memory blocks. + * + * Return: negative on errors, 0 on success. + */ +static int spansion_nor_select_zone(struct spi_nor *nor, loff_t ofs, uint64_t len, + u8 sr, bool *tb, bool op) +{ + int retval = 1; + bool can_be_bottom = nor->flags & SNOR_F_HAS_SR_TB, can_be_top = true; + + if (op) { + /* Select for lock zone operation */ + + /* + * If nothing in our range is unlocked, we don't need + * to do anything. + */ + if (spansion_is_locked_sr(nor, ofs, len, sr)) + return 0; + + /* + * If anything below us is unlocked, we can't use 'bottom' + * protection. + */ + if (!spansion_is_locked_sr(nor, 0, ofs, sr)) + can_be_bottom = false; + + /* + * If anything above us is unlocked, we can't use 'top' + * protection. + */ + if (!spansion_is_locked_sr(nor, ofs + len, + nor->mtd.size - (ofs + len), sr)) + can_be_top = false; + } else { + /* Select unlock zone */ + + /* + * If nothing in our range is locked, we don't need to + * do anything. + */ + if (spansion_is_unlocked_sr(nor, ofs, len, sr)) + return 0; + + /* + * If anything below us is locked, we can't use 'top' + * protection + */ + if (!spansion_is_unlocked_sr(nor, 0, ofs, sr)) + can_be_top = false; + + /* + * If anything above us is locked, we can't use 'bottom' + * protection + */ + if (!spansion_is_unlocked_sr(nor, ofs + len, + nor->mtd.size - (ofs + len), sr)) + can_be_bottom = false; + } + + if (!can_be_bottom && !can_be_top) + return -EINVAL; + + /* Prefer top, if both are valid */ + *tb = can_be_top; + return retval; +} + +static int spansion_write_sr_cr(struct spi_nor *nor, u8 *sr_cr) +{ + int ret; + + write_enable(nor); + + ret = nor->write_reg(nor, SPINOR_OP_WRSR, sr_cr, 2); + if (ret < 0) { + dev_dbg(nor->dev, + "error while writing configuration register\n"); + return -EINVAL; + } + + ret = spi_nor_wait_till_ready(nor); + if (ret) { + dev_dbg(nor->dev, + "timeout while writing configuration register\n"); + return ret; + } + + ret = write_disable(nor); + if (ret) + return ret; + + return 0; +} + +/** + * spansion_flash_lock() - set BP[012] write-protection. + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to lock memory. + * @len: number of bytes to unlock. + * + * Lock a region of the flash.Implementation is based on stm_lock + * Supports the block protection bits BP{0,1,2} in status register + * + * Return: 0 on success, -errno otherwise. + */ +static int spansion_flash_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + u64 lock_len; + u32 sector_size; + u16 n_sectors; + unsigned int bp_slots, bp_slots_needed; + int cr, can_be_top, val, status_old; + u8 pow, ret, shift, sr_cr[2]; + bool use_top = false; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2; + + shift = ffs(mask) - 1; + + status_old = read_sr(nor); + /* if status reg is Write protected don't update bit protection */ + if (status_old & SR_SRWD) { + dev_err(nor->dev, + "SR is write protected, can't update BP bits...\n"); + return -EINVAL; + } + + cr = spansion_read_cr(nor); + if (cr < 0) + return cr; + + log_debug("SPI Protection: %s\n", (cr & CR_TB_SPAN) ? "bottom" : "top"); + + /* CR_TB is OTP, so we can't use 'top' protection if that is already set. */ + can_be_top = !(cr & CR_TB_SPAN); + + ret = spansion_nor_select_zone(nor, ofs, len, status_old, &use_top, 1); + /* Older protected blocks include the new requested block's */ + if (ret <= 0) + return ret; + + use_top = can_be_top; + + /* lock_len: length of region that should end up locked */ + if (use_top) + lock_len = nor->mtd.size - ofs; + else + lock_len = ofs + len; + + sector_size = nor->sector_size; + n_sectors = (nor->size) / sector_size; + + bp_slots = (1 << hweight8(mask)) - 2; + bp_slots_needed = ilog2(n_sectors); + + if (bp_slots_needed > bp_slots) + sector_size <<= (bp_slots_needed - bp_slots); + + pow = ilog2(lock_len) - ilog2(sector_size) + 1; + val = pow << shift; + sr_cr[0] = status_old & ~mask; + sr_cr[0] |= val; + + sr_cr[1] = cr | (use_top ? 0 : CR_TB_SPAN); + ret = spansion_write_sr_cr(nor, sr_cr); + if (ret) + return ret; + + /* Check that the bits got written as expected */ + ret = read_sr(nor); + if (ret < 0) + return ret; + + ret = spansion_read_cr(nor); + if (ret < 0) + return ret; + + return 0; +} + +/** + * spansion_flash_unlock() - clear BP[012] write-protection. + * @nor: pointer to a 'struct spi_nor'. + * @ofs: offset from which to unlock memory. + * @len: number of bytes to unlock. + * + * Bits [234] of the Status Register are BP[012]. + * Clear the corresponding BP status bits. + * + * Return: 0 on success, -errno otherwise. + */ +static int spansion_flash_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) +{ + int ret, val; + u8 mask = SR_BP0 | SR_BP1 | SR_BP2; + + val = read_sr(nor); + if (val < 0) + return val; + + if (!(val & mask)) + return 0; + + write_enable(nor); + + write_sr(nor, val & ~mask); + + ret = spi_nor_wait_till_ready(nor); + if (ret) + return ret; + + ret = write_disable(nor); + if (ret) + return ret; + + return 0; +} +#endif /* CONFIG_SPI_FLASH_SPANSION */ #endif /* CONFIG_SPI_FLASH_LOCK */ #ifdef CONFIG_SPI_FLASH_SOFT_RESET @@ -5708,6 +6072,14 @@ int spi_nor_scan(struct spi_nor *nor) } #endif +#if defined(CONFIG_SPI_FLASH_SPANSION) + if (JEDEC_MFR(info) == SNOR_MFR_SPANSION) { + nor->flash_lock = spansion_flash_lock; + nor->flash_unlock = spansion_flash_unlock; + nor->flash_is_unlocked = spansion_is_unlocked; + } +#endif + #ifdef CONFIG_SPI_FLASH_SST /* * sst26 series block protection implementation differs from other diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 797f0f275a..07d6c4ff93 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -203,6 +203,7 @@ /* Configuration Register bits. */ #define CR_QUAD_EN_SPAN BIT(1) /* Spansion Quad I/O */ #define CR_TB_MX BIT(3) /* Macronix Top/Bottom protect */ +#define CR_TB_SPAN BIT(5) /* Spansion Top/Bottom protect */ /* Status Register 2 bits. */ #define SR2_QUAD_EN_BIT7 BIT(7)