xref: /OK3568_Linux_fs/kernel/drivers/gpu/arm/bifrost/Kbuild (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2#
3# (C) COPYRIGHT 2012-2023 ARM Limited. All rights reserved.
4#
5# This program is free software and is provided to you under the terms of the
6# GNU General Public License version 2 as published by the Free Software
7# Foundation, and any use by you of this program is subject to the terms
8# of such GNU license.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, you can access it online at
17# http://www.gnu.org/licenses/gpl-2.0.html.
18#
19#
20
21# make $(src) as absolute path if it is not already, by prefixing $(srctree)
22# This is to prevent any build issue due to wrong path.
23src:=$(if $(patsubst /%,,$(src)),$(srctree)/$(src),$(src))
24
25#
26# Prevent misuse when Kernel configurations are not present by default
27# in out-of-tree builds
28#
29ifneq ($(CONFIG_ANDROID),n)
30ifeq ($(CONFIG_GPU_TRACEPOINTS),n)
31    $(error CONFIG_GPU_TRACEPOINTS must be set in Kernel configuration)
32endif
33endif
34
35ifeq ($(CONFIG_DMA_SHARED_BUFFER),n)
36    $(error CONFIG_DMA_SHARED_BUFFER must be set in Kernel configuration)
37endif
38
39ifeq ($(CONFIG_PM_DEVFREQ),n)
40    $(error CONFIG_PM_DEVFREQ must be set in Kernel configuration)
41endif
42
43ifeq ($(CONFIG_DEVFREQ_THERMAL),n)
44    $(error CONFIG_DEVFREQ_THERMAL must be set in Kernel configuration)
45endif
46
47ifeq ($(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND),n)
48    $(error CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND must be set in Kernel configuration)
49endif
50
51ifeq ($(CONFIG_FW_LOADER), n)
52    $(error CONFIG_FW_LOADER must be set in Kernel configuration)
53endif
54
55ifeq ($(CONFIG_MALI_PRFCNT_SET_SELECT_VIA_DEBUG_FS), y)
56    ifneq ($(CONFIG_DEBUG_FS), y)
57        $(error CONFIG_MALI_PRFCNT_SET_SELECT_VIA_DEBUG_FS depends on CONFIG_DEBUG_FS to be set in Kernel configuration)
58    endif
59endif
60
61ifeq ($(CONFIG_MALI_BIFROST_FENCE_DEBUG), y)
62    ifneq ($(CONFIG_SYNC_FILE), y)
63        $(error CONFIG_MALI_BIFROST_FENCE_DEBUG depends on CONFIG_SYNC_FILE to be set in Kernel configuration)
64    endif
65endif
66
67#
68# Configurations
69#
70
71# Driver version string which is returned to userspace via an ioctl
72MALI_RELEASE_NAME ?= '"g18p0-01eac0"'
73# Set up defaults if not defined by build system
74ifeq ($(CONFIG_MALI_BIFROST_DEBUG), y)
75    MALI_UNIT_TEST = 1
76    MALI_CUSTOMER_RELEASE ?= 0
77else
78    MALI_UNIT_TEST ?= 0
79    MALI_CUSTOMER_RELEASE ?= 1
80endif
81MALI_COVERAGE ?= 0
82
83# Kconfig passes in the name with quotes for in-tree builds - remove them.
84MALI_PLATFORM_DIR := $(shell echo $(CONFIG_MALI_PLATFORM_NAME))
85
86ifeq ($(CONFIG_MALI_CSF_SUPPORT),y)
87    MALI_JIT_PRESSURE_LIMIT_BASE = 0
88    MALI_USE_CSF = 1
89else
90    MALI_JIT_PRESSURE_LIMIT_BASE ?= 1
91    MALI_USE_CSF ?= 0
92endif
93
94
95ifneq ($(CONFIG_MALI_KUTF), n)
96    MALI_KERNEL_TEST_API ?= 1
97else
98    MALI_KERNEL_TEST_API ?= 0
99endif
100
101# Experimental features (corresponding -D definition should be appended to
102# ccflags-y below, e.g. for MALI_EXPERIMENTAL_FEATURE,
103# -DMALI_EXPERIMENTAL_FEATURE=$(MALI_EXPERIMENTAL_FEATURE) should be appended)
104#
105# Experimental features must default to disabled, e.g.:
106# MALI_EXPERIMENTAL_FEATURE ?= 0
107MALI_INCREMENTAL_RENDERING_JM ?= 0
108
109#
110# ccflags
111#
112ccflags-y = \
113    -DMALI_CUSTOMER_RELEASE=$(MALI_CUSTOMER_RELEASE) \
114    -DMALI_USE_CSF=$(MALI_USE_CSF) \
115    -DMALI_KERNEL_TEST_API=$(MALI_KERNEL_TEST_API) \
116    -DMALI_UNIT_TEST=$(MALI_UNIT_TEST) \
117    -DMALI_COVERAGE=$(MALI_COVERAGE) \
118    -DMALI_RELEASE_NAME=$(MALI_RELEASE_NAME) \
119    -DMALI_JIT_PRESSURE_LIMIT_BASE=$(MALI_JIT_PRESSURE_LIMIT_BASE) \
120    -DMALI_INCREMENTAL_RENDERING_JM=$(MALI_INCREMENTAL_RENDERING_JM) \
121    -DMALI_PLATFORM_DIR=$(MALI_PLATFORM_DIR)
122
123
124ifeq ($(KBUILD_EXTMOD),)
125# in-tree
126    ccflags-y +=-DMALI_KBASE_PLATFORM_PATH=../../$(src)/platform/$(CONFIG_MALI_PLATFORM_NAME)
127else
128# out-of-tree
129    ccflags-y +=-DMALI_KBASE_PLATFORM_PATH=$(src)/platform/$(CONFIG_MALI_PLATFORM_NAME)
130endif
131
132ccflags-y += \
133    -I$(srctree)/include/linux \
134    -I$(srctree)/drivers/staging/android \
135    -I$(src) \
136    -I$(src)/platform/$(MALI_PLATFORM_DIR) \
137    -I$(src)/../../../base \
138    -I$(src)/../../../../include
139
140subdir-ccflags-y += $(ccflags-y)
141
142#
143# Kernel Modules
144#
145obj-$(CONFIG_MALI_BIFROST) += bifrost_kbase.o
146obj-$(CONFIG_MALI_KUTF)    += tests/
147
148bifrost_kbase-y := \
149    mali_kbase_cache_policy.o \
150    mali_kbase_ccswe.o \
151    mali_kbase_mem.o \
152    mali_kbase_mem_migrate.o \
153    mali_kbase_mem_pool_group.o \
154    mali_kbase_native_mgm.o \
155    mali_kbase_ctx_sched.o \
156    mali_kbase_gpuprops.o \
157    mali_kbase_pm.o \
158    mali_kbase_config.o \
159    mali_kbase_kinstr_prfcnt.o \
160    mali_kbase_vinstr.o \
161    mali_kbase_softjobs.o \
162    mali_kbase_hw.o \
163    mali_kbase_debug.o \
164    mali_kbase_gpu_memory_debugfs.o \
165    mali_kbase_mem_linux.o \
166    mali_kbase_core_linux.o \
167    mali_kbase_mem_profile_debugfs.o \
168    mali_kbase_disjoint_events.o \
169    mali_kbase_debug_mem_view.o \
170    mali_kbase_debug_mem_zones.o \
171    mali_kbase_debug_mem_allocs.o \
172    mali_kbase_smc.o \
173    mali_kbase_mem_pool.o \
174    mali_kbase_mem_pool_debugfs.o \
175    mali_kbase_debugfs_helper.o \
176    mali_kbase_strings.o \
177    mali_kbase_as_fault_debugfs.o \
178    mali_kbase_regs_history_debugfs.o \
179    mali_kbase_dvfs_debugfs.o \
180    mali_power_gpu_frequency_trace.o \
181    mali_kbase_trace_gpu_mem.o \
182    mali_kbase_pbha.o
183
184bifrost_kbase-$(CONFIG_DEBUG_FS) += mali_kbase_pbha_debugfs.o
185
186bifrost_kbase-$(CONFIG_MALI_CINSTR_GWT) += mali_kbase_gwt.o
187
188bifrost_kbase-$(CONFIG_SYNC_FILE) += \
189    mali_kbase_fence_ops.o \
190    mali_kbase_sync_file.o \
191    mali_kbase_sync_common.o
192
193ifneq ($(CONFIG_MALI_CSF_SUPPORT),y)
194    bifrost_kbase-y += \
195        mali_kbase_jm.o \
196        mali_kbase_dummy_job_wa.o \
197        mali_kbase_debug_job_fault.o \
198        mali_kbase_event.o \
199        mali_kbase_jd.o \
200        mali_kbase_jd_debugfs.o \
201        mali_kbase_js.o \
202        mali_kbase_js_ctx_attr.o \
203        mali_kbase_kinstr_jm.o
204
205    bifrost_kbase-$(CONFIG_SYNC_FILE) += \
206        mali_kbase_fence_ops.o \
207        mali_kbase_fence.o
208endif
209
210
211INCLUDE_SUBDIR = \
212    $(src)/context/Kbuild \
213    $(src)/debug/Kbuild \
214    $(src)/device/Kbuild \
215    $(src)/backend/gpu/Kbuild \
216    $(src)/mmu/Kbuild \
217    $(src)/tl/Kbuild \
218    $(src)/hwcnt/Kbuild \
219    $(src)/gpu/Kbuild \
220    $(src)/thirdparty/Kbuild \
221    $(src)/platform/$(MALI_PLATFORM_DIR)/Kbuild
222
223ifeq ($(CONFIG_MALI_CSF_SUPPORT),y)
224    INCLUDE_SUBDIR += $(src)/csf/Kbuild
225endif
226
227ifeq ($(CONFIG_MALI_ARBITER_SUPPORT),y)
228    INCLUDE_SUBDIR += $(src)/arbiter/Kbuild
229endif
230
231ifeq ($(CONFIG_MALI_BIFROST_DEVFREQ),y)
232    ifeq ($(CONFIG_DEVFREQ_THERMAL),y)
233        INCLUDE_SUBDIR += $(src)/ipa/Kbuild
234    endif
235endif
236
237ifeq ($(KBUILD_EXTMOD),)
238# in-tree
239    -include $(INCLUDE_SUBDIR)
240else
241# out-of-tree
242    include $(INCLUDE_SUBDIR)
243endif
244