18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * include/asm/xor.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * High speed xor_block operation for RAID4/5 utilizing the
68c2ecf20Sopenharmony_ci * UltraSparc Visual Instruction Set and Niagara block-init
78c2ecf20Sopenharmony_ci * twin-load instructions.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * Copyright (C) 1997, 1999 Jakub Jelinek (jj@ultra.linux.cz)
108c2ecf20Sopenharmony_ci * Copyright (C) 2006 David S. Miller <davem@davemloft.net>
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <asm/spitfire.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_civoid xor_vis_2(unsigned long, unsigned long *, unsigned long *);
168c2ecf20Sopenharmony_civoid xor_vis_3(unsigned long, unsigned long *, unsigned long *,
178c2ecf20Sopenharmony_ci	       unsigned long *);
188c2ecf20Sopenharmony_civoid xor_vis_4(unsigned long, unsigned long *, unsigned long *,
198c2ecf20Sopenharmony_ci	       unsigned long *, unsigned long *);
208c2ecf20Sopenharmony_civoid xor_vis_5(unsigned long, unsigned long *, unsigned long *,
218c2ecf20Sopenharmony_ci	       unsigned long *, unsigned long *, unsigned long *);
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* XXX Ugh, write cheetah versions... -DaveM */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistatic struct xor_block_template xor_block_VIS = {
268c2ecf20Sopenharmony_ci        .name	= "VIS",
278c2ecf20Sopenharmony_ci        .do_2	= xor_vis_2,
288c2ecf20Sopenharmony_ci        .do_3	= xor_vis_3,
298c2ecf20Sopenharmony_ci        .do_4	= xor_vis_4,
308c2ecf20Sopenharmony_ci        .do_5	= xor_vis_5,
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_civoid xor_niagara_2(unsigned long, unsigned long *, unsigned long *);
348c2ecf20Sopenharmony_civoid xor_niagara_3(unsigned long, unsigned long *, unsigned long *,
358c2ecf20Sopenharmony_ci		   unsigned long *);
368c2ecf20Sopenharmony_civoid xor_niagara_4(unsigned long, unsigned long *, unsigned long *,
378c2ecf20Sopenharmony_ci		   unsigned long *, unsigned long *);
388c2ecf20Sopenharmony_civoid xor_niagara_5(unsigned long, unsigned long *, unsigned long *,
398c2ecf20Sopenharmony_ci		   unsigned long *, unsigned long *, unsigned long *);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic struct xor_block_template xor_block_niagara = {
428c2ecf20Sopenharmony_ci        .name	= "Niagara",
438c2ecf20Sopenharmony_ci        .do_2	= xor_niagara_2,
448c2ecf20Sopenharmony_ci        .do_3	= xor_niagara_3,
458c2ecf20Sopenharmony_ci        .do_4	= xor_niagara_4,
468c2ecf20Sopenharmony_ci        .do_5	= xor_niagara_5,
478c2ecf20Sopenharmony_ci};
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci#undef XOR_TRY_TEMPLATES
508c2ecf20Sopenharmony_ci#define XOR_TRY_TEMPLATES				\
518c2ecf20Sopenharmony_ci	do {						\
528c2ecf20Sopenharmony_ci		xor_speed(&xor_block_VIS);		\
538c2ecf20Sopenharmony_ci		xor_speed(&xor_block_niagara);		\
548c2ecf20Sopenharmony_ci	} while (0)
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/* For VIS for everything except Niagara.  */
578c2ecf20Sopenharmony_ci#define XOR_SELECT_TEMPLATE(FASTEST) \
588c2ecf20Sopenharmony_ci	((tlb_type == hypervisor && \
598c2ecf20Sopenharmony_ci	  (sun4v_chip_type == SUN4V_CHIP_NIAGARA1 || \
608c2ecf20Sopenharmony_ci	   sun4v_chip_type == SUN4V_CHIP_NIAGARA2 || \
618c2ecf20Sopenharmony_ci	   sun4v_chip_type == SUN4V_CHIP_NIAGARA3 || \
628c2ecf20Sopenharmony_ci	   sun4v_chip_type == SUN4V_CHIP_NIAGARA4 || \
638c2ecf20Sopenharmony_ci	   sun4v_chip_type == SUN4V_CHIP_NIAGARA5)) ? \
648c2ecf20Sopenharmony_ci	 &xor_block_niagara : \
658c2ecf20Sopenharmony_ci	 &xor_block_VIS)
66