summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2022-10-31 14:46:37 -0500
committerJohn Klug <john.klug@multitech.com>2023-05-24 16:28:46 -0500
commitb896db61b5da7f117beea0ad783359e85a5a0f29 (patch)
tree9696f3fc8547d23a9f13754d3b46d4e831ed5e14
parentc26ad9368a1ff1513448ec83d760b9204d0dda3b (diff)
downloadmeta-mlinux-atmel-b896db61b5da7f117beea0ad783359e85a5a0f29.tar.gz
meta-mlinux-atmel-b896db61b5da7f117beea0ad783359e85a5a0f29.tar.bz2
meta-mlinux-atmel-b896db61b5da7f117beea0ad783359e85a5a0f29.zip
Linux 5.4 MTAC Ethernet fix so AP1 is eth1 and AP2 is eth2
-rw-r--r--recipes-core/udev/eudev/mtcdt/accessory_ethernet.rules11
-rwxr-xr-xrecipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh46
-rw-r--r--recipes-core/udev/eudev_%.bbappend5
3 files changed, 57 insertions, 5 deletions
diff --git a/recipes-core/udev/eudev/mtcdt/accessory_ethernet.rules b/recipes-core/udev/eudev/mtcdt/accessory_ethernet.rules
index 2d559de..5426544 100644
--- a/recipes-core/udev/eudev/mtcdt/accessory_ethernet.rules
+++ b/recipes-core/udev/eudev/mtcdt/accessory_ethernet.rules
@@ -18,8 +18,11 @@
# ...........
# Four port to four port hub case
-KERNELS=="1-2.1.1:1.0", SUBSYSTEMS=="usb", DRIVERS=="smsc75xx", NAME="eth1"
-KERNELS=="1-2.1.2:1.0", SUBSYSTEMS=="usb", DRIVERS=="smsc75xx", NAME="eth2"
+# 1-2.1:1.0 eth1 (Only in four port case)
+# 1-2.2:1.0 eth2 (Matches eth1 in the two port case)
+#
# Four port to two port hub case
-KERNELS=="1-2.2:1.0", SUBSYSTEMS=="usb", DRIVERS=="smsc75xx", NAME="eth1"
-KERNELS=="1-2.3:1.0", SUBSYSTEMS=="usb", DRIVERS=="smsc75xx", NAME="eth2"
+# 1-2.2:1.0 eth1 (matches eth2 in the four port case)
+# 1-2.3:1.0 eth2 (only in two port case)
+#
+SUBSYSTEMS=="usb", DRIVERS=="smsc75xx", RUN+="/etc/udev/scripts/mtcdt_eth_rename.sh"
diff --git a/recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh b/recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh
new file mode 100755
index 0000000..4273d30
--- /dev/null
+++ b/recipes-core/udev/eudev/mtcdt/mtcdt_eth_rename.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+I2C_DIR="/sys/bus/i2c/devices"
+
+AP1_EEPROM="$I2C_DIR/1-0050/eeprom"
+AP2_EEPROM="$I2C_DIR/1-0052/eeprom"
+hw_version1=''
+hw_version2=''
+
+if [[ -f $AP1_EEPROM ]] ; then
+ hw_version1=$(mts-id-eeprom --accessory-card --in-file "$AP1_EEPROM" 2>/dev/null | grep '^hw-version:')
+fi
+if [[ -f $AP2_EEPROM ]] ; then
+ hw_version2=$(mts-id-eeprom --accessory-card --in-file "$AP2_EEPROM" 2>/dev/null | grep '^hw-version:')
+fi
+
+AP1=0
+AP2=0
+
+if [[ $hw_version1 =~ ^hw-version:[[:space:]]*\"MTAC-ETH ]] ; then
+ AP1=1
+fi
+
+if [[ $hw_version2 =~ ^hw-version:[[:space:]]*\"MTAC-ETH ]] ; then
+ AP2=1
+fi
+
+if ((AP1 == 0)) && ((AP2 == 1)) ; then
+ if ip addr show eth1 >/dev/null 2>&1 && ! ip addr show eth2 >/dev/null 2>&1 ; then
+ ip link set eth1 name eth2
+ fi
+fi
+
+# Handle the case where we are coming out of reset.
+# udev will assign eth# where # is the first open slot starting from zero.
+# We assing by AP slot here.
+if ((AP1 == 1)) && ((AP2 == 1)) ; then
+ if (($(mts-io-sysfs show ap2/reset) == 0)) ; then
+ :
+ # Nothing to do if ap2 is in reset.
+ elif (($(mts-io-sysfs show ap1/reset) == 0)) ; then
+ if ip addr show eth1 >/dev/null 2>&1 && ! ip addr show eth2 >/dev/null 2>&1 ; then
+ ip link set eth1 name eth2
+ fi
+ fi
+fi
diff --git a/recipes-core/udev/eudev_%.bbappend b/recipes-core/udev/eudev_%.bbappend
index 446ad6e..772ab33 100644
--- a/recipes-core/udev/eudev_%.bbappend
+++ b/recipes-core/udev/eudev_%.bbappend
@@ -1,13 +1,16 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
-PR .= ".mlinux11"
+PR .= ".mlinux12"
SRC_URI_append_mtcdt = " \
file://accessory_ethernet.rules \
+ file://mtcdt_eth_rename.sh \
file://mtcdt-atmel-serial.rules \
"
do_install_append_mtcdt() {
install -m 644 ${WORKDIR}/accessory_ethernet.rules ${D}${sysconfdir}/udev/rules.d/
install -m 644 ${WORKDIR}/mtcdt-atmel-serial.rules ${D}${sysconfdir}/udev/rules.d/
+ install -d 755 ${D}${sysconfdir}/udev/scripts/
+ install -m 755 ${WORKDIR}/mtcdt_eth_rename.sh ${D}${sysconfdir}/udev/scripts/
}