From patchwork Wed Dec 6 05:29: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: 1872435 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=2ocKrAaX; 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) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SlQvr4g3wz1yST for ; Wed, 6 Dec 2023 16:30:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DFC5887630; Wed, 6 Dec 2023 06:29:55 +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="2ocKrAaX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B985087655; Wed, 6 Dec 2023 06:29:54 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2060c.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::60c]) (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 83A7D87494 for ; Wed, 6 Dec 2023 06:29:52 +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=QE/GvKM3WRGviYRaMXM7JvVH/yVqEaD8xM6Rtywk3d1Pw3C7KK8nmnKWWKkSKu8NErH7wwFYtQH2tbL5ZALfWvlxti8qWFImGdC5Hx9mFLn9ceD4ylUW45FPIJi/DyYxeKJmu/0tWsgOb4/JWBLNqhAEFOKjQhH/dDQ+87DcxYzFRZsjdbbNAFw5+AMbIv4gbJcKJnSjfS56vZgYz999lgIpObe03A9v+Q5LJEQUHy7EkNNsaMm6kyQl6l0Wj2wrLo79xlT+PWCD0XFS3PH+kxuwXbMyCTQWYzhEK69lP+qCKC7yyg/0QfTmx2hO4k9lgMXpuqiIDGjz4/Igy9ZJUg== 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=Yx7IrSo661+ISJbiiEAwY8vaE4RoBrSMQMmeXA3SGBcSh0R0ielPjwattQJZdM+GpgWho5stRWgo6jhi0MskQ96BpemkXS3rfl2DYqRDHZM2yi0VcU9qKcyEPfSx3OrU27CtUxeDNCcHhkGcGorfhoC6VFIyNCGurb50b7RXGzShyhFY5faDPUrpNOUc14NEEkKCqvR9VSS4UvfZwSzxsgoFKq39Ml498trEVmfaifZ8ITgnX1rrDNs9Efonq6LdcIGm1YXPkMNuka6D7sOQ9EhnBhtMMzinQLXXgJneCT/q5OZlWzUUyj0EeNbYL1SBhJvZBEBgTNU7KzIiiHLztw== 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=2ocKrAaXjezlJO2Dp6s2gGVUEHxKkrZoxvWlgCeaz/xM3ZepuZWRM8zbGUxo8OWUaYS2eHPUoTr6/bJotpDOoYdi94RSgToVLMSQuVkiLYHkikHvzv6cqbsGekX9S6abrM9RoOclKRyv99hfuqWqGAegB/P0TTsHRziedOzBfHs= Received: from DM6PR05CA0061.namprd05.prod.outlook.com (2603:10b6:5:335::30) by LV3PR12MB9094.namprd12.prod.outlook.com (2603:10b6:408:19e::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 05:29:47 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:5:335:cafe::b0) by DM6PR05CA0061.outlook.office365.com (2603:10b6:5:335::30) 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 05:29: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 CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) 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 05:29:46 +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; Tue, 5 Dec 2023 23:29:46 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:29:43 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:29:41 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH 01/30] mtd: spi-nor: Add config to enable flash DTR Date: Wed, 6 Dec 2023 10:59:34 +0530 Message-ID: <20231206052934.3744128-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|LV3PR12MB9094:EE_ X-MS-Office365-Filtering-Correlation-Id: 6628f383-62b9-49e6-f0c3-08dbf61c5c0c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M7pui3OkbR2lwiipzc7u3G8MFZEuCI5orrZSJa98Gb2Jf7yBKilAxa1YvOunkbJbWQhP8aZgEuHj8ErpkMblkvLqTNsbjYdOXz4U0U4UJAiosvww24wnaNbP9anTYgDEDDSZ5HKfvYvWGlLkALKKHMQdZLcM8vE4CXi2SW5RkaCM1hqy8+wMV85K7kNPIa3pilbGaS27QEmOPW6WuPW/cmCweARVdQINX3b9rP6gB6R6gw7ayMRm9WesB7Yi09F2MoRx1h0N2pRT0KbdvUcwa/bNDeQkFj258XARk7B9B7Ivix/GcsXBi/4LauLt9bZoLBZSVfW1OxBTbLMhY4Yex3EBoxbzxGUXplNCOf9/j7IH6O3vjT5Ladd0P6gtFdHMOPipksqSMGfahZS41apzxw+LiCiRGmEl0nDvg3w2FCKP33tjoQwcAiKL/3QErR1d6M3jgCgSxpx7sVnHuWbeQ55YfYzr5Cb7ShiUDRgIDbJMO+QghQHVY5/gVcfUpWrzYt2moCHhegeuSMui1J/07gaQjPw7Vk0rleicWRM6X4Y22U0FPlBG9p9daVbIgJFdF28OTM1lbf8ek9f1QnqHoOOr+luBFsmDRxG4pfWkM5eH2zheJLzZ+QkwRlL++xHjqTocmbMdSeAOuqU1YWWJwpyRO9sSXGPsKKA8ifh9AeeEB+KY2YUlsOA2PMwuVmXm7A05pNKox6BEolVBR9iVlaywxyNPuap5W5o4jLcJj0+hsF3Fll7z+QKt63osKFj57UiWk3SFqQ2ApjZ5Ys3ycw== 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)(376002)(136003)(39860400002)(396003)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(82310400011)(46966006)(36840700001)(40470700004)(83380400001)(426003)(40460700003)(6666004)(1076003)(2616005)(26005)(336012)(316002)(70586007)(70206006)(54906003)(6916009)(40480700001)(5660300002)(103116003)(2906002)(4326008)(86362001)(8676002)(8936002)(36756003)(41300700001)(82740400003)(81166007)(356005)(478600001)(36860700001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:29:46.5832 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6628f383-62b9-49e6-f0c3-08dbf61c5c0c 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: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9094 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 05:30: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: 1872436 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=o/mzzbsI; 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 4SlQwr0543z23nQ for ; Wed, 6 Dec 2023 16:30:51 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 75D898752F; Wed, 6 Dec 2023 06:30:49 +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="o/mzzbsI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 07F39875F5; Wed, 6 Dec 2023 06:30: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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::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 E7AF487494 for ; Wed, 6 Dec 2023 06:30: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=AKaIIJ7GiKA8i0cdkq3w3iWY0joIx/sD80PYfXNAl1+AVBGkm/9jRwMJ2VCk2Q/s325FSJMrTyGe1ZI9RM86UALU+0G7z9W4ing3pDqooUuD4Q7u1KmClCahO0s3eZooaHr6EWKFrpyd/5BAfzkaSSwvOwYOZNkZg/MNu5KDdcowtnD87/a/UvXRD11MVz11hOBBpxWF/KwbVTglYNeNwT4d3ucNmGYisubG6Sd/VU+jbrNJyCkkkF73ep7w0Jd6JAeR2KfjuZ8g87qGt9zsAukyapEiEYFzIKM2OEB/XB9WKgIewgkOJl4oX7vz4o2ru04Gt3Am0gzbczGcNbzdYg== 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=DPaWJpydwI1SRmh8oRMEuoFte6F0UCXvFTpkWAq81MTUph+WRpnAYKxosHmOLwHyCG+4tDUkTwRpxgIR0ynZHVpWK7xO4KOrtrx0fknIn/03oQZZvvDGxqmGdpFA/kaYTOK0jeGkT5p8FH2MrmivB6nvg3Oxcb2wp38PsyyMpadC5V9tGR/pR1tG2bsf7RfnPkIySSGmF8iFEuJjNTeMEdK64lk3FMvN7+vUv8XuQ/jDX33k9AXz+aBb8W5UOBfey5R/we6Q5SQaTPsJbL9O9xaDpPHIRXXdqUv7HndVp3f2HjvTTHmczxsmP1mu/tXc7J1K1wSkNDeRHjOtf5czdA== 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=o/mzzbsI8yoXQdZBK6Q26sTNAtFYUzSPq9W0YunwSkqS057UTGxucwJHQpY93DCB/Y3df3a20OBUPjvP9BwAqTohnN4sQdw1VlV2OVAZTHEUaJ2aVLVW4wpRnUTVAMrpvj0ruaj9AZhqeg3Xunzvxc2jaO5HF/e1SrPj9hBLLJk= Received: from DM6PR05CA0062.namprd05.prod.outlook.com (2603:10b6:5:335::31) by DM6PR12MB4137.namprd12.prod.outlook.com (2603:10b6:5:218::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 05:30:41 +0000 Received: from CY4PEPF0000FCBF.namprd03.prod.outlook.com (2603:10b6:5:335:cafe::e) by DM6PR05CA0062.outlook.office365.com (2603:10b6:5:335::31) 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 05:30: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000FCBF.mail.protection.outlook.com (10.167.242.101) 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 05:30:41 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:30:40 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:30:37 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Ashok Reddy Soma Subject: [PATCH 02/30] mtd: spi-nor-core: Set dummy buswidth equal to data buswidth Date: Wed, 6 Dec 2023 11:00:24 +0530 Message-ID: <20231206053024.3744447-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCBF:EE_|DM6PR12MB4137:EE_ X-MS-Office365-Filtering-Correlation-Id: 85919d9a-24d5-4a97-f803-08dbf61c7c88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rTuRgbhyTSp3g0PoPBcwrg0mjEucNI2REmi20jJhsjnGn5f3DnhrlQ4vGTwfHHbzHYRSKVqhW3YbY+H9YYp2f/jlOP1LUjZSOxUj+PTlkSAW3CNGceEsTWleepKx1XbB/FHwuQpbZz42nSgNINxlE/92g0G3Q+XC46qSyDc+Fg1xZMtOfcM67bLa8hqxCXivItuqZtsr5TeMggP9Fc1vv5TToN8RiWPYV+YitYFQoud40xf+/McNWmoKx65erMrj1VgXdFfYIAzX5dhT9D/ZYX2AItMwbSZStXtATQZhAacaaGperQQfznV+pxN9kG4lT1jlM48BKPp7O45gSj7wIlJ786Yyvtj2GLaiHN2BxQPSvX8hW6Q7C2H9QecWqGi4jO/7p30D490SpPSJLlDgTccQibQp0oEvElMgyFp8PEAdMu+ixEEInCQxgxdosLcwSsBD5ZiUUjqaR0Bxnu8eXEPH/vm2YgdQTayKqu1+Ykm8kxMRDM1AIel9N33cGvVcKsJXjLMVxKA5LAyb1W7gsZqhljFa6AX7cGEf1wBlY9y5IoWdrFel2s5guz0ouhAftBWus8KbtuLXU3blUfDj3LXzzaAuZlFkNEWAvIIFvhcAJEC3J0rm3b5TUU1lHDHlcET8i3uYEX8cBX/lJMRK5ABN5h+8L9kkClsX+zfZBIM0t6I6W3r2Y/RkPhczyS+YSpR15vKDr1Vn2HYpEOc926ygj/gBOWCAMtoWX7XVCHikmn9joE1A5NH98ZyxGUffr64+22hQhUDEwubgLDQdLQ== 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)(136003)(346002)(39860400002)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(426003)(83380400001)(478600001)(2616005)(26005)(1076003)(336012)(6666004)(316002)(54906003)(6916009)(86362001)(36756003)(41300700001)(8936002)(70206006)(70586007)(8676002)(4326008)(36860700001)(40480700001)(103116003)(2906002)(5660300002)(356005)(82740400003)(81166007)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:30:41.0987 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 85919d9a-24d5-4a97-f803-08dbf61c7c88 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: CY4PEPF0000FCBF.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4137 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 05: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: 1872437 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=tHlsqvj5; 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 4SlQy440kFz23mf for ; Wed, 6 Dec 2023 16:31:56 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F16318644E; Wed, 6 Dec 2023 06:31: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="tHlsqvj5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BDAF5875F5; Wed, 6 Dec 2023 06:31:52 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20626.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::626]) (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 AD7DA87494 for ; Wed, 6 Dec 2023 06:31:50 +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=C+nmyVKkWaY4c4AFS/TZ8KR+KwNIftrNjRj5vIJTyJM/fqaN9BbMRrmsyvfg9moB0OWMY3VoDis8WTzEARo8D09MpWVmUQFFZPjYn9wSeA+zf3qIBhMIFEL9TxL6HZkasuRLb0+K3nOXYQ9vGf/b6hSWG71oz2lsFeQhKxC68/FD8UxPahzjKqHUhoOoiPioGNNureD8Hh3+txtiYuD3p03y6IjL0WALhGQY2As7QkrWoK6LF+EF7gFXK4l3ZxQf81KMKfvDrh/1OubtpXgHN7mf3hMaJMo8wFgOTDtzyWK6vtkkq7zpwrezO0zoqEyX3qB2+9Es4sx4fEWh45tLVA== 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=ijqbwPXtO14xJS2QnGnclHsJQWYLW58L3YP/em/raptX7BsXVeZdVkB42Q3Ch8qz1GV1sJNnvxAgfZ4CQht/AJmEMOe1oLo/SG3zIhhy54EDGIjHtw74MemNaqIf5hzjmbSArn5uAeo6v4q0/oKz2e3lnbwsEqWs/QfnMpdfDbCdMa3Z9cnzy4IgtP8wlGoRzNOX9RnQYX/DlOksHvLgsEXlVIbvKoAnFhn1MP8C4kwcqPYNc+x24SMXOyCBrAptxMvUWfpzMcltmklZIUNUlx3em/B1RguXX5YLGUzS3Fa5AcGCqc2T/HWZFKuB2cpImCealbtJGhfYvIB7MfFA7w== 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=tHlsqvj5nU33tjeUiYjv/Fkmv4QDoVTo0sPnTuhP436ZPC6qtL35bqwamT3maQeOluNSTxabBM3404lZavrm+hnCBCDhRUPD0S5/Vtjnmv8jmkmsUsbbMoAQHzCo28ECFbCNlNqgNLZB0PRp0KS9OP8dTK35ucA1gE/9ewzG5uM= Received: from CYZPR05CA0033.namprd05.prod.outlook.com (2603:10b6:930:a3::22) by CH2PR12MB4198.namprd12.prod.outlook.com (2603:10b6:610:7e::23) 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 05:31:47 +0000 Received: from CY4PEPF0000FCC0.namprd03.prod.outlook.com (2603:10b6:930:a3:cafe::f3) by CYZPR05CA0033.outlook.office365.com (2603:10b6:930:a3::22) 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 05:31:47 +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 CY4PEPF0000FCC0.mail.protection.outlook.com (10.167.242.102) 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 05:31:46 +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; Tue, 5 Dec 2023 23:31:44 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 21:31:44 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:31:42 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH 03/30] arm64: versal: Enable defconfig for Micron octal flashes Date: Wed, 6 Dec 2023 11:01:35 +0530 Message-ID: <20231206053135.3744877-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC0:EE_|CH2PR12MB4198:EE_ X-MS-Office365-Filtering-Correlation-Id: 9807943d-850f-4404-0667-08dbf61ca3c6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FCIKfKNp7KRxj3fOVkMtWvSxWCl62CJoLc8iK7uxVbHr3f2qghyBcb4n7NeYjcRl9eA+SmZHMyU+Hk+ixkuOUV2mAQzi0EEHl2ojYrukDXMLwfB27Bw3OKss6BLeOgIzTps7J9Ecb8yEEggoZG7/obJkDw9PSjkyH9ImlZTIITdUffc/hqj3UR7q5MNa2//dmBbXEdHuCqfgwfdZ8Ph5CEjvPR6SkHs30UCwQl01cW1JYke6dlhreNL6otOSMoueUxZEvFhfFsQRZWGwbjLR32m7Ttk5ptcuIvhwTgvwvR4klxlXvYpp2EGet0atkLlOjfoHxdTtJZMr0lN/rG8bBIpkVbQNdwf7gdH6zDZPfOY1T+Sg5Ctnq0w/YQo99HNR2vlwK2z3uXocOnNFdLCwFqWVvb6le/Y1/VxtHUW2dOkEcVxJ4pp2DMALevhJl3CcNZYe+1K93b1dVQS/TYBq9sgyoBfI0mvAqeFV/KhpWPvVJ4NzQMeApXc9bt45ARBqSdu6MrtZ+153hjmN0SN0KZH95LULovshxw4gpKVMjaAasKeupQ4P/rODfUZQ8ptOB6aH6/vj6p4RjjxOkaqbm4VzvEut2F//fczuNTeZs3mbDZkMIzIzWnnz8/etfFrXWCRmmLN9gfkyO0iZ7upc1LgWcGsJlH6/WUHxlwRJ4omSj+qywT+EotfQTT6Kl/ZHmGEQrEdS83OCtOQ9rMLGPEDfUM1tc2ZEeVlIrH/1fqeG4UNyE4J2hfF6Uk6ugalWjnW9shj4rZ4GU4AYpkzUxA== 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)(346002)(396003)(39860400002)(136003)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(36860700001)(6666004)(40480700001)(478600001)(54906003)(356005)(70586007)(70206006)(81166007)(316002)(26005)(107886003)(2616005)(1076003)(47076005)(83380400001)(4326008)(8676002)(8936002)(6916009)(426003)(336012)(82740400003)(5660300002)(40460700003)(4744005)(2906002)(41300700001)(103116003)(86362001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:31:46.9144 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9807943d-850f-4404-0667-08dbf61ca3c6 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: CY4PEPF0000FCC0.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4198 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 05:31:51 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: 1872438 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=w57n3jD7; 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 4SlQyQ1tdxz23mf for ; Wed, 6 Dec 2023 16:32:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B148187683; Wed, 6 Dec 2023 06:32:11 +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="w57n3jD7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E74F87683; Wed, 6 Dec 2023 06:32:10 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::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 E66C9875F5 for ; Wed, 6 Dec 2023 06: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=fail smtp.mailfrom=tejas.arvind.bhumkar@amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UBvpzet3YZKKL8U6RUxQw5LcS6IZGG7DgPw9o1ITXCvrufyMH/G6MENL1QqBrmjlvLklUwwepluJaQKS8XJI0VyWacXwaspywd39f6aeUF8nNkB83IBLU1ORe9rSqunZq0z4C69hCqDqpcj14ej2zqT1UAUqxPbZYXOJUzIgBadCvAfk1lVXyriZ2sd971fbmrSo/Kkl2vuveA/n7OPeY7uenT7q2tOEKYW2qt9Pm+iuMc28WItpwlXeRGIUvH+n6YBzIvmBcQxLOqtjP9XBebsWFEnYet4tGwHZjjECBzKW5buWW+3Q7rn/0FWxgLnxJkXPi/RvyOzJLzbRgHvZlA== 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=HMa0a9OqPNQMbZ2TXf4IfvST2tgLVUcDc8J6p/6silMs3I/qEoKp8jvFT5eM7FbzYFUhrjQ6cmBf2Rm98K4xvtZONIbrNleBHuJerAmPjtHV5755jsT6yuEEIUy12XUZEk8P8fDdxUVAPBT4gRaP0BZFkAuCBN8goBvtWk6LsSXh9+MyKxzsTbAQBe59DM1QEDNnolEGUFPqLPLNFoX46yqtxbVZ+c6+Fp5BpU/OdNSpI0FqTb2M1Fp9MwjPytY4TBQKAiAHOfIeVp24eLkxH6XZCHmi5FziJMLAi4oa9zEQXwgCQfhI5sqoe6eBsJV+q7vdlvzIAH8+4wb0IGbm+w== 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=w57n3jD7n/16iuveSWdzCFIrIzl0fyD0fFiPH1KfGJNUyhsYcjRr/AMuBlrM3aUir2ua4RGZw+LmpCYHjVozh/RGSS3UwA/V5DQvZZCRN/E0eVwfw3D4gsFl+ExNq4lgWNIdKylGl9GptgzzXe2uoJ2XepQ27XKCG8+/ppo5mrY= Received: from DM6PR07CA0114.namprd07.prod.outlook.com (2603:10b6:5:330::29) by MN2PR12MB4254.namprd12.prod.outlook.com (2603:10b6:208:1d0::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 05:32:04 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:5:330:cafe::25) by DM6PR07CA0114.outlook.office365.com (2603:10b6:5:330::29) 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 05:32:03 +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 CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) 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 05:32:03 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:32:00 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:31:58 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 04/30] mtd: spi-nor: Enable mt35xu512aba_fixups for all mt35xx flashes Date: Wed, 6 Dec 2023 11:01:51 +0530 Message-ID: <20231206053151.3745010-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC1:EE_|MN2PR12MB4254:EE_ X-MS-Office365-Filtering-Correlation-Id: 62c8fb58-eff9-4c9c-af7d-08dbf61cadaa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2r0MlLcHq4ZM0angnFbMY3AX6Dg4o+a9D6FnxmGm5Jsx/CnzL2Y+/b6R2FNqgP09ddpDKtA6mVCLa0d/ii+Vhx/dMHTn+vKFY1ydEbRCdNUuWfZfrl7AeiivaSep8Jisd0wK4ihpo1DXKSs013IoL7Mr9JHXYPr5GQPV3h6pSpkFX2khj8RnWbGJp22TKNiEnVsC+qqcYeTL78y2OJsRq1HCCW4tW6LGfgNMqyA1mPlTbxJ6JCraAQ0Efncz3HIUA2bOgQe9dG/eu7H08V2Oou3hy9nNPzVcJcSarlHicNA1jPLxMV8EV1LmICTM+z2//T2udYTgk0MyvQEFdynTraIim7qlfNN3TDAGNsPskkavDF/l9tIO131Tq7npHdo3fu8rx4n0N3KeCz0sLIFJhDgD8kc3mwYLm65TIj43aZ02OkRQYmlVu7eOcG/HYMcu1lHLxzcgXm/iM3uWzZ8YMw1nlD47eW+yf5S/QHn2UDac1ckQSwrg5Vhu+lsBkloL+OZ6IHDZ/2NMO5jAbszqTuZOSdDLe2LHypo3kXwksl9m1hhtOZkVcYh66kiaeBLzfo/FG/11JzyPvSl4HNd4K9HTjJwxBT4DycuIxIEv29TFspVUagL37u9KC2gpgzEA8+oPVj8efc//i7WoaesgwnemJlkLdrZ40lOzyGtGGqrILSi+7L2I96HZcQZLXCT+2NEvYNMZE9EpCMPspdbMkA3iHxo5SJn/uMORNAP0vrHUiiVCx2nxyZNwOHefz7ZhgxIdyhz/X6gZw2H2E3yF9g== 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)(39860400002)(376002)(346002)(230922051799003)(82310400011)(186009)(451199024)(64100799003)(1800799012)(36840700001)(40470700004)(46966006)(40460700003)(103116003)(41300700001)(54906003)(316002)(86362001)(8676002)(70586007)(8936002)(4326008)(478600001)(36756003)(6916009)(70206006)(83380400001)(36860700001)(5660300002)(47076005)(356005)(81166007)(1076003)(2906002)(6666004)(82740400003)(336012)(426003)(2616005)(40480700001)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:32:03.5125 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 62c8fb58-eff9-4c9c-af7d-08dbf61cadaa 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: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4254 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 05:32:09 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: 1872439 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=qup1jPHb; 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 4SlQyh5XQcz23mf for ; Wed, 6 Dec 2023 16:32:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4049687682; Wed, 6 Dec 2023 06: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="qup1jPHb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 21F6E876A8; Wed, 6 Dec 2023 06:32:25 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2061d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::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 E71D4876AC for ; Wed, 6 Dec 2023 06: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=k3gMkfjmaeeYPa4yp1Z/8zzg6PkOOBxg0Z8ZppgymnOr997msfI/VYKzbdVCQJUzz9ND0cqnlNowTKBcRvn+AAqjLZj6HAMsp6ua56lVubAzX942dMXqwVqoi7ozC+EjFOCLcBA4+Drqq3z3jQkpkKIIG5DVoTdAlj/x1hW1xeramATQrSlRa5LHhe1JP1IeAWAegQnOen++ki1NHTtPb4lLWsf7M/+svcortB9Ud6BuZEWXfFqs5PGJYjwQjdibFx78gjj6LoUm9V5l/IP9nmvhDDPUVnKgADAALxOYdkfvNZiqRdpKfgry1sq94lBa9vPhZPJxqzBSX7xeW/W9mA== 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=csEDarvuTQSkBCTmjLY3RX+8ysMeiy6svSgPfC1ThLNI8dpMRyH64XqF950rCukipJ72ww3EviMnGg0e+9sKuBdmP+iCQpW55OQo2ACaHJ6vmWZrsFILtEDqC8kCWXbru8sVhkOb2mlI1VRVFN/+8JawLErDrtjHy8k/wY2VZSodfd+Ie3VQPVcJ6ldhfQGT/33OGqbDPZVPTlxcIq74LodqwDrMEDz0jg3nthKBzTJztGuBdtpfstrVNUt7YRDqQpKSyS3zxKiW1Aq//gqtVs3vc/mikud8pL0dRqgDIVwrRTmE+PxeK+sPhpBTklTD0JvmG7GM62qVA1SwHqIxCA== 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=qup1jPHbYAA4mEL5ptgylyarkKpmYj8loMv0O/FhMk2iGzmahrQH8+9ipqWTfiIyVd1jD6ATPBy7swKinzzsOu6aFv9DRy4yvP7awdyCZ8naw2k6+yoYz93WEp6MmS/VvSIfE9U0DRFmVMiDCIZTaKtCLBzh1x3xhsM4Dw54EUE= Received: from DM6PR01CA0022.prod.exchangelabs.com (2603:10b6:5:296::27) by DM4PR12MB5961.namprd12.prod.outlook.com (2603:10b6:8:68::21) 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 05:32:19 +0000 Received: from CY4PEPF0000FCC3.namprd03.prod.outlook.com (2603:10b6:5:296:cafe::f7) by DM6PR01CA0022.outlook.office365.com (2603:10b6:5:296::27) 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 05:32:19 +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 CY4PEPF0000FCC3.mail.protection.outlook.com (10.167.242.105) 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 05:32:19 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:32:18 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:32:15 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" , Michal Simek Subject: [PATCH 05/30] mtd: spi-nor: Add support for cross die read in dual flash configuration Date: Wed, 6 Dec 2023 11:02:09 +0530 Message-ID: <20231206053209.3745148-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC3:EE_|DM4PR12MB5961:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ef3c58c-1fb7-4abe-7624-08dbf61cb6ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aCwSpyM3lkHMRE1U4o/67E6EMFc4kF75t4t57OzWaY1cXDcY+MDq6lmdjZCTDuS2CuHkzNrjtjWXDu4SlG5e6Z1Xum1y44+PqMz14Fm6b0xyfCefgDvDwKMzgCop1jCbgAfENSG3WrS2QgpGaFbpfdnstnVlcqQIJKd8AtRGSB/10fmF8oTQO0Vc8993FqM4JWrKblN+AcDaBXUK/+/9tFSHqdYzyWTXHBMwdMqZmsYDYd9HUzFb1E9KR92448RN0qnkB4v2koHMYgIbdEtYTOTFmkn/x5Cxjmsn6sYaSBswM8FNxocIe2Olgfryh/ZbSWLIgqslmrqLBB3uAixIlNznSElWcbKT9KZdfScQBbx1BimzcYZvJjyPD8Iudc59xhVXS+1in03XGtdwHMWY4l/sNSUpt5zrshxrxBhpkWUxQcVhaCucp5RMLBZcfcseYW7fD9G8tmUZiakH9Na1uH1bywjrNwZOtylO18QYH9D4/M9sJd5/uppUIbzvF8DmmAaIbQn4ihpO+8HkY9b+dfu6G8Iwb/UvSZVfc8uUkILZ1hsIbzO+ckdYKuV4J7TgnxDQns2RLPVP06o7GuKSTdpAPy5bA7J7GzsXwKkEoEBaKV6Rk2PhbvC0IyQHsNAqu1aV9Su+3Gcg19pnugGBZ4+UX08IVU4c54cGRIddaS6X69yXhJZJ2OTFmevSZs3teGfengLGyD5d9hZZMe8y6jl+SYnB0g5S1IwnNma/T7XHH8HAZkrGS/X3EKOlXlBJLTfi1apGl8+fvFIdfze8RA== 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)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(82310400011)(46966006)(40470700004)(36840700001)(83380400001)(426003)(40460700003)(6666004)(1076003)(2616005)(26005)(336012)(316002)(70586007)(70206006)(54906003)(6916009)(40480700001)(5660300002)(103116003)(2906002)(4326008)(86362001)(8676002)(8936002)(36756003)(41300700001)(82740400003)(478600001)(81166007)(356005)(36860700001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:32:19.0717 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ef3c58c-1fb7-4abe-7624-08dbf61cb6ee 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: CY4PEPF0000FCC3.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5961 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 05:32: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: 1872440 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=fEQfkOuV; 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 4SlQyz4MHRz23mf for ; Wed, 6 Dec 2023 16:32:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 168C286D85; Wed, 6 Dec 2023 06: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="fEQfkOuV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C0318644E; Wed, 6 Dec 2023 06:32:39 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20620.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::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 8D008876BA for ; Wed, 6 Dec 2023 06: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=GVXt8aE2OqCKVGZnyaF11FirLxsIhl4BSk5d5gpyOe8OIsK6VLNC6hBH5r3B5C0RkGSZ/5jmNPRRmOnZRQeHyR/aNJboEtwLlKOw3cjIvXXsK0AST7LPEUvZOzj8mIr3TYqyL049HpNJQl3rfQqj0d5M4QjDUfeqLSbamtEJTvghxCvGe/Rdy6VrzC9hag7cq5GJOxiCDImYI6dP4+Ez+Hnu44R8TthgObCJjU9h/TY/8qF01JSq2j8INMUXFRSpyZMlSGnrghzp6obOaSRPzKUyUcO9eN6WaPrORvuDm5kDJom9pqDbW6kz+1LmPN7K8SRHKvS8vZiZGV66NHUG7Q== 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=JQmvfDiNAaOF5w+h7NBXZRHK7XweTh+dopxaDlBgq5hm1aff0axf4oXa0i/NXOka9i8nYUXNm1sXAulxFPu02p7tXp8lbXoNkMoy4lgRSiPR/ca1TrcKmPTMIhD3BUe89QWfc/p5VOrjbi+bpWSnsIGc2xn0CFjXkLV4sxuxZ9klVQMvcdKyi3fVU+RraDA+ra0FvLvH1fb8YOWD9//rO4S1vyhBMnYrZIg9urTN6KCNCYT8XxuRYE1bzYc5Cpnl/6Ghyl2CKO/JWFvxNm+AAKamWNKanMvNjH9uLdHRgw/12YvEMcD0s0zFBz3V7h2xCZVQd18QVjtKuYyuEldumg== 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=fEQfkOuVMPiGE+/wkESmt+7jwK+72MSad3BaH+KWfI5tOWXetB652fg6F4Hb9sRS6gZurYuKYNcQaOw9FIpjbXtNCP8IoDgjlKO2CpacJfck2OdymgWiR4CtoLELcLIBz/4mZVQAIIlmANYEdaDHbSo7WAeHXwpA8kMmvtXR8i4= Received: from DM6PR07CA0130.namprd07.prod.outlook.com (2603:10b6:5:330::22) by DM8PR12MB5414.namprd12.prod.outlook.com (2603:10b6:8:3e::17) 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 05:32:34 +0000 Received: from CY4PEPF0000FCC1.namprd03.prod.outlook.com (2603:10b6:5:330:cafe::b6) by DM6PR07CA0130.outlook.office365.com (2603:10b6:5:330::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 05:32: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000FCC1.mail.protection.outlook.com (10.167.242.103) 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 05:32:34 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:32:33 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:32:31 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 06/30] mtd: spi-nor: Enable DTR octal flash program Date: Wed, 6 Dec 2023 11:02:24 +0530 Message-ID: <20231206053224.3745273-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC1:EE_|DM8PR12MB5414:EE_ X-MS-Office365-Filtering-Correlation-Id: 695cc1cc-00dd-4f1e-17ad-08dbf61cc00d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xWjzHopwY5Onw28cbARm9RUts65czVS9SJznMg5cpiHI4lE7u+b1UHtqSygOk+HDhdX16SucfcjK+8EKmo6HoH0qoLweq4709MW3IxN0eksD58YYUSoBwFd/7o7i4wrixTRE8/dYdkokzFGGVRf38Tanr41pjfevnSCIxF6ILczTvfGq0LudnhXsFOMxZWOSjhLjkC5hBY5PxAChbDLm0i5NvMzX2CGLypTdN10thEhWXWMChn8LdXdyUAkux7BwIG/tt+l25eBDcxO1iqXe1Iscys/4LcHvlEPWjoYVoYG28Hsz0cgY07a/f37Q1Nb0JojLCXH2UQSG27Fmo5x8fR4OGTAZ27xlYSBEKX4pVJDMPuPB93Dsytni0AUCPhsocXZvkefeJbEXHwQEQV3ACJeXakZtEegGTDS7SpteDXEq/+BNdxv4WuHlJIozf61COgFwDbHDAMaXj07TdZCwP2P75R0LBcnUoqkpcfV+cx5Vqqy/uM+9WsZQg5HF8EIBwRr8s6indbUzYTvvwLMCNgi4c/WrXPH/n9LeleX6fZo5uSEpz5vn9fuwmYXFfgy3gBqQEDxLzQlz2SYWk2AIwFFs2+GpT/3qYNMRJ6EmeTegqyE0ScaX8JMibHkoiME3wJeREqEgXNDwXRdci6641ixW1IgWcmdwJrKPBldzEyV1gI/vFwRanR3i1t/EMjPPE3/j/rsWmRMsZj0gynXiwhEPWaVGOTUKnPv3/6IjE3aYo+u1jPEgD1LUidLAnDeuHdjuPNuqDWOGexSC/oQxtQ== 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)(346002)(396003)(39860400002)(230922051799003)(1800799012)(451199024)(82310400011)(186009)(64100799003)(40470700004)(46966006)(36840700001)(83380400001)(40460700003)(26005)(1076003)(2616005)(336012)(426003)(36860700001)(81166007)(356005)(86362001)(36756003)(103116003)(82740400003)(47076005)(316002)(70586007)(70206006)(54906003)(6916009)(8936002)(8676002)(4326008)(41300700001)(5660300002)(2906002)(6666004)(40480700001)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:32:34.3564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 695cc1cc-00dd-4f1e-17ad-08dbf61cc00d 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: CY4PEPF0000FCC1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5414 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 05:32: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: 1872441 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=v1Zp/sC5; 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 4SlQzN4VySz23mf for ; Wed, 6 Dec 2023 16:33:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0D1D887683; Wed, 6 Dec 2023 06:33: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="v1Zp/sC5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1302087682; Wed, 6 Dec 2023 06:33: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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) (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 0DB5987683 for ; Wed, 6 Dec 2023 06:32: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=lqFkFMJ4PmYzwvc36Zg+uNvYyF9kI0L+vIo2y9HybxJu2zVzwRf+bJB5x714hilvJK2TAja6IL/N8cKxtnVxMLrNPZO9y3ZAyXl/x1rLVy5oMXJyrwSQs2Gk6dO8mlcTvspwIrVDT2gQWB7d+O/Y4+gEVHHU7QTk+mWC+VfiHEhRx38zNT8Kn8KaiBCKFQH5PEI3NsgRE5a/2H4mrVBeXNEBEBsVChQts3Kf7bshXRxaIwNORzYajMqBWdDJrMJ456b3SPPZruImXa0g8O88nO6h8UkNggM5yrzCytd2FFguZUHLvyiyDu1C/GtmojyIUjFQfHgUG4UBh+8dE2kP4Q== 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=BHztlAnKtpTDD4jxC5D5kzu6wBOCy+A3KrEkv92QceUo7fTvLAX7nJODuMBI/MZtuu1zc/aXtLlhx+5449Qk0lzJEPuUMOtEVgS0HcyJn0sDk2j7y5NfhBlROjcvS6zCmEHT2o2LEvUsI6BRc+xmoCc+rfNNZf0y4anJKMLNu9QfzwtcFA7TR51x5aeGh8RMvFk0sgauhBQoCgUzxNE2l4tGKtxx3c30DJc7Ui/+Ahbkq61fyisgCFjpOq/MXBmPUGiV1yS9CxxQa+phIHIn9vXJpuxG/D0mA2EUvhNUQ8GZqwSjielN4grDxfnWRyrqbZji75UZA0/kt1/XNNQqfQ== 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=v1Zp/sC536syV4nxJS3S52GV/B76g6mGfAovHFPuY+B3RyOBvX2EgzkxiauklH/Eg2VHLXbsFnx6D//QGRp9hwOObEmchC9DNki5junGjoanVQda3GS/O8jOHjqzrOK0OoFEBne3yQOC18owR/5HpZf6/VAqESFJS3nvPuvFNBE= Received: from DS7PR05CA0001.namprd05.prod.outlook.com (2603:10b6:5:3b9::6) by IA1PR12MB8554.namprd12.prod.outlook.com (2603:10b6:208:450::8) 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 05:32:55 +0000 Received: from CY4PEPF0000FCC4.namprd03.prod.outlook.com (2603:10b6:5:3b9:cafe::4d) by DS7PR05CA0001.outlook.office365.com (2603:10b6:5:3b9::6) 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 05:32:55 +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 CY4PEPF0000FCC4.mail.protection.outlook.com (10.167.242.106) 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 05:32:54 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:32:53 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:32:51 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Ashok Reddy Soma Subject: [PATCH 07/30] spi: mtd: Use split reads if multi-die flag is set Date: Wed, 6 Dec 2023 11:02:39 +0530 Message-ID: <20231206053239.3745393-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC4:EE_|IA1PR12MB8554:EE_ X-MS-Office365-Filtering-Correlation-Id: 6727f9b5-bba7-4453-fc34-08dbf61ccc12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W4BggcYsJ6RoyBE0WcQ16Lhm00/BodgP4Zh0YsSB6Kjjx1bKp5LLa+xDgQw83+3KV4GYnJCS/6t92WPnolx0sAAp+D0gmqIaQdDfGporgWdhQPOOcSVbAzcbTSjJp6yKo5HkRNt4fT4TzobExhY61gVtAgMnzwlQTdzpo+fSbjR/j1lUp3I1BwAC3BSmj7AzW73BbGCKVSScUF05k/Mq9u+cvbjSidWBHSjGakUGuWKNXYiEdesDc9bUTkBS6cHWJXsdlgssL+wAoZYmjels9/S3uCiYlr1S+nAfVmdqqeLYk74OQ4I/mvDsCHDins00eq3BJ/GTecktpRf3h53XSeBaR4ldHl+DwxnxHKqiTASnaop4yrfXnhfFjsvXEah1JaSTXU6/IzfKLXy5y3mTybxgt8ZMT7Rz+hlpL/5ypZSvoAM3PA2WbMkhjX/lY18SmZOdbzO23uLBhkTHIFXmwRY4JPr7CnKhHHnU4YVTGa86w3rmpwjZ9SGdz04fMaTMMkDtOReWTyEmJFP1302PNZdSVauIPedyCkNSQSsg9oVjPXdWV+sIeN+GhNNAOsFBrIaZa5L1Mi17Yb63E/Ag/COKRZmoEs5FMX90UicaD9b264h/v9EiUOpAmuzsyY/4l/LLv4J5wX3uXBrPrExY/pZjWwgSpJo/wCD4RAHgrW2NvJB1Fkf/uHByZgyn+yyIzKCe/8RGMBMVesEqRDY8anjGr3WggrI7xpRXI29Fde9ITJMxhA+vSWrReJQmc6moKtIQDrlPJJUrE7kQFWbK1A== 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)(186009)(1800799012)(451199024)(82310400011)(64100799003)(36840700001)(40470700004)(46966006)(86362001)(5660300002)(40480700001)(54906003)(6916009)(478600001)(36756003)(2906002)(316002)(6666004)(41300700001)(103116003)(70206006)(70586007)(8936002)(8676002)(4326008)(2616005)(26005)(336012)(1076003)(426003)(40460700003)(47076005)(82740400003)(81166007)(356005)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:32:54.5276 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6727f9b5-bba7-4453-fc34-08dbf61ccc12 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: CY4PEPF0000FCC4.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB8554 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 05:32:59 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: 1872442 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=XSTXsKH/; 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 4SlQzp2Wkpz23mf for ; Wed, 6 Dec 2023 16:33:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCE10876D0; Wed, 6 Dec 2023 06:33: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="XSTXsKH/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 56E9286D85; Wed, 6 Dec 2023 06:33: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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20617.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::617]) (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 EABFE876D3 for ; Wed, 6 Dec 2023 06:33:19 +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=RkvNp/MQt7QetRdl68n9vJhlf4NaqyHoJ+RMh4858uJGF3YsyIPbjK/cWaUvvVx9Mgqj32lmGQeBg1QJx68Wr3ucxoyZQCSx8HzICF0HR01sqj9hVW33NvkSPg08bIfeB0g+Okcw80Anvb7pNb1pp2iqo/WakI+ancUAQ8tCNx0loEoUbpdjKCa39pE6o2tjIdmNRWfbYalwllEry+yZK3Ti7Nhs/E0TmTZRoKPRS28ebebvuCApYyqNwRs7djfkqahNS+B1rypq5uDsHgxmDlkXNMgPzSWE617aetrOmvNz2ee78iIy0V2YrRt+1kDg6lB9UHN3exeM8KDZv2zmYg== 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=XEO0SmDfeJO8SD1W3Gvn49eU69ERU1bRGq3fpcREzY0=; b=cQbxn7xremlPoC0U+8E3bksY4/6gdJl2NJg+HThgQ6zo6LWEkowyt7go0itczDHvIXk1+MQKhY1nycp8l8q8KmivJn5PUvL0vdPSGGbnr11g5PGPd90iHdVa5NHkz43PSfuMkAOKW9MBWMHy8RRh9WJlDJ20hcWuCcmsUAF0mHQ3kZ+waZTgsZ4VJGrjxSBrQgfLPF4j2RtZJVkE+xNm0ANTTPPooMUVXv/mVMte0F0mY7QJARgaWHMEHvn3gD5YmiiobJMf7UXO2xUTl7+S+aNSgPvZcuL08iQL1geVtXa+UwMdnHHZJvgNLuup1lBRz0S9ACqk0kEXvBUIFacseA== 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=XEO0SmDfeJO8SD1W3Gvn49eU69ERU1bRGq3fpcREzY0=; b=XSTXsKH/zq6/zxKEXcxjSWEdUgRMQZH6++1ndwbUeEzIXTl96i+HsjtSeCI0xlPHD6puTL/LVJ/MPfTFOtkOLzEWPkVZs/fSfAi3wgeKPidgL4qLqZZJxWu0n+NfoYlaJKqoys1nVnke6ybOSPRKe4LNzcsyOAfsu6mAdLK/7Mk= Received: from CY5P221CA0089.NAMP221.PROD.OUTLOOK.COM (2603:10b6:930:9::20) by DM6PR12MB4042.namprd12.prod.outlook.com (2603:10b6:5:215::11) 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 05:33:15 +0000 Received: from CY4PEPF0000FCC2.namprd03.prod.outlook.com (2603:10b6:930:9:cafe::ec) by CY5P221CA0089.outlook.office365.com (2603:10b6:930:9::20) 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 05:33: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 CY4PEPF0000FCC2.mail.protection.outlook.com (10.167.242.104) 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 05:33:14 +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; Tue, 5 Dec 2023 23:33:14 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:33:13 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:33:11 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH 08/30] mtd: spi-nor: Update block protection flags for flash parts Date: Wed, 6 Dec 2023 11:02:59 +0530 Message-ID: <20231206053259.3745551-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000FCC2:EE_|DM6PR12MB4042:EE_ X-MS-Office365-Filtering-Correlation-Id: 2ce56656-16de-4157-1dcc-08dbf61cd842 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gGHvbSretG80wuAtaj5O41T0PPHbvwixoSzFvXwawW9RIU7fUBlLq0fTT0guW/aed3UoHpcLmYyuAgiXEWkPSEZ7qSyTIffYayu4xwHfThlez4FGMRJ2Q/ZJm5LNXf7EMeonXsCXlMu6yAHKvvOw3tmQ+VT1o7ttb0MOX//WnD6nZdY1ebLRzRuPwHERPb7rpj+xicK2qJSfUZ/LnHBVDQwn3IQIm0zUoxRjSCuq7FpteOuyrWwZZf2KfO5mJeblhdI/dYF9fAqlOm9v+meOPFxFEEoClhyM9D98GdNQRvisf6vkQqVtxR79MitG+r/Gzt8qxD8yDJ/BN+rzMLWKc4hXCK7HO8G458CZezG90IdneerHdO0dHmgO8x/NOBORe2iCllggjoveWQMepWkT0gDqhlwjquo0brLKekeeNcx/JI7eqzcWX2EJj/fWN3uIana1asXkXfHGZz+yPjz9MYu9SsZkr73S9W2A0fxS/4V4zZoAX4yAF/VrhF0O7Md7tmbpUKeUqOz4AgPCSByEcgmS+j/MDQr2iDJsmd48nZMpb83sG3JCTQSe4FEGJDkG2zfEWmAORi4wM56wYT7mnUil1Ac8FPx1TE96FKgPVz2uFf+/xSi4F6Y5IJIyQPS8di3DaQY1peZcp11LSWVjD4T7EPcdvhK2N9kKq7BnXHdLtrDsDREklbMAisOPn054bhN9TyTV0I9fJP0fENUK2mgVmNCEB8Lt3Hi6D7PU3dROUKq7TO0fF125GWcL2R9lQQrsm4qbLrAY9xL62R0MuQ== 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)(136003)(346002)(39860400002)(230922051799003)(64100799003)(451199024)(186009)(1800799012)(82310400011)(46966006)(40470700004)(36840700001)(83380400001)(426003)(40460700003)(6666004)(1076003)(2616005)(26005)(336012)(316002)(70586007)(70206006)(54906003)(6916009)(40480700001)(5660300002)(103116003)(2906002)(4326008)(86362001)(8676002)(8936002)(36756003)(41300700001)(82740400003)(478600001)(81166007)(356005)(36860700001)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:33:14.9692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ce56656-16de-4157-1dcc-08dbf61cd842 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: CY4PEPF0000FCC2.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4042 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 | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index 3cb132dcff..cb39c99fa8 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 | @@ -191,7 +191,8 @@ const struct flash_info spi_nor_ids[] = { SPI_NOR_QUAD_READ | SPI_NOR_HAS_LOCK | SPI_NOR_4B_OPCODES)}, { INFO("gd25lx256e", 0xc86819, 0, 64 * 1024, 512, - SECT_4K | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES) + SECT_4K | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | + SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) }, /* adding these 1.8V OSPI flash parts */ {INFO("gd25lx512", 0xc8681A, 0, 64 * 1024, 1024, SECT_4K | @@ -212,11 +213,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, @@ -233,7 +234,8 @@ const struct flash_info spi_nor_ids[] = { { INFO("is25wp01g", 0x9d701b, 0, 64 * 1024, 2048, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { INFO("is25wx256", 0x9d5b19, 0, 128 * 1024, 256, - SECT_4K | USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES) }, + SECT_4K | USE_FSR | SPI_NOR_OCTAL_READ | SPI_NOR_4B_OPCODES | + SPI_NOR_HAS_TB) }, #endif #ifdef CONFIG_SPI_FLASH_MACRONIX /* MACRONIX */ /* Macronix */ @@ -312,11 +314,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 +331,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 +340,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 05:33: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: 1872443 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=owcZtfj0; 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 4SlR0C0l3Nz23mf for ; Wed, 6 Dec 2023 16:33:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F6DE87683; Wed, 6 Dec 2023 06: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="owcZtfj0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51E27876D9; Wed, 6 Dec 2023 06: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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20623.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::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 430D786D85 for ; Wed, 6 Dec 2023 06: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=gaThB+8Gf4MvzJrBlWsAxDe40nYpeBviRoQiK0h5D7/BfhozW9EJG+u512c93e67irW1k5Q7IUAosVGhdS1INcl5J3LFgjEibzdD+6ajkCxzC1bQcZYf7RjSw7PO2QzD0my9fiopt8l63vuWGEVJM0j5SYFehGFTmedT2cRBdz4JitR5JJ8Pkiro2StKX0PjKAHnzR7gEsF8qcPJgcLjekcAa0bNU69mpMQmP5jzLu1S4zegSmPCyny2zXne7xJxhLndHF9y3pLkBDD6Ihp23TF1kIJZ59fijZpNeRrol0XL/Qr1p4O18gj3ScHUIVbIBGNyjFK4ZXpJUPgBOwovug== 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=HaHXknuWWV3/YU/3d/T05xxJzBLgn1cmNRcOP51t3HI=; b=VhD3LsHycUUHery1KubYd++uwHAyyAEsf9S41f9smxLxGDL0QVYYqtuUeOZ0ocTxKgWdpoAPiWfLPT/rKNHPFpMVnE98HM5mbYobq0pi+qbLpkZk/eDkOYpWkBRGzzK3nFe5mVgiiyNDJZ044T9C1n+cLbMMNgqdmhvrdLi+cOu8g2+Cwtg1VWTV5KB2XxSdwx+nvlcvlQI9HqmENI4RUpXELaqf/dLIT1+/db71fv+PbtM+QFzn72qYDuq233OpjWknLlb5rcaQtxzR034ugOTVtGT/qPZrih8scXFunzkee/NWbAC0swoE7lPMok9dopwxLxpWAt2uTwu3BAPqAg== 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=HaHXknuWWV3/YU/3d/T05xxJzBLgn1cmNRcOP51t3HI=; b=owcZtfj0ryJiqkDnQTCRTnOEWd6Wb4g/MmQkEOlP2D3DKrejI2l6qyUgEKxLLkQqJSLoxqNG0xwWvPF3gzDGYWYcHOERbGK/pUW+KK/zG1gDO2EH9vYS0yBIZJYavvcSrWW7VsMimxiYr++L0nFcTBQFwKOwtB8fF3CXkaAXhZw= Received: from SA0PR11CA0127.namprd11.prod.outlook.com (2603:10b6:806:131::12) by SJ1PR12MB6169.namprd12.prod.outlook.com (2603:10b6:a03:45c::16) 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 05:33:36 +0000 Received: from SN1PEPF0002BA52.namprd03.prod.outlook.com (2603:10b6:806:131:cafe::db) by SA0PR11CA0127.outlook.office365.com (2603:10b6:806:131::12) 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 05:33: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 SN1PEPF0002BA52.mail.protection.outlook.com (10.167.242.75) 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 05:33:35 +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; Tue, 5 Dec 2023 23:33:34 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 21:33:33 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:33:31 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Algapally Santosh Sagar" , Ashok Reddy Soma Subject: [PATCH 09/30] mtd: spi-nor-ids: Add support for W25Q02NW Date: Wed, 6 Dec 2023 11:03:19 +0530 Message-ID: <20231206053319.3745698-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA52:EE_|SJ1PR12MB6169:EE_ X-MS-Office365-Filtering-Correlation-Id: c294ac2e-1980-4361-f9d7-08dbf61ce4b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h4YF1/UFUnHeOQk08Iv30pVmjqwU0rab5X851oO3rxt//xXoJ1aNMO7Kmo2dYRq4VqArPsuolC7u4t3ovebhcCYNkva824KdbG6OivpfjVhSuU8Fm5AdzrLUgyrk7dZdY2gNGQTTT6DZDmJXib/8niZQqSitg5rjsTEwBPHGMFJwcNCLkZ/Dj+p/GPlFQGwLEcFM2aIBp3pc+NGGm8SkOEsKyuSxOWvCxWyv17ui9h4hIohdVxavw02gYoRHjpA3XDoEd43gXKUpJgd1RAOOYDXspC0GCSHQKACUD6oZST0lrBFcSSEJBJoJ4MZTIaSvvGlQptuF83gvdUm+FxKuCPMBC70T5U0V0cqUsnrwfPZc4jjkBfBuaV6UPNWgD6N97TxvJKa+P4TVHSGCwYF36i3hrfzGc9zsvSlCHjBX0toRjkE1sJhrRgTdzwaDSfPesfBvofM2navCIU0gcD8rGRmATvO/dKu2acmFE+a9k7FKmSmummXnw31MPwTCeku9HANp1TYrwlPFxk+RUm3fPRNwhazwJXg1Zd9CjmdqnS+OMkLy37TpVE7lWbVjRzdvkJZgVxSCfpdslW4556QgsRn2c27VtlfftBcd5H9POeDMjNmMftwuZe/cGoxa+zZOvEK4fdoko0OShZeA3GvNIJWeQA99WvBkv4lpnPkrS5I+dqG0EyGcl/gMDNlLIrFF6Hd1Uq9ZlUgv14GecbpVxW2NU7U6LHIcI1ykN5fO2DC2gTY6f7Ddgovnn584bnZ5XPfxIzOdEYtI/rC3RJTflg== 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)(346002)(396003)(39860400002)(136003)(230922051799003)(186009)(82310400011)(64100799003)(451199024)(1800799012)(36840700001)(46966006)(40470700004)(86362001)(356005)(82740400003)(36860700001)(103116003)(36756003)(81166007)(40460700003)(478600001)(6666004)(316002)(8936002)(5660300002)(4326008)(8676002)(70206006)(70586007)(41300700001)(54906003)(6916009)(2906002)(40480700001)(47076005)(26005)(83380400001)(336012)(2616005)(426003)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:33:35.8883 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c294ac2e-1980-4361-f9d7-08dbf61ce4b2 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: SN1PEPF0002BA52.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6169 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 cb39c99fa8..7876874f97 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -519,6 +519,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 05:33:44 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: 1872444 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=d9kw8DJJ; 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 4SlR0k4Jswz23mf for ; Wed, 6 Dec 2023 16:34:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0EEA6876D2; Wed, 6 Dec 2023 06:34: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="d9kw8DJJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8930B876DD; Wed, 6 Dec 2023 06:34:10 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::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 5E03F876D0 for ; Wed, 6 Dec 2023 06:34:08 +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=SgTmWQSvyB5kRfSp7+fHOmkBK4DLZijda6O1sIlcH16uSlgzQQeRZzmb1jz8H80l+1jYxaDlV6o4k/Zdv+lhsdZBru1qM7ftajEVwvsCKZ7YAPnF7jMahnde+uTvYPv8p8IqFf7uDIhD8rcxZXRaAbu16hmWmcgF1FEn3KZjBBjkbRzgzIZWn1HN1yZ9spORMTOqIzaUl3nYBIinZY8I6DQfUjehSO3HDfSvgmMDM9EXf3WDGcqqCWiiKK1e7MsabLKz6v2+tmV9rfnTntA/AWJkkf76aQDNSOC41Ga7lltmWqBhYzcUuyf8PbVGLhbsuF/7v1p0dCPpUul0dfskgw== 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=nWUsm5rjSVzixeV6v+FUklEmN/5BwEKAAzFDriyU1+tO4bwDlnpD6C6r89KTz2Ihu1VQbbZNxVDCxpnf7hqerITsyxrew2GiUwQW2ukCFRWt8RgJnPiKxq+SnXfUcoD3gv7HH2//R0RY1AiWBdO2naLjWHeE34C7ykipLRx1j0WfOkblNAQj0vQHNxbuIvd72frb8MlByREryTzyHhgYwPqpLHjvcIEkNLmP7lyaDXMikjRFVcK9QebI2INb08sedD7lm22Vkac92kClca+HcGQL8MRBJfDd+n7l/GYXx+h4ZD9qBOAu0CB4u9omYhnp9gidgrCQobq1z23EqO5Yhg== 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=d9kw8DJJ5io9YUureQe5j+Y6IMzbbPeMpWImdP0Hfloauisot/WjF+zDuO/KxGDGVv2AG8Ctm0m2cA5ykLPWzA+i5j5nY/bQ1M1NIOXvFt2l2UD7uMt+FPLNUZAiiQBUFWK+apMk1nTPTva8Tx7E2WC8y2PoRtOA1YA8kW5cbNE= Received: from BLAPR03CA0072.namprd03.prod.outlook.com (2603:10b6:208:329::17) by SJ2PR12MB9113.namprd12.prod.outlook.com (2603:10b6:a03:560::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 05:34:03 +0000 Received: from MN1PEPF0000ECD4.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::4) by BLAPR03CA0072.outlook.office365.com (2603:10b6:208:329::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 05:34:03 +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 MN1PEPF0000ECD4.mail.protection.outlook.com (10.167.242.132) 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 05:34:03 +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; Tue, 5 Dec 2023 23:34:03 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 21:34:02 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:00 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH 10/30] mtd: spi-nor: program quad enable bit for winbond flashes Date: Wed, 6 Dec 2023 11:03:44 +0530 Message-ID: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD4:EE_|SJ2PR12MB9113:EE_ X-MS-Office365-Filtering-Correlation-Id: 59256add-5fde-4aa9-92e3-08dbf61cf50f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O7+z5rqpvoRgKOlQ96hohxTx4rC8jb7yihLgy4O/v4rgiwBEs1DqohmSDvb4AI6Qt29fJ/5TVKplxb8Ea+ttkjxb8pD9Nwu+8+/ZBMuWG1kZ1UXSdBn+z+bUxZ5bO/R7Ii0B5IrjX7xAPDB+/H0dMS1Lho7NBCK70TbLocwujeWgB9kGsudmvX3PKbrPFUkIYx4ZyDe3PwtSNSYTBWtpltgdN+DwcQuJxK3I8/Xi2yKFBEz5Fzce5H/r+pEGwLXC3xmQAfhjQlcviZZrD8z2WQsIk9H1XIhfoeHcgE4r6lNzZnrfJrhmuQBM8sF/h5gb1/3yZlFVabTl9rd7KWVM4n3Qg7F9gh9JJmJ6ir98J51UPmughv4AipZY7chktO/g636uuJtky//CF5gMbiO1l15wwexPTCRHv0TY5RADXdJAU9Xhjd5L5Hdel6p3U2SHIugMh39bRVQLDJtmsaM8Uidy1J1ixTJpZczNwUokEps28kKocRWioYu1x3W63d2JJoDHhjzLhUho+MLUixUoV7IJM/RQst5EtSNZJG2toFlFjc04Sy4RKsMCXHU8sSvDSI9qVEfDhS8ry0xbHR3iqwZENSPnpge9/+v1IevqxOpEMKKpmQtFw4r8fODCZgFJTmM55AF66n4G0LZFEGlUGcSzfdrWe+4kVY5n32X/gMU+RfX9iI7q3TGwmzzJVVIDn4jPdrj6/woLP8irkheXM/5csOWIZX5b2ZAIxeci/MfgGQ8IFTQxdd+D9yZErN7JmvanjqkfqLTdgaWaKuUdKw== 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)(39860400002)(346002)(396003)(230922051799003)(451199024)(82310400011)(186009)(1800799012)(64100799003)(40470700004)(46966006)(36840700001)(1076003)(478600001)(26005)(5660300002)(36860700001)(6666004)(54906003)(316002)(336012)(70586007)(40480700001)(2616005)(6916009)(70206006)(8936002)(41300700001)(426003)(2906002)(36756003)(86362001)(103116003)(356005)(47076005)(40460700003)(4326008)(8676002)(81166007)(82740400003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:03.3387 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 59256add-5fde-4aa9-92e3-08dbf61cf50f 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: MN1PEPF0000ECD4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB9113 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 05:33:45 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: 1872445 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=n/eSOECV; 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 4SlR0v1G4bz23mf for ; Wed, 6 Dec 2023 16:34:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 83468876D0; Wed, 6 Dec 2023 06:34:16 +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="n/eSOECV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6E0CE876D0; Wed, 6 Dec 2023 06:34:15 +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-mw2nam10on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::608]) (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 33E46876E2 for ; Wed, 6 Dec 2023 06:34:13 +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=gs8zeen3anim96Oce2ggNXHZ+ON7NzePgrel+60Us6qaR8Qai4NN4CbpeD36dxQxvon4Z95BCxXdl7g8UYWm2HS1O2EKlXRZdyZmUuCw9YOvPJiNZ0Hg2kMSjhIOXv2VafqqlctvL6jrmWsZ4dqfdPB+oZJfnuS+3e9ofVEt0ZMUpHIu35KjJPK0SwqTpPTTjy+e5IVxVb9YOV0aWfqYIurVY12HRY3Dx4llNAg0C2XfP4P2OejMpi61uK+NnNRuHTs/O2HTAOtbrdF3PxUOn7vTfd0A5TwAdVzvOYuhV6kxliDhh7qPhlSmuk41/4OswbFTrksA6NqHmS2KRixElg== 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=PsuI4RQpB5kraA4tzYory/VyWVzr7vVNHvhcOvj/lMnXXd4r16kepPon7UHSERleSAOCiZBVlGuqMZPGH001MPIXTS5qH2ZEq+CyYwR9mSlIhcaiQTNJWDVsSY+1BgdWurpkPa7GHWMKkFB2GEFvPCZUDw9FE0d1K9gOT7ZcSTJ1usBcdLkeiX+NHe7wjb3kil3kEg+6kNKOzahViS0gp5+/xMtUfSriNJkY9wCWzhuI4movGxW4/pwJeCfg65MFaWkXTZFmbOgoNIguJ1g+MD5YeNRuneJB49wVMJtr2PbXE+KSse69Yx7bFbovGflT0Y0XoXQgm66eBTsk2OY/NQ== 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=n/eSOECVR81R0+95pQr2DHQZh4K5JslCY0br9h95KnLsj+G+QCFgaQB/15o1yhXBoKKipOs8p9m8B6a5dviLewi4sxnczmdkXIcVQr/fx0vz011DFxsu5QgKFnf9TTMekfbbmg1mcXFYZGkmQND82Flge1IrWEZ0dDSLyM2FB98= Received: from SA1P222CA0125.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:3c5::19) by SA3PR12MB8047.namprd12.prod.outlook.com (2603:10b6:806:31b::8) 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 05:34:09 +0000 Received: from SN1PEPF0002BA4E.namprd03.prod.outlook.com (2603:10b6:806:3c5:cafe::18) by SA1P222CA0125.outlook.office365.com (2603:10b6:806:3c5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.26 via Frontend Transport; Wed, 6 Dec 2023 05:34:09 +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 SN1PEPF0002BA4E.mail.protection.outlook.com (10.167.242.71) 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 05:34:09 +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; Tue, 5 Dec 2023 23:34:08 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:05 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:03 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" , Amit Kumar Mahapatra Subject: [PATCH 11/30] mtd: spi-nor: Send write disable cmd after every write enable Date: Wed, 6 Dec 2023 11:03:45 +0530 Message-ID: <20231206053353.3745918-2-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4E:EE_|SA3PR12MB8047:EE_ X-MS-Office365-Filtering-Correlation-Id: 18a802a9-5f8d-4979-42d5-08dbf61cf885 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: omdjtyztQEtYUAy8DW900pB1bfn+Hd2u8HjbA/m7IZHlf/7eNZ1Q2jFABEF9bYTe2VXuDkWqMdbBuZgriwkos7f1Ry1VzzjI54JF/oVG0Z69KZo7rmZz/BmlAVgd5sOdgDpZR43Kqx2RIe6NDdjzccNAMbB9gNbfhexlgRA799jYzobXLaclLhKMN0aZCbKldJWyeEwPUbD/9GvaBuValDBLJOw2o9W9k5R0mC5KPykYOLoCB4RvvenwymyONx4ZscuPgJJaDeaGyS8AFtE+ekmZHqfnDKbdeZz+T1B4nx/NUjsCYIotsN225U9J79vwaRTP87pFD8cXHMTquh78hl2uksGQkkoQpkuDTEAGIU4K1mLF1zUyzroPO4IgeYAqp+BIM5xdMD2+nx0OnuFeKePyOKmCdExCTpeuHfPvhqtKQTpTOCyCYHRQzYBMS2a8gTWx6NOr9mqQJ4ygTZPWhtYTVRzcnGBoquugfUgULqc1xnOHbm405KVkx4gpnoKWAm/tyxQwWik1VKDz+/MmbtgnNMGXghAeD8x7LGvBED2b+bVbrVIDHxBmscuPy39JuEGOc21KlDpI+fcqHqDDnNeCU8SPFus1Io8/qoEL/VUXY39xSMpeK2OW/5/ETNLgsgQcEKKMt3o3ROmIZgJfrBCNqOlWBIkEf6PyR5+KSv5yMrjOYf3ltiVLMa316tO7+zhU+F4itJasVHVrsCpA4bzXgpk+dbOBWH1ho49FVGG8SQxbM9KNHi//q4HtbPFTgBrOKOrO8ycU5fla9tPeHw== 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)(376002)(396003)(346002)(230922051799003)(82310400011)(451199024)(1800799012)(186009)(64100799003)(36840700001)(40470700004)(46966006)(36756003)(5660300002)(2906002)(41300700001)(103116003)(40460700003)(86362001)(47076005)(356005)(81166007)(2616005)(36860700001)(1076003)(6666004)(83380400001)(426003)(336012)(40480700001)(478600001)(82740400003)(26005)(4326008)(8936002)(316002)(8676002)(6916009)(54906003)(70206006)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:09.1588 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 18a802a9-5f8d-4979-42d5-08dbf61cf885 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: SN1PEPF0002BA4E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA3PR12MB8047 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 05:33:46 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: 1872447 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=uVsjUdtE; 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 4SlR1V4HPtz23mf for ; Wed, 6 Dec 2023 16:34:54 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7766F876E8; Wed, 6 Dec 2023 06:34: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="uVsjUdtE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BAD04876E8; Wed, 6 Dec 2023 06:34:28 +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-sn1nam02on20610.outbound.protection.outlook.com [IPv6:2a01:111:f400:7ea9::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 3B1AC876E9 for ; Wed, 6 Dec 2023 06:34: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=agtCm49yyjjalzDaUc1eyVVgxaDjfcbSkhpjFTENsmCCq0OuRBM4kLqL0BUiBoFaIbf8GPEQ4O0yRxN59a1PAGfc6N2ulJTTGwR2b4WTEKqNei5Qqo0y3GowfsaGeE9SqvWlM7i1hlF7j2B92OKTsCaOdrftRE8PUGAZB6tDkaRookB6SMVk2ojUF7VYq6h0QVcSMYkeTY7nlfONGLZukBxx+sWVlzIZsQpWfhHek7zxqD8p0v8r2xajLTm5qJM59sPFQhQI+NFVCHQrJvVnibdKpRSsSXZzPttU40/5s9TVxwAM56qWmnydIR/vuv1VFQt4mPigJbbwPc1qJyFPog== 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=hrWlqVlYj+EeUayFCyxjcFP7uyzDLOA2k3zp72Y2QKP+DwgEsU+Ysary8I358MzpjISH9e6LsgdHhV6rguiew2rPViXJI5DSdmwXX3oHVe8+b54fxV9FIMfwiHv1hJ1HmaplRxS2Th8C/4HyYlT5BPwI3R1Xyz1emmHi3cy1xpeGg8oAVjkN5iVj6CgS12wSpG1BODuofRRB/1JNEoGgSwGJzhJDox5CbbZMmQE0M4xcLAlF8Ruh1P+hXW09b0hJwpGulWll6QjabDqHiBQjn19mQDPWpj3Fka+JH3SnSgPnHqPO9EvbmjYTNijDg4RglBv4gES4+mqX2rsTD3TM6w== 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=uVsjUdtEa3swYaiD8Qb1qx17ztA7/qiARPLm4DvFcnYtsD/ivClUB22z6JDSG2ra4jKGsuBFzCuf1YF0BQtes8+UKgjH6+gcF8r85Wugsh3cXYynuM0BjBfjAd8VF4ErRmBPk9qKHZzw54OZ9h1jLJvkTal120fSmcyjaJRGz40= Received: from BLAPR03CA0070.namprd03.prod.outlook.com (2603:10b6:208:329::15) by MN2PR12MB4536.namprd12.prod.outlook.com (2603:10b6:208:263::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 05:34:12 +0000 Received: from MN1PEPF0000ECD4.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::d0) by BLAPR03CA0070.outlook.office365.com (2603:10b6:208:329::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 05:34: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 MN1PEPF0000ECD4.mail.protection.outlook.com (10.167.242.132) 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 05:34:12 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:10 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:08 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH 12/30] mtd: spi-nor: Update erase operation function Date: Wed, 6 Dec 2023 11:03:46 +0530 Message-ID: <20231206053353.3745918-3-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD4:EE_|MN2PR12MB4536:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d1e46d3-5872-433e-27f4-08dbf61cfa9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z4DKt2RsK4lPfngJFu1ntak6MXsjHKslrWjRHIqnubJRxZSzCCAlNpBmE+SVH8/ddNoSG0CWEUvTjxTm3nSZ1Ozlkv3wEOlzaP/9Ni4ev+zl/+Evm1QmiPvFTLzcPOfjfdbPFUi6waa/6uxHjbEezZ5wCwHH5y3m6Adl6VSjyducXZ8UKhWAynU0PMSLcllzGRJrm83bzqnD0mlZ6IB44Uqjv3xbOayEvwqYhT/Z5v1YfGGmwBYpf9E8gNTzDf+bAkxDEqL4y5Vu/cypfdimCP5C4vQWmH0RaWo/TTCottFNcxqo4rGzlSFPaaau3iTdFsKl8PEpMn1wQ4CV9gLo8+36e8XmaRqICZfh9AEhqr3X3myarB7E6TniHcujh7isi0MAKk9a29KLsj4qByeiw7707LHga1PHYzDBtRn/kVp5KHBUr/5qkyeez3XrFod/v2LOIs8wg7n5x1ndUp9V3zC/W0URtnAHkKjNLcjhyoY0V5Cn0L82FGQlvdcwHDmCbytQ8ySbvVf/Dxu06VxWdlCymjSCGJrR4O/QrvIdOi2/mn7p1qMhDIjTC0FtPMxQ/TPZu6vpvtwrqkwgswu1WF2YwYy8WWHAhC1W/uZBidm6hZBDvcxOz3SBna9terPVzT0k7PXs2FP18kJBrxZquKnRagtWikycBprnDNWhTXxZ5zZ7PGDO3x/1rvWjs6/Gdsa+Po0s0jgsS04Vf31Gd3CotQ79WqkI/iAu/+ImbbwJt6rLoZ/2W6CdeybsBVZhBMvlRWGje7ubSB4nfcCW6Q== 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)(396003)(376002)(39860400002)(136003)(230922051799003)(64100799003)(186009)(1800799012)(451199024)(82310400011)(46966006)(36840700001)(40470700004)(40460700003)(66899024)(107886003)(1076003)(2616005)(26005)(83380400001)(82740400003)(336012)(426003)(6916009)(316002)(54906003)(4326008)(8936002)(8676002)(478600001)(6666004)(70586007)(40480700001)(70206006)(36860700001)(356005)(81166007)(47076005)(36756003)(41300700001)(2906002)(15650500001)(86362001)(103116003)(5660300002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:12.6512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d1e46d3-5872-433e-27f4-08dbf61cfa9a 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: MN1PEPF0000ECD4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4536 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 05:33:47 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: 1872448 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=L3BoCZ2g; 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 4SlR1w4zv8z1ySd for ; Wed, 6 Dec 2023 16:35:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EBF1E876EA; Wed, 6 Dec 2023 06:34:43 +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="L3BoCZ2g"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 51D1B876F9; Wed, 6 Dec 2023 06:34:30 +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-dm6nam04on20629.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::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 52CB0876EA for ; Wed, 6 Dec 2023 06:34:19 +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=MfSgIiQlAL+pQUi08g273tMlklYwpAbatoqxR3flzfDKZwg15CRXgbM8dBFfIadKxfeIyGUItLGN6vaTSkl7Hk376KpY0CNcgpepk6R7z0uJJ72fSINgXBT2Vm0ebC/k8S5KSsRiWFUhn86OFsgI7F6hiJPYf7WZ4K3iaZByfOJkFat0DtHC0Zv9Nlq5x+7X0+DvYdLUYggzwHv6MHTy5p8ziRAzbbesAqk+AWnwY9kLX/dDD7AlrWWQeOkzQUJlYOIKmteVgvA0Q8jO/X4pKt49QP7kEW895fJRcld21fG418KsP2c6BOnPI2bEwrAvt8hQ1uml9/6kT70OlBNTpw== 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=R6z3B+OOkO1yK27TUpCtH8YIv0FbVEscche8Twe3DD4pJTmByM32E7d/MK1w1ajhkDziYNVp850UcTGuaa0xx8hZyVOYF/S/lLMcUdFQm2aThgNJQ8OHeqf94zba+KDo2XUl9IR1qinS80F4mrdThtoRr/EpCTIpTupjSq8aPT0cZaltdOfNXqn62vClFOjopxtaXbkvS8xKuj7F0LA6koN2Kj6B5QEPDma4QwONUto9OW/Wbkv04gYJ0qXbSQkbqcEUN7RMMfTjdDjHJ1uvNPXe4spiWCQeo2g/dXekrQnoDMJbpCgfnSrPDIqY3w38iiV1c3c8dhjpwRLPen1wiA== 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=L3BoCZ2g7V9QPaG6bUjMY1u8EM5L7+a0BhV1BNo4GH0nOrWpr2o70WSE/+ltHppbdI9AIYp1ZrgG+0lGT++GHXr+R27N8MO3KzUJaHzdFloeFRzQEBbeHjB+OcdbEOFv9XC1A87lMTCVUM0tiAZ4cq+gzVlp8RSH+Rz7lvIZtbQ= Received: from BLAPR03CA0066.namprd03.prod.outlook.com (2603:10b6:208:329::11) by CO6PR12MB5412.namprd12.prod.outlook.com (2603:10b6:5:35e::15) 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 05:34:16 +0000 Received: from MN1PEPF0000ECD4.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::b1) by BLAPR03CA0066.outlook.office365.com (2603:10b6:208:329::11) 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 05:34: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 MN1PEPF0000ECD4.mail.protection.outlook.com (10.167.242.132) 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 05:34:15 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:13 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:11 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 13/30] mtd: spi-nor: Check SNOR_F_IO_MODE_EN_VOLATILE only if SFDP is enabled Date: Wed, 6 Dec 2023 11:03:47 +0530 Message-ID: <20231206053353.3745918-4-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD4:EE_|CO6PR12MB5412:EE_ X-MS-Office365-Filtering-Correlation-Id: f37acbf1-93b0-4b38-d825-08dbf61cfc50 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4w23+8eBEudPA59wRFWM7cPPJoGoCKwi432DFnJVErXZEO7gfS2OFD9+14S4zqe01wVvg0hhPOflaQPzlsVx2JSFx0CpCAzMVTUZz4P24V3Z9nuREq3RII8o2v9o7xVMhT9cvfgnTBj0zAlDi1P42aenqWoSuo8JGpc/SRprvZv/Gu1dxu7rFuVt2yCl54DtDyeBIlXGMJUpLRkQiIhoVyD39shUPql49sJwZG18LaHF5+bnLcC4Opy9t93PIDHM5AS8s08kgDIeNlyPRElY7QVlLz3gHKYphBJBufMtZydVF+f08rd99hyJk4ZU7S1p9RRR/YpUbQTAK1PdNV/t00dGmZL34s51g+HgJpP5YXHzK/jno5gjy73qxAKQh54cQ31zsbTQLXLypjXTkfQt87Pu42icY/yePE9EyurvOsLn42Ifd7H5loRHdILWSxqPKTUL9PLURadNPpXV2JfHSpCTW2iqZyVF6/AboN/A3ESfCeiatXdBapAdaHCVK9OgVp8LsDmvCMtMysuZ+x/3ImvU5zFE5eWuSLwNm8iJGNO6SzNzB9OJkfEJ3r4z/p1Ujs7PTipkYqmpCAxS9pMGyW6cp+4jw0dZM5enOS23fZEClmjNJaQHq0CZJOArsek97cbpSFrtSIdFVP2UAdzPvLK25DrFx3gxx50hdXkqDrzU3S6P0qLPe5pADhl/Xi5SQpBLYqf27ye/2QcGiB0aVOV/t9GqZ7adZqKaVsJnL12VcpNO9Zilmw4SoFupzyAhz/Gbvhws3JAbHGPxTBSMbw== 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)(136003)(376002)(396003)(230922051799003)(451199024)(186009)(82310400011)(1800799012)(64100799003)(36840700001)(40470700004)(46966006)(41300700001)(36756003)(86362001)(40460700003)(5660300002)(2906002)(103116003)(2616005)(26005)(1076003)(40480700001)(82740400003)(83380400001)(426003)(6666004)(336012)(478600001)(47076005)(81166007)(356005)(36860700001)(4326008)(8936002)(8676002)(54906003)(70206006)(316002)(70586007)(6916009)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:15.5262 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f37acbf1-93b0-4b38-d825-08dbf61cfc50 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: MN1PEPF0000ECD4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5412 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 05:33:48 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: 1872446 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=WCM284FE; 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 4SlR1472hvz23mf for ; Wed, 6 Dec 2023 16:34:32 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2B0F2876EF; Wed, 6 Dec 2023 06:34:29 +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="WCM284FE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6D926876F4; Wed, 6 Dec 2023 06:34:27 +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-mw2nam10on20603.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::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 742CE87683 for ; Wed, 6 Dec 2023 06:34: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=LwUV9PG+/7jMIv/MI3f4/0TpaQStkMmRm3i1YMTEC9b/k7R3BUvHg3nCcTEoqtc0a1Q8JZLlL4haUzD5hhco+Sk51mwsHSsZExgsNW+FM5Xf3mPUP/ZTsFJWBrsuItpcOOAIiPRJKV6T88ReuW3dCyGyskFlXDXN2eyqmmcN+jL7oKw863AIvvX96bY0SGY4m7xgX+ax4n2dWKcY9IwHYWlwCyVH/Aj6AqDV42pMfOlCUDhl02+DRHVavQb1rq2VM2VFG8XzqpH4QWHg0H5ScObhfUxjWh72j0yW0RWttToDecNs4msZgTvgQATr6fyB8Kkwg0WeS53Nfqt963Yvtg== 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=S0DVdMAaf8BpVpIzO132+ZgJwv04SH3PejOPRDfUpNa7e1XNv86BZwmKz0aZckHXDVk3FKloXFU5VJFrnLc6YsQsWN6SagOhzom/WPWxT+ItvQ62o29KJytxJXYvaqol+8SqJnT2u47DiasYb3UTdL776djRBz9OmjjJP3mmyZBhdu8tal7yiiqsjH0JGbqIK5bDtLpuPVS7vZ2eNU8MpF/FMefufLLvB/Od+2nKmVfFy8NFkp4j8EK1MbABsylblx22L7psaGEVc+LVmy2XJJMy7Lv5aOZ5HtJvFqeF2B7rVTvFyGGMXBQTf3Us9YfnJvBkra6cu+nE7ug5MalbyQ== 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=WCM284FErdARPgWzAdZu+GWT5vYl+ZsdTA07lpMNabWkgnJ5yNfFGYVUsRR0pd5xMqXR9zZxKDnbtT52Da0tO1AYvtqYkblJ2tsV6G/8uTU5dt9YwexWH300B7MxnMgliGgWbGjVg2VStZPLaeRntCPR5gMYe95TvpDX0HIXFbc= Received: from BL1PR13CA0194.namprd13.prod.outlook.com (2603:10b6:208:2be::19) by BN9PR12MB5340.namprd12.prod.outlook.com (2603:10b6:408:105::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 05:34:18 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:2be:cafe::a) by BL1PR13CA0194.outlook.office365.com (2603:10b6:208:2be::19) 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 05:34: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) 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 05:34:18 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:16 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:13 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Ashok Reddy Soma Subject: [PATCH 14/30] spi: cadence_qspi: Setup ddr mode in cadence qspi driver Date: Wed, 6 Dec 2023 11:03:48 +0530 Message-ID: <20231206053353.3745918-5-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|BN9PR12MB5340:EE_ X-MS-Office365-Filtering-Correlation-Id: 5be69700-7e97-450d-d484-08dbf61cfe10 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q1HOg71NZmzTiUK/mltqrcyiYz/H1Fi2Gndhrv888CZOP2hgHuM3+s0itLi8OBUtTdxXRRvENMt1dg8UaO8PcDwvUo/qg469HRXcVGg6xiqAFpstBMOqs/ztSRizK/Bfop11ZEUXvKXLE1S5iVMCUQ8ClgHvYTPX1iSwUWM4CFwqaNwOr5gCWqMUrzNbyqRr54oz4r81wyQfin3l00t0/AXz4ZyLHd4UGDiuxjoP5K3V62uCleBH2VL3f2KC4xVLESN/ITCUtHKhUSNMOPMuOCV2OIRz2PWpDR1knkPgQtXIH7u2vuLBx/THdvA1VhZtc8xc6K5VZW6vI0OtyJNan+AmiWR6/xw/MKOC5e9tfLt99G/f/7Xw3NMhyJ3097EzbMLUJVS4i/B33UfAUeliYlHYG3a7hoWZN2EmWJPrOvwFBTd7+pNZ3PHehTe9U4PGirwgV8f4/pauZVeOWredeNyaX8MDP+llpdwNSQ3jbKPtgnFFcAbpcjtw/xkfWylbi8DUleZQ754Op+CtyYaNzJo9/7ryeyiF/o5ok/KvItIfiBpJnYM+wikgBk026Ajf2olyGMO+UCAjWiBVHU/PluQwdgrUx5IneZkCZ996KUnqjXqVjEUGzQMZRjqrI1irStIqxTnfpJnaTWFmUwIf/pASRJqrdsbjS3pUeRusHa+zmHK9ZmlpC2oYPVgzTH+moD0C9eG4Hfr2bN5xQ7Vbu4PwW7Wtj47V+d2jLrolB3oZztC0cNvyJeeVK8SNykgx/RB350PvcUvBoNaX+9YBPA== 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)(39860400002)(346002)(396003)(230922051799003)(186009)(64100799003)(82310400011)(1800799012)(451199024)(40470700004)(46966006)(36840700001)(40460700003)(30864003)(2906002)(5660300002)(36860700001)(41300700001)(86362001)(103116003)(36756003)(356005)(82740400003)(1076003)(2616005)(26005)(6666004)(4326008)(336012)(478600001)(8676002)(8936002)(47076005)(70586007)(70206006)(426003)(54906003)(316002)(6916009)(83380400001)(81166007)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:18.4621 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5be69700-7e97-450d-d484-08dbf61cfe10 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5340 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 05:33:49 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: 1872449 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=1yPkZDEK; 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 4SlR1x5WTlz23nQ for ; Wed, 6 Dec 2023 16:35:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 56BC0876F8; Wed, 6 Dec 2023 06:34: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="1yPkZDEK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 870D6876EA; Wed, 6 Dec 2023 06:34:30 +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-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on20604.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8d::604]) (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 EC210876F2 for ; Wed, 6 Dec 2023 06:34: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=dQHWBCpywVbveBWxDjca4YD5sB5D955e5flL7O9ycp46zFsRn3A6m3SYK+joL9bpberc9i7y5c3Hs7VYwAJABZz85QYSHXo7yZ3T76xizwG9q42qhfh9bnf7TvYkoFIxFPJM4S5rK4emcrRb9VW8Wpwv5vZ6c/PXoiIaAGcohgI9CVh8RtZ6Rm03JSyieXeB+eRc2rhBmUrnaE9UMgg5X10hSXfmSoboQrfGriPxtL0Lk4rBQdWNwwzkfBboTCoQQqREiqZHzX8li3n4tbyRjnT7s/EN8NihLWwWzh+GloDr0gijyyRXJFNP9X9ag9yubo4M2gHYaFOsBtA/44R0Hg== 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=cE0UkZZPEguJL7YOSGknu6XHZSJNV2yuCSoA1mLot9frkVMwHNeq0zC0EQhXsh3MnWhVdExKq4Pj8howujVkEk7CKSaQNdnXZFebkxOI/tbkniwZt6tSSZKuOxCevVqvWnV1y7qjt8J1DDW3tkv0rRjYq4NxL60kpSqOJqWuR8q04H6LasesheuG+1k7Pl7nSaUXKREtKgXWvzZ4/9Px2nPh/7jIl5E/O/JqJ2jeq+zQ5FZknMZL34WZTKJ4Eu/VAHog+QgSmT5CMxi20dL6VZE3lpOQPzfR8Rfz7CNkMKL2jhL/t72BbniCIwy+NM7oUd0JrDiAeA+AZ2p8yKzaag== 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=1yPkZDEK3rYsrsCKStpFOjJGYLQl1Nsa4/Xf7BjuM7zIRIzQ0dvvA9fm/HTa8pKNLmECiIp106LmBMglVGIxSQiPZP/oJvI7ARDt37ob4qATAhmICmZ9YwMvSLn3BYdUEVgHgWRzz7dAriTjoFQ6RmSPc74JADS0wKPSZsyeh04= Received: from PA7P264CA0539.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3db::19) by CY8PR12MB7123.namprd12.prod.outlook.com (2603:10b6:930:60::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 05:34:21 +0000 Received: from SN1PEPF0002BA4B.namprd03.prod.outlook.com (2603:10a6:102:3db:cafe::18) by PA7P264CA0539.outlook.office365.com (2603:10a6:102:3db::19) 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 05:34:20 +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 SN1PEPF0002BA4B.mail.protection.outlook.com (10.167.242.68) 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 05:34:19 +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; Tue, 5 Dec 2023 23:34:19 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 21:34:18 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:16 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH 15/30] spi: cadence-qspi: Switch SDR/DTR using SPI_FLASH_DTR_ENABLE config Date: Wed, 6 Dec 2023 11:03:49 +0530 Message-ID: <20231206053353.3745918-6-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4B:EE_|CY8PR12MB7123:EE_ X-MS-Office365-Filtering-Correlation-Id: 87623154-fed5-43a3-59d7-08dbf61cfee4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CAcUzJXkTVb3JCq8HeEQS5n5BgStsWO2JiqudGlUDbmKmEWmjP9kb+5dHF4UU4/aEqRWH7AjuhWpLOwIP5Ipc6R2zmXGmX0OLWeKHywQ2BAr3oY2h+TXyePweMLZ977c5v3LvXxZCtYb/7NdVOqcejH4jiYhKkr+W8dphBsheZ0ElOy8Ie2kaVcWs+Hrz7No5H4xK8dCdseesgq9e/DQhgiCAmo82v1CaptfWiol/NnIuANSRzgLw0WtTi8dLRF5UtamJyssPYqSporTUA0PpCWAQDhb3+Q1wjTJvgfMepcEYXSu8Yv/QO+jGMtQ9/D2yquEschhGdlDbSG0eEcn2OzcxqsuOPj7iSXX8RrCrwNr1knSbeiBAVTqeGRgD1mfiFwV0sKGJTaUfirWlTEw1I2wmPK/2/4xtHpYNHpyK2MjDSgk5RkDNuQhK7owD8+CgpIwoWUsMd61cbSuKqFcx+cY3wJnlKt1P5u3CixYiWxsLCJ0HugyySBB5L+3LgSdZ4TwXLFbl1DsRk6B0XU2HcU+FvxW1hxed2CqKjnDowhWUsKsyXWpZVPQ3vp+NEGV2BZeXNMypyTMg6OcTpcRwvZLOik8kPFPc6tS46RDJZg4+iZS+Dk+K2JiAQb5URIpxKj5ObameT4/l/nqSC/4RoIVbjZbhzEUQrAAItSmQhFtwnR0A7z510Qdd4+Cp4B81j651DjMzhln4qXSBIIGlRnkk71u7nZJH9gB+UrqSZKPjk3yX+5ivnv4yivnTnHYfOjGhIBQnPjWNGUxrqT+6w== 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)(136003)(376002)(346002)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799012)(40470700004)(36840700001)(46966006)(40460700003)(316002)(81166007)(82740400003)(5660300002)(2906002)(41300700001)(36860700001)(86362001)(103116003)(36756003)(356005)(47076005)(336012)(26005)(6666004)(2616005)(478600001)(1076003)(8676002)(70586007)(4326008)(70206006)(54906003)(83380400001)(8936002)(6916009)(426003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:19.8327 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87623154-fed5-43a3-59d7-08dbf61cfee4 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: SN1PEPF0002BA4B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7123 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 05:33:50 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: 1872451 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=CuYK4EiX; 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 4SlR336PsZz1ySd for ; Wed, 6 Dec 2023 16:36:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 439068773B; Wed, 6 Dec 2023 06:34:48 +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="CuYK4EiX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 61C7C876E9; Wed, 6 Dec 2023 06:34:37 +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 23569876F7 for ; Wed, 6 Dec 2023 06:34:27 +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=U5ADuwAfMzhKY0SJiE4JiOTjoXkiypEYiJQbF6LyA/CQsgCYP6W1ELvs0E8EHvR8Vybu68BLrUtlr1QqnJPIcx4cifHclGi2Xn0/i8t2n+j8VmPZjy92D7HOoKY/vASquwpBuDkpHzzqA7OtiloULOxut/wTgT8g68pMr7jktTN7OAhDCCvKfcc6RZT1vk7Aa+9D9iY+debFNvU56ekof9EXUNtW7uRIDaiCXD7JaFUeoQahzScuWzilQTo7LKrN8uRgPFb1f3QOb540OCj2BN0PJKjpE6HxAJWlCumaLNDHr13fa3U6zNFw/yY/34dQQEqlO4pO7XzllM/DAlP2xg== 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=E/ZQiygCkqpJwkfdApFaS4Wqs27mwHiICY+AEeDt2r61w2pLOuridv0NwTvp+w+5bFesrUSUxKdbyrt88iu6qfJI4EmOyhSPldDYNi5ffrabBQoy38ox7+m/I9JM5Wxgmyjjo/qFFc5zwu6OzjhZDLqjzrFqMJ1F7hREan+kwNfh9hW2rQiDWGni+peMnVvlZFi+Rh3PP0gPcmvtrc72dhdzXckk23NRh4M4SLreCMup3jWikHrb5HELCwdqHRCQYqh3T8vg5XmdaI+4jiuMtOwsXwIlHKghXADRV5p8OxyRJ99Zj2fT8xqECo/YXyO26rlSZwEmr984KsXkrRj22A== 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=CuYK4EiXON1RigK/gLOFkgSpWq8uUx7TW8HOWp1PeSaHjmQmX7pKSBqTaMvDve1S/9mAThhrDJYpPdap0PBwetqzzyAW2gjPDvO+2OtYPbFdsQOy2b676UIH7LkyrhzmftOB9tyFAQzMOJ90fjMOvewVVBoEPTDEp6Z5nPesWf0= Received: from MN2PR05CA0001.namprd05.prod.outlook.com (2603:10b6:208:c0::14) by BL0PR12MB5506.namprd12.prod.outlook.com (2603:10b6:208:1cb::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 05:34:23 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:c0:cafe::60) by MN2PR05CA0001.outlook.office365.com (2603:10b6:208:c0::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 05:34:23 +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 MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) 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 05:34:23 +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; Tue, 5 Dec 2023 23:34:22 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 21:34:21 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:19 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH 16/30] spi: cadence_ospi_versal: ospi ddr changes in cadence ospi versal driver Date: Wed, 6 Dec 2023 11:03:50 +0530 Message-ID: <20231206053353.3745918-7-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDA:EE_|BL0PR12MB5506:EE_ X-MS-Office365-Filtering-Correlation-Id: 4aba7929-596e-49aa-8114-08dbf61d0108 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zfan4qhM92+8h88websW9oGgAxb3DyKLY13TB7+jSsVZn4XC5pI2UWZUVHjcHqjJHlNSy7Q3iPNDPA0/74LueV+wHMyfx+55ldrVxWdRyvMHeDjFmQRo+thCyHdiYp9M3sxso92Xu5Q6oazc6TEzVvdAE8hhS8baKzhoCXxh0YQ4rJab0dLxJIldpMp5KaCdjHF4qKgeM4q79/nzQwqYEcz46F8rKSc83AmIguyEW6RFPiJe8qPDBfYmx+W5S10AJDpy/PBbPVT/0keE9iIYiAUUUVDRjEbqJJOtvPhq76LAUv/m5qyaEHwFSEhWiX+EZ2VGlEyKxV8JsX3Dgd/0rXKo+UPs6hCLzH46o8Auc8scmFo/0LB6z/2+tpft4obPASg9H/fmX91U649ijIuss+nvC/1sxz2CbK5LeqRDjVXpIQu0AGvwZTXrneRHfqx5dSgsO+UpdzcJY4U9pfmNL4sQZFwMbuwDgcycWs9uRvsXVeX3SHRUD1LOeJVImWw1Wj3yBL2Capo0nxQLGvGtfWQr/QhrdBoXwXi4GHjAV7/6/ogN3O5D5ykUrsfoBrDYSPXRey1U/Jmn7XjdsFa0h+d6DQlpxdbSnJiltRtWxiiewWlc/nB0k8ig766G6ty5K1fEjHaynBlaJNhspdWoIB9Sr0igHwTI3F20xyeDTpWRDssqtc+iEx2WAue5DDa8fY62olv1mORtmIZjlAE5vJFFJDIBOyfd+B6bLEAE1K1O/dAWEVni6FRyA4WOU6xSaPHKsPMRhcQmJj5zLfWhEQ== 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)(136003)(376002)(396003)(230922051799003)(451199024)(186009)(82310400011)(1800799012)(64100799003)(36840700001)(40470700004)(46966006)(41300700001)(36756003)(86362001)(40460700003)(5660300002)(2906002)(103116003)(2616005)(26005)(1076003)(40480700001)(82740400003)(83380400001)(426003)(6666004)(336012)(478600001)(47076005)(81166007)(356005)(36860700001)(4326008)(8936002)(8676002)(54906003)(70206006)(316002)(70586007)(6916009)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:23.3782 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4aba7929-596e-49aa-8114-08dbf61d0108 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5506 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 05:33:51 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: 1872450 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=2Bj+D+G1; 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 4SlR2G34CXz1ySd for ; Wed, 6 Dec 2023 16:35:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C70C187717; Wed, 6 Dec 2023 06:34: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="2Bj+D+G1"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72EE4876E9; Wed, 6 Dec 2023 06:34: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 NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::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 ABF0F87683 for ; Wed, 6 Dec 2023 06:34:28 +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=Z7gaoUgosnoxNEFFwxnH8NaPcWAJPWxsHsPt71a8CcyrmEha40I+a+jvurshkZTRSZEN0/XLCo2thiHBSnNtiqqZe9XN6ajHNe7yo0JQ77NqUk1Kyvn4yTFfLYnjOGuSwzaRaEfwB8uyCS3UQx5Ot+pAXq5TIBMZEKuM3hew1aliHFKVmSf92hnPfVXG12U7DQ9yAJ2Y16T7LrdFiP92BhzT6CDWMqzQ2DggC0fe3VSSUZ9ndaBlbYWYbL7d32V0x8PIIJxQ0PUdCD36Uk5F9W8qIlv/yI9KLmA7NMzXd1Q3hC61+z3KmsSRoVGiHPNjciOW9Yw8tJ7krWmKI8txgg== 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=f7731TN1xjG+v7teO1GvjFe0YzKz91ygCjItsF4XKHylojKBU4q9p8BkAYIPrRZZFdbxnwUIk/ezN0jm702DdOM0WvvAsXXYBOg0Gg/1f36OpwRZ/DWVICspb4BT8GMwfWOrYS5mf/IXka1Z4ipKY3Eq74sKyqGvUvkwPzo2y2SzTZQGtzzl8pjLmjZqfT+nON25KkNS8zzM53tE7S8jeyb90PG2+dQi21PfUSymMClxDOqs9odJd4x2jpScw0ddpESF1Lz0lkQt2rggAV3182u/SeSXCgYOeT2nIt+Ynh2c3zF9wjtsml4dbOgNr8r5pdryoz2fHsf8r5MDIDE9tA== 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=2Bj+D+G1/IgfRqn2TnkT3k+/FwcMYok0ZzZfv4o/f3yj+ygnQRjG3K/UAwFoGPwf2gaxzO05rZhEslAoQZQ23PRZsa2iyYag/0lthRoF5ZIxzEBufWF1I0r2FpvGH/Lru4MlfIrlsAbtTh6B/5Qwq67JVMAkqbsTJW7HYeIYgPA= Received: from BL1PR13CA0187.namprd13.prod.outlook.com (2603:10b6:208:2be::12) by DS0PR12MB6485.namprd12.prod.outlook.com (2603:10b6:8:c6::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 05:34:25 +0000 Received: from MN1PEPF0000ECD6.namprd02.prod.outlook.com (2603:10b6:208:2be:cafe::10) by BL1PR13CA0187.outlook.office365.com (2603:10b6:208:2be::12) 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 05:34: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 MN1PEPF0000ECD6.mail.protection.outlook.com (10.167.242.135) 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 05:34:24 +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; Tue, 5 Dec 2023 23:34:24 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:23 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:22 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH 17/30] spi: cadence_qspi: Fix versal ospi indirect write timed out issue Date: Wed, 6 Dec 2023 11:03:51 +0530 Message-ID: <20231206053353.3745918-8-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD6:EE_|DS0PR12MB6485:EE_ X-MS-Office365-Filtering-Correlation-Id: ac6c3bb4-5f91-4edb-a8ea-08dbf61d01d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zY8H7G9BQuGFLHuFUl3IwY6M/LiVy0vzRcF8sBxLXyRUBOYbzGs+h7u8MxMGNstVHnkX/+wtJa0pc8bq2zYDjU+1qwAgw7ujnMV/oH/e7SZu73jPLPjQCa+5LnSabk1KK1to8uxwQlD4N2lwfSoBrI9PTxIhK+0i82HOJZPhzNxKvXylBmTacqimfLJFhIR3pujjr68ceF9/kg5KGl0XdXMJIbx72lIPAJ9AXpEjYVJTBezOrGBuSGgklyu6nggkHQku2jNFi8FwBOB1QEl1hOJ/Z5Pa2WT8T17C9anBWydHAKzkH/ZiredRsj9qLyOMjHX0UoWLIU5nEfmvLJmZNuufkJ0YtihFmjtP4W3x1jpaF0w2oAZPBhWkdDw1txiAv3knTLP7A0N7jUg3ZQpbCLKvSu3CR379SH0Ld0jlq+k6KTK4FRtUgXEkZZ79fGFm/zemrxYVR9YZ8x7MG4LCtFtdfJqjOlGw4U6m8NeWCycj+qk2LItQvXG7wT/IXgzW2p5m7bJ6pKHru7XHLp+ZK2ADuN1W1IqjHEeD+uWjKU6/PkhQhu98FY2CY9/K66vZfoUnPmb9U3vixuaXNmD3A5YJm4W4ljPPVEY0EWhfmyeXFBZeiqCCUUsFjoRffkfGpmpoPC3zf6PatGcv8HeL6NWUu5JCNQKZS8lEpoNPGQOY4eqlREWTtBqJ7OUCFTprUQal/BddxrnIgAedcC/Jh5mJ1BPEroxMe+8ImYpd1ZdeUVbvaEnDbj80nkejqjiyu+UEjVE+DzabJXpwxYgd8g== 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)(346002)(39860400002)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(426003)(83380400001)(478600001)(2616005)(26005)(1076003)(336012)(6666004)(107886003)(316002)(54906003)(6916009)(86362001)(36756003)(41300700001)(8936002)(70206006)(70586007)(8676002)(4326008)(36860700001)(40480700001)(103116003)(2906002)(5660300002)(356005)(82740400003)(81166007)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:24.7590 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ac6c3bb4-5f91-4edb-a8ea-08dbf61d01d1 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: MN1PEPF0000ECD6.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6485 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 05:33:52 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: 1872452 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=ws+pXkNz; 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 4SlR3D5FlSz1ySd for ; Wed, 6 Dec 2023 16:36:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C023087751; Wed, 6 Dec 2023 06:34:48 +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="ws+pXkNz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4421E876F0; Wed, 6 Dec 2023 06:34: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-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20612.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::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 94C38876EA for ; Wed, 6 Dec 2023 06:34: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=fSdhVD6WV8uHRbLAXzeHlCfRyz8f486nBVC8PU9nsJZRJ7FHvqVre/+lNQM0dks6h/5ayqTvUTOz9m1AvkOuBL+kcoLWDOZiHwNPeiFpNIxin2ZCtGlDn+MVnZV0rAYdERKX8qBfL/CQT3Rf5yVnSkI9FWsP+zmhDMKdhzkeFX9oEGwe1OWx7PakS/GsGFBoo/dKxUqgqoKDB/CQ89OdiFFOO4vcWpzTRRYPo4uErg+ZksaSxRNsl2i+uVGKKiwXyBjceCyQtUjiglxpdBuMcX6bGeYS4jhYMAMocE3uanB/aDYmSmMzZ1WNZi+UiWM4Nim9pfsjwXEoXGbeg7I8pg== 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=iPfctGXfynut/xC1Zbi98GANomC/Z4pJVHmmG/dLWrgCHQVtF8fzUcBhM8MYmvxlyxC7QHzKD8a3Gax/flA6MGn09f/8AQGw8BXFPwOhWiUHkIa/yPN5iQdgsk/KUMCozZnSRkBgdbjnRefuyqmEgxJREzrKWhRPHbGNT10Q4c0bBOZ8ZP97e1BR6kfb/LsRIwV4YerfzepCLSpBVn1VUEmyY2wgP/opOiDCVh+TBy3LTPy8OBiNgngZbBoLlz6mnjI+vc8CJ7oRRHaiqQpsYreVikpP45QA5kgZV9GxHCXP2EoCPRJHDEBgFYWQI2DU5zUl1Rk7l9L6t7TttH8ijA== 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=ws+pXkNzw2fjUmBdiTDihPb0BIWLL5ADQ7MiGwfckniVubP+aJiJjNIsTm2omm6q01H1orawVU6DEX8hv8z3suFuQpiGPs+yPR4+l0I0qS38s0QkdhNL/kdwLO2xmLrTKIfHjC9QbtvwfWKGi2jmZ/erXtFnnlSHUmNUFV4Is8g= Received: from PA7P264CA0519.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:3db::14) by CH2PR12MB4908.namprd12.prod.outlook.com (2603:10b6:610:6b::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 05:34:29 +0000 Received: from SN1PEPF0002BA4B.namprd03.prod.outlook.com (2603:10a6:102:3db:cafe::21) by PA7P264CA0519.outlook.office365.com (2603:10a6:102:3db::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 05:34:28 +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 SN1PEPF0002BA4B.mail.protection.outlook.com (10.167.242.68) 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 05:34:27 +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; Tue, 5 Dec 2023 23:34:26 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:26 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:24 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 18/30] spi: cadence_qspi: Set tshsl_ns to at least one sclk_ns Date: Wed, 6 Dec 2023 11:03:52 +0530 Message-ID: <20231206053353.3745918-9-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4B:EE_|CH2PR12MB4908:EE_ X-MS-Office365-Filtering-Correlation-Id: f59cf8e0-83e4-40e1-82c0-08dbf61d039f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Pe0Xqqn6n3fyu3oQj/pKPEXclscZZa3xskl+oQQwPvTwaBV7Qzd6Tz+1ulzwrTdcldNJHB7jKzKx312SB7QuqXzx2YyttmZGBBb77gFl/pQb01zBitJrQmLAdXGpsFO3uhXVTdJNK4pv393uq2cphMdfYaz5VMAVrWscuLqjo04YQXhLt9Md1HsaJdt11p7pBBXENgJwjk7F3okesHaLCHy9Uu1OERdnPzvnUhQSCDxVt2neu093eWXOLDoS4ZG0/GeLsAS1HhnPpm0PPLmWCdyL7zbPJaxZDPxJfQEtij5ApjgfKWmnzAGyt48tmYBzuMM/76xkr5/tYq1cSO1G+zAXVeTG+iFdfKRO42qHrmyOixXmsrlMByKQF/rbuOvxLRk8HrVzvsbIbNnnGeSWDXKf5r2oR3Q6gY7k/Ye5/qaHUgfJUHhNKwrPs5HT3os0oxe9Uq4/lHCfdjNRW6iRbr8lenTqzLtJLdJELHwz9X3OvvSXXV3TaWSBRNW31CwojdixvCHLtUGeZa/EaawxXbaj5XsqIPKd73Ikf0TA3bQILts55twyA9V5DNjwiIKvGPEWu5zPd7SPPcKAFJgy02RJeV6Aq2PvYPA0knOMWmNqayN9XtXjYQFDF1VJyd53QuysP4H+XCHT32+mlG41jQo/96T6Xb0TxRAWpyG1BJAEdTwwOD9fbTkGnTEIVhUefR5YaXncD/zlbRSHE7Q74Raj4jUUxFNmC0KI1jpj107W0xewcuOLn+/Cb1e7/5TOYD9+vF9JPZsu5hS6YlEONQ== 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)(136003)(346002)(39860400002)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(426003)(83380400001)(478600001)(2616005)(26005)(1076003)(336012)(6666004)(316002)(54906003)(6916009)(86362001)(36756003)(41300700001)(8936002)(70206006)(70586007)(8676002)(4326008)(36860700001)(40480700001)(103116003)(2906002)(5660300002)(356005)(82740400003)(81166007)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:27.7702 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f59cf8e0-83e4-40e1-82c0-08dbf61d039f 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: SN1PEPF0002BA4B.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4908 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 05:33:53 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: 1872453 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=AEq7VQ92; 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 4SlR3G1LpWz1ySd for ; Wed, 6 Dec 2023 16:36:26 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F10B887796; Wed, 6 Dec 2023 06:35:29 +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="AEq7VQ92"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4F0EE87683; Wed, 6 Dec 2023 06:34: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 NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on20608.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8a::608]) (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 298F0876F9 for ; Wed, 6 Dec 2023 06:34: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=clBJ3sz7MX0DD0CtKYbormUguvUlt7iMuHThqj+MVf9c8/I1tcj5sc+1FXrwwvXLCX6vu5ijmGP7T4QLAw779R1RSrhQzgc/ZZRyDQVDFVf8VSdVetOX1xoF9XoH6p2qiF0Dthn+hvIk6c1/0tj2jBU9q5PRat3TYdutkz1vmvKWJTJGapIOTFfZtIoEamEaP+64DOLYV3rfkFWbCBmFu0bMzlb/vB1NKmYckgrjgjqUk5k1AnT+PVt94eDbZUM5jPFj9YZ0v73a+jQmHhED+7XGa1w5g4V/RvfpNZriWVeDUJwDrxW6J97aW7xNGMGA1T4E26JLunBs+T3UnbCkfQ== 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=KYflhwcQaG+pgXWbWfHu7MQ+T2mWWpd8In19npHDoEyBNsiuuyTVSXuPkZt+j53uO36YGGCfaaAce07sV8L8f0IherC4ksyxEv8ScZVVSdIXSC5cvU1c2zjWcrlWy/PYxZKlgANDcMS+64GjzLw4TLCl16libuYne1cwMcmSkWhrepLWCrNFXlnqFfXHQUfAFAOyBrwSQkEp0/Pg4ffYlO3o6TRNIE6D2ILE3R3NNL89korGT1z3XcxU1m2PfwFxHc0bf30TCf7dsSW1duPpGhwDB4fy15j/XGyVV3eJ6AtfbPJq8Fr6Oqcl5yYMvaB/dp6FI44/U7orxyTVjTC0kw== 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=AEq7VQ92jDG4PIyRx5skWH7V7nURI8FCwTtjZ1Ou3YZacpuQc07FNlcFZrQijpx8Vzo3ERhQSM0teUxaVbEu47mmugpNRHAbgt8+pSt2vOSiop7dA5/rLjKZ/M//0dQey1adM5gNktuMi/TEmP9VbFuqvRKFakSby1qb9VQryoo= Received: from BLAPR03CA0069.namprd03.prod.outlook.com (2603:10b6:208:329::14) by MW4PR12MB6922.namprd12.prod.outlook.com (2603:10b6:303:207::16) 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 05:34:30 +0000 Received: from MN1PEPF0000ECD4.namprd02.prod.outlook.com (2603:10b6:208:329:cafe::69) by BLAPR03CA0069.outlook.office365.com (2603:10b6:208:329::14) 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 05:34: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=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by MN1PEPF0000ECD4.mail.protection.outlook.com (10.167.242.132) 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 05:34:29 +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; Tue, 5 Dec 2023 23:34:29 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:28 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:26 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 19/30] spi: cadence_qspi: Clean up registers in init Date: Wed, 6 Dec 2023 11:03:53 +0530 Message-ID: <20231206053353.3745918-10-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> References: <20231206053353.3745918-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD4:EE_|MW4PR12MB6922:EE_ X-MS-Office365-Filtering-Correlation-Id: d40abb7e-b6ca-4bf5-e5ec-08dbf61d04df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gg7G3mropqHXL30Sn8ap3RkeS/tTBJHRskk6ZNQ5aufHIpZvc+rwsUObBKanclI3n4dlQhG1O0TZbcaTCPbQv9lE3hPKCy+UFLeZnJf4MPM2uRV7RgPyHEPtEgCLkAKikdZzvPbaBzY4XjpFI3M6h0InxwYmuGoHXqwkTa0YnBGzJnM/UMfPn2SYATxbMiptt0RFLsCmIInpCIc2tWh9bdzWPH9j8xj32OWrok1s3FUZyG+DOh51CAvY/G3C01c7vZvL5sybX2rzv0onxM7A9CK6tFJYLcu46/2nVNtiIx+DxoIGUDNVjDcWkYoMuGmO07Ly6w7tzlbuks8NNMUI4WJSapxlSZsoPtcyRmxtvnwKTMfiE4t1OqVyc35o0mK89/KobQewrXDH2WPhauMi2VwVZPyDqUgUGu9NdHRZa2KgWTeG1suIWJ8Z0EotMtg0qx9XRQbJUzDsfVULRCdlS9MdxksNrYrCESA6XVmdPLxp1F0K8k+xVJkkIjWVOgIPdlasFsNIQHw7G8hhHJdhILQzEycHwAccnxFu2Y0rkbeh7XVD5kUY3+pUvDZmleNz/CF0KfbOV1WJkY5bn9omSrYid4iQPSw2AjW5oGe++HWcS83W+xVkiHh7orI5IzMYAjQEhp9gp4wikUcc6QUxFkBt4Nb64XPtm8H4aH8rpMkzA9I3Ih7wziuMUNNIRZt/r6dXXGvvKY+xPtVq/KnThjY+N+mKgEiFTaR+6z/G6/Vp3Yrk9pwINgSvsHmngC74EarXNpisS7CDhI6sp88sRg== 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)(396003)(136003)(376002)(346002)(230922051799003)(82310400011)(64100799003)(186009)(451199024)(1800799012)(40470700004)(36840700001)(46966006)(40460700003)(316002)(81166007)(82740400003)(5660300002)(2906002)(41300700001)(36860700001)(86362001)(103116003)(36756003)(356005)(47076005)(336012)(26005)(6666004)(2616005)(478600001)(1076003)(8676002)(70586007)(4326008)(70206006)(54906003)(8936002)(6916009)(426003)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:29.8855 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d40abb7e-b6ca-4bf5-e5ec-08dbf61d04df 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: MN1PEPF0000ECD4.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6922 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 05:34: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: 1872454 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=2AOnZkRC; 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 4SlR3g1p2Sz1ySd for ; Wed, 6 Dec 2023 16:36:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9ABD587716; Wed, 6 Dec 2023 06:35: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="2AOnZkRC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 34256877B3; Wed, 6 Dec 2023 06:35: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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20605.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::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 0D71087737 for ; Wed, 6 Dec 2023 06:34:59 +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=lM7NFRDQf80U/+TX7q7hdXdfF90FYU+44R2iBhQmjIOYODv+H3A5oHpsNfET6guQWy8+bYyPk3qGXP4suMoMmp7rHSA/RHC4gxJtRQC1dLQjg9PfJ99bCZ+2m+VZNHMUDKbPqUBjujuMUEtf9YL1GEoiiQx4YGBCcwnX1vueUyK2TWfjhRWSwdr+xIlSUefpdkbczV4rLC9oCgTL9LsXs4EDDiBoc9QVdrcc/Gzs98c6OA5bmv4H8xi9JD29mKFrQen+mWw3IBSHiCjN2JYsUUVTzeMb4ZBMPtJxAdb0IF508tMByy4JpZ8cbJFczoia1O/oPZTFgpDS7YdvA06VJw== 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=Z3cT5IUw9HiY428/FcKd5acepEiouvleMMIYyuZT3RWKwnDDTMeXfy/NI6wcC58o8TceNrupdXUr+Xsmf+LxBtesnZVS8zQOHY+yKLvOU0JBEbbkvTf9EYFmR/fhVsO2EL14tj9CV6swGBbas3d4ZZlaDsbCoF6738IAHsJe2JLImHYNQJ3U4LxDpZEU4tLbOA+WSZLe3oe94N8leZH3VUnMufxA7/PJ3GDq8KFENijaZ1N/ExmwTlVjJM4Ur6Fq0KAQZOLvSSypKgSrTK6rSy/19EfYjxVMALpXEPMWxLgocRItmhgw8xpGBuQokYwqsw590Rjgn1V0jByUSn2W6A== 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=2AOnZkRCEsnqpFMqsN73FSeCK+ijjxDE+eSRYpPSfJHWYGu8Zur95mC1sca0i2OlNnzoTE7YJhihxqxd9sekjg/EM4DJePN8Yu27RhumsLmZz7+Dvn+tZtAWYIOO0A4aMF9KyaLG2kPxv1kz75MB5V4HbpOyCqCF8NsU1c9Kqho= Received: from BLAPR03CA0155.namprd03.prod.outlook.com (2603:10b6:208:32f::13) 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 05:34:55 +0000 Received: from MN1PEPF0000ECD5.namprd02.prod.outlook.com (2603:10b6:208:32f:cafe::ca) by BLAPR03CA0155.outlook.office365.com (2603:10b6:208:32f::13) 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 05:34:55 +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 MN1PEPF0000ECD5.mail.protection.outlook.com (10.167.242.133) 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 05:34:55 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:52 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:50 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 20/30] spi: cadence_qspi: Initialize read and write watermark registers Date: Wed, 6 Dec 2023 11:04:34 +0530 Message-ID: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD5:EE_|MN2PR12MB4453:EE_ X-MS-Office365-Filtering-Correlation-Id: eefeb1a4-75b8-4f3e-468d-08dbf61d141f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: goS5mRiolBJFLTaAEfkG2eGQy64bd7IC+6MTZl1hA0XuBEUAod72XFrSaa0FovvF4nRmcSUeMLouasAbaKys0RGzgO5yrau1s+XTvtXi9iAahFINFZKWPTqoFKQRG86cWua+Kcj61Uv0yEHW1iTYlz0MYnpxxEAgkkEAe5pgG+YoItiDlE3d1tt03VAJHtykc2ZJxhNK3swb3yHOxiQIQkXAdJtXueR6atZK3pIlegRWXTPgTuEa8JnGYHyUgM18XzOiVGYDkxO9b/k+RI9HODB7o4ToqM0U2Ki0+/NN41b1FM1ei1UVV6qPodxOt8anHL0c1W/Rfv5aQfg37zaMR2BMp19sVI79hVCW9WbB57zZgy4mhpjqpc98ezl+/1EPCTkamuh8uu3WojJy1qd+cV1xwLSRvrpwGXnqJDLmH8EC5R7q/KRhKxdYLtCSPk8p6N9zVZLtMM3rCbPBFKB5ZHNVdBS+wErYajs10pnBxHugVJ0eBcayjgtN1nSH9/IzhVH6rfzEcppsREmn5o5nyTnkie5yQ5QjTFhK6SXcptXYn0F/P5htzXM+TuAiKzGXcck8D++nPNyJ5Uvi5v2ReGLkMu3pPf4+KuD5FTtuFfZetq0zGuu0m25mF6ApLmcqIbXSQFXFaPvfxqpBJuL65Fpg2eo8gp8NtLyMIvi/ZKkZQM69coFVWgHydq8ByFiuZdcxyNgZEDXOs0vRt7A+W8BKX+lKXOW5yd3jJ684Welfy+4eYql2IzZRQlzEMBdPFz6Y7Oa4rySTbyj35UdZow== 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)(396003)(376002)(136003)(39860400002)(230922051799003)(82310400011)(451199024)(64100799003)(186009)(1800799012)(36840700001)(46966006)(40470700004)(4326008)(36756003)(41300700001)(5660300002)(2906002)(40460700003)(103116003)(86362001)(82740400003)(356005)(47076005)(81166007)(478600001)(6666004)(336012)(26005)(2616005)(1076003)(426003)(40480700001)(70586007)(6916009)(36860700001)(8676002)(8936002)(316002)(54906003)(70206006)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:55.4666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eefeb1a4-75b8-4f3e-468d-08dbf61d141f 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: MN1PEPF0000ECD5.namprd02.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: 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 05:34: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: 1872455 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=vdegrG1z; 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 4SlR404J74z1ySd for ; Wed, 6 Dec 2023 16:37:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 573C88774E; Wed, 6 Dec 2023 06:35: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="vdegrG1z"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2277F877AC; Wed, 6 Dec 2023 06:35:15 +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-mw2nam12on2061c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5a::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 E773587763 for ; Wed, 6 Dec 2023 06:34:59 +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=RIIV8qZL4BFkmT31yfPIRUbPw0w8FwTCSei6LgCEI61mG3hU22QyoUABPEmScMfiInghg99hjrWqS+5jctpG/DFJ2PARYFnuQR0dDjn48uA9uHhFOeTGXmLvPRW3B86N5YVXPUGbEF6yEjYh5Fi2JaYKKCb9kKMMOZnusMNeyD3enxRCcrc5xT8meqLDzcvEpTLeA4Wwv8aYietrdsp44TOfKptuOH49bRYDLtxRrf1PA1v8ct6lksKKGuCiU9OmHV1N2EUrJtcDbnsxuMzTpMJ/W0QOqqkd8lTcRRWdhQ030h+3VOg7PItnh783Fn54rWSOAS/iJukSvQFnOJmXFg== 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=RJdmYME5wVHy7XlmZdh0WXBhR6rwJ+i6w4Uq+ynKZk+tdumU+4AejmHqdsu6yf+N3R+on16bxSVqyH+a7E0sy005tNnEq0k6BnuO+NHJLllGv/1J/vzyazJOQJLCgUZgzRtWV+9hBHEv2xAB5qtFSDnmGaoxRPPL4sq07p+ZjxTr6uEwwIzdOBgZ33JX+N69yWMAL0QBOSzHlbeK4Gpb+yGG8tdK1FOBdf6gvUmRyen8XZd9UMh70eKTgZL/RsulN4LzUvGHvZNMrpa/Z1VGzlh2yS8ziOKizGAwvC/Shdvgdabya8WpEh5TVunambkmzitPa/43hrrrkEFDWQXsrg== 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=vdegrG1zAvaADKlPZL6XdHHozi8qDt15QjtP9hHqEw89NGz2J3vrhb80ouKZTu4KJP86LjFnKIrTJ4UNuGqPX6P86AYIg90ueRMR8FTxOkGW60wJQ5f0bvvpcyR4V/rT6A7vktzr1GPEGf15mB6qHHNpWu5ZbEVxhE9p1WPW5gQ= Received: from BLAPR03CA0173.namprd03.prod.outlook.com (2603:10b6:208:32f::35) by LV8PR12MB9111.namprd12.prod.outlook.com (2603:10b6:408:189::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 05:34:56 +0000 Received: from MN1PEPF0000ECD5.namprd02.prod.outlook.com (2603:10b6:208:32f:cafe::f1) by BLAPR03CA0173.outlook.office365.com (2603:10b6:208:32f::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 05:34:56 +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 MN1PEPF0000ECD5.mail.protection.outlook.com (10.167.242.133) 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 05:34:55 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:55 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:53 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 21/30] spi: cadence_qspi: Enable ECO bit for higher frequencies Date: Wed, 6 Dec 2023 11:04:35 +0530 Message-ID: <20231206053443.3746237-2-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD5:EE_|LV8PR12MB9111:EE_ X-MS-Office365-Filtering-Correlation-Id: 28aa451e-1eaa-4be4-91c4-08dbf61d146b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uQiIi1GIYHsxR+TxrGZK2BiuXsWe3PoF5aodybL6zCYbsIWKuyKfG6YvACuEO2h8lSdHije8BApfosR4vBf5n7AKPfgdh60fFvHAucbjUu96jEDawHYfZK+m5zoWq4sMYTWJHNyEAtEYK+BfXZKWANKl+H72+rZwDLYLdBZOu5CbRJzfAL/9I5hlv58ILpDKNYkEX+rlJkYoF3SdNTSFAzxvHQKcBUrQ7GkPy3XbZajXO9JqULbMd02dx9KrtQOGBH//JirpW6pfdxWeAjI7ufhehxc8U3wK33SZluIsGCQ3P7s1h/9QeWqoXh96JnXjejqzsSrZOPEPKJAorgrXPZg++Qepp26SRmM0e19cyWyqIwaPIDnTfPFExSO8ULZCqHtrcpUIiOfC+LBAzByEK2dHv6CvztXriBKq3nr8HNWDAV8oCxQ8hiIpcN1+m+t+nOAkDkGVH2sf+89f6IKAHCSamNohuS/2fQ/lFXWhdqdoFEqYQgViBPDrdsQ2KJXoQfmwuMuVFvbKdbVM/BTv2lJwZjHGiK/6hL73FKcNS5Qd7M+cmAW8n90YWiLvYfiUAWyGmMn5rIC3Z81DJU8yIcnz51FZhwLHMOSRRhpg8cSCiQ8dDWPhaU9hyCtv6UgUSau462GX8wvNcsV8h0/1/FwautR8NHkWyDoQr9FgQ26FaNmMRCohHsXfGkI3DtCx0sQ6g2MRFnb4m62C4X0ZHPU/2bSqWe2sOQt7eOFGb+PLNUAX1jX1cq/U0+fevAvx2cjk+oibj9XEVVlFBZccCQ== 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)(346002)(39860400002)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(426003)(478600001)(2616005)(26005)(1076003)(336012)(6666004)(316002)(54906003)(6916009)(86362001)(36756003)(41300700001)(8936002)(70206006)(70586007)(8676002)(4326008)(36860700001)(40480700001)(103116003)(2906002)(5660300002)(356005)(82740400003)(81166007)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:55.9666 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28aa451e-1eaa-4be4-91c4-08dbf61d146b 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: MN1PEPF0000ECD5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV8PR12MB9111 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 05:34: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: 1872457 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=TcjXgGxa; 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 4SlR4M4rQ0z1ySd for ; Wed, 6 Dec 2023 16:37:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CCADE877DA; Wed, 6 Dec 2023 06:35:49 +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="TcjXgGxa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7EA5F877E4; Wed, 6 Dec 2023 06:35: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 NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) (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 12E468778C for ; Wed, 6 Dec 2023 06:35:04 +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=DuxFqfxNtMjFaIK0EuN9gLqn9+GtjOHY+1b6doHc561c0CmqSgPLhO871kVlkqsh3TYHEBDryTKuL2mFuLmwMokLYKam3SSXu/QK4wpxu9KL1zIY/mzBS2sIeo9qqfsPefsCflWvY4j+YhTS+DfU0xyXdkTruLjX6fq93+P0tcauDMDH3+pwAkixWAAYU/PNEi/sqXH8P9XzO7ipOmP07Fiw5vy3sCKMAn1XWbevIEQTc+iNEPXi2M9zVG4Inz2ePQwyu7Ma/NWrpnhSjDzLET8ugQKYXRZ2Uu5gBAK0Bm3YUdmDK3Min0a6Yf/Fl9UzlOnh+qaLSBVwFA49laz5dA== 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=Rw4P2zFHnRsu7qf3ZO4sQU3mh0bkvSS4E800VfS06YRL132F11jjuQt6lP+JVarOMlD7q9Qp0TNzi/PhO1vDalg0frcOdzekhTVdDtrUXd2NrVzovOU2tG2bCOQFmLEZ6SvvWNyJAdvJyPN3Q8BtXaMLFBq8Wt5I8RxKJYerVD8r5ldBRvMZFak+hlKbbsErFTR6uswGt36p7QMFoV/FzQjgP6NyFMlq0wyrsK1kUkJc3gq0JDRewK7youqZ/+y7K7lro77KPHLt0kTQTGnybJ2eXxd59/x4zkx9pgjYcRox28lV4kSkNyEJx/4tSWmLsa9G1MPmThotls8m+wT+NA== 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=TcjXgGxaKlAlQKFl8MDziO9lp1Aq4/LmOK5D8OnICy4kkwDlOJ/1JszxLC13hARpoCXKfM6l6p0HojWe+fmcVrBV5gEVo1lhaWB+1yRs3+3b2ckP94X/1Fyx5bCVpVCvh7dj2qoRTyN74yUUiUBGO7amln6YexzsCgrEwYXAHKw= Received: from PH0PR07CA0056.namprd07.prod.outlook.com (2603:10b6:510:e::31) by DS7PR12MB6167.namprd12.prod.outlook.com (2603:10b6:8:98::20) 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 05:34:59 +0000 Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:510:e:cafe::78) by PH0PR07CA0056.outlook.office365.com (2603:10b6:510:e::31) 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 05:34: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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) 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 05:34:58 +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; Tue, 5 Dec 2023 23:34:58 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:34:57 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:55 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH 22/30] spi: cadence_qspi: Add spi mem dtr support ops Date: Wed, 6 Dec 2023 11:04:36 +0530 Message-ID: <20231206053443.3746237-3-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA4F:EE_|DS7PR12MB6167:EE_ X-MS-Office365-Filtering-Correlation-Id: 55c91c10-e49d-4fe5-cba4-08dbf61d1629 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /0BuXtIHADCyy7WGEf0cNHykODmWn0htSqCArbyZqOULItBCx8rnP1Ec0XLWPlp9+dQcWO2Qaxcgpus8DoGzjFdC0vPYiqmi6m3WLjPehHCnln1cicjZTYtVZCAS+yTElNxLLDYpalKqxM/yqYd48raV5X9W31XGBk+52ltKOs8ZVKeQ/GJF2pZxfY/pCnChGsOTQNydvV+NxO78ntImogqk6cjkZ2yFURTS8NfgYkM2IfdZ1dSP5Y287JqInGkemnxOgOCC5m0wsMGyXCk2gI2ShJzE368nFFwO7MulwCzHyy12/24CuVBt+0DxnguAK+vU1qScOdAOb9SnBF0hgO2DRtTOOKXFjKOmU0mG3ibg7TAVot5ALnmn9+8UTe1xTHuLg9bCsAMRdwQz/8QXUFILS/WggMCNN7At4PkhTa4PmJ0gKsYv+raKUzp7H/9wn4A6S3hihRtyr4fdZIl5dDJQKkLGNhrIcLL++oM//WveK8OCORcZEuNHLSkDZsYmQdlXnJrdpSoYA/yIeBDyU8A8jjhuGdhosYyfkwMZCSPNxE4Do58bO/vWyFkC/ylIl31h+c6cE1FVSNgZnW76SCxMStVTlMBKKwturguG+nySK0Ao9TelmAKZzTZGRR9sbHVxrBXVxqN0hZwT99zwcRBVaoyMevLPODwMGfnK+EgN3T6fefHJc/rKu7rYHGMrwgOnE0tqJ/X2CEEQ5rEGgqAotly7xpNRzXeuhOEfhhjRGf2XjW9B/n4ap+nLu5srKbHZDFPg06aQZV1uG2QqQQ== 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)(396003)(376002)(230922051799003)(451199024)(1800799012)(186009)(82310400011)(64100799003)(46966006)(36840700001)(40470700004)(83380400001)(40480700001)(81166007)(54906003)(26005)(356005)(4326008)(70206006)(86362001)(70586007)(8936002)(47076005)(8676002)(336012)(82740400003)(316002)(6666004)(36860700001)(5660300002)(6916009)(478600001)(36756003)(2906002)(41300700001)(103116003)(426003)(2616005)(1076003)(40460700003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:34:58.8754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 55c91c10-e49d-4fe5-cba4-08dbf61d1629 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6167 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 05:34: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: 1872459 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=jM2G+tGo; 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 4SlR4q10MJz1ySd for ; Wed, 6 Dec 2023 16:37:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 35B06876F4; Wed, 6 Dec 2023 06:36:30 +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="jM2G+tGo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EB745877B3; Wed, 6 Dec 2023 06:35:29 +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 12ECA876EF for ; Wed, 6 Dec 2023 06:35:06 +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=FJjWAtSQcBUsZWE8LjYxNOVvy3qJCispobH9f6ku3LGRi5acIOJwpukGz+Vzw/Q2jUZLfKfgRlgqOvXfVGZ+EMvVyr3hjbLQ6A90kw/NjjOxTcEN+JSLRvVNd1VuKtwVoyQQCF3DT78YC3atGzNpY0fHdorevo9MW2W3S681xg1SPVrjZadY+iT8AvgzXAZE6+rjFsRp2m5WGI8rKHnpVbxpsAOCPexUWoOcA62PSpFtX2cGOr7oFP399o1TFhXyJtotRxu4ZYUTHsQ6Ikn4oO1ov6CWIFlPweJR0gYcogUs9cMNLi+UjSQnBhA9BwrdHoM+Anox/Jl/RinL49VR6A== 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=B2fZ1tBtoVJQXoXkVEH6FRw7Xg7K1N/Vy0S+VL8IAvM=; b=cRpoK++9R7NnftTVKTvuL4Sx3ONe4nzoNF4egS1Rtn7K9KwocsX8Qr6mMLW6ptPy21cLAWB5Mx/rWFs7eJZbqt192StFMN/hLAUgDV8yggDXcGkpO9BB7t93XUju/6cx8kv89XgYqKnlS5DO5YAm/bDqANLAvviwm61r8RWBBqq50bdDEFaXn7e1Q5g+nx3tcTQHWe+dKCUvZLSaKVkP3R8f4KN2v8hwpwTed3NoUhMQg822iEgROO5UlsKZuJdB/lOd0Cg7W3OnWQ2DkOSHT+RzPZd5n8jYW8oYBBp6hJ1LUhJm7zbS83brkPKJIKD9DvL78htFE41bC4PU0u4c3g== 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=B2fZ1tBtoVJQXoXkVEH6FRw7Xg7K1N/Vy0S+VL8IAvM=; b=jM2G+tGoL8ER4dQ72Ym/6h2UvK6kFQwg6eEgAWl4dn+h4Rs7c1uIGAVfWHCYRm+g9QSCdGffdRJW3DwuDeuy6VaDk5cgLV8A4paCBniP0xo/nMW/gm4W+7BXof17PxFaKmHeqAtWxWo0DCvH/wDfB5TtOddoemMsCshcLAXAw/k= Received: from MN2PR12CA0031.namprd12.prod.outlook.com (2603:10b6:208:a8::44) by DS0PR12MB7926.namprd12.prod.outlook.com (2603:10b6:8:14a::10) 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 05:35:02 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:a8:cafe::2a) by MN2PR12CA0031.outlook.office365.com (2603:10b6:208:a8::44) 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 05:35:02 +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 MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) 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 05:35:02 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:35:00 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:34:58 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Ashok Reddy Soma" Subject: [PATCH 23/30] spi: cadence_qspi: Write aligned byte length to ahbbase Date: Wed, 6 Dec 2023 11:04:37 +0530 Message-ID: <20231206053443.3746237-4-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDB:EE_|DS0PR12MB7926:EE_ X-MS-Office365-Filtering-Correlation-Id: e988ebbb-ea83-4a40-57d8-08dbf61d184a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RDmgQiAgMxAyEECNUuPNn/HlFSOV16qd94MkhqQSthNuuGBcDYsQCDQAgzX3TDpXRdhoBdlx/uG97fDc8dAf/p3jP0ydqqVL9w02lBsZ/IoGmmNgHWK9E+D809bwUDibPC/NwMbFDpBFnNQaHQstlswDc3Y+dNX7DRIr+OoL5zqRggCMvIY8jGpW4yW5J2TYwXNn5iHkaDJaL4hMRTo71kpMLErM3Vpm3g0QWYtzsj1QtUo5iShelf7eRYWBSVvbW2jiAtNLIontPtQV9KE3WdIR6O9gtYqcHZOfDbUVdkugRZw73JxddKdGIW/YMCdi2N/0Sf+YGBdu2IW5hXlVP6sv53WqTDEm/Ekya4BZ7fqgTj0lXhxoEHjcUkk9KMJ3fGUS3dQZI5wqZnvdCFe74RcPCOOQyRx642EVX6xzB/diMsrk3V8D7zLAzP2ovaPrCfdOhfF6z+IhJaFkpdXU7pp6MBIF1Wwzb0rdgS+DngNhaJ/U2YYsygR0cAw6cjS9IGEW5MEErUZ3Dx5m40/o1yxDIwSFEzRZJ3cKaWheEOMgBSzKP3YJ0EyAS7VnPzGf1UBBKZ11TQ4Cs3vIZ5cqYwDPk2YT/8V32oShRf0AMRkpgj6i2xRU2No0lCBY0m8PBhb802cjCapQ5LhEFHmkbo3/tOUngOsOnpOD4ZKqixaU6gFa+FT/yyjgyANmnxAnkz0XcpdNs+kdzOOm0NulZSZ58vkE44gWF2dyJKuokl6OxAtWM0vo43vPMmmD53Ht3MAn9g5TpnQbW4NgD8q/lA== 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)(136003)(376002)(346002)(396003)(230922051799003)(451199024)(82310400011)(186009)(64100799003)(1800799012)(46966006)(36840700001)(40470700004)(8936002)(8676002)(4326008)(5660300002)(6666004)(36756003)(2616005)(316002)(6916009)(70206006)(70586007)(54906003)(478600001)(41300700001)(2906002)(40480700001)(82740400003)(81166007)(47076005)(40460700003)(36860700001)(26005)(1076003)(83380400001)(86362001)(336012)(356005)(103116003)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:02.4598 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e988ebbb-ea83-4a40-57d8-08dbf61d184a 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7926 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 State: pending --- 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 05:34: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: 1872458 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/8vzObV; 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 4SlR4n3nWjz1ySd for ; Wed, 6 Dec 2023 16:37:45 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 37F9D87832; Wed, 6 Dec 2023 06:35: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="q/8vzObV"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BA6178778C; Wed, 6 Dec 2023 06:35:25 +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-mw2nam10on20604.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e89::604]) (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 12F398779C for ; Wed, 6 Dec 2023 06:35:07 +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=DfaLiAVs7oubFhdwmWl/Y4/oHgIOBkWNvaU2uF/KZiUTVZ7OYjvxthRpdUcphEmvzIgdCFHfU9NT70hEZNBsC/HlC2YYoxvPVl0ZBpIxZSivMJdxuWwaTN+jbmOpn9JF3Eiu/cqmewVV/J1OMzMFEda7RBx4f7MtPN56DoZOp0XhOKPseQdF+ZJRH/5kbWRiD1ZUG4E8Rd/7tW2B4GnroQxIiSGrEGrbE34ISVkU4ESIP6TSH37+xbu2Vp5zcPMk7UDMUAEc0XA/BBocutoPaiu//QOY0kqaepT4F6hp6zE5L6DpOTQZh/EtrcO1HbiRdqjcmD8ggud9P3DxdYz1xQ== 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=QLHgWR8j5XL2bXPLBcOF8sNyZGC1ANeF8opCv+oPWV4KNjlYwiXYMfhk73jSyuyy7pmbZLuJyqGEuBaNxHKpTEL/EdBtb7K+2BhECVBGneYQF9epVT8Nc8GU7XMFPlEhyaKzWnhNEaNAnw7yUwjtEqdlLzrmqZUr8ENTMMWiJz4rzqY5bvRA+VQbT/cDEsXoyHposG9WC//lv0abNTCCrQ4E5xYmS2Psh7Z/VvMXzrt4XpggCdcGcTKvyiR5ugV/kZleyChGRfQzm8293rnGh0Zac3o7MOSZfI6rIKznBObCF0ujPmUFea75RFnNw7PyUaH/6pJpEjG9GVPxwxT1VQ== 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=q/8vzObVeOldug83mYdvB6htWUX1NQ6cxuxpTNmBQ7yy7gMS8Z9SDwxZeAgpNne5HtKJ43SINEq05pNmoYRvThEiIdirm1QlleVIOK9dLSN/wGz8+JhYvF6ABP4I/kRZNbnwRYRF4KDlKtCdPZ3zTehMQc009SAkdtetxPgaGYw= Received: from MN2PR12CA0008.namprd12.prod.outlook.com (2603:10b6:208:a8::21) by LV3PR12MB9331.namprd12.prod.outlook.com (2603:10b6:408:219::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 05:35:03 +0000 Received: from MN1PEPF0000ECDB.namprd02.prod.outlook.com (2603:10b6:208:a8:cafe::7b) by MN2PR12CA0008.outlook.office365.com (2603:10b6:208:a8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.32 via Frontend Transport; Wed, 6 Dec 2023 05:35:03 +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 MN1PEPF0000ECDB.mail.protection.outlook.com (10.167.242.139) 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 05:35:03 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:35:03 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:35:01 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" Subject: [PATCH 24/30] arm64: versal: Enable soft reset support for xspi flashes Date: Wed, 6 Dec 2023 11:04:38 +0530 Message-ID: <20231206053443.3746237-5-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDB:EE_|LV3PR12MB9331:EE_ X-MS-Office365-Filtering-Correlation-Id: a4cbc025-13e1-440f-88c6-08dbf61d191e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2tg6ZH9ZG2aKVVvG+kEjgsUkPSAmUs9j032mNWeRD6kOhspiJ774ZeZWG5+8LilJA6QoXwH7BAUwPofVxYcezmwSHvJBD/LAld+PqSTmQtZgiNJSzv922rGe96Gg2yW3XT6iNOrdWP7O7ltQID5+LptsYNeJjTl+7EB2n7BADZMWyLgq/PiME4gF2ZakXqEU8x0PdXNkBJ59OUqCfVBj5jvcSW4OQnYcIQFmAvnLSn2bgBdEgl0N2tcW7LSwGc9RKHIbv8MgxLFd1Va/O/3OKQVNTF/J5goL2gSNPmT2CH9sACjw6yvH1jtQrmjTWdVQvLkXVCc5u5bmXzLoF9IXadJETHfBh7adkRy9nBOcau9y2+BDPpEfylguUWMfjgSDGakpJlTdNX4q1XZ4IgNIlQjwAOcl+OY8NlbgXlw67CqKwth6huezD4YHWoy2DZ4Jv5bTIhk+Q7n4m6n3vCsHjtZErUR+7TkXYSA3kYYIQ/os6FsixfRsXdDspOVM5AC33aNZf7+UlY6iGvTj/mjfkVsBVXgORc2PgqnIq+MHTSrRBEFcdMwPimBUazVIW3aj59ubX3Vt6j+xbzcgATB3TlvfppqGCrP3zIFKmQ8O9zByc8V1qmCs8W1LNADydEbGFyh4yfny/AzPVdAf72f1f9IQbCAtCQeDKoV2ApXG70fI4rV20e0piRxKsLJCdBkdJjWdNpPaluVLZOlTyx/FaziR8Pu1xhCRlIvWSl37/lcAbNBHJG/dYLiNuifdHch/KEee8RIdhTKILrAzTBt43Q== 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)(346002)(396003)(39860400002)(136003)(230922051799003)(1800799012)(82310400011)(186009)(64100799003)(451199024)(36840700001)(40470700004)(46966006)(36860700001)(6666004)(40480700001)(478600001)(54906003)(356005)(70586007)(70206006)(81166007)(316002)(26005)(2616005)(1076003)(47076005)(83380400001)(4326008)(8676002)(8936002)(6916009)(426003)(336012)(82740400003)(5660300002)(40460700003)(4744005)(2906002)(41300700001)(103116003)(86362001)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:03.8191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a4cbc025-13e1-440f-88c6-08dbf61d191e 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: MN1PEPF0000ECDB.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9331 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 05:34: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: 1872461 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=eBpaNCGr; 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 4SlR5G59wkz1ySd for ; Wed, 6 Dec 2023 16:38:10 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BE08387877; Wed, 6 Dec 2023 06:36:31 +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="eBpaNCGr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1E059877C5; Wed, 6 Dec 2023 06:35: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 NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20602.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::602]) (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 3136A877B1 for ; Wed, 6 Dec 2023 06:35:12 +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=UZd4V6wBzAKkeX81BkFFCSS3N7JPKOe7LmUU9ONBR7Ie4+35il8wdYJYh8BGhCccs+ESsfkaK/EqoEMAoGplTk8vWkampwaFfbFvsMip9yaNRz9W/p6HuDzDYK6xVTUxDedZE1HfU16uxlxyBdutM7Z6IrOKqPhYdhAygP94W81yfIZxWVRSieeFYavn+50+dLUtaQ1dMNZRyh+CqFYUcRR1RsLRMSRBFkRKWyPDZ9wmF0ekKXXTLCl27JjQfcjiqJOusE9sIvKcdkL8PRMtRK5nMQlpifpiWbbZsp22rjJKFXBQ01VqkIcLoK4CiDMxwhFpcYRgXhYOXv9IgoBegQ== 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=hUO6uAtXCiuKQiqq7/b0HZ7YfsLkpWIxz6g9JzKD0/M9oDfC+LZuyrYwQwyN903SbxQr6MRfLv6yO5iU1KJaWiYTGLyVY2Fx6eEkdU/Uo4HeLoHPEHHPurxGoendjfiu0Vpb40B+raXFrpMETnmw2NWsL3qE/GT90CDk/PHuKRNPZdY+kIUrElT/14napwBBm3tDTuRiN7BXqLU3noUwk2ELSCMiXCgZpAjeNn4qTRaoA0w6578yLn3It0qvfOtXrg8L2SeQCG/JWEAAw0vZtLYH7W3clSvakpQr3Dcamog+VAgXNpO9L57r5+vnCZtRQMazFb8fgas7ZOXREq7eMw== 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=eBpaNCGr9PU+t0rQ8wozhc1owIEb0ZVj2ibsJpvGh1sSINGuuUeptR28S65v5o9C0fG2fqS2Uy0puy5tCZwcsr9VBf0OwqIy0ktFnLXExaRz6FpkguXkejwg8tvlKy6pPC9zKGh72csiuyJ9AsIb/Ioz5VEq2PA/MHLnpo7F1aQ= Received: from MN2PR08CA0017.namprd08.prod.outlook.com (2603:10b6:208:239::22) by DS7PR12MB5933.namprd12.prod.outlook.com (2603:10b6:8:7c::14) 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 05:35:08 +0000 Received: from MN1PEPF0000ECD8.namprd02.prod.outlook.com (2603:10b6:208:239:cafe::be) by MN2PR08CA0017.outlook.office365.com (2603:10b6:208:239::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.23 via Frontend Transport; Wed, 6 Dec 2023 05:35:08 +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 MN1PEPF0000ECD8.mail.protection.outlook.com (10.167.242.137) 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 05:35:08 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:35:06 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:35:05 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:35:03 -0600 From: Tejas Bhumkar To: CC: , , , , , Subject: [PATCH 25/30] arm64: versal: Enable octal DTR mode Date: Wed, 6 Dec 2023 11:04:39 +0530 Message-ID: <20231206053443.3746237-6-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD8:EE_|DS7PR12MB5933:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e4907a1-d51f-43a3-6126-08dbf61d1ba8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9xLOlGZC30vC75ozl2iqH3BxatE6o6771iYWOkFBkLLwCZ966wwWGqNDnl9kmkFeA8zc+WlrZodY7mKNO/SgNB1cbkQPVGp9GlPWkXE55+/vt3FYUHLTKuV3Sy5QYrSyzrxKoAShPXORJo3pzqAhVD/Os3oFsIx/zb/Ez4BdciR9uZU5jXHqEyFy1nHHTDgh998HZk2SYT2LXvaJNo5SarWA5dEd3+XOqW0suIAhkLayh6KVYFMjd4tntES1XBERpLKh3BRuUA8Iu40E1fy+8sLEyGzbOmc5sUc+vGw3jfhFV6NgircAkeT3NT5nPZ7LG8XoMS+BHkXiCBgpAxCBvf6JZQmfUIJDJwFHm2DQwgqaYqulBoeI8yGcVnGcFcC0vtmrY+71wnhZQw3rWEYvAuknVtys0LEoZtEPIho2SLSUhhewKhbsGjZgOuEdRKKTYfPV262pUqv19IU5GOmlcCugfDhEdVDjOERpdUsF/pmaFWoWeeYYXVa9WgHHDeJIEtErruTrjkcA/fVpztxONyrF1GrCvrfwnKEUqcGPKRb/rf67Hkf44jtY/62tVMU3oVPithxPdVnqs4ixhXad01wDbmMYe2PlMk1zo8H9+rddCbV/evUbCpM8l4d4aADBKP8949SXMy/5oFmBlvFEN5qr0WMMybwzrcNe75WbmYzjmdK5NzHn7L3jC+CMxEZLmHadnMUVPYL0BENVrZs3mG0YHGMixdr9tL53Yz1NaSTD2yUYww6GYSLZnD2Ql3T311oCDKCB5HLRfEx3XbZjoQ== 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)(396003)(136003)(376002)(346002)(230922051799003)(1800799012)(64100799003)(186009)(451199024)(82310400011)(46966006)(36840700001)(40470700004)(70206006)(40460700003)(5660300002)(2906002)(1076003)(478600001)(4744005)(6916009)(6666004)(54906003)(8676002)(316002)(336012)(103116003)(70586007)(26005)(107886003)(8936002)(82740400003)(81166007)(2616005)(47076005)(4326008)(356005)(86362001)(36756003)(36860700001)(426003)(40480700001)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:08.1092 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0e4907a1-d51f-43a3-6126-08dbf61d1ba8 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: MN1PEPF0000ECD8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5933 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 05:34: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: 1872456 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=Vy3Lf15W; 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 4SlR47124cz1ySd for ; Wed, 6 Dec 2023 16:37:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6B176876E8; Wed, 6 Dec 2023 06:35:49 +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="Vy3Lf15W"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F11B4876E8; Wed, 6 Dec 2023 06:35:25 +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-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20626.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::626]) (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 9727B87721 for ; Wed, 6 Dec 2023 06:35:13 +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=oANKm/EJRalDNWFSjwTuHmdLlAkGGAxNVDHGUv2CYcZdsh0qJJX7jI2+1LnJF89Jza33IpnqaOPQBDNzk7y7Q8K+6yPvk9USpMFzFrquSc4kEd6KQz41G+SzJHnQcwaEPtpcV7jF98O0Gf98axgQBqCK+/76keVr7gporZduFnxxvQIGm7q1whvToLAxAOi5GB1fNwW0lHqWcT16+NWXxnZfMxR/WwiXk6sKZhtlB5p7QZV+8z2WmSMidqbuDC/IN3NCu7K+DJsw3okMIb00Wgab2KOwywmqBDRA/QypzPjHQ2k4DMCb5ZVxQczdeyiZeObmJjlffXYdvWhY6Vpmqw== 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=W3nPJT/2R8HKXZncBhs+oOH8pK4aYx+lAzo3fzA+A6TngKz01UrFmjggYhHa8QW4XwtmVN8UhZTeKMrbeYcyDnJe6iTN5yzdcE61uJDJ0s1tmFFzYdu8kb3tr+DNKr4nwPtnsd9IqLzzm/14996raveHsWkjUlCppl3x6XBgAghMkdHkiM3mLEW3q3rFirfLWQ8Y0iFFnLJbFU0i1vRIWG5ttw3p7/NB2nkY9YkFBxkl31FG+y0x6PG9NiNAzaWd2dRwSZifYRLTULYf2m+mNmsndidWb2cwBUTFz7Q6CMk06DwcrijGvJeRZJsqfJNBLRuJom+7MkHLmfinn+4DGw== 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=Vy3Lf15W33xl+5weHH66Bu1cBAirPRcEtnSLOcuCGJpljSrnLlp8Mdq1CDJzqYePzAvpqy7IxQqvMyAZeBZCR0PuAq7C1udzMUU2iaXxt7KDuJx+7JSWOVFSrA34bWyWU188oWDGSMSW+RFJx/M8OWOeAsnCV9lY2mULXRWhGrI= Received: from MN2PR05CA0004.namprd05.prod.outlook.com (2603:10b6:208:c0::17) by MN0PR12MB6366.namprd12.prod.outlook.com (2603:10b6:208:3c1::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 05:35:10 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:c0:cafe::35) by MN2PR05CA0004.outlook.office365.com (2603:10b6:208:c0::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 05:35:10 +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 MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) 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 05:35:10 +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; Tue, 5 Dec 2023 23:35:09 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 23:35:08 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:35:05 -0600 From: Tejas Bhumkar To: CC: , , , , , , "T Karthik Reddy" , Siva Durga Prasad Paladugu , Ashok Reddy Soma , Venkatesh Yadav Abbarapu Subject: [PATCH 26/30] mtd: spi-nor: Add block protection support for micron flashes Date: Wed, 6 Dec 2023 11:04:40 +0530 Message-ID: <20231206053443.3746237-7-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDA:EE_|MN0PR12MB6366:EE_ X-MS-Office365-Filtering-Correlation-Id: 2eab3025-d5ca-47b9-b74c-08dbf61d1d09 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rgGtABpI1TsWjKpHbrawnIqHAul27bZRvoeCPEZvCNk21aGpK6hetWidOAsCoIinI7brcVCdUoDLA53kVU3zYbTnbp2C7IfYCbH7j8eyDxr92OnVo0i7jg1ckYlYRnW4TLy7dS9uuylWLDjQ5KHA6Zb8Mr/deuonlZGRz1nfyf+97lKn6s5YZutgN+pfoxoVnU0jVvnID/1QWs+x47bGobkTf5pEbQe3ZpAdDFiP1vz8qn8PeJmZ6DAPGkwe2MNETwcubEM7tTrhW70Ieo8TI1qqFMNCT2LxrQ9/kCrc/r63RpnyT5+km2rzDuZ5Dbf2YlrRFAiWHORQqIv84qQ8SwUHlliQzmm++nOmYOdZZNTO+BC+6f1wk3adMt/AxnQ+A3/LTQ80aPz/o/qQvgo4KToHzF04fFOiEKggmF3bCbHF+HeDwWnhISaOPVRIeTJxWQdFwTZh4JTHgkWiKlmUexFyQXKDj6DMfagj52wR+Pg93GxCcA829Qv8w1R2AxhBM55I8EwM5uMsbJsRh0HOdqHDZi5kYKMvcsDsBzP6lteePy2xAT1WKklQzX4CSbRrbsrwi94NBBYL5b1WrjONbLcLzIbgdJWSxjDBfGDL63W6MrK1nTHEIBlLj9KYLA5CqUNVaU8XSvaU8c7fJ1/yF3f8vGUKraOlD0EwdT5FrjaLQ3REziV7ZyB1xm4VXR90eeH4ISUj+KAiCRsgf5WbpX2LBaKnxrlBLUVwA5FQSUGPIiNJYTDaKl+MinxfOPikIsFMOPuDJkvvNKiDNbCVFg== 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)(396003)(136003)(376002)(346002)(230922051799003)(82310400011)(451199024)(1800799012)(186009)(64100799003)(36840700001)(46966006)(40470700004)(8936002)(4326008)(8676002)(5660300002)(36756003)(6666004)(1076003)(2616005)(316002)(54906003)(70206006)(6916009)(70586007)(478600001)(41300700001)(36860700001)(2906002)(81166007)(356005)(82740400003)(103116003)(40480700001)(47076005)(40460700003)(86362001)(26005)(336012)(83380400001)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:10.4248 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2eab3025-d5ca-47b9-b74c-08dbf61d1d09 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6366 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 05:34: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: 1872460 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=twBGJvC/; 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 4SlR540dg6z1ySd for ; Wed, 6 Dec 2023 16:38:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2EAA877A2; Wed, 6 Dec 2023 06:36:30 +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="twBGJvC/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 597AA876EF; Wed, 6 Dec 2023 06:35:35 +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-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on20611.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe59::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 E2D2F87716 for ; Wed, 6 Dec 2023 06:35: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=ReGjFYU6UJ/7/Ud7mag40E2/ZViFAdquxP0SUOkgNDTvOHHKKWdCBZvEllkRo+ITYRrnQ4yrGaPl6O8q9oX3coExjy/Aa9s8DGWRO1VrsMoIDHRBFfY3rrVvDqvEEbSZ+7lMB0qhrTGDnqJ8FEE69AEFAYliuTZHIHcNZSwpmaprSZoNjjGu1bwNQq48uspay8BtXg9avCXtncBvdGO7XRe/M6mjETSamV0O2gZT3A52eS88DdtfE5snDEQO5OJq5J0YjGUK2kETuOutDDCHM7ZPdMTRM5FBrXXufLGmS+p8mJdcIGLWLp1tXEIB6AyWS00GZ8vjz45cvmRpdEsEyQ== 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=iFVHtcQ000tfCVehus4IczLZx7fzf4JbYKZM+keWRrF1ltpoBYuoqNZMg44Z2i/v9se+ip5jK28TLR776yc8G6Fe3nmu7PVj1qX+6hx9eGlAByE72wZUEDSmSnonH61sS9U6ERqRb7lM6N3O9c1W4GGQRedksg+xzkjIoBO83IYKJt6Aec4goodV4gZPAngwGIsDPTmYWjpk+LJzyr1Bx1xFOyg8L7bmFcrjBN8NAJqky94ZYjRYOfZrpRrRO3ZrhMiDYxmmAsmS0wjh2nWdtLz20YZc43iGku3Fkiwn+o+mB2+jrdSOLT7cMOdz35xWf9o/MHNfe9ubRY+no0uqlw== 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=twBGJvC/is2NkpDWugwICSTy0yrBhoDUrrYN8iR252aSjDKbSkh1sGypfgK19iqFvAp/gjCW6B7dh8lhq7RpuVhrMf8sKe+kyj0VGmcibGgX02BN1fKhYX1FyZYZcoedCy4bjU0gWoHnfyFLnA8kgzLl8KGbxnXqpN1DedoXrpI= Received: from MN2PR05CA0003.namprd05.prod.outlook.com (2603:10b6:208:c0::16) by CYYPR12MB8656.namprd12.prod.outlook.com (2603:10b6:930:c3::11) 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 05:35:13 +0000 Received: from MN1PEPF0000ECDA.namprd02.prod.outlook.com (2603:10b6:208:c0:cafe::59) by MN2PR05CA0003.outlook.office365.com (2603:10b6:208:c0::16) 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 05:35: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 MN1PEPF0000ECDA.mail.protection.outlook.com (10.167.242.134) 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 05:35:12 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:35:12 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:35:11 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:35:09 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH 27/30] mtd: spi-nor: Add support for locking on Macronix nor flashes Date: Wed, 6 Dec 2023 11:04:41 +0530 Message-ID: <20231206053443.3746237-8-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECDA:EE_|CYYPR12MB8656:EE_ X-MS-Office365-Filtering-Correlation-Id: d3dc8de2-dda7-43d8-0941-08dbf61d1e61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d8Vg3B/+txRHYzo34ER62/Y2J5Y6boY/J7xxDvLl7b0pgXiLakIK/jE+jmPqm3MdNtGuRBJGxW45acCFFrpmeRk8f46nKbuCI7YIm0nWXzLdQIZBGEWaGVkMS6jhe5ZAdFgefkRdsQVG6IdGO83Ot+OLxpzfqy8Fxwuv0l2ZJQJH1H0VJBQPR0BE9Fdo+Acl3wGfYfCV9xmUmKYZqGLjWSR73ro/NWyz4fwVX4xx5uH3uZyoUeYWzm52EVGQgFBXEOYDtNlE+18+/WDL8zu7/C6c8B1G461LzvpWE5hNq61BE4fDgNfVeoREVbLd+3IqTHxYh8BXnf4vYiuy6v8AtYjzZ4hVhO0UT0/Mp7X5OiZ1RHV4NgUuR2a4DOX0htUbNUal1PiX5YSiovEdrzqkYWvSbs0NM6R1FmQDBBWWeMvCXUsVydR4Vqhg/MhJow6Mc3BdbCViYgV2sKC34sZLrztZCG7a9inqVQfvUQqhPSpaEEP6N0BWgKKhfBEtZvFgbF3WxgaTO/XFYx3EB/IlY7pvxcUPeSzPhc/oC+ky06YhA3TPJgBBm55im1K+TmXRYMs991oei5IokGly5+16QEVzF4YhK+xDmNQrH2FLQ5/fnQ9lbC9/+Ag+avft9hS1Xtec45qQCbGauBEoWxPTnnJz3GwXbiLwx33lM6bFbPu33HlQCyoXQoR8qi+zhKd9jawUotP0+JLEm6a7BhDpwAlEaFGyoXzZ6JMmWhn4w1IDgqA3hIxF/AjuWOH6DVG1LmwGcprqdI+m9G1jL0zCWg== 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)(346002)(39860400002)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(426003)(83380400001)(478600001)(2616005)(26005)(1076003)(336012)(6666004)(316002)(54906003)(6916009)(86362001)(36756003)(41300700001)(8936002)(70206006)(70586007)(8676002)(4326008)(36860700001)(40480700001)(103116003)(2906002)(5660300002)(356005)(82740400003)(81166007)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:12.6748 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d3dc8de2-dda7-43d8-0941-08dbf61d1e61 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: MN1PEPF0000ECDA.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8656 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 05:34:42 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: 1872463 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=5F96k6dX; 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 4SlR5q4zXJz1ySd for ; Wed, 6 Dec 2023 16:38:39 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5B1AE87887; Wed, 6 Dec 2023 06:36: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="5F96k6dX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9934A876EF; Wed, 6 Dec 2023 06:35:50 +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-dm6nam11on20622.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eaa::622]) (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 2D1F6876E9 for ; Wed, 6 Dec 2023 06:35:28 +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=JKQcPikLLBmjTvF2nyTnPQyijKiBexYN3JS4UUj7RtOaCG7Ne7Gy3OzegaMl3S2WuVVgM284m9nbMwoSybizO4hn02DIcNRHCS5f884dSiJycs7x6N0ZOrYyhbpIYghaF/+2tRNwD4hH1kIx6X3HfvgdHTaWLLxAmEG21+zhT2X9t5z8JOGu+nJL6MBd2050UsUy6eYhavOmxPQEXKx/2EJbpCEPqdDYqeF+amJ4EKZw3QZxXSHxDqB0xu0YUdDbWAcQY420HpkgoHYxusQXtIQbg1GPSm7v2cIRRkeogi8bH6GcAA8s7YAGC3y6Y24TKLChlBJP64TboElGORnY2g== 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=d2fl5s6b/LAAQwoi3O5+XXxsOfvQnvxDykpGbywuQV2UWcBc5xjl108foFBTupI+yNX2AbGfcfYhy2IjrAn7S3ECepzkziS7/8bK//Z9yGjKT86QdCqqryH0RyFU4fvvcloQODhcr/Nz18hdfzp6mOkjP7ONr+v/B2IX6shQM3S9xmjRlLaSxUR+tCuw23dkNZQMzsADnVHtU23Jy41VSDxDMa87jydOg31JBfAXhr8OCVHdx9EGa8SHQzhZkttD5/EOI0JIrpLu2lrp16qgT1RRSLqD6qGITxKKTEEvd8Kh+yOGIJe9a2RlRyeUH1O7HMQTz0YG+r7WLk4hnX0XXw== 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=5F96k6dXEq7gtueJNurh6Qb5G1avJvy/4WNNQfDfeuzumeEoOMxar9bIo/82CF82r+BWcw0qrOk/jC99ng4a4HT6RbtwejJ/ujxYUor2z9rj2Hu4+Dh+BckHEUXIbXpsHeZD8yu/kpP+eNo2xGr/FWRyH3PG2Mbp/mh6jZjpFZo= Received: from SA9PR13CA0141.namprd13.prod.outlook.com (2603:10b6:806:27::26) by BL1PR12MB5350.namprd12.prod.outlook.com (2603:10b6:208:31d::23) 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 05:35:24 +0000 Received: from SN1PEPF0002BA50.namprd03.prod.outlook.com (2603:10b6:806:27:cafe::90) by SA9PR13CA0141.outlook.office365.com (2603:10b6:806:27::26) 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 05:35: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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF0002BA50.mail.protection.outlook.com (10.167.242.73) 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 05:35:24 +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; Tue, 5 Dec 2023 23:35:22 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:35:14 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:35:12 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH 28/30] mtd: spi-nor: Add support for locking on ISSI nor flashes Date: Wed, 6 Dec 2023 11:04:42 +0530 Message-ID: <20231206053443.3746237-9-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF0002BA50:EE_|BL1PR12MB5350:EE_ X-MS-Office365-Filtering-Correlation-Id: 1215393e-f90f-4b9c-41d7-08dbf61d2533 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CeAEoYUALOsUu+dM89vXFNIKDqzjE2YfLjMwIsJckBYBiL57sICOB9t6dybBmVmlzYhMLxTMTENg7upXRtyAN9w3byzVvZr62nzKdcW1rl+0Z5y2FgCqwLvt2LHoKJkSakzs/uvM/5AomJyvJw4NUGe7FgPewGEhcadJuv7P4/gADzrAB5eiDqVFscQ8SohOVFC4QUhYxi+bsrNT2sI60AsGIEZs3mXBOIsuD9ybd3Jg/VxGi6EEicqq45kVqAny5MjhsZx5Nk34ketR38oIPhAgZ7MRlWSmfefk02toeGk1Di7c2hQF6YxO1IFXBWDwkGVH+B2SpfQN1//BBhw6Lr7O+rRpSN1Dmcg6cN9LKzHb1yeOMUiB1y922QyAicITJZEtv29ZjnY7TA9OigOtR8dbOe2YnDbIUK0miglOb0wls2BhySYAPRcdG59jFUyvSwvVMZfpdZ25bV8BRglMm6SekA8ALF9x4URTzgieMfQpsla+3OrU93u3JOJTDqTryPZIaYJ/X4jkEn8hMObeoE8cd/3mbf8PfU/P48eRwud3SrXiplYL7L9BjBh7925UgbMt+AEpwnm7MDScAlokvqrtiy4yApc6ZuzsBt4q0dx1fJoCdmkQJ0tz+Duc7pkkHU/ANwHE8RUOJ5xXISXpH2Cc+obGWxG0SmO1M3ldTLG5CUTj+ax9udQRNsy3XbPOwwv7xQNc041tGWCa34bROHxsstVhgj5ffwad1zwr1EZhNLMTBcsNVDPqhZ+hvyCYvIl4eKG+HCO4AswBKe9tas1TfJV85sbHvFGBMjLZTvI= 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)(136003)(376002)(396003)(230922051799003)(451199024)(186009)(82310400011)(1800799012)(64100799003)(36840700001)(40470700004)(46966006)(41300700001)(36756003)(86362001)(40460700003)(5660300002)(2906002)(30864003)(103116003)(2616005)(26005)(1076003)(40480700001)(82740400003)(83380400001)(426003)(6666004)(336012)(478600001)(47076005)(81166007)(356005)(36860700001)(4326008)(8936002)(8676002)(54906003)(70206006)(316002)(70586007)(6916009)(69594002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:24.1032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1215393e-f90f-4b9c-41d7-08dbf61d2533 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: SN1PEPF0002BA50.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5350 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 05:34:43 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: 1872462 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=axzFqtEb; 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 4SlR5d4yJzz1ySd for ; Wed, 6 Dec 2023 16:38:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3CC228787E; Wed, 6 Dec 2023 06:36: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="axzFqtEb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7E3B877A9; Wed, 6 Dec 2023 06:35:47 +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-bn8nam12on20609.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::609]) (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 0918E877BC for ; Wed, 6 Dec 2023 06:35: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=FoAf/on04Ua4bzlmWywtUnA/yZBURryGI84ZpzplsE0JOgDPydOZx2EanHreVc0whU/GMD+puXQeE8fLFS1bSHzBZnC7BR5o+ZGvPzQvI4e6WSpwASOLqptt08WTX62KxXqhwpkXrwgVGHhYinUTYT9YVzoAQnVcnqbZhBE/qzXzD5VYmF/rZz5vXM6yBVR7qtZCeNKA1QGexf10gB+/ZsIEEjSzH0Vep8tw88TaoPbjqKCTYKWVg46xO0gLOwSr99PUnskotRzDYMrWShuHR0K7XX5cxFyUnCCZYMjPJGxPL9YY2OwF0w93eEcjVWx7n9cYSM8ANYtyJd7cC6517g== 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=VUNO2YpXoK9beID2MiLFfwstpXFQExlo1FajnmggX7DRrB5xultdz14UtbuXXDw0tD7LQJG+Mvr6QHDFdUq+uetVqiJy1r0W9WnlQpAsFjhxA4Nm7htaRoKGYp53CNtNjsqQOroxQQCxerj1aNuCws9Qn3g9YOjIip2EwrQ0OVSAMZW8XJJfSt3/k3NUncT9Fq9E3LLMqGtYCTop3pzz7AFWdNZJ4n2gbknOf7DCkPWe2GHcJB2gr79nkx51nrEC1Ev5vmi7CxdGlEekefetWt6qEnz+KZjwHKo8AvJVkUBZi7m5MHhsLDIf2eOCTAsJ2k7AlttSPg9iGIwplzQZ6w== 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=axzFqtEbZdarDzkjwhWBQVqIk48V0DoLzfUmr2lJvO0ZmbfAgR31fDzgxTqKpwuq3mqC+raVhez19NMrsGswkbs2Cokwmhtc6I3LBNsA0++so7oUUe3rqkOJRyLp4Y3RBTSOz1/wNO7784VSZW9Awlva5JelKTdncs3jXRlTN58= Received: from BLAPR03CA0035.namprd03.prod.outlook.com (2603:10b6:208:32d::10) by DM4PR12MB5842.namprd12.prod.outlook.com (2603:10b6:8:65::13) 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 05:35:26 +0000 Received: from MN1PEPF0000ECD7.namprd02.prod.outlook.com (2603:10b6:208:32d:cafe::d1) by BLAPR03CA0035.outlook.office365.com (2603:10b6:208:32d::10) 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 05:35:25 +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 MN1PEPF0000ECD7.mail.protection.outlook.com (10.167.242.136) 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 05:35:25 +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; Tue, 5 Dec 2023 23:35:25 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) 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; Tue, 5 Dec 2023 21:35:24 -0800 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:35:22 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH 29/30] mtd: spi-nor: Add support for locking on GIGADEVICE nor flashes Date: Wed, 6 Dec 2023 11:04:43 +0530 Message-ID: <20231206053443.3746237-10-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> References: <20231206053443.3746237-1-tejas.arvind.bhumkar@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD7:EE_|DM4PR12MB5842:EE_ X-MS-Office365-Filtering-Correlation-Id: 023249f7-5bbf-429c-b822-08dbf61d2616 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +7KFPjLmWYIbdaplxGNd4kkl9F0IOSUmqFu/+RHbXx5tZMc5ePHLeu+z49BZXjywOT8vgrJ3PrmpwQ1hfy4vMr/+vmDzU7q37SpGQDFEIbw9sDK+3oSRdQnK+NScq8cvg87H8KwhAYeKtmC6Xm5pPOPy57iGJurZU/BjtA2k7FPRTI3p8fcpuE8l0TxpnuK5vYezkEAfefNlMVRLra8+yjqHk8uw3GDTv2wBFVwsMP8tCarVEXzCj+yYijcHqW5kO0mVTXCzORjEdp4mqJrY5zsT5LS3Tmx9A6D5wdz9hIV5wOBNv+p27HvWaAn4X9q4YkLPOF1vsRjFvbZAzJRKC2HJ52yTxikOlq12Dfe4mAgNRttodBcEgjCFoAuxyyr38+VYaXSiH81MU9sA+SAb8rTWmlo4M7Q1kbqFkRPhlvNcPeldnC4SvDkYKF2N7A7I4lsJtsBq+4WE36+T6vi1fe8FV3C1YEwA6Y7VZwqpvsLj94HQxueWooUrJUKMn4x/sMZnoci8MVrkSMBA5+XBkBl7ouN9CeIro4S3g7bMxIw3h+ccjjGJy+t8FDteRFMUNDxoYyIMJDmCHYyQztl0BHadBngBrhe5frBe0T1eB0sbz+diCTW51NpxiyUwej9lgogEUGQ3APS0+6Fu0dE1mpC+rjkLGtyCJr31IvrudrYhTJNcK/ZoD9UAiUc1/jpK7j5Q79QLtInRZchscyGO36zIKG+Ptzr5KncVn0u4oeeXZ2f42u2ACSftl3lGKYqouKPmxtUd0FvP1g4lHmXOYA== 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)(346002)(376002)(396003)(230922051799003)(1800799012)(82310400011)(64100799003)(451199024)(186009)(46966006)(36840700001)(40470700004)(2906002)(40460700003)(478600001)(8936002)(8676002)(4326008)(6666004)(86362001)(70586007)(54906003)(6916009)(70206006)(5660300002)(47076005)(36860700001)(356005)(81166007)(82740400003)(26005)(40480700001)(426003)(83380400001)(36756003)(336012)(103116003)(41300700001)(2616005)(316002)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:35:25.6096 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 023249f7-5bbf-429c-b822-08dbf61d2616 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: MN1PEPF0000ECD7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5842 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 05:36: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: 1872464 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=XO1PmJ4A; 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 4SlR5v4Hzsz1ySd for ; Wed, 6 Dec 2023 16:38:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2CA56876EF; Wed, 6 Dec 2023 06:37:17 +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="XO1PmJ4A"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5536A87751; Wed, 6 Dec 2023 06:37:15 +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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,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=no autolearn_force=no version=3.4.2 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on20622.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e8b::622]) (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 76582875F8 for ; Wed, 6 Dec 2023 06:37:12 +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=LA35sgc0/ibOm8pjdmaHN+I/IrR2dDLM0p6yk69ut+0NLfhwd+ORZzgManxaUEoGwRHAxgRgYCD5P3MG8carhVdMe94xNUzZPzVk82XZQD6EY3v/JnbZC2kIDpaXYb1PcBM0mU/xEEySgaxisaNDMJa8EWUrgcvdGVQj/pfZDvzLmzDJce3fMvJuxPC54v88rU99rUn4ShVeMjZV2yg1+R5+2brAtZn3LswggfCfL0TsKBI5lLMFY9cUyDvDF6u/zlnmo+4j6AlTZ12O1XpQr+yqgd8kltkFBfGyYAwPGE/qVwoKkVjBfApXLxxKnq3BiQpDTPe0booDUsJYZ9CD5Q== 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=ZcegGMg35tBxbYS5USTL1/55eb/86tCgREBypmegBrKNZ+PglZVjdQR8nYqakIeMeJwQ2Cp5/ojVxRKZ1z2ihQGSwwMFP9vLGd/2EbSFVROXV+De8fFVHCfRbuVuXDoRvKdqTZjfMH6QG3TTSFZatpcCwcDgyfjqAzlQExaj+Me8n1G5gSpOlZAoprzQkyDl1wfFicwr+2xDc4eY6xVCtXJgeMpa+y6G7OhL1JeRv8xXiW/2xL6uBgzjjdys+YlmeBtKYwTTDSewKEUGf+2qJKhQ2yXbSVmjFxJDAVCUPx4VkwNc77ZBCfm0O+8Wy6zYbHQ2Rv+EJeqhj7VjVjadPg== 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=XO1PmJ4AoGM1q4NyepPv2c5Kzy2DJtFSlOHNV7QZgJsbsxJK3Hjta70cEtcdFfnAohbHcdB+/WwtcjhbH/5ZRY8OaC2uPwVDr0LvSLW2qth/cXP4a1Y8kK0Lq4UdPb7vZvrmOVX1UjXIWo6jr7TRDSwOKvXbBj4qxrJhks60ywM= Received: from MN2PR08CA0018.namprd08.prod.outlook.com (2603:10b6:208:239::23) by CH0PR12MB8550.namprd12.prod.outlook.com (2603:10b6:610:192::11) 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 05:37:08 +0000 Received: from MN1PEPF0000ECD8.namprd02.prod.outlook.com (2603:10b6:208:239:cafe::ac) by MN2PR08CA0018.outlook.office365.com (2603:10b6:208:239::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.29 via Frontend Transport; Wed, 6 Dec 2023 05:37:08 +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 MN1PEPF0000ECD8.mail.protection.outlook.com (10.167.242.137) 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 05:37:08 +0000 Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:37:08 -0600 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Tue, 5 Dec 2023 23:36:42 -0600 Received: from xhdcl190040.xilinx.com (10.180.168.240) 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 via Frontend Transport; Tue, 5 Dec 2023 23:36:40 -0600 From: Tejas Bhumkar To: CC: , , , , , , "Venkatesh Yadav Abbarapu" Subject: [PATCH 30/30] mtd: spi-nor: Add support for locking on Spansion nor flashes Date: Wed, 6 Dec 2023 11:06:28 +0530 Message-ID: <20231206053628.3746861-1-tejas.arvind.bhumkar@amd.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000ECD8:EE_|CH0PR12MB8550:EE_ X-MS-Office365-Filtering-Correlation-Id: f30bdbc3-0ea2-464b-971c-08dbf61d634b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Gjc1NQ1Kjjdx2NLw957wLCnSej7669wWCnnHUuik2LzROFQ4Z/l0ulEetu1l0lJ1n0SZZ4Ecyax1KRibyAxBQ+Te9OVtXTmLznLqB+tOzuyLxshKy7N7RhgbK2C1zzpnGcYO6GaFNw6wNXgzQ+0hGnHGOwtr3Unea6oqUmU4vKdoEPFR3ckK2Be89lCkVwzXJCOaO5pzl/Q7cnYxvU09fVhXUyb6/NXnFW/JPqKH0xw/Ssz9bdAN/BywW83kROoJLDcN79lgL5kXx1ZD91GrdSE1SoCwt9dhqKcxIYHC0xxm92+jwANy259uWs4nb7IDMSPqQcrIBqtJWcf0hQa7uVMQPA4deln91gOIH7Q+PoVTiH2wfegimcubzFx8uY6QjizEH9WcrYSE1dxuk+8EFM5sRAc/6nLmKaZ8DB5SNqj+Z1Ui2IlwCDtpjSpp/CBspGh39GUSkYhtCJVJpd9DhivXYZETdrmp6zB0usdf5J8DLTcSrHKa/frGv4t4uPFDCiHZg42osyzhXfySw54cTg8ZfTRDiOxoV3T8CpYp0F/H+97ZxijvQPTMVamU9FMVWoO5Eu2e1Dl5smwroLtJurXXpwJgZJ9JElmqrpvMH2bbr+2GFv3DQ5Yow1KCyVwRrQxaSTs9lUeVNZ7rbIS/hS8N4GEgetJQ5szCKmoIp7sGKL2AoTtl5JldGrVlZqz3xKgy2qxrBJXVCYJaZ37cFiTsb6yGUeO4JR8Cs9C0p4ITZRqBh3Kml+upfYVEUJ8xc+vqAWRnWMHqpWbaGj5Kpw== 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)(376002)(136003)(346002)(230922051799003)(64100799003)(451199024)(82310400011)(1800799012)(186009)(36840700001)(40470700004)(46966006)(40460700003)(54906003)(6916009)(316002)(86362001)(8676002)(4326008)(8936002)(478600001)(70206006)(70586007)(41300700001)(36756003)(30864003)(2906002)(5660300002)(103116003)(36860700001)(356005)(47076005)(81166007)(2616005)(26005)(1076003)(6666004)(83380400001)(82740400003)(426003)(336012)(40480700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2023 05:37:08.2971 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f30bdbc3-0ea2-464b-971c-08dbf61d634b 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: MN1PEPF0000ECD8.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB8550 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)