From patchwork Wed Feb 3 13:26:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyrille Pitchen X-Patchwork-Id: 8203181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D5E1F9F38B for ; Wed, 3 Feb 2016 13:33:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0690520253 for ; Wed, 3 Feb 2016 13:33:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2D7DD201F2 for ; Wed, 3 Feb 2016 13:33:06 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQxWn-0003tU-R2; Wed, 03 Feb 2016 13:31:25 +0000 Received: from eusmtp01.atmel.com ([212.144.249.243]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aQxVV-0008Qs-PT; Wed, 03 Feb 2016 13:30:46 +0000 Received: from tenerife.corp.atmel.com (10.161.101.13) by eusmtp01.atmel.com (10.161.101.31) with Microsoft SMTP Server id 14.3.235.1; Wed, 3 Feb 2016 14:29:47 +0100 From: Cyrille Pitchen To: , Subject: [PATCH v3 07/14] mtd: spi-nor: fix support of Spansion memories Date: Wed, 3 Feb 2016 14:26:52 +0100 Message-ID: X-Mailer: git-send-email 1.8.2.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160203_053006_944757_FF79BE57 X-CRM114-Status: GOOD ( 10.86 ) X-Spam-Score: -4.6 (----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marex@denx.de, boris.brezillon@free-electrons.com, vigneshr@ti.com, pawel.moll@arm.com, devicetree@vger.kernel.org, ijc+devicetree@hellion.org.uk, nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org, robh+dt@kernel.org, galak@codeaurora.org, mark.rutland@arm.com, Cyrille Pitchen , linux-arm-kernel@lists.infradead.org, beanhuo@micron.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is only a transitional one. It concludes the series of patches to select op codes and protocols by manufacturer. Signed-off-by: Cyrille Pitchen --- drivers/mtd/spi-nor/spi-nor.c | 53 ++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 6785e699106d..f9dd1fd3f53c 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -1439,10 +1439,35 @@ static int micron_set_single_mode(struct spi_nor *nor) return 0; } -static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info) +static int spansion_set_quad_mode(struct spi_nor *nor) { int status; + status = spansion_quad_enable(nor); + if (status) { + dev_err(nor->dev, "Spansion quad-read not enabled\n"); + return -EINVAL; + } + nor->read_proto = SNOR_PROTO_1_1_4; + nor->read_opcode = SPINOR_OP_READ_1_1_4; + return 0; +} + +static int spansion_set_dual_mode(struct spi_nor *nor) +{ + nor->read_proto = SNOR_PROTO_1_1_2; + nor->read_opcode = SPINOR_OP_READ_1_1_2; + return 0; +} + +static int spansion_set_single_mode(struct spi_nor *nor) +{ + nor->read_proto = SNOR_PROTO_1_1_1; + return 0; +} + +static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info) +{ switch (JEDEC_MFR(info)) { case SNOR_MFR_MACRONIX: return macronix_set_quad_mode(nor); @@ -1454,20 +1479,13 @@ static int set_quad_mode(struct spi_nor *nor, const struct flash_info *info) return micron_set_quad_mode(nor); case SNOR_MFR_SPANSION: - status = spansion_quad_enable(nor); - if (status) { - dev_err(nor->dev, "Spansion quad-read not enabled\n"); - return -EINVAL; - } - nor->read_proto = SNOR_PROTO_1_1_4; - break; + return spansion_set_quad_mode(nor); default: - return -EINVAL; + break; } - nor->read_opcode = SPINOR_OP_READ_1_1_4; - return 0; + return -EINVAL; } static int set_dual_mode(struct spi_nor *nor, const struct flash_info *info) @@ -1482,13 +1500,14 @@ static int set_dual_mode(struct spi_nor *nor, const struct flash_info *info) case SNOR_MFR_MICRON: return micron_set_dual_mode(nor); + case SNOR_MFR_SPANSION: + return spansion_set_dual_mode(nor); + default: - nor->read_proto = SNOR_PROTO_1_1_2; break; } - nor->read_opcode = SPINOR_OP_READ_1_1_2; - return 0; + return -EINVAL; } static int set_single_mode(struct spi_nor *nor, const struct flash_info *info) @@ -1503,12 +1522,14 @@ static int set_single_mode(struct spi_nor *nor, const struct flash_info *info) case SNOR_MFR_MICRON: return micron_set_single_mode(nor); + case SNOR_MFR_SPANSION: + return spansion_set_single_mode(nor); + default: - nor->read_proto = SNOR_PROTO_1_1_1; break; } - return 0; + return -EINVAL; } static int spi_nor_check(struct spi_nor *nor)