GNU Linux-libre 4.19.245-gnu1
[releases.git] / arch / arc / plat-eznps / include / plat / mtm.h
1 /*
2  * Copyright(c) 2015 EZchip Technologies.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms and conditions of the GNU General Public License,
6  * version 2, as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
11  * more details.
12  *
13  * The full GNU General Public License is included in this distribution in
14  * the file called "COPYING".
15  */
16
17 #ifndef _PLAT_EZNPS_MTM_H
18 #define _PLAT_EZNPS_MTM_H
19
20 #include <plat/ctop.h>
21
22 static inline void *nps_mtm_reg_addr(u32 cpu, u32 reg)
23 {
24         struct global_id gid;
25         u32 core, blkid;
26
27         gid.value = cpu;
28         core = gid.core;
29         blkid = (((core & 0x0C) << 2) | (core & 0x03));
30
31         return nps_host_reg(cpu, blkid, reg);
32 }
33
34 #ifdef CONFIG_EZNPS_MTM_EXT
35 #define NPS_CPU_TO_THREAD_NUM(cpu) \
36         ({ struct global_id gid; gid.value = cpu; gid.thread; })
37
38 /* MTM registers */
39 #define MTM_CFG(cpu)                    nps_mtm_reg_addr(cpu, 0x81)
40 #define MTM_THR_INIT(cpu)               nps_mtm_reg_addr(cpu, 0x92)
41 #define MTM_THR_INIT_STS(cpu)           nps_mtm_reg_addr(cpu, 0x93)
42
43 #define get_thread(map) map.thread
44 #define eznps_max_cpus 4096
45 #define eznps_cpus_per_cluster  256
46
47 void mtm_enable_core(unsigned int cpu);
48 int mtm_enable_thread(int cpu);
49 #else /* !CONFIG_EZNPS_MTM_EXT */
50
51 #define get_thread(map) 0
52 #define eznps_max_cpus 256
53 #define eznps_cpus_per_cluster  16
54 #define mtm_enable_core(cpu)
55 #define mtm_enable_thread(cpu) 1
56 #define NPS_CPU_TO_THREAD_NUM(cpu) 0
57
58 #endif /* CONFIG_EZNPS_MTM_EXT */
59
60 #endif /* _PLAT_EZNPS_MTM_H */