From patchwork Fri Dec 7 09:26:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 1009296 X-Patchwork-Delegate: tudor.ambarus@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="D4ia5jPi"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43B6ty5725z9s3q for ; Fri, 7 Dec 2018 20:42:02 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=LSWAQa/6h5/JVuLN/TGEre+HyK5T3o+78mcxAHSj4fE=; b=D4ia5jPikqkN28Jv1st+I7UTgO wP6u6N/zyE3lOqUJ6LlC+x2Df/bzMetuMLEp1wnfkG70u9JFHtfoeuyNlrNOxwjfFD5F7l08Z0D74 wBfuVCaD6QZOAEaQDj+3MJBNl0R38kfgz0Qv/hlO19LsrTzp6jXXgnbdUVMNjnkWd8PVtWOnIgpYL 17DeX8BecYClkAcGH8aMPPqWjUcx6/9vlQSPFxf/V/KYHX5M0/JowPgA1ElwYEISewIgy/CotBjZ9 DIv0IHjf3pPpKoOxN6Qx21JFstbNpq+kS9e5tB5hOSCQbQwCKtv1mhXYs3auS2zaqxpLfnyCkKyfn 6YgbMHpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVCds-0006PO-Or; Fri, 07 Dec 2018 09:41:52 +0000 Received: from mail.bootlin.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVCPv-0001KW-Au for linux-mtd@lists.infradead.org; Fri, 07 Dec 2018 09:27:46 +0000 Received: by mail.bootlin.com (Postfix, from userid 110) id DF01D20717; Fri, 7 Dec 2018 10:26:52 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.2 Received: from localhost.localdomain (aaubervilliers-681-1-79-44.w90-88.abo.wanadoo.fr [90.88.21.44]) by mail.bootlin.com (Postfix) with ESMTPSA id 1C55220CFB; Fri, 7 Dec 2018 10:26:41 +0100 (CET) From: Boris Brezillon To: Tudor Ambarus , Marek Vasut Subject: [RFC PATCH 16/34] mtd: spi-nor: Move Atmel bits out of core.c Date: Fri, 7 Dec 2018 10:26:19 +0100 Message-Id: <20181207092637.18687-17-boris.brezillon@bootlin.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181207092637.18687-1-boris.brezillon@bootlin.com> References: <20181207092637.18687-1-boris.brezillon@bootlin.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181207_012728_556112_A75AA3C7 X-CRM114-Status: GOOD ( 15.99 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yogesh Narayan Gaur , Vignesh R , Richard Weinberger , Boris Brezillon , linux-mtd@lists.infradead.org, Miquel Raynal , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Create a SPI NOR manufacturer driver for Atmel chips, and move the Atmel definitions outside of core.c. Signed-off-by: Boris Brezillon --- drivers/mtd/spi-nor/Makefile | 1 + drivers/mtd/spi-nor/atmel.c | 47 +++++++++++++++++++++++++++++++++ drivers/mtd/spi-nor/core.c | 29 +++----------------- drivers/mtd/spi-nor/internals.h | 3 +++ 4 files changed, 54 insertions(+), 26 deletions(-) create mode 100644 drivers/mtd/spi-nor/atmel.c diff --git a/drivers/mtd/spi-nor/Makefile b/drivers/mtd/spi-nor/Makefile index 0d6c4967a445..fd8454d38b17 100644 --- a/drivers/mtd/spi-nor/Makefile +++ b/drivers/mtd/spi-nor/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 spi-nor-objs := core.o +spi-nor-objs += atmel.o obj-$(CONFIG_MTD_SPI_NOR) += spi-nor.o obj-$(CONFIG_MTD_SPI_NOR) += controllers/ diff --git a/drivers/mtd/spi-nor/atmel.c b/drivers/mtd/spi-nor/atmel.c new file mode 100644 index 000000000000..a700a17fdead --- /dev/null +++ b/drivers/mtd/spi-nor/atmel.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2005, Intec Automation Inc. + * Copyright (C) 2014, Freescale Semiconductor, Inc. + */ + +#include +#include + +#include "internals.h" + +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) }, + + { "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) }, + + { "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) }, + + { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) }, +}; + +static int atmel_post_sfdp_fixups(struct spi_nor *nor, + struct spi_nor_flash_parameter *params) +{ + nor->flags |= SNOR_F_CLR_SW_PROT_BITS; + + return 0; +} + +static const struct spi_nor_fixups atmel_fixups = { + .post_sfdp = atmel_post_sfdp_fixups, +}; + +const struct spi_nor_manufacturer spi_nor_atmel = { + .name = "atmel", + .parts = atmel_parts, + .nparts = ARRAY_SIZE(atmel_parts), + .fixups = &atmel_fixups, +}; diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0bdbedb464c1..28b0d46aa3a0 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1401,22 +1401,6 @@ static struct spi_nor_fixups mx25l25635_fixups = { * old entries may be missing 4K flag. */ static const struct flash_info spi_nor_ids[] = { - /* 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) }, - - { "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) }, - - { "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) }, - - { "at45db081d", INFO(0x1f2500, 0, 64 * 1024, 16, SECT_4K) }, - /* EON -- en25xxx */ { "en25f32", INFO(0x1c3116, 0, 64 * 1024, 64, SECT_4K) }, { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, @@ -1714,7 +1698,9 @@ static const struct flash_info spi_nor_ids[] = { { }, }; -static const struct spi_nor_manufacturer *manufacturers[0]; +static const struct spi_nor_manufacturer *manufacturers[] = { + &spi_nor_atmel, +}; static const struct flash_info * spi_nor_search_part_by_id(const struct flash_info *parts, unsigned int nparts, @@ -3394,11 +3380,6 @@ static void intel_post_sfdp_fixups(struct spi_nor *nor) nor->flags |= SNOR_F_CLR_SW_PROT_BITS; } -static void atmel_post_sfdp_fixups(struct spi_nor *nor) -{ - nor->flags |= SNOR_F_CLR_SW_PROT_BITS; -} - static void sst_post_sfdp_fixups(struct spi_nor *nor) { nor->flags |= SNOR_F_CLR_SW_PROT_BITS; @@ -3461,10 +3442,6 @@ spi_nor_manufacturer_post_sfdp_fixups(struct spi_nor *nor, return nor->manufacturer->fixups->post_sfdp(nor, params); switch (JEDEC_MFR(nor->info)) { - case SNOR_MFR_ATMEL: - atmel_post_sfdp_fixups(nor); - break; - case SNOR_MFR_INTEL: intel_post_sfdp_fixups(nor); break; diff --git a/drivers/mtd/spi-nor/internals.h b/drivers/mtd/spi-nor/internals.h index 5ed65f46333d..9ad903a51846 100644 --- a/drivers/mtd/spi-nor/internals.h +++ b/drivers/mtd/spi-nor/internals.h @@ -332,6 +332,9 @@ struct spi_nor_manufacturer { const struct spi_nor_fixups *fixups; }; +/* Manufacturer drivers. */ +extern const struct spi_nor_manufacturer spi_nor_atmel; + /* Core helpers. */ int en4_ex4_set_4byte(struct spi_nor *nor, bool enable); int en4_ex4_wen_set_4byte(struct spi_nor *nor, bool enable);