xref: /wlan-dirver/qcacld-3.0/Android.mk (revision 6bff3d33e365cac8f422ee96e2cdb5716f924edb)
110a5bb12SJeff Johnson# Android makefile for the WLAN Module
210a5bb12SJeff Johnson
310a5bb12SJeff Johnson# set WLAN_BUILD_DEBUG=y in your environment to enable debug logging
410a5bb12SJeff Johnsondefine wlog
510a5bb12SJeff Johnson$(if $(WLAN_BUILD_DEBUG),$(info $(1)))
610a5bb12SJeff Johnsonendef
710a5bb12SJeff Johnson
87eea98dcSZhaoyang Liudefine target_is_dual_wlan
97eea98dcSZhaoyang Liu$(strip \
107eea98dcSZhaoyang Liu  $(if $(TARGET_SUPPORT_DUAL_WLAN), \
117eea98dcSZhaoyang Liu     $(if $(findstring cnss2,$(1)),true,), \
127eea98dcSZhaoyang Liu  ) \
137eea98dcSZhaoyang Liu)
147eea98dcSZhaoyang Liuendef
157eea98dcSZhaoyang Liu
1610a5bb12SJeff JohnsonLOCAL_PATH := $(call my-dir)
1710a5bb12SJeff Johnson$(call wlog,LOCAL_PATH=$(LOCAL_PATH))
1810a5bb12SJeff Johnson
1956a9bf7fSSmita GhoshENABLE_QCACLD := true
2056a9bf7fSSmita Ghoshifeq ($(TARGET_USES_QMAA), true)
2156a9bf7fSSmita Ghoshifneq ($(TARGET_USES_QMAA_OVERRIDE_WLAN), true)
2256a9bf7fSSmita GhoshENABLE_QCACLD := false
2356a9bf7fSSmita Ghoshelse
2456a9bf7fSSmita GhoshENABLE_QCACLD := true
2556a9bf7fSSmita Ghoshendif
2656a9bf7fSSmita Ghoshendif
2756a9bf7fSSmita Ghosh
28a89f1924SKomal Maheshwariifeq ($(BOARD_COMMON_DIR),)
29a89f1924SKomal Maheshwari    BOARD_COMMON_DIR := device/qcom/common
30a89f1924SKomal Maheshwariendif
31a89f1924SKomal Maheshwari
3256a9bf7fSSmita Ghoshifeq  ($(ENABLE_QCACLD), true)
337090c5fdSPrakash Dhavali
347090c5fdSPrakash Dhavali# Assume no targets will be supported
357090c5fdSPrakash DhavaliWLAN_CHIPSET :=
367090c5fdSPrakash Dhavali
377090c5fdSPrakash Dhavaliifeq ($(BOARD_HAS_QCOM_WLAN), true)
387090c5fdSPrakash Dhavali
391e382ffaSYue Ma# Check if this driver needs be built for current target
401e382ffaSYue Maifneq ($(findstring qca_cld3,$(WIFI_DRIVER_BUILT)),)
41fbb9b373SSatish Singh	WLAN_CHIPSET := qca_cld3
427090c5fdSPrakash Dhavali	WLAN_SELECT  := CONFIG_QCA_CLD_WLAN=m
431e382ffaSYue Maendif
447090c5fdSPrakash Dhavali
457090c5fdSPrakash Dhavali# Build/Package only in case of supported target
467090c5fdSPrakash Dhavaliifneq ($(WLAN_CHIPSET),)
477090c5fdSPrakash Dhavali
487090c5fdSPrakash Dhavali# This makefile is only for DLKM
497090c5fdSPrakash Dhavaliifneq ($(findstring vendor,$(LOCAL_PATH)),)
507090c5fdSPrakash Dhavali
517090c5fdSPrakash Dhavaliifneq ($(findstring opensource,$(LOCAL_PATH)),)
5249948f1dSYuanyuan Liu	WLAN_BLD_DIR := vendor/qcom/opensource/wlan
537090c5fdSPrakash Dhavaliendif # opensource
547090c5fdSPrakash Dhavali
556c4599c8SYu Wang# Multi-ko check
568cf2c24eSYu WangLOCAL_DEV_NAME := $(patsubst .%,%,\
578cf2c24eSYu Wang	$(lastword $(strip $(subst /, ,$(LOCAL_PATH)))))
586c4599c8SYu Wang
5910a5bb12SJeff Johnson$(call wlog,LOCAL_DEV_NAME=$(LOCAL_DEV_NAME))
6010a5bb12SJeff Johnson$(call wlog,TARGET_WLAN_CHIP=$(TARGET_WLAN_CHIP))
6110a5bb12SJeff Johnson
6227b941b7SJeff JohnsonTARGET_WLAN_CHIP ?= wlan
6327b941b7SJeff JohnsonLOCAL_MULTI_KO := false
6427b941b7SJeff Johnsonifneq ($(TARGET_WLAN_CHIP), wlan)
657d866f69SYu Wangifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
666c4599c8SYu WangLOCAL_MULTI_KO := true
676c4599c8SYu Wangendif
686c4599c8SYu Wangendif
696c4599c8SYu Wang
706c4599c8SYu Wangifeq ($(LOCAL_MULTI_KO), true)
71*6bff3d33SJeff JohnsonLOCAL_ANDROID_ROOT := $(shell pwd)
72*6bff3d33SJeff JohnsonLOCAL_WLAN_BLD_DIR := $(LOCAL_ANDROID_ROOT)/$(WLAN_BLD_DIR)
73*6bff3d33SJeff Johnson$(shell find $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/ -maxdepth 1 \
74*6bff3d33SJeff Johnson	-name '.*' ! -name '.git' -delete {} +)
756c4599c8SYu Wang
76*6bff3d33SJeff Johnson$(foreach chip, $(TARGET_WLAN_CHIP), \
77*6bff3d33SJeff Johnson	$(shell ln -sf . $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/.$(chip)))
788cf2c24eSYu Wanginclude $(foreach chip, $(TARGET_WLAN_CHIP), $(LOCAL_PATH)/.$(chip)/Android.mk)
796c4599c8SYu Wang
806c4599c8SYu Wangelse # Multi-ok check
816c4599c8SYu Wang
827eea98dcSZhaoyang Liu# When dual wlan enabled, secondary dev name would be $(chip)_cnss2.
837eea98dcSZhaoyang Liu# Use LOCAL_CHIP_NAME instead of LOCAL_DEV_NAME for secondary one.
847eea98dcSZhaoyang LiuLOCAL_CHIP_NAME := $(LOCAL_DEV_NAME)
857eea98dcSZhaoyang LiuTARGET_SECONDARY_WLAN := $(call target_is_dual_wlan,$(LOCAL_DEV_NAME))
867eea98dcSZhaoyang Liuifeq ($(TARGET_SECONDARY_WLAN), true)
877eea98dcSZhaoyang LiuLOCAL_CHIP_NAME := $(patsubst %_cnss2,%,$(strip $(LOCAL_DEV_NAME)))
887eea98dcSZhaoyang Liuendif
897eea98dcSZhaoyang Liu
90d8ef4743SSurabhi Vishnoiifeq ($(WLAN_PROFILE),)
914b136b1cSMahesh Kumar Kalikot VeetilWLAN_PROFILE := default
92d8ef4743SSurabhi Vishnoiendif
934b136b1cSMahesh Kumar Kalikot Veetil
947d866f69SYu Wangifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
957d866f69SYu Wang
967d866f69SYu WangLOCAL_DEV_NAME := wlan
976c4599c8SYu WangLOCAL_MOD_NAME := wlan
986c4599c8SYu WangLOCAL_SRC_DIR :=
996c4599c8SYu WangTARGET_FW_DIR := firmware/wlan/qca_cld
1006c4599c8SYu WangTARGET_CFG_PATH := /vendor/etc/wifi
1016c4599c8SYu WangTARGET_MAC_BIN_PATH := /mnt/vendor/persist
1027d866f69SYu Wang
1036c4599c8SYu Wangelse
1047d866f69SYu Wang
1058cf2c24eSYu WangLOCAL_SRC_DIR := .$(LOCAL_DEV_NAME)
1064b136b1cSMahesh Kumar Kalikot Veetil# Use default profile if WLAN_CFG_USE_DEFAULT defined.
1074b136b1cSMahesh Kumar Kalikot Veetilifeq ($(WLAN_CFG_USE_DEFAULT),)
1087eea98dcSZhaoyang LiuWLAN_PROFILE := $(LOCAL_CHIP_NAME)
1094b136b1cSMahesh Kumar Kalikot Veetilendif
1107eea98dcSZhaoyang LiuTARGET_FW_DIR := firmware/wlan/qca_cld/$(LOCAL_CHIP_NAME)
1117eea98dcSZhaoyang LiuTARGET_CFG_PATH := /vendor/etc/wifi/$(LOCAL_CHIP_NAME)
1127eea98dcSZhaoyang LiuTARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
1137d866f69SYu Wang
1147d866f69SYu Wangifneq ($(TARGET_MULTI_WLAN), true)
1157d866f69SYu WangLOCAL_MOD_NAME := wlan
1167d866f69SYu WangDYNAMIC_SINGLE_CHIP := $(LOCAL_DEV_NAME)
1177d866f69SYu Wangelse
1187d866f69SYu WangLOCAL_MOD_NAME := $(LOCAL_DEV_NAME)
1197d866f69SYu Wangendif
1207d866f69SYu Wang
1217eea98dcSZhaoyang Liuifeq ($(TARGET_SECONDARY_WLAN), true)
1227eea98dcSZhaoyang LiuLOCAL_MOD_NAME := $(LOCAL_CHIP_NAME)
1237eea98dcSZhaoyang LiuDYNAMIC_SINGLE_CHIP := $(LOCAL_CHIP_NAME)
1247eea98dcSZhaoyang Liuendif
1257eea98dcSZhaoyang Liu
1266c4599c8SYu Wangendif
1276c4599c8SYu Wang
1287090c5fdSPrakash Dhavali# DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
1297090c5fdSPrakash Dhavaliifeq ($(call is-platform-sdk-version-at-least,16),true)
130a89f1924SKomal Maheshwari	DLKM_DIR := $(TOP)/$(BOARD_COMMON_DIR)/dlkm
1317090c5fdSPrakash Dhavalielse
1327090c5fdSPrakash Dhavali	DLKM_DIR := build/dlkm
1337090c5fdSPrakash Dhavaliendif # platform-sdk-version
1347090c5fdSPrakash Dhavali
1357090c5fdSPrakash Dhavali# Build wlan.ko as $(WLAN_CHIPSET)_wlan.ko
1367090c5fdSPrakash Dhavali###########################################################
1377090c5fdSPrakash Dhavali# This is set once per LOCAL_PATH, not per (kernel) module
1386c4599c8SYu WangKBUILD_OPTIONS := WLAN_ROOT=$(WLAN_BLD_DIR)/qcacld-3.0/$(LOCAL_SRC_DIR)
139e5d65fc8SJeff JohnsonKBUILD_OPTIONS += WLAN_COMMON_ROOT=cmn
140e5d65fc8SJeff JohnsonKBUILD_OPTIONS += WLAN_COMMON_INC=$(WLAN_BLD_DIR)/qcacld-3.0/cmn
1416c4599c8SYu WangKBUILD_OPTIONS += WLAN_FW_API=$(WLAN_BLD_DIR)/fw-api
1426c4599c8SYu WangKBUILD_OPTIONS += WLAN_PROFILE=$(WLAN_PROFILE)
1437d866f69SYu WangKBUILD_OPTIONS += DYNAMIC_SINGLE_CHIP=$(DYNAMIC_SINGLE_CHIP)
14408abad6cSPrakash Dhavali
1457090c5fdSPrakash Dhavali# We are actually building wlan.ko here, as per the
1467090c5fdSPrakash Dhavali# requirement we are specifying <chipset>_wlan.ko as LOCAL_MODULE.
1477090c5fdSPrakash Dhavali# This means we need to rename the module to <chipset>_wlan.ko
1487090c5fdSPrakash Dhavali# after wlan.ko is built.
1496c4599c8SYu WangKBUILD_OPTIONS += MODNAME=$(LOCAL_MOD_NAME)
150f91c461dSAditya KodukulaKBUILD_OPTIONS += DEVNAME=$(LOCAL_DEV_NAME)
1517090c5fdSPrakash DhavaliKBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
1527090c5fdSPrakash DhavaliKBUILD_OPTIONS += $(WLAN_SELECT)
1537090c5fdSPrakash Dhavali
154716b35abSNamita NairKBUILD_REQUIRED_KOS := ipam.ko
155716b35abSNamita Nair
156baff800eSYu Wangifneq ($(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME)),)
157baff800eSYu WangKBUILD_OPTIONS += WLAN_CFG_OVERRIDE="$(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME))"
158baff800eSYu Wangendif
159baff800eSYu Wang
1607eea98dcSZhaoyang Liu# driver expects "/dev/<name>" for wifi driver state ctrl parameter.
1617eea98dcSZhaoyang Liu# i.e. WIFI_DRIVER_STATE_CTRL_PARAM="/dev/wlan" is defined for single wlan.
1627eea98dcSZhaoyang Liu# WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY="/dev/wlan2" is defined for 2nd wlan.
1637eea98dcSZhaoyang Liuifeq ($(TARGET_SECONDARY_WLAN), true)
1647eea98dcSZhaoyang Liu$(call wlog,STATE_CTRL_PARAM_SECONDARY=$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
1657eea98dcSZhaoyang LiuPARAM_SECONDARY := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
1667eea98dcSZhaoyang Liu$(call wlog,PARAM_SECONDARY=$(PARAM_SECONDARY))
1677eea98dcSZhaoyang Liuifeq ($(dir $(PARAM_SECONDARY)),/dev/)
1687eea98dcSZhaoyang LiuKBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM_SECONDARY))
1697eea98dcSZhaoyang Liuendif
1707eea98dcSZhaoyang Liuelse
171216957b4SJeff Johnson$(call wlog,WIFI_DRIVER_STATE_CTRL_PARAM=$(WIFI_DRIVER_STATE_CTRL_PARAM))
172216957b4SJeff JohnsonPARAM := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM))
173216957b4SJeff Johnson$(call wlog,PARAM=$(PARAM))
174216957b4SJeff Johnsonifeq ($(dir $(PARAM)),/dev/)
175216957b4SJeff JohnsonKBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM))
176216957b4SJeff Johnsonendif
1777eea98dcSZhaoyang Liuendif
178216957b4SJeff Johnson
1799cc41114SMahesh Kumar Kalikot Veetil# Pass build options per chip to Kbuild. This will be injected from upper layer
1809cc41114SMahesh Kumar Kalikot Veetil# makefile.
1819cc41114SMahesh Kumar Kalikot Veetil#
1829cc41114SMahesh Kumar Kalikot Veetil# e.g.
1839cc41114SMahesh Kumar Kalikot Veetil#  WLAN_KBUILD_OPTIONS_qca6390 := CONFIG_CNSS_QCA6390=y
1849cc41114SMahesh Kumar Kalikot Veetilifneq ($(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME)),)
1859cc41114SMahesh Kumar Kalikot VeetilKBUILD_OPTIONS += "$(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME))"
1869cc41114SMahesh Kumar Kalikot Veetilendif
1879cc41114SMahesh Kumar Kalikot Veetil
188a2f607aaSJeff Johnsonifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
189a2f607aaSJeff JohnsonTARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
190a2f607aaSJeff Johnsonelse
191a2f607aaSJeff JohnsonTARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
192a2f607aaSJeff Johnsonendif
193a2f607aaSJeff Johnson
194db747806SYue Ma# WLAN_PLATFORM_KBUILD_OPTIONS should be passed from upper level Makefiles
195db747806SYue Ma# like wlan.mk. It indicates sources of CNSS family drivers (cnss2, cnss_nl,
196db747806SYue Ma# cnss_prealloc and cnss_utils etc.) are built out of kernel tree and it
197db747806SYue Ma# should also include all necessary config flags (e.g. CONFIG_CNSS2) which
198db747806SYue Ma# are originally defined from kernel Kconfig/defconfig. KBUILD_EXTRA_SYMBOLS
199db747806SYue Ma# is also needed to indicate all the symbols from these drivers.
200db747806SYue Maifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
201db747806SYue MaKBUILD_OPTIONS += $(foreach wlan_platform_kbuild_option, \
202db747806SYue Ma		   $(WLAN_PLATFORM_KBUILD_OPTIONS), \
203db747806SYue Ma		   $(wlan_platform_kbuild_option))
204db747806SYue Ma
205716b35abSNamita NairKBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS+=$(shell pwd)/$(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
206db747806SYue Maendif
207db747806SYue Ma
2087090c5fdSPrakash Dhavaliinclude $(CLEAR_VARS)
209a2f607aaSJeff Johnson
210a2f607aaSJeff Johnson# Create the module
2117d866f69SYu WangLOCAL_MODULE              := $(WLAN_CHIPSET)_$(LOCAL_DEV_NAME).ko
2126c4599c8SYu WangLOCAL_MODULE_KBUILD_NAME  := $(LOCAL_MOD_NAME).ko
2137090c5fdSPrakash DhavaliLOCAL_MODULE_DEBUG_ENABLE := true
21464271516SSameer Thalappilifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
21564271516SSameer Thalappil    ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
21664271516SSameer Thalappil        LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
21764271516SSameer Thalappil    else
218b4d7b211SSameer Thalappil        LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
21964271516SSameer Thalappil    endif
22064271516SSameer Thalappilelse
2217090c5fdSPrakash Dhavali    LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
22264271516SSameer Thalappilendif
22364271516SSameer Thalappil
224a2f607aaSJeff Johnson# Create wlan_mac.bin symbolic link as part of the module
225a2f607aaSJeff Johnson$(call symlink-file,,$(TARGET_MAC_BIN_PATH)/wlan_mac.bin,$(TARGET_FW_PATH)/wlan_mac.bin)
226a2f607aaSJeff JohnsonLOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_FW_PATH)/wlan_mac.bin
227a2f607aaSJeff Johnson
228a2f607aaSJeff Johnson# Conditionally create module symbolic link
229a2f607aaSJeff Johnsonifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
230a2f607aaSJeff Johnsonifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
231a2f607aaSJeff Johnsonifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
232a2f607aaSJeff Johnson$(call symlink-file,,$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
233a2f607aaSJeff JohnsonLOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE)
234a2f607aaSJeff Johnsonendif
235a2f607aaSJeff Johnsonelse
236a2f607aaSJeff Johnson$(call symlink-file,,/system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
237a2f607aaSJeff JohnsonLOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE)
238a2f607aaSJeff Johnsonendif
239a2f607aaSJeff Johnsonendif
240a2f607aaSJeff Johnson
241a2f607aaSJeff Johnson# Conditionally create ini symbolic link
242a2f607aaSJeff Johnsonifeq ($(TARGET_BOARD_AUTO),true)
243a2f607aaSJeff Johnson$(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
244a2f607aaSJeff JohnsonLOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
245a2f607aaSJeff Johnson$(call wlog,"generate soft link because TARGET_BOARD_AUTO true")
246a2f607aaSJeff Johnsonelse
247a2f607aaSJeff Johnsonifneq ($(GENERIC_ODM_IMAGE),true)
248a2f607aaSJeff Johnson$(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
249a2f607aaSJeff JohnsonLOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
250a2f607aaSJeff Johnson$(call wlog,"generate soft link because GENERIC_ODM_IMAGE not true")
251a2f607aaSJeff Johnsonendif
252a2f607aaSJeff Johnsonendif
253a2f607aaSJeff Johnson
254db747806SYue Ma# Set dependencies so that CNSS family drivers can be compiled ahead.
255db747806SYue Maifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
256db747806SYue MaLOCAL_REQUIRED_MODULES := wlan-platform-module-symvers
257db747806SYue MaLOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
258db747806SYue Maendif
259db747806SYue Ma
2607d2bb431SJeff Johnson$(call wlog,TARGET_USES_KERNEL_PLATFORM=$(TARGET_USES_KERNEL_PLATFORM))
2617d2bb431SJeff Johnsonifeq ($(TARGET_USES_KERNEL_PLATFORM),true)
262d7e399e9SJeff Johnson    include $(DLKM_DIR)/Build_external_kernelmodule.mk
263d7e399e9SJeff Johnsonelse
2647090c5fdSPrakash Dhavali    include $(DLKM_DIR)/AndroidKernelModule.mk
265d7e399e9SJeff Johnsonendif
2667090c5fdSPrakash Dhavali
2676c4599c8SYu Wangendif # Multi-ko check
2687090c5fdSPrakash Dhavaliendif # DLKM check
2697090c5fdSPrakash Dhavaliendif # supported target check
2707090c5fdSPrakash Dhavaliendif # WLAN enabled check
27156a9bf7fSSmita Ghoshendif # ENABLE_QCACLD
272