Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1e57372e JH |
2 | /* |
3 | * Copyright (C) 2008 Imagination Technologies | |
4 | */ | |
5 | #ifndef __METAG_HWTHREAD_H | |
6 | #define __METAG_HWTHREAD_H | |
7 | ||
8 | #include <linux/bug.h> | |
9 | #include <linux/io.h> | |
10 | ||
11 | #include <asm/metag_mem.h> | |
12 | ||
13 | #define BAD_HWTHREAD_ID (0xFFU) | |
14 | #define BAD_CPU_ID (0xFFU) | |
15 | ||
16 | extern u8 cpu_2_hwthread_id[]; | |
17 | extern u8 hwthread_id_2_cpu[]; | |
18 | ||
19 | /* | |
20 | * Each hardware thread's Control Unit registers are memory-mapped | |
21 | * and can therefore be accessed by any other hardware thread. | |
22 | * | |
23 | * This helper function returns the memory address where "thread"'s | |
24 | * register "regnum" is mapped. | |
25 | */ | |
26 | static inline | |
27 | void __iomem *__CU_addr(unsigned int thread, unsigned int regnum) | |
28 | { | |
29 | unsigned int base, thread_offset, thread_regnum; | |
30 | ||
31 | WARN_ON(thread == BAD_HWTHREAD_ID); | |
32 | ||
33 | base = T0UCTREG0; /* Control unit base */ | |
34 | ||
35 | thread_offset = TnUCTRX_STRIDE * thread; | |
36 | thread_regnum = TXUCTREGn_STRIDE * regnum; | |
37 | ||
38 | return (void __iomem *)(base + thread_offset + thread_regnum); | |
39 | } | |
40 | ||
41 | #endif /* __METAG_HWTHREAD_H */ |