# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2019-2024 Hailo Technologies Ltd. All rights reserved.
#

COMMON_SRC_DIRECTORY=../../common
VDMA_SRC_DIRECTORY=../vdma
UTILS_SRC_DIRECTORY=../utils
BASE_INCLUDE_DIRECTORY=..

obj-m := hailo_integrated_nnc.o

hailo_integrated_nnc-objs += src/main.o
hailo_integrated_nnc-objs += src/dram_vdma.o
hailo_integrated_nnc-objs += src/integrated_nnc_cpu.o
hailo_integrated_nnc-objs += src/integrated_nnc_fw_validation.o
hailo_integrated_nnc-objs += src/file_operations.o
hailo_integrated_nnc-objs += src/fw_control.o
hailo_integrated_nnc-objs += src/fw_notification.o
hailo_integrated_nnc-objs += src/driver_down_notification.o
hailo_integrated_nnc-objs += src/fw_logger.o

hailo_integrated_nnc-objs += $(COMMON_SRC_DIRECTORY)/fw_validation.o
hailo_integrated_nnc-objs += $(COMMON_SRC_DIRECTORY)/fw_operation.o
hailo_integrated_nnc-objs += $(COMMON_SRC_DIRECTORY)/vdma_common.o
hailo_integrated_nnc-objs += $(COMMON_SRC_DIRECTORY)/hailo_resource.o

hailo_integrated_nnc-objs += $(UTILS_SRC_DIRECTORY)/logs.o
hailo_integrated_nnc-objs += $(UTILS_SRC_DIRECTORY)/integrated_nnc_utils.o

hailo_integrated_nnc-objs += $(VDMA_SRC_DIRECTORY)/vdma.o
hailo_integrated_nnc-objs += $(VDMA_SRC_DIRECTORY)/memory.o
hailo_integrated_nnc-objs += $(VDMA_SRC_DIRECTORY)/ioctl.o

ccflags-y      += -Werror
ccflags-y      += -I$(src)/include
ccflags-y      += -I$(src)/$(COMMON_SRC_DIRECTORY)
ccflags-y      += -I$(src)/$(BASE_INCLUDE_DIRECTORY)

ifeq ($(shell (test $(VERSION) -ge 6 && test $(PATCHLEVEL) -ge 9) && echo 1 || echo 0), 0)
# MMIO_DMA_MAPPING is not supported on kernels above 6.9 (since follow_pfn was removed).
ccflags-y      += -DHAILO_SUPPORT_MMIO_DMA_MAPPING
endif

clean-files := $(hailo_integrated_nnc-objs)
