meta-ampere: mtmitchell: control GPIO via Mt.Mitchell 1.0 vs 2.0 detection
Support checking BOARD_ID GPIOs to detect Mt.Mitchell 1.0 vs 2.0 board
revision and configure GPI[1:0] accordingly.
Host firmware will use GPI[1:0] to identify the board revision to handle its
features property.
Signed-off-by: Chanh Nguyen <chanh@os.amperecomputing.com>
Change-Id: I3c2834be0f1ef2ef3de9b9ae24a2c2e3c0eb5ae5
diff --git a/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh b/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
index a5ec8e7..ac472f9 100644
--- a/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
+++ b/meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/ampere_platform_init.sh
@@ -4,6 +4,48 @@
# shellcheck source=meta-ampere/meta-mitchell/recipes-ampere/platform/ampere-platform-init/mtmitchell_platform_gpios_init.sh
source /usr/sbin/platform_gpios_init.sh
+function mtc_board_revision_detection() {
+ # Support to detect MTC board revisions via board ID and to set GPI pins for the host
+ # to identify the board revision.
+
+ # Check the mainboard by board_id (i2c0, address 0x20)
+ board_id=$(i2cget -y -a 0 0x20 0x0 b)
+ if [ "$?" == '1' ]; then
+ echo "Failed to read board_id from i2c"
+ fi
+
+ # BIT[7:6:5:4]
+ # 0000 : EVT1
+ # 0001 : EVT2
+ # 0010 : EVT3
+ # 0011 :
+ # 0100 : DVT1
+ # 0101 : DVT2
+ # 0110 : DVT3
+ # 0111 :
+ # 1000 : PVT1
+ # 1001 : PVT2
+ # 1010 : PVT3
+ # 1011 :
+
+ md_id_7_6_5_4=$(( (board_id & 0xF0)>>4 ))
+
+ # P0[7] -> GPI[1] and P0[6] -> GPI[0]
+ # P[7:6] = 2'b01 for Mitchell 2.0 (PVT2)
+ # P[7:6] = 2'b00 for Mitchell 1.0 (EVTx, DVTx, PVT1 )
+ if [[ $md_id_7_6_5_4 -gt 8 ]]; then
+ # Board is MTC2.0
+ echo "Update GPI1 to low and GPI0 to high"
+ gpioset $(gpiofind gpi1)=0
+ gpioset $(gpiofind gpi0)=1
+ else
+ # Board is MTC1.0
+ echo "Update GPI1 to low and GPI0 to low"
+ gpioset $(gpiofind gpi1)=0
+ gpioset $(gpiofind gpi0)=0
+ fi
+}
+
#pre platform init function. implemented in platform_gpios_init.sh
pre-platform-init
@@ -40,6 +82,8 @@
gpioget $(gpiofind "$gpioName")
done
+mtc_board_revision_detection
+
#post platform init function. implemented in platform_gpios_init.sh
post-platform-init