xref: /OK3568_Linux_fs/kernel/arch/mips/loongson2ef/Platform (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun#
2*4882a593Smuzhiyun# Loongson Processors' Support
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun
5*4882a593Smuzhiyun# Only gcc >= 4.4 have Loongson specific support
6*4882a593Smuzhiyuncflags-$(CONFIG_CPU_LOONGSON2EF)	+= -Wa,--trap
7*4882a593Smuzhiyuncflags-$(CONFIG_CPU_LOONGSON2E) += \
8*4882a593Smuzhiyun	$(call cc-option,-march=loongson2e,-march=r4600)
9*4882a593Smuzhiyuncflags-$(CONFIG_CPU_LOONGSON2F) += \
10*4882a593Smuzhiyun	$(call cc-option,-march=loongson2f,-march=r4600)
11*4882a593Smuzhiyun#
12*4882a593Smuzhiyun# Some versions of binutils, not currently mainline as of 2019/02/04, support
13*4882a593Smuzhiyun# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction
14*4882a593Smuzhiyun# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a
15*4882a593Smuzhiyun# description).
16*4882a593Smuzhiyun#
17*4882a593Smuzhiyun# We disable this in order to prevent the assembler meddling with the
18*4882a593Smuzhiyun# instruction that labels refer to, ie. if we label an ll instruction:
19*4882a593Smuzhiyun#
20*4882a593Smuzhiyun# 1: ll v0, 0(a0)
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# ...then with the assembler fix applied the label may actually point at a sync
23*4882a593Smuzhiyun# instruction inserted by the assembler, and if we were using the label in an
24*4882a593Smuzhiyun# exception table the table would no longer contain the address of the ll
25*4882a593Smuzhiyun# instruction.
26*4882a593Smuzhiyun#
27*4882a593Smuzhiyun# Avoid this by explicitly disabling that assembler behaviour. If upstream
28*4882a593Smuzhiyun# binutils does not merge support for the flag then we can revisit & remove
29*4882a593Smuzhiyun# this later - for now it ensures vendor toolchains don't cause problems.
30*4882a593Smuzhiyun#
31*4882a593Smuzhiyuncflags-$(CONFIG_CPU_LOONGSON2EF)	+= $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,)
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun# Enable the workarounds for Loongson2f
34*4882a593Smuzhiyunifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS
35*4882a593Smuzhiyun  ifeq ($(call as-option,-Wa$(comma)-mfix-loongson2f-nop,),)
36*4882a593Smuzhiyun    $(error only binutils >= 2.20.2 have needed option -mfix-loongson2f-nop)
37*4882a593Smuzhiyun  else
38*4882a593Smuzhiyun    cflags-$(CONFIG_CPU_NOP_WORKAROUNDS) += -Wa$(comma)-mfix-loongson2f-nop
39*4882a593Smuzhiyun  endif
40*4882a593Smuzhiyun  ifeq ($(call as-option,-Wa$(comma)-mfix-loongson2f-jump,),)
41*4882a593Smuzhiyun    $(error only binutils >= 2.20.2 have needed option -mfix-loongson2f-jump)
42*4882a593Smuzhiyun  else
43*4882a593Smuzhiyun    cflags-$(CONFIG_CPU_JUMP_WORKAROUNDS) += -Wa$(comma)-mfix-loongson2f-jump
44*4882a593Smuzhiyun  endif
45*4882a593Smuzhiyunendif
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun# Some -march= flags enable MMI instructions, and GCC complains about that
48*4882a593Smuzhiyun# support being enabled alongside -msoft-float. Thus explicitly disable MMI.
49*4882a593Smuzhiyuncflags-y += $(call cc-option,-mno-loongson-mmi)
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun#
52*4882a593Smuzhiyun# Loongson Machines' Support
53*4882a593Smuzhiyun#
54*4882a593Smuzhiyun
55*4882a593Smuzhiyuncflags-$(CONFIG_MACH_LOONGSON2EF) += -I$(srctree)/arch/mips/include/asm/mach-loongson2ef -mno-branch-likely
56*4882a593Smuzhiyunload-$(CONFIG_LEMOTE_FULOONG2E) += 0xffffffff80100000
57*4882a593Smuzhiyunload-$(CONFIG_LEMOTE_MACH2F) += 0xffffffff80200000
58