1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 28fad84c1SGeert UytterhoevenKBUILD_DEFCONFIG := mmu_defconfig 38fad84c1SGeert Uytterhoeven 44b2368ffSMichal SimekUTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" 55f8ffb5fSMichal Simek 614a83249SColin Ian King# What CPU version are we building for, and crack it open 75f8ffb5fSMichal Simek# as major.minor.rev 8129ab0d2SMasahiro YamadaCPU_VER := $(CONFIG_XILINX_MICROBLAZE0_HW_VER) 9c0ee9bbaSMasahiro YamadaCPU_MAJOR := $(word 1, $(subst ., , $(CPU_VER))) 10c0ee9bbaSMasahiro YamadaCPU_MINOR := $(word 2, $(subst ., , $(CPU_VER))) 11c0ee9bbaSMasahiro YamadaCPU_REV := $(word 3, $(subst ., , $(CPU_VER))) 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 51950b260eSSam Ravnborglibs-y += arch/microblaze/lib/ 525f8ffb5fSMichal Simek 53950b260eSSam Ravnborgboot := arch/microblaze/boot 545f8ffb5fSMichal Simek 55f05131cdSMichal Simek# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 56f05131cdSMichal SimekDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 57f05131cdSMichal Simek 5805cdf457SMichal Simekexport DTB 595f8ffb5fSMichal Simek 605f8ffb5fSMichal Simekall: linux.bin 615f8ffb5fSMichal Simek 621e17ab53SFiroz Khanarchheaders: 631e17ab53SFiroz Khan $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all 641e17ab53SFiroz Khan 653dda563bSMasahiro YamadaPHONY += linux.bin linux.bin.gz linux.bin.ub 6652e79c4fSMasahiro Yamadalinux.bin.ub linux.bin.gz: linux.bin 6752e79c4fSMasahiro Yamadalinux.bin: vmlinux 6852e79c4fSMasahiro Yamadalinux.bin linux.bin.gz linux.bin.ub: 69b843e4ecSThomas Backlund $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 70*083cad78SMasahiro Yamada @echo 'Kernel: $(boot)/$@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')' 715f5e3236SJason Wu 723dda563bSMasahiro YamadaPHONY += simpleImage.$(DTB) 733dda563bSMasahiro YamadasimpleImage.$(DTB): vmlinux 744722a3e6SMasahiro Yamada $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip) 75*083cad78SMasahiro Yamada @echo 'Kernel: $(boot)/$@ is ready' ' (#'$(or $(KBUILD_BUILD_VERSION),`cat .version`)')' 765f8ffb5fSMichal Simek 775f8ffb5fSMichal Simekdefine archhelp 785f8ffb5fSMichal Simek echo '* linux.bin - Create raw binary' 795f8ffb5fSMichal Simek echo ' linux.bin.gz - Create compressed raw binary' 80ec2eba55SJason Wu echo ' linux.bin.ub - Create U-Boot wrapped raw binary' 81bafcc61dSMasahiro Yamada echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in' 82bafcc61dSMasahiro Yamada echo ' simpleImage.<dt> : raw image' 83bafcc61dSMasahiro Yamada echo ' simpleImage.<dt>.ub : raw image with U-Boot header' 84bafcc61dSMasahiro Yamada echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)' 85bafcc61dSMasahiro Yamada echo ' simpleImage.<dt>.strip : stripped ELF' 86f05131cdSMichal Simek echo ' Targets with <dt> embed a device tree blob inside the image' 87f05131cdSMichal Simek echo ' These targets support board with firmware that does not' 88f05131cdSMichal Simek echo ' support passing a device tree directly. Replace <dt> with the' 89f05131cdSMichal Simek echo ' name of a dts file from the arch/microblaze/boot/dts/ directory' 90f05131cdSMichal Simek echo ' (minus the .dts extension).' 915f8ffb5fSMichal Simekendef 928a8804f1SArun Bhanu 938a8804f1SArun BhanuMRPROPER_FILES += $(boot)/simpleImage.* 94