From b073fb71800a2ed16a8585b801603a1a196b737f Mon Sep 17 00:00:00 2001 From: jklug Date: Fri, 29 Jul 2016 12:07:31 -0500 Subject: Jesse Gilles bitbake layer for the RS9113 --- recipes-bsp/multitech/mts-io/mts-io | 163 +++++++++++++++++++++ recipes-kernel/rs9113/rs9113-1.3.0/kthread.patch | 34 +++++ recipes-kernel/rs9113/rs9113-1.3.0/mtcdt/defconfig | 14 ++ .../rs9113/rs9113-1.3.0/rs9113_load_modules.sh | 153 +++++++++++++++++++ .../rs9113/rs9113-1.3.0/rs9113_remove_modules.sh | 29 ++++ recipes-kernel/rs9113/rs9113_1.3.0.bb | 49 +++++++ 6 files changed, 442 insertions(+) create mode 100755 recipes-bsp/multitech/mts-io/mts-io create mode 100644 recipes-kernel/rs9113/rs9113-1.3.0/kthread.patch create mode 100644 recipes-kernel/rs9113/rs9113-1.3.0/mtcdt/defconfig create mode 100755 recipes-kernel/rs9113/rs9113-1.3.0/rs9113_load_modules.sh create mode 100755 recipes-kernel/rs9113/rs9113-1.3.0/rs9113_remove_modules.sh create mode 100644 recipes-kernel/rs9113/rs9113_1.3.0.bb diff --git a/recipes-bsp/multitech/mts-io/mts-io b/recipes-bsp/multitech/mts-io/mts-io new file mode 100755 index 0000000..565b1a7 --- /dev/null +++ b/recipes-bsp/multitech/mts-io/mts-io @@ -0,0 +1,163 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: mts-io +# Default-Start: 2345 +# Default-Stop: 016 +# Short-Description: load the mts-io driver +# Description: mts-io driver initializes the Conduit hardware and +# provides user mode access through the driver to the +# Conduit features. +### END INIT INFO + +((fail=0)) + +sysdir=/sys/devices/platform/mts-io +gpiodir=/sys/class/gpio + +USBRST=${sysdir}/usbhub-reset + +RST[0]="${sysdir}/mtq-reset" +RST[1]="${sysdir}/ap1-reset" +RST[2]="${sysdir}/ap2-reset" +RST[3]="${sysdir}/gnss-reset" +RST[4]="${sysdir}/radio-reset" +RST[5]="${sysdir}/secure-reset" +RST[6]="${sysdir}/eth-reset" +#RST[7]="${sysdir}/wifi-bt-reset" +RS9113RST="${sysdir}/wifi-bt-reset" + +USLPTIME=30000 # 30 milliseconds +WAIT="/bin/busybox usleep ${USLPTIME}" + +reset_path() { + pin=$1 + /usr/bin/logger -t "mts-io" -p info Reset $pin + + if [[ -f ${pin} ]] ; then + if ! ( (echo 1 >${pin}) && (echo 0 >${pin}) && ${WAIT} && (echo 1 >${pin}) ) ; then + /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${pin}" + fi + else + /usr/bin/logger -t "mts-io" -p error -s "${pin} does not exist" + return 1 + fi + return 0 +} +reset_array() { + ((i=${#RST[@]}-1)) + while ((i>=0)) ; do + if [[ -f ${RST[$i]} ]] ; then + if ! ( (echo 1 >${RST[i]}) ) ; then + /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RST[$i]}" + fi + else + /usr/bin/logger -t "mts-io" -p info -s "${RST[$i]} does not exist" + RST[$i]="" + fi + ((i--)) + done + while ((i>0)) ; do + if ((${#RST[$i] > 0)) && [[ -f ${RST[$i]} ]] ; then + if ! ( (echo 0 >${RST[i]}) ) ; then + /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RST[$i]}" + fi + else + /usr/bin/logger -t "mts-io" -p info -s "${RST[$i]} does not exist" + fi + done + ${WAIT} + while ((i>0)) ; do + if ((${#RST[$i] > 0)) && [[ -f ${RST[$i]} ]] ; then + if ! ( (echo 1 >${RST[i]}) ) ; then + /usr/bin/logger -t "mts-io" -p error -s "Failed write to ${RST[$i]}" + fi + else + /usr/bin/logger -t "mts-io" -p info -s "${RST[$i]} does not exist" + fi + done +} +read_card_info() { + ap1_product_id="" + ap2_product_id="" + mts_hw_version="" + + if [[ -d $sysdir/ap1 ]]; then + ap1_product_id=$(cat $sysdir/ap1/product-id) + fi + if [[ -d $sysdir/ap2 ]]; then + ap2_product_id=$(cat $sysdir/ap2/product-id) + fi +} + +mfser_init() { + found_ap1=0 + + if [[ $ap1_product_id =~ ^MTAC-MFSER- ]]; then + /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser to /dev/ttyAP1" + ln -sf /dev/ttyAP1 /dev/mfser + found_ap1=1 + fi + + if [[ $ap2_product_id =~ ^MTAC-MFSER- ]]; then + if [[ $found_ap1 = 1 ]]; then + /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser-2 to /dev/ttyAP2" + ln -sf /dev/ttyAP2 /dev/mfser-2 + else + /usr/bin/logger -t "mts-io" -p info -s "Linking /dev/mfser to /dev/ttyAP2" + ln -sf /dev/ttyAP2 /dev/mfser + fi + fi + +} + +case $1 in + start) + /usr/bin/logger -t "mts-io" -p info -s "Loading mts-io module" + if ! modprobe mts_io ; then + ((fail++)) + fi + read_card_info + if ! reset_path $USBRST ; then + ((fail++)) + fi + usleep 200 + reset_array + mfser_init + if ! reset_path $RS9113RST ; then + ((fail++)) + fi + + if ((fail == 0)) ; then + echo "OK" + else + echo "FAIL" + fi + exit $fail + ;; + + stop) + /usr/bin/logger -t "mts-io" -p info -s "Unloading mts-io module" + modprobe -r mts_io + RETVAL=$? + if ((RETVAL == 0)) ; then + echo "OK" + else + echo "FAIL" + fi + ;; + status) + if [[ -d ${sysdir} ]] ; then + echo Driver is loaded + exit 0 + else + echo Driver is not loaded + exit 3 + fi + ;; + *) + echo "Usage: $0 {start|stop|status}" + exit 2 + ;; +esac + + diff --git a/recipes-kernel/rs9113/rs9113-1.3.0/kthread.patch b/recipes-kernel/rs9113/rs9113-1.3.0/kthread.patch new file mode 100644 index 0000000..485d0ff --- /dev/null +++ b/recipes-kernel/rs9113/rs9113-1.3.0/kthread.patch @@ -0,0 +1,34 @@ +diff -rupN host/common_hal/osd/linux/onebox_thread.c host_new/common_hal/osd/linux/onebox_thread.c +--- host/common_hal/osd/linux/onebox_thread.c 2016-03-02 14:58:53.962962812 +0530 ++++ host_new/common_hal/osd/linux/onebox_thread.c 2016-03-02 14:54:04.111702855 +0530 +@@ -99,11 +99,12 @@ int kill_thread(onebox_thread_handle_t * + atomic_inc(&handle->thread_done); + ONEBOX_DEBUG(ONEBOX_ZONE_INFO,(TEXT("In %s Before setting event\n"),__func__)); + rsi_set_event(&handle->thread_event); +- wait_for_completion(&handle->thread_complete); ++ //wait_for_completion(&handle->thread_complete); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + //handle->thread_id = NULL; + kthread_stop(handle->thread_id); + #else ++ wait_for_completion(&handle->thread_complete); + handle->thread_id = 0; + #endif + #endif +diff -rupN host/wlan/wlan_hal/osd_wlan/linux/onebox_wlan_osd_ops.c host_new/wlan/wlan_hal/osd_wlan/linux/onebox_wlan_osd_ops.c +--- host/wlan/wlan_hal/osd_wlan/linux/onebox_wlan_osd_ops.c 2016-03-02 14:58:53.956962786 +0530 ++++ host_new/wlan/wlan_hal/osd_wlan/linux/onebox_wlan_osd_ops.c 2016-03-02 14:52:32.287303701 +0530 +@@ -244,11 +244,12 @@ int kill_wlan_thread(WLAN_ADAPTER w_adap + atomic_inc(&w_adapter->txThreadDone); + ONEBOX_DEBUG(ONEBOX_ZONE_INFO,(TEXT("In %s Before setting event\n"),__func__)); + os_intf_ops->onebox_set_event(&(w_adapter->sdio_scheduler_event)); +- wait_for_completion(&w_adapter->txThreadComplete); ++ //wait_for_completion(&w_adapter->txThreadComplete); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,39) + //handle->thread_id = NULL; + kthread_stop(handle->thread_id); + #else ++ wait_for_completion(&w_adapter->txThreadComplete); + handle->thread_id = 0; + #endif + return ONEBOX_STATUS_SUCCESS; diff --git a/recipes-kernel/rs9113/rs9113-1.3.0/mtcdt/defconfig b/recipes-kernel/rs9113/rs9113-1.3.0/mtcdt/defconfig new file mode 100644 index 0000000..e8dd6a7 --- /dev/null +++ b/recipes-kernel/rs9113/rs9113-1.3.0/mtcdt/defconfig @@ -0,0 +1,14 @@ +# +# Automatically generated by make menuconfig: don't edit +# +# CONFIG_SDIO is not set +CONFIG_USB=y +CONFIG_LINUX=y +# CONFIG_ANDROID is not set +ONEBOX_CONFIG_NL80211=y +# HOSTAPD_SUPPORT is not set +ENABLE_WLAN=y +ENABLE_BT=y +# ENABLE_ZIGB is not set +ONEBOX_DEBUG_ENABLE=y +# RSI_SDIO_MULTI_BLOCK_SUPPORT is not set diff --git a/recipes-kernel/rs9113/rs9113-1.3.0/rs9113_load_modules.sh b/recipes-kernel/rs9113/rs9113-1.3.0/rs9113_load_modules.sh new file mode 100755 index 0000000..0a16db0 --- /dev/null +++ b/recipes-kernel/rs9113/rs9113-1.3.0/rs9113_load_modules.sh @@ -0,0 +1,153 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage: $(basename $0) COEX_MODE" + echo "" + echo "COEX_MODE options: + 1 WLAN STATION /WIFI-Direct/WLAN PER + 2 WLAN ACCESS POINT(including muliple APs on different vaps) + 3 WLAN ACCESS POINT + STATION MODE(on multiple vaps) + + 4 BT CLASSIC MODE/BT CLASSIC PER MODE + 5 WLAN STATION + BT CLASSIC MODE + 6 WLAN ACCESS POINT + BT CLASSIC MODE + 8 BT LE MODE /BT LE PER MODE + 9 WLAN STATION + BT LE MODE + 12 BT CLASSIC + BT LE MODE + 14 WLAN ACCESS POINT + BT CLASSIC MODE+ BT LE MODE + " + exit 1 +fi + +COEX_MODE=$1 + +cd /opt/rs9113 + +modprobe mac80211 +modprobe bluetooth + +insmod onebox_common_gpl.ko + +insmod wlan.ko +insmod wlan_wep.ko +insmod wlan_tkip.ko +insmod wlan_ccmp.ko +insmod wlan_acl.ko +insmod wlan_xauth.ko +insmod wlan_scan_sta.ko +insmod onebox_wlan_nongpl.ko +insmod onebox_wlan_gpl.ko + +#Power_mode type +# 0 - HIGH POWER MODE +# 1 - MEDIUM POWER MODE +# 2 - LOW POWER MODE +BT_RF_TX_POWER_MODE=0 +BT_RF_RX_POWER_MODE=0 + +PARAMS=$PARAMS" bt_rf_tx_power_mode=$BT_RF_TX_POWER_MODE" +PARAMS=$PARAMS" bt_rf_rx_power_mode=$BT_RF_RX_POWER_MODE" + +insmod onebox_bt_nongpl.ko $PARAMS +insmod onebox_bt_gpl.ko + +#Driver Mode 1 END-TO-END mode, +# 2 RF Evaluation Mode + +DRIVER_MODE=1 + +# COEX MODE: +# 1 WLAN STATION /WIFI-Direct/WLAN PER +# 2 WLAN ACCESS POINT(including muliple APs on different vaps) +# 3 WLAN ACCESS POINT + STATION MODE(on multiple vaps) + +# 4 BT CLASSIC MODE/BT CLASSIC PER MODE +# 5 WLAN STATION + BT CLASSIC MODE +# 6 WLAN ACCESS POINT + BT CLASSIC MODE +# 8 BT LE MODE /BT LE PER MODE +# 9 WLAN STATION + BT LE MODE +# 12 BT CLASSIC + BT LE MODE +# 14 WLAN ACCESS POINT + BT CLASSIC MODE+ BT LE MODE + +# 16 ZIGBEE MODE/ ZIGBEE PER MODE +# 17 WLAN STATION + ZIGBEE + +#COEX_MODE=3 + +#To enable TA-level SDIO aggregation set 1 else set 0 to disable it. +TA_AGGR=4 + +#Disable Firmware load set 1 to skip FW loading through Driver else set to 0. +SKIP_FW_LOAD=0 + +#FW Download Mode +# 1 - Full Flash mode with Secondary Boot Loader +# 2 - Full RAM mode with Secondary Boot Loader +# 3 - Flash + RAM mode with Secondary Boot Loader +# 4 - Firmware loading WITHOUT Secondary Boot Loader +# Recommended to use the default mode 1 +FW_LOAD_MODE=1 + +#ps_handshake_mode +# 1 - No hand shake Mode +# 2 - Packet hand shake Mode +# 3 - GPIO Hand shake Mode +###########Default is Packet handshake mode=2 +HANDSHAKE_MODE=2 + +#SDIO Clock speed +SDIO_CLOCK_SPEED=50000 + +#Antenna diversity enable +RSI_ANTENNA_DIVERSITY=0 + +#Antenna Selection +ANT_SEL_VAL=2 # 2 Internal Antenna Selection + # 3 External Antenna Selection + +####RF_POWER_MODE Selection + +# 0x00 For Both TX and RX High Power +# 0x11 For Both TX and RX Medium Power +# 0x22 For Both TX and RX LOW Power + +# 0x10 For High Power TX and Medium RX Power +# 0x20 For High Power TX and LOW RX Power + +# 0x01 For Medium TX and RX High Power +# 0x21 For Medium Power TX and LOW RX Power + +# 0x02 For Low Power TX and RX High Power +# 0x12 For LOW Power TX and Medium RX Power + + +WLAN_RF_PWR_MODE=0x00 +BT_RF_PWR_MODE=0x00 +ZIGB_RF_PWR_MODE=0x00 + +#COUNTRY Selection +# 0 World Domain +# 840 US Domain Maps to US Region +# 276 Germany Maps to EU Region +# 392 Japan Maps to Japan Region +SET_COUNTRY_CODE=0 + +PARAMS=" driver_mode=$DRIVER_MODE" +PARAMS=$PARAMS" firmware_path=/opt/rs9113/firmware/" +PARAMS=$PARAMS" onebox_zone_enabled=0x1" +PARAMS=$PARAMS" ta_aggr=$TA_AGGR" +PARAMS=$PARAMS" skip_fw_load=$SKIP_FW_LOAD" +PARAMS=$PARAMS" fw_load_mode=$FW_LOAD_MODE" +PARAMS=$PARAMS" sdio_clock=$SDIO_CLOCK_SPEED" +PARAMS=$PARAMS" enable_antenna_diversity=$RSI_ANTENNA_DIVERSITY" +PARAMS=$PARAMS" coex_mode=$COEX_MODE" +#PARAMS=$PARAMS" ps_handshake_mode=$HANDSHAKE_MODE" +PARAMS=$PARAMS" obm_ant_sel_val=$ANT_SEL_VAL" +PARAMS=$PARAMS" wlan_rf_power_mode=$WLAN_RF_PWR_MODE" +PARAMS=$PARAMS" bt_rf_power_mode=$BT_RF_PWR_MODE" +PARAMS=$PARAMS" zigb_rf_power_mode=$ZIGB_RF_PWR_MODE" +PARAMS=$PARAMS" country_code=$SET_COUNTRY_CODE" + +insmod onebox_nongpl.ko $PARAMS +insmod onebox_gpl.ko + diff --git a/recipes-kernel/rs9113/rs9113-1.3.0/rs9113_remove_modules.sh b/recipes-kernel/rs9113/rs9113-1.3.0/rs9113_remove_modules.sh new file mode 100755 index 0000000..bcd885a --- /dev/null +++ b/recipes-kernel/rs9113/rs9113-1.3.0/rs9113_remove_modules.sh @@ -0,0 +1,29 @@ +killall -9 wpa_supplicant +killall -9 hostapd +rm -rf /var/run/wpa_supplicant/ +sleep 2 + +### COMMON HAL MODULES +rmmod onebox_gpl.ko +rmmod onebox_nongpl.ko + +###WLAN MODULES +rmmod onebox_wlan_gpl.ko +rmmod onebox_wlan_nongpl.ko +rmmod wlan_scan_sta.ko +rmmod wlan_xauth.ko +rmmod wlan_acl.ko +rmmod wlan_tkip.ko +rmmod wlan_ccmp.ko +rmmod wlan_wep.ko +rmmod wlan.ko + +###BT MODULES +rmmod onebox_bt_gpl.ko +rmmod onebox_bt_nongpl.ko + +###ZIGB MODULES +#rmmod onebox_zigb_gpl.ko +#rmmod onebox_zigb_nongpl.ko + +rmmod onebox_common_gpl.ko diff --git a/recipes-kernel/rs9113/rs9113_1.3.0.bb b/recipes-kernel/rs9113/rs9113_1.3.0.bb new file mode 100644 index 0000000..be52385 --- /dev/null +++ b/recipes-kernel/rs9113/rs9113_1.3.0.bb @@ -0,0 +1,49 @@ +DESCRIPTION = "USB Driver for Redpine RS9113" +SECTION = "base" +PRIORITY = "optional" +LICENSE = "Proprietary" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28" + +SRC_URI = " \ + file://RS9113.NBZ.NL.GENR.LNX.1.3.0.tgz \ + file://kthread.patch \ + file://defconfig \ + file://rs9113_load_modules.sh \ + file://rs9113_remove_modules.sh \ + file://rs9113.init \ +" + +S = "${WORKDIR}/RS9113.NBZ.NL.GENR.LNX.1.3.0/source/host" + +EXTRA_OEMAKE = " KERNELDIR=${STAGING_KERNEL_DIR} \ + CROSS_COMPILE=${TARGET_PREFIX} \ + ARCH=arm \ + WLAN_COMPILE_FLAGS='' \ + " + +do_configure() { + cp ${WORKDIR}/defconfig .config +} + +do_compile () { + unset CFLAGS CPPFLAGS CXXFLAGS LDFLAGS + oe_runmake +} + +FILES_${PN} = "/opt/rs9113 ${sbindir}" +FILES_${PN}-dbg = "/opt/rs9113/.debug/" + +PARALLEL_MAKE = "" + +do_install() { + install -m 0755 -d ${D}/opt/rs9113 + cp -r ${S}/release/* ${D}/opt/rs9113/ + + install -m 0755 -d ${D}${sbindir} + install -m 0755 ${WORKDIR}/rs9113_load_modules.sh ${D}${sbindir}/ + install -m 0755 ${WORKDIR}/rs9113_remove_modules.sh ${D}${sbindir}/ +} + +python do_clean() { + bb.note("Skipping clean in rs9113 recipe.") +} -- cgit v1.2.3