Skip to content

Commit

Permalink
spi_flash: do not return error code for unsupported flash lock/unlock…
Browse files Browse the repository at this point in the history
… ops

Instead, print a warning message for the user to see.

This is, in order to support non-Micron/STMicro flashes for
internal/experimental usage, or for other boards that are similar to
Pluto/M2k, but with different flash types.

The flashing operation will try to do a `sf protect lock/unlock` on the
flash, and that will error out for non-Micron/STMicro flashes.
That's because other flash types don't support the ops [in the driver].

Disabling an error condition is not nice, but it's easier than modifying
the u-boot vars for each flash-type. And we still get a warning message, so
there should be awareness about this.

Supporting lock/unlock for ISSI flashes is possible, but requires more work
because ISSI needs to access another register for doing the same
lock/unlock as Micron/STmicro (i.e. access the Top/Bottom select & BP3
bit).

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
  • Loading branch information
commodo committed Feb 23, 2018
1 parent ffa45f0 commit d8cf117
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/spi_flash.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,11 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
bool prot)
{
if (!flash->flash_lock || !flash->flash_unlock)
return -EOPNOTSUPP;
if (!flash->flash_lock || !flash->flash_unlock) {
printf("*** Warning: flash lock/unlock ops not supported "
" for '%s'\n", flash->name);
return 0;
}

if (prot)
return flash->flash_lock(flash, ofs, len);
Expand Down

0 comments on commit d8cf117

Please sign in to comment.