bind emmc device

Change-Id: Iebbcc1b15bed6be7a1b2d51345e63a1a53f2bd72
diff --git a/system/udev/bcm-mailbox/mailbox.c b/system/udev/bcm-mailbox/mailbox.c
index 1880002..b144736 100644
--- a/system/udev/bcm-mailbox/mailbox.c
+++ b/system/udev/bcm-mailbox/mailbox.c
@@ -385,7 +385,7 @@
     .ioctl = mailbox_device_ioctl,
 };
 
-static mx_protocol_device_t vc_device_proto = {};
+static mx_protocol_device_t empty_device_proto = {};
 
 mx_status_t mailbox_bind(mx_driver_t* driver, mx_device_t* parent, void** cookie) {
     uintptr_t page_base;
@@ -436,7 +436,7 @@
 
     bcm_vc_get_framebuffer(&framebuff_descriptor);
 
-    device_init(&disp_device, driver, "bcm-vc-fbuff", &vc_device_proto);
+    device_init(&disp_device, driver, "bcm-vc-fbuff", &empty_device_proto);
 
     disp_device.protocol_id = MX_PROTOCOL_DISPLAY;
     disp_device.protocol_ops = &vc_display_proto;
@@ -457,6 +457,16 @@
 
     bcm_vc_poweron(bcm_dev_sd);
 
+    // Publish this mock device to allow the eMMC device to bind to.
+    mx_device_t* sdmmc_device = malloc(sizeof(*sdmmc_device));
+    device_init(sdmmc_device, driver, "bcm-sdmmc", &empty_device_proto);
+    sdmmc_device->props = calloc(2, sizeof(mx_device_prop_t));
+    sdmmc_device->props[0] = (mx_device_prop_t){BIND_SOC_VID, 0, SOC_VID_BROADCOMM};
+    sdmmc_device->props[1] = (mx_device_prop_t){BIND_SOC_DID, 0, SOC_DID_BROADCOMM_EMMC};
+    sdmmc_device->prop_count = 2;
+    sdmmc_device->protocol_id = MX_PROTOCOL_SOC;
+    status = device_add(sdmmc_device, parent);
+
     bcm_vc_poweron(bcm_dev_usb);
 
     return NO_ERROR;
diff --git a/system/udev/bcm-mmc/emmc.c b/system/udev/bcm-mmc/emmc.c
index 5263d6d..0ebe5c1 100644
--- a/system/udev/bcm-mmc/emmc.c
+++ b/system/udev/bcm-mmc/emmc.c
@@ -703,7 +703,7 @@
 
     // Create the device.
     device_init(&emmc->device, drv, "bcm-emmc", &emmc_device_proto);
-    emmc->device.protocol_id = MX_PROTOCOL_MMC;
+    emmc->device.protocol_id = MX_PROTOCOL_SDMMC;
 
     // Create a thread to handle IRQs.
     thrd_t irq_thrd;
@@ -766,6 +766,6 @@
 MAGENTA_DRIVER_BEGIN(_driver_emmc_dwc, "bcm-emmc", "magenta", "0.1", 3)
     BI_ABORT_IF(NE, BIND_PROTOCOL, MX_PROTOCOL_SOC),
     BI_ABORT_IF(NE, BIND_SOC_VID, SOC_VID_BROADCOMM),
-    BI_MATCH_IF(EQ, BIND_SOC_DID, SOC_DID_BROADCOMM_VIDEOCORE_BUS),
+    BI_MATCH_IF(EQ, BIND_SOC_DID, SOC_DID_BROADCOMM_EMMC),
 MAGENTA_DRIVER_END(_driver_emmc_dwc)
 // clang-format on
\ No newline at end of file
diff --git a/system/udev/sdmmc/sdmmc.c b/system/udev/sdmmc/sdmmc.c
index a8f8d9a..bb30754 100644
--- a/system/udev/sdmmc/sdmmc.c
+++ b/system/udev/sdmmc/sdmmc.c
@@ -177,7 +177,7 @@
     emmc_txn->flags = txn->flags;
     emmc_txn->offset = txn->offset;
     emmc_txn->length = txn->length;
-    emmc_txn->protocol = MX_PROTOCOL_MMC;
+    emmc_txn->protocol = MX_PROTOCOL_SDMMC;
     sdmmc_protocol_data_t* pdata = iotxn_pdata(emmc_txn, sdmmc_protocol_data_t);
 
     uint8_t current_state;
@@ -483,6 +483,6 @@
 // The formatter does not play nice with these macros.
 // clang-format off
 MAGENTA_DRIVER_BEGIN(_driver_sdmmc, "sdmmc", "magenta", "0.1", 1)
-    BI_MATCH_IF(EQ, BIND_PROTOCOL, MX_PROTOCOL_MMC),
+    BI_MATCH_IF(EQ, BIND_PROTOCOL, MX_PROTOCOL_SDMMC),
 MAGENTA_DRIVER_END(_driver_sdmmc)
 // clang-format on
\ No newline at end of file
diff --git a/system/ulib/ddk/include/ddk/protocol/bcm.h b/system/ulib/ddk/include/ddk/protocol/bcm.h
index 169fd50..9d07e84 100644
--- a/system/ulib/ddk/include/ddk/protocol/bcm.h
+++ b/system/ulib/ddk/include/ddk/protocol/bcm.h
@@ -19,6 +19,7 @@
 // Broadcomm specific PIDs
 #define SOC_DID_BROADCOMM_VIDEOCORE_BUS 0x0000  // Videocore device (used as root bus)
 #define SOC_DID_BROADCOMM_MAILBOX       0x0001  // Videocore mailbox, used for comms between cpu/gpu
+#define SOC_DID_BROADCOMM_EMMC          0x0002  // Bcm28xx eMMC device.
 
 typedef struct {
     uint32_t phys_width;    //request
diff --git a/system/ulib/ddk/include/ddk/protodefs.h b/system/ulib/ddk/include/ddk/protodefs.h
index 3d4dcbd..96b3161 100644
--- a/system/ulib/ddk/include/ddk/protodefs.h
+++ b/system/ulib/ddk/include/ddk/protodefs.h
@@ -27,6 +27,6 @@
 DDK_PROTOCOL_DEF(SOC,            'pSOC', "soc")
 DDK_PROTOCOL_DEF(ACPI_BUS,       'pABS', "acpi-bus")
 DDK_PROTOCOL_DEF(ACPI,           'pACP', "acpi")
-DDK_PROTOCOL_DEF(MMC,            'pMMC', "mmc")
+DDK_PROTOCOL_DEF(SDMMC,          'pSDM' ,"sdmmc")
 #undef DDK_PROTOCOL_DEF
 #endif