Android.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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. # 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. TARGET_SECONDARY_WLAN_NUMBER := 2
  174. LOCAL_MOD_NAME := $(LOCAL_CHIP_NAME)_$(TARGET_SECONDARY_WLAN_NUMBER)
  175. DYNAMIC_SINGLE_CHIP := $(LOCAL_CHIP_NAME)
  176. endif
  177. endif
  178. # DLKM_DIR was moved for JELLY_BEAN (PLATFORM_SDK 16)
  179. ifeq ($(call is-platform-sdk-version-at-least,16),true)
  180. DLKM_DIR := $(TOP)/$(BOARD_COMMON_DIR)/dlkm
  181. else
  182. DLKM_DIR := build/dlkm
  183. endif # platform-sdk-version
  184. # Build wlan.ko as $(WLAN_CHIPSET)_wlan.ko
  185. ###########################################################
  186. # This is set once per LOCAL_PATH, not per (kernel) module
  187. KBUILD_OPTIONS := WLAN_ROOT=$(WLAN_BLD_DIR)/qcacld-3.0/$(LOCAL_SRC_DIR)
  188. KBUILD_OPTIONS += WLAN_COMMON_ROOT=cmn
  189. KBUILD_OPTIONS += WLAN_COMMON_INC=$(WLAN_BLD_DIR)/qcacld-3.0/cmn
  190. KBUILD_OPTIONS += WLAN_FW_API=$(WLAN_BLD_DIR)/fw-api
  191. KBUILD_OPTIONS += WLAN_PROFILE=$(WLAN_PROFILE)
  192. KBUILD_OPTIONS += DYNAMIC_SINGLE_CHIP=$(DYNAMIC_SINGLE_CHIP)
  193. # We are actually building wlan.ko here, as per the
  194. # requirement we are specifying <chipset>_wlan.ko as LOCAL_MODULE.
  195. # This means we need to rename the module to <chipset>_wlan.ko
  196. # after wlan.ko is built.
  197. KBUILD_OPTIONS += MODNAME=$(LOCAL_MOD_NAME)
  198. KBUILD_OPTIONS += DEVNAME=$(LOCAL_DEV_NAME)
  199. KBUILD_OPTIONS += BOARD_PLATFORM=$(TARGET_BOARD_PLATFORM)
  200. KBUILD_OPTIONS += $(WLAN_SELECT)
  201. KBUILD_REQUIRED_KOS := ipam.ko
  202. ifneq ($(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME)),)
  203. KBUILD_OPTIONS += WLAN_CFG_OVERRIDE="$(WLAN_CFG_OVERRIDE_$(LOCAL_DEV_NAME))"
  204. endif
  205. # driver expects "/dev/<name>" for wifi driver state ctrl parameter.
  206. # i.e. WIFI_DRIVER_STATE_CTRL_PARAM="/dev/wlan" is defined for single wlan.
  207. # WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY="/dev/wlan2" is defined for 2nd wlan.
  208. ifeq ($(TARGET_SECONDARY_WLAN), true)
  209. $(call wlog,STATE_CTRL_PARAM_SECONDARY=$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
  210. PARAM_SECONDARY := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM_SECONDARY))
  211. $(call wlog,PARAM_SECONDARY=$(PARAM_SECONDARY))
  212. ifeq ($(dir $(PARAM_SECONDARY)),/dev/)
  213. KBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM_SECONDARY))
  214. endif
  215. else
  216. $(call wlog,WIFI_DRIVER_STATE_CTRL_PARAM=$(WIFI_DRIVER_STATE_CTRL_PARAM))
  217. PARAM := $(patsubst "%",%,$(WIFI_DRIVER_STATE_CTRL_PARAM))
  218. $(call wlog,PARAM=$(PARAM))
  219. ifeq ($(dir $(PARAM)),/dev/)
  220. KBUILD_OPTIONS += WLAN_CTRL_NAME=$(notdir $(PARAM))
  221. endif
  222. endif
  223. # Pass build options per chip to Kbuild. This will be injected from upper layer
  224. # makefile.
  225. #
  226. # e.g.
  227. # WLAN_KBUILD_OPTIONS_qca6390 := CONFIG_CNSS_QCA6390=y
  228. ifneq ($(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME)),)
  229. KBUILD_OPTIONS += "$(WLAN_KBUILD_OPTIONS_$(LOCAL_DEV_NAME))"
  230. endif
  231. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  232. TARGET_FW_PATH := $(TARGET_OUT_VENDOR)/$(TARGET_FW_DIR)
  233. else
  234. TARGET_FW_PATH := $(TARGET_OUT_ETC)/$(TARGET_FW_DIR)
  235. endif
  236. # WLAN_PLATFORM_KBUILD_OPTIONS should be passed from upper level Makefiles
  237. # like wlan.mk. It indicates sources of CNSS family drivers (cnss2, cnss_nl,
  238. # cnss_prealloc and cnss_utils etc.) are built out of kernel tree and it
  239. # should also include all necessary config flags (e.g. CONFIG_CNSS2) which
  240. # are originally defined from kernel Kconfig/defconfig. KBUILD_EXTRA_SYMBOLS
  241. # is also needed to indicate all the symbols from these drivers.
  242. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  243. KBUILD_OPTIONS += $(foreach wlan_platform_kbuild_option, \
  244. $(WLAN_PLATFORM_KBUILD_OPTIONS), \
  245. $(wlan_platform_kbuild_option))
  246. KBUILD_OPTIONS += KBUILD_EXTRA_SYMBOLS+=$(shell pwd)/$(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  247. endif
  248. include $(CLEAR_VARS)
  249. # Create the module
  250. LOCAL_MODULE := $(WLAN_CHIPSET)_$(LOCAL_DEV_NAME).ko
  251. LOCAL_MODULE_KBUILD_NAME := $(LOCAL_MOD_NAME).ko
  252. LOCAL_MODULE_DEBUG_ENABLE := true
  253. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  254. ifeq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  255. LOCAL_MODULE_PATH := $(KERNEL_MODULES_OUT)
  256. else
  257. LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)
  258. endif
  259. else
  260. LOCAL_MODULE_PATH := $(TARGET_OUT)/lib/modules/$(WLAN_CHIPSET)
  261. endif
  262. # Create wlan_mac.bin symbolic link as part of the module
  263. $(call symlink-file,,$(TARGET_MAC_BIN_PATH)/wlan_mac.bin,$(TARGET_FW_PATH)/wlan_mac.bin)
  264. LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_FW_PATH)/wlan_mac.bin
  265. # Conditionally create module symbolic link
  266. ifneq ($(findstring $(WLAN_CHIPSET),$(WIFI_DRIVER_DEFAULT)),)
  267. ifeq ($(PRODUCT_VENDOR_MOVE_ENABLED),true)
  268. ifneq ($(WIFI_DRIVER_INSTALL_TO_KERNEL_OUT),true)
  269. $(call symlink-file,,$(TARGET_COPY_OUT_VENDOR)/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE))
  270. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT_VENDOR)/lib/modules/$(LOCAL_MODULE)
  271. endif
  272. else
  273. $(call symlink-file,,/system/lib/modules/$(WLAN_CHIPSET)/$(LOCAL_MODULE),$(TARGET_OUT)/lib/modules/$(LOCAL_MODULE))
  274. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_OUT)/lib/modules/$(LOCAL_MODULE)
  275. endif
  276. endif
  277. # Conditionally create ini symbolic link
  278. ifeq ($(TARGET_BOARD_AUTO),true)
  279. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  280. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  281. $(call wlog,"generate soft link because TARGET_BOARD_AUTO true")
  282. else
  283. ifneq ($(GENERIC_ODM_IMAGE),true)
  284. $(call symlink-file,,$(TARGET_CFG_PATH)/WCNSS_qcom_cfg.ini,$(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini)
  285. LOCAL_ADDITIONAL_DEPENDENCIES += $(TARGET_FW_PATH)/WCNSS_qcom_cfg.ini
  286. $(call wlog,"generate soft link because GENERIC_ODM_IMAGE not true")
  287. endif
  288. endif
  289. # Set dependencies so that CNSS family drivers can be compiled ahead.
  290. ifneq ($(WLAN_PLATFORM_KBUILD_OPTIONS),)
  291. LOCAL_REQUIRED_MODULES := wlan-platform-module-symvers
  292. LOCAL_ADDITIONAL_DEPENDENCIES += $(call intermediates-dir-for,DLKM,wlan-platform-module-symvers)/Module.symvers
  293. endif
  294. $(call wlog,TARGET_USES_KERNEL_PLATFORM=$(TARGET_USES_KERNEL_PLATFORM))
  295. ifeq ($(TARGET_USES_KERNEL_PLATFORM),true)
  296. include $(DLKM_DIR)/Build_external_kernelmodule.mk
  297. else
  298. include $(DLKM_DIR)/AndroidKernelModule.mk
  299. endif
  300. endif # Multi-ko check
  301. endif # DLKM check
  302. endif # supported target check
  303. endif # WLAN enabled check
  304. endif # ENABLE_QCACLD