xref: /openbmc/linux/arch/powerpc/include/asm/xor.h (revision ef1313de)
1ef1313deSAnton Blanchard /*
2ef1313deSAnton Blanchard  * This program is free software; you can redistribute it and/or modify
3ef1313deSAnton Blanchard  * it under the terms of the GNU General Public License as published by
4ef1313deSAnton Blanchard  * the Free Software Foundation; either version 2 of the License, or
5ef1313deSAnton Blanchard  * (at your option) any later version.
6ef1313deSAnton Blanchard  *
7ef1313deSAnton Blanchard  * This program is distributed in the hope that it will be useful,
8ef1313deSAnton Blanchard  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9ef1313deSAnton Blanchard  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10ef1313deSAnton Blanchard  * GNU General Public License for more details.
11ef1313deSAnton Blanchard  *
12ef1313deSAnton Blanchard  * You should have received a copy of the GNU General Public License
13ef1313deSAnton Blanchard  * along with this program; if not, write to the Free Software
14ef1313deSAnton Blanchard  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15ef1313deSAnton Blanchard  *
16ef1313deSAnton Blanchard  * Copyright (C) IBM Corporation, 2012
17ef1313deSAnton Blanchard  *
18ef1313deSAnton Blanchard  * Author: Anton Blanchard <anton@au.ibm.com>
19ef1313deSAnton Blanchard  */
20ef1313deSAnton Blanchard #ifndef _ASM_POWERPC_XOR_H
21ef1313deSAnton Blanchard #define _ASM_POWERPC_XOR_H
22ef1313deSAnton Blanchard 
23ef1313deSAnton Blanchard #ifdef CONFIG_ALTIVEC
24ef1313deSAnton Blanchard 
25ef1313deSAnton Blanchard #include <asm/cputable.h>
26ef1313deSAnton Blanchard 
27ef1313deSAnton Blanchard void xor_altivec_2(unsigned long bytes, unsigned long *v1_in,
28ef1313deSAnton Blanchard 		   unsigned long *v2_in);
29ef1313deSAnton Blanchard void xor_altivec_3(unsigned long bytes, unsigned long *v1_in,
30ef1313deSAnton Blanchard 		   unsigned long *v2_in, unsigned long *v3_in);
31ef1313deSAnton Blanchard void xor_altivec_4(unsigned long bytes, unsigned long *v1_in,
32ef1313deSAnton Blanchard 		   unsigned long *v2_in, unsigned long *v3_in,
33ef1313deSAnton Blanchard 		   unsigned long *v4_in);
34ef1313deSAnton Blanchard void xor_altivec_5(unsigned long bytes, unsigned long *v1_in,
35ef1313deSAnton Blanchard 		   unsigned long *v2_in, unsigned long *v3_in,
36ef1313deSAnton Blanchard 		   unsigned long *v4_in, unsigned long *v5_in);
37ef1313deSAnton Blanchard 
38ef1313deSAnton Blanchard static struct xor_block_template xor_block_altivec = {
39ef1313deSAnton Blanchard 	.name = "altivec",
40ef1313deSAnton Blanchard 	.do_2 = xor_altivec_2,
41ef1313deSAnton Blanchard 	.do_3 = xor_altivec_3,
42ef1313deSAnton Blanchard 	.do_4 = xor_altivec_4,
43ef1313deSAnton Blanchard 	.do_5 = xor_altivec_5,
44ef1313deSAnton Blanchard };
45ef1313deSAnton Blanchard 
46ef1313deSAnton Blanchard #define XOR_SPEED_ALTIVEC()				\
47ef1313deSAnton Blanchard 	do {						\
48ef1313deSAnton Blanchard 		if (cpu_has_feature(CPU_FTR_ALTIVEC))	\
49ef1313deSAnton Blanchard 			xor_speed(&xor_block_altivec);	\
50ef1313deSAnton Blanchard 	} while (0)
51ef1313deSAnton Blanchard #else
52ef1313deSAnton Blanchard #define XOR_SPEED_ALTIVEC()
53ef1313deSAnton Blanchard #endif
54ef1313deSAnton Blanchard 
55ef1313deSAnton Blanchard /* Also try the generic routines. */
56b8b572e1SStephen Rothwell #include <asm-generic/xor.h>
57ef1313deSAnton Blanchard 
58ef1313deSAnton Blanchard #undef XOR_TRY_TEMPLATES
59ef1313deSAnton Blanchard #define XOR_TRY_TEMPLATES				\
60ef1313deSAnton Blanchard do {							\
61ef1313deSAnton Blanchard 	xor_speed(&xor_block_8regs);			\
62ef1313deSAnton Blanchard 	xor_speed(&xor_block_8regs_p);			\
63ef1313deSAnton Blanchard 	xor_speed(&xor_block_32regs);			\
64ef1313deSAnton Blanchard 	xor_speed(&xor_block_32regs_p);			\
65ef1313deSAnton Blanchard 	XOR_SPEED_ALTIVEC();				\
66ef1313deSAnton Blanchard } while (0)
67ef1313deSAnton Blanchard 
68ef1313deSAnton Blanchard #endif /* _ASM_POWERPC_XOR_H */
69