From patchwork Thu Mar 26 11:42:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1261952 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=cQDb/w+q; dkim-atps=neutral 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48p36C4dKYz9sQx for ; Thu, 26 Mar 2020 22:43:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8122B81831; Thu, 26 Mar 2020 12:43:30 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk 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=prevas.dk header.i=@prevas.dk header.b="cQDb/w+q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id F10F68004A; Thu, 26 Mar 2020 12:43: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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0704.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::704]) (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 2E7268004A for ; Thu, 26 Mar 2020 12:43:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GffibSHyjARUS8LgPPl5YYwnpgDdVt1SnQxJKfvmDrP0vvioWEnFJA5FkjnVm5Hwhrypzl2Bd/QTc2Qbw3Dxej/M/lrUHObGe4DKu1E5U16am7dBwzyZjsA1lMqSd7LnxhqAkS7ZN4FoOKksHvEF7X06qUKy63g5OAmcx9NfKu/K2Dz5te1NH8bAhSXbQnEH7MGwDT/K3nwN6EjmFlKi8zNpGonCZijTR+P9oef2V5dSA1zdDXjp7NymFkJPhiFoO+dvS/MZIUDPv1rpajiblRjJso/cXThd6/lSPxY8w5t6dTsGXhCINUPEij2Oov6oZYs6L0E/kcWys4uwiOPJjg== 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-SenderADCheck; bh=G4kpnwOS3xntJ1KwiYzr87/vynQGN1kpqOrKSZgVTSg=; b=Rp/pfutCWkQhBnp+qQq4k+2FFqHrTEv8A/zUzn+8rUUOaGABRvJTVQAcDBa2Kio+3mNFf1KAcJ1IYcten6p7bQ3h/q+cPgrysKaRhnJSGZeD4xGpJHNvbIFIKsM2pCosukCufDsqDVyhHDRxKBAMw+Me2C/ceFO8aE3BoXegLtxFJuGO6/4zy7FtYA3R9ntCGlsv8GMT0ibXRyMx94TaM8AiRoX1J04sCTBAXoCEHCSOdJDjZsbuXRqgb2jTvG/sHZH0THnaPz4NejA7k4KKwy5LUjVq4arIT0miBUnCSPPnjcLVbKh/ULdU1wU4BriH1N8hrKV3Y8vIegJY58i/fg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G4kpnwOS3xntJ1KwiYzr87/vynQGN1kpqOrKSZgVTSg=; b=cQDb/w+qUpiFuM+VljwIh4Z3EvTueqkYzpzqBW0abE4Hilxck/9PMZHZWJ4dKlooU53TvGA6pRyVdkdKWaJ3z3DLULT/aX28wNA6F808Pr00dHIB8TtuORmlSEWFZo2Aq7S1cUn2NAr4WtEGFAWRfGm9Y59tyxa3usn+H6UMctk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3583.EURPRD10.PROD.OUTLOOK.COM (10.186.160.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Thu, 26 Mar 2020 11:43:15 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7%5]) with mapi id 15.20.2835.023; Thu, 26 Mar 2020 11:43:15 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Jagan Teki , Vignesh R , Rasmus Villemoes Subject: [PATCH 1/3] mtd: spi-nor: don't guard stm_*lock* family by preprocessor conditionals Date: Thu, 26 Mar 2020 12:42:55 +0100 Message-Id: <20200326114257.1782-2-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200326114257.1782-1-rasmus.villemoes@prevas.dk> References: <20200326114257.1782-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR10CA0092.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::33) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR10CA0092.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18 via Frontend Transport; Thu, 26 Mar 2020 11:43:15 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c227d1cd-a63c-48aa-2ed5-08d7d17adefc X-MS-TrafficTypeDiagnostic: VI1PR10MB3583: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-Forefront-PRVS: 0354B4BED2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(39840400004)(366004)(136003)(376002)(396003)(54906003)(956004)(81166006)(316002)(1076003)(16526019)(107886003)(6916009)(8676002)(6486002)(86362001)(81156014)(186003)(5660300002)(8936002)(44832011)(6512007)(4326008)(8976002)(36756003)(2616005)(6506007)(6666004)(52116002)(478600001)(2906002)(26005)(66946007)(66556008)(66476007)(3714002); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3583; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pN1XIVOEK4gLIGey8cxuj9J+p9+/LuXpwNBfqLvb7+Bp4ymNmMdU+PITf41FLdwO2dKJkOlpSPo1r+ctvGfCpZXWJEN696poOQjj2L6IEZJ5+7TpdfT1GqBnKD4XjLqpeZ4WFYDj5BeoCGPRxl1jMNj8nf6gwJOWCTfan0/0CtCy0vajOwKpRZ0+BlASRVe9xUd7XzqMIdfXhO57l5SWfDEf93WARU4cz2tZ9wwGoioSo/t7j/x6bFO3iTThr25xOjRp5pxpYhnUx0Tj9NGzxwnoE5BqIk7V+XoTRNQGNwSUzwr7XUORZ3yWPLXoaAyu2hg0n+5EQOxf23TgBmUtNLBPVBeHrkXXj+XGImV10iWK4G0BoTr/tSB8al44tMla8ytGCLypEeiprm1CeKDfwZh8QDmF7PbmI3aCgKMncildtwvQCpUbx8VUOHLdzk0tJXddeHCwFXfqDx95cv9xtz6Nx+bj0tjjv0JDJh8fC8I= X-MS-Exchange-AntiSpam-MessageData: ST5+WI1S6+SaTmVLGvcgJIqlQm9Y/zzkpezNJrj4kO7E1REQvzeYIXiWTKzQWdAaXquRNFGTg79vXcxb2Fgz1dFWWvrBjizCLsgT9LbvxG/jZy4sd3fpWliZCLB+9z3a86uFHMFDCUeqPbYErrGw1g== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: c227d1cd-a63c-48aa-2ed5-08d7d17adefc X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2020 11:43:15.4428 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: epz5hISd5dRaSHGP2nTjgs0xnf+TRqSjq5MNCmEZ7GmBGm2iHQ4d63LGDWyJWMQwICSZVAk4T5hXO5MUfqDDS21Wtr5XAp8yIwVzS8/GxXc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3583 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean Use C instead of cpp to choose whether the stm_lock and friends get compiled in. This provides better compile testing and reduces the amount of #ifdeffery. All of the previously guarded functions are static, so this does not add anything to the binary in the !(SPI_FLASH_STMICRO or SPI_FLASH_SST) case (and even if they were not static, the linker would eventually remove them). The test of SPI_FLASH_STMICRO or SPI_FLASH_SST is done inside the test for specific manufacturers or SPI_NOR_HAS_LOCK in flags, to prepare for adding support for locking on Macronix flashes. The compiler is perfectly capabable of compiling if (expression with no side effects) { if (0) { } } to nothing at all. Signed-off-by: Rasmus Villemoes --- drivers/mtd/spi/spi-nor-core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index 7b6ad495ac..af83d813fc 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -591,7 +591,6 @@ erase_err: return ret; } -#if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST) /* Write status register and ensure bits in mask match written values */ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) { @@ -877,7 +876,6 @@ static int stm_is_locked(struct spi_nor *nor, loff_t ofs, uint64_t len) return stm_is_locked_sr(nor, ofs, len, status); } -#endif /* CONFIG_SPI_FLASH_STMICRO */ static const struct flash_info *spi_nor_read_id(struct spi_nor *nor) { @@ -2528,17 +2526,17 @@ int spi_nor_scan(struct spi_nor *nor) mtd->_erase = spi_nor_erase; mtd->_read = spi_nor_read; -#if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST) /* NOR protection support for STmicro/Micron chips and similar */ if (JEDEC_MFR(info) == SNOR_MFR_ST || JEDEC_MFR(info) == SNOR_MFR_MICRON || JEDEC_MFR(info) == SNOR_MFR_SST || info->flags & SPI_NOR_HAS_LOCK) { - nor->flash_lock = stm_lock; - nor->flash_unlock = stm_unlock; - nor->flash_is_locked = stm_is_locked; + if (IS_ENABLED(CONFIG_SPI_FLASH_STMICRO) || IS_ENABLED(CONFIG_SPI_FLASH_SST)) { + nor->flash_lock = stm_lock; + nor->flash_unlock = stm_unlock; + nor->flash_is_locked = stm_is_locked; + } } -#endif #ifdef CONFIG_SPI_FLASH_SST /* From patchwork Thu Mar 26 11:42:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1261954 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=OoG+B6P+; dkim-atps=neutral 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48p36c0hs3z9sQx for ; Thu, 26 Mar 2020 22:44:07 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0A7E681851; Thu, 26 Mar 2020 12:43:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk 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=prevas.dk header.i=@prevas.dk header.b="OoG+B6P+"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1D6B681834; Thu, 26 Mar 2020 12:43: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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0704.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::704]) (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 47CE280111 for ; Thu, 26 Mar 2020 12:43:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dlLtR1MtK03BU2Q+5kZAuTTToEK2z7BCS5ciHyf8BegjhO2WpSseQZZjBvUr1RoTOA00hoXRgxUcyW0uB9THWTVFDVIRT19KlPCzzu4DplX6BPpG3quFQA6nlgJS/7gkH4mxzJCRirYts5IRJHq+iFGdILNexJ79/bUOkpAaaLejtSus1BQ2K2jjqeShH50FAMHA1rlWEjSLMG2TrkCpLgN8/yyWhrhnTxabsS7Xualumzl5F+urfbSik6D7lc0Kf/IgLxyO28rovMNkyDgFD5NByKU0lFst8Qm4WyuW/hmc30c9OFgVQTTPqMXx9nGdBQflNcc/ytO3bKUYSo/OpA== 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-SenderADCheck; bh=gnafPcPXQgmUxdANJ+2OHwmVcyLW+/q+TsO0GgZLZ6E=; b=CSOY0qm74fV9NZWr0CoZhfLXiqd2AguhhBZzLR57/K+bfpSQUqscp4mubXgyKazxKSc7Wd1P6oJ5AC1azH238JUkrR3Un88mPH8TWUWf7k81CzC5WKFms6w58Ubuipr3xx+QSF2UEnDwKt9A25wa2JwQXUHu9eHpSNE+AYTqdgTPvfNqfN6qr/vFxCYV/aowAkVCWV1uzcJe9HQJf+RFKdbKiOv82K4CKNbfZctN4CSx/PF764jXJTn+p6yLtjx4KGQJslpxvQJpBE5Fet3GupZwyk9Hzc3nQPDYk048Nyp1qBFUPSoWVPE+r1Kp22+vzor/e52qB8ldXiurPhAeZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gnafPcPXQgmUxdANJ+2OHwmVcyLW+/q+TsO0GgZLZ6E=; b=OoG+B6P+3PA0x2MOOfGNHqsoS8a5srz7Z3C+/ZDTI44sQzbhfbzXJfbZtw1zh9QJW0RWL06ksP2jlsZcJF+xTITqalrpnS3hptfJiYO9zJkf0frd0XG8UrtYY4gimXmud57X+hyw7lW+eEsUOjLmpAlRSeBBij9uKSHpEvQRAVA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3583.EURPRD10.PROD.OUTLOOK.COM (10.186.160.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Thu, 26 Mar 2020 11:43:16 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7%5]) with mapi id 15.20.2835.023; Thu, 26 Mar 2020 11:43:16 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Jagan Teki , Vignesh R , Rasmus Villemoes Subject: [PATCH 2/3] mtd: spi-nor: add support for locking on Macronix nor flashes Date: Thu, 26 Mar 2020 12:42:56 +0100 Message-Id: <20200326114257.1782-3-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200326114257.1782-1-rasmus.villemoes@prevas.dk> References: <20200326114257.1782-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR10CA0092.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::33) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR10CA0092.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18 via Frontend Transport; Thu, 26 Mar 2020 11:43:15 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9a8a242b-9f85-4cab-7736-08d7d17adf4d X-MS-TrafficTypeDiagnostic: VI1PR10MB3583: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0354B4BED2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(39840400004)(366004)(136003)(376002)(396003)(54906003)(956004)(81166006)(316002)(1076003)(16526019)(107886003)(6916009)(8676002)(6486002)(86362001)(81156014)(186003)(5660300002)(8936002)(44832011)(6512007)(4326008)(8976002)(36756003)(2616005)(6506007)(6666004)(52116002)(478600001)(2906002)(26005)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3583; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wWf/i4C6s546NL4JZ6KeJE1xcX5oGYzefb6Yl2XeiDCz66/JQdaqhnO+/FA7/AFNw7H9rAruh2I74zbPkbUb8PTNZI9K5lTAM7ODlkolCKqZzRqoYOQXiSKGItoew0Itp0b4O5VaVsfzCqqUT0cvTJD91TH0NvWcKQP3Ffy3RBcuDtLuoWhxS5wAGWmwiDIQOszStouzeUVF2IaXjPF2BM40NwocIahBTwv6sieEQ3duteosR+DLF2DzoUKV9V92/aOXndtotzwc//qTMFF6sq8mmW6zeUbGy+J5ylPb76I1wQH3/NkdDr3KPEOfmjK0YO9F+O62tSV98mULWa8yiXEJSOdYGtqEl5x7M+aA3Qv3KOj6+uD52EOjhr2ND1osMb8coZJCAF5669Ai/GYOY1etCspyZ7Zdc55+6aFfC2mP1sby2oPq0TGzLl6WSvO4 X-MS-Exchange-AntiSpam-MessageData: zSrnrftCxbRRty5TKROsG+CzJa6Cfv39T655xTSYz11ZjbGiMiC7ao+m6HtKjaoknBfSyW9sWbWHFm70wHUVwxOICB+/AFMNVA0gLjxRZOVmufyPO77gewF1K9CzncSTJCTH2sBEEzmSI5QKaKE3Ew== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 9a8a242b-9f85-4cab-7736-08d7d17adf4d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2020 11:43:15.9895 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Xbrf27Pqy+t+iDdL3remYnQJFSY6McTvJgzoWyYxJmBGldfRRWMe0YtrsbkG5hIFPMeIkn1dI6mDkUm7tiErU5OnZiLP8vDx/dNspgWOCew= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3583 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean 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). These differences from the stm_* lock family means that most of it needs to be reimplemented. Doing the combined write of the status and configuration registers via write_sr_cr() could be reused, though, so this lifts that function from inside #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND) - it will get eliminated as dead code if neither of those or CONFIG_SPI_FLASH_MACRONIX are set. Signed-off-by: Rasmus Villemoes --- drivers/mtd/spi/spi-nor-core.c | 258 +++++++++++++++++++++++++++++---- include/linux/mtd/spi-nor.h | 3 + 2 files changed, 231 insertions(+), 30 deletions(-) diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index af83d813fc..40bf2d5de5 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -591,6 +591,229 @@ erase_err: return ret; } +/* + * 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 negative if error occurred. + */ +static int 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; + } + + 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; +} + +/* + * 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; + u8 mask = SR_BP3 | SR_BP2 | SR_BP1 | SR_BP0; + int shift = ffs(mask) - 1; + int pow; + + pow = ((sr & mask) >> shift) - 1; + if (pow < 0) { + /* No protection */ + *ofs = 0; + *len = 0; + return; + } + *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; +} + +/* + * 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; + uint64_t 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); + else + /* 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; + u8 sr_cr[2]; + u8 mask = SR_BP3 | SR_BP2 | SR_BP1 | SR_BP0; + u8 shift = ffs(mask) - 1, val; + loff_t lock_len, blocks; + bool can_be_top, can_be_bottom; + bool use_top; + + sr = read_sr(nor); + if (sr < 0) + return sr; + + cr = mx_read_cr(nor); + if (cr < 0) + return cr; + + /* 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 = 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_locked(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, true); +} + /* Write status register and ensure bits in mask match written values */ static int write_sr_and_check(struct spi_nor *nor, u8 status_new, u8 mask) { @@ -1324,35 +1547,6 @@ static int macronix_quad_enable(struct spi_nor *nor) #endif #if defined(CONFIG_SPI_FLASH_SPANSION) || defined(CONFIG_SPI_FLASH_WINBOND) -/* - * 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 negative if error occurred. - */ -static int 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; - } - - return 0; -} - /** * spansion_read_cr_quad_enable() - set QE bit in Configuration Register. * @nor: pointer to a 'struct spi_nor' @@ -2531,7 +2725,11 @@ int spi_nor_scan(struct spi_nor *nor) JEDEC_MFR(info) == SNOR_MFR_MICRON || JEDEC_MFR(info) == SNOR_MFR_SST || info->flags & SPI_NOR_HAS_LOCK) { - if (IS_ENABLED(CONFIG_SPI_FLASH_STMICRO) || IS_ENABLED(CONFIG_SPI_FLASH_SST)) { + if (IS_ENABLED(CONFIG_SPI_FLASH_MACRONIX) && JEDEC_MFR(info) == SNOR_MFR_MACRONIX) { + nor->flash_lock = mx_lock; + nor->flash_unlock = mx_unlock; + nor->flash_is_locked = mx_is_locked; + } else if (IS_ENABLED(CONFIG_SPI_FLASH_STMICRO) || IS_ENABLED(CONFIG_SPI_FLASH_SST)) { nor->flash_lock = stm_lock; nor->flash_unlock = stm_unlock; nor->flash_is_locked = stm_is_locked; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index ec144a08d8..6ceac009eb 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -62,6 +62,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 */ @@ -131,6 +132,7 @@ #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(5) /* Block protect 3 (Macronix) */ #define SR_TB BIT(5) /* Top/Bottom protect */ #define SR_SRWD BIT(7) /* SR write protect */ /* Spansion/Cypress specific status bits */ @@ -150,6 +152,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 Thu Mar 26 11:42:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1261953 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=D6y9/FVc; dkim-atps=neutral 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 RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48p36P3M6Jz9sQx for ; Thu, 26 Mar 2020 22:43:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5542A81834; Thu, 26 Mar 2020 12:43:41 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk 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=prevas.dk header.i=@prevas.dk header.b="D6y9/FVc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4C1CB81264; Thu, 26 Mar 2020 12:43: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=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0704.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::704]) (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 7F4C981264 for ; Thu, 26 Mar 2020 12:43:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PkSUWgZ4FwyWwAVY+lXvsradWc8yqsKbmySA7Eblm09xsY6DU2AuHeb3Snkde+PFdOptMTFEs+nAu7qJzngLpAbmt325YXYzUpx+9NgjFuPNViFYVuJYe4jbRZnBStK/n7nJJy/KhBEv1Vni0t5EEJOIFQFPBXeL1J+sMofstrqjJ8YFIm+trwQoerusckymDoYalPRlMTPIBzmuqRPS5uv6+bnNEIwR9PMqF7+0Vzbjhe3tV159vhnUTEN/dM8zwD5FIiXFQbRRye/0gQ2NNATzqoByVnfQUhU2IVslZq266mrK5mUb5bsEgdYGfRIPn3sWxBfimUUWPLl9XrpDsw== 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-SenderADCheck; bh=X4b0P6AXF8p3K1ejXf3rUjYrZodRFhaa+W6f08OK9ow=; b=eXXaRdB6mYRDQ1rdQ697olMcKl37aFjLy/YDEPAgxkdO5CMe2urOhQwaayIrUqh90aw3K91KQWqGaaRMjBJNeuaVrGkMsiO/QLFMvPbP0w90j6ZtpLzrR8eSwzFInfnixxSS0I9Z30BPCpmPaRxtlnpl50GWCQnXWijDxhhs1Q41tNNeQNN/ZbiaeBzTOUoGws6LE6ltEcF8eMGIa/CXK9HPewsLR1dx80a1GaNGFN5DAgS4fb3048Rd1jCU16Etvx9bEjGho3znj7NdzSmd0IoGbrrittgm1mg+RZIygjS/uTCHU5fFiMfxULISMH9FELrewmxbqtNysgDmcdRS4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X4b0P6AXF8p3K1ejXf3rUjYrZodRFhaa+W6f08OK9ow=; b=D6y9/FVcdiUpC9wWs6V7F3uNTydzLZpq6B+usEIVRbEIi9mFICWv5X2uAYWc7QYgspn2eG8DGyAEKULkozx5r4XEDXgwyQi4st+anWiRFMohwRgB7wFr1StihQiHLRUgg7mfNTpl3BE/YmiprAm1jYrLh12YSctXM8U48b7FZ2k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3583.EURPRD10.PROD.OUTLOOK.COM (10.186.160.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Thu, 26 Mar 2020 11:43:16 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7%5]) with mapi id 15.20.2835.023; Thu, 26 Mar 2020 11:43:16 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Jagan Teki , Vignesh R , Rasmus Villemoes Subject: [PATCH 3/3] mtd: spi-nor: set SPI_NOR_HAS_LOCK for Macronix mx25l3205d Date: Thu, 26 Mar 2020 12:42:57 +0100 Message-Id: <20200326114257.1782-4-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200326114257.1782-1-rasmus.villemoes@prevas.dk> References: <20200326114257.1782-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: AM6PR10CA0092.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::33) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6PR10CA0092.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18 via Frontend Transport; Thu, 26 Mar 2020 11:43:16 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 103570f5-7848-4d1f-04ac-08d7d17adfa3 X-MS-TrafficTypeDiagnostic: VI1PR10MB3583: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0354B4BED2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(346002)(39840400004)(366004)(136003)(376002)(396003)(54906003)(956004)(81166006)(316002)(1076003)(16526019)(107886003)(6916009)(8676002)(6486002)(86362001)(81156014)(186003)(5660300002)(8936002)(44832011)(6512007)(4326008)(8976002)(36756003)(2616005)(6506007)(6666004)(52116002)(478600001)(2906002)(26005)(66946007)(66556008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3583; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QB+QHfYEBbWLcxpF233mq5ESoyi5SDcfn9sIz10hmTfPBiCwxz0CbaBWvYcS9x7tSlPMqfKP2WzvgqlV9sCuh1fuwTlU6QiY0XmyAxobtrh0hl53Kh4+ak8dX9VYmhUCc9H3Gp08PtPQ7PFywi6tl27zzRZG18GjsbOmVl9h/gG2TCVbkqgvj3+OF83OzjRe2eZ/2slOoKqvdsk7UbJDXTyYZ2XpwHMfNV6a+5ue+ah5DMJypjnvroLqiS9UB9RDEk6s3jcL4YdR/ksWbYpz6oXEUbXJCO98uTbbGGCeouc5Vmsyk4Xi7UPFbcYYTXzP9z07NsoKyE18l5sjsMls5NckrAF55l58ov/1N7x6veDdz7+DiIsOz0T/XZWxamlUBCoMZacJYXfhYncSpB699xSxGHv0jzMM6dCTDR4IpOlumr7jD8UtPMrVEH+LVgmP X-MS-Exchange-AntiSpam-MessageData: 3VkVG199Cc1oJyKtlgIZFlPzirEVAGtTsacsbd9jfht4/13Oxycm6bByp+zv1hj/w3Z0LjSVUrsOHKUEneERTZhZVw94pJ8pYnzeDXiIpxIEkUEaF6aUGXXI+NW0cEOSfX3VuBujc6a4exblCyGhww== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 103570f5-7848-4d1f-04ac-08d7d17adfa3 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2020 11:43:16.6031 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eXwg3LYa4Uneaa6LKyFaBTLhCKMVdu8pGA6mUQTdlXfcVbljClVGWAP9C9PldU71d5rgOvgdpLk2AY0NnrlVSGRKu36OW5RL3NiTnCfI21M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3583 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean This sets the SPI_NOR_HAS_LOCK for the mx25l3205d nor flash, to enable use of the "sf protect" subcommand for that. Reading the data sheets for various other Macronix flashes suggest they should also be able to use the new mx_* lock functions, but this is the chip I've tested them on. Signed-off-by: Rasmus Villemoes --- drivers/mtd/spi/spi-nor-ids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/spi/spi-nor-ids.c b/drivers/mtd/spi/spi-nor-ids.c index 973b6f86c9..5beb3cb3ad 100644 --- a/drivers/mtd/spi/spi-nor-ids.c +++ b/drivers/mtd/spi/spi-nor-ids.c @@ -143,7 +143,7 @@ const struct flash_info spi_nor_ids[] = { { INFO("mx25l4005a", 0xc22013, 0, 64 * 1024, 8, SECT_4K) }, { INFO("mx25l8005", 0xc22014, 0, 64 * 1024, 16, 0) }, { INFO("mx25l1606e", 0xc22015, 0, 64 * 1024, 32, SECT_4K) }, - { INFO("mx25l3205d", 0xc22016, 0, 64 * 1024, 64, SECT_4K) }, + { INFO("mx25l3205d", 0xc22016, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) }, { INFO("mx25l6405d", 0xc22017, 0, 64 * 1024, 128, SECT_4K) }, { INFO("mx25u2033e", 0xc22532, 0, 64 * 1024, 4, SECT_4K) }, { INFO("mx25u1635e", 0xc22535, 0, 64 * 1024, 32, SECT_4K) },