Android.mk 13 KB

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