TI E2E Community
Sitara Processors Forum
Dynamic Loading of SPI Flash (m25p80)
I have an AM3517 board that uses an external at25d041a on the SPI bus. The unique thing is the flash device will not be present at boot time, so I must figure out how to mount it at runtime.
Right now I have the board configured in my board file in the traditional way. (As a platform device using the m25p80.c driver). If the device is connected at boot time, the m25p80 driver successfully identifies the chip as an "at25df041a" and I can mount/read/write etc. However, if the device is not connected at boot time, the mtdblock0 device still gets created but the m25p80 driver fails to auto detect the chip and configures it to be a "m25p05-nonjedec" with only 64Kbytes of space. If I plug the spi flash in at this time, the spi bus obviously will not re-probe the bus so it stays configured as m25p05-nonjedec and I cannot read/write. I need to find a way to force this to be identified as an "at25df041a" at run time.
By the way, I have a gpio that I can read to detect if the flash has been inserted or not...
I can think of 2 ways to go about this, neither of which I have been able to figure out how to do:
1) Somehow turn off jedec auto-detection in the m25p80 driver. If I can force it to always configure the spi device as at25df041a regardless of hardware presence, this would be the easiest solution. Is there a way to disable auto detection (jedec) in the board file for my device?
2) Compile the m25p80 (or some other driver) as a module and insmod / rmmod when I detect the device getting inserted and removed via my gpio. This way, the driver would run it's probe procedure and auto detect the chip correctly. However, I have not been able to figure out how to configure an m25p80 device as a module driver. Can this be done?
I apologize for the wall of text. Thanks in advance.
Module support for m25p80 can be done.
change the m25p80 to module support can be done using menuconfig as follows.
-> Device Drivers -> Memory Technology Device (MTD) support (MTD [=y]) -> Self-contained MTD device drivers
<M> Support most SPI Flash chips (AT26DF, M25P, W25X, ...)
Now you can use module build to generate m25p8o module.
Thanks! I think this would be a viable solution, and perhaps more elgant than what I ended up doing. I was actually planning on posting a follow up to this today since as of today I have a working solution. I ended writing a custom driver that watches my GPIO and on detection, adds the spi device using spi_new_device, and then sets a sysfs flag. I then wrote daemon that reads my drivers sysfs flag and mounts the filesystem. In retrospect it may be overkill but it works rather reliably so far. Thanks again,
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.