Merge remote-tracking branch 'asoc/topic/tlv320aic32x4' into asoc-next
[deliverable/linux.git] / arch / powerpc / include / asm / plpar_wrappers.h
CommitLineData
212bebb4
DD
1#ifndef _ASM_POWERPC_PLPAR_WRAPPERS_H
2#define _ASM_POWERPC_PLPAR_WRAPPERS_H
a1218720 3
614f15b4 4#include <linux/string.h>
fb912568 5#include <linux/irqflags.h>
614f15b4 6
a1218720 7#include <asm/hvcall.h>
614f15b4 8#include <asm/paca.h>
370e4587 9#include <asm/page.h>
a1218720 10
f8b67691
MN
11/* Get state of physical CPU from query_cpu_stopped */
12int smp_query_cpu_stopped(unsigned int pcpu);
13#define QCSS_STOPPED 0
14#define QCSS_STOPPING 1
15#define QCSS_NOT_STOPPED 2
16#define QCSS_HARDWARE_ERROR -1
17#define QCSS_HARDWARE_BUSY -2
18
a1218720
ME
19static inline long poll_pending(void)
20{
b9377ffc 21 return plpar_hcall_norets(H_POLL_PENDING);
a1218720
ME
22}
23
69ddb57c
GS
24static inline u8 get_cede_latency_hint(void)
25{
cf8a056a 26 return get_lppaca()->cede_latency_hint;
69ddb57c
GS
27}
28
29static inline void set_cede_latency_hint(u8 latency_hint)
30{
cf8a056a 31 get_lppaca()->cede_latency_hint = latency_hint;
69ddb57c
GS
32}
33
a1218720
ME
34static inline long cede_processor(void)
35{
b9377ffc 36 return plpar_hcall_norets(H_CEDE);
a1218720
ME
37}
38
69ddb57c
GS
39static inline long extended_cede_processor(unsigned long latency_hint)
40{
41 long rc;
42 u8 old_latency_hint = get_cede_latency_hint();
43
44 set_cede_latency_hint(latency_hint);
fb912568 45
69ddb57c 46 rc = cede_processor();
fb912568
LZ
47#ifdef CONFIG_TRACE_IRQFLAGS
48 /* Ensure that H_CEDE returns with IRQs on */
49 if (WARN_ON(!(mfmsr() & MSR_EE)))
50 __hard_irq_enable();
51#endif
52
69ddb57c
GS
53 set_cede_latency_hint(old_latency_hint);
54
55 return rc;
56}
57
40765d2b 58static inline long vpa_call(unsigned long flags, unsigned long cpu,
a1218720
ME
59 unsigned long vpa)
60{
bb18b3a4 61 flags = flags << H_VPA_FUNC_SHIFT;
40765d2b
ME
62
63 return plpar_hcall_norets(H_REGISTER_VPA, flags, cpu, vpa);
64}
65
598c8231 66static inline long unregister_vpa(unsigned long cpu)
40765d2b 67{
bb18b3a4 68 return vpa_call(H_VPA_DEREG_VPA, cpu, 0);
40765d2b
ME
69}
70
71static inline long register_vpa(unsigned long cpu, unsigned long vpa)
72{
bb18b3a4 73 return vpa_call(H_VPA_REG_VPA, cpu, vpa);
a1218720
ME
74}
75
598c8231 76static inline long unregister_slb_shadow(unsigned long cpu)
2f6093c8 77{
bb18b3a4 78 return vpa_call(H_VPA_DEREG_SLB, cpu, 0);
2f6093c8
MN
79}
80
81static inline long register_slb_shadow(unsigned long cpu, unsigned long vpa)
82{
bb18b3a4 83 return vpa_call(H_VPA_REG_SLB, cpu, vpa);
2f6093c8
MN
84}
85
b1301797 86static inline long unregister_dtl(unsigned long cpu)
fc59a3fc 87{
bb18b3a4 88 return vpa_call(H_VPA_DEREG_DTL, cpu, 0);
fc59a3fc
JK
89}
90
91static inline long register_dtl(unsigned long cpu, unsigned long vpa)
92{
bb18b3a4 93 return vpa_call(H_VPA_REG_DTL, cpu, vpa);
fc59a3fc
JK
94}
95
86630a32
BK
96static inline long plpar_page_set_loaned(unsigned long vpa)
97{
370e4587
BK
98 unsigned long cmo_page_sz = cmo_get_page_size();
99 long rc = 0;
100 int i;
101
102 for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
103 rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED, vpa + i, 0);
104
105 for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
106 plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE,
107 vpa + i - cmo_page_sz, 0);
108
109 return rc;
86630a32
BK
110}
111
112static inline long plpar_page_set_active(unsigned long vpa)
113{
370e4587
BK
114 unsigned long cmo_page_sz = cmo_get_page_size();
115 long rc = 0;
116 int i;
117
118 for (i = 0; !rc && i < PAGE_SIZE; i += cmo_page_sz)
119 rc = plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_ACTIVE, vpa + i, 0);
120
121 for (i -= cmo_page_sz; rc && i != 0; i -= cmo_page_sz)
122 plpar_hcall_norets(H_PAGE_INIT, H_PAGE_SET_LOANED,
123 vpa + i - cmo_page_sz, 0);
124
125 return rc;
86630a32
BK
126}
127
40765d2b 128extern void vpa_init(int cpu);
a1218720 129
b9377ffc
AB
130static inline long plpar_pte_enter(unsigned long flags,
131 unsigned long hpte_group, unsigned long hpte_v,
132 unsigned long hpte_r, unsigned long *slot)
133{
134 long rc;
135 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
136
137 rc = plpar_hcall(H_ENTER, retbuf, flags, hpte_group, hpte_v, hpte_r);
138
139 *slot = retbuf[0];
140
141 return rc;
142}
143
a1218720
ME
144static inline long plpar_pte_remove(unsigned long flags, unsigned long ptex,
145 unsigned long avpn, unsigned long *old_pteh_ret,
146 unsigned long *old_ptel_ret)
147{
b9377ffc
AB
148 long rc;
149 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
150
151 rc = plpar_hcall(H_REMOVE, retbuf, flags, ptex, avpn);
152
153 *old_pteh_ret = retbuf[0];
154 *old_ptel_ret = retbuf[1];
155
156 return rc;
a1218720
ME
157}
158
b4aea36b
MK
159/* plpar_pte_remove_raw can be called in real mode. It calls plpar_hcall_raw */
160static inline long plpar_pte_remove_raw(unsigned long flags, unsigned long ptex,
161 unsigned long avpn, unsigned long *old_pteh_ret,
162 unsigned long *old_ptel_ret)
163{
164 long rc;
165 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
166
167 rc = plpar_hcall_raw(H_REMOVE, retbuf, flags, ptex, avpn);
168
169 *old_pteh_ret = retbuf[0];
170 *old_ptel_ret = retbuf[1];
171
172 return rc;
173}
174
a1218720
ME
175static inline long plpar_pte_read(unsigned long flags, unsigned long ptex,
176 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
177{
b9377ffc
AB
178 long rc;
179 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
180
181 rc = plpar_hcall(H_READ, retbuf, flags, ptex);
182
183 *old_pteh_ret = retbuf[0];
184 *old_ptel_ret = retbuf[1];
185
186 return rc;
a1218720
ME
187}
188
b7abc5c5
SS
189/* plpar_pte_read_raw can be called in real mode. It calls plpar_hcall_raw */
190static inline long plpar_pte_read_raw(unsigned long flags, unsigned long ptex,
191 unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
192{
193 long rc;
194 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
195
196 rc = plpar_hcall_raw(H_READ, retbuf, flags, ptex);
197
198 *old_pteh_ret = retbuf[0];
199 *old_ptel_ret = retbuf[1];
200
201 return rc;
202}
203
4ad90c86
AK
204/*
205 * ptes must be 8*sizeof(unsigned long)
206 */
207static inline long plpar_pte_read_4(unsigned long flags, unsigned long ptex,
208 unsigned long *ptes)
209
210{
211 long rc;
212 unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
213
214 rc = plpar_hcall9(H_READ, retbuf, flags | H_READ_4, ptex);
215
216 memcpy(ptes, retbuf, 8*sizeof(unsigned long));
217
218 return rc;
219}
220
f90ece28
MN
221/*
222 * plpar_pte_read_4_raw can be called in real mode.
223 * ptes must be 8*sizeof(unsigned long)
224 */
225static inline long plpar_pte_read_4_raw(unsigned long flags, unsigned long ptex,
226 unsigned long *ptes)
227
228{
229 long rc;
230 unsigned long retbuf[PLPAR_HCALL9_BUFSIZE];
231
232 rc = plpar_hcall9_raw(H_READ, retbuf, flags | H_READ_4, ptex);
233
234 memcpy(ptes, retbuf, 8*sizeof(unsigned long));
235
236 return rc;
237}
238
a1218720
ME
239static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
240 unsigned long avpn)
241{
242 return plpar_hcall_norets(H_PROTECT, flags, ptex, avpn);
243}
244
245static inline long plpar_tce_get(unsigned long liobn, unsigned long ioba,
246 unsigned long *tce_ret)
247{
b9377ffc
AB
248 long rc;
249 unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
250
251 rc = plpar_hcall(H_GET_TCE, retbuf, liobn, ioba);
252
253 *tce_ret = retbuf[0];
254
255 return rc;
a1218720
ME
256}
257
258static inline long plpar_tce_put(unsigned long liobn, unsigned long ioba,
259 unsigned long tceval)
260{
261 return plpar_hcall_norets(H_PUT_TCE, liobn, ioba, tceval);
262}
263
264static inline long plpar_tce_put_indirect(unsigned long liobn,
265 unsigned long ioba, unsigned long page, unsigned long count)
266{
267 return plpar_hcall_norets(H_PUT_TCE_INDIRECT, liobn, ioba, page, count);
268}
269
270static inline long plpar_tce_stuff(unsigned long liobn, unsigned long ioba,
271 unsigned long tceval, unsigned long count)
272{
273 return plpar_hcall_norets(H_STUFF_TCE, liobn, ioba, tceval, count);
274}
275
d8f48ecc
IM
276/* Set various resource mode parameters */
277static inline long plpar_set_mode(unsigned long mflags, unsigned long resource,
278 unsigned long value1, unsigned long value2)
279{
280 return plpar_hcall_norets(H_SET_MODE, mflags, resource, value1, value2);
281}
798042da
IM
282
283/*
284 * Enable relocation on exceptions on this partition
285 *
286 * Note: this call has a partition wide scope and can take a while to complete.
287 * If it returns H_LONG_BUSY_* it should be retried periodically until it
288 * returns H_SUCCESS.
289 */
290static inline long enable_reloc_on_exceptions(void)
291{
292 /* mflags = 3: Exceptions at 0xC000000000004000 */
60666de2 293 return plpar_set_mode(3, H_SET_MODE_RESOURCE_ADDR_TRANS_MODE, 0, 0);
798042da
IM
294}
295
296/*
297 * Disable relocation on exceptions on this partition
298 *
299 * Note: this call has a partition wide scope and can take a while to complete.
300 * If it returns H_LONG_BUSY_* it should be retried periodically until it
301 * returns H_SUCCESS.
302 */
303static inline long disable_reloc_on_exceptions(void) {
60666de2 304 return plpar_set_mode(0, H_SET_MODE_RESOURCE_ADDR_TRANS_MODE, 0, 0);
798042da
IM
305}
306
e844b1ee
AB
307/*
308 * Take exceptions in big endian mode on this partition
309 *
310 * Note: this call has a partition wide scope and can take a while to complete.
311 * If it returns H_LONG_BUSY_* it should be retried periodically until it
312 * returns H_SUCCESS.
313 */
314static inline long enable_big_endian_exceptions(void)
315{
316 /* mflags = 0: big endian exceptions */
60666de2 317 return plpar_set_mode(0, H_SET_MODE_RESOURCE_LE, 0, 0);
e844b1ee
AB
318}
319
320/*
321 * Take exceptions in little endian mode on this partition
322 *
323 * Note: this call has a partition wide scope and can take a while to complete.
324 * If it returns H_LONG_BUSY_* it should be retried periodically until it
325 * returns H_SUCCESS.
326 */
327static inline long enable_little_endian_exceptions(void)
328{
329 /* mflags = 1: little endian exceptions */
60666de2 330 return plpar_set_mode(1, H_SET_MODE_RESOURCE_LE, 0, 0);
e844b1ee
AB
331}
332
376a8646
IM
333static inline long plapr_set_ciabr(unsigned long ciabr)
334{
60666de2 335 return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_CIABR, ciabr, 0);
376a8646
IM
336}
337
338static inline long plapr_set_watchpoint0(unsigned long dawr0, unsigned long dawrx0)
339{
60666de2 340 return plpar_set_mode(0, H_SET_MODE_RESOURCE_SET_DAWR, dawr0, dawrx0);
376a8646
IM
341}
342
212bebb4 343#endif /* _ASM_POWERPC_PLPAR_WRAPPERS_H */
This page took 0.650328 seconds and 5 git commands to generate.