diff options
Diffstat (limited to 'bsp/meta-freescale-3rdparty/recipes-core')
7 files changed, 326 insertions, 0 deletions
diff --git a/bsp/meta-freescale-3rdparty/recipes-core/init-ifupdown/init-ifupdown/ccimx6ulsbcexpress/interfaces b/bsp/meta-freescale-3rdparty/recipes-core/init-ifupdown/init-ifupdown/ccimx6ulsbcexpress/interfaces new file mode 100644 index 00000000..6d1c3d21 --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/init-ifupdown/init-ifupdown/ccimx6ulsbcexpress/interfaces @@ -0,0 +1,39 @@ +# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) + +# The loopback interface +auto lo +iface lo inet loopback + +# Wireless interfaces + +# Client infrastructure mode +auto wlan0 +iface wlan0 inet static + address 192.168.8.2 + netmask 255.255.255.0 + network 192.168.8.0 + wireless_mode managed + wireless_essid any + wpa-driver nl80211 + wpa-conf /etc/wpa_supplicant.conf + +# SoftAP mode +auto wlan1 +iface wlan1 inet static + address 192.168.9.2 + netmask 255.255.255.0 + network 192.168.9.0 + post-up /etc/init.d/hostapd start + pre-down /etc/init.d/hostapd stop + +# Wired interfaces +auto eth0 +iface eth0 inet dhcp + +# Ethernet/RNDIS gadget (g_ether) +# ... or on host side, usbnet and random hwaddr +iface usb0 inet static + address 192.168.7.2 + netmask 255.255.255.0 + network 192.168.7.0 + gateway 192.168.7.1 diff --git a/bsp/meta-freescale-3rdparty/recipes-core/init-ifupdown/init-ifupdown/ccimx6ulsbcpro/interfaces b/bsp/meta-freescale-3rdparty/recipes-core/init-ifupdown/init-ifupdown/ccimx6ulsbcpro/interfaces new file mode 100644 index 00000000..281f91c4 --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/init-ifupdown/init-ifupdown/ccimx6ulsbcpro/interfaces @@ -0,0 +1,40 @@ +# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8) + +# The loopback interface +auto lo +iface lo inet loopback + +# Wireless interfaces + +# Client infrastructure mode +auto wlan0 +iface wlan0 inet static + address 192.168.8.2 + netmask 255.255.255.0 + network 192.168.8.0 + wireless_mode managed + wireless_essid any + wpa-driver nl80211 + wpa-conf /etc/wpa_supplicant.conf + +# SoftAP mode +auto wlan1 +iface wlan1 inet static + address 192.168.9.2 + netmask 255.255.255.0 + network 192.168.9.0 + post-up /etc/init.d/hostapd start + pre-down /etc/init.d/hostapd stop + +# Wired interfaces +auto eth1 +iface eth0 inet dhcp +iface eth1 inet dhcp + +# Ethernet/RNDIS gadget (g_ether) +# ... or on host side, usbnet and random hwaddr +iface usb0 inet static + address 192.168.7.2 + netmask 255.255.255.0 + network 192.168.7.0 + gateway 192.168.7.1 diff --git a/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi.bb b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi.bb new file mode 100644 index 00000000..c438c91c --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi.bb @@ -0,0 +1,25 @@ +# Copyright (C) 2019 Digi International. + +DESCRIPTION = "udev rules for Digi International SOMs" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI_ccimx6ul = " \ + file://81-qcom-wifi.rules \ + file://qca6564-init-wifi.sh \ + file://81-qcom-bt.rules \ + file://qca6564-attach.sh \ +" + +S = "${WORKDIR}" + +do_install_ccimx6ul () { + install -d ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/81-qcom-wifi.rules ${D}${sysconfdir}/udev/rules.d/ + install -m 0644 ${WORKDIR}/81-qcom-bt.rules ${D}${sysconfdir}/udev/rules.d/ + install -d ${D}${sysconfdir}/udev/scripts/ + install -m 0755 ${WORKDIR}/qca6564-init-wifi.sh ${D}${sysconfdir}/udev/scripts/ + install -m 0755 ${WORKDIR}/qca6564-attach.sh ${D}${sysconfdir}/udev/scripts/ +} + +COMPATIBLE_MACHINE = "(ccimx6ul)" diff --git a/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/81-qcom-bt.rules b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/81-qcom-bt.rules new file mode 100644 index 00000000..aee7fd75 --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/81-qcom-bt.rules @@ -0,0 +1,2 @@ +# Attach QCA6564 Bluetooth (uart) +SUBSYSTEM=="tty", KERNEL=="ttymxc0", ACTION=="add", RUN="/etc/udev/scripts/qca6564-attach.sh start" diff --git a/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/81-qcom-wifi.rules b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/81-qcom-wifi.rules new file mode 100644 index 00000000..0f32f74a --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/81-qcom-wifi.rules @@ -0,0 +1,2 @@ +# Load Qualcomm wireless module (sdio) +SUBSYSTEM=="sdio", ACTION=="add", ENV{MODALIAS}=="sdio:c00v0271d050A", RUN="/etc/udev/scripts/qca6564-init-wifi.sh" diff --git a/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/qca6564-attach.sh b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/qca6564-attach.sh new file mode 100644 index 00000000..ef34c619 --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/qca6564-attach.sh @@ -0,0 +1,97 @@ +#!/bin/sh +#=============================================================================== +# +# Copyright (C) 2019 by Digi International Inc. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published by +# the Free Software Foundation. +# +# +# !Description: Initialize bluetooth hardware +# +#=============================================================================== + +# Bluetooth power GPIO +BT_EN_QCA_GPIO_NR="137" + +# set_gpio_value <gpio_nr> <value> +set_gpio_value() { + local SG_GPIONR="${1}" + local SG_GPIOVAL="${2}" + local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}" + + [ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export + printf out > "${SG_GPIOPATH}/direction" && sleep .2 + printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2 + [ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport +} + +# powercycle_gpio <gpio_nr> +powercycle_gpio() { + set_gpio_value "${1}" 0 + set_gpio_value "${1}" 1 +} + +set_mac_address() { + # Get MAC address from the device tree. Use a default value if it has not been set. + BT_MACADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/bluetooth/mac-address 2>/dev/null | sed 's/:$//g')" + if [ -z "${BT_MACADDR}" ] || [ "${BT_MACADDR}" = "00:00:00:00:00:00" ]; then + BT_MACADDR="00:04:F3:FF:FF:BB" + fi + + # Convert the BT address to the hcitool command format. + # Example: "00:04:F3:11:22:33" coverted to "33 22 11 F3 04 00" + HCI_BT_ADDR="$(echo ${BT_MACADDR} | sed -e 's,^\(..\):\(..\):\(..\):\(..\):\(..\):\(..\)$,\6 \5 \4 \3 \2 \1,g')" + + # Up the interface to be able to send hci commands + hciconfig hci0 up || echo "Cannot bring up bluetooth interface after initial attach" || exit 1 + + # Set the MAC address + hcitool -i hci0 cmd 3F 000B 01 02 06 ${HCI_BT_ADDR} > /dev/null || echo "Unable to set BT MAC Address" || exit 1 + + # Bring the interface down/up to apply the MAC change + hciconfig hci0 down || echo "Cannot bring down bluetooth interface after setting MAC" || exit 1 + hciconfig hci0 up || echo "Cannot bring up bluetooth interface after setting MAC" || exit 1 + +} + +bluetooth_init() { + # Start the Bluetooth driver and bring up the interface + killproc hciattach + powercycle_gpio "${BT_EN_QCA_GPIO_NR}" + hciattach ttymxc0 qualcomm 115200 -t3 flow unused > /dev/null 2>&1 || BT_ERROR="FAIL (hciattach)" + set_mac_address || BT_ERROR="Unable to set MAC address" +} + +# Source function library +. /etc/init.d/functions + +case "$1" in + start) + if [ -d "/proc/device-tree/bluetooth" ]; then + echo -n "Starting bluetooth hardware: " + bluetooth_init + echo "${BT_ERROR:-done.}" + fi + ;; + stop) + if [ -d "/sys/class/bluetooth/hci0" ]; then + echo -n "Stopping bluetooth hardware: " + killproc hciattach + # Power down bluetooth + set_gpio_value "${BT_EN_QCA_GPIO_NR}" 0 + echo "done." + fi + ;; + restart) + $0 stop + sleep 1 + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/qca6564-init-wifi.sh b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/qca6564-init-wifi.sh new file mode 100644 index 00000000..fe3be3b4 --- /dev/null +++ b/bsp/meta-freescale-3rdparty/recipes-core/udev/udev-rules-digi/ccimx6ul/qca6564-init-wifi.sh @@ -0,0 +1,121 @@ +#!/bin/sh +# +# Copyright (c) 2019 Digi International Inc. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at http://mozilla.org/MPL/2.0/. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +# At this point of the boot (udev script), the system log (syslog) is not +# available yet, so use the kernel log buffer from userspace. +log() { + printf "<$1>qca6564: $2\n" >/dev/kmsg +} + +# Do nothing if the module is already loaded +grep -qws 'wlan' /proc/modules && exit 0 + +FIRMWARE_DIR="/lib/firmware" +MACFILE="${FIRMWARE_DIR}/wlan/wlan_mac.bin" +TMP_MACFILE="$(mktemp -t wlan_mac.XXXXXX)" + +# Read the MACs from DeviceTree. We can have up to four wireless interfaces +# The only required one is wlan0 that is mapped with device tree mac address +# without suffix. +for index in $(seq 0 3); do + MAC_ADDR="$(hexdump -ve '1/1 "%02X"' /proc/device-tree/wireless/mac-address${index%0} 2>/dev/null)" + if [ "${index}" = "0" ] && { [ -z "${MAC_ADDR}" ] || [ "${MAC_ADDR}" = "00:00:00:00:00:00" ]; }; then + # Set a default MAC for wlan0 + MAC_ADDR="0004F3FFFFFB" + fi + + # Add the MAC address to the firmware file with the expected format + echo "Intf${index}MacAddress=${MAC_ADDR}" >> ${TMP_MACFILE} +done + +# Override the MAC firmware file only if the MAC file has changed. +if ! cmp -s ${TMP_MACFILE} ${MACFILE}; then + cp ${TMP_MACFILE} ${MACFILE} +fi +rm -f "${TMP_MACFILE}" + +OTP_REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null | tr -d '\0')" +DTB_REGION_CODE="$(cat /proc/device-tree/wireless/regulatory-domain 2>/dev/null | tr -d '\0')" +US_CODE="0x0" +WW_CODE="0x1" +JP_CODE="0x2" +# Check if the DTB_REGION_CODE is in the list of valid codes, +# if not use the OTP programmed value. +case "${DTB_REGION_CODE}" in + ${US_CODE} | ${WW_CODE} | ${JP_CODE}) + REGULATORY_DOMAIN="${DTB_REGION_CODE}";; + *) + if [ -n "${DTB_REGION_CODE}" ]; then + log "5" "[WARN] Invalid region code in device tree, using OTP value" + fi + REGULATORY_DOMAIN="${OTP_REGION_CODE}";; +esac + + +# Create symbolic links to the proper FW files depending on the country region +# Use a sub-shell here to change to firmware directory +( + cd "${FIRMWARE_DIR}" + + BDATA_SOURCE="bdwlan30_US.bin" + case "${REGULATORY_DOMAIN}" in + ${US_CODE}) + log "5" "Setting US wireless region";; + ${WW_CODE}|${JP_CODE}) + if [ -f "bdwlan30_World.bin" ]; then + log "5" "Setting WW (world wide) wireless region" + BDATA_SOURCE="bdwlan30_World.bin" + else + log "5" "[WARN] No WW (worldwide) board data file, using US" + fi + ;; + "") + log "5" "[WARN] region code not found, using US";; + *) + log "5" "[WARN] Invalid region code, using US";; + esac + + # We don't want to rewrite NAND every time we boot so only + # change the links if they are wrong. + BDATA_LINK="bdwlan30.bin" + UTFBDATA_LINK="utfbd30.bin" + if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${BDATA_SOURCE}"; then + ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}" + ln -sf "${BDATA_SOURCE}" "${UTFBDATA_LINK}" + fi +) + +# Load the wireless module with the params defined in modprobe.d/qca6564.conf +# and reduce the console log level to avoid debug messages at boot time +LOGLEVEL="$(sed -ne 's,^kernel.printk[^=]*=[[:blank:]]*\(.*\)$,\1,g;T;p' /etc/sysctl.conf 2>/dev/null)" +[ -n "${LOGLEVEL}" ] && sysctl -q -w kernel.printk="${LOGLEVEL}" +modprobe wlan + +# Verify the interface is present +if [ -d "/sys/class/net/wlan0" ]; then + # Create 'wlan1' virtual interface + if [ -s "/proc/device-tree/wireless/mac-address1" ] && + [ -s "/proc/device-tree/wireless/mac-address2" ] && + [ -s "/proc/device-tree/wireless/mac-address3" ]; then + : + else + echo "[WARN] Using default MAC addresses for virtual interfaces." + fi + iw dev wlan0 interface add wlan1 type __ap +else + log "3" "[ERROR] Loading qca6564 module" +fi |