18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
38c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
48c2ecf20Sopenharmony_ci * for more details.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2009 Wind River Systems,
78c2ecf20Sopenharmony_ci *   written by Ralf Baechle <ralf@linux-mips.org>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef __ASM_COP2_H
108c2ecf20Sopenharmony_ci#define __ASM_COP2_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/notifier.h>
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci#if defined(CONFIG_CPU_CAVIUM_OCTEON)
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ciextern void octeon_cop2_save(struct octeon_cop2_state *);
178c2ecf20Sopenharmony_ciextern void octeon_cop2_restore(struct octeon_cop2_state *);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#define cop2_save(r)		octeon_cop2_save(&(r)->thread.cp2)
208c2ecf20Sopenharmony_ci#define cop2_restore(r)		octeon_cop2_restore(&(r)->thread.cp2)
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci#define cop2_present		1
238c2ecf20Sopenharmony_ci#define cop2_lazy_restore	1
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#elif defined(CONFIG_CPU_XLP)
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciextern void nlm_cop2_save(struct nlm_cop2_state *);
288c2ecf20Sopenharmony_ciextern void nlm_cop2_restore(struct nlm_cop2_state *);
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci#define cop2_save(r)		nlm_cop2_save(&(r)->thread.cp2)
318c2ecf20Sopenharmony_ci#define cop2_restore(r)		nlm_cop2_restore(&(r)->thread.cp2)
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci#define cop2_present		1
348c2ecf20Sopenharmony_ci#define cop2_lazy_restore	0
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#elif defined(CONFIG_CPU_LOONGSON64)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define cop2_present		1
398c2ecf20Sopenharmony_ci#define cop2_lazy_restore	1
408c2ecf20Sopenharmony_ci#define cop2_save(r)		do { (void)(r); } while (0)
418c2ecf20Sopenharmony_ci#define cop2_restore(r)		do { (void)(r); } while (0)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#else
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci#define cop2_present		0
468c2ecf20Sopenharmony_ci#define cop2_lazy_restore	0
478c2ecf20Sopenharmony_ci#define cop2_save(r)		do { (void)(r); } while (0)
488c2ecf20Sopenharmony_ci#define cop2_restore(r)		do { (void)(r); } while (0)
498c2ecf20Sopenharmony_ci#endif
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cienum cu2_ops {
528c2ecf20Sopenharmony_ci	CU2_EXCEPTION,
538c2ecf20Sopenharmony_ci	CU2_LWC2_OP,
548c2ecf20Sopenharmony_ci	CU2_LDC2_OP,
558c2ecf20Sopenharmony_ci	CU2_SWC2_OP,
568c2ecf20Sopenharmony_ci	CU2_SDC2_OP,
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ciextern int register_cu2_notifier(struct notifier_block *nb);
608c2ecf20Sopenharmony_ciextern int cu2_notifier_call_chain(unsigned long val, void *v);
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define cu2_notifier(fn, pri)						\
638c2ecf20Sopenharmony_ci({									\
648c2ecf20Sopenharmony_ci	static struct notifier_block fn##_nb = {			\
658c2ecf20Sopenharmony_ci		.notifier_call = fn,					\
668c2ecf20Sopenharmony_ci		.priority = pri						\
678c2ecf20Sopenharmony_ci	};								\
688c2ecf20Sopenharmony_ci									\
698c2ecf20Sopenharmony_ci	register_cu2_notifier(&fn##_nb);				\
708c2ecf20Sopenharmony_ci})
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#endif /* __ASM_COP2_H */
73