From: Ivan Mikhaylov <i.mikhaylov@yadro.com> To: unlisted-recipients:; (no To-header on input) Cc: Ivan Mikhaylov <i.mikhaylov@yadro.com>, Tudor Ambarus <tudor.ambarus@microchip.com>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH 1/2] mtd: spi-nor: do not touch TB bit without SPI_NOR_HAS_TB Date: Wed, 12 Aug 2020 18:18:17 +0300 [thread overview] Message-ID: <20200812151818.16699-2-i.mikhaylov@yadro.com> (raw) In-Reply-To: <20200812151818.16699-1-i.mikhaylov@yadro.com> Some chips like macronix don't have TB(Top/Bottom protection) bit in the status register. Do not write tb_mask inside status register, unless SPI_NOR_HAS_TB is present for the chip. Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com> --- drivers/mtd/spi-nor/core.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0369d98b2d12..f9853dd566dc 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1735,13 +1735,18 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) return -EINVAL; } - status_new = (status_old & ~mask & ~tb_mask) | val; + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new = (status_old & ~mask & ~tb_mask) | val; + else + status_new = (status_old & ~mask) | val; /* Disallow further writes if WP pin is asserted */ status_new |= SR_SRWD; - if (!use_top) - status_new |= tb_mask; + if (!use_top) { + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new |= tb_mask; + } /* Don't bother if they're the same */ if (status_new == status_old) @@ -1817,14 +1822,19 @@ static int spi_nor_sr_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) return -EINVAL; } - status_new = (status_old & ~mask & ~tb_mask) | val; + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new = (status_old & ~mask & ~tb_mask) | val; + else + status_new = (status_old & ~mask) | val; /* Don't protect status register if we're fully unlocked */ if (lock_len == 0) status_new &= ~SR_SRWD; - if (!use_top) - status_new |= tb_mask; + if (!use_top) { + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new |= tb_mask; + } /* Don't bother if they're the same */ if (status_new == status_old) -- 2.21.1
WARNING: multiple messages have this Message-ID (diff)
From: Ivan Mikhaylov <i.mikhaylov@yadro.com> Cc: Vignesh Raghavendra <vigneshr@ti.com>, Tudor Ambarus <tudor.ambarus@microchip.com>, Richard Weinberger <richard@nod.at>, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Miquel Raynal <miquel.raynal@bootlin.com>, Ivan Mikhaylov <i.mikhaylov@yadro.com> Subject: [PATCH 1/2] mtd: spi-nor: do not touch TB bit without SPI_NOR_HAS_TB Date: Wed, 12 Aug 2020 18:18:17 +0300 [thread overview] Message-ID: <20200812151818.16699-2-i.mikhaylov@yadro.com> (raw) In-Reply-To: <20200812151818.16699-1-i.mikhaylov@yadro.com> Some chips like macronix don't have TB(Top/Bottom protection) bit in the status register. Do not write tb_mask inside status register, unless SPI_NOR_HAS_TB is present for the chip. Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com> --- drivers/mtd/spi-nor/core.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 0369d98b2d12..f9853dd566dc 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -1735,13 +1735,18 @@ static int spi_nor_sr_lock(struct spi_nor *nor, loff_t ofs, uint64_t len) return -EINVAL; } - status_new = (status_old & ~mask & ~tb_mask) | val; + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new = (status_old & ~mask & ~tb_mask) | val; + else + status_new = (status_old & ~mask) | val; /* Disallow further writes if WP pin is asserted */ status_new |= SR_SRWD; - if (!use_top) - status_new |= tb_mask; + if (!use_top) { + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new |= tb_mask; + } /* Don't bother if they're the same */ if (status_new == status_old) @@ -1817,14 +1822,19 @@ static int spi_nor_sr_unlock(struct spi_nor *nor, loff_t ofs, uint64_t len) return -EINVAL; } - status_new = (status_old & ~mask & ~tb_mask) | val; + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new = (status_old & ~mask & ~tb_mask) | val; + else + status_new = (status_old & ~mask) | val; /* Don't protect status register if we're fully unlocked */ if (lock_len == 0) status_new &= ~SR_SRWD; - if (!use_top) - status_new |= tb_mask; + if (!use_top) { + if (nor->flags & SNOR_F_HAS_SR_TB) + status_new |= tb_mask; + } /* Don't bother if they're the same */ if (status_new == status_old) -- 2.21.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-08-12 15:15 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-12 15:18 [PATCH 0/2] enable lock interface for macronix chips Ivan Mikhaylov 2020-08-12 15:18 ` Ivan Mikhaylov 2020-08-12 15:18 ` Ivan Mikhaylov [this message] 2020-08-12 15:18 ` [PATCH 1/2] mtd: spi-nor: do not touch TB bit without SPI_NOR_HAS_TB Ivan Mikhaylov 2020-08-12 15:18 ` [PATCH 2/2] mtd: spi-nor: enable lock interface for macronix chips Ivan Mikhaylov 2020-08-12 15:18 ` Ivan Mikhaylov 2020-08-31 10:55 ` Rasmus Villemoes 2020-08-31 10:55 ` Rasmus Villemoes 2020-09-01 14:06 ` Ivan Mikhaylov 2020-09-01 14:06 ` Ivan Mikhaylov 2020-08-31 10:38 ` [PATCH 0/2] " Ivan Mikhaylov 2020-08-31 10:38 ` Ivan Mikhaylov
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=20200812151818.16699-2-i.mikhaylov@yadro.com \ --to=i.mikhaylov@yadro.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ --cc=miquel.raynal@bootlin.com \ --cc=richard@nod.at \ --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.