NOR Chip Drivers
As you might have noticed, the NOR flash chip used by the handheld in Figure 17.2 is labeled CFI-compliant. CFI stands for Common Flash Interface, a specification designed to do away with the need for developing separate drivers to support chips from different vendors. Software can query CFI-compliant flash chips and automatically detect block sizes, timing parameters, and the command-set to be used for communication. Drivers that implement specifications such as CFI and JEDEC are called chip drivers.
According to the CFI specification, software must write 0x98 to location 0x55 within flash memory to initiate a query. Look at Listing 17.4 to see how MTD implements CFI query.
Listing 17.4. Querying CFI-compliant Flash
/* Snippet from cfi_probe_chip() (2.6.23.1 kernel) defined in drivers/mtd/chips/cfi_probe.c, with comments added */ /* cfi is a pointer to struct cfi_private defined in include/linux/mtd/cfi.h */ /* ... */ /* Ask the device to enter query mode by sending 0x98 to offset 0x55 */ cfi_send_gen_cmd(0x98, 0x55, base, map, cfi, cfi->device_type, NULL); /* If the device did not return the ASCII characters 'Q', 'R' and 'Y', the chip is not CFI-compliant */ if (!qry_present(map, base, cfi)) { xip_enable(base, map, cfi); return 0; } /* Elicit chip parameters and the command-set, and populate the cfi structure */ if (!cfi->numchips) { return cfi_chip_setup(map, cfi); } /* ... */
The CFI specification defines various command-sets that compliant chips can implement. Some of the common ones are as follows:
- Command-set 0001, supported by Intel and Sharp flash chips
- Command-set 0002, implemented on AMD and Fujitsu flash chips
- Command-set 0020, used on ST flash chips
MTD supports these command-sets as kernel modules. You can enable the one supported by your flash chip via the kernel configuration menu.