nand: Port MTD from U-boot to depthcharge

This is the first stage in a patchset giving NAND support to depthcharge.
This patch copies MTD from U-boot and cleans up the code, adding
the appropriate makefiles, etc.

Basing depthcharge's NAND support on mtd is intended to reduce
the work required to port SoC-specific NAND drivers from the
Linux kernel or U-Boot to depthcharge. An attempt has been made
to minimize the amount of code which was brought in, but there may
still be room for improvement in importing less code or cleanups.

The interfaces and source code locations are probably as they need
to be, so this can provide an adequate basis for vendors to
begin working on low-level drivers or higher-level code to be
written on top.

From the user's perspective, the two main functions are
- mtd_block_isbad, to determine if a block is bad
- mtd_read, to read from NAND memory
Devices are lazily instantiated from an MtdDevCtrlr to an MtdDev.

A backend implementation for a particular SoC implements methods
in the MtdDev struct which describe the behavior of the device.

BUG=chromium:403432
TEST=ported the IPQ8064 NAND driver and ran a hacked up kernel
loader, observing it to initialize NAND, read from it, and fail
verification.
BRANCH=none

Signed-off-by: Dan Ehrenberg <dehrenberg@chromium.org>

Change-Id: Id4c6b827cc4a0808a646448fd9ff25a97d332d7b
Reviewed-on: https://chromium-review.googlesource.com/222310
Reviewed-by: Julius Werner <jwerner@chromium.org>
Commit-Queue: Daniel Ehrenberg <dehrenberg@chromium.org>
Tested-by: Daniel Ehrenberg <dehrenberg@chromium.org>
8 files changed