162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2011 Tobias Klauser <tklauser@distanz.ch>
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef _ASM_NIOS2_REGISTERS_H
762306a36Sopenharmony_ci#define _ASM_NIOS2_REGISTERS_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef __ASSEMBLY__
1062306a36Sopenharmony_ci#include <asm/cpuinfo.h>
1162306a36Sopenharmony_ci#endif
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/* control register numbers */
1462306a36Sopenharmony_ci#define CTL_FSTATUS	0
1562306a36Sopenharmony_ci#define CTL_ESTATUS	1
1662306a36Sopenharmony_ci#define CTL_BSTATUS	2
1762306a36Sopenharmony_ci#define CTL_IENABLE	3
1862306a36Sopenharmony_ci#define CTL_IPENDING	4
1962306a36Sopenharmony_ci#define CTL_CPUID	5
2062306a36Sopenharmony_ci#define CTL_RSV1	6
2162306a36Sopenharmony_ci#define CTL_EXCEPTION	7
2262306a36Sopenharmony_ci#define CTL_PTEADDR	8
2362306a36Sopenharmony_ci#define CTL_TLBACC	9
2462306a36Sopenharmony_ci#define CTL_TLBMISC	10
2562306a36Sopenharmony_ci#define CTL_RSV2	11
2662306a36Sopenharmony_ci#define CTL_BADADDR	12
2762306a36Sopenharmony_ci#define CTL_CONFIG	13
2862306a36Sopenharmony_ci#define CTL_MPUBASE	14
2962306a36Sopenharmony_ci#define CTL_MPUACC	15
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci/* access control registers using GCC builtins */
3262306a36Sopenharmony_ci#define RDCTL(r)	__builtin_rdctl(r)
3362306a36Sopenharmony_ci#define WRCTL(r, v)	__builtin_wrctl(r, v)
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci/* status register bits */
3662306a36Sopenharmony_ci#define STATUS_PIE	(1 << 0)	/* processor interrupt enable */
3762306a36Sopenharmony_ci#define STATUS_U	(1 << 1)	/* user mode */
3862306a36Sopenharmony_ci#define STATUS_EH	(1 << 2)	/* Exception mode */
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci/* estatus register bits */
4162306a36Sopenharmony_ci#define ESTATUS_EPIE	(1 << 0)	/* processor interrupt enable */
4262306a36Sopenharmony_ci#define ESTATUS_EU	(1 << 1)	/* user mode */
4362306a36Sopenharmony_ci#define ESTATUS_EH	(1 << 2)	/* Exception mode */
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* tlbmisc register bits */
4662306a36Sopenharmony_ci#define TLBMISC_PID_SHIFT	4
4762306a36Sopenharmony_ci#ifndef __ASSEMBLY__
4862306a36Sopenharmony_ci#define TLBMISC_PID_MASK	((1UL << cpuinfo.tlb_pid_num_bits) - 1)
4962306a36Sopenharmony_ci#endif
5062306a36Sopenharmony_ci#define TLBMISC_WAY_MASK	0xf
5162306a36Sopenharmony_ci#define TLBMISC_WAY_SHIFT	20
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci#define TLBMISC_PID	(TLBMISC_PID_MASK << TLBMISC_PID_SHIFT)	/* TLB PID */
5462306a36Sopenharmony_ci#define TLBMISC_WE	(1 << 18)	/* TLB write enable */
5562306a36Sopenharmony_ci#define TLBMISC_RD	(1 << 19)	/* TLB read */
5662306a36Sopenharmony_ci#define TLBMISC_WAY	(TLBMISC_WAY_MASK << TLBMISC_WAY_SHIFT) /* TLB way */
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci#endif /* _ASM_NIOS2_REGISTERS_H */
59