New SPI Devices Under Linux – KBA220962

Version: **

 

Question:

How can I add support for new SPI devices to Linux?

 

Answer:

Support for Cypress SPI flash devices comes with the MTD chip driver in m25p80.c and/or spi-nor.c (for kernels 3.16 or later). This driver implements the device specific command set, i.e., the protocol or language needed to talk to the physical device. It includes support for a whole series of compatible SPI flash devices from various vendors. Its code base has been growing continuously in the past with an increasing number of features as well as number of supported devices. If needed, new OPNs can easily be added. For example, the following device entries describe the new Cypress S25FL-L family members:

 

{ "s25fl064l", INFO(0x016017, 0, 64 * 1024, 128, SECT_4K) }, 
{ "s25fl128l", INFO(0x016018, 0, 64 * 1024, 256, SECT_4K) },
{ "s25fl256l", INFO(0x016019, 0, 64 * 1024, 512, SECT_4K) },

The structure of device entries is pretty simple. Data sets start with a unique string or name followed by the standard and extended device IDs, sector size in bytes, number of sectors and finally optional flags. The SECT_4K flag is optional and can be omitted if the full bock sectors are desired as erase unit size, e.g., in the context of a flash file system.