1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0 28fad84c1SGeert UytterhoevenKBUILD_DEFCONFIG := mmu_defconfig 38fad84c1SGeert Uytterhoeven 44b2368ffSMichal Simekifeq ($(CONFIG_MMU),y) 54b2368ffSMichal SimekUTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" 64b2368ffSMichal Simekelse 75f8ffb5fSMichal SimekUTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\" 84b2368ffSMichal Simekendif 95f8ffb5fSMichal Simek 105f8ffb5fSMichal Simek# What CPU vesion are we building for, and crack it open 115f8ffb5fSMichal Simek# as major.minor.rev 12950b260eSSam RavnborgCPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER)) 13950b260eSSam RavnborgCPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1) 14950b260eSSam RavnborgCPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2) 15950b260eSSam RavnborgCPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3) 165f8ffb5fSMichal Simek 175f8ffb5fSMichal Simekexport CPU_VER CPU_MAJOR CPU_MINOR CPU_REV 185f8ffb5fSMichal Simek 195f8ffb5fSMichal Simek# Use cpu-related CONFIG_ vars to set compile options. 20950b260eSSam Ravnborg# The various CONFIG_XILINX cpu features options are integers 0/1/2... 21950b260eSSam Ravnborg# rather than bools y/n 225f8ffb5fSMichal Simek 237f01af04SMichal Simek# Work out HW multipler support. This is tricky. 2425985edcSLucas De Marchi# 1. Spartan2 has no HW multipliers. 255f8ffb5fSMichal Simek# 2. MicroBlaze v3.x always uses them, except in Spartan 2 265f8ffb5fSMichal Simek# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings 275f8ffb5fSMichal Simekifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY))) 285f8ffb5fSMichal Simek ifeq ($(CPU_MAJOR),3) 295f8ffb5fSMichal Simek CPUFLAGS-1 += -mno-xl-soft-mul 305f8ffb5fSMichal Simek else 31732bee7aSUwe Kleine-König # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support. 325f8ffb5fSMichal Simek CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high 335f8ffb5fSMichal Simek CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul 345f8ffb5fSMichal Simek endif 355f8ffb5fSMichal Simekendif 365f8ffb5fSMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div 375f8ffb5fSMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift 3804e3a553SMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare 39*71e7673dSArnd Bergmann 40*71e7673dSArnd Bergmannifdef CONFIG_CPU_BIG_ENDIAN 41*71e7673dSArnd BergmannKBUILD_CFLAGS += -mbig-endian 42*71e7673dSArnd BergmannKBUILD_AFLAGS += -mbig-endian 43*71e7673dSArnd BergmannLD += -EB 44*71e7673dSArnd Bergmannelse 45*71e7673dSArnd BergmannKBUILD_CFLAGS += -mlittle-endian 46*71e7673dSArnd BergmannKBUILD_AFLAGS += -mlittle-endian 47*71e7673dSArnd BergmannLD += -EL 48*71e7673dSArnd Bergmannendif 495f8ffb5fSMichal Simek 505f8ffb5fSMichal SimekCPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 515f8ffb5fSMichal Simek 525f8ffb5fSMichal Simek# r31 holds current when in kernel mode 53*71e7673dSArnd BergmannKBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2) 545f8ffb5fSMichal Simek 555f8ffb5fSMichal Simekhead-y := arch/microblaze/kernel/head.o 56950b260eSSam Ravnborglibs-y += arch/microblaze/lib/ 57950b260eSSam Ravnborgcore-y += arch/microblaze/kernel/ 58950b260eSSam Ravnborgcore-y += arch/microblaze/mm/ 59a6475c13SMichal Simekcore-$(CONFIG_PCI) += arch/microblaze/pci/ 605f8ffb5fSMichal Simek 613540ce82SJohn Williamsdrivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ 623540ce82SJohn Williams 63950b260eSSam Ravnborgboot := arch/microblaze/boot 645f8ffb5fSMichal Simek 65f05131cdSMichal Simek# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 66f05131cdSMichal SimekDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 67f05131cdSMichal Simek 68f05131cdSMichal Simekifneq ($(DTB),) 69300db34aSStephen Warren core-y += $(boot)/dts/ 70f05131cdSMichal Simekendif 71f05131cdSMichal Simek 725f8ffb5fSMichal Simek# defines filename extension depending memory management type 735f8ffb5fSMichal Simekifeq ($(CONFIG_MMU),) 74950b260eSSam RavnborgMMU := -nommu 755f8ffb5fSMichal Simekendif 76950b260eSSam Ravnborg 77f05131cdSMichal Simekexport MMU DTB 785f8ffb5fSMichal Simek 795f8ffb5fSMichal Simekall: linux.bin 805f8ffb5fSMichal Simek 815f8ffb5fSMichal Simekarchclean: 825f8ffb5fSMichal Simek $(Q)$(MAKE) $(clean)=$(boot) 835f8ffb5fSMichal Simek 84ec2eba55SJason Wulinux.bin linux.bin.gz linux.bin.ub: vmlinux 85b843e4ecSThomas Backlund $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 865f5e3236SJason Wu 875f5e3236SJason WusimpleImage.%: vmlinux 885f8ffb5fSMichal Simek $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 895f8ffb5fSMichal Simek 905f8ffb5fSMichal Simekdefine archhelp 915f8ffb5fSMichal Simek echo '* linux.bin - Create raw binary' 925f8ffb5fSMichal Simek echo ' linux.bin.gz - Create compressed raw binary' 93ec2eba55SJason Wu echo ' linux.bin.ub - Create U-Boot wrapped raw binary' 94f05131cdSMichal Simek echo ' simpleImage.<dt> - ELF image with $(arch)/boot/dts/<dt>.dts linked in' 95699d17bcSArun Bhanu echo ' - stripped elf with fdt blob' 96f05131cdSMichal Simek echo ' simpleImage.<dt>.unstrip - full ELF image with fdt blob' 97f05131cdSMichal Simek echo ' *_defconfig - Select default config from arch/microblaze/configs' 98f05131cdSMichal Simek echo '' 99f05131cdSMichal Simek echo ' Targets with <dt> embed a device tree blob inside the image' 100f05131cdSMichal Simek echo ' These targets support board with firmware that does not' 101f05131cdSMichal Simek echo ' support passing a device tree directly. Replace <dt> with the' 102f05131cdSMichal Simek echo ' name of a dts file from the arch/microblaze/boot/dts/ directory' 103f05131cdSMichal Simek echo ' (minus the .dts extension).' 1045f8ffb5fSMichal Simekendef 1058a8804f1SArun Bhanu 1068a8804f1SArun BhanuMRPROPER_FILES += $(boot)/simpleImage.* 107