Initial commit of aiy-board-wlan

- Disable random mac for scanning (QCACLD driver doesn't like it)
- Add service to enable the wifi driver
- Firmware binaries for the module

Change-Id: I181ec0ef4644950353cfda400460aea0791ee7d1
diff --git a/debian/aiy-board-wlan.install b/debian/aiy-board-wlan.install
new file mode 100644
index 0000000..d0b7fe8
--- /dev/null
+++ b/debian/aiy-board-wlan.install
@@ -0,0 +1,2 @@
+etc /
+lib /
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..6c8356f
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+aiy-board-wlan (0.1) UNRELEASED; urgency=medium
+
+  * Initial release.
+
+ -- AIY Projects <support-aiy@google.com>  Mon, 04 Jun 2018 16:14:00 -0800
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 0000000..f599e28
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+10
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..6642fe1
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,9 @@
+Source: aiy-board-wlan
+Maintainer: AIY Projects <support-aiyprojects@google.com>
+
+Package: aiy-board-wlan
+Section: net
+Priority: required
+Architecture: all
+Depends:
+Description: Additional configuration for AIY Board wireless networking
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 0000000..5b390e6
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,7 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: aiy-board-wlan
+Source: https://aiyprojects.withgoogle.com
+
+Files: *
+Copyright: Copyright 2018 Google, LLC <support-aiyprojects@google.com>
+License: Apache-2.0
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..ea37544
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,8 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+# export DH_VERBOSE=1
+
+%:
+	dh $@
diff --git a/etc/NetworkManager/conf.d/wifi.scan-rand-mac-address.conf b/etc/NetworkManager/conf.d/wifi.scan-rand-mac-address.conf
new file mode 100644
index 0000000..0763348
--- /dev/null
+++ b/etc/NetworkManager/conf.d/wifi.scan-rand-mac-address.conf
@@ -0,0 +1,2 @@
+[device]
+wifi.scan-rand-mac-address=no
diff --git a/lib/firmware/bdwlan30.bin b/lib/firmware/bdwlan30.bin
new file mode 100644
index 0000000..e77a4a8
--- /dev/null
+++ b/lib/firmware/bdwlan30.bin
Binary files differ
diff --git a/lib/firmware/otp30.bin b/lib/firmware/otp30.bin
new file mode 100644
index 0000000..84a40e3
--- /dev/null
+++ b/lib/firmware/otp30.bin
Binary files differ
diff --git a/lib/firmware/qwlan30.bin b/lib/firmware/qwlan30.bin
new file mode 100644
index 0000000..818e081
--- /dev/null
+++ b/lib/firmware/qwlan30.bin
Binary files differ
diff --git a/lib/firmware/utf30.bin b/lib/firmware/utf30.bin
new file mode 100644
index 0000000..cfbfb2d
--- /dev/null
+++ b/lib/firmware/utf30.bin
Binary files differ
diff --git a/lib/firmware/wlan/qcom_cfg.ini b/lib/firmware/wlan/qcom_cfg.ini
new file mode 100644
index 0000000..63f47e8
--- /dev/null
+++ b/lib/firmware/wlan/qcom_cfg.ini
@@ -0,0 +1,402 @@
+# This file allows user to override the factory
+
+# defaults for the WLAN Driver
+
+#Host module debug
+vosTraceEnableHDD=0
+vosTraceEnableWDA=0
+vosTraceEnableWDI=0
+vosTraceEnableSME=0
+vosTraceEnablePE=0
+vosTraceEnableWMA=0
+vosTraceEnableVOSS=0
+gEnableLogp=1
+
+#Prioritize user(hostapd, iw,) specified country
+gCountryCodePriority=1 
+
+#Host logging
+gMulticastHostFwMsgs=0
+
+#packetlog 
+gEnablePacketLog=0
+
+#Enable firmware uart print
+gEnablefwprint=0
+
+#Enable firmware log
+gEnablefwlog=0
+
+# Disable FW log function by default
+gFwDebugLogType=0
+gFwDebugModuleLoglevel=0,0
+
+# Generic
+
+# Phy Mode (auto, b, g, n, etc)
+# Valid values are 0-9, with 0 = Auto, 4 = 11n, 9 = 11ac
+# 1 = 11abg, 2 = 11b, 3 = 11g, 5 = 11g only, 6 = 11n only
+# 7 = 11b only 8 = 11ac only.
+gDot11Mode=0
+
+# VHT Tx/Rx MCS values
+# Valid values are 0,1,2. If commented out, the default value is 0.
+# 0=MCS0-7, 1=MCS0-8, 2=MCS0-9
+gVhtRxMCS=2
+gVhtTxMCS=2
+
+# VHT Tx/Rx MCS values for 2x2
+# Valid values are 0,1,2. If commented out, the default value is 0.
+# 0=MCS0-7, 1=MCS0-8, 2=MCS0-9
+gEnable2x2=1
+gVhtRxMCS2x2=2
+gVhtTxMCS2x2=2
+
+gVhtChannelWidth=2
+
+#Short Guard Interval Enable/disable
+gShortGI20Mhz=1
+gShortGI40Mhz=1
+
+#Channel Bonding
+gChannelBondingMode5GHz=1
+
+# 1=enable STBC; 0=disable STBC
+gEnableRXSTBC=1
+
+# 1=enable tx STBC; 0=disable
+gEnableTXSTBC=1
+
+# 1=enable rx LDPC; 0=disable
+gEnableRXLDPC=1
+
+#If set to 0, MCC is not allowed.
+gEnableMCCMode=1
+
+# Enable or Disable MCC Adaptive Scheduler at the FW
+# 1=Enable (default), 0=Disable
+gEnableMCCAdaptiveScheduler=1
+
+# Enable BMPS or not
+gEnableBmps=1
+
+# Enable IMPS or not
+gEnableImps=1
+
+# Enable/Disable Idle Scan
+gEnableIdleScan=0
+
+#Data Inactivity Timeout when in powersave (in ms)
+gDataInactivityTimeout=200
+
+# Increase sleep duration (seconds) during IMPS
+# 0 implies no periodic wake up from IMPS. Periodic wakeup is
+# unnecessary if Idle Scan is disabled.
+gImpsModSleepTime=0
+
+# Enable suspend or not
+# 1: Enable standby, 2: Enable Deep sleep, 3: Enable Mcast/Bcast Filter
+gEnableSuspend=3
+
+
+#Enable/Disable UAPSD for SoftAP
+gEnableApUapsd=1
+
+# UAPSD service interval for VO,VI, BE, BK traffic
+InfraUapsdVoSrvIntv=0
+InfraUapsdViSrvIntv=0
+InfraUapsdBeSrvIntv=0
+InfraUapsdBkSrvIntv=0
+
+# Flag to allow STA send AddTspec even when ACM is Off
+gAddTSWhenACMIsOff=1
+
+# Beacon filtering frequency (unit in beacon intervals)
+gNthBeaconFilter=50
+
+# Enable WAPI or not
+WAPIIsEnabled=0
+# Flags to filter Mcast abd Bcast RX packets.
+# Value 0: No filtering, 1: Filter all Multicast.
+# 2: Filter all Broadcast. 3: Filter all Mcast abd Bcast
+McastBcastFilter=3
+
+#Flag to enable HostARPOffload feature or not
+hostArpOffload=0
+
+#Flag to enable TCPChkSumOffld feature or not
+gEnableTCPChkSumOffld=0
+
+#Flag to enable HostNSOffload feature or not
+hostNSOffload=0
+
+#Flag to enable IPChkSumOffld feature or not
+gEnableIPChecksumOffload=0
+
+# 802.11n Protection flag
+gEnableApProt=1
+
+#Enable OBSS protection
+gEnableApOBSSProt=1
+
+# Fixed Rate
+gFixedRate=0
+
+# RTS threshold
+RTSThreshold=192000
+
+# Intra-BSS forward
+gDisableIntraBssFwd=0
+
+# WMM Enable/Disable
+WmmIsEnabled=0
+
+# 802.11d support
+g11dSupportEnabled=1
+
+# 802.11h support
+g11hSupportEnabled=1
+
+# ESE Support and fast transition
+EseEnabled=0
+ImplicitQosIsEnabled=0
+gNeighborScanTimerPeriod=200
+
+gNeighborLookupThreshold=76
+gNeighborReassocThreshold=81
+
+gNeighborScanChannelMinTime=20
+gNeighborScanChannelMaxTime=30
+gMaxNeighborReqTries=3
+
+gEnableFastRoamInConcurrency=1
+
+# CSR Roaming Enable(1) Disable(0)
+gRoamingTime=0
+
+# Roaming Preference
+gRoamPrefer5GHz=1
+gSelect5GHzMargin=20
+
+# Legacy (non-ESE, non-802.11r) Fast Roaming Support
+# To enable, set FastRoamEnabled=1
+# To disable, set FastRoamEnabled=0
+FastRoamEnabled=1
+
+#Check if the AP to which we are roaming is better than current AP in terms of RSSI.
+#Checking is disabled if set to Zero.Otherwise it will use this value as to how better
+#the RSSI of the new/roamable AP should be for roaming
+RoamRssiDiff=3
+
+# If the RSSI of any available candidate is better than currently associated
+# AP by at least gImmediateRoamRssiDiff, then being to roam immediately (without
+# registering for reassoc threshold).
+# NOTE: Value of 0 means that we would register for reassoc threshold.
+gImmediateRoamRssiDiff=10
+
+# To enable, set gRoamIntraBand=1 (Roaming within band)
+# To disable, set gRoamIntraBand=0 (Roaming across band)
+gRoamIntraBand=0
+
+# SAP Country code
+# Default Country Code is 2 bytes, 3rd byte is optional indoor or out door.
+# Example
+#   US Indoor, USI
+#   Korea Outdoor, KRO
+#   Japan without optional byte, JP
+#   France without optional byte, FR
+#gAPCntryCode=US
+
+#Auto Shutdown  Value in seconds. A value of 0 means Auto shutoff is disabled
+gAPAutoShutOff=0
+
+# SAP auto channel selection configuration
+# 0 = disable auto channel selection
+# 1 = enable auto channel selection, channel provided by supplicant will be ignored
+gApAutoChannelSelection=0
+
+#Preferred band (both or 2.4 only or 5 only)
+BandCapability=0
+
+#Beacon Early Termination (1 = enable the BET feature, 0 = disable)
+enableBeaconEarlyTermination=0
+beaconEarlyTerminationWakeInterval=3
+
+#SOFTAP Channel Range selection
+gAPChannelSelectStartChannel=1
+gAPChannelSelectEndChannel=11
+
+#SOFTAP Channel Range selection Operating band
+# 0:2.4GHZ 1: LOW-5GHZ 2:MID-5GHZ 3:HIGH-5GHZ 4: 4.9HZ BAND
+gAPChannelSelectOperatingBand=0
+
+# Listen Energy Detect Mode Configuration
+# Valid values 0-128
+# 128 means disable Energy Detect feature
+# 0-9 are threshold code and 7 is recommended value from system if feature is to be enabled.
+# 10-128 are reserved.
+# The EDET threshold mapping is as follows in 3dB step:
+# 0 = -60 dBm
+# 1 = -63 dBm
+# 2 = -66 dBm
+# ...
+# 7 = -81 dBm
+# 8 = -84 dBm
+# 9 = -87 dBm
+
+# Note: Any of these settings are valid. Setting 0 would yield the highest power saving (in a noisy environment) at the cost of more range. The range impact is approximately #calculated as:
+
+#
+#  Range Loss  (dB)  =  EDET threshold level (dBm) + 97 dBm.
+#
+gEnablePhyAgcListenMode=128
+
+#Enable Keep alive with non-zero period value
+gStaKeepAlivePeriod = 30
+#Say gGoKeepAlivePeriod(5 seconds) and gGoLinkMonitorPeriod(10 seconds).
+#For every 10 seconds DUT send Qos Null frame(i.e., Keep Alive frame if link is idle for last 10 seconds.)
+#For both active and power save clients.
+
+#Power save clients: DUT set TIM bit from 10th second onwards and till client honors TIM bit.
+#If doesn't honor for 5 seconds then DUT remove client.
+
+#Active clients: DUT send Qos Null frame for 10th seconds onwards if it is not success still we try on
+#11th second if not tries on 12th and so on till 15th second. Hence before disconnection DUT will send 5 NULL frames.
+#Hence in any case DUT will detect client got removed in (10+5) seconds. i.e., (gGoKeepAlivePeriod + gGoLinkMonitorPeriod)..
+
+#gGoLinkMonitorPeriod/ gApLinkMonitorPeriod is period where link is idle and it is period
+#where we send NULL frame.
+gApLinkMonitorPeriod = 10
+gGoLinkMonitorPeriod = 10
+
+#gGoKeepAlivePeriod/gApKeepAlivePeriod is time to spend to check whether frame are succeed to send or not.
+#Hence total effective detection time is gGoLinkMonitorPeriod+ gGoKeepAlivePeriod/gApLinkMonitorPeriod+ gApKeepAlivePeriod.
+gGoKeepAlivePeriod = 20
+gApKeepAlivePeriod = 20
+
+#If set will start with active scan after driver load, otherwise will start with
+#passive scan to find out the domain
+gEnableBypass11d=1
+
+#If set to 0, will not scan DFS channels
+gEnableDFSChnlScan=1
+
+# Enable Automatic Tx Power control
+gEnableAutomaticTxPowerControl=1
+
+# 0 for OLPC 1 for CLPC and SCPC
+gEnableCloseLoop=1
+
+# Scan Timing Parameters
+gPassiveMaxChannelTime=110
+gPassiveMinChannelTime=60
+gActiveMaxChannelTime=40
+gActiveMinChannelTime=20
+
+# Enable Active mode offload
+gEnableActiveModeOffload=1
+
+#Enable Scan Results Aging based on timer
+#Timer value is in seconds
+#If Set to 0 it will not enable the feature
+gScanAgingTime=0
+
+#Enable Power saving mechanism Based on Android Framework
+#If set to 0 Driver internally control the Power saving mechanism
+#If set to 1 Android Framwrok control the Power saving mechanism
+isAndroidPsEn=0
+
+#disable LDPC in STA mode if the AP is TXBF capable
+gDisableLDPCWithTxbfAP=0
+
+#Enable thermal mitigation
+gThermalMitigationEnable=1
+gThermalTempMinLevel1=90
+gThermalTempMaxLevel0=110
+gThermalTempMaxLevel1=115
+gThrottlePeriod=100
+
+#List of Country codes for which 11ac needs to be disabled
+#Each country code must be delimited by comma(,)
+gListOfNon11acCountryCode=RU,UA,ZA
+
+#Maxium Channel time in msec
+gMaxMediumTime = 6000
+
+#FlexConnect Power Factor
+#Default is set to 0 (disable)
+gFlexConnectPowerFactor=0
+
+#Disable split scan, the FW will take care of it
+gNumChanCombinedConc=60
+
+#Enable Power Save offload
+gEnablePowerSaveOffload=1
+
+gEnableWoW=1
+
+#Enable or Disable p2p device address administered
+isP2pDeviceAddrAdministrated=0
+
+#Disable scan_pno by default
+gPNOScanSupport=0
+
+#Enable TDLS
+gEnableTDLSSupport=1
+
+# Regulatory Setting; 0=STRICT; 1=CUSTOM
+gRegulatoryChangeCountry=1
+
+# Enable or Disable Rx thread
+# 1=Enable (default), 0=Disable
+gEnableRxThread=0
+
+# Enable or Disable FW self-recovery
+# Currently, It's for USB only.
+# 1=Enable, 0=Disable (default)
+gEnableFwSelfRecovery=0
+gEnableSelfRecovery=0
+gEnableForceTargetAssert=0
+# Enable or Disable SAP suspend
+# 1=Enable (default), 0=Disable
+gEnableSapSuspend=0
+
+# Enable TxBF
+gTxBFEnable=1
+
+# Enable or Disable WOW Pulse feature
+# 1 = Enable, 0 = Disable (default)
+gwow_pulse_support = 0
+
+#P2P Listen offload
+gEnableP2pListenOffload=1
+
+# gEnableSAPAuthOffload: Enable Software AP Authentication Offload feature
+# 1=Enable, 0=Disable (default)
+gEnableSAPAuthOffload=0
+
+# Sifs burst feature configuration
+gEnableSifsBurst=1
+gSoftApMaxPeers=10
+
+gVhtMpduLen=2
+# FW reorder
+gReorderOffloadSupported=1
+# DFS Master Capability
+gEnableDFSMasterCap=1
+
+#Fine tuned TxFlow parameters
+TxFlowLowWaterMark=300
+TxFlowHighWaterMarkOffset=94
+
+# PTA
+gCoexPtaConfigEnable=0
+gCoexPtaConfigParam=0
+gEnableNanSupport=0
+
+#ETSI
+gStaLocalEDCAForETSI=0
+#TxBF in 20MHz
+gEnableTxBFin20MHz=1
+END
+# Note: Configuration parser would not read anything past the END marker
diff --git a/lib/systemd/system/aiy-board-wlan.service b/lib/systemd/system/aiy-board-wlan.service
new file mode 100644
index 0000000..9a111d2
--- /dev/null
+++ b/lib/systemd/system/aiy-board-wlan.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=AIY Board WLAN
+
+[Service]
+Type=oneshot
+ExecStart=/bin/bash -c "echo '/lib/firmware' > /sys/module/wlan/parameters/fwpath"
+
+[Install]
+WantedBy=multi-user.target