Android.mk 13 KB

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