Android.mk 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  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 := false
  14. LOCAL_MODULE_DDK_ALLOW_UNSAFE_HEADERS := false
  15. ifeq ($(TARGET_BOARD_PLATFORM), pineapple)
  16. LOCAL_MODULE_DDK_BUILD := true
  17. LOCAL_MODULE_DDK_ALLOW_UNSAFE_HEADERS := true
  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. ifeq ($(CHIPSET),)
  66. $(foreach chip, $(TARGET_WLAN_CHIP),\
  67. $(eval CHIPSET := $(chip))\
  68. $(eval include $(LOCAL_PATH)/Android.mk))
  69. else
  70. # DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
  71. BAZEL_CHIPSET_NAME := $(subst _,-,$(CHIPSET))
  72. ifeq ($(call is-platform-sdk-version-at-least,16),true)
  73. DLKM_DIR := $(TOP)/$(BOARD_COMMON_DIR)/dlkm
  74. else
  75. DLKM_DIR := build/dlkm
  76. endif # platform-sdk-version
  77. include $(CLEAR_VARS)
  78. LOCAL_MOD_NAME := wlan
  79. LOCAL_MODULE := qca_cld3_$(CHIPSET).ko
  80. LOCAL_MODULE_KBUILD_NAME := qca_cld3_$(CHIPSET).ko
  81. LOCAL_MODULE_DEBUG_ENABLE := true
  82. LOCAL_MODULE_DDK_SUBTARGET_REGEX := "all.*"
  83. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  84. ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  85. LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
  86. else
  87. LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
  88. endif
  89. else
  90. LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
  91. endif
  92. LOCAL_DEV_NAME := $(CHIPSET)
  93. LOCAL_CHIP_NAME := $(LOCAL_DEV_NAME)
  94. TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
  95. TARGET_FW_DIR := firmware/wlan/qca_cld/$(LOCAL_CHIP_NAME)
  96. TARGET_CFG_PATH := /vendor/etc/wifi/$(LOCAL_CHIP_NAME)
  97. TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
  98. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  99. TARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
  100. else
  101. TARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
  102. endif
  103. # Create wlan_mac.bin symbolic link as part of the module
  104. $(call symlink-file,,$(TARGET_MAC_BIN_PATH)/wlan_mac.bin,$(TARGET_FW_PATH)/wlan_mac.bin)
  105. LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_FW_PATH)/wlan_mac.bin
  106. # Conditionally create module symbolic link
  107. ifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
  108. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  109. ifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  110. $(call symlink-file,,$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
  111. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE)
  112. endif
  113. else
  114. $(call symlink-file,,/system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
  115. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE)
  116. endif
  117. endif
  118. # Conditionally create ini symbolic link
  119. ifeq ($(TARGET_BOARD_AUTO),true)
  120. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  121. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  122. $(call wlog,"generate soft link because TARGET_BOARD_AUTO true")
  123. else
  124. ifneq ($(GENERIC_ODM_IMAGE),true)
  125. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  126. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  127. $(call wlog,"generate soft link because GENERIC_ODM_IMAGE not true")
  128. endif
  129. endif
  130. # Set dependencies so that CNSS family drivers can be compiled ahead.
  131. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  132. LOCAL_REQUIRED_MODULES := wlan-platform-module-symvers
  133. LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  134. endif
  135. $(call wlog,TARGET_USES_KERNEL_PLATFORM=$(TARGET_USES_KERNEL_PLATFORM))
  136. ifeq ($(TARGET_USES_KERNEL_PLATFORM),true)
  137. include $(DLKM_DIR)/Build_external_kernelmodule.mk
  138. else
  139. include $(DLKM_DIR)/AndroidKernelModule.mk
  140. endif
  141. endif
  142. else
  143. $(foreach chip, $(TARGET_WLAN_CHIP), \
  144. $(shell ln -sf . $(LOCAL_WLAN_BLD_DIR)/qcacld-3.0/.$(chip)))
  145. include $(foreach chip, $(TARGET_WLAN_CHIP), $(LOCAL_PATH)/.$(chip)/Android.mk)
  146. endif
  147. else # Multi-ok check
  148. # When dual wlan enabled, secondary dev name would be $(chip)_cnss2.
  149. # Use LOCAL_CHIP_NAME instead of LOCAL_DEV_NAME for secondary one.
  150. LOCAL_CHIP_NAME := $(LOCAL_DEV_NAME)
  151. TARGET_SECONDARY_WLAN := $(call target_is_dual_wlan,$(LOCAL_DEV_NAME))
  152. ifeq ($(TARGET_SECONDARY_WLAN), true)
  153. LOCAL_CHIP_NAME := $(patsubst %_cnss2,%,$(strip $(LOCAL_DEV_NAME)))
  154. endif
  155. ifeq ($(WLAN_PROFILE),)
  156. WLAN_PROFILE := default
  157. endif
  158. ifeq ($(LOCAL_DEV_NAME), qcacld-3.0)
  159. LOCAL_DEV_NAME := wlan
  160. LOCAL_MOD_NAME := wlan
  161. LOCAL_SRC_DIR :=
  162. TARGET_FW_DIR := firmware/wlan/qca_cld
  163. TARGET_CFG_PATH := /vendor/etc/wifi
  164. TARGET_MAC_BIN_PATH := /mnt/vendor/persist
  165. else
  166. LOCAL_SRC_DIR := .$(LOCAL_DEV_NAME)
  167. # Use default profile if WLAN_CFG_USE_DEFAULT defined.
  168. ifeq ($(WLAN_CFG_USE_DEFAULT),)
  169. WLAN_PROFILE := $(LOCAL_CHIP_NAME)
  170. endif
  171. TARGET_FW_DIR := firmware/wlan/qca_cld/$(LOCAL_CHIP_NAME)
  172. TARGET_CFG_PATH := /vendor/etc/wifi/$(LOCAL_CHIP_NAME)
  173. TARGET_MAC_BIN_PATH := /mnt/vendor/persist/$(LOCAL_CHIP_NAME)
  174. ifneq ($(TARGET_MULTI_WLAN), true)
  175. LOCAL_MOD_NAME := wlan
  176. DYNAMIC_SINGLE_CHIP := $(LOCAL_DEV_NAME)
  177. else
  178. LOCAL_MOD_NAME := $(LOCAL_DEV_NAME)
  179. endif
  180. ifeq ($(TARGET_SECONDARY_WLAN), true)
  181. TARGET_SECONDARY_WLAN_NUMBER := 2
  182. LOCAL_MOD_NAME := $(LOCAL_CHIP_NAME)_$(TARGET_SECONDARY_WLAN_NUMBER)
  183. DYNAMIC_SINGLE_CHIP := $(LOCAL_CHIP_NAME)
  184. endif
  185. endif
  186. # DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
  187. ifeq ($(call is-platform-sdk-version-at-least,16),true)
  188. DLKM_DIR := $(TOP)/$(BOARD_COMMON_DIR)/dlkm
  189. else
  190. DLKM_DIR := build/dlkm
  191. endif # platform-sdk-version
  192. # Build wlan.ko as $(WLAN_CHIPSET)_wlan.ko
  193. ###########################################################
  194. # This is set once per LOCAL_PATH, not per (kernel) module
  195. KBUILD_OPTIONS := WLAN_ROOT=$(WLAN_BLD_DIR)/qcacld-3.0/$(LOCAL_SRC_DIR)
  196. KBUILD_OPTIONS += WLAN_COMMON_ROOT=cmn
  197. KBUILD_OPTIONS += WLAN_COMMON_INC=$(WLAN_BLD_DIR)/qcacld-3.0/cmn
  198. KBUILD_OPTIONS += WLAN_FW_API=$(WLAN_BLD_DIR)/fw-api
  199. KBUILD_OPTIONS += WLAN_PROFILE=$(WLAN_PROFILE)
  200. KBUILD_OPTIONS += DYNAMIC_SINGLE_CHIP=$(DYNAMIC_SINGLE_CHIP)
  201. # We are actually building wlan.ko here, as per the
  202. # requirement we are specifying <chipset>_wlan.ko as LOCAL_MODULE.
  203. # This means we need to rename the module to <chipset>_wlan.ko
  204. # after wlan.ko is built.
  205. KBUILD_OPTIONS += MODNAME=$(LOCAL_MOD_NAME)
  206. KBUILD_OPTIONS += DEVNAME=$(LOCAL_DEV_NAME)
  207. KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
  208. KBUILD_OPTIONS += $(WLAN_SELECT)
  209. KBUILD_REQUIRED_KOS := ipam.ko
  210. ifneq ($(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME)),)
  211. KBUILD_OPTIONS += WLAN_CFG_OVERRIDE="$(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME))"
  212. endif
  213. # driver expects "/dev/<name>" for wifi driver state ctrl parameter.
  214. # i.e. WIFI_DRIVER_STATE_CTRL_PARAM="/dev/wlan" is defined for single wlan.
  215. # WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY="/dev/wlan2" is defined for 2nd wlan.
  216. ifeq ($(TARGET_SECONDARY_WLAN), true)
  217. $(call wlog,STATE_CTRL_PARAM_SECONDARY=$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
  218. PARAM_SECONDARY := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
  219. $(call wlog,PARAM_SECONDARY=$(PARAM_SECONDARY))
  220. ifeq ($(dir $(PARAM_SECONDARY)),/dev/)
  221. KBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM_SECONDARY))
  222. endif
  223. else
  224. $(call wlog,WIFI_DRIVER_STATE_CTRL_PARAM=$(WIFI_DRIVER_STATE_CTRL_PARAM))
  225. PARAM := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM))
  226. $(call wlog,PARAM=$(PARAM))
  227. ifeq ($(dir $(PARAM)),/dev/)
  228. KBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM))
  229. endif
  230. endif
  231. # Pass build options per chip to Kbuild. This will be injected from upper layer
  232. # makefile.
  233. #
  234. # e.g.
  235. # WLAN_KBUILD_OPTIONS_qca6390 := CONFIG_CNSS_QCA6390=y
  236. ifneq ($(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME)),)
  237. KBUILD_OPTIONS += "$(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME))"
  238. endif
  239. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  240. TARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
  241. else
  242. TARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
  243. endif
  244. # WLAN_PLATFORM_KBUILD_OPTIONS should be passed from upper level Makefiles
  245. # like wlan.mk. It indicates sources of CNSS family drivers (cnss2, cnss_nl,
  246. # cnss_prealloc and cnss_utils etc.) are built out of kernel tree and it
  247. # should also include all necessary config flags (e.g. CONFIG_CNSS2) which
  248. # are originally defined from kernel Kconfig/defconfig. KBUILD_EXTRA_SYMBOLS
  249. # is also needed to indicate all the symbols from these drivers.
  250. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  251. KBUILD_OPTIONS += $(foreach wlan_platform_kbuild_option, \
  252. $(WLAN_PLATFORM_KBUILD_OPTIONS), \
  253. $(wlan_platform_kbuild_option))
  254. KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS+=$(shell pwd)/$(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  255. endif
  256. include $(CLEAR_VARS)
  257. # Create the module
  258. LOCAL_MODULE := $(WLAN_CHIPSET)_$(LOCAL_DEV_NAME).ko
  259. LOCAL_MODULE_KBUILD_NAME := $(LOCAL_MOD_NAME).ko
  260. LOCAL_MODULE_DEBUG_ENABLE := true
  261. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  262. ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  263. LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
  264. else
  265. LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
  266. endif
  267. else
  268. LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
  269. endif
  270. # Create wlan_mac.bin symbolic link as part of the module
  271. $(call symlink-file,,$(TARGET_MAC_BIN_PATH)/wlan_mac.bin,$(TARGET_FW_PATH)/wlan_mac.bin)
  272. LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_FW_PATH)/wlan_mac.bin
  273. # Conditionally create module symbolic link
  274. ifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
  275. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  276. ifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  277. $(call symlink-file,,$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
  278. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE)
  279. endif
  280. else
  281. $(call symlink-file,,/system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
  282. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE)
  283. endif
  284. endif
  285. # Conditionally create ini symbolic link
  286. ifeq ($(TARGET_BOARD_AUTO),true)
  287. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  288. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  289. $(call wlog,"generate soft link because TARGET_BOARD_AUTO true")
  290. else
  291. ifneq ($(GENERIC_ODM_IMAGE),true)
  292. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  293. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  294. $(call wlog,"generate soft link because GENERIC_ODM_IMAGE not true")
  295. endif
  296. endif
  297. # Set dependencies so that CNSS family drivers can be compiled ahead.
  298. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  299. LOCAL_REQUIRED_MODULES := wlan-platform-module-symvers
  300. LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  301. endif
  302. $(call wlog,TARGET_USES_KERNEL_PLATFORM=$(TARGET_USES_KERNEL_PLATFORM))
  303. ifeq ($(TARGET_USES_KERNEL_PLATFORM),true)
  304. include $(DLKM_DIR)/Build_external_kernelmodule.mk
  305. else
  306. include $(DLKM_DIR)/AndroidKernelModule.mk
  307. endif
  308. endif # Multi-ko check
  309. endif # DLKM check
  310. endif # supported target check
  311. endif # WLAN enabled check
  312. endif # ENABLE_QCACLD