You are on page 1of 68

AR6003 for Android Platform

Wilson Loi/ Date [20110324]

2011 FAE Training


1 CONFIDENTIAL

Agenda

WIFIDriveronAndroid
AndroidArchitectureaboutWLAN TheDifferencesforWIFIDriver betweenAndroidandLinux b A d id d Li HowtoCompileWIFIDriverfor AndroidEnvironment Android Environment HowtoVerifyWIFIDriverManually WIFIDriverArchitecture AndroidWIFIFlows

CONFIDENTIAL

Agenda

LinuxMMCStack
WorkingModel BusDriver:MMC,SD,SDIO TheInterfacebetweenBusDriverand HostControllerDriver TheInterfaceBetweenBusDriverand The Interface Between Bus Driver and FunctionDriver BusDriverCardPollingMechanism SDIOCardInitialization InterruptProcess

CONFIDENTIAL

Agenda IntegrationforAndroid
Chipdetection,WoW,etc. wpa_supplicant HotspotAPmode bluetooth.cforBTCOEX Bluetoothclocksharing Bl t th l k h i GoogleCTSprogram

CONFIDENTIAL

WLAN Architecture in Android


WifiManager WifiService WifiMonitor WifiWatchdog Service Java Framework

WifiStateTracker WifiNative (JNI) system/core libnetutils.so dhcpcd SQLite


keystore

hardware/wifi.c libwpa_client.so wpa_supplicant

Native Process

TCP/IP

Wireless extension AR6000 driver

Linux Kernel

CONFIDENTIAL

WLAN Architecture in Android

JAVA Applications Supplicants control interface wpa_supplicant Kernel-defined IOCTL Kernel WLAN Subsystem (Wireless Extension) Kernel-defined IOCTL WIFI Driver

CONFIDENTIAL

ThedifferencesforWIFIDriverbetweenAndroidandLinux

Androidhasitownuserspacelibrary.
Buildourwlantools,wmiconfig,bmiloader,eeprominAndroidSDKtreewith Android.mkfile A d id k fil OrwecancompileWIFIdriversapplicationtoolsbystaticlink.

Androiddoesntsupportacomprehensivescript.
Addtest.cpatchintoandroidshtosupport[]functioninscript
Westillhaveproblemtoreloadthefirmwareafterresume p

Implementallthescriptfunctionintodriver,likeWinCE
PassdrivermoduleparametersbyandroidpropertyAPI

FocusonLinuxMMCstack
Mostcustomerrequesttouselinuxmmcstack

CONFIDENTIAL

HowtoCompileWIFIDriverforAndroidEnvironment

Modify<WIFIDriver>/host/localmake.linux.inc
ATH_ANDROID_ENV:=yes y
BuildforAndroidsystem

ATH_SOFTMAC_FILE_USED:=yes
UseMACaddresswhichisstoredin/system/wifi/softmac

ATH_HTC_RAW_INT_ENV:=yes
TCMDsupport

ATH_AR6K_OTA_TEST_MODE:=no
DontenablepowersavingforOTAmode

ATH_CROSS_COMPILE_TYPE:=$(ANDROID_SDK)//toolchain//armeabi ATH_BUS_TYPE:=SDIO ATH_BUS_SUBTYPE:=linux_sdio ATH_LINUXPATH:=<Yourkernelsourcepath>


Android/out/target/product/xxxx/obj/KERNEL_OBJ

Typemaketomakethedriver
host/.output/$(ATH_BUILD)$(ATH_BUS_TYPE)/image/ar6000.ko
CONFIDENTIAL

HowtoVerifyWIFIDriverManually

Putfirmwareanddrivermoduleinthefolder
/system/wifi
ar6000.ko athwlan.bin.z77 data.patch.hw2_0.bin

LoadWIFImodule
insmod /system/wifi/ar6000.ko

CONFIDENTIAL

HowtoCompileWIFIDriverwithinAndroidSDK

1. CopyAR6kSDK.xxx/androidintoyourandroid/
android/system/wlan/atheros/AR6kSDK.xxxx android/system/wlan/atheros/AR6kSDK xxxx android/external/ath_supplicant0.6.10 android/external/hostapd 0.6.8 android/external/hostapd0.6.8

2. PatchyourSDKwithcorrespondingpatchfile 3. EnsureSettingsofAndroidandAR600x 3 Ensure Settings of Android and AR600x


