diff mbox series

mtd: spi-nor: use 4 bit locking for MX25L12805D

Message ID 20210416162859.94305-1-mail@david-bauer.net
State Changes Requested
Delegated to: Vignesh R
Headers show
Series mtd: spi-nor: use 4 bit locking for MX25L12805D | expand

Commit Message

David Bauer April 16, 2021, 4:28 p.m. UTC
Macronix MX25L12805D supports locking with 4 block
protection bits in its status register. Add the corresponding
flag in order to clear these bits when unloking the flash.

Otherwise, the flash might not be writable depending on the state
left by the bootloader.

Tested-on: Ubiquiti UniFi AC Lite (ath79)

Fixes commit 62593cf40b23 ("mtd: spi-nor: refactor block protection functions")

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 drivers/mtd/spi-nor/macronix.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michael Walle April 20, 2021, 8:44 a.m. UTC | #1
Hi David,

Am 2021-04-16 18:28, schrieb David Bauer:
> Macronix MX25L12805D supports locking with 4 block
> protection bits in its status register. Add the corresponding
> flag in order to clear these bits when unloking the flash.
> 
> Otherwise, the flash might not be writable depending on the state
> left by the bootloader.
> 
> Tested-on: Ubiquiti UniFi AC Lite (ath79)
> 
> Fixes commit 62593cf40b23 ("mtd: spi-nor: refactor block protection 
> functions")

Strictly speaking, this is not a fix, because there was never
locking support for macronix flashes.

This should also be in the subject, it should rather be "enable locking
support" or something similar.

Btw. these bits are non-volatile, so if your bootloader will set
them again, depending on the flash and your reboot cycles, they might
wear out.

> Signed-off-by: David Bauer <mail@david-bauer.net>

With that:
Reviewed-by: Michael Walle <michael@walle.cc>

-michael

> ---
>  drivers/mtd/spi-nor/macronix.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/macronix.c 
> b/drivers/mtd/spi-nor/macronix.c
> index 2d39dd32a64e..ed8b56a0102f 100644
> --- a/drivers/mtd/spi-nor/macronix.c
> +++ b/drivers/mtd/spi-nor/macronix.c
> @@ -50,7 +50,8 @@ static const struct flash_info macronix_parts[] = {
>  	{ "mx25u4035",   INFO(0xc22533, 0, 64 * 1024,   8, SECT_4K) },
>  	{ "mx25u8035",   INFO(0xc22534, 0, 64 * 1024,  16, SECT_4K) },
>  	{ "mx25u6435f",  INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) },
> -	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K) },
> +	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K |
> +			      SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) },
>  	{ "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
>  	{ "mx25r1635f",  INFO(0xc22815, 0, 64 * 1024,  32,
>  			      SECT_4K | SPI_NOR_DUAL_READ |
David Bauer April 20, 2021, 11:09 a.m. UTC | #2
Hi,

thanks for your review.

On 4/20/21 10:44 AM, Michael Walle wrote:
> Hi David,
> 
> Am 2021-04-16 18:28, schrieb David Bauer:
>> Macronix MX25L12805D supports locking with 4 block
>> protection bits in its status register. Add the corresponding
>> flag in order to clear these bits when unloking the flash.
>>
>> Otherwise, the flash might not be writable depending on the state
>> left by the bootloader.
>>
>> Tested-on: Ubiquiti UniFi AC Lite (ath79)
>>
>> Fixes commit 62593cf40b23 ("mtd: spi-nor: refactor block protection functions")
> 
> Strictly speaking, this is not a fix, because there was never
> locking support for macronix flashes.

You're right. On a second read, the description is a bit off, part of the reason
being the patch was part of another series from me some moths ago. I'll fix that.

> 
> This should also be in the subject, it should rather be "enable locking
> support" or something similar.
> 
> Btw. these bits are non-volatile, so if your bootloader will set
> them again, depending on the flash and your reboot cycles, they might
> wear out.

I didn't knew that, thanks for this information. Sadly this is the quirk of
the bootloader from Ubiquiti. Some versions of their UniFi and all of their
AirMax series behave like that.

Best
David

> 
>> Signed-off-by: David Bauer <mail@david-bauer.net>
> 
> With that:
> Reviewed-by: Michael Walle <michael@walle.cc>
> 
> -michael
> 
>> ---
>>  drivers/mtd/spi-nor/macronix.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
>> index 2d39dd32a64e..ed8b56a0102f 100644
>> --- a/drivers/mtd/spi-nor/macronix.c
>> +++ b/drivers/mtd/spi-nor/macronix.c
>> @@ -50,7 +50,8 @@ static const struct flash_info macronix_parts[] = {
>>      { "mx25u4035",   INFO(0xc22533, 0, 64 * 1024,   8, SECT_4K) },
>>      { "mx25u8035",   INFO(0xc22534, 0, 64 * 1024,  16, SECT_4K) },
>>      { "mx25u6435f",  INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) },
>> -    { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K) },
>> +    { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K |
>> +                  SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) },
>>      { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
>>      { "mx25r1635f",  INFO(0xc22815, 0, 64 * 1024,  32,
>>                    SECT_4K | SPI_NOR_DUAL_READ |
diff mbox series

Patch

diff --git a/drivers/mtd/spi-nor/macronix.c b/drivers/mtd/spi-nor/macronix.c
index 2d39dd32a64e..ed8b56a0102f 100644
--- a/drivers/mtd/spi-nor/macronix.c
+++ b/drivers/mtd/spi-nor/macronix.c
@@ -50,7 +50,8 @@  static const struct flash_info macronix_parts[] = {
 	{ "mx25u4035",   INFO(0xc22533, 0, 64 * 1024,   8, SECT_4K) },
 	{ "mx25u8035",   INFO(0xc22534, 0, 64 * 1024,  16, SECT_4K) },
 	{ "mx25u6435f",  INFO(0xc22537, 0, 64 * 1024, 128, SECT_4K) },
-	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K) },
+	{ "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, SECT_4K |
+			      SPI_NOR_HAS_LOCK | SPI_NOR_4BIT_BP) },
 	{ "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) },
 	{ "mx25r1635f",  INFO(0xc22815, 0, 64 * 1024,  32,
 			      SECT_4K | SPI_NOR_DUAL_READ |