aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2017-04-19 07:19:02 -0400
committerLey Foon Tan <ley.foon.tan@intel.com>2017-05-08 04:59:19 -0400
commitedebea98777d7090ea14bdce2e38e6798557729d (patch)
tree42d00a6c8e42ed6d2c04bf8d78c21fc2a0247ccf
parent23460839b983d5d8d47fe90f341599f66523dd81 (diff)
nios2: Add CDX support
Add support for the CDX Code Density Extensions present in Nios II R2 . This introduces new 16bit instruction set to improve code density while retaining support for the 32bit Nios II R2 instructions. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Ley Foon Tan <lftan@altera.com>
-rw-r--r--arch/nios2/Makefile1
-rw-r--r--arch/nios2/include/asm/cpuinfo.h1
-rw-r--r--arch/nios2/kernel/cpuinfo.c10
-rw-r--r--arch/nios2/platform/Kconfig.platform9
4 files changed, 19 insertions, 2 deletions
diff --git a/arch/nios2/Makefile b/arch/nios2/Makefile
index 74109c01eaea..8673a79dca9c 100644
--- a/arch/nios2/Makefile
+++ b/arch/nios2/Makefile
@@ -30,6 +30,7 @@ KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MUL_SUPPORT),-mhw-mul,-mno-hw-mul)
30KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx) 30KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_MULX_SUPPORT),-mhw-mulx,-mno-hw-mulx)
31KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div) 31KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_HW_DIV_SUPPORT),-mhw-div,-mno-hw-div)
32KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_BMX_SUPPORT),-mbmx,-mno-bmx) 32KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_BMX_SUPPORT),-mbmx,-mno-bmx)
33KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_CDX_SUPPORT),-mcdx,-mno-cdx)
33KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,) 34KBUILD_CFLAGS += $(if $(CONFIG_NIOS2_FPU_SUPPORT),-mcustom-fpu-cfg=60-1,)
34 35
35KBUILD_CFLAGS += -fno-optimize-sibling-calls 36KBUILD_CFLAGS += -fno-optimize-sibling-calls
diff --git a/arch/nios2/include/asm/cpuinfo.h b/arch/nios2/include/asm/cpuinfo.h
index 79d376435d7d..dbdaf96f28d4 100644
--- a/arch/nios2/include/asm/cpuinfo.h
+++ b/arch/nios2/include/asm/cpuinfo.h
@@ -30,6 +30,7 @@ struct cpuinfo {
30 bool has_mul; 30 bool has_mul;
31 bool has_mulx; 31 bool has_mulx;
32 bool has_bmx; 32 bool has_bmx;
33 bool has_cdx;
33 34
34 /* CPU caches */ 35 /* CPU caches */
35 u32 icache_line_size; 36 u32 icache_line_size;
diff --git a/arch/nios2/kernel/cpuinfo.c b/arch/nios2/kernel/cpuinfo.c
index 4c84fec34882..93207718bb22 100644
--- a/arch/nios2/kernel/cpuinfo.c
+++ b/arch/nios2/kernel/cpuinfo.c
@@ -68,6 +68,7 @@ void __init setup_cpuinfo(void)
68 cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul"); 68 cpuinfo.has_mul = of_property_read_bool(cpu, "altr,has-mul");
69 cpuinfo.has_mulx = of_property_read_bool(cpu, "altr,has-mulx"); 69 cpuinfo.has_mulx = of_property_read_bool(cpu, "altr,has-mulx");
70 cpuinfo.has_bmx = of_property_read_bool(cpu, "altr,has-bmx"); 70 cpuinfo.has_bmx = of_property_read_bool(cpu, "altr,has-bmx");
71 cpuinfo.has_cdx = of_property_read_bool(cpu, "altr,has-cdx");
71 cpuinfo.mmu = of_property_read_bool(cpu, "altr,has-mmu"); 72 cpuinfo.mmu = of_property_read_bool(cpu, "altr,has-mmu");
72 73
73 if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div) 74 if (IS_ENABLED(CONFIG_NIOS2_HW_DIV_SUPPORT) && !cpuinfo.has_div)
@@ -82,6 +83,9 @@ void __init setup_cpuinfo(void)
82 if (IS_ENABLED(CONFIG_NIOS2_BMX_SUPPORT) && !cpuinfo.has_bmx) 83 if (IS_ENABLED(CONFIG_NIOS2_BMX_SUPPORT) && !cpuinfo.has_bmx)
83 err_cpu("BMX"); 84 err_cpu("BMX");
84 85
86 if (IS_ENABLED(CONFIG_NIOS2_CDX_SUPPORT) && !cpuinfo.has_cdx)
87 err_cpu("CDX");
88
85 cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways"); 89 cpuinfo.tlb_num_ways = fcpu(cpu, "altr,tlb-num-ways");
86 if (!cpuinfo.tlb_num_ways) 90 if (!cpuinfo.tlb_num_ways)
87 panic("altr,tlb-num-ways can't be 0. Please check your hardware " 91 panic("altr,tlb-num-ways can't be 0. Please check your hardware "
@@ -148,11 +152,13 @@ static int show_cpuinfo(struct seq_file *m, void *v)
148 " MUL:\t\t%s\n" 152 " MUL:\t\t%s\n"
149 " MULX:\t\t%s\n" 153 " MULX:\t\t%s\n"
150 " DIV:\t\t%s\n" 154 " DIV:\t\t%s\n"
151 " BMX:\t\t%s\n", 155 " BMX:\t\t%s\n"
156 " CDX:\t\t%s\n",
152 cpuinfo.has_mul ? "yes" : "no", 157 cpuinfo.has_mul ? "yes" : "no",
153 cpuinfo.has_mulx ? "yes" : "no", 158 cpuinfo.has_mulx ? "yes" : "no",
154 cpuinfo.has_div ? "yes" : "no", 159 cpuinfo.has_div ? "yes" : "no",
155 cpuinfo.has_bmx ? "yes" : "no"); 160 cpuinfo.has_bmx ? "yes" : "no",
161 cpuinfo.has_cdx ? "yes" : "no");
156 162
157 seq_printf(m, 163 seq_printf(m,
158 "Icache:\t\t%ukB, line length: %u\n", 164 "Icache:\t\t%ukB, line length: %u\n",
diff --git a/arch/nios2/platform/Kconfig.platform b/arch/nios2/platform/Kconfig.platform
index b6a8bfd59491..74c1aaf588b8 100644
--- a/arch/nios2/platform/Kconfig.platform
+++ b/arch/nios2/platform/Kconfig.platform
@@ -90,6 +90,15 @@ config NIOS2_BMX_SUPPORT
90 the BMX Bit Manipulation Extension instructions. Enables 90 the BMX Bit Manipulation Extension instructions. Enables
91 the -mbmx compiler flag. 91 the -mbmx compiler flag.
92 92
93config NIOS2_CDX_SUPPORT
94 bool "Enable CDX instructions"
95 depends on NIOS2_ARCH_REVISION = 2
96 default n
97 help
98 Set to true if you configured the Nios II R2 to include
99 the CDX Bit Manipulation Extension instructions. Enables
100 the -mcdx compiler flag.
101
93config NIOS2_FPU_SUPPORT 102config NIOS2_FPU_SUPPORT
94 bool "Custom floating point instr support" 103 bool "Custom floating point instr support"
95 default n 104 default n