Android.mk 8.9 KB

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