#define MTD_ABSENT 0 #define MTD_RAM 1 #define MTD_ROM 2 #define MTD_NORFLASH 3 #define MTD_NANDFLASH 4 #define MTD_PEROM 5 #define MTD_OTHER 14 #define MTD_UNKNOWN 15
#define MTD_CLEAR_BITS 1 // Bits can be cleared (flash) #define MTD_SET_BITS 2 // Bits can be set #define MTD_ERASEABLE 4 // Has an erase function #define MTD_WRITEB_WRITEABLE 8 // Direct IO is possible #define MTD_VOLATILE 16 // Set for RAMs #define MTD_XIP 32 // eXecute-In-Place possible #define MTD_OOB 64 // Out-of-band data (NAND flash) #define MTD_ECC 128 // Device capable of automatic ECC
#define MTD_ECC_NONE 0 // No automatic ECC available #define MTD_ECC_RS_DiskOnChip 1 // Automatic ECC on DiskOnChipThe eccsize holds the size of the blocks on which the hardware can perform automatic ECC.
When a driver is a kernel loadable module, this field is a pointer to the struct module of the module. It is used to increase and decrease the module's usage count as appropriate.
The user modules are responsible for increasing and decreasing the usage count of the driver as appropriate, for example by calling __MOD_INC_USE_COUNT(mtd->module); in their open routine.
This routine adds a struct erase_info to the erase queue for the device. This routine may sleep until the erase had finished, or it may simply queue the request and return immediately.
The struct erase_info contains a pointer to a callback function which will be called by the driver module when the erase has completed.
For more information, see the erase page.
Read and write functions for the memory device. These may sleep, and should not be called from IRQ context or with locks held.
The buf argument is assumed to be in kernel-space. If you need to copy to userspace, either use a kiobuf to lock down the pages first, or use a bounce buffer.
For devices which support automatic ECC generation or checking, these routines behave just the same at the read/write functions above, but with the addition that the write_ecc function places the generated ECC data into eccbuf, and the read_ecc function verifies the ECC data and attempts to correct any errors which it detects.
For devices which have out-of-band data, these functions provide access to it.
The from/to address is the address of the start of the real page of memory with which the OOB data is associated, added to the offset within the OOB block.
Example: To specify the 5th byte of the OOB data associated with the NAND flash page at 0x1000 in the device, you would pass address 0x1005
This routine will sleep until all pending flash operations have completed.
All the MTD driver functions may be sleep. You may not call any of them from an IRQ or timer context, or with locks held.
Nothing may modify the data in the struct mtd_info after it is registered with the MTD system.
The read, write and erase routines are mandatory. Also read_oob and write_oob if the MTD device indicates that it has such capability.
The sync routine is not mandatory, and users should check that the vector is non-NULL before attempting to use it.