xref: /openbmc/linux/arch/mips/kernel/fpu-probe.c (revision cbecf716ca618fd44feda6bd9a64a8179d031fc5)
1*a616c061SThomas Bogendoerfer // SPDX-License-Identifier: GPL-2.0-or-later
2*a616c061SThomas Bogendoerfer /*
3*a616c061SThomas Bogendoerfer  * Processor capabilities determination functions.
4*a616c061SThomas Bogendoerfer  *
5*a616c061SThomas Bogendoerfer  * Copyright (C) xxxx  the Anonymous
6*a616c061SThomas Bogendoerfer  * Copyright (C) 1994 - 2006 Ralf Baechle
7*a616c061SThomas Bogendoerfer  * Copyright (C) 2003, 2004  Maciej W. Rozycki
8*a616c061SThomas Bogendoerfer  * Copyright (C) 2001, 2004, 2011, 2012	 MIPS Technologies, Inc.
9*a616c061SThomas Bogendoerfer  */
10*a616c061SThomas Bogendoerfer 
11*a616c061SThomas Bogendoerfer #include <linux/init.h>
12*a616c061SThomas Bogendoerfer #include <linux/kernel.h>
13*a616c061SThomas Bogendoerfer 
14*a616c061SThomas Bogendoerfer #include <asm/bugs.h>
15*a616c061SThomas Bogendoerfer #include <asm/cpu.h>
16*a616c061SThomas Bogendoerfer #include <asm/cpu-features.h>
17*a616c061SThomas Bogendoerfer #include <asm/cpu-type.h>
18*a616c061SThomas Bogendoerfer #include <asm/elf.h>
19*a616c061SThomas Bogendoerfer #include <asm/fpu.h>
20*a616c061SThomas Bogendoerfer #include <asm/mipsregs.h>
21*a616c061SThomas Bogendoerfer 
22*a616c061SThomas Bogendoerfer #include "fpu-probe.h"
23*a616c061SThomas Bogendoerfer 
24*a616c061SThomas Bogendoerfer /*
25*a616c061SThomas Bogendoerfer  * Get the FPU Implementation/Revision.
26*a616c061SThomas Bogendoerfer  */
cpu_get_fpu_id(void)27*a616c061SThomas Bogendoerfer static inline unsigned long cpu_get_fpu_id(void)
28*a616c061SThomas Bogendoerfer {
29*a616c061SThomas Bogendoerfer 	unsigned long tmp, fpu_id;
30*a616c061SThomas Bogendoerfer 
31*a616c061SThomas Bogendoerfer 	tmp = read_c0_status();
32*a616c061SThomas Bogendoerfer 	__enable_fpu(FPU_AS_IS);
33*a616c061SThomas Bogendoerfer 	fpu_id = read_32bit_cp1_register(CP1_REVISION);
34*a616c061SThomas Bogendoerfer 	write_c0_status(tmp);
35*a616c061SThomas Bogendoerfer 	return fpu_id;
36*a616c061SThomas Bogendoerfer }
37*a616c061SThomas Bogendoerfer 
38*a616c061SThomas Bogendoerfer /*
39*a616c061SThomas Bogendoerfer  * Check if the CPU has an external FPU.
40*a616c061SThomas Bogendoerfer  */
__cpu_has_fpu(void)41*a616c061SThomas Bogendoerfer int __cpu_has_fpu(void)
42*a616c061SThomas Bogendoerfer {
43*a616c061SThomas Bogendoerfer 	return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
44*a616c061SThomas Bogendoerfer }
45*a616c061SThomas Bogendoerfer 
46*a616c061SThomas Bogendoerfer /*
47*a616c061SThomas Bogendoerfer  * Determine the FCSR mask for FPU hardware.
48*a616c061SThomas Bogendoerfer  */
cpu_set_fpu_fcsr_mask(struct cpuinfo_mips * c)49*a616c061SThomas Bogendoerfer static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c)
50*a616c061SThomas Bogendoerfer {
51*a616c061SThomas Bogendoerfer 	unsigned long sr, mask, fcsr, fcsr0, fcsr1;
52*a616c061SThomas Bogendoerfer 
53*a616c061SThomas Bogendoerfer 	fcsr = c->fpu_csr31;
54*a616c061SThomas Bogendoerfer 	mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM;
55*a616c061SThomas Bogendoerfer 
56*a616c061SThomas Bogendoerfer 	sr = read_c0_status();
57*a616c061SThomas Bogendoerfer 	__enable_fpu(FPU_AS_IS);
58*a616c061SThomas Bogendoerfer 
59*a616c061SThomas Bogendoerfer 	fcsr0 = fcsr & mask;
60*a616c061SThomas Bogendoerfer 	write_32bit_cp1_register(CP1_STATUS, fcsr0);
61*a616c061SThomas Bogendoerfer 	fcsr0 = read_32bit_cp1_register(CP1_STATUS);
62*a616c061SThomas Bogendoerfer 
63*a616c061SThomas Bogendoerfer 	fcsr1 = fcsr | ~mask;
64*a616c061SThomas Bogendoerfer 	write_32bit_cp1_register(CP1_STATUS, fcsr1);
65*a616c061SThomas Bogendoerfer 	fcsr1 = read_32bit_cp1_register(CP1_STATUS);
66*a616c061SThomas Bogendoerfer 
67*a616c061SThomas Bogendoerfer 	write_32bit_cp1_register(CP1_STATUS, fcsr);
68*a616c061SThomas Bogendoerfer 
69*a616c061SThomas Bogendoerfer 	write_c0_status(sr);
70*a616c061SThomas Bogendoerfer 
71*a616c061SThomas Bogendoerfer 	c->fpu_msk31 = ~(fcsr0 ^ fcsr1) & ~mask;
72*a616c061SThomas Bogendoerfer }
73*a616c061SThomas Bogendoerfer 
74*a616c061SThomas Bogendoerfer /*
75*a616c061SThomas Bogendoerfer  * Determine the IEEE 754 NaN encodings and ABS.fmt/NEG.fmt execution modes
76*a616c061SThomas Bogendoerfer  * supported by FPU hardware.
77*a616c061SThomas Bogendoerfer  */
cpu_set_fpu_2008(struct cpuinfo_mips * c)78*a616c061SThomas Bogendoerfer static void cpu_set_fpu_2008(struct cpuinfo_mips *c)
79*a616c061SThomas Bogendoerfer {
80*a616c061SThomas Bogendoerfer 	if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
81*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
82*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R5 | MIPS_CPU_ISA_M64R5 |
83*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
84*a616c061SThomas Bogendoerfer 		unsigned long sr, fir, fcsr, fcsr0, fcsr1;
85*a616c061SThomas Bogendoerfer 
86*a616c061SThomas Bogendoerfer 		sr = read_c0_status();
87*a616c061SThomas Bogendoerfer 		__enable_fpu(FPU_AS_IS);
88*a616c061SThomas Bogendoerfer 
89*a616c061SThomas Bogendoerfer 		fir = read_32bit_cp1_register(CP1_REVISION);
90*a616c061SThomas Bogendoerfer 		if (fir & MIPS_FPIR_HAS2008) {
91*a616c061SThomas Bogendoerfer 			fcsr = read_32bit_cp1_register(CP1_STATUS);
92*a616c061SThomas Bogendoerfer 
93*a616c061SThomas Bogendoerfer 			/*
94*a616c061SThomas Bogendoerfer 			 * MAC2008 toolchain never landed in real world, so
95*a616c061SThomas Bogendoerfer 			 * we're only testing whether it can be disabled and
96*a616c061SThomas Bogendoerfer 			 *  don't try to enabled it.
97*a616c061SThomas Bogendoerfer 			 */
98*a616c061SThomas Bogendoerfer 			fcsr0 = fcsr & ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008 |
99*a616c061SThomas Bogendoerfer 					 FPU_CSR_MAC2008);
100*a616c061SThomas Bogendoerfer 			write_32bit_cp1_register(CP1_STATUS, fcsr0);
101*a616c061SThomas Bogendoerfer 			fcsr0 = read_32bit_cp1_register(CP1_STATUS);
102*a616c061SThomas Bogendoerfer 
103*a616c061SThomas Bogendoerfer 			fcsr1 = fcsr | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
104*a616c061SThomas Bogendoerfer 			write_32bit_cp1_register(CP1_STATUS, fcsr1);
105*a616c061SThomas Bogendoerfer 			fcsr1 = read_32bit_cp1_register(CP1_STATUS);
106*a616c061SThomas Bogendoerfer 
107*a616c061SThomas Bogendoerfer 			write_32bit_cp1_register(CP1_STATUS, fcsr);
108*a616c061SThomas Bogendoerfer 
109*a616c061SThomas Bogendoerfer 			if (c->isa_level & (MIPS_CPU_ISA_M32R2 |
110*a616c061SThomas Bogendoerfer 					    MIPS_CPU_ISA_M64R2)) {
111*a616c061SThomas Bogendoerfer 				/*
112*a616c061SThomas Bogendoerfer 				 * The bit for MAC2008 might be reused by R6
113*a616c061SThomas Bogendoerfer 				 * in future, so we only test for R2-R5.
114*a616c061SThomas Bogendoerfer 				 */
115*a616c061SThomas Bogendoerfer 				if (fcsr0 & FPU_CSR_MAC2008)
116*a616c061SThomas Bogendoerfer 					c->options |= MIPS_CPU_MAC_2008_ONLY;
117*a616c061SThomas Bogendoerfer 			}
118*a616c061SThomas Bogendoerfer 
119*a616c061SThomas Bogendoerfer 			if (!(fcsr0 & FPU_CSR_NAN2008))
120*a616c061SThomas Bogendoerfer 				c->options |= MIPS_CPU_NAN_LEGACY;
121*a616c061SThomas Bogendoerfer 			if (fcsr1 & FPU_CSR_NAN2008)
122*a616c061SThomas Bogendoerfer 				c->options |= MIPS_CPU_NAN_2008;
123*a616c061SThomas Bogendoerfer 
124*a616c061SThomas Bogendoerfer 			if ((fcsr0 ^ fcsr1) & FPU_CSR_ABS2008)
125*a616c061SThomas Bogendoerfer 				c->fpu_msk31 &= ~FPU_CSR_ABS2008;
126*a616c061SThomas Bogendoerfer 			else
127*a616c061SThomas Bogendoerfer 				c->fpu_csr31 |= fcsr & FPU_CSR_ABS2008;
128*a616c061SThomas Bogendoerfer 
129*a616c061SThomas Bogendoerfer 			if ((fcsr0 ^ fcsr1) & FPU_CSR_NAN2008)
130*a616c061SThomas Bogendoerfer 				c->fpu_msk31 &= ~FPU_CSR_NAN2008;
131*a616c061SThomas Bogendoerfer 			else
132*a616c061SThomas Bogendoerfer 				c->fpu_csr31 |= fcsr & FPU_CSR_NAN2008;
133*a616c061SThomas Bogendoerfer 		} else {
134*a616c061SThomas Bogendoerfer 			c->options |= MIPS_CPU_NAN_LEGACY;
135*a616c061SThomas Bogendoerfer 		}
136*a616c061SThomas Bogendoerfer 
137*a616c061SThomas Bogendoerfer 		write_c0_status(sr);
138*a616c061SThomas Bogendoerfer 	} else {
139*a616c061SThomas Bogendoerfer 		c->options |= MIPS_CPU_NAN_LEGACY;
140*a616c061SThomas Bogendoerfer 	}
141*a616c061SThomas Bogendoerfer }
142*a616c061SThomas Bogendoerfer 
143*a616c061SThomas Bogendoerfer /*
144*a616c061SThomas Bogendoerfer  * IEEE 754 conformance mode to use.  Affects the NaN encoding and the
145*a616c061SThomas Bogendoerfer  * ABS.fmt/NEG.fmt execution mode.
146*a616c061SThomas Bogendoerfer  */
147*a616c061SThomas Bogendoerfer static enum { STRICT, LEGACY, STD2008, RELAXED } ieee754 = STRICT;
148*a616c061SThomas Bogendoerfer 
149*a616c061SThomas Bogendoerfer /*
150*a616c061SThomas Bogendoerfer  * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
151*a616c061SThomas Bogendoerfer  * to support by the FPU emulator according to the IEEE 754 conformance
152*a616c061SThomas Bogendoerfer  * mode selected.  Note that "relaxed" straps the emulator so that it
153*a616c061SThomas Bogendoerfer  * allows 2008-NaN binaries even for legacy processors.
154*a616c061SThomas Bogendoerfer  */
cpu_set_nofpu_2008(struct cpuinfo_mips * c)155*a616c061SThomas Bogendoerfer static void cpu_set_nofpu_2008(struct cpuinfo_mips *c)
156*a616c061SThomas Bogendoerfer {
157*a616c061SThomas Bogendoerfer 	c->options &= ~(MIPS_CPU_NAN_2008 | MIPS_CPU_NAN_LEGACY);
158*a616c061SThomas Bogendoerfer 	c->fpu_csr31 &= ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008);
159*a616c061SThomas Bogendoerfer 	c->fpu_msk31 &= ~(FPU_CSR_ABS2008 | FPU_CSR_NAN2008);
160*a616c061SThomas Bogendoerfer 
161*a616c061SThomas Bogendoerfer 	switch (ieee754) {
162*a616c061SThomas Bogendoerfer 	case STRICT:
163*a616c061SThomas Bogendoerfer 		if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
164*a616c061SThomas Bogendoerfer 				    MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
165*a616c061SThomas Bogendoerfer 				    MIPS_CPU_ISA_M32R5 | MIPS_CPU_ISA_M64R5 |
166*a616c061SThomas Bogendoerfer 				    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
167*a616c061SThomas Bogendoerfer 			c->options |= MIPS_CPU_NAN_2008 | MIPS_CPU_NAN_LEGACY;
168*a616c061SThomas Bogendoerfer 		} else {
169*a616c061SThomas Bogendoerfer 			c->options |= MIPS_CPU_NAN_LEGACY;
170*a616c061SThomas Bogendoerfer 			c->fpu_msk31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
171*a616c061SThomas Bogendoerfer 		}
172*a616c061SThomas Bogendoerfer 		break;
173*a616c061SThomas Bogendoerfer 	case LEGACY:
174*a616c061SThomas Bogendoerfer 		c->options |= MIPS_CPU_NAN_LEGACY;
175*a616c061SThomas Bogendoerfer 		c->fpu_msk31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
176*a616c061SThomas Bogendoerfer 		break;
177*a616c061SThomas Bogendoerfer 	case STD2008:
178*a616c061SThomas Bogendoerfer 		c->options |= MIPS_CPU_NAN_2008;
179*a616c061SThomas Bogendoerfer 		c->fpu_csr31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
180*a616c061SThomas Bogendoerfer 		c->fpu_msk31 |= FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
181*a616c061SThomas Bogendoerfer 		break;
182*a616c061SThomas Bogendoerfer 	case RELAXED:
183*a616c061SThomas Bogendoerfer 		c->options |= MIPS_CPU_NAN_2008 | MIPS_CPU_NAN_LEGACY;
184*a616c061SThomas Bogendoerfer 		break;
185*a616c061SThomas Bogendoerfer 	}
186*a616c061SThomas Bogendoerfer }
187*a616c061SThomas Bogendoerfer 
188*a616c061SThomas Bogendoerfer /*
189*a616c061SThomas Bogendoerfer  * Override the IEEE 754 NaN encoding and ABS.fmt/NEG.fmt execution mode
190*a616c061SThomas Bogendoerfer  * according to the "ieee754=" parameter.
191*a616c061SThomas Bogendoerfer  */
cpu_set_nan_2008(struct cpuinfo_mips * c)192*a616c061SThomas Bogendoerfer static void cpu_set_nan_2008(struct cpuinfo_mips *c)
193*a616c061SThomas Bogendoerfer {
194*a616c061SThomas Bogendoerfer 	switch (ieee754) {
195*a616c061SThomas Bogendoerfer 	case STRICT:
196*a616c061SThomas Bogendoerfer 		mips_use_nan_legacy = !!cpu_has_nan_legacy;
197*a616c061SThomas Bogendoerfer 		mips_use_nan_2008 = !!cpu_has_nan_2008;
198*a616c061SThomas Bogendoerfer 		break;
199*a616c061SThomas Bogendoerfer 	case LEGACY:
200*a616c061SThomas Bogendoerfer 		mips_use_nan_legacy = !!cpu_has_nan_legacy;
201*a616c061SThomas Bogendoerfer 		mips_use_nan_2008 = !cpu_has_nan_legacy;
202*a616c061SThomas Bogendoerfer 		break;
203*a616c061SThomas Bogendoerfer 	case STD2008:
204*a616c061SThomas Bogendoerfer 		mips_use_nan_legacy = !cpu_has_nan_2008;
205*a616c061SThomas Bogendoerfer 		mips_use_nan_2008 = !!cpu_has_nan_2008;
206*a616c061SThomas Bogendoerfer 		break;
207*a616c061SThomas Bogendoerfer 	case RELAXED:
208*a616c061SThomas Bogendoerfer 		mips_use_nan_legacy = true;
209*a616c061SThomas Bogendoerfer 		mips_use_nan_2008 = true;
210*a616c061SThomas Bogendoerfer 		break;
211*a616c061SThomas Bogendoerfer 	}
212*a616c061SThomas Bogendoerfer }
213*a616c061SThomas Bogendoerfer 
214*a616c061SThomas Bogendoerfer /*
215*a616c061SThomas Bogendoerfer  * IEEE 754 NaN encoding and ABS.fmt/NEG.fmt execution mode override
216*a616c061SThomas Bogendoerfer  * settings:
217*a616c061SThomas Bogendoerfer  *
218*a616c061SThomas Bogendoerfer  * strict:  accept binaries that request a NaN encoding supported by the FPU
219*a616c061SThomas Bogendoerfer  * legacy:  only accept legacy-NaN binaries
220*a616c061SThomas Bogendoerfer  * 2008:    only accept 2008-NaN binaries
221*a616c061SThomas Bogendoerfer  * relaxed: accept any binaries regardless of whether supported by the FPU
222*a616c061SThomas Bogendoerfer  */
ieee754_setup(char * s)223*a616c061SThomas Bogendoerfer static int __init ieee754_setup(char *s)
224*a616c061SThomas Bogendoerfer {
225*a616c061SThomas Bogendoerfer 	if (!s)
226*a616c061SThomas Bogendoerfer 		return -1;
227*a616c061SThomas Bogendoerfer 	else if (!strcmp(s, "strict"))
228*a616c061SThomas Bogendoerfer 		ieee754 = STRICT;
229*a616c061SThomas Bogendoerfer 	else if (!strcmp(s, "legacy"))
230*a616c061SThomas Bogendoerfer 		ieee754 = LEGACY;
231*a616c061SThomas Bogendoerfer 	else if (!strcmp(s, "2008"))
232*a616c061SThomas Bogendoerfer 		ieee754 = STD2008;
233*a616c061SThomas Bogendoerfer 	else if (!strcmp(s, "relaxed"))
234*a616c061SThomas Bogendoerfer 		ieee754 = RELAXED;
235*a616c061SThomas Bogendoerfer 	else
236*a616c061SThomas Bogendoerfer 		return -1;
237*a616c061SThomas Bogendoerfer 
238*a616c061SThomas Bogendoerfer 	if (!(boot_cpu_data.options & MIPS_CPU_FPU))
239*a616c061SThomas Bogendoerfer 		cpu_set_nofpu_2008(&boot_cpu_data);
240*a616c061SThomas Bogendoerfer 	cpu_set_nan_2008(&boot_cpu_data);
241*a616c061SThomas Bogendoerfer 
242*a616c061SThomas Bogendoerfer 	return 0;
243*a616c061SThomas Bogendoerfer }
244*a616c061SThomas Bogendoerfer 
245*a616c061SThomas Bogendoerfer early_param("ieee754", ieee754_setup);
246*a616c061SThomas Bogendoerfer 
247*a616c061SThomas Bogendoerfer /*
248*a616c061SThomas Bogendoerfer  * Set the FIR feature flags for the FPU emulator.
249*a616c061SThomas Bogendoerfer  */
cpu_set_nofpu_id(struct cpuinfo_mips * c)250*a616c061SThomas Bogendoerfer static void cpu_set_nofpu_id(struct cpuinfo_mips *c)
251*a616c061SThomas Bogendoerfer {
252*a616c061SThomas Bogendoerfer 	u32 value;
253*a616c061SThomas Bogendoerfer 
254*a616c061SThomas Bogendoerfer 	value = 0;
255*a616c061SThomas Bogendoerfer 	if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
256*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
257*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R5 | MIPS_CPU_ISA_M64R5 |
258*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
259*a616c061SThomas Bogendoerfer 		value |= MIPS_FPIR_D | MIPS_FPIR_S;
260*a616c061SThomas Bogendoerfer 	if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
261*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R5 | MIPS_CPU_ISA_M64R5 |
262*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
263*a616c061SThomas Bogendoerfer 		value |= MIPS_FPIR_F64 | MIPS_FPIR_L | MIPS_FPIR_W;
264*a616c061SThomas Bogendoerfer 	if (c->options & MIPS_CPU_NAN_2008)
265*a616c061SThomas Bogendoerfer 		value |= MIPS_FPIR_HAS2008;
266*a616c061SThomas Bogendoerfer 	c->fpu_id = value;
267*a616c061SThomas Bogendoerfer }
268*a616c061SThomas Bogendoerfer 
269*a616c061SThomas Bogendoerfer /* Determined FPU emulator mask to use for the boot CPU with "nofpu".  */
270*a616c061SThomas Bogendoerfer static unsigned int mips_nofpu_msk31;
271*a616c061SThomas Bogendoerfer 
272*a616c061SThomas Bogendoerfer /*
273*a616c061SThomas Bogendoerfer  * Set options for FPU hardware.
274*a616c061SThomas Bogendoerfer  */
cpu_set_fpu_opts(struct cpuinfo_mips * c)275*a616c061SThomas Bogendoerfer void cpu_set_fpu_opts(struct cpuinfo_mips *c)
276*a616c061SThomas Bogendoerfer {
277*a616c061SThomas Bogendoerfer 	c->fpu_id = cpu_get_fpu_id();
278*a616c061SThomas Bogendoerfer 	mips_nofpu_msk31 = c->fpu_msk31;
279*a616c061SThomas Bogendoerfer 
280*a616c061SThomas Bogendoerfer 	if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
281*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
282*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R5 | MIPS_CPU_ISA_M64R5 |
283*a616c061SThomas Bogendoerfer 			    MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
284*a616c061SThomas Bogendoerfer 		if (c->fpu_id & MIPS_FPIR_3D)
285*a616c061SThomas Bogendoerfer 			c->ases |= MIPS_ASE_MIPS3D;
286*a616c061SThomas Bogendoerfer 		if (c->fpu_id & MIPS_FPIR_UFRP)
287*a616c061SThomas Bogendoerfer 			c->options |= MIPS_CPU_UFR;
288*a616c061SThomas Bogendoerfer 		if (c->fpu_id & MIPS_FPIR_FREP)
289*a616c061SThomas Bogendoerfer 			c->options |= MIPS_CPU_FRE;
290*a616c061SThomas Bogendoerfer 	}
291*a616c061SThomas Bogendoerfer 
292*a616c061SThomas Bogendoerfer 	cpu_set_fpu_fcsr_mask(c);
293*a616c061SThomas Bogendoerfer 	cpu_set_fpu_2008(c);
294*a616c061SThomas Bogendoerfer 	cpu_set_nan_2008(c);
295*a616c061SThomas Bogendoerfer }
296*a616c061SThomas Bogendoerfer 
297*a616c061SThomas Bogendoerfer /*
298*a616c061SThomas Bogendoerfer  * Set options for the FPU emulator.
299*a616c061SThomas Bogendoerfer  */
cpu_set_nofpu_opts(struct cpuinfo_mips * c)300*a616c061SThomas Bogendoerfer void cpu_set_nofpu_opts(struct cpuinfo_mips *c)
301*a616c061SThomas Bogendoerfer {
302*a616c061SThomas Bogendoerfer 	c->options &= ~MIPS_CPU_FPU;
303*a616c061SThomas Bogendoerfer 	c->fpu_msk31 = mips_nofpu_msk31;
304*a616c061SThomas Bogendoerfer 
305*a616c061SThomas Bogendoerfer 	cpu_set_nofpu_2008(c);
306*a616c061SThomas Bogendoerfer 	cpu_set_nan_2008(c);
307*a616c061SThomas Bogendoerfer 	cpu_set_nofpu_id(c);
308*a616c061SThomas Bogendoerfer }
309*a616c061SThomas Bogendoerfer 
310*a616c061SThomas Bogendoerfer int mips_fpu_disabled;
311*a616c061SThomas Bogendoerfer 
fpu_disable(char * s)312*a616c061SThomas Bogendoerfer static int __init fpu_disable(char *s)
313*a616c061SThomas Bogendoerfer {
314*a616c061SThomas Bogendoerfer 	cpu_set_nofpu_opts(&boot_cpu_data);
315*a616c061SThomas Bogendoerfer 	mips_fpu_disabled = 1;
316*a616c061SThomas Bogendoerfer 
317*a616c061SThomas Bogendoerfer 	return 1;
318*a616c061SThomas Bogendoerfer }
319*a616c061SThomas Bogendoerfer 
320*a616c061SThomas Bogendoerfer __setup("nofpu", fpu_disable);
321*a616c061SThomas Bogendoerfer 
322