/* * The Atmel AT25FS010/AT25FS040 parts have some weird configuration for the * block protection bits. We don't support them. But legacy behavior in linux * is to unlock the whole flash array on startup. Therefore, we have to support * exactly this operation.
*/ staticint at25fs_nor_lock(struct spi_nor *nor, loff_t ofs, u64 len)
{ return -EOPNOTSUPP;
}
/* We only support unlocking the whole flash array */ if (ofs || len != nor->params->size) return -EINVAL;
/* Write 0x00 to the status register to disable write protection */
ret = spi_nor_write_sr_and_check(nor, 0); if (ret)
dev_dbg(nor->dev, "unable to clear BP bits, WP# asserted?\n");
/** * atmel_nor_set_global_protection - Do a Global Protect or Unprotect command * @nor: pointer to 'struct spi_nor' * @ofs: offset in bytes * @len: len in bytes * @is_protect: if true do a Global Protect otherwise it is a Global Unprotect * * Return: 0 on success, -error otherwise.
*/ staticint atmel_nor_set_global_protection(struct spi_nor *nor, loff_t ofs,
u64 len, bool is_protect)
{ int ret;
u8 sr;
/* We only support locking the whole flash array */ if (ofs || len != nor->params->size) return -EINVAL;
ret = spi_nor_read_sr(nor, nor->bouncebuf); if (ret) return ret;
sr = nor->bouncebuf[0];
/* SRWD bit needs to be cleared, otherwise the protection doesn't change */ if (sr & SR_SRWD) {
sr &= ~SR_SRWD;
ret = spi_nor_write_sr_and_check(nor, sr); if (ret) {
dev_dbg(nor->dev, "unable to clear SRWD bit, WP# asserted?\n"); return ret;
}
}
if (is_protect) {
sr |= ATMEL_SR_GLOBAL_PROTECT_MASK; /* * Set the SRWD bit again as soon as we are protecting * anything. This will ensure that the WP# pin is working * correctly. By doing this we also behave the same as * spi_nor_sr_lock(), which sets SRWD if any block protection * is active.
*/
sr |= SR_SRWD;
} else {
sr &= ~ATMEL_SR_GLOBAL_PROTECT_MASK;
}
nor->bouncebuf[0] = sr;
/* * We cannot use the spi_nor_write_sr_and_check() because this command * isn't really setting any bits, instead it is an pseudo command for * "Global Unprotect" or "Global Protect"
*/ return spi_nor_write_sr(nor, nor->bouncebuf, 1);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.