18c2ecf20Sopenharmony_ci#
28c2ecf20Sopenharmony_ci# Loongson Processors' Support
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_LOONGSON64)	+= -Wa,--trap
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#
98c2ecf20Sopenharmony_ci# binutils from v2.25 on and gcc starting from v4.9.0 treat -march=loongson3a
108c2ecf20Sopenharmony_ci# as MIPS64 R2; older versions as just R1.  This leaves the possibility open
118c2ecf20Sopenharmony_ci# that GCC might generate R2 code for -march=loongson3a which then is rejected
128c2ecf20Sopenharmony_ci# by GAS.  The cc-option can't probe for this behaviour so -march=loongson3a
138c2ecf20Sopenharmony_ci# can't easily be used safely within the kbuild framework.
148c2ecf20Sopenharmony_ci#
158c2ecf20Sopenharmony_ciifeq ($(call cc-ifversion, -ge, 0409, y), y)
168c2ecf20Sopenharmony_ci  ifeq ($(call ld-ifversion, -ge, 225000000, y), y)
178c2ecf20Sopenharmony_ci    cflags-$(CONFIG_CPU_LOONGSON64)  += \
188c2ecf20Sopenharmony_ci      $(call cc-option,-march=loongson3a -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64)
198c2ecf20Sopenharmony_ci  else
208c2ecf20Sopenharmony_ci    cflags-$(CONFIG_CPU_LOONGSON64)  += \
218c2ecf20Sopenharmony_ci      $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64)
228c2ecf20Sopenharmony_ci  endif
238c2ecf20Sopenharmony_cielse
248c2ecf20Sopenharmony_ci    cflags-$(CONFIG_CPU_LOONGSON64)  += \
258c2ecf20Sopenharmony_ci      $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64)
268c2ecf20Sopenharmony_ciendif
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci# Some -march= flags enable MMI instructions, and GCC complains about that
298c2ecf20Sopenharmony_ci# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
308c2ecf20Sopenharmony_cicflags-y += $(call cc-option,-mno-loongson-mmi)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#
338c2ecf20Sopenharmony_ci# Loongson Machines' Support
348c2ecf20Sopenharmony_ci#
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cicflags-$(CONFIG_MACH_LOONGSON64) += -I$(srctree)/arch/mips/include/asm/mach-loongson64 -mno-branch-likely
378c2ecf20Sopenharmony_ciload-$(CONFIG_CPU_LOONGSON64) += 0xffffffff80200000
38