Detect EVT2 board based on mmc capacity
It is used to apply evt2 device tree overlay automatically in the boot script.
Tested: EVT1 and EVT2 boards
Change-Id: I3908bd761e34bf8ebd3318c24a190731723785d5
diff --git a/board/mediatek/mt8516-coral/mt8516-coral.c b/board/mediatek/mt8516-coral/mt8516-coral.c
index 2f17a88..c302da9 100644
--- a/board/mediatek/mt8516-coral/mt8516-coral.c
+++ b/board/mediatek/mt8516-coral/mt8516-coral.c
@@ -5,6 +5,7 @@
#include <common.h>
#include <dm.h>
+#include <mmc.h>
#include "../../../drivers/watchdog/mtk_wdt.h"
#define WDT_DRIVER_NAME "mtk_wdt"
@@ -36,7 +37,9 @@
int ret;
struct udevice *dev;
struct uclass *uc;
+ struct mmc *mmc;
int reg_val;
+ int mmc_dev = 0;
ret = uclass_get(UCLASS_WDT, &uc);
if (ret)
@@ -51,9 +54,17 @@
}
}
}
-
+
env_set("serial#", "0123456789ABCDEF");
+ mmc = find_mmc_device(mmc_dev);
+ if (mmc) {
+ if (!mmc_init(mmc) && mmc->capacity >= 7000000000) {
+ printf("EVT2 detected\n");
+ env_set("evt2_board", "1");
+ }
+ }
+
return 0;
}
diff --git a/include/configs/mt8516-coral.h b/include/configs/mt8516-coral.h
index 8a50313..01de927 100644
--- a/include/configs/mt8516-coral.h
+++ b/include/configs/mt8516-coral.h
@@ -88,6 +88,7 @@
"kerneladdr=0x4A000000\0" \
"fastboot=fastboot usb 0\0" \
"force_fastboot=0\0" \
+ "evt2_board=0\0" \
MMCBOOT \
TFTPBOOT \
"bootcmd=" \