1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 28fad84c1SGeert UytterhoevenKBUILD_DEFCONFIG := mmu_defconfig 38fad84c1SGeert Uytterhoeven 44b2368ffSMichal SimekUTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" 55f8ffb5fSMichal Simek 65f8ffb5fSMichal Simek# What CPU vesion are we building for, and crack it open 75f8ffb5fSMichal Simek# as major.minor.rev 8950b260eSSam RavnborgCPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER)) 9950b260eSSam RavnborgCPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1) 10950b260eSSam RavnborgCPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2) 11950b260eSSam RavnborgCPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3) 125f8ffb5fSMichal Simek 135f8ffb5fSMichal Simekexport CPU_VER CPU_MAJOR CPU_MINOR CPU_REV 145f8ffb5fSMichal Simek 155f8ffb5fSMichal Simek# Use cpu-related CONFIG_ vars to set compile options. 16950b260eSSam Ravnborg# The various CONFIG_XILINX cpu features options are integers 0/1/2... 17950b260eSSam Ravnborg# rather than bools y/n 185f8ffb5fSMichal Simek 197f01af04SMichal Simek# Work out HW multipler support. This is tricky. 2025985edcSLucas De Marchi# 1. Spartan2 has no HW multipliers. 215f8ffb5fSMichal Simek# 2. MicroBlaze v3.x always uses them, except in Spartan 2 225f8ffb5fSMichal Simek# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings 235f8ffb5fSMichal Simekifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY))) 245f8ffb5fSMichal Simek ifeq ($(CPU_MAJOR),3) 255f8ffb5fSMichal Simek CPUFLAGS-1 += -mno-xl-soft-mul 265f8ffb5fSMichal Simek else 27732bee7aSUwe Kleine-König # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support. 285f8ffb5fSMichal Simek CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high 295f8ffb5fSMichal Simek CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul 305f8ffb5fSMichal Simek endif 315f8ffb5fSMichal Simekendif 325f8ffb5fSMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div 335f8ffb5fSMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift 3404e3a553SMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare 3571e7673dSArnd Bergmann 3671e7673dSArnd Bergmannifdef CONFIG_CPU_BIG_ENDIAN 3771e7673dSArnd BergmannKBUILD_CFLAGS += -mbig-endian 3871e7673dSArnd BergmannKBUILD_AFLAGS += -mbig-endian 39d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -EB 4071e7673dSArnd Bergmannelse 4171e7673dSArnd BergmannKBUILD_CFLAGS += -mlittle-endian 4271e7673dSArnd BergmannKBUILD_AFLAGS += -mlittle-endian 43d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -EL 4471e7673dSArnd Bergmannendif 455f8ffb5fSMichal Simek 465f8ffb5fSMichal SimekCPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 475f8ffb5fSMichal Simek 485f8ffb5fSMichal Simek# r31 holds current when in kernel mode 4971e7673dSArnd BergmannKBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2) 505f8ffb5fSMichal Simek 515f8ffb5fSMichal Simekhead-y := arch/microblaze/kernel/head.o 52950b260eSSam Ravnborglibs-y += arch/microblaze/lib/ 53950b260eSSam Ravnborgcore-y += arch/microblaze/kernel/ 54950b260eSSam Ravnborgcore-y += arch/microblaze/mm/ 55a6475c13SMichal Simekcore-$(CONFIG_PCI) += arch/microblaze/pci/ 565f8ffb5fSMichal Simek 573540ce82SJohn Williamsdrivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ 583540ce82SJohn Williams 59950b260eSSam Ravnborgboot := arch/microblaze/boot 605f8ffb5fSMichal Simek 61f05131cdSMichal Simek# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 62f05131cdSMichal SimekDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 63f05131cdSMichal Simek 64300db34aSStephen Warrencore-y += $(boot)/dts/ 65f05131cdSMichal Simek 66*05cdf457SMichal Simekexport DTB 675f8ffb5fSMichal Simek 685f8ffb5fSMichal Simekall: linux.bin 695f8ffb5fSMichal Simek 705f8ffb5fSMichal Simekarchclean: 715f8ffb5fSMichal Simek $(Q)$(MAKE) $(clean)=$(boot) 725f8ffb5fSMichal Simek 731e17ab53SFiroz Khanarchheaders: 741e17ab53SFiroz Khan $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all 751e17ab53SFiroz Khan 763dda563bSMasahiro YamadaPHONY += linux.bin linux.bin.gz linux.bin.ub 7752e79c4fSMasahiro Yamadalinux.bin.ub linux.bin.gz: linux.bin 7852e79c4fSMasahiro Yamadalinux.bin: vmlinux 7952e79c4fSMasahiro Yamadalinux.bin linux.bin.gz linux.bin.ub: 80b843e4ecSThomas Backlund $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 812e14f94cSMasahiro Yamada @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 825f5e3236SJason Wu 833dda563bSMasahiro YamadaPHONY += simpleImage.$(DTB) 843dda563bSMasahiro YamadasimpleImage.$(DTB): vmlinux 854722a3e6SMasahiro Yamada $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip) 862e14f94cSMasahiro Yamada @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 875f8ffb5fSMichal Simek 885f8ffb5fSMichal Simekdefine archhelp 895f8ffb5fSMichal Simek echo '* linux.bin - Create raw binary' 905f8ffb5fSMichal Simek echo ' linux.bin.gz - Create compressed raw binary' 91ec2eba55SJason Wu echo ' linux.bin.ub - Create U-Boot wrapped raw binary' 92bafcc61dSMasahiro Yamada echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in' 93bafcc61dSMasahiro Yamada echo ' simpleImage.<dt> : raw image' 94bafcc61dSMasahiro Yamada echo ' simpleImage.<dt>.ub : raw image with U-Boot header' 95bafcc61dSMasahiro Yamada echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)' 96bafcc61dSMasahiro Yamada echo ' simpleImage.<dt>.strip : stripped ELF' 97f05131cdSMichal Simek echo ' Targets with <dt> embed a device tree blob inside the image' 98f05131cdSMichal Simek echo ' These targets support board with firmware that does not' 99f05131cdSMichal Simek echo ' support passing a device tree directly. Replace <dt> with the' 100f05131cdSMichal Simek echo ' name of a dts file from the arch/microblaze/boot/dts/ directory' 101f05131cdSMichal Simek echo ' (minus the .dts extension).' 1025f8ffb5fSMichal Simekendef 1038a8804f1SArun Bhanu 1048a8804f1SArun BhanuMRPROPER_FILES += $(boot)/simpleImage.* 105