Thedefinesinolca/host/Android.mkfile Android/device/<vendor>/<platform>/BoardConfig.mk
BOARD_WLAN_ATHEROS_SDK:=system/wlan/atheros/AR6kSdk.xxx WPA_SUPPLICANT_VERISON:=VER_0_6_ATHEROS

4. BuildtheAndroidsdk 4 Build the Android sdk


makej4PRODUCT<platform>eng
CONFIDENTIAL

HowtoVerifyWIFIDriverManually

KerneldebugmessageswillshowWMIisReadyif WIFIbringupsuccessfully g p y WecanverifyWIFIbasicfunctionsbyaLinux applicationpackageWirelessToolsnow ScanAPsbyiwlist


iwlisti<interface>scan

ConnecttoanAPbyiwconfig
iwconfigi<interface>essid<ESSID> iwconfig i <interface> essid <ESSID>
CONFIDENTIAL

WIFIDriverArchitecture:SomeImportantFiles

host/include/ar6000_api.h
ar6000_drv.cheaderfile ar6000 drv.c header file

host/os/linux/include/osapi_linux.h / / / / p_
IncludesOSAPIdefinitions(osapi_linux.h)

host/os/linux/include/wlan_config.h
Configurationforwifidriver

host/os/linux/include/athdrv_linux.h
IOCTLassignmentanddescriptions IOCTL assignment and descriptions
CONFIDENTIAL

WIFIDriverArchitecture:SomeImportantFiles

host/os/linux/include/ar6000_drv.h
Variousdatastructures Various data structures

host/os/linux/include/ieee80211_ioctl.h host/os/linux/include/ieee80211 ioctl h


VariousIOCTLdatastructures

host/os/linux/include/osapi_linux.h
OSdependentfunctionremapping(printk,locks,etc) OSdependentfunction remapping (printk locks etc)

host/os/linux/ar6000_drv.c / / /
Maindriverfunctions(start/stop,TX/RX)
CONFIDENTIAL

WIFIDriverArchitecture:SomeImportantFiles

host/os/linux/ar6000_android.c
MaindriverfunctionsforAndroid

host/os/linux/ar6000_pm.c
Powermanagementforwifi driver

host/os/linux/ioctl.c
IOCTLrelatedfunctions

host/os/linux/wireless.c
Thefunctionsforthekernelwirelessextension
CONFIDENTIAL

WIFI Driver Architecture: Some Important Files

ar6000_drv.c
Startup/Shutdownfunctions Startup/Shutdown functions
Initialization/destructionof WLANstates Bufferallocationandbuffer free

wireless_ext.c /ioctl.c
Driver Driver Interface Application Application

IOCTLs(applicationtodriver) Eventnotifications(driverto application)

TX/RXinterfaces TX/RX interfaces


Buffermanagement (enqueue anddequeue) QoS:IPTOStoWLANPriority

ar6000_pm.c 6000
Powermanagementforwifi on/off,suspend/resume on/off, suspend/resume

ar6000_android.c
Androidrelatedhelper p functions

CONFIDENTIAL

WIFIDriverArchitecture:Startup/Shutdownfunctions

ar6000_init_module()
InitializeHTC/Dataset/GPIOstates Initialize HTC/Dataset/GPIO states Registerar6000_avail_ev()andar6000_unavail_ev() RegisterWIFIdrivertokernelnetworksubsystemvia Register WIFI driver to kernel network subsystem via module_init()

ar6000_cleanup_module()
CleanupHTCstates UnregisterWIFIdriverviamodule_exit()

CONFIDENTIAL

WIFIDriverArchitecture:Startup/Shutdownfunctions

ar6000_avail_ev()
HTCcallsthiswhenTargetisready HTC calls this when Target is ready Registersdevicedriverfunctioncalls
netdev>hard_start_xmit ar6000_data_tx() netdev>open ar6000_open() Netdev>stop ar6000_close() netdev>do_ioctl ar6000_ioctl() () netdev>get_stats ar6000_get_stats()

ar6000_unavail_ev()
CleanupHTCandremoveallocateddevices

CONFIDENTIAL

WIFIDriverArchitecture:Startup/Shutdownfunctions

ar6000_open()
ExecuteBMIsequence Execute BMI sequence RegistereventstoHTC(send,receive,hasdata,etc.)forall endpoints ProvideHTCwithRxbuffers StartHTC(enabletargetandinterrupts)

