[ddk][nand] Add NAND class and partition GUID fields to nand_info_t struct

The NAND class is used to determine which driver should bind to the NAND device:

- NAND_CLASS_PARTMAP binds NAND partition map driver
- NAND_CLASS_FTL binds FTL driver
- NAND_CLASS_BBS binds NAND bad block skip driver

The GUID field contains the partition type GUID from the NAND partition map.

Change-Id: I48280ef100afbed20537559449a3dfa5d8d15c0e
diff --git a/system/dev/nand/ram-nand/ram-nand.h b/system/dev/nand/ram-nand/ram-nand.h
index 6ca0d6d..00e41c7 100644
--- a/system/dev/nand/ram-nand/ram-nand.h
+++ b/system/dev/nand/ram-nand/ram-nand.h
@@ -23,7 +23,8 @@
 
     NandParams(uint32_t page_size, uint32_t pages_per_block, uint32_t num_blocks, uint32_t ecc_bits,
                uint32_t oob_size)
-        : NandParams(nand_info_t {page_size, pages_per_block, num_blocks, ecc_bits, oob_size}) {}
+        : NandParams(nand_info_t {page_size, pages_per_block, num_blocks, ecc_bits, oob_size,
+                     NAND_CLASS_FTL, {}}) {}
 
     NandParams(const nand_info_t& base) {
         // NandParams has no data members.
diff --git a/system/dev/nand/ram-nand/test/ram-nand-ctl.cpp b/system/dev/nand/ram-nand/test/ram-nand-ctl.cpp
index 704ee00..45623a3 100644
--- a/system/dev/nand/ram-nand/test/ram-nand-ctl.cpp
+++ b/system/dev/nand/ram-nand/test/ram-nand-ctl.cpp
@@ -16,7 +16,7 @@
 class NandDevice {
   public:
     NandDevice() {
-        nand_info_t config = {4096, 4, 5, 6, 0};
+        nand_info_t config = {4096, 4, 5, 6, 0, NAND_CLASS_FTL, {}};
         if (!create_ram_nand(&config, path_)) {
             device_.reset(open(path_, O_RDWR));
         }
diff --git a/system/dev/rawnand/aml-rawnand/aml-rawnand.c b/system/dev/rawnand/aml-rawnand/aml-rawnand.c
index f2c17de..9f211df 100644
--- a/system/dev/rawnand/aml-rawnand/aml-rawnand.c
+++ b/system/dev/rawnand/aml-rawnand/aml-rawnand.c
@@ -776,6 +776,10 @@
     capacity /= raw_nand->erasesize;
     nand_info->num_blocks = (uint32_t)capacity;
     nand_info->ecc_bits = raw_nand->controller_params.ecc_strength;
+
+    nand_info->nand_class = NAND_CLASS_PARTMAP;
+    memset(&nand_info->partition_guid, 0, sizeof(nand_info->partition_guid));
+
     if (raw_nand->controller_params.user_mode == 2)
         nand_info->oob_size =
             (raw_nand->writesize /
diff --git a/system/public/zircon/driver/binding.h b/system/public/zircon/driver/binding.h
index cc92568..7766fa5 100644
--- a/system/public/zircon/driver/binding.h
+++ b/system/public/zircon/driver/binding.h
@@ -123,6 +123,9 @@
 #define BIND_SERIAL_VID             0x0601
 #define BIND_SERIAL_PID             0x0602
 
+// NAND binding variables at 0x07XX
+#define BIND_NAND_CLASS             0x0700
+
 // TEMPORARY binding variables at 0xfXX
 // I2C_ADDR is a temporary way to bind the i2c touchscreen on the Acer12. This
 // binding will eventually be made via some sort of ACPI device enumeration.
diff --git a/system/ulib/ddk/include/ddk/protocol/nand.h b/system/ulib/ddk/include/ddk/protocol/nand.h
index 3e7c6b7..191fa1b 100644
--- a/system/ulib/ddk/include/ddk/protocol/nand.h
+++ b/system/ulib/ddk/include/ddk/protocol/nand.h
@@ -8,12 +8,19 @@
 #include <stdint.h>
 
 #include <zircon/types.h>
+#include <zircon/boot/image.h>
 
 // nand_info_t is used to retrieve various parameters describing the geometry of
 // the underlying NAND chip(s). This is retrieved using the query api in
 // nand_protocol_ops.
 typedef struct nand_info nand_info_t;
 
+enum {
+    NAND_CLASS_PARTMAP = 1,   // NAND device contains multiple partitions.
+    NAND_CLASS_FTL = 2,       // NAND device is a FTL partition.
+    NAND_CLASS_BBS = 3,       // NAND device is a bad block skip partition.
+};
+
 struct nand_info {
     uint32_t page_size;         // Read/write unit size, in bytes.
     uint32_t pages_per_block;   // Erase block size, in pages.
@@ -21,6 +28,8 @@
     uint32_t ecc_bits;          // Number of ECC bits (correctable bit flips),
                                 // per correction chunk.
     uint32_t oob_size;          // Available out of band bytes per page.
+    uint32_t nand_class;        // NAND_CLASS_PARTMAP, NAND_CLASS_FTL or NAND_CLASS_RAW.
+    uint8_t partition_guid[ZBI_PARTITION_GUID_LEN]; // partition type GUID from partition map.
 };
 
 // nand_op_t's are submitted for processing via the queue() method of the