Android.mk 7.4 KB

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