ar6000_close()
BlockfurtherincomingbufferstoTxfromupperlayer Bl k f th i i b ff t T f l DisconnectSTAfromAPandclearWLANstates StopHTC Stop HTC
CONFIDENTIAL

WIFIDriverArchitecture:TX/RXInterfaces

ar6000_data_tx() calledfromnetworklayer
Fortransmittingdataframes PrepareWMIandHTCheaders Enqueuetothecorrespondingendpoint
IfQoSisenabled,useIPTOSformapping

ar6000_control_tx() calledfromWMI
Fortransmittingcontrolmessages

ar6000_tx_complete()
CalledbyHTCevent(scheduledbyinterrupt)
CONFIDENTIAL

WIFIDriverArchitecture:TX/RXInterfaces

ar6000_rx()
CalledbyHTCevent(scheduledbyinterrupt) y ( y p) RemoveWMIandHTCheaders 802.3conversion

ar6000_data_rx_data_refill()
PrepareWMIandHTCheaders EnqueuebufferstoHTCqueue

CONFIDENTIAL

WIFIDriverArchitecture:Androidrelated
android_ioctl_siwpriv()
DoAndroidcustomDRIVERcommand(RSSI,ComboScan)

android_ar6k_check_wow_status()
Holdwakelockifwehavewowpatternbeforesuspend

android_readwrite_file()
Loadfirmware Loadsoftwaremacaddress Writedriverdebugmessagetologcat

android_send_reload_event() d id d l d ()
SendHANGeventtosupplicanttorecoveryerror

21

CONFIDENTIAL

WIFIDriverArchitecture:Powerrelated
ar6000_suspend_ev()/ar6000_resume_ev()
Suspend/Resumefunction

ar6000_set_wlan_state()
SetupWifi On/Offstate

ar6000_set_bt_hw_state()
SetupBluetoothstateforclocksharing

ar6000_setup_cut_power_state()
SetupstateofcutpowermodeforWiFi

ar6000_setup_deep_sleep_state() 6000 d l ()
SetupstateofdeepsleepforWiFi

ar6000_wow_suspend()/ar6000_wow_resume() ar6000 wow suspend()/ ar6000 wow resume()


SetupWoW forWifi
22 CONFIDENTIAL

AndroidWIFIFlows:Background

AndroidusesWIFIthroughthewpa_supplicantinterfacewhich usewirelessextensionstocontrolourdriver WIFIdriverisonlyloadedafterenablingWLANfromAndroidGUI wpa_supplicantisusedasthebackendforWLANcontroland securityconnections(WEP/WPA) y ( / ) Others,likeTCP/IPpacketflowandsoon,arebasedonstandard Linuximplementation.

CONFIDENTIAL

AndroidWIFIFlows:FileArchitecture

ApplicationFramework:
Folder:base/wifi/java/android/net/wifi Folder: base/wifi/java/android/net/wifi Files:WifiManager,WifiMonitor,WifiConfiguration,etc

ServiceFramework:
Folder:base/services/java/com/android/server/ Folder: base/services/java/com/android/server/ Files:WifiService,WifiWatchdogService,etc

JNI(JavaNativeInterface)
j / jni/android_net_wifi_Wifi.cpp pp
CONFIDENTIAL

AndroidWIFIFlows:FileArchitecture

HAL(HardwareAbstractLayer)
hardware/libhardware/wifi/wifi.c h d /l bh d / f/ f wpa_supplicant

WIFIdriver:ar6000.ko

CONFIDENTIAL

AndroidWIFIFlows:WIFITurnOnFlow

ApplicationFramework:WifiManager
setWifiEnabled() ()

Service:WifiService
setWifiEnabled() handleMessage()withMESSAGE_ENABLE_WIFI

JNI:android_net_wifi_Wifi.cpp :
JNINativeMethod:loadDriver JNINati eMethod loadDri er android_net_wifi_loadDriver()

HAL:hardware/libhardware/wifi/wifi.c HAL: hardware/libhardware/wifi/wifi.c


wifi_load_driver()

Kernel:insmodar6000.ko
CONFIDENTIAL

AndroidWIFIFlows:WIFIScanFlow

ApplicationFramework:WifiManager
startScan() ()

Service:
WifiService::startScan() WifiNative::scanCommand()

