summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2020-09-18 14:34:11 -0500
committerJohn Klug <john.klug@multitech.com>2021-06-22 11:39:24 -0500
commit067a4b3a3dd4a0bccd71649303487c6dcc2ca9e3 (patch)
treec1c4f9f861696ae2c2aa737f04a08077d9bd64a2
parentc4ea765062db2380cfd0327ccefe00f3848ce768 (diff)
downloadmeta-multitech-067a4b3a3dd4a0bccd71649303487c6dcc2ca9e3.tar.gz
meta-multitech-067a4b3a3dd4a0bccd71649303487c6dcc2ca9e3.tar.bz2
meta-multitech-067a4b3a3dd4a0bccd71649303487c6dcc2ca9e3.zip
Move overlay code from mts-io to mt-dt-overlay
-rwxr-xr-xrecipes-bsp/multitech/mt-dt-overlay/init91
-rw-r--r--recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb91
-rw-r--r--recipes-bsp/multitech/mts-io.inc4
-rwxr-xr-xrecipes-bsp/multitech/mts-io/mts-io115
-rw-r--r--recipes-bsp/multitech/mts-io/mts-io.mtcap.init37
-rw-r--r--recipes-bsp/multitech/mts-io_4.3.3b.bb2
6 files changed, 314 insertions, 26 deletions
diff --git a/recipes-bsp/multitech/mt-dt-overlay/init b/recipes-bsp/multitech/mt-dt-overlay/init
new file mode 100755
index 0000000..748a470
--- /dev/null
+++ b/recipes-bsp/multitech/mt-dt-overlay/init
@@ -0,0 +1,91 @@
+#!/bin/bash
+# This script must be run after mts-io
+# to read the hw-version,
+# but before anything else needs the
+# device tree.
+sysdir=/sys/devices/platform/mts-io
+
+i2c=/sys/bus/i2c/devices/
+
+DEVTREE="/sys/kernel/config/device-tree/overlays/"
+SYSFS="/usr/sbin/mts-io-sysfs"
+
+install_dtbo_dir() {
+ for f in *.dtbo ; do
+ if ! [[ -f $f ]] ; then
+ continue
+ fi
+ if ! [[ -d ${DEVTREE} ]] ; then
+ mount configfs
+ fi
+ # f2 is the extracted device name
+ base=$(basename $f .dtbo)
+ /bin/mkdir ${DEVTREE}/$base || true
+ /bin/cat $f >${DEVTREE}/$base/dtbo
+ done
+}
+
+# Device tree format:
+# [mach]
+# [rev]
+# [file1] [file2] [file3] capability
+# [flag]
+# [file1] [file2] [file3]
+setdevtree() {
+ hw=$(${SYSFS} show hw-version)
+ mach=${hw/%-*}
+ rev=${hw/#*-/}
+ echo mach is $mach
+ echo rev is $rev
+ capd="${sysdir}/capability"
+
+ # add device tree overlays, if they exist.
+ [[ -d /lib/dtoverlays ]] || return 1
+ (
+ cd /lib/dtoverlays
+
+ cd ${mach}
+
+ best="-1"
+ for d in * ; do
+ if awk "BEGIN{if ($d <= $rev)exit 1}" ; then
+ continue
+ fi
+ if awk "BEGIN{if ($d < $best)exit 1}" ; then
+ best="$d"
+ fi
+ done
+ cd $best
+ install_dtbo_dir
+ if [[ -d capability ]] ; then
+ cd capability
+ for d in * ; do
+ if [[ -f ${capd}/$d ]] ; then
+ if (($(cat ${capd}/$d) == 1)) ; then
+ echo "This device has capabilithy $d"
+ (
+ cd $d
+ install_dtbo_dir
+ )
+ fi # Install dtbo files for a capability
+ fi # Does a given capability flag exist in the mts-io platform
+ done # Loop over all capabilities for this machine and version overlays
+ fi # Is there a capability directory to be installed?
+ )
+}
+
+case $1 in
+ start)
+ /usr/bin/logger -t "mts-io" -p daemon.info -s "Loading device tree overlay"
+ setdevtree
+ ;;
+
+ stop)
+ echo "Not implemented"
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop}"
+ exit 2
+ ;;
+esac
diff --git a/recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb b/recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb
new file mode 100644
index 0000000..ba3a7ab
--- /dev/null
+++ b/recipes-bsp/multitech/mt-dt-overlay_1.0.1.bb
@@ -0,0 +1,91 @@
+DESCRIPTION = "Compile MT board device tree overlays"
+LICENSE = "(GPLv2+)"
+LIC_FILES_CHKSUM = "file://COPYING;md5=94d55d512a9ba36caa9b7df079bae19f"
+PACKAGE_ARCH = "${MACHINE_ARCH}"
+
+inherit update-rc.d
+INITSCRIPT_NAME = "${PN}"
+INITSCRIPT_PARAMS = "start 40 S ."
+
+RDEPENDS_${PN} = "bash"
+
+
+# For now, just mtcap
+COMPATIBLE_MACHINE = "(mtcap)"
+
+# By using an overlay, we should be able to support multiple pinouts
+# using the same image. The overlays go into /lib/dtoverlays.
+# There names are: [hw-version]-driver.dtbo
+# e.g. /lib/dtoverlays/MTRV1-0.0-pps.dtbo
+# The idea is that mts-io will search for the overlays, and install the
+# appropriate device tree overlay for the current hw-version.
+
+dt_dir = "/lib/dtoverlays"
+
+PR = "r1"
+
+SRC_URI = " \
+ git://git.multitech.net/mt-dt-overlay.git;protocol=git \
+ file://init \
+"
+
+SRCREV = "${PV}"
+
+DEPENDS = "virtual/kernel u-boot-mkimage-native"
+
+S = "${WORKDIR}/git"
+
+do_compile[depends] += "virtual/kernel:do_deploy virtual/kernel:do_shared_workdir"
+do_compile[nostamp] = "1"
+
+do_compile () {
+ echo MACHINE is ${MACHINE}
+ oe_runmake DTC=/usr/bin/dtc KERNEL_DIR=${STAGING_KERNEL_DIR} KERNEL_BUILD_DIR=${KERNEL_PATH} ${MACHINE}_dtbos
+}
+
+FILES_${PN} = "${dt_dir} ${sysconfdir}"
+
+addtask install after do_compile
+
+# The destination and any symlinks are defined in the source file.
+#
+# A line starting as follows " * Put: [destination]" in the source
+# defines the destination file name for the device tree binaries.
+#
+# A line starting as follows " * Link: [destination]" defines a symlink
+# to the device tree binary file.
+#
+do_install () {
+ install -d ${D}/${sysconfdir}/init.d
+ install -m 0755 ${WORKDIR}/init ${D}/${sysconfdir}/init.d/${PN}
+ # Copy files to /lib/dt-overlay/main (mtac cards will be in mtac)
+ if [ -e ${AT91BOOTSTRAP_MACHINE} ]; then
+ install -d ${D}/${dt_dir}
+ (
+ cd ${MACHINE}
+ echo "Current directory is $(pwd)"
+ for f in *.dtbo ; do
+ s=$(basename -s .dtbo $f).dtso
+ location_ln=$(egrep '^[[:space:]]*\*[[:space:]]*Put:[[:space:]]*[^[:space:]]+' $s | sed -r 's/.*Put:[[:space:]]*//')
+ echo "Binary: $f Source: $s"
+ echo "Destination: $location_ln"
+ dirname=$(dirname $location_ln)
+ install -d ${D}/${dt_dir}/$dirname
+ install ${f} ${D}/${dt_dir}/$location_ln
+ links=$(egrep '^[[:space:]]*\*[[:space:]]*Link:[[:space:]]*[^[:space:]]+' $s | sed -r 's/.*Link:[[:space:]]*//')
+ echo "All Links: "
+ echo "$links"
+ echo "End links"
+ for l in $links ; do
+ ldirname=$(dirname $l)
+ if ! [ -d "${D}/$ldirname" ] ; then
+ install -d ${D}/${dt_dir}/$ldirname
+ fi
+ echo ln -sf ${dt_dir}/$dirname/$f ${D}/${dt_dir}/$l
+ ln -sf ${dt_dir}/$location_ln ${D}/${dt_dir}/$l
+ done
+ done
+ )
+ fi
+}
+
diff --git a/recipes-bsp/multitech/mts-io.inc b/recipes-bsp/multitech/mts-io.inc
index 02b434b..917dc10 100644
--- a/recipes-bsp/multitech/mts-io.inc
+++ b/recipes-bsp/multitech/mts-io.inc
@@ -7,10 +7,10 @@ LIC_FILES_CHKSUM = "file://io-module/COPYING;md5=94d55d512a9ba36caa9b7df079bae19
file://io-tool/COPYING;md5=94d55d512a9ba36caa9b7df079bae19f \
"
do_fetch[depends] += "virtual/kernel:do_shared_workdir"
-INC_PR = "r3"
+INC_PR = "r1"
SRCREV = "${PV}"
-PR = "${INC_PR}.0-${KERNEL_MODULE_PACKAGE_SUFFIX}"
+PR = "${INC_PR}-${KERNEL_MODULE_PACKAGE_SUFFIX}"
# Some package needs to provide mts-io
RPROVIDES_kernel-module-${PN} = "mts-io"
diff --git a/recipes-bsp/multitech/mts-io/mts-io b/recipes-bsp/multitech/mts-io/mts-io
new file mode 100755
index 0000000..d33e5f4
--- /dev/null
+++ b/recipes-bsp/multitech/mts-io/mts-io
@@ -0,0 +1,115 @@
+#!/bin/bash
+
+. /etc/default/mts-io
+
+sysdir=/sys/devices/platform/mts-io
+
+i2c=/sys/bus/i2c/devices/
+
+SYSFS="/usr/sbin/mts-io-sysfs"
+
+setwificap() {
+ WIFICAP=0
+ if [[ -f ${sysdir}/capability/wifi ]] && (($(cat ${sysdir}/capability/wifi) == 1)) ; then
+ WIFICAP=1
+ fi
+}
+
+lora_init() {
+ # reset lora chip
+ mts-io-sysfs store lora/reset 1
+ mts-io-sysfs store lora/reset 0
+ usleep 100000
+ mts-io-sysfs store lora/reset 1
+}
+
+eth_init() {
+ # reset eth phy
+ mts-io-sysfs store eth-reset 1
+ mts-io-sysfs store eth-reset 0
+ usleep 100000
+ mts-io-sysfs store eth-reset 1
+}
+
+# Normal state when powered up
+wifi_init1() {
+ (($WIFICAP)) || return 0
+ # reset wlan
+ mts-io-sysfs store wlan-rst 0
+ # disable wlan
+ mts-io-sysfs store wlan-en 0
+}
+
+wifi_init2() {
+ (($WIFICAP)) || return 0
+ mts-io-sysfs store wlan-en 1
+ usleep 30000 # 30mS according to WILC1000 spec.
+ mts-io-sysfs store wlan-rst 1
+}
+
+GNSS_RESET=${sysdir}/gnss-reset
+gnss_init() {
+ set -x
+ ((GPSGNSSRESET)) || return 0
+ USLPTIME=60000
+ if [[ -f $GNSS_RESET ]] ; then
+ echo 0 >$GNSS_RESET
+ usleep $USLPTIME
+ echo 1 >$GNSS_RESET
+ fi
+}
+
+
+cell_init() {
+ # remove /dev/modem_at[0,1] symlinks
+ rm -f /dev/modem_at[0,1]
+
+ if [ -w /sys/devices/platform/mts-io/radio-power ] ; then
+ # power down the cellular chip gracefully
+ mts-io-sysfs store radio-power 0
+ # power up the cellular chip
+ mts-io-sysfs store radio-power 1
+ fi
+}
+
+start_lora_led_updater() {
+ lora-led-updater &
+}
+
+case $1 in
+ start)
+ # SPI driver for LoRa
+ modprobe spidev
+ # Point the firmware API at our i2c EEPROMs
+ echo -n ${i2c} > /sys/module/firmware_class/parameters/path
+ echo "Loading mts-io module"
+ modprobe -r atmel_mci
+ # Point the firmware API at our i2c EEPROMs
+ echo -n ${i2c} > /sys/module/firmware_class/parameters/path
+ modprobe mts_io
+ setwificap
+ wifi_init1
+ lora_init
+ eth_init
+ cell_init &
+ start_lora_led_updater
+ wifi_init2
+ gnss_init
+ modprobe atmel_mci
+ (($WIFICAP)) && modprobe wilc1000
+ (($WIFICAP)) && modprobe wilc1000-sdio
+ ;;
+
+ stop)
+ echo "Unloading mts-io module"
+ wifi_init1 # Power down wifi
+ modprobe -r wilc1000 >/dev/null 2>&1
+ modprobe -r wilc1000-sdio >/dev/null 2>&1
+ modprobe -r mts_io >/dev/null 2>&1
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop}"
+ exit 2
+ ;;
+esac
diff --git a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
index 2642de9..d33e5f4 100644
--- a/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
+++ b/recipes-bsp/multitech/mts-io/mts-io.mtcap.init
@@ -1,10 +1,11 @@
#!/bin/bash
+. /etc/default/mts-io
+
sysdir=/sys/devices/platform/mts-io
i2c=/sys/bus/i2c/devices/
-DEVTREE="/sys/kernel/config/device-tree/overlays/"
SYSFS="/usr/sbin/mts-io-sysfs"
setwificap() {
@@ -46,6 +47,18 @@ wifi_init2() {
mts-io-sysfs store wlan-rst 1
}
+GNSS_RESET=${sysdir}/gnss-reset
+gnss_init() {
+ set -x
+ ((GPSGNSSRESET)) || return 0
+ USLPTIME=60000
+ if [[ -f $GNSS_RESET ]] ; then
+ echo 0 >$GNSS_RESET
+ usleep $USLPTIME
+ echo 1 >$GNSS_RESET
+ fi
+}
+
cell_init() {
# remove /dev/modem_at[0,1] symlinks
@@ -63,26 +76,6 @@ start_lora_led_updater() {
lora-led-updater &
}
-setdevtree() {
- hw=$(${SYSFS} show hw-version)
-
- # add device tree overlays, if they exist.
- [[ -d /lib/dtoverlays ]] || return 1
- (
- cd /lib/dtoverlays
- for f in $(ls ${hw}*) ; do
- if ! [[ -d ${DEVTREE} ]] ; then
- mount configfs
- fi
- f1=${f/#${hw}-/}
- f2=${f1/%.dtbo}
- # f2 is the extracted device name
- /bin/mkdir ${DEVTREE}/$f2
- /bin/cat $f >${DEVTREE}/$f2/dtbo
- done
- )
-}
-
case $1 in
start)
# SPI driver for LoRa
@@ -94,7 +87,6 @@ case $1 in
# Point the firmware API at our i2c EEPROMs
echo -n ${i2c} > /sys/module/firmware_class/parameters/path
modprobe mts_io
- setdevtree
setwificap
wifi_init1
lora_init
@@ -102,6 +94,7 @@ case $1 in
cell_init &
start_lora_led_updater
wifi_init2
+ gnss_init
modprobe atmel_mci
(($WIFICAP)) && modprobe wilc1000
(($WIFICAP)) && modprobe wilc1000-sdio
diff --git a/recipes-bsp/multitech/mts-io_4.3.3b.bb b/recipes-bsp/multitech/mts-io_4.3.3b.bb
index 9311675..ee4fcfa 100644
--- a/recipes-bsp/multitech/mts-io_4.3.3b.bb
+++ b/recipes-bsp/multitech/mts-io_4.3.3b.bb
@@ -1,4 +1,2 @@
require mts-io.inc
-PR = "r0${KERNEL_MODULE_PACKAGE_SUFFIX}"
-