Looking at the Sources
In the kernel tree, the drivers/mtd/ directory contains the sources for the MTD layer. Map, chip, and NAND drivers live in the drivers/mtd/maps/, drivers/mtd/chips/, and drivers/mtd/nand/ subdirectories, respectively. Most MTD data structures are defined in header files present in include/linux/mtd/.
To access an unsupported BIOS firmware hub from Linux, implement a driver using drivers/mtd/maps/ichxrom.c as your starting point.
For examples of operating on NAND OOB data from user space, look at nanddump.c and nandwrite.c in the MTD-utils package.
Table 17.1 contains the main data structures used in this chapter and their location in the source tree. Table 17.2 lists the main kernel programming interfaces that you used in this chapter along with the location of their definitions.
Table 17.1. Summary of Data Structures
Data Structure |
Location |
Description |
mtd_partition |
include/linux/mtd/partitions.h |
Representation of a flash chip's partition layout. |
map_info |
include/linux/mtd/map.h |
Low-level access routines implemented by the map driver are passed to the chip driver using this structure. |
mtd_info |
include/linux/mtd/mtd.h |
General device-specific information. |
erase_info, erase_info_user |
include/linux/mtd/mtd.h, include/mtd/mtd-abi.h |
Structures used for flash erase management. |
cfi_private |
include/linux/mtd/cfi.h |
Device-specific information maintained by NOR chip drivers. |
amd_flash_info |
drivers/mtd/chips/jedec_probe.c |
Device-specific information supplied to the JEDEC chip driver. |
nand_ecclayout |
include/mtd/mtd-abi.h |
Layout of the OOB spare area of a NAND chip. |
Table 17.2. Summary of Kernel Programming Interfaces
Kernel Interface |
Location |
Description |
simple_map_init() |
drivers/mtd/maps/map_funcs.c |
Initializes a map_info structure with generic flash access methods |
do_map_probe() |
drivers/mtd/chips/chipreg.c |
Probes the NOR flash via a chip driver |
add_mtd_partitions() |
drivers/mtd/mtdpart.c |
Registers an mtd_partition structure with the MTD core |