DO NOT SUBMIT: Set SD_MODE on vim3
Change-Id: I4268ac92bf549acafda9aa6402702109053abff6
diff --git a/src/devices/block/drivers/aml-sdmmc/aml-sdmmc.cc b/src/devices/block/drivers/aml-sdmmc/aml-sdmmc.cc
index 6bc9cf6..a4cbbc2 100644
--- a/src/devices/block/drivers/aml-sdmmc/aml-sdmmc.cc
+++ b/src/devices/block/drivers/aml-sdmmc/aml-sdmmc.cc
@@ -1611,6 +1611,12 @@
reset_gpio = ddk::GpioProtocolClient(parent, "gpio");
}
+ ddk::GpioProtocolClient sd_mode_gpio(parent, "sd-mode-gpio");
+ if (sd_mode_gpio.is_valid()) {
+ sd_mode_gpio.ConfigOut(1);
+ zxlogf(INFO, "Set SD_MODE high");
+ }
+
auto dev =
std::make_unique<AmlSdmmc>(parent, std::move(bti), *std::move(mmio), *std::move(pinned_mmio),
config, std::move(irq), reset_gpio);
diff --git a/src/devices/board/drivers/vim3/vim3-sd.cc b/src/devices/board/drivers/vim3/vim3-sd.cc
index 7fc10dd..a12aec2 100644
--- a/src/devices/board/drivers/vim3/vim3-sd.cc
+++ b/src/devices/board/drivers/vim3/vim3-sd.cc
@@ -12,6 +12,7 @@
#include <soc/aml-a311d/a311d-hw.h>
#include <soc/aml-common/aml-sdmmc.h>
+#include "vim3-gpios.h"
#include "vim3.h"
namespace vim3 {
@@ -54,6 +55,17 @@
},
};
+static const zx_bind_inst_t sd_mode_gpio_match[] = {
+ BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_GPIO),
+ BI_MATCH_IF(EQ, BIND_GPIO_PIN, VIM3_SD_MODE),
+};
+static const device_fragment_part_t sd_mode_gpio_fragment[] = {
+ {countof(sd_mode_gpio_match), sd_mode_gpio_match},
+};
+static const device_fragment_t fragments[] = {
+ {"sd-mode-gpio", countof(sd_mode_gpio_fragment), sd_mode_gpio_fragment},
+};
+
static const zx_bind_inst_t sdio_fn1_match[] = {
BI_ABORT_IF(NE, BIND_PROTOCOL, ZX_PROTOCOL_SDIO),
BI_ABORT_IF(NE, BIND_SDIO_VID, 0x02d0),
@@ -117,7 +129,8 @@
gpio_impl_.SetDriveStrength(A311D_GPIOC(4), 4000, nullptr);
gpio_impl_.SetDriveStrength(A311D_GPIOC(5), 4000, nullptr);
- if ((status = pbus_.CompositeDeviceAdd(&sd_dev, /* nullptr */ 0, 0, nullptr)) != ZX_OK) {
+ if ((status = pbus_.CompositeDeviceAdd(&sd_dev, reinterpret_cast<uint64_t>(fragments),
+ countof(fragments), nullptr)) != ZX_OK) {
zxlogf(ERROR, "SdInit could not add sd_dev: %d", status);
return status;
}