Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp60785pxu; Wed, 2 Dec 2020 15:04:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzP7go9D5T78xJQ59oMB5VlE97zAgs1Ytt9t+Bnr20PGRClJuKCiyRyvhkN+of/pHDTQd39 X-Received: by 2002:a17:907:b09:: with SMTP id h9mr66099ejl.155.1606950275779; Wed, 02 Dec 2020 15:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606950275; cv=none; d=google.com; s=arc-20160816; b=JLcQTPP+1V2Q5/Bxqn6eaH954uxgxmWZJhrTNEYbTexUo5dYmBhq1jlsOqbPko4oYM LFF9OyLAC64xL3h3a3dR7e4DB8ZFWgP5HJEJ/Jid4GGbc8xEld1PQqA9FIjfJf+CAi1V pYyYU9GdA1Fi1+Mhzv2smSe6hf4UqNqBPKGW0VAErW+SD8LzLQCxUAqb0zl9991+e41T HKujCn1Swzq4jtg9HAuAOqlazGFvtN6HQxCap7eL+N1oDm23q0JMLy2+eZPXgXtJEA8w 8YvHNFetAlH3izFvyUST2jVpcCKaBadKvbycvf1WGvr4UKH0e7qI1S+2uNGjZcOL1ZSs KjBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=h8vyz4gfxHCQveE4zBheV251F2GcWHVCtbO7K6jIi/E=; b=DpOdxPBw9dODQG2fRv49em6cN//JjtxQ+axPNlCxkFFgv1472zHSEieKvCNqF7gBgm 8YrgXXJNfwLeFNQl8K2wBGkAB6XlxH7z4yqu7b+HH/8XytYvE1Oc68e3knd6wwgxW0tn kqYVc4v6L0Ygfn60Up3Y+ifyapY+9/xwMlqY4+DiYU4FdkpYDJJRWL4b0LCIMMHOS6qH /cpxGX9/Wu/yTS4Vt/UE4MiZrlJNIItgJYHJO1a6/AuDpUi+/iPLzZyvjtJ18xbAB3MF 7VEzlyAQ9+dHDYK0CaGcdgFmlJ6uvGP4sEjyUsTBDxPtjE9nfHU5nceuMfDIzseeFu8r sMGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=o8rYhGD9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si36304ejw.262.2020.12.02.15.04.11; Wed, 02 Dec 2020 15:04:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=o8rYhGD9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388000AbgLBXBz (ORCPT + 99 others); Wed, 2 Dec 2020 18:01:55 -0500 Received: from ssl.serverraum.org ([176.9.125.105]:54799 "EHLO ssl.serverraum.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728499AbgLBXBl (ORCPT ); Wed, 2 Dec 2020 18:01:41 -0500 Received: from apollo.fritz.box (unknown [IPv6:2a02:810c:c200:2e91:6257:18ff:fec4:ca34]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id DF82C23E5D; Thu, 3 Dec 2020 00:00:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1606950059; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h8vyz4gfxHCQveE4zBheV251F2GcWHVCtbO7K6jIi/E=; b=o8rYhGD9ZiY8iFW+WR7XrIJSYQA1+B1Lo/qROrDM0rS8TN3/IVAPfcdzmrIVnPZ1ud4znJ P7mhgDfHQn6USXJQVhR+IDtPMKPIj+oWAPULP7eGuEd3Uj7mQNQZtKJs7d23KAUrTsvuEa CO4KfG5zVq6uOYZloO/T3bq/aAY3CYI= From: Michael Walle To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Tudor Ambarus , Boris Brezillon , Michael Walle Subject: [PATCH v7 3/7] mtd: spi-nor: atmel: remove global protection flag Date: Thu, 3 Dec 2020 00:00:36 +0100 Message-Id: <20201202230040.14009-4-michael@walle.cc> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201202230040.14009-1-michael@walle.cc> References: <20201202230040.14009-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is considered bad for the following reasons: (1) We only support the block protection with BPn bits for write protection. Not all Atmel parts support this. (2) Newly added flash chip will automatically inherit the "has locking" support and thus needs to explicitly tested. Better be opt-in instead of opt-out. (3) There are already supported flashes which doesn't support the locking scheme. So I assume this wasn't properly tested before adding that chip; which enforces my previous argument that locking support should be an opt-in. Remove the global flag and add individual flags to all flashes which supports BP locking. In particular the following flashes don't support the BP scheme: - AT26F004 - AT25SL321 - AT45DB081D Please note, that some flashes which are marked as SPI_NOR_HAS_LOCK just support Global Protection, i.e. not our supported block protection locking scheme. This is to keep backwards compatibility with the current "unlock all at boot" mechanism. In particular the following flashes doesn't have BP bits: - AT25DF041A - AT25DF321 - AT25DF321A - AT25DF641 - AT26DF081A - AT26DF161A - AT26DF321 Signed-off-by: Michael Walle Reviewed-by: Tudor Ambarus --- changes since v6: - none changes since v5: - none changes since v4: - none changes since v3/v2/v1: - there was no such version because this patch was bundled with another patch changes since RFC: - mention the flashes which just support the "Global Unprotect" in the commit message drivers/mtd/spi-nor/atmel.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c index 3f5f21a473a6..49d392c6c8bc 100644 --- a/drivers/mtd/spi-nor/atmel.c +++ b/drivers/mtd/spi-nor/atmel.c @@ -10,37 +10,27 @@ static const struct flash_info atmel_parts[] = { /* Atmel -- some are (confusingly) marketed as "DataFlash" */ - { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, - { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K) }, + { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at25fs040", INFO(0x1f6604, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) }, - { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K) }, - { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, - { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K) }, + { "at25df041a", INFO(0x1f4401, 0, 64 * 1024, 8, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at25df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at25df321a", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at25df641", INFO(0x1f4800, 0, 64 * 1024, 128, SECT_4K | SPI_NOR_HAS_LOCK) }, { "at25sl321", INFO(0x1f4216, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ) }, { "at26f004", INFO(0x1f0400, 0, 64 * 1024, 8, SECT_4K) }, - { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K) }, - { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) }, - { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, + { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K | SPI_NOR_HAS_LOCK) }, + { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K | SPI_NOR_HAS_LOCK) }, { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) }, }; -static void atmel_default_init(struct spi_nor *nor) -{ - nor->flags |= SNOR_F_HAS_LOCK; -} - -static const struct spi_nor_fixups atmel_fixups = { - .default_init = atmel_default_init, -}; - const struct spi_nor_manufacturer spi_nor_atmel = { .name = "atmel", .parts = atmel_parts, .nparts = ARRAY_SIZE(atmel_parts), - .fixups = &atmel_fixups, }; -- 2.20.1