1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2008 Imagination Technologies
5 #ifndef __METAG_HWTHREAD_H
6 #define __METAG_HWTHREAD_H
11 #include <asm/metag_mem.h>
13 #define BAD_HWTHREAD_ID (0xFFU)
14 #define BAD_CPU_ID (0xFFU)
16 extern u8 cpu_2_hwthread_id[];
17 extern u8 hwthread_id_2_cpu[];
20 * Each hardware thread's Control Unit registers are memory-mapped
21 * and can therefore be accessed by any other hardware thread.
23 * This helper function returns the memory address where "thread"'s
24 * register "regnum" is mapped.
27 void __iomem *__CU_addr(unsigned int thread, unsigned int regnum)
29 unsigned int base, thread_offset, thread_regnum;
31 WARN_ON(thread == BAD_HWTHREAD_ID);
33 base = T0UCTREG0; /* Control unit base */
35 thread_offset = TnUCTRX_STRIDE * thread;
36 thread_regnum = TXUCTREGn_STRIDE * regnum;
38 return (void __iomem *)(base + thread_offset + thread_regnum);
41 #endif /* __METAG_HWTHREAD_H */