JNI:android_net_wifi_Wifi.cpp
scanCommand C d android_net_wifi_scanCommand d id t ifi C d scanResultsCommand android_net_wifi_scanResultsCommand

CONFIDENTIAL

AndroidWIFIFlows:WIFIScanFlow

HAL:hardware/libhardware/wifi/wifi.c
wifi_send_command:SCAN/SCAN_RESULTS wifi send command : SCAN / SCAN RESULTS wpa_supplicant/driver_wext.c wpa_driver_wext_scan():SIOCSIWSCAN

Kernel:WIFIdriverhandlesthecommandsofwireless extensioninterface

CONFIDENTIAL

Addonsfuncitonsinandroidwpa_supplicant
Invoke by driver_cmd callback of wpa_supplicant driver_ops which will call android_ioctl_siwpriv() in ar6000_android.c eventually.
RSSI
Gettherssi

SCANCHANNELS
Setuptheregulardomain

LINKSPEED
Getthecurrenttx/rxrate

CSCAN(comboscan)
SetupscanParameters
Channels,dwell,passivesettings

MACADDR
Getthemacaddressofwlancard

SETSUSPENDOPT
Suspendmodeoptions

START
Enablethewlanbasedonwifisleep policy

BTCOEXMODE
Btcoex fordhcp obtaining

STOP
Disablethewlanbasedonwifisleep policy

RXFILTERSTART
Multicastfilter

POWERMODE
Enable/Disablepowersaving,mainlyfor dhcprequest
CONFIDENTIAL

Wifi Facilities in Android Services


Nativeprocesswhichcanbe launchedbyJavaandCPP Setupin/init.rc wpa_supplicant dhcpcd abtfilt hostapd wlan_tool
Programmablescript Wrapperaboveservices W b i Wifion/off Configurationafterbootup

Configuration
Androidpropertysystem
Networkinterfacename

SQLITE3database
Wifi parametersusedforJavacode Settings.Secure.getInt(cr, Settings.Secure.WIFI_NUM_ALLO WED_CHANNELS)

wpa_supplicant.conf
Networkprofiles

Certificate
Keystore system

30

CONFIDENTIAL

AndroidWIFIFlows:APScanList

CONFIDENTIAL

AndroidWIFIFlows:APconnected

CONFIDENTIAL

Androidevolution
Donut Date Kernel K l MMC Stack Supplicant Hotspot NAT DRIVER CMD 15 Sep 09 2.6.29 2 6 29 Suspend unsupported 0.5.11 No No
RSSI LINKSPEED MACADDR START/STOP
POWERMODE

clair 12 Jan 10 2.6.29 2 6 29

Froyo 20 May 10 2.6.32 2 6 32 Cut-power suspend

Gingerbread

Honycomb 22 Feb 11 2.6.35 2 6 35 Combo card 8 bits mode 0.6.10+ CSCAN Yes Yes
+CSCAN (parameters)

06 Dec 10 2.6.35 2 6 35 WoW/Deep Sleep 0.6.10+ CSCAN Yes Yes


+GETBAND +GETPOWER +SETSUSPENDOPT

0.5.11 No No
+COUNTRY

0.6.10 Yes Yes

DRIVER EVENT

START STOP S O

+HANGED

Enhance HANGED G

33

CONFIDENTIAL

Questions
WhichAndroidversionsupportcomboscan?
A. Froyo B. Donut C. Gingerbread

WhichfiledoIneedtomodifytobuildAR600xdriverwithAndroidSDK? y
A. BoardConfig.mk B. init.rc C. bluetooth.c

WhichmodulesdoAndroidcalltheWEXTIOCTL?
A. A WifiManager B. wpa_supplicant B wpa supplicant C. C JNI

34

CONFIDENTIAL

Agenda

LinuxMMCStack
WorkingModel BusDriver:MMC,SD,SDIO TheInterfacebetweenBusDriverand HostControllerDriver TheInterfaceBetweenBusDriverand The Interface Between Bus Driver and FunctionDriver BusDriverCardPollingMechanism SDIOCardInitialization InterruptProcess

CONFIDENTIAL

Working Model

Function drivers (ex. WIFI driver)

Bus driver (MMC or SD or SDIO)

Host controller drivers (msm_sdcc, sdhci, etc.)

Physical interface (MMC or SD)

CONFIDENTIAL

