From: Marco Felsch <m.felsch@pengutronix.de> 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 [thread overview] Message-ID: <20200911144703.25409-4-m.felsch@pengutronix.de> (raw) In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> 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 <m.felsch@pengutronix.de> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: Marco Felsch <m.felsch@pengutronix.de> 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, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 3/3] mtd: spi-nor: sst: move sst_write_second to local driver Date: Fri, 11 Sep 2020 16:47:03 +0200 [thread overview] Message-ID: <20200911144703.25409-4-m.felsch@pengutronix.de> (raw) In-Reply-To: <20200911144703.25409-1-m.felsch@pengutronix.de> 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 <m.felsch@pengutronix.de> --- 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 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-09-11 16:46 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-11 14:47 [PATCH 0/3] MTD: SST SPI-NOR fixes Marco Felsch 2020-09-11 14:47 ` Marco Felsch 2020-09-11 14:47 ` [PATCH 1/3] mtd: spi-nor: sst: fix write support for SST_WRITE marked devices Marco Felsch 2020-09-11 14:47 ` Marco Felsch 2020-09-14 12:00 ` Vignesh Raghavendra 2020-09-14 12:00 ` Vignesh Raghavendra 2020-09-16 9:36 ` Tudor.Ambarus 2020-09-16 9:36 ` Tudor.Ambarus 2020-09-11 14:47 ` [PATCH 2/3] mtd: spi-nor: sst: add missing write_enable Marco Felsch 2020-09-11 14:47 ` Marco Felsch 2020-09-11 14:47 ` Marco Felsch [this message] 2020-09-11 14:47 ` [PATCH 3/3] mtd: spi-nor: sst: move sst_write_second to local driver Marco Felsch 2020-11-24 20:35 ` [PATCH 0/3] MTD: SST SPI-NOR fixes Michael Auchter 2020-11-24 20:35 ` Michael Auchter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200911144703.25409-4-m.felsch@pengutronix.de \ --to=m.felsch@pengutronix.de \ --cc=boris.brezillon@collabora.com \ --cc=j.neuschaefer@gmx.net \ --cc=kernel@pengutronix.de \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ --cc=michael@walle.cc \ --cc=miquel.raynal@bootlin.com \ --cc=richard@nod.at \ --cc=sergei.shtylyov@cogentembedded.com \ --cc=tudor.ambarus@microchip.com \ --cc=vigneshr@ti.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.