SPI NOR peripheral restart

Hi 

I have an external NOR flash chip which is powered off on startup. The idea is to power up the flash when needed to reserve power. On startup, I get the error message:

<err> spi_nor: SFDP magic ffffffff invalid
<err> spi_nor: SFDP read failed: -22

Enabling the power pin only starts during application code, meaning SPI-NOR fails before that.

Is there a way to restart the SPI-NOR instance or driver to re-attempt initializing the device?

I have had limited success by reorganizing boot priorities to have GPIO start before SPI, but what about the case where I have to reinitialize during runtime?

I have also tried remounting the fstab entry, but it doesn't seem to do anything to the SPI situation.

I appreciate any guidance regarding this

Parents Reply
  • Hi,

    Sorry, you are right, I see now that the PM device APIs are only implemented for the spim driver, not the spi nor driver. I think the easiest way around this is to manually call spi_nor.c:spi_nor_init() from the application after issuing the pm resume action.  

    #define EXFLASH0_NODE_ID DT_NODELABEL(EXFLASH0)
    
    #if DT_NODE_HAS_STATUS(DT_NODELABEL(EXFLASH0), okay)
    const struct device *flash_dev = DEVICE_DT_GET(EXFLASH0_NODE_ID);
    #else
    #error "Node is disabled"
    #endif
    
    ...
    
    err = spi_nor_init(flash_dev);
    ...
    
    

Children
Related