[spinor]add spinor_global_unlock for spi nor flash

This commit is contained in:
JianjunJiang 2023-04-25 18:50:33 +08:00
parent 0b1ca5d03a
commit b49c4897f8

View File

@ -322,7 +322,32 @@ static int spinor_helper_init(struct xfel_ctx_t * ctx, struct spinor_pdata_t * p
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write status */
/* global block/sector unlock */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 1;
cbuf[clen++] = 0x98;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* wait busy */
cbuf[clen++] = SPI_CMD_SPINOR_WAIT;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write enable */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 1;
cbuf[clen++] = pdat->info.opcode_write_enable;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write status 1 */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 2;
cbuf[clen++] = OPCODE_WRSR;
@ -337,6 +362,58 @@ static int spinor_helper_init(struct xfel_ctx_t * ctx, struct spinor_pdata_t * p
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write enable */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 1;
cbuf[clen++] = pdat->info.opcode_write_enable;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write status 2 */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 2;
cbuf[clen++] = 0x31;
cbuf[clen++] = 0;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* wait busy */
cbuf[clen++] = SPI_CMD_SPINOR_WAIT;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write enable */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 1;
cbuf[clen++] = pdat->info.opcode_write_enable;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* write status 3 */
cbuf[clen++] = SPI_CMD_FAST;
cbuf[clen++] = 2;
cbuf[clen++] = 0x11;
cbuf[clen++] = 0;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
/* spi select */
cbuf[clen++] = SPI_CMD_SELECT;
/* wait busy */
cbuf[clen++] = SPI_CMD_SPINOR_WAIT;
/* spi deselect */
cbuf[clen++] = SPI_CMD_DESELECT;
if(pdat->info.address_length == 4)
{
/* spi select */