meta-facebook: minerva: Add initial GPIO setting
Summary:
To initial GPIO setting by following minerva hardware setting
Change-Id: If005ae6a352bc93db3255e43ecea5c7475ddc78e
Signed-off-by: Yang Chen <yang.chen@quantatw.com>
diff --git a/meta-facebook/meta-minerva/recipes-minerva/plat-tool/files/minerva-common-functions b/meta-facebook/meta-minerva/recipes-minerva/plat-tool/files/minerva-common-functions
new file mode 100644
index 0000000..81b90b1
--- /dev/null
+++ b/meta-facebook/meta-minerva/recipes-minerva/plat-tool/files/minerva-common-functions
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+set_gpio()
+{
+ local NET_NAME=$1
+ local OUT_VAL=$2
+ mapfile -t -d " " GPIO_INFO < <(gpiofind "$NET_NAME")
+ if [ "${#GPIO_INFO[@]}" -ne 2 ]; then
+ echo "set_gpio: can not find gpio, $NET_NAME"
+ return 1
+ fi
+
+ echo -n "set_gpio: set $NET_NAME = $OUT_VAL"
+ if ! gpioset "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}"="$OUT_VAL"; then
+ echo " failed"
+ return 1
+ fi
+
+ echo " success"
+ return 0
+}
+
+get_gpio()
+{
+ local NET_NAME=$1
+ local RET_VAL
+
+ mapfile -t -d " " GPIO_INFO < <(gpiofind "${NET_NAME}")
+ if [ "${#GPIO_INFO[@]}" -ne 2 ]; then
+ logger -p user.info "get_gpio: can not find gpio, ${NET_NAME}"
+ return 1
+ fi
+ if ! RET_VAL=$(gpioget "${GPIO_INFO[0]}" "${GPIO_INFO[1]%$'\n'}") ; then
+ logger -p user.info "get_gpio: get ${NET_NAME} failed"
+ return 1
+ fi
+ logger -p user.info "get_gpio: get ${NET_NAME} = ${RET_VAL}"
+ echo "${RET_VAL}"
+ return 0
+}
diff --git a/meta-facebook/meta-minerva/recipes-minerva/plat-tool/minerva-common-functions_0.1.bb b/meta-facebook/meta-minerva/recipes-minerva/plat-tool/minerva-common-functions_0.1.bb
new file mode 100644
index 0000000..2f470be
--- /dev/null
+++ b/meta-facebook/meta-minerva/recipes-minerva/plat-tool/minerva-common-functions_0.1.bb
@@ -0,0 +1,13 @@
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+RDEPENDS:${PN} += " bash libgpiod-tools"
+
+SRC_URI += " \
+ file://minerva-common-functions \
+ "
+
+do_install() {
+ install -d ${D}${libexecdir}
+ install -m 0755 ${WORKDIR}/minerva-common-functions ${D}${libexecdir}
+}