1*b2441318SGreg 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 39206d3642SBabu MogerCPUFLAGS-$(CONFIG_BIG_ENDIAN) += -mbig-endian 40206d3642SBabu MogerCPUFLAGS-$(CONFIG_LITTLE_ENDIAN) += -mlittle-endian 415f8ffb5fSMichal Simek 425f8ffb5fSMichal SimekCPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 435f8ffb5fSMichal Simek 445f8ffb5fSMichal Simek# r31 holds current when in kernel mode 45e469b0ebSJohn WilliamsKBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-1) $(CPUFLAGS-2) 465f8ffb5fSMichal Simek 47c3055d14SThomas ChouLDFLAGS := 48c3055d14SThomas ChouLDFLAGS_vmlinux := 495f8ffb5fSMichal Simek 505f8ffb5fSMichal Simekhead-y := arch/microblaze/kernel/head.o 51950b260eSSam Ravnborglibs-y += arch/microblaze/lib/ 52950b260eSSam Ravnborgcore-y += arch/microblaze/kernel/ 53950b260eSSam Ravnborgcore-y += arch/microblaze/mm/ 54a6475c13SMichal Simekcore-$(CONFIG_PCI) += arch/microblaze/pci/ 555f8ffb5fSMichal Simek 563540ce82SJohn Williamsdrivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ 573540ce82SJohn Williams 58950b260eSSam Ravnborgboot := arch/microblaze/boot 595f8ffb5fSMichal Simek 60f05131cdSMichal Simek# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 61f05131cdSMichal SimekDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 62f05131cdSMichal Simek 63f05131cdSMichal Simekifneq ($(DTB),) 64300db34aSStephen Warren core-y += $(boot)/dts/ 65f05131cdSMichal Simekendif 66f05131cdSMichal Simek 675f8ffb5fSMichal Simek# defines filename extension depending memory management type 685f8ffb5fSMichal Simekifeq ($(CONFIG_MMU),) 69950b260eSSam RavnborgMMU := -nommu 705f8ffb5fSMichal Simekendif 71950b260eSSam Ravnborg 72f05131cdSMichal Simekexport MMU DTB 735f8ffb5fSMichal Simek 745f8ffb5fSMichal Simekall: linux.bin 755f8ffb5fSMichal Simek 765f8ffb5fSMichal Simekarchclean: 775f8ffb5fSMichal Simek $(Q)$(MAKE) $(clean)=$(boot) 785f8ffb5fSMichal Simek 79ec2eba55SJason Wulinux.bin linux.bin.gz linux.bin.ub: vmlinux 80b843e4ecSThomas Backlund $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 815f5e3236SJason Wu 825f5e3236SJason WusimpleImage.%: vmlinux 835f8ffb5fSMichal Simek $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 845f8ffb5fSMichal Simek 855f8ffb5fSMichal Simekdefine archhelp 865f8ffb5fSMichal Simek echo '* linux.bin - Create raw binary' 875f8ffb5fSMichal Simek echo ' linux.bin.gz - Create compressed raw binary' 88ec2eba55SJason Wu echo ' linux.bin.ub - Create U-Boot wrapped raw binary' 89f05131cdSMichal Simek echo ' simpleImage.<dt> - ELF image with $(arch)/boot/dts/<dt>.dts linked in' 90699d17bcSArun Bhanu echo ' - stripped elf with fdt blob' 91f05131cdSMichal Simek echo ' simpleImage.<dt>.unstrip - full ELF image with fdt blob' 92f05131cdSMichal Simek echo ' *_defconfig - Select default config from arch/microblaze/configs' 93f05131cdSMichal Simek echo '' 94f05131cdSMichal Simek echo ' Targets with <dt> embed a device tree blob inside the image' 95f05131cdSMichal Simek echo ' These targets support board with firmware that does not' 96f05131cdSMichal Simek echo ' support passing a device tree directly. Replace <dt> with the' 97f05131cdSMichal Simek echo ' name of a dts file from the arch/microblaze/boot/dts/ directory' 98f05131cdSMichal Simek echo ' (minus the .dts extension).' 995f8ffb5fSMichal Simekendef 1008a8804f1SArun Bhanu 1018a8804f1SArun BhanuMRPROPER_FILES += $(boot)/simpleImage.* 102