Android.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. # Android makefile for the WLAN Module
  2. # set WLAN_BUILD_DEBUG=y in your environment to enable debug logging
  3. define wlog
  4. $(if $(WLAN_BUILD_DEBUG),$(info $(1)))
  5. endef
  6. define target_is_dual_wlan
  7. $(strip \
  8. $(if $(TARGET_SUPPORT_DUAL_WLAN), \
  9. $(if $(findstring cnss2,$(1)),true,), \
  10. ) \
  11. )
  12. endef
  13. LOCAL_MODULE_DDK_BUILD := true
  14. LOCAL_MODULE_DDK_ALLOW_UNSAFE_HEADERS := true
  15. ifeq ($(shell test $(PLATFORM_VERSION) -lt 14; echo $$?),0)
  16. LOCAL_MODULE_DDK_BUILD := false
  17. LOCAL_MODULE_DDK_ALLOW_UNSAFE_HEADERS := false
  18. endif
  19. LOCAL_PATH := $(call my-dir)
  20. $(call wlog,LOCAL_PATH=$(LOCAL_PATH))
  21. ENABLE_QCACLD := true
  22. ifeq ($(TARGET_USES_QMAA), true)
  23. ifneq ($(TARGET_USES_QMAA_OVERRIDE_WLAN), true)
  24. ENABLE_QCACLD := false
  25. else
  26. ENABLE_QCACLD := true
  27. endif
  28. endif
  29. ifeq ($(BOARD_COMMON_DIR),)
  30. BOARD_COMMON_DIR := device/qcom/common
  31. endif
  32. ifeq ($(ENABLE_QCACLD), true)
  33. # Assume no targets will be supported
  34. WLAN_CHIPSET :=
  35. ifeq ($(BOARD_HAS_QCOM_WLAN), true)
  36. # Check if this driver needs be built for current target
  37. ifneq ($(findstring qca_cld3,$(WIFI_DRIVER_BUILT)),)
  38. WLAN_CHIPSET := qca_cld3
  39. WLAN_SELECT := CONFIG_QCA_CLD_WLAN=m
  40. endif
  41. # Build/Package only in case of supported target
  42. ifneq ($(WLAN_CHIPSET),)
  43. # This makefile is only for DLKM
  44. ifneq ($(findstring vendor,$(LOCAL_PATH)),)
  45. ifneq ($(findstring opensource,$(LOCAL_PATH)),)
  46. WLAN_BLD_DIR := vendor/qcom/opensource/wlan
  47. endif # opensource
  48. # Multi-ko check
  49. LOCAL_DEV_NAME := $(patsubst .%,%,\
  50. $(lastword $(strip $(subst /, ,$(LOCAL_PATH)))))
  51. $(call wlog,LOCAL_DEV_NAME=$(LOCAL_DEV_NAME))
  52. $(call wlog,TARGET_WLAN_CHIP=$(TARGET_WLAN_CHIP))
  53. TARGET_WLAN_CHIP ?= wlan
  54. LOCAL_MULTI_KO := false
  55. ifneq ($(TARGET_WLAN_CHIP), wlan)
  56. ifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
  57. LOCAL_MULTI_KO := true
  58. endif
  59. endif
  60. ifeq ($(LOCAL_MULTI_KO), true)
  61. LOCAL_ANDROID_ROOT := $(shell pwd)
  62. LOCAL_WLAN_BLD_DIR := $(LOCAL_ANDROID_ROOT)/$(WLAN_BLD_DIR)
  63. $(shell `find $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/ -maxdepth 1 -name '.*' ! -name '.git' -delete`)
  64. ifeq ($(LOCAL_MODULE_DDK_BUILD), true)
  65. # DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
  66. ifeq ($(call is-platform-sdk-version-at-least,16),true)
  67. DLKM_DIR := $(TOP)/$(BOARD_COMMON_DIR)/dlkm
  68. else
  69. DLKM_DIR := build/dlkm
  70. endif # platform-sdk-version
  71. include $(CLEAR_VARS)
  72. LOCAL_MOD_NAME := wlan
  73. LOCAL_MODULE := qca_cld3_kiwi_v2.ko
  74. LOCAL_MODULE_KBUILD_NAME := qca_cld3_kiwi_v2.ko
  75. LOCAL_MODULE_DEBUG_ENABLE := true
  76. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  77. ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  78. LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
  79. else
  80. LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
  81. endif
  82. else
  83. LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
  84. endif
  85. LOCAL_DEV_NAME := kiwi_v2
  86. LOCAL_CHIP_NAME := $(LOCAL_DEV_NAME)
  87. TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
  88. TARGET_FW_DIR := firmware/wlan/qca_cld/$(LOCAL_CHIP_NAME)
  89. TARGET_CFG_PATH := /vendor/etc/wifi/$(LOCAL_CHIP_NAME)
  90. TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
  91. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  92. TARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
  93. else
  94. TARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
  95. endif
  96. # Create wlan_mac.bin symbolic link as part of the module
  97. $(call symlink-file,,$(TARGET_MAC_BIN_PATH)/wlan_mac.bin,$(TARGET_FW_PATH)/wlan_mac.bin)
  98. LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_FW_PATH)/wlan_mac.bin
  99. # Conditionally create module symbolic link
  100. ifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
  101. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  102. ifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  103. $(call symlink-file,,$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
  104. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE)
  105. endif
  106. else
  107. $(call symlink-file,,/system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
  108. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE)
  109. endif
  110. endif
  111. # Conditionally create ini symbolic link
  112. ifeq ($(TARGET_BOARD_AUTO),true)
  113. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  114. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  115. $(call wlog,"generate soft link because TARGET_BOARD_AUTO true")
  116. else
  117. ifneq ($(GENERIC_ODM_IMAGE),true)
  118. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  119. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  120. $(call wlog,"generate soft link because GENERIC_ODM_IMAGE not true")
  121. endif
  122. endif
  123. # Set dependencies so that CNSS family drivers can be compiled ahead.
  124. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  125. LOCAL_REQUIRED_MODULES := wlan-platform-module-symvers
  126. LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  127. endif
  128. $(call wlog,TARGET_USES_KERNEL_PLATFORM=$(TARGET_USES_KERNEL_PLATFORM))
  129. ifeq ($(TARGET_USES_KERNEL_PLATFORM),true)
  130. include $(DLKM_DIR)/Build_external_kernelmodule.mk
  131. else
  132. include $(DLKM_DIR)/AndroidKernelModule.mk
  133. endif
  134. else
  135. $(foreach chip, $(TARGET_WLAN_CHIP), \
  136. $(shell ln -sf . $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/.$(chip)))
  137. include $(foreach chip, $(TARGET_WLAN_CHIP), $(LOCAL_PATH)/.$(chip)/Android.mk)
  138. endif
  139. else # Multi-ok check
  140. # When dual wlan enabled, secondary dev name would be $(chip)_cnss2.
  141. # Use LOCAL_CHIP_NAME instead of LOCAL_DEV_NAME for secondary one.
  142. LOCAL_CHIP_NAME := $(LOCAL_DEV_NAME)
  143. TARGET_SECONDARY_WLAN := $(call target_is_dual_wlan,$(LOCAL_DEV_NAME))
  144. ifeq ($(TARGET_SECONDARY_WLAN), true)
  145. LOCAL_CHIP_NAME := $(patsubst %_cnss2,%,$(strip $(LOCAL_DEV_NAME)))
  146. endif
  147. ifeq ($(WLAN_PROFILE),)
  148. WLAN_PROFILE := default
  149. endif
  150. ifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
  151. LOCAL_DEV_NAME := wlan
  152. LOCAL_MOD_NAME := wlan
  153. LOCAL_SRC_DIR :=
  154. TARGET_FW_DIR := firmware/wlan/qca_cld
  155. TARGET_CFG_PATH := /vendor/etc/wifi
  156. TARGET_MAC_BIN_PATH := /mnt/vendor/persist
  157. else
  158. LOCAL_SRC_DIR := .$(LOCAL_DEV_NAME)
  159. # Use default profile if WLAN_CFG_USE_DEFAULT defined.
  160. ifeq ($(WLAN_CFG_USE_DEFAULT),)
  161. WLAN_PROFILE := $(LOCAL_CHIP_NAME)
  162. endif
  163. TARGET_FW_DIR := firmware/wlan/qca_cld/$(LOCAL_CHIP_NAME)
  164. TARGET_CFG_PATH := /vendor/etc/wifi/$(LOCAL_CHIP_NAME)
  165. TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
  166. ifneq ($(TARGET_MULTI_WLAN), true)
  167. LOCAL_MOD_NAME := wlan
  168. DYNAMIC_SINGLE_CHIP := $(LOCAL_DEV_NAME)
  169. else
  170. LOCAL_MOD_NAME := $(LOCAL_DEV_NAME)
  171. endif
  172. ifeq ($(TARGET_SECONDARY_WLAN), true)
  173. LOCAL_MOD_NAME := $(LOCAL_CHIP_NAME)
  174. DYNAMIC_SINGLE_CHIP := $(LOCAL_CHIP_NAME)
  175. endif
  176. endif
  177. # DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
  178. ifeq ($(call is-platform-sdk-version-at-least,16),true)
  179. DLKM_DIR := $(TOP)/$(BOARD_COMMON_DIR)/dlkm
  180. else
  181. DLKM_DIR := build/dlkm
  182. endif # platform-sdk-version
  183. # Build wlan.ko as $(WLAN_CHIPSET)_wlan.ko
  184. ###########################################################
  185. # This is set once per LOCAL_PATH, not per (kernel) module
  186. KBUILD_OPTIONS := WLAN_ROOT=$(WLAN_BLD_DIR)/qcacld-3.0/$(LOCAL_SRC_DIR)
  187. KBUILD_OPTIONS += WLAN_COMMON_ROOT=cmn
  188. KBUILD_OPTIONS += WLAN_COMMON_INC=$(WLAN_BLD_DIR)/qcacld-3.0/cmn
  189. KBUILD_OPTIONS += WLAN_FW_API=$(WLAN_BLD_DIR)/fw-api
  190. KBUILD_OPTIONS += WLAN_PROFILE=$(WLAN_PROFILE)
  191. KBUILD_OPTIONS += DYNAMIC_SINGLE_CHIP=$(DYNAMIC_SINGLE_CHIP)
  192. # We are actually building wlan.ko here, as per the
  193. # requirement we are specifying <chipset>_wlan.ko as LOCAL_MODULE.
  194. # This means we need to rename the module to <chipset>_wlan.ko
  195. # after wlan.ko is built.
  196. KBUILD_OPTIONS += MODNAME=$(LOCAL_MOD_NAME)
  197. KBUILD_OPTIONS += DEVNAME=$(LOCAL_DEV_NAME)
  198. KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
  199. KBUILD_OPTIONS += $(WLAN_SELECT)
  200. KBUILD_REQUIRED_KOS := ipam.ko
  201. ifneq ($(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME)),)
  202. KBUILD_OPTIONS += WLAN_CFG_OVERRIDE="$(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME))"
  203. endif
  204. # driver expects "/dev/<name>" for wifi driver state ctrl parameter.
  205. # i.e. WIFI_DRIVER_STATE_CTRL_PARAM="/dev/wlan" is defined for single wlan.
  206. # WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY="/dev/wlan2" is defined for 2nd wlan.
  207. ifeq ($(TARGET_SECONDARY_WLAN), true)
  208. $(call wlog,STATE_CTRL_PARAM_SECONDARY=$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
  209. PARAM_SECONDARY := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
  210. $(call wlog,PARAM_SECONDARY=$(PARAM_SECONDARY))
  211. ifeq ($(dir $(PARAM_SECONDARY)),/dev/)
  212. KBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM_SECONDARY))
  213. endif
  214. else
  215. $(call wlog,WIFI_DRIVER_STATE_CTRL_PARAM=$(WIFI_DRIVER_STATE_CTRL_PARAM))
  216. PARAM := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM))
  217. $(call wlog,PARAM=$(PARAM))
  218. ifeq ($(dir $(PARAM)),/dev/)
  219. KBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM))
  220. endif
  221. endif
  222. # Pass build options per chip to Kbuild. This will be injected from upper layer
  223. # makefile.
  224. #
  225. # e.g.
  226. # WLAN_KBUILD_OPTIONS_qca6390 := CONFIG_CNSS_QCA6390=y
  227. ifneq ($(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME)),)
  228. KBUILD_OPTIONS += "$(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME))"
  229. endif
  230. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  231. TARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
  232. else
  233. TARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
  234. endif
  235. # WLAN_PLATFORM_KBUILD_OPTIONS should be passed from upper level Makefiles
  236. # like wlan.mk. It indicates sources of CNSS family drivers (cnss2, cnss_nl,
  237. # cnss_prealloc and cnss_utils etc.) are built out of kernel tree and it
  238. # should also include all necessary config flags (e.g. CONFIG_CNSS2) which
  239. # are originally defined from kernel Kconfig/defconfig. KBUILD_EXTRA_SYMBOLS
  240. # is also needed to indicate all the symbols from these drivers.
  241. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  242. KBUILD_OPTIONS += $(foreach wlan_platform_kbuild_option, \
  243. $(WLAN_PLATFORM_KBUILD_OPTIONS), \
  244. $(wlan_platform_kbuild_option))
  245. KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS+=$(shell pwd)/$(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  246. endif
  247. include $(CLEAR_VARS)
  248. # Create the module
  249. LOCAL_MODULE := $(WLAN_CHIPSET)_$(LOCAL_DEV_NAME).ko
  250. LOCAL_MODULE_KBUILD_NAME := $(LOCAL_MOD_NAME).ko
  251. LOCAL_MODULE_DEBUG_ENABLE := true
  252. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  253. ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  254. LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
  255. else
  256. LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
  257. endif
  258. else
  259. LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
  260. endif
  261. # Create wlan_mac.bin symbolic link as part of the module
  262. $(call symlink-file,,$(TARGET_MAC_BIN_PATH)/wlan_mac.bin,$(TARGET_FW_PATH)/wlan_mac.bin)
  263. LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_FW_PATH)/wlan_mac.bin
  264. # Conditionally create module symbolic link
  265. ifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
  266. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  267. ifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  268. $(call symlink-file,,$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
  269. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE)
  270. endif
  271. else
  272. $(call symlink-file,,/system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
  273. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE)
  274. endif
  275. endif
  276. # Conditionally create ini symbolic link
  277. ifeq ($(TARGET_BOARD_AUTO),true)
  278. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  279. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  280. $(call wlog,"generate soft link because TARGET_BOARD_AUTO true")
  281. else
  282. ifneq ($(GENERIC_ODM_IMAGE),true)
  283. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  284. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  285. $(call wlog,"generate soft link because GENERIC_ODM_IMAGE not true")
  286. endif
  287. endif
  288. # Set dependencies so that CNSS family drivers can be compiled ahead.
  289. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  290. LOCAL_REQUIRED_MODULES := wlan-platform-module-symvers
  291. LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  292. endif
  293. $(call wlog,TARGET_USES_KERNEL_PLATFORM=$(TARGET_USES_KERNEL_PLATFORM))
  294. ifeq ($(TARGET_USES_KERNEL_PLATFORM),true)
  295. include $(DLKM_DIR)/Build_external_kernelmodule.mk
  296. else
  297. include $(DLKM_DIR)/AndroidKernelModule.mk
  298. endif
  299. endif # Multi-ko check
  300. endif # DLKM check
  301. endif # supported target check
  302. endif # WLAN enabled check
  303. endif # ENABLE_QCACLD