leon: add SDK patches from buildroot-2022.02-1.2/5.10.175
[openwrt/staging/wigyori.git] / target / linux / leon / patches-5.15 / 0028-sparc32-leon-Make-what-mcpu-to-be-used-configurable-.patch
1 From b04fd686298fdb90d617a9bb07d3c8dd3d0962f8 Mon Sep 17 00:00:00 2001
2 From: Andreas Larsson <andreas@gaisler.com>
3 Date: Thu, 5 Jan 2023 16:57:29 +0100
4 Subject: [PATCH 28/32] sparc32,leon: Make what -mcpu to be used configurable,
5 defaulting to none
6
7 Signed-off-by: Andreas Larsson <andreas@gaisler.com>
8 ---
9 arch/sparc/Kconfig | 32 ++++++++++++++++++++++++++++++++
10 arch/sparc/Makefile | 13 +++++++++----
11 2 files changed, 41 insertions(+), 4 deletions(-)
12
13 diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
14 index a9d618c6f6c1..8188cae9786f 100644
15 --- a/arch/sparc/Kconfig
16 +++ b/arch/sparc/Kconfig
17 @@ -395,6 +395,38 @@ config SPARC_LEON
18 toolchain at www.gaisler.com.
19
20 if SPARC_LEON
21 +
22 +choice
23 + prompt "LEON CPU architecture"
24 + default SPARC_LEON_MCPU_DEFAULT
25 + help
26 + This chooses if and what architecture shall be used if any
27 + to build the kernel.
28 +
29 +config SPARC_LEON_MCPU_DEFAULT
30 + bool "default"
31 + help
32 + Build the kernel with no -mcpu option, getting the default
33 + for the toolchain that is being used.
34 +
35 +config SPARC_LEON_MCPU_LEON3
36 + bool "leon3"
37 + help
38 + Build the kernel with -mcpu=leon3.
39 +
40 +config SPARC_LEON_MCPU_LEON5
41 + bool "leon5"
42 + help
43 + Build the kernel with -mcpu=leon5.
44 +
45 +endchoice
46 +
47 +config SPARC_LEON_MCPU
48 + string
49 + default "" if SPARC_LEON_MCPU_DEFAULT
50 + default "leon3" if SPARC_LEON_MCPU_LEON3
51 + default "leon5" if SPARC_LEON_MCPU_LEON5
52 +
53 config SPARC_LEON_FIX_UT700
54 bool "UT700 errata fixes"
55 select SPARC_LEON_FIX_TN0018
56 diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
57 index aa9d12c54e4b..63894edc86c6 100644
58 --- a/arch/sparc/Makefile
59 +++ b/arch/sparc/Makefile
60 @@ -26,19 +26,24 @@ export BITS := 32
61 UTS_MACHINE := sparc
62
63 ifeq ($(CONFIG_SPARC_LEON),y)
64 -SPARC_MCPU=leon3
65 +leon_mcpu := $(strip $(shell echo $(CONFIG_SPARC_LEON_MCPU)))
66 +ifeq ($(leon_mcpu),)
67 +SPARC_MCPU=
68 else
69 -SPARC_MCPU=v8
70 +SPARC_MCPU=-mcpu=$(leon_mcpu)
71 +endif
72 +else
73 +SPARC_MCPU=-mcpu=v8
74 endif
75
76 # We are adding -Wa,-Av8 to KBUILD_CFLAGS to deal with a specs bug in some
77 # versions of gcc. Some gcc versions won't pass -Av8 to binutils when you
78 # give -mcpu=v8. This silently worked with older bintutils versions but
79 # does not any more.
80 -KBUILD_CFLAGS += -m32 -mcpu=$(SPARC_MCPU) -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
81 +KBUILD_CFLAGS += -m32 $(SPARC_MCPU) -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
82 KBUILD_CFLAGS += -Wa,-Av8
83
84 -KBUILD_AFLAGS += -m32 -mcpu=$(SPARC_MCPU) -Wa,-Av8
85 +KBUILD_AFLAGS += -m32 $(SPARC_MCPU) -Wa,-Av8
86
87 ifeq ($(CONFIG_SPARC_LEON_FIX_UT700),y)
88 KBUILD_CFLAGS += -mfix-ut700 -fno-jump-tables
89 --
90 2.34.1
91