Download Linux support package (LSP) v2.3 for SPEAr
Transcript
Non-volatile memory device drivers u_long erasesize; u_long oobblock; u_long oobsize; u_long ecctype; u_long eccsize; UM0851 Size in bytes of the "erase block" of this memory device - the smallest area which can be erased in a single erase command. Some memory technologies support out-of-band data - for example, NAND flash has 16 extra bytes per 512-byte page, for error correction or metadata. oobsize and oobblock hold the size of each out-of-band area, and the number of bytes of "real" memory with which each is associated, respectively. As an example, NAND flash, would have oobblock == 512 and oobsize == 16 to show that it has 16 bytes of OOB data per 512 bytes of flash. Some hardware not only allows access to flash or similar devices, but also has ECC (error correction) capabilities builtin to the interface. The eccsize holds the size of the blocks on which the hardware can perform automatic ECC. int (*erase) (struct mtd_info *mtd, struct erase_info *instr); This routine adds a struct erase_info to the erase queue for the routine may sleep until the erase had finished, or it may simply request and return immediately. The struct erase_info contains a callback function which will be called by the driver module when completed. device. This queue the pointer to a the erase has int (*read) (struct mtd_info *mtd, loff_t from, size_t len, u_char *buf); int (*write) (struct mtd_info *mtd, loff_t to, size_t len, const u_char *buf); 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. int (*read_ecc) (struct mtd_info *mtd, loff_t from, size_t len, u_char *buf, u_char *eccbuf); int (*write_ecc) (struct mtd_info *mtd, loff_t to, size_t len, const u_char *buf, u_char*eccbuf); 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. int (*read_oob) (struct mtd_info *mtd, loff_t from, size_t len, u_char *buf); int (*write_oob) (struct mtd_info *mtd, loff_t to, size_t len, const u_char *buf); 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 }; The NAND device driver populates the struct mtd_info to MTD layer by calling the following routines. #ifdef CONFIG_MTD_PARTITIONS err = add_mtd_partitions( &mtd, v->mtd_parts, mtd_parts_nb ); 126/245 Doc ID 16604 Rev 2