Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp396010pxk; Fri, 11 Sep 2020 09:46:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtkFx8L05cU7gT4ibhyZUmnG3RafBqTfEIT+OdyiGupsA37qcM6ipmeylIBwGKQsfqv0Sg X-Received: by 2002:a17:906:819:: with SMTP id e25mr2963231ejd.211.1599842811515; Fri, 11 Sep 2020 09:46:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599842811; cv=none; d=google.com; s=arc-20160816; b=xFyqfd4UJTjFuMoEGAla86kh1jKxMSd2/yCVjBsh4GJHFd3XSsvTD/zGOTiIXKVEtu kvFbclTieL0Es3VHIn/RIneVolOmQcGodDQ6ZLfSjBX8sAu59AEEuyBMGQiQ8P050bEl tLcssp/rm4ghpCehDf6oqY47802gZRHixh+R0jn1XXFEgfx9LyPP8Hwzf/VjeBv1yu3l oqMO1p7pKjJ19OCYar3F3kEqF+fa7rJZ//JeeG9NrEj9sEoWV5/CP+bnzOmd49ZHu9Wq 3gJBDIygWfuLQjHJrFzyhs+QDkpwVAhWJ5o1OTTm5k/DcAFq/chslNWKADcjl0hygnJR wCSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rjOYDFw/0PgwSdS6G8jRvupzdnGMANqHRLdp9SPFEbQ=; b=R4GgOKdbjnhMb2cKBJv6Or/ICcVA/UCKMILz3E6iD8Q7jnxiIAmYFa7Vzgy3Ypu6uV 2PH+1AW1UVdB+JK1HhMWCiPngoD7mLe43BM4pGXv0jNh/TMq/bkan3NvQd1cuKnL0Pp+ ci3klIY3FvqQ3RHUuJsXjbmhqRMqZyjeMg5b9pXN0IF85khdHVceAAbcR7s+bgavHQUB oh/nEu/AmhDSXkK3oFvZqFal4kF9ZtFcHKwswSPuQmXTnQPtbBYkFklss5DW65Di+hmU rCdgLVpAY0TKOlusmtZ0YVbcz6dQuV722eqy5tyWCfQS6kr/hNip7B3u5gRV3vzaXHTi qC3A== ARC-Authentication-Results: i=1; mx.google.com; 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 p16si1643059ejw.31.2020.09.11.09.46.27; Fri, 11 Sep 2020 09:46:51 -0700 (PDT) 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; 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 S1726224AbgIKQpw (ORCPT + 99 others); Fri, 11 Sep 2020 12:45:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgIKPIN (ORCPT ); Fri, 11 Sep 2020 11:08:13 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BA72C0612ED for ; Fri, 11 Sep 2020 07:47:21 -0700 (PDT) Received: from dude02.hi.pengutronix.de ([2001:67c:670:100:1d::28]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kGkKU-0006Pw-NV; Fri, 11 Sep 2020 16:47:10 +0200 Received: from mfe by dude02.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1kGkKP-0006nh-4Z; Fri, 11 Sep 2020 16:47:05 +0200 From: Marco Felsch To: tudor.ambarus@microchip.com, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sergei.shtylyov@cogentembedded.com, boris.brezillon@collabora.com, michael@walle.cc, j.neuschaefer@gmx.net Cc: linux-mtd@lists.infradead.org, kernel@pengutronix.de, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] mtd: spi-nor: sst: move sst_write_second to local driver Date: Fri, 11 Sep 2020 16:47:03 +0200 Message-Id: <20200911144703.25409-4-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> References: <20200911144703.25409-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::28 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't mess the spi-nor core with details only relating to this specific device. Handle the addr_width locally and drop the sst related stuff from the spi-nor core to clean it up. Signed-off-by: Marco Felsch --- drivers/mtd/spi-nor/core.c | 3 --- drivers/mtd/spi-nor/sst.c | 10 ++++++---- include/linux/mtd/spi-nor.h | 2 -- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 31869ac245a8..fabd8ca4e801 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -173,9 +173,6 @@ static ssize_t spi_nor_spimem_write_data(struct spi_nor *nor, loff_t to, op.addr.buswidth = spi_nor_get_protocol_addr_nbits(nor->write_proto); op.data.buswidth = spi_nor_get_protocol_data_nbits(nor->write_proto); - if (nor->program_opcode == SPINOR_OP_AAI_WP && nor->sst_write_second) - op.addr.nbytes = 0; - if (spi_nor_spimem_bounce(nor, &op)) memcpy(nor->bouncebuf, buf, op.data.nbytes); diff --git a/drivers/mtd/spi-nor/sst.c b/drivers/mtd/spi-nor/sst.c index 644252e27a2a..7ca7e1a13511 100644 --- a/drivers/mtd/spi-nor/sst.c +++ b/drivers/mtd/spi-nor/sst.c @@ -58,10 +58,9 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) goto out; - nor->sst_write_second = false; - /* Start write from odd address. */ if (to % 2) { + nor->addr_width = 3; nor->program_opcode = SPINOR_OP_BP; /* write one byte. */ @@ -86,6 +85,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, goto out; } + /* Send address only once for each AAI_WP cycle */ + nor->addr_width = (actual > 1) ? 0 : 3; nor->program_opcode = SPINOR_OP_AAI_WP; /* write two bytes. */ @@ -97,9 +98,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) goto out; to += 2; - nor->sst_write_second = true; } - nor->sst_write_second = false; ret = spi_nor_write_disable(nor); if (ret) @@ -115,6 +114,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, if (ret) goto out; + nor->addr_width = 3; nor->program_opcode = SPINOR_OP_BP; ret = spi_nor_write_data(nor, to, 1, buf + actual); if (ret < 0) @@ -129,6 +129,8 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, ret = spi_nor_write_disable(nor); } out: + /* Set to default in case no trailing bytes are written */ + nor->addr_width = 3; *retlen += actual; spi_nor_unlock_and_unprep(nor); return ret; diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h index 60bac2c0ec45..4368c0c41fda 100644 --- a/include/linux/mtd/spi-nor.h +++ b/include/linux/mtd/spi-nor.h @@ -343,7 +343,6 @@ struct spi_nor_flash_parameter; * @read_opcode: the read opcode * @read_dummy: the dummy needed by the read operation * @program_opcode: the program opcode - * @sst_write_second: used by the SST write operation * @flags: flag options for the current SPI NOR (SNOR_F_*) * @read_proto: the SPI protocol for read operations * @write_proto: the SPI protocol for write operations @@ -374,7 +373,6 @@ struct spi_nor { enum spi_nor_protocol read_proto; enum spi_nor_protocol write_proto; enum spi_nor_protocol reg_proto; - bool sst_write_second; u32 flags; const struct spi_nor_controller_ops *controller_ops; -- 2.20.1