WorkingModel
Application File System SD Memory y Function Driver Application Network N t k Stack SDIO WLAN Function Driver SDIO Bus Driver Host Controller Driver Host Controller SDIO Card
CONFIDENTIAL

Application Application Software System Software

SDIO Function Driver

Operating system specific code

Hardware

BusDriver:MMC,SD,SDIO

1busdriverkernelmodule
core.ko

2kindsofbustypestructures(formatch,probe, remove,etc.) remove etc )


Memory(MMC/SD):mmc_bus_type IO(SDIO):sdio_bus_type

3kindsofbusoperatingstructures(forremove, detect, suspend, resume) detect,suspend,resume)


MMC:mmc_ops SD:mmc_sd_ops SDIO:mmc_sdio_ops SDIO mmc sdio ops
CONFIDENTIAL

RelationshipbetweeneachSDIOmodule
Linux BUS device

SDIO CORE

mmc_bus_type sd_op mmc_op

sdio_bus_type sdio_op

SDIO host controller


CONFIDENTIAL

SDIOCardDetection
mmc_rescan() will be called based on host controller platform device
mmc_rescan() <ifhost>bus_ops==NULL> p mmc_go_idle() CMD0 mmc_send_if_cond() /*sdio?*/ mmc_send_if_cond() CMD5 d if d() <ifok> mmc_attach_sdio() /*normalSD?*/ mmc_send_app_op_cond() CMD41 <ifok> mmc_attach_sd() / MMC? / /*MMC?*/ mmc_send_op_cond() CMD1 <ifok> mmc_attach_mmc() <else> host>bus_ops>detect() CMD7
CONFIDENTIAL

SDIO Card Initialization


SD Bus Driver

2. Find the card


Host Controller Driver Di

3. Card Initialization

1. Card Inserted
SDIO Card

1 bit, low clock rate bus mode OCR Assignment (CMD5) Card Type Detection RCA Assignment (CMD3) Card Selection (CMD7) Start CMD52 Read the common registers Common CIS Query Function CIS Query Switch to high speed Change to the cards maximum speed Switch to wider bus Initialize all present functions Final Bus Mode

CONFIDENTIAL

TheInterfacebetweenBusDriverandHostControllerDriver

mmc_alloc_host()
Allocatememoryforhostcontrollerstructure

mmc_add_host()
Registerthehost g Thehostmustbereadytoserverequestsbeforeit Cardpollingatleast1time

mmc_signal_sdio_irq()
InformbusdriverofanIOIRQevent

structuremmc_host_ops
request,set_ios,enable_sdio_irq t t i bl di i
CONFIDENTIAL

TheInterfacebetweenBusDriverandFunctionDriver

sdio_register_driver()
Registerafunctiondriver

structuresdio_driver
probe,remove drv.pm.suspend,drv.pm.resume

sdio_claim_irq() _ _ q
ClaimtheIRQ

CONFIDENTIAL

TheInterfacebetweenBusDriverandFunctionDriver

sdio_writesb()
WritetoaFIFO

sdio_readsb()
ReadfromaFIFO

sdio_memcpy_toio() di t i ()
Writeachunkofmemory

sdio_memcpy_fromio()
Readachunkofmemory ead a c u o e o y
CONFIDENTIAL

Therequirementofclaimandrelease
EveryMMC(SDIO)APIneedtobelockedbymmcclaimfunction Noasynchronouscommandisallowed lowerthroughput
Example
sdio_claim_host()
sdio_writesb() sdio_memcpy_toio() sdio memcpy toio()

sdio_release_host()

Asynchronoussupportinolca y pp
Wecreateaasync_task()bykernel_thread WequeueallHIF(SDIO)requestintolinkedlistwithoutclaimmmchost async_task()willcheckthependingdatainlinked listandcallmmc(sdio)commandin async task() will check the pending data in linkedlist and call mmc (sdio) command in itscontext Onlyasync_task()willcallsdio_claim_host()andsdio_release_host()inthiscase

45

CONFIDENTIAL

SDIOAPIInternals Implemenation ofsdio_mempy_xxxx()


sdio_claim_host(mmc_host)
DECLARE_COMPLETION_ONSTACK(complete); struct scatterlist sg; struct mmc_command cmd ={.opcode =SD_IO_RW_EXTENDED}; struct mmc data data = { sg = &sg sg len = 1 }; mmc_data data={.sg =&sg,.sg_len =1}; struct mmc_request mrq ={.cmd =&cmd,.data=&data}; data>blksz =blksz;data>blocks=blocks;data>flags=flags; sg_init_one(sg,buf,blksz *blocks); cmd.flags =MMC_RSP_SPI_R5|MMC_RSP_R5|MMC_CMD_ADTC; cmd.arg =ARGS(rw,fn,bmode,incr,addr,blocks_or_bytes); mmc_set_data_timeout(data,device>func>card); mrq.done_data =&complete; mrq,.done=mmc_wait_done; mmc_host>ops>request(mmc_host,&mrq); wait_for_completion(&complete); wait for completion(&complete);

sdio_release_host(mmc_host)
46 CONFIDENTIAL

MMCAPIInternals CompleteCallback
voidmmc_wait_doen(mmc_request*mrq) { /*DMAtaskletorPIOIRQcontext*/ complete(mrq>done_data); }

47

CONFIDENTIAL

MMC Scatter-Gather Internals


DoHifReadWriteScatter() in hif_scatter.c Use mmc core API directly SDIOAPI SDIO API
Italwaysuses1bufferformmcAPI

MMCAPI MMC API


Wecanassignourscatterbufferdirectly

struct scatterlist sg; sg_init_one(&sg,buf,blksz *blocks);

struct scatterlist sg[Entries]; li [E i ] sg_init_table(&sg,Entries); for(i=0;i<Entries;i++,pSg++){ sg_set_buf(&sg,buf[i],len[i]); } data.sg=&sg; data.sg_len =Entries; d t l E ti

data.sg=&sg; data.sg_len =1; data sg len = 1;

48

CONFIDENTIAL

InterruptProcess
Busdrivercreatesakernelthreadforinterruptprocess: ksdioirqd Hostcontrollerdrivercanwakeupthiskernelthreadforthe bottomhalfprocessofanIOinterruptevent b tt h lf f IO i t t t mmc_signal_sdio_irq() Hostcontrollerdriverindicatesinterruptsupportbythe belowflag mmc>caps|=MMC_CAP_SDIO_IRQ

CONFIDENTIAL

Interrupt Process

Interrupt on SD interface

Host controller driver calls mmc_signal_sdio_irq()

Bus driver (ksdioirq) calls func->irq_handler()

WIFI driver HIF layer hifIRQHandler()

CONFIDENTIAL

SDIOAPIintegrationforHIFlayer
AllSDIOread/writeoperationsaredonebyHIFasync_task SDIOhostwillbeclaimedinsideasync_task Herearethekerneltaskrelationshipinsidekernel
Driver context HIFReadWrite Linux ksdioirqd dsrHandler() HIFReadWrite HIF async task __HIFReadWrite HIFR dW it SDIO API Host driver
51 CONFIDENTIAL

LinuxMMCSuspendandResume
Linuxversion<2.6.32(Android<2.2)
NonativeMMCsuspendandresumemethod

Linuxversion==2.6.32(Android2.2Froyo) Li i 2 6 32 (A d id 2 2 F )
Cutpowermodeissupported Clock,highspeedmodeandbuswidthneedtoberesetafterresume

Linuxversion>2.6.34(Android>2.2)
Deepsleepmodeissupport
MMC_PM_KEEP_POWER

WoWissupported
MMC_PM_WAKE_SDIO_IRQandMMC_PM_KEEP_POWER Buswidthwilltoswitchto1bitmodeaftersuspendandrestoreto4bitsmodeafterresume

52

CONFIDENTIAL

Elements in Suspend and Resume PMoperationsforSDIO


structdev_pm_opspmops={ .suspend=hifDeviceSuspend, .resume=hifDeviceResume, }; structsdio_driverar6k_driver={ .name="ar6k_wlan", .id_table=ar6k_id_table, id t bl 6k id t bl .probe=hifDeviceInserted, .remove=hifDeviceRemoved, .drv={.pm=&pmops}, };

PMflagsformmchost
MMC_PM_KEEP_POWER _ _ _
DeepsleeporWoWmode

MMC_PM_WAKE_SDIO_IRQ
WakeonWoWviaSDIObus W k W W i SDIO b

53

CONFIDENTIAL

SuspendandResumeFlow SuspendFlow
core.c,mmc_host_suspend() host>bus_ops>suspend()
sdio.c ,mmc_sdio_suspend() func>pmops>suspend()
hif.c,hifDeviceSuspend() deviceSuspendHandler() ar6000_pm.c,ar6000_suspend_ev() _p _ p _ () host>pm_flags |=MMC_PM_KEEP_POWER WoW/Deepsleep host>pm_flags =0 Cutpowermode

ResumeFlow
core.c,mmc_host_resume() host>bus_ops>resume()
sdio.c ,mmc_sdio_resume() f di di () func>pmops>resume() () hif.c,hifDeviceResume() deviceResumeHandler ()
ar6000_pm.c,ar6000_resume_ev()

54

CONFIDENTIAL

Questions
WhichLinuxversionsupportWoWsuspendmode?
A. 2.6.27 B. 2.6.32 C. 2.6.34

WhichonebelowisNOTMMCbustype? yp
A. SDIO B. UART C. MMC

WhichonebelowisNOTsupportedbyLinuxmmcstack?
A. A WoW B. B SDIO C. C Asynchronous request

55

CONFIDENTIAL

Agenda IntegrationforAndroid
Chipdetection,WoW,etc. wpa_supplicant HotspotAPmode bluetooth.cforBTCOEX Bluetoothclocksharing Bl t th l k h i GoogleCTSprogram

56

CONFIDENTIAL

CarddetectionandWoW
Detectionmode
Polling
mmc>caps&MMC_CAP_NEEDS_POLL mmc >caps & MMC CAP NEEDS POLL

Onetimedetectionbyexportingmmc_detect_change()in/sysfs Callbackfunciton ofplatform_device


SMDK:int ( ext_cd_init)(void( notify_func)(platform_device int SMDK : int (*ext cd init)(void (*notify func)(platform device *,int state)) Qualcomm:int (*register_status_notify)(void(*callback)(int present,void*),void*)

HWIRQ

Configuration
host/os/linux/include/wlan_config.h
#definePLAT_WOW_GPIO_PIN 0 #definePLAT_WLAN_CHIP_PWD_PIN0 #define PLAT WLAN CHIP PWD PIN 0

Implementation
voidplat_setup_power(AR_SOFTC*dev,int on,int detect){
1. SetupWLANpowerwithWLAN_CHIP_PWD_PIN 1 Setup WLAN power with WLAN CHIP PWD PIN 2. Callplatformdevicecallbackfunctiontodothedetection

}
57 CONFIDENTIAL

wpa_supplicant
AndroidsupplicantisNOTwpa_supplicant
0.5.11whenAndroid<2.2 0.6.10afterAndroid>=2.2 0 6 10 after Android > 2 2 supplcaintwithcustomizefeature
DRIVERcmdsincecupcake Twoctrl_ifacesocketssincecupcake Two ctrl iface sockets since cupcake SpecialcertificateRead/WritewithoutusingfilesinceDonut keystoreforcertificateread/writesinceclair NewkeystoreAPIafterFroyo ComboScansinceGingerbread

Knownissues
Unicodedisplayissue UnabletoconnectifAPdoesnotsupportPMKforRSN WPAconnectionissuewhenproberesponseandbeaconIEarenotsame GUIwillbependingonobtainingscreenafterWPArekey Longconnectiontimeafteraddinganewnonexistingnetwork Long connection time after adding a new non existing network

Theknownissuesneedeitherpatchorusingathsupplicant0.6.10
58 CONFIDENTIAL

Configurationofwpa_supplicant
Filledevice/<vendor>/<device>/BoardConfig.mk Usingath_supplicant0.6.10
WPA_SUPPLICANT_VERSION:=VER_0_6_ATHEROS BOARD_WPA_SUPPLICANT_DRIVER:=WEXT

UsingAndroidsupplicant
WPA_SUPPLICANT_VERSION:=VER_0_6_X BOARD_WPA_SUPPLICANT_DRIVER:=WEXT

59

CONFIDENTIAL

Commandlineforwpa_supplicant
wpa_cliiwlan0p/data/misc/wifi/ Scan
scan

Scanresutls
scan_results

Drivercommand
DRIVERRSSI

Adjustloglevel Adjust log level


log_level1

60

CONFIDENTIAL

Hotspotmode
WirelessRoutermodetethering3Gnetwork
OPEN/WPA2PSKonly

SDKfilesrelatedtohotspotmode SDK fil l t dt h t t d


frameworks/base/core/res/res/values/config.xml frameworks/base/services/java/com/android/server/WifiService.java system/netd/SoftapController.cpp system/netd/NetlinkHandler.cpp

61

CONFIDENTIAL

Hotspotmodeimplemenation
frameworks/base/core/res/res/values/config.xml Change<tether>aswlan1 Change<upstream>as3GorEthernetport Change <upstream> as 3G or Ethernet port

android/system/netd/SoftApController.cpp
NeedtochangeBRCMproprietaryIOCTLintohostapd daemon

SoftapController::setSoftap()
Writenewhostapd.conf basedonsetSoftap()parameters ChangestationintoAPmodebyIOCTL Changewlan interfacenamefromwlan0towlan1 Starthostapd daemon SimulateNetlink eventtonotifystation(wlan0)interfaceisdownwhileAP(wlan1)isup Simulate Netlink event to notify station(wlan0) interface is down while AP(wlan1) is up

SoftapController::stopSoftap()
Stophostapd daemon Changebacktostationmode Change back to station mode Changewlan interfacenamebacktowlan0 SimulateNetlink eventtonotifyAPinterfaceisdownwhilestationisup
62 CONFIDENTIAL

TestingforHotspotmode
Configurebycommandline
Startwifidriver
ndcsoftapstart ndc softap start

StartAPmode
ndcsoftapstartap

ConfigureAPmodeparameters Configure AP mode parameters


ndcsoftapsetwlan0wlan1[ssid][security][key][channel][preamble][maxstations]

Configurebydatabase Configure by database


sqlite3/data/data/com.android.providers.settings/databases/settings.db
Updatesecuresetvalue=<newvalue>wherename=<apfieldname>

Availablefieldname Available field name


wifi_ap_ssid wifi_ap_security wifi_ap_passwd

63

CONFIDENTIAL

BTCOEX
BTfilter
BtfilterwillconfigureAR6003automaticallybasedonDBUSandHCIevents

Patchfile P t h fil
android/system/bluetooth/bluedroid/bluetooth.c
Startbtfilterserviceinbt_on() Stopbtfilterserviceinbt_off() St btfilt i i bt ff()

Debugbtfilterinhostsideusinglogcat
logcatabtfilt:**:s

HCIUTILSlibrary
AddonlibraryprovidebybluetoothvendorwhenthereisnotHCIdevice Mainfeatures
EventforthebeginningandendofBTInqury,SCO. EDRandroleinfomationoftheA2DPdevices

Notes
EventforbeginningandendofA2DPcanbeobtainedbyDBUS
64 CONFIDENTIAL

Bluetoothclocksharing
Sharewificlocksourcetobluetoothchip
Wififirmwareneedtobeloadedbeforebluetoothturningon.

Basicconfiguration B i fi ti
host/os/linux/include/wlan_config.h
#defineWLAN_CONFIG_BT_SHARING1 #defineWLAN_CONFIG_PM_SUSPEND3(Cutpowerifbtisoff) #d fi WLAN CONFIG PM SUSPEND 3 (C t if bt i ff)

host/tools/wlan_tool/wlan_tool
CLK_HELPER=1

Patchfile P t h fil
android/system/bluetooth/bluedroid/bluetooth.c
CallIOCTLtoar6000toindicatebluetoothnewON/OFFstate

65

CONFIDENTIAL

GoogleCTSprogram
BasicruletopassGoogleCTS(CompatibilityTestSuite)program
Noprogramwhichisrunningwithrootpermissionforalongtime.

Solution S l ti
Avoidrootserviceforwlanininit.rc
E.g.servicewpa_supplicant/system/bin/wlan_toolwpa_supplicant
userwifi ifi groupwifisysteminetnet_adminnet_rawkeystore

Rootservicewillnotforkanybackgroundprogram Rootservicewillswitchbacktonormalpermissionafterlaunched. Root service will switch back to normal permission after launched.
E.g.dhcpcd

66

CONFIDENTIAL

Questions
WhichoneisnecessaryforBTCOEX
A. hostapd B. abtfilt C. wpa_supplicant

Whichoneisrelatedtohotspotmode? p
A. SoftApController.cpp B. WifiManager.java C. bluetooth.c

Whichprogramcancontrolsupplicant?
A. wpa_cli A wpa cli B. B ndc C. C svc wifi

67

CONFIDENTIAL

THANKYOU Q&A

68

CONFIDENTIAL

You might also like