1
2
3
4
5
6
7
8
9
10
11#ifndef __MIPS_ASM_MIPS_CPC_H__
12#define __MIPS_ASM_MIPS_CPC_H__
13
14#include <linux/io.h>
15#include <linux/types.h>
16
17
18extern void __iomem *mips_cpc_base;
19
20
21
22
23
24
25
26
27
28extern phys_addr_t mips_cpc_default_phys_base(void);
29
30
31
32
33
34
35
36
37
38extern phys_addr_t __weak mips_cpc_phys_base(void);
39
40
41
42
43
44
45
46#ifdef CONFIG_MIPS_CPC
47extern int mips_cpc_probe(void);
48#else
49static inline int mips_cpc_probe(void)
50{
51 return -ENODEV;
52}
53#endif
54
55
56
57
58
59
60static inline bool mips_cpc_present(void)
61{
62#ifdef CONFIG_MIPS_CPC
63 return mips_cpc_base != NULL;
64#else
65 return false;
66#endif
67}
68
69
70#define MIPS_CPC_GCB_OFS 0x0000
71#define MIPS_CPC_CLCB_OFS 0x2000
72#define MIPS_CPC_COCB_OFS 0x4000
73
74
75#define BUILD_CPC_R_(name, off) \
76static inline u32 *addr_cpc_##name(void) \
77{ \
78 return (u32 *)(mips_cpc_base + (off)); \
79} \
80 \
81static inline u32 read_cpc_##name(void) \
82{ \
83 return __raw_readl(mips_cpc_base + (off)); \
84}
85
86#define BUILD_CPC__W(name, off) \
87static inline void write_cpc_##name(u32 value) \
88{ \
89 __raw_writel(value, mips_cpc_base + (off)); \
90}
91
92#define BUILD_CPC_RW(name, off) \
93 BUILD_CPC_R_(name, off) \
94 BUILD_CPC__W(name, off)
95
96#define BUILD_CPC_Cx_R_(name, off) \
97 BUILD_CPC_R_(cl_##name, MIPS_CPC_CLCB_OFS + (off)) \
98 BUILD_CPC_R_(co_##name, MIPS_CPC_COCB_OFS + (off))
99
100#define BUILD_CPC_Cx__W(name, off) \
101 BUILD_CPC__W(cl_##name, MIPS_CPC_CLCB_OFS + (off)) \
102 BUILD_CPC__W(co_##name, MIPS_CPC_COCB_OFS + (off))
103
104#define BUILD_CPC_Cx_RW(name, off) \
105 BUILD_CPC_Cx_R_(name, off) \
106 BUILD_CPC_Cx__W(name, off)
107
108
109BUILD_CPC_RW(access, MIPS_CPC_GCB_OFS + 0x00)
110BUILD_CPC_RW(seqdel, MIPS_CPC_GCB_OFS + 0x08)
111BUILD_CPC_RW(rail, MIPS_CPC_GCB_OFS + 0x10)
112BUILD_CPC_RW(resetlen, MIPS_CPC_GCB_OFS + 0x18)
113BUILD_CPC_R_(revision, MIPS_CPC_GCB_OFS + 0x20)
114
115
116BUILD_CPC_Cx_RW(cmd, 0x00)
117BUILD_CPC_Cx_RW(stat_conf, 0x08)
118BUILD_CPC_Cx_RW(other, 0x10)
119
120
121#define CPC_Cx_CMD_SHF 0
122#define CPC_Cx_CMD_MSK (_ULCAST_(0xf) << 0)
123#define CPC_Cx_CMD_CLOCKOFF (_ULCAST_(0x1) << 0)
124#define CPC_Cx_CMD_PWRDOWN (_ULCAST_(0x2) << 0)
125#define CPC_Cx_CMD_PWRUP (_ULCAST_(0x3) << 0)
126#define CPC_Cx_CMD_RESET (_ULCAST_(0x4) << 0)
127
128
129#define CPC_Cx_STAT_CONF_PWRUPE_SHF 23
130#define CPC_Cx_STAT_CONF_PWRUPE_MSK (_ULCAST_(0x1) << 23)
131#define CPC_Cx_STAT_CONF_SEQSTATE_SHF 19
132#define CPC_Cx_STAT_CONF_SEQSTATE_MSK (_ULCAST_(0xf) << 19)
133#define CPC_Cx_STAT_CONF_SEQSTATE_D0 (_ULCAST_(0x0) << 19)
134#define CPC_Cx_STAT_CONF_SEQSTATE_U0 (_ULCAST_(0x1) << 19)
135#define CPC_Cx_STAT_CONF_SEQSTATE_U1 (_ULCAST_(0x2) << 19)
136#define CPC_Cx_STAT_CONF_SEQSTATE_U2 (_ULCAST_(0x3) << 19)
137#define CPC_Cx_STAT_CONF_SEQSTATE_U3 (_ULCAST_(0x4) << 19)
138#define CPC_Cx_STAT_CONF_SEQSTATE_U4 (_ULCAST_(0x5) << 19)
139#define CPC_Cx_STAT_CONF_SEQSTATE_U5 (_ULCAST_(0x6) << 19)
140#define CPC_Cx_STAT_CONF_SEQSTATE_U6 (_ULCAST_(0x7) << 19)
141#define CPC_Cx_STAT_CONF_SEQSTATE_D1 (_ULCAST_(0x8) << 19)
142#define CPC_Cx_STAT_CONF_SEQSTATE_D3 (_ULCAST_(0x9) << 19)
143#define CPC_Cx_STAT_CONF_SEQSTATE_D2 (_ULCAST_(0xa) << 19)
144#define CPC_Cx_STAT_CONF_CLKGAT_IMPL_SHF 17
145#define CPC_Cx_STAT_CONF_CLKGAT_IMPL_MSK (_ULCAST_(0x1) << 17)
146#define CPC_Cx_STAT_CONF_PWRDN_IMPL_SHF 16
147#define CPC_Cx_STAT_CONF_PWRDN_IMPL_MSK (_ULCAST_(0x1) << 16)
148#define CPC_Cx_STAT_CONF_EJTAG_PROBE_SHF 15
149#define CPC_Cx_STAT_CONF_EJTAG_PROBE_MSK (_ULCAST_(0x1) << 15)
150
151
152#define CPC_Cx_OTHER_CORENUM_SHF 16
153#define CPC_Cx_OTHER_CORENUM_MSK (_ULCAST_(0xff) << 16)
154
155#ifdef CONFIG_MIPS_CPC
156
157
158
159
160
161
162
163
164
165extern void mips_cpc_lock_other(unsigned int core);
166
167
168
169
170
171
172
173extern void mips_cpc_unlock_other(void);
174
175#else
176
177static inline void mips_cpc_lock_other(unsigned int core) { }
178static inline void mips_cpc_unlock_other(void) { }
179
180#endif
181
182#endif
183