1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0 2*4882a593SmuzhiyunKBUILD_DEFCONFIG := mmu_defconfig 3*4882a593Smuzhiyun 4*4882a593Smuzhiyunifeq ($(CONFIG_MMU),y) 5*4882a593SmuzhiyunUTS_SYSNAME = -DUTS_SYSNAME=\"Linux\" 6*4882a593Smuzhiyunelse 7*4882a593SmuzhiyunUTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\" 8*4882a593Smuzhiyunendif 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun# What CPU vesion are we building for, and crack it open 11*4882a593Smuzhiyun# as major.minor.rev 12*4882a593SmuzhiyunCPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER)) 13*4882a593SmuzhiyunCPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1) 14*4882a593SmuzhiyunCPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2) 15*4882a593SmuzhiyunCPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3) 16*4882a593Smuzhiyun 17*4882a593Smuzhiyunexport CPU_VER CPU_MAJOR CPU_MINOR CPU_REV 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun# Use cpu-related CONFIG_ vars to set compile options. 20*4882a593Smuzhiyun# The various CONFIG_XILINX cpu features options are integers 0/1/2... 21*4882a593Smuzhiyun# rather than bools y/n 22*4882a593Smuzhiyun 23*4882a593Smuzhiyun# Work out HW multipler support. This is tricky. 24*4882a593Smuzhiyun# 1. Spartan2 has no HW multipliers. 25*4882a593Smuzhiyun# 2. MicroBlaze v3.x always uses them, except in Spartan 2 26*4882a593Smuzhiyun# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings 27*4882a593Smuzhiyunifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY))) 28*4882a593Smuzhiyun ifeq ($(CPU_MAJOR),3) 29*4882a593Smuzhiyun CPUFLAGS-1 += -mno-xl-soft-mul 30*4882a593Smuzhiyun else 31*4882a593Smuzhiyun # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support. 32*4882a593Smuzhiyun CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high 33*4882a593Smuzhiyun CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul 34*4882a593Smuzhiyun endif 35*4882a593Smuzhiyunendif 36*4882a593SmuzhiyunCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div 37*4882a593SmuzhiyunCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift 38*4882a593SmuzhiyunCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare 39*4882a593Smuzhiyun 40*4882a593Smuzhiyunifdef CONFIG_CPU_BIG_ENDIAN 41*4882a593SmuzhiyunKBUILD_CFLAGS += -mbig-endian 42*4882a593SmuzhiyunKBUILD_AFLAGS += -mbig-endian 43*4882a593SmuzhiyunKBUILD_LDFLAGS += -EB 44*4882a593Smuzhiyunelse 45*4882a593SmuzhiyunKBUILD_CFLAGS += -mlittle-endian 46*4882a593SmuzhiyunKBUILD_AFLAGS += -mlittle-endian 47*4882a593SmuzhiyunKBUILD_LDFLAGS += -EL 48*4882a593Smuzhiyunendif 49*4882a593Smuzhiyun 50*4882a593SmuzhiyunCPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER)) 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun# r31 holds current when in kernel mode 53*4882a593SmuzhiyunKBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2) 54*4882a593Smuzhiyun 55*4882a593Smuzhiyunhead-y := arch/microblaze/kernel/head.o 56*4882a593Smuzhiyunlibs-y += arch/microblaze/lib/ 57*4882a593Smuzhiyuncore-y += arch/microblaze/kernel/ 58*4882a593Smuzhiyuncore-y += arch/microblaze/mm/ 59*4882a593Smuzhiyuncore-$(CONFIG_PCI) += arch/microblaze/pci/ 60*4882a593Smuzhiyun 61*4882a593Smuzhiyundrivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/ 62*4882a593Smuzhiyun 63*4882a593Smuzhiyunboot := arch/microblaze/boot 64*4882a593Smuzhiyun 65*4882a593Smuzhiyun# Are we making a simpleImage.<boardname> target? If so, crack out the boardname 66*4882a593SmuzhiyunDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS))) 67*4882a593Smuzhiyun 68*4882a593Smuzhiyuncore-y += $(boot)/dts/ 69*4882a593Smuzhiyun 70*4882a593Smuzhiyun# defines filename extension depending memory management type 71*4882a593Smuzhiyunifeq ($(CONFIG_MMU),) 72*4882a593SmuzhiyunMMU := -nommu 73*4882a593Smuzhiyunendif 74*4882a593Smuzhiyun 75*4882a593Smuzhiyunexport MMU DTB 76*4882a593Smuzhiyun 77*4882a593Smuzhiyunall: linux.bin 78*4882a593Smuzhiyun 79*4882a593Smuzhiyunarchclean: 80*4882a593Smuzhiyun $(Q)$(MAKE) $(clean)=$(boot) 81*4882a593Smuzhiyun 82*4882a593Smuzhiyunarchheaders: 83*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all 84*4882a593Smuzhiyun 85*4882a593SmuzhiyunPHONY += linux.bin linux.bin.gz linux.bin.ub 86*4882a593Smuzhiyunlinux.bin.ub linux.bin.gz: linux.bin 87*4882a593Smuzhiyunlinux.bin: vmlinux 88*4882a593Smuzhiyunlinux.bin linux.bin.gz linux.bin.ub: 89*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 90*4882a593Smuzhiyun @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 91*4882a593Smuzhiyun 92*4882a593SmuzhiyunPHONY += simpleImage.$(DTB) 93*4882a593SmuzhiyunsimpleImage.$(DTB): vmlinux 94*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip) 95*4882a593Smuzhiyun @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')' 96*4882a593Smuzhiyun 97*4882a593Smuzhiyundefine archhelp 98*4882a593Smuzhiyun echo '* linux.bin - Create raw binary' 99*4882a593Smuzhiyun echo ' linux.bin.gz - Create compressed raw binary' 100*4882a593Smuzhiyun echo ' linux.bin.ub - Create U-Boot wrapped raw binary' 101*4882a593Smuzhiyun echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in' 102*4882a593Smuzhiyun echo ' simpleImage.<dt> : raw image' 103*4882a593Smuzhiyun echo ' simpleImage.<dt>.ub : raw image with U-Boot header' 104*4882a593Smuzhiyun echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)' 105*4882a593Smuzhiyun echo ' simpleImage.<dt>.strip : stripped ELF' 106*4882a593Smuzhiyun echo ' Targets with <dt> embed a device tree blob inside the image' 107*4882a593Smuzhiyun echo ' These targets support board with firmware that does not' 108*4882a593Smuzhiyun echo ' support passing a device tree directly. Replace <dt> with the' 109*4882a593Smuzhiyun echo ' name of a dts file from the arch/microblaze/boot/dts/ directory' 110*4882a593Smuzhiyun echo ' (minus the .dts extension).' 111*4882a593Smuzhiyunendef 112*4882a593Smuzhiyun 113*4882a593SmuzhiyunMRPROPER_FILES += $(boot)/simpleImage.* 114