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