aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/include
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /arch/powerpc/include
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'arch/powerpc/include')
-rw-r--r--arch/powerpc/include/asm/8xx_immap.h8
-rw-r--r--arch/powerpc/include/asm/bitops.h95
-rw-r--r--arch/powerpc/include/asm/checksum.h10
-rw-r--r--arch/powerpc/include/asm/compat.h6
-rw-r--r--arch/powerpc/include/asm/cpm.h2
-rw-r--r--arch/powerpc/include/asm/cpm1.h2
-rw-r--r--arch/powerpc/include/asm/cputable.h77
-rw-r--r--arch/powerpc/include/asm/cputhreads.h27
-rw-r--r--arch/powerpc/include/asm/cputime.h12
-rw-r--r--arch/powerpc/include/asm/dbell.h3
-rw-r--r--arch/powerpc/include/asm/device.h6
-rw-r--r--arch/powerpc/include/asm/dma-mapping.h20
-rw-r--r--arch/powerpc/include/asm/elf.h2
-rw-r--r--arch/powerpc/include/asm/emulated_ops.h4
-rw-r--r--arch/powerpc/include/asm/exception-64s.h116
-rw-r--r--arch/powerpc/include/asm/feature-fixups.h40
-rw-r--r--arch/powerpc/include/asm/firmware.h4
-rw-r--r--arch/powerpc/include/asm/fsl_85xx_cache_sram.h48
-rw-r--r--arch/powerpc/include/asm/fsl_guts.h (renamed from arch/powerpc/include/asm/immap_86xx.h)111
-rw-r--r--arch/powerpc/include/asm/fsl_lbc.h36
-rw-r--r--arch/powerpc/include/asm/fsldma.h137
-rw-r--r--arch/powerpc/include/asm/ftrace.h14
-rw-r--r--arch/powerpc/include/asm/futex.h27
-rw-r--r--arch/powerpc/include/asm/highmem.h9
-rw-r--r--arch/powerpc/include/asm/hvcall.h18
-rw-r--r--arch/powerpc/include/asm/hw_irq.h115
-rw-r--r--arch/powerpc/include/asm/hydra.h2
-rw-r--r--arch/powerpc/include/asm/immap_qe.h21
-rw-r--r--arch/powerpc/include/asm/io-workarounds.h48
-rw-r--r--arch/powerpc/include/asm/io.h33
-rw-r--r--arch/powerpc/include/asm/io_event_irq.h54
-rw-r--r--arch/powerpc/include/asm/ioctls.h2
-rw-r--r--arch/powerpc/include/asm/irq.h18
-rw-r--r--arch/powerpc/include/asm/irqflags.h42
-rw-r--r--arch/powerpc/include/asm/kexec.h3
-rw-r--r--arch/powerpc/include/asm/kgdb.h1
-rw-r--r--arch/powerpc/include/asm/kprobes.h2
-rw-r--r--arch/powerpc/include/asm/kvm.h185
-rw-r--r--arch/powerpc/include/asm/kvm_44x.h1
-rw-r--r--arch/powerpc/include/asm/kvm_asm.h5
-rw-r--r--arch/powerpc/include/asm/kvm_book3s.h31
-rw-r--r--arch/powerpc/include/asm/kvm_book3s_asm.h1
-rw-r--r--arch/powerpc/include/asm/kvm_e500.h2
-rw-r--r--arch/powerpc/include/asm/kvm_fpu.h4
-rw-r--r--arch/powerpc/include/asm/kvm_host.h26
-rw-r--r--arch/powerpc/include/asm/kvm_para.h139
-rw-r--r--arch/powerpc/include/asm/kvm_ppc.h10
-rw-r--r--arch/powerpc/include/asm/lppaca.h54
-rw-r--r--arch/powerpc/include/asm/machdep.h44
-rw-r--r--arch/powerpc/include/asm/memblock.h7
-rw-r--r--arch/powerpc/include/asm/mmu-book3e.h43
-rw-r--r--arch/powerpc/include/asm/mmu-hash64.h8
-rw-r--r--arch/powerpc/include/asm/mmu.h64
-rw-r--r--arch/powerpc/include/asm/mmu_context.h12
-rw-r--r--arch/powerpc/include/asm/mmzone.h12
-rw-r--r--arch/powerpc/include/asm/mpic.h18
-rw-r--r--arch/powerpc/include/asm/nvram.h53
-rw-r--r--arch/powerpc/include/asm/pSeries_reconfig.h5
-rw-r--r--arch/powerpc/include/asm/paca.h23
-rw-r--r--arch/powerpc/include/asm/page.h4
-rw-r--r--arch/powerpc/include/asm/page_64.h27
-rw-r--r--arch/powerpc/include/asm/pasemi_dma.h2
-rw-r--r--arch/powerpc/include/asm/pci-bridge.h39
-rw-r--r--arch/powerpc/include/asm/pci.h2
-rw-r--r--arch/powerpc/include/asm/pgalloc.h21
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc32.h8
-rw-r--r--arch/powerpc/include/asm/pgtable-ppc64.h15
-rw-r--r--arch/powerpc/include/asm/pgtable.h1
-rw-r--r--arch/powerpc/include/asm/pmac_feature.h4
-rw-r--r--arch/powerpc/include/asm/ppc-opcode.h43
-rw-r--r--arch/powerpc/include/asm/ppc-pci.h4
-rw-r--r--arch/powerpc/include/asm/ppc_asm.h51
-rw-r--r--arch/powerpc/include/asm/processor.h10
-rw-r--r--arch/powerpc/include/asm/prom.h20
-rw-r--r--arch/powerpc/include/asm/pte-common.h11
-rw-r--r--arch/powerpc/include/asm/pte-hash64-64k.h2
-rw-r--r--arch/powerpc/include/asm/ptrace.h2
-rw-r--r--arch/powerpc/include/asm/qe_ic.h19
-rw-r--r--arch/powerpc/include/asm/reg.h119
-rw-r--r--arch/powerpc/include/asm/reg_a2.h165
-rw-r--r--arch/powerpc/include/asm/reg_booke.h31
-rw-r--r--arch/powerpc/include/asm/rio.h5
-rw-r--r--arch/powerpc/include/asm/rtas.h46
-rw-r--r--arch/powerpc/include/asm/rwsem.h51
-rw-r--r--arch/powerpc/include/asm/scom.h156
-rw-r--r--arch/powerpc/include/asm/smp.h41
-rw-r--r--arch/powerpc/include/asm/spu.h8
-rw-r--r--arch/powerpc/include/asm/spu_priv1.h2
-rw-r--r--arch/powerpc/include/asm/suspend.h6
-rw-r--r--arch/powerpc/include/asm/syscall.h5
-rw-r--r--arch/powerpc/include/asm/systbl.h25
-rw-r--r--arch/powerpc/include/asm/system.h10
-rw-r--r--arch/powerpc/include/asm/thread_info.h11
-rw-r--r--arch/powerpc/include/asm/time.h5
-rw-r--r--arch/powerpc/include/asm/tlbflush.h2
-rw-r--r--arch/powerpc/include/asm/topology.h15
-rw-r--r--arch/powerpc/include/asm/types.h7
-rw-r--r--arch/powerpc/include/asm/udbg.h1
-rw-r--r--arch/powerpc/include/asm/uninorth.h2
-rw-r--r--arch/powerpc/include/asm/unistd.h27
-rw-r--r--arch/powerpc/include/asm/vdso_datapage.h4
-rw-r--r--arch/powerpc/include/asm/wsp.h14
-rw-r--r--arch/powerpc/include/asm/xics.h142
103 files changed, 2251 insertions, 856 deletions
diff --git a/arch/powerpc/include/asm/8xx_immap.h b/arch/powerpc/include/asm/8xx_immap.h
index 4b0e15206006..bdf0563ba423 100644
--- a/arch/powerpc/include/asm/8xx_immap.h
+++ b/arch/powerpc/include/asm/8xx_immap.h
@@ -93,7 +93,7 @@ typedef struct mem_ctlr {
93} memctl8xx_t; 93} memctl8xx_t;
94 94
95/*----------------------------------------------------------------------- 95/*-----------------------------------------------------------------------
96 * BR - Memory Controler: Base Register 16-9 96 * BR - Memory Controller: Base Register 16-9
97 */ 97 */
98#define BR_BA_MSK 0xffff8000 /* Base Address Mask */ 98#define BR_BA_MSK 0xffff8000 /* Base Address Mask */
99#define BR_AT_MSK 0x00007000 /* Address Type Mask */ 99#define BR_AT_MSK 0x00007000 /* Address Type Mask */
@@ -110,7 +110,7 @@ typedef struct mem_ctlr {
110#define BR_V 0x00000001 /* Bank Valid */ 110#define BR_V 0x00000001 /* Bank Valid */
111 111
112/*----------------------------------------------------------------------- 112/*-----------------------------------------------------------------------
113 * OR - Memory Controler: Option Register 16-11 113 * OR - Memory Controller: Option Register 16-11
114 */ 114 */
115#define OR_AM_MSK 0xffff8000 /* Address Mask Mask */ 115#define OR_AM_MSK 0xffff8000 /* Address Mask Mask */
116#define OR_ATM_MSK 0x00007000 /* Address Type Mask Mask */ 116#define OR_ATM_MSK 0x00007000 /* Address Type Mask Mask */
@@ -393,8 +393,8 @@ typedef struct fec {
393 uint fec_addr_low; /* lower 32 bits of station address */ 393 uint fec_addr_low; /* lower 32 bits of station address */
394 ushort fec_addr_high; /* upper 16 bits of station address */ 394 ushort fec_addr_high; /* upper 16 bits of station address */
395 ushort res1; /* reserved */ 395 ushort res1; /* reserved */
396 uint fec_hash_table_high; /* upper 32-bits of hash table */ 396 uint fec_grp_hash_table_high; /* upper 32-bits of hash table */
397 uint fec_hash_table_low; /* lower 32-bits of hash table */ 397 uint fec_grp_hash_table_low; /* lower 32-bits of hash table */
398 uint fec_r_des_start; /* beginning of Rx descriptor ring */ 398 uint fec_r_des_start; /* beginning of Rx descriptor ring */
399 uint fec_x_des_start; /* beginning of Tx descriptor ring */ 399 uint fec_x_des_start; /* beginning of Tx descriptor ring */
400 uint fec_r_buff_size; /* Rx buffer size */ 400 uint fec_r_buff_size; /* Rx buffer size */
diff --git a/arch/powerpc/include/asm/bitops.h b/arch/powerpc/include/asm/bitops.h
index 30964ae2d096..f18c6d9b9510 100644
--- a/arch/powerpc/include/asm/bitops.h
+++ b/arch/powerpc/include/asm/bitops.h
@@ -209,8 +209,8 @@ static __inline__ unsigned long ffz(unsigned long x)
209 return BITS_PER_LONG; 209 return BITS_PER_LONG;
210 210
211 /* 211 /*
212 * Calculate the bit position of the least signficant '1' bit in x 212 * Calculate the bit position of the least significant '1' bit in x
213 * (since x has been changed this will actually be the least signficant 213 * (since x has been changed this will actually be the least significant
214 * '0' bit in * the original x). Note: (x & -x) gives us a mask that 214 * '0' bit in * the original x). Note: (x & -x) gives us a mask that
215 * is the least significant * (RIGHT-most) 1-bit of the value in x. 215 * is the least significant * (RIGHT-most) 1-bit of the value in x.
216 */ 216 */
@@ -267,73 +267,70 @@ static __inline__ int fls64(__u64 x)
267#include <asm-generic/bitops/fls64.h> 267#include <asm-generic/bitops/fls64.h>
268#endif /* __powerpc64__ */ 268#endif /* __powerpc64__ */
269 269
270#ifdef CONFIG_PPC64
271unsigned int __arch_hweight8(unsigned int w);
272unsigned int __arch_hweight16(unsigned int w);
273unsigned int __arch_hweight32(unsigned int w);
274unsigned long __arch_hweight64(__u64 w);
275#include <asm-generic/bitops/const_hweight.h>
276#else
270#include <asm-generic/bitops/hweight.h> 277#include <asm-generic/bitops/hweight.h>
278#endif
279
271#include <asm-generic/bitops/find.h> 280#include <asm-generic/bitops/find.h>
272 281
273/* Little-endian versions */ 282/* Little-endian versions */
274 283
275static __inline__ int test_le_bit(unsigned long nr, 284static __inline__ int test_bit_le(unsigned long nr,
276 __const__ unsigned long *addr) 285 __const__ void *addr)
277{ 286{
278 __const__ unsigned char *tmp = (__const__ unsigned char *) addr; 287 __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
279 return (tmp[nr >> 3] >> (nr & 7)) & 1; 288 return (tmp[nr >> 3] >> (nr & 7)) & 1;
280} 289}
281 290
282#define __set_le_bit(nr, addr) \ 291static inline void __set_bit_le(int nr, void *addr)
283 __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 292{
284#define __clear_le_bit(nr, addr) \ 293 __set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
285 __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 294}
286 295
287#define test_and_set_le_bit(nr, addr) \ 296static inline void __clear_bit_le(int nr, void *addr)
288 test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 297{
289#define test_and_clear_le_bit(nr, addr) \ 298 __clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
290 test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 299}
291 300
292#define __test_and_set_le_bit(nr, addr) \ 301static inline int test_and_set_bit_le(int nr, void *addr)
293 __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 302{
294#define __test_and_clear_le_bit(nr, addr) \ 303 return test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
295 __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr)) 304}
296 305
297#define find_first_zero_le_bit(addr, size) generic_find_next_zero_le_bit((addr), (size), 0) 306static inline int test_and_clear_bit_le(int nr, void *addr)
298unsigned long generic_find_next_zero_le_bit(const unsigned long *addr, 307{
308 return test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
309}
310
311static inline int __test_and_set_bit_le(int nr, void *addr)
312{
313 return __test_and_set_bit(nr ^ BITOP_LE_SWIZZLE, addr);
314}
315
316static inline int __test_and_clear_bit_le(int nr, void *addr)
317{
318 return __test_and_clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
319}
320
321#define find_first_zero_bit_le(addr, size) \
322 find_next_zero_bit_le((addr), (size), 0)
323unsigned long find_next_zero_bit_le(const void *addr,
299 unsigned long size, unsigned long offset); 324 unsigned long size, unsigned long offset);
300 325
301unsigned long generic_find_next_le_bit(const unsigned long *addr, 326unsigned long find_next_bit_le(const void *addr,
302 unsigned long size, unsigned long offset); 327 unsigned long size, unsigned long offset);
303/* Bitmap functions for the ext2 filesystem */ 328/* Bitmap functions for the ext2 filesystem */
304 329
305#define ext2_set_bit(nr,addr) \
306 __test_and_set_le_bit((nr), (unsigned long*)addr)
307#define ext2_clear_bit(nr, addr) \
308 __test_and_clear_le_bit((nr), (unsigned long*)addr)
309
310#define ext2_set_bit_atomic(lock, nr, addr) \ 330#define ext2_set_bit_atomic(lock, nr, addr) \
311 test_and_set_le_bit((nr), (unsigned long*)addr) 331 test_and_set_bit_le((nr), (unsigned long*)addr)
312#define ext2_clear_bit_atomic(lock, nr, addr) \ 332#define ext2_clear_bit_atomic(lock, nr, addr) \
313 test_and_clear_le_bit((nr), (unsigned long*)addr) 333 test_and_clear_bit_le((nr), (unsigned long*)addr)
314
315#define ext2_test_bit(nr, addr) test_le_bit((nr),(unsigned long*)addr)
316
317#define ext2_find_first_zero_bit(addr, size) \
318 find_first_zero_le_bit((unsigned long*)addr, size)
319#define ext2_find_next_zero_bit(addr, size, off) \
320 generic_find_next_zero_le_bit((unsigned long*)addr, size, off)
321
322#define ext2_find_next_bit(addr, size, off) \
323 generic_find_next_le_bit((unsigned long *)addr, size, off)
324/* Bitmap functions for the minix filesystem. */
325
326#define minix_test_and_set_bit(nr,addr) \
327 __test_and_set_le_bit(nr, (unsigned long *)addr)
328#define minix_set_bit(nr,addr) \
329 __set_le_bit(nr, (unsigned long *)addr)
330#define minix_test_and_clear_bit(nr,addr) \
331 __test_and_clear_le_bit(nr, (unsigned long *)addr)
332#define minix_test_bit(nr,addr) \
333 test_le_bit(nr, (unsigned long *)addr)
334
335#define minix_find_first_zero_bit(addr,size) \
336 find_first_zero_le_bit((unsigned long *)addr, size)
337 334
338#include <asm-generic/bitops/sched.h> 335#include <asm-generic/bitops/sched.h>
339 336
diff --git a/arch/powerpc/include/asm/checksum.h b/arch/powerpc/include/asm/checksum.h
index 7cdf358337cf..ce0c28495f9a 100644
--- a/arch/powerpc/include/asm/checksum.h
+++ b/arch/powerpc/include/asm/checksum.h
@@ -52,12 +52,22 @@ extern __wsum csum_partial(const void *buff, int len, __wsum sum);
52extern __wsum csum_partial_copy_generic(const void *src, void *dst, 52extern __wsum csum_partial_copy_generic(const void *src, void *dst,
53 int len, __wsum sum, 53 int len, __wsum sum,
54 int *src_err, int *dst_err); 54 int *src_err, int *dst_err);
55
56#ifdef __powerpc64__
57#define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER
58extern __wsum csum_and_copy_from_user(const void __user *src, void *dst,
59 int len, __wsum sum, int *err_ptr);
60#define HAVE_CSUM_COPY_USER
61extern __wsum csum_and_copy_to_user(const void *src, void __user *dst,
62 int len, __wsum sum, int *err_ptr);
63#else
55/* 64/*
56 * the same as csum_partial, but copies from src to dst while it 65 * the same as csum_partial, but copies from src to dst while it
57 * checksums. 66 * checksums.
58 */ 67 */
59#define csum_partial_copy_from_user(src, dst, len, sum, errp) \ 68#define csum_partial_copy_from_user(src, dst, len, sum, errp) \
60 csum_partial_copy_generic((__force const void *)(src), (dst), (len), (sum), (errp), NULL) 69 csum_partial_copy_generic((__force const void *)(src), (dst), (len), (sum), (errp), NULL)
70#endif
61 71
62#define csum_partial_copy_nocheck(src, dst, len, sum) \ 72#define csum_partial_copy_nocheck(src, dst, len, sum) \
63 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL) 73 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL)
diff --git a/arch/powerpc/include/asm/compat.h b/arch/powerpc/include/asm/compat.h
index a11d4eac4f97..91010e8f8479 100644
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -140,10 +140,10 @@ static inline void __user *arch_compat_alloc_user_space(long len)
140 unsigned long usp = regs->gpr[1]; 140 unsigned long usp = regs->gpr[1];
141 141
142 /* 142 /*
143 * We cant access below the stack pointer in the 32bit ABI and 143 * We can't access below the stack pointer in the 32bit ABI and
144 * can access 288 bytes in the 64bit ABI 144 * can access 288 bytes in the 64bit ABI
145 */ 145 */
146 if (!(test_thread_flag(TIF_32BIT))) 146 if (!is_32bit_task())
147 usp -= 288; 147 usp -= 288;
148 148
149 return (void __user *) (usp - len); 149 return (void __user *) (usp - len);
@@ -213,7 +213,7 @@ struct compat_shmid64_ds {
213 213
214static inline int is_compat_task(void) 214static inline int is_compat_task(void)
215{ 215{
216 return test_thread_flag(TIF_32BIT); 216 return is_32bit_task();
217} 217}
218 218
219#endif /* __KERNEL__ */ 219#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/cpm.h b/arch/powerpc/include/asm/cpm.h
index e50323fe941f..4398a6cdcf53 100644
--- a/arch/powerpc/include/asm/cpm.h
+++ b/arch/powerpc/include/asm/cpm.h
@@ -98,7 +98,7 @@ typedef struct cpm_buf_desc {
98#define BD_SC_INTRPT (0x1000) /* Interrupt on change */ 98#define BD_SC_INTRPT (0x1000) /* Interrupt on change */
99#define BD_SC_LAST (0x0800) /* Last buffer in frame */ 99#define BD_SC_LAST (0x0800) /* Last buffer in frame */
100#define BD_SC_TC (0x0400) /* Transmit CRC */ 100#define BD_SC_TC (0x0400) /* Transmit CRC */
101#define BD_SC_CM (0x0200) /* Continous mode */ 101#define BD_SC_CM (0x0200) /* Continuous mode */
102#define BD_SC_ID (0x0100) /* Rec'd too many idles */ 102#define BD_SC_ID (0x0100) /* Rec'd too many idles */
103#define BD_SC_P (0x0100) /* xmt preamble */ 103#define BD_SC_P (0x0100) /* xmt preamble */
104#define BD_SC_BR (0x0020) /* Break received */ 104#define BD_SC_BR (0x0020) /* Break received */
diff --git a/arch/powerpc/include/asm/cpm1.h b/arch/powerpc/include/asm/cpm1.h
index bd07650dca56..8ee4211ca0c6 100644
--- a/arch/powerpc/include/asm/cpm1.h
+++ b/arch/powerpc/include/asm/cpm1.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * This file contains structures and information for the communication 5 * This file contains structures and information for the communication
6 * processor channels. Some CPM control and status is available 6 * processor channels. Some CPM control and status is available
7 * throught the MPC8xx internal memory map. See immap.h for details. 7 * through the MPC8xx internal memory map. See immap.h for details.
8 * This file only contains what I need for the moment, not the total 8 * This file only contains what I need for the moment, not the total
9 * CPM capabilities. I (or someone else) will add definitions as they 9 * CPM capabilities. I (or someone else) will add definitions as they
10 * are needed. -- Dan 10 * are needed. -- Dan
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h
index 3a40a992e594..c0d842cfd012 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -154,8 +154,10 @@ extern const char *powerpc_base_platform;
154#define CPU_FTR_NAP_DISABLE_L2_PR ASM_CONST(0x0000000000002000) 154#define CPU_FTR_NAP_DISABLE_L2_PR ASM_CONST(0x0000000000002000)
155#define CPU_FTR_DUAL_PLL_750FX ASM_CONST(0x0000000000004000) 155#define CPU_FTR_DUAL_PLL_750FX ASM_CONST(0x0000000000004000)
156#define CPU_FTR_NO_DPM ASM_CONST(0x0000000000008000) 156#define CPU_FTR_NO_DPM ASM_CONST(0x0000000000008000)
157#define CPU_FTR_476_DD2 ASM_CONST(0x0000000000010000)
157#define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000) 158#define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000)
158#define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000) 159#define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000)
160#define CPU_FTR_DEBUG_LVL_EXC ASM_CONST(0x0000000000080000)
159#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000) 161#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000)
160#define CPU_FTR_PPC_LE ASM_CONST(0x0000000000200000) 162#define CPU_FTR_PPC_LE ASM_CONST(0x0000000000200000)
161#define CPU_FTR_REAL_LE ASM_CONST(0x0000000000400000) 163#define CPU_FTR_REAL_LE ASM_CONST(0x0000000000400000)
@@ -177,33 +179,34 @@ extern const char *powerpc_base_platform;
177#define LONG_ASM_CONST(x) 0 179#define LONG_ASM_CONST(x) 0
178#endif 180#endif
179 181
180#define CPU_FTR_SLB LONG_ASM_CONST(0x0000000100000000) 182
181#define CPU_FTR_16M_PAGE LONG_ASM_CONST(0x0000000200000000) 183#define CPU_FTR_HVMODE_206 LONG_ASM_CONST(0x0000000800000000)
182#define CPU_FTR_TLBIEL LONG_ASM_CONST(0x0000000400000000) 184#define CPU_FTR_CFAR LONG_ASM_CONST(0x0000001000000000)
183#define CPU_FTR_IABR LONG_ASM_CONST(0x0000002000000000) 185#define CPU_FTR_IABR LONG_ASM_CONST(0x0000002000000000)
184#define CPU_FTR_MMCRA LONG_ASM_CONST(0x0000004000000000) 186#define CPU_FTR_MMCRA LONG_ASM_CONST(0x0000004000000000)
185#define CPU_FTR_CTRL LONG_ASM_CONST(0x0000008000000000) 187#define CPU_FTR_CTRL LONG_ASM_CONST(0x0000008000000000)
186#define CPU_FTR_SMT LONG_ASM_CONST(0x0000010000000000) 188#define CPU_FTR_SMT LONG_ASM_CONST(0x0000010000000000)
187#define CPU_FTR_LOCKLESS_TLBIE LONG_ASM_CONST(0x0000040000000000)
188#define CPU_FTR_CI_LARGE_PAGE LONG_ASM_CONST(0x0000100000000000)
189#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000) 189#define CPU_FTR_PAUSE_ZERO LONG_ASM_CONST(0x0000200000000000)
190#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000) 190#define CPU_FTR_PURR LONG_ASM_CONST(0x0000400000000000)
191#define CPU_FTR_CELL_TB_BUG LONG_ASM_CONST(0x0000800000000000) 191#define CPU_FTR_CELL_TB_BUG LONG_ASM_CONST(0x0000800000000000)
192#define CPU_FTR_SPURR LONG_ASM_CONST(0x0001000000000000) 192#define CPU_FTR_SPURR LONG_ASM_CONST(0x0001000000000000)
193#define CPU_FTR_DSCR LONG_ASM_CONST(0x0002000000000000) 193#define CPU_FTR_DSCR LONG_ASM_CONST(0x0002000000000000)
194#define CPU_FTR_1T_SEGMENT LONG_ASM_CONST(0x0004000000000000)
195#define CPU_FTR_NO_SLBIE_B LONG_ASM_CONST(0x0008000000000000)
196#define CPU_FTR_VSX LONG_ASM_CONST(0x0010000000000000) 194#define CPU_FTR_VSX LONG_ASM_CONST(0x0010000000000000)
197#define CPU_FTR_SAO LONG_ASM_CONST(0x0020000000000000) 195#define CPU_FTR_SAO LONG_ASM_CONST(0x0020000000000000)
198#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0040000000000000) 196#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0040000000000000)
199#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0080000000000000) 197#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0080000000000000)
200#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0100000000000000) 198#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0100000000000000)
199#define CPU_FTR_STCX_CHECKS_ADDRESS LONG_ASM_CONST(0x0200000000000000)
200#define CPU_FTR_POPCNTB LONG_ASM_CONST(0x0400000000000000)
201#define CPU_FTR_POPCNTD LONG_ASM_CONST(0x0800000000000000)
202#define CPU_FTR_ICSWX LONG_ASM_CONST(0x1000000000000000)
201 203
202#ifndef __ASSEMBLY__ 204#ifndef __ASSEMBLY__
203 205
204#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_SLB | \ 206#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_NOEXECUTE | CPU_FTR_NODSISRALIGN)
205 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \ 207
206 CPU_FTR_NODSISRALIGN | CPU_FTR_16M_PAGE) 208#define MMU_FTR_PPCAS_ARCH_V2 (MMU_FTR_SLB | MMU_FTR_TLBIEL | \
209 MMU_FTR_16M_PAGE)
207 210
208/* We only set the altivec features if the kernel was compiled with altivec 211/* We only set the altivec features if the kernel was compiled with altivec
209 * support 212 * support
@@ -378,10 +381,13 @@ extern const char *powerpc_base_platform;
378#define CPU_FTRS_E500_2 (CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | \ 381#define CPU_FTRS_E500_2 (CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | \
379 CPU_FTR_SPE_COMP | CPU_FTR_MAYBE_CAN_NAP | \ 382 CPU_FTR_SPE_COMP | CPU_FTR_MAYBE_CAN_NAP | \
380 CPU_FTR_NODSISRALIGN | CPU_FTR_NOEXECUTE) 383 CPU_FTR_NODSISRALIGN | CPU_FTR_NOEXECUTE)
381#define CPU_FTRS_E500MC (CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | \ 384#define CPU_FTRS_E500MC (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
382 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_NODSISRALIGN | \
383 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \ 385 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
384 CPU_FTR_DBELL) 386 CPU_FTR_DBELL)
387#define CPU_FTRS_E5500 (CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN | \
388 CPU_FTR_L2CSR | CPU_FTR_LWSYNC | CPU_FTR_NOEXECUTE | \
389 CPU_FTR_DBELL | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
390 CPU_FTR_DEBUG_LVL_EXC)
385#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN) 391#define CPU_FTRS_GENERIC_32 (CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN)
386 392
387/* 64-bit CPUs */ 393/* 64-bit CPUs */
@@ -392,46 +398,55 @@ extern const char *powerpc_base_platform;
392 CPU_FTR_MMCRA | CPU_FTR_CTRL) 398 CPU_FTR_MMCRA | CPU_FTR_CTRL)
393#define CPU_FTRS_POWER4 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 399#define CPU_FTRS_POWER4 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
394 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 400 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
395 CPU_FTR_MMCRA | CPU_FTR_CP_USE_DCBTZ) 401 CPU_FTR_MMCRA | CPU_FTR_CP_USE_DCBTZ | \
402 CPU_FTR_STCX_CHECKS_ADDRESS)
396#define CPU_FTRS_PPC970 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 403#define CPU_FTRS_PPC970 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
397 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 404 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
398 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA | \ 405 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA | \
399 CPU_FTR_CP_USE_DCBTZ) 406 CPU_FTR_CP_USE_DCBTZ | CPU_FTR_STCX_CHECKS_ADDRESS)
400#define CPU_FTRS_POWER5 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 407#define CPU_FTRS_POWER5 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
401 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 408 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
402 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 409 CPU_FTR_MMCRA | CPU_FTR_SMT | \
403 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 410 CPU_FTR_COHERENT_ICACHE | CPU_FTR_PURR | \
404 CPU_FTR_PURR) 411 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB)
405#define CPU_FTRS_POWER6 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 412#define CPU_FTRS_POWER6 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
406 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 413 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
407 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 414 CPU_FTR_MMCRA | CPU_FTR_SMT | \
408 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 415 CPU_FTR_COHERENT_ICACHE | \
409 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \ 416 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
410 CPU_FTR_DSCR | CPU_FTR_UNALIGNED_LD_STD) 417 CPU_FTR_DSCR | CPU_FTR_UNALIGNED_LD_STD | \
418 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_CFAR)
411#define CPU_FTRS_POWER7 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 419#define CPU_FTRS_POWER7 (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
412 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 420 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | CPU_FTR_HVMODE_206 |\
413 CPU_FTR_MMCRA | CPU_FTR_SMT | \ 421 CPU_FTR_MMCRA | CPU_FTR_SMT | \
414 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE | \ 422 CPU_FTR_COHERENT_ICACHE | \
415 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \ 423 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
416 CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT) 424 CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT | \
425 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
426 CPU_FTR_ICSWX | CPU_FTR_CFAR)
417#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 427#define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
418 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ 428 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
419 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ 429 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
420 CPU_FTR_PAUSE_ZERO | CPU_FTR_CI_LARGE_PAGE | \ 430 CPU_FTR_PAUSE_ZERO | CPU_FTR_CELL_TB_BUG | CPU_FTR_CP_USE_DCBTZ | \
421 CPU_FTR_CELL_TB_BUG | CPU_FTR_CP_USE_DCBTZ | \
422 CPU_FTR_UNALIGNED_LD_STD) 431 CPU_FTR_UNALIGNED_LD_STD)
423#define CPU_FTRS_PA6T (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ 432#define CPU_FTRS_PA6T (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \
424 CPU_FTR_PPCAS_ARCH_V2 | \ 433 CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_ALTIVEC_COMP | \
425 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CI_LARGE_PAGE | \ 434 CPU_FTR_PURR | CPU_FTR_REAL_LE)
426 CPU_FTR_PURR | CPU_FTR_REAL_LE | CPU_FTR_NO_SLBIE_B)
427#define CPU_FTRS_COMPATIBLE (CPU_FTR_USE_TB | CPU_FTR_PPCAS_ARCH_V2) 435#define CPU_FTRS_COMPATIBLE (CPU_FTR_USE_TB | CPU_FTR_PPCAS_ARCH_V2)
428 436
437#define CPU_FTRS_A2 (CPU_FTR_USE_TB | CPU_FTR_SMT | CPU_FTR_DBELL | \
438 CPU_FTR_NOEXECUTE | CPU_FTR_NODSISRALIGN)
439
429#ifdef __powerpc64__ 440#ifdef __powerpc64__
441#ifdef CONFIG_PPC_BOOK3E
442#define CPU_FTRS_POSSIBLE (CPU_FTRS_E5500 | CPU_FTRS_A2)
443#else
430#define CPU_FTRS_POSSIBLE \ 444#define CPU_FTRS_POSSIBLE \
431 (CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 | \ 445 (CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 | \
432 CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_POWER6 | \ 446 CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_POWER6 | \
433 CPU_FTRS_POWER7 | CPU_FTRS_CELL | CPU_FTRS_PA6T | \ 447 CPU_FTRS_POWER7 | CPU_FTRS_CELL | CPU_FTRS_PA6T | \
434 CPU_FTR_1T_SEGMENT | CPU_FTR_VSX) 448 CPU_FTR_VSX)
449#endif
435#else 450#else
436enum { 451enum {
437 CPU_FTRS_POSSIBLE = 452 CPU_FTRS_POSSIBLE =
@@ -458,23 +473,28 @@ enum {
458 CPU_FTRS_44X | CPU_FTRS_440x6 | 473 CPU_FTRS_44X | CPU_FTRS_440x6 |
459#endif 474#endif
460#ifdef CONFIG_PPC_47x 475#ifdef CONFIG_PPC_47x
461 CPU_FTRS_47X | 476 CPU_FTRS_47X | CPU_FTR_476_DD2 |
462#endif 477#endif
463#ifdef CONFIG_E200 478#ifdef CONFIG_E200
464 CPU_FTRS_E200 | 479 CPU_FTRS_E200 |
465#endif 480#endif
466#ifdef CONFIG_E500 481#ifdef CONFIG_E500
467 CPU_FTRS_E500 | CPU_FTRS_E500_2 | CPU_FTRS_E500MC | 482 CPU_FTRS_E500 | CPU_FTRS_E500_2 | CPU_FTRS_E500MC |
483 CPU_FTRS_E5500 |
468#endif 484#endif
469 0, 485 0,
470}; 486};
471#endif /* __powerpc64__ */ 487#endif /* __powerpc64__ */
472 488
473#ifdef __powerpc64__ 489#ifdef __powerpc64__
490#ifdef CONFIG_PPC_BOOK3E
491#define CPU_FTRS_ALWAYS (CPU_FTRS_E5500 & CPU_FTRS_A2)
492#else
474#define CPU_FTRS_ALWAYS \ 493#define CPU_FTRS_ALWAYS \
475 (CPU_FTRS_POWER3 & CPU_FTRS_RS64 & CPU_FTRS_POWER4 & \ 494 (CPU_FTRS_POWER3 & CPU_FTRS_RS64 & CPU_FTRS_POWER4 & \
476 CPU_FTRS_PPC970 & CPU_FTRS_POWER5 & CPU_FTRS_POWER6 & \ 495 CPU_FTRS_PPC970 & CPU_FTRS_POWER5 & CPU_FTRS_POWER6 & \
477 CPU_FTRS_POWER7 & CPU_FTRS_CELL & CPU_FTRS_PA6T & CPU_FTRS_POSSIBLE) 496 CPU_FTRS_POWER7 & CPU_FTRS_CELL & CPU_FTRS_PA6T & CPU_FTRS_POSSIBLE)
497#endif
478#else 498#else
479enum { 499enum {
480 CPU_FTRS_ALWAYS = 500 CPU_FTRS_ALWAYS =
@@ -505,6 +525,7 @@ enum {
505#endif 525#endif
506#ifdef CONFIG_E500 526#ifdef CONFIG_E500
507 CPU_FTRS_E500 & CPU_FTRS_E500_2 & CPU_FTRS_E500MC & 527 CPU_FTRS_E500 & CPU_FTRS_E500_2 & CPU_FTRS_E500MC &
528 CPU_FTRS_E5500 &
508#endif 529#endif
509 CPU_FTRS_POSSIBLE, 530 CPU_FTRS_POSSIBLE,
510}; 531};
diff --git a/arch/powerpc/include/asm/cputhreads.h b/arch/powerpc/include/asm/cputhreads.h
index a8e18447c62b..ce516e5eb0d3 100644
--- a/arch/powerpc/include/asm/cputhreads.h
+++ b/arch/powerpc/include/asm/cputhreads.h
@@ -37,16 +37,16 @@ extern cpumask_t threads_core_mask;
37 * This can typically be used for things like IPI for tlb invalidations 37 * This can typically be used for things like IPI for tlb invalidations
38 * since those need to be done only once per core/TLB 38 * since those need to be done only once per core/TLB
39 */ 39 */
40static inline cpumask_t cpu_thread_mask_to_cores(cpumask_t threads) 40static inline cpumask_t cpu_thread_mask_to_cores(const struct cpumask *threads)
41{ 41{
42 cpumask_t tmp, res; 42 cpumask_t tmp, res;
43 int i; 43 int i;
44 44
45 res = CPU_MASK_NONE; 45 cpumask_clear(&res);
46 for (i = 0; i < NR_CPUS; i += threads_per_core) { 46 for (i = 0; i < NR_CPUS; i += threads_per_core) {
47 cpus_shift_left(tmp, threads_core_mask, i); 47 cpumask_shift_left(&tmp, &threads_core_mask, i);
48 if (cpus_intersects(threads, tmp)) 48 if (cpumask_intersects(threads, &tmp))
49 cpu_set(i, res); 49 cpumask_set_cpu(i, &res);
50 } 50 }
51 return res; 51 return res;
52} 52}
@@ -58,25 +58,28 @@ static inline int cpu_nr_cores(void)
58 58
59static inline cpumask_t cpu_online_cores_map(void) 59static inline cpumask_t cpu_online_cores_map(void)
60{ 60{
61 return cpu_thread_mask_to_cores(cpu_online_map); 61 return cpu_thread_mask_to_cores(cpu_online_mask);
62} 62}
63 63
64static inline int cpu_thread_to_core(int cpu) 64#ifdef CONFIG_SMP
65{ 65int cpu_core_index_of_thread(int cpu);
66 return cpu >> threads_shift; 66int cpu_first_thread_of_core(int core);
67} 67#else
68static inline int cpu_core_index_of_thread(int cpu) { return cpu; }
69static inline int cpu_first_thread_of_core(int core) { return core; }
70#endif
68 71
69static inline int cpu_thread_in_core(int cpu) 72static inline int cpu_thread_in_core(int cpu)
70{ 73{
71 return cpu & (threads_per_core - 1); 74 return cpu & (threads_per_core - 1);
72} 75}
73 76
74static inline int cpu_first_thread_in_core(int cpu) 77static inline int cpu_first_thread_sibling(int cpu)
75{ 78{
76 return cpu & ~(threads_per_core - 1); 79 return cpu & ~(threads_per_core - 1);
77} 80}
78 81
79static inline int cpu_last_thread_in_core(int cpu) 82static inline int cpu_last_thread_sibling(int cpu)
80{ 83{
81 return cpu | (threads_per_core - 1); 84 return cpu | (threads_per_core - 1);
82} 85}
diff --git a/arch/powerpc/include/asm/cputime.h b/arch/powerpc/include/asm/cputime.h
index 8bdc6a9e5773..1cf20bdfbeca 100644
--- a/arch/powerpc/include/asm/cputime.h
+++ b/arch/powerpc/include/asm/cputime.h
@@ -124,23 +124,23 @@ static inline u64 cputime64_to_jiffies64(const cputime_t ct)
124} 124}
125 125
126/* 126/*
127 * Convert cputime <-> milliseconds 127 * Convert cputime <-> microseconds
128 */ 128 */
129extern u64 __cputime_msec_factor; 129extern u64 __cputime_msec_factor;
130 130
131static inline unsigned long cputime_to_msecs(const cputime_t ct) 131static inline unsigned long cputime_to_usecs(const cputime_t ct)
132{ 132{
133 return mulhdu(ct, __cputime_msec_factor); 133 return mulhdu(ct, __cputime_msec_factor) * USEC_PER_MSEC;
134} 134}
135 135
136static inline cputime_t msecs_to_cputime(const unsigned long ms) 136static inline cputime_t usecs_to_cputime(const unsigned long us)
137{ 137{
138 cputime_t ct; 138 cputime_t ct;
139 unsigned long sec; 139 unsigned long sec;
140 140
141 /* have to be a little careful about overflow */ 141 /* have to be a little careful about overflow */
142 ct = ms % 1000; 142 ct = us % 1000000;
143 sec = ms / 1000; 143 sec = us / 1000000;
144 if (ct) { 144 if (ct) {
145 ct *= tb_ticks_per_sec; 145 ct *= tb_ticks_per_sec;
146 do_div(ct, 1000); 146 do_div(ct, 1000);
diff --git a/arch/powerpc/include/asm/dbell.h b/arch/powerpc/include/asm/dbell.h
index 0893ab9343a6..9c70d0ca96d4 100644
--- a/arch/powerpc/include/asm/dbell.h
+++ b/arch/powerpc/include/asm/dbell.h
@@ -27,9 +27,8 @@ enum ppc_dbell {
27 PPC_G_DBELL_MC = 4, /* guest mcheck doorbell */ 27 PPC_G_DBELL_MC = 4, /* guest mcheck doorbell */
28}; 28};
29 29
30extern void doorbell_message_pass(int target, int msg); 30extern void doorbell_cause_ipi(int cpu, unsigned long data);
31extern void doorbell_exception(struct pt_regs *regs); 31extern void doorbell_exception(struct pt_regs *regs);
32extern void doorbell_check_self(void);
33extern void doorbell_setup_this_cpu(void); 32extern void doorbell_setup_this_cpu(void);
34 33
35static inline void ppc_msgsnd(enum ppc_dbell type, u32 flags, u32 tag) 34static inline void ppc_msgsnd(enum ppc_dbell type, u32 flags, u32 tag)
diff --git a/arch/powerpc/include/asm/device.h b/arch/powerpc/include/asm/device.h
index a3954e4fcbe2..16d25c0974be 100644
--- a/arch/powerpc/include/asm/device.h
+++ b/arch/powerpc/include/asm/device.h
@@ -9,6 +9,12 @@
9struct dma_map_ops; 9struct dma_map_ops;
10struct device_node; 10struct device_node;
11 11
12/*
13 * Arch extensions to struct device.
14 *
15 * When adding fields, consider macio_add_one_device in
16 * drivers/macintosh/macio_asic.c
17 */
12struct dev_archdata { 18struct dev_archdata {
13 /* DMA operations on that device */ 19 /* DMA operations on that device */
14 struct dma_map_ops *dma_ops; 20 struct dma_map_ops *dma_ops;
diff --git a/arch/powerpc/include/asm/dma-mapping.h b/arch/powerpc/include/asm/dma-mapping.h
index 8c9c6ad2004e..dd70fac57ec8 100644
--- a/arch/powerpc/include/asm/dma-mapping.h
+++ b/arch/powerpc/include/asm/dma-mapping.h
@@ -42,6 +42,7 @@ extern void __dma_free_coherent(size_t size, void *vaddr);
42extern void __dma_sync(void *vaddr, size_t size, int direction); 42extern void __dma_sync(void *vaddr, size_t size, int direction);
43extern void __dma_sync_page(struct page *page, unsigned long offset, 43extern void __dma_sync_page(struct page *page, unsigned long offset,
44 size_t size, int direction); 44 size_t size, int direction);
45extern unsigned long __dma_get_coherent_pfn(unsigned long cpu_addr);
45 46
46#else /* ! CONFIG_NOT_COHERENT_CACHE */ 47#else /* ! CONFIG_NOT_COHERENT_CACHE */
47/* 48/*
@@ -127,19 +128,7 @@ static inline int dma_supported(struct device *dev, u64 mask)
127 return dma_ops->dma_supported(dev, mask); 128 return dma_ops->dma_supported(dev, mask);
128} 129}
129 130
130static inline int dma_set_mask(struct device *dev, u64 dma_mask) 131extern int dma_set_mask(struct device *dev, u64 dma_mask);
131{
132 struct dma_map_ops *dma_ops = get_dma_ops(dev);
133
134 if (unlikely(dma_ops == NULL))
135 return -EIO;
136 if (dma_ops->set_dma_mask != NULL)
137 return dma_ops->set_dma_mask(dev, dma_mask);
138 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
139 return -EIO;
140 *dev->dma_mask = dma_mask;
141 return 0;
142}
143 132
144static inline void *dma_alloc_coherent(struct device *dev, size_t size, 133static inline void *dma_alloc_coherent(struct device *dev, size_t size,
145 dma_addr_t *dma_handle, gfp_t flag) 134 dma_addr_t *dma_handle, gfp_t flag)
@@ -210,6 +199,11 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
210#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f) 199#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
211#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h) 200#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
212 201
202extern int dma_mmap_coherent(struct device *, struct vm_area_struct *,
203 void *, dma_addr_t, size_t);
204#define ARCH_HAS_DMA_MMAP_COHERENT
205
206
213static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size, 207static inline void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
214 enum dma_data_direction direction) 208 enum dma_data_direction direction)
215{ 209{
diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
index c376eda15313..2b917c69ed15 100644
--- a/arch/powerpc/include/asm/elf.h
+++ b/arch/powerpc/include/asm/elf.h
@@ -250,7 +250,7 @@ do { \
250 * the 64bit ABI has never had these issues dont enable the workaround 250 * the 64bit ABI has never had these issues dont enable the workaround
251 * even if we have an executable stack. 251 * even if we have an executable stack.
252 */ 252 */
253# define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \ 253# define elf_read_implies_exec(ex, exec_stk) (is_32bit_task() ? \
254 (exec_stk == EXSTACK_DEFAULT) : 0) 254 (exec_stk == EXSTACK_DEFAULT) : 0)
255#else 255#else
256# define SET_PERSONALITY(ex) \ 256# define SET_PERSONALITY(ex) \
diff --git a/arch/powerpc/include/asm/emulated_ops.h b/arch/powerpc/include/asm/emulated_ops.h
index f0fb4fc1f6e6..45921672b97a 100644
--- a/arch/powerpc/include/asm/emulated_ops.h
+++ b/arch/powerpc/include/asm/emulated_ops.h
@@ -52,6 +52,10 @@ extern struct ppc_emulated {
52#ifdef CONFIG_VSX 52#ifdef CONFIG_VSX
53 struct ppc_emulated_entry vsx; 53 struct ppc_emulated_entry vsx;
54#endif 54#endif
55#ifdef CONFIG_PPC64
56 struct ppc_emulated_entry mfdscr;
57 struct ppc_emulated_entry mtdscr;
58#endif
55} ppc_emulated; 59} ppc_emulated;
56 60
57extern u32 ppc_warn_emulated; 61extern u32 ppc_warn_emulated;
diff --git a/arch/powerpc/include/asm/exception-64s.h b/arch/powerpc/include/asm/exception-64s.h
index 57c400071995..f5dfe3411f64 100644
--- a/arch/powerpc/include/asm/exception-64s.h
+++ b/arch/powerpc/include/asm/exception-64s.h
@@ -46,6 +46,7 @@
46#define EX_CCR 60 46#define EX_CCR 60
47#define EX_R3 64 47#define EX_R3 64
48#define EX_LR 72 48#define EX_LR 72
49#define EX_CFAR 80
49 50
50/* 51/*
51 * We're short on space and time in the exception prolog, so we can't 52 * We're short on space and time in the exception prolog, so we can't
@@ -56,30 +57,40 @@
56#define LOAD_HANDLER(reg, label) \ 57#define LOAD_HANDLER(reg, label) \
57 addi reg,reg,(label)-_stext; /* virt addr of handler ... */ 58 addi reg,reg,(label)-_stext; /* virt addr of handler ... */
58 59
59#define EXCEPTION_PROLOG_1(area) \ 60/* Exception register prefixes */
60 mfspr r13,SPRN_SPRG_PACA; /* get paca address into r13 */ \ 61#define EXC_HV H
62#define EXC_STD
63
64#define EXCEPTION_PROLOG_1(area) \
65 GET_PACA(r13); \
61 std r9,area+EX_R9(r13); /* save r9 - r12 */ \ 66 std r9,area+EX_R9(r13); /* save r9 - r12 */ \
62 std r10,area+EX_R10(r13); \ 67 std r10,area+EX_R10(r13); \
63 std r11,area+EX_R11(r13); \ 68 std r11,area+EX_R11(r13); \
64 std r12,area+EX_R12(r13); \ 69 std r12,area+EX_R12(r13); \
65 mfspr r9,SPRN_SPRG_SCRATCH0; \ 70 BEGIN_FTR_SECTION_NESTED(66); \
71 mfspr r10,SPRN_CFAR; \
72 std r10,area+EX_CFAR(r13); \
73 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \
74 GET_SCRATCH0(r9); \
66 std r9,area+EX_R13(r13); \ 75 std r9,area+EX_R13(r13); \
67 mfcr r9 76 mfcr r9
68 77
69#define EXCEPTION_PROLOG_PSERIES_1(label) \ 78#define __EXCEPTION_PROLOG_PSERIES_1(label, h) \
70 ld r12,PACAKBASE(r13); /* get high part of &label */ \ 79 ld r12,PACAKBASE(r13); /* get high part of &label */ \
71 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 80 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \
72 mfspr r11,SPRN_SRR0; /* save SRR0 */ \ 81 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \
73 LOAD_HANDLER(r12,label) \ 82 LOAD_HANDLER(r12,label) \
74 mtspr SPRN_SRR0,r12; \ 83 mtspr SPRN_##h##SRR0,r12; \
75 mfspr r12,SPRN_SRR1; /* and SRR1 */ \ 84 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \
76 mtspr SPRN_SRR1,r10; \ 85 mtspr SPRN_##h##SRR1,r10; \
77 rfid; \ 86 h##rfid; \
78 b . /* prevent speculative execution */ 87 b . /* prevent speculative execution */
88#define EXCEPTION_PROLOG_PSERIES_1(label, h) \
89 __EXCEPTION_PROLOG_PSERIES_1(label, h)
79 90
80#define EXCEPTION_PROLOG_PSERIES(area, label) \ 91#define EXCEPTION_PROLOG_PSERIES(area, label, h) \
81 EXCEPTION_PROLOG_1(area); \ 92 EXCEPTION_PROLOG_1(area); \
82 EXCEPTION_PROLOG_PSERIES_1(label); 93 EXCEPTION_PROLOG_PSERIES_1(label, h);
83 94
84/* 95/*
85 * The common exception prolog is used for all except a few exceptions 96 * The common exception prolog is used for all except a few exceptions
@@ -98,10 +109,11 @@
98 beq- 1f; \ 109 beq- 1f; \
99 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \ 110 ld r1,PACAKSAVE(r13); /* kernel stack to use */ \
1001: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \ 1111: cmpdi cr1,r1,0; /* check if r1 is in userspace */ \
101 bge- cr1,2f; /* abort if it is */ \ 112 blt+ cr1,3f; /* abort if it is */ \
102 b 3f; \ 113 li r1,(n); /* will be reloaded later */ \
1032: li r1,(n); /* will be reloaded later */ \
104 sth r1,PACA_TRAP_SAVE(r13); \ 114 sth r1,PACA_TRAP_SAVE(r13); \
115 std r3,area+EX_R3(r13); \
116 addi r3,r13,area; /* r3 -> where regs are saved*/ \
105 b bad_stack; \ 117 b bad_stack; \
1063: std r9,_CCR(r1); /* save CR in stackframe */ \ 1183: std r9,_CCR(r1); /* save CR in stackframe */ \
107 std r11,_NIP(r1); /* save SRR0 in stackframe */ \ 119 std r11,_NIP(r1); /* save SRR0 in stackframe */ \
@@ -123,6 +135,10 @@
123 std r9,GPR11(r1); \ 135 std r9,GPR11(r1); \
124 std r10,GPR12(r1); \ 136 std r10,GPR12(r1); \
125 std r11,GPR13(r1); \ 137 std r11,GPR13(r1); \
138 BEGIN_FTR_SECTION_NESTED(66); \
139 ld r10,area+EX_CFAR(r13); \
140 std r10,ORIG_GPR3(r1); \
141 END_FTR_SECTION_NESTED(CPU_FTR_CFAR, CPU_FTR_CFAR, 66); \
126 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \ 142 ld r2,PACATOC(r13); /* get kernel TOC into r2 */ \
127 mflr r9; /* save LR in stackframe */ \ 143 mflr r9; /* save LR in stackframe */ \
128 std r9,_LINK(r1); \ 144 std r9,_LINK(r1); \
@@ -137,62 +153,68 @@
137 li r10,0; \ 153 li r10,0; \
138 ld r11,exception_marker@toc(r2); \ 154 ld r11,exception_marker@toc(r2); \
139 std r10,RESULT(r1); /* clear regs->result */ \ 155 std r10,RESULT(r1); /* clear regs->result */ \
140 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ 156 std r11,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ \
157 ACCOUNT_STOLEN_TIME
141 158
142/* 159/*
143 * Exception vectors. 160 * Exception vectors.
144 */ 161 */
145#define STD_EXCEPTION_PSERIES(n, label) \ 162#define STD_EXCEPTION_PSERIES(loc, vec, label) \
146 . = n; \ 163 . = loc; \
147 .globl label##_pSeries; \ 164 .globl label##_pSeries; \
148label##_pSeries: \ 165label##_pSeries: \
149 HMT_MEDIUM; \ 166 HMT_MEDIUM; \
150 DO_KVM n; \ 167 DO_KVM vec; \
151 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \ 168 SET_SCRATCH0(r13); /* save r13 */ \
152 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) 169 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_STD)
153 170
154#define HSTD_EXCEPTION_PSERIES(n, label) \ 171#define STD_EXCEPTION_HV(loc, vec, label) \
155 . = n; \ 172 . = loc; \
156 .globl label##_pSeries; \ 173 .globl label##_hv; \
157label##_pSeries: \ 174label##_hv: \
158 HMT_MEDIUM; \ 175 HMT_MEDIUM; \
159 mtspr SPRN_SPRG_SCRATCH0,r20; /* save r20 */ \ 176 DO_KVM vec; \
160 mfspr r20,SPRN_HSRR0; /* copy HSRR0 to SRR0 */ \ 177 SET_SCRATCH0(r13); /* save r13 */ \
161 mtspr SPRN_SRR0,r20; \ 178 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_HV)
162 mfspr r20,SPRN_HSRR1; /* copy HSRR0 to SRR0 */ \
163 mtspr SPRN_SRR1,r20; \
164 mfspr r20,SPRN_SPRG_SCRATCH0; /* restore r20 */ \
165 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \
166 EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
167 179
168 180#define __MASKABLE_EXCEPTION_PSERIES(vec, label, h) \
169#define MASKABLE_EXCEPTION_PSERIES(n, label) \
170 . = n; \
171 .globl label##_pSeries; \
172label##_pSeries: \
173 HMT_MEDIUM; \ 181 HMT_MEDIUM; \
174 DO_KVM n; \ 182 DO_KVM vec; \
175 mtspr SPRN_SPRG_SCRATCH0,r13; /* save r13 */ \ 183 SET_SCRATCH0(r13); /* save r13 */ \
176 mfspr r13,SPRN_SPRG_PACA; /* get paca address into r13 */ \ 184 GET_PACA(r13); \
177 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \ 185 std r9,PACA_EXGEN+EX_R9(r13); /* save r9, r10 */ \
178 std r10,PACA_EXGEN+EX_R10(r13); \ 186 std r10,PACA_EXGEN+EX_R10(r13); \
179 lbz r10,PACASOFTIRQEN(r13); \ 187 lbz r10,PACASOFTIRQEN(r13); \
180 mfcr r9; \ 188 mfcr r9; \
181 cmpwi r10,0; \ 189 cmpwi r10,0; \
182 beq masked_interrupt; \ 190 beq masked_##h##interrupt; \
183 mfspr r10,SPRN_SPRG_SCRATCH0; \ 191 GET_SCRATCH0(r10); \
184 std r10,PACA_EXGEN+EX_R13(r13); \ 192 std r10,PACA_EXGEN+EX_R13(r13); \
185 std r11,PACA_EXGEN+EX_R11(r13); \ 193 std r11,PACA_EXGEN+EX_R11(r13); \
186 std r12,PACA_EXGEN+EX_R12(r13); \ 194 std r12,PACA_EXGEN+EX_R12(r13); \
187 ld r12,PACAKBASE(r13); /* get high part of &label */ \ 195 ld r12,PACAKBASE(r13); /* get high part of &label */ \
188 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \ 196 ld r10,PACAKMSR(r13); /* get MSR value for kernel */ \
189 mfspr r11,SPRN_SRR0; /* save SRR0 */ \ 197 mfspr r11,SPRN_##h##SRR0; /* save SRR0 */ \
190 LOAD_HANDLER(r12,label##_common) \ 198 LOAD_HANDLER(r12,label##_common) \
191 mtspr SPRN_SRR0,r12; \ 199 mtspr SPRN_##h##SRR0,r12; \
192 mfspr r12,SPRN_SRR1; /* and SRR1 */ \ 200 mfspr r12,SPRN_##h##SRR1; /* and SRR1 */ \
193 mtspr SPRN_SRR1,r10; \ 201 mtspr SPRN_##h##SRR1,r10; \
194 rfid; \ 202 h##rfid; \
195 b . /* prevent speculative execution */ 203 b . /* prevent speculative execution */
204#define _MASKABLE_EXCEPTION_PSERIES(vec, label, h) \
205 __MASKABLE_EXCEPTION_PSERIES(vec, label, h)
206
207#define MASKABLE_EXCEPTION_PSERIES(loc, vec, label) \
208 . = loc; \
209 .globl label##_pSeries; \
210label##_pSeries: \
211 _MASKABLE_EXCEPTION_PSERIES(vec, label, EXC_STD)
212
213#define MASKABLE_EXCEPTION_HV(loc, vec, label) \
214 . = loc; \
215 .globl label##_hv; \
216label##_hv: \
217 _MASKABLE_EXCEPTION_PSERIES(vec, label, EXC_HV)
196 218
197#ifdef CONFIG_PPC_ISERIES 219#ifdef CONFIG_PPC_ISERIES
198#define DISABLE_INTS \ 220#define DISABLE_INTS \
diff --git a/arch/powerpc/include/asm/feature-fixups.h b/arch/powerpc/include/asm/feature-fixups.h
index 96a7d067fbb2..9a67a38bf7b9 100644
--- a/arch/powerpc/include/asm/feature-fixups.h
+++ b/arch/powerpc/include/asm/feature-fixups.h
@@ -37,18 +37,21 @@ label##2: \
37 .align 2; \ 37 .align 2; \
38label##3: 38label##3:
39 39
40#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \ 40#define MAKE_FTR_SECTION_ENTRY(msk, val, label, sect) \
41label##4: \ 41label##4: \
42 .popsection; \ 42 .popsection; \
43 .pushsection sect,"a"; \ 43 .pushsection sect,"a"; \
44 .align 3; \ 44 .align 3; \
45label##5: \ 45label##5: \
46 FTR_ENTRY_LONG msk; \ 46 FTR_ENTRY_LONG msk; \
47 FTR_ENTRY_LONG val; \ 47 FTR_ENTRY_LONG val; \
48 FTR_ENTRY_OFFSET label##1b-label##5b; \ 48 FTR_ENTRY_OFFSET label##1b-label##5b; \
49 FTR_ENTRY_OFFSET label##2b-label##5b; \ 49 FTR_ENTRY_OFFSET label##2b-label##5b; \
50 FTR_ENTRY_OFFSET label##3b-label##5b; \ 50 FTR_ENTRY_OFFSET label##3b-label##5b; \
51 FTR_ENTRY_OFFSET label##4b-label##5b; \ 51 FTR_ENTRY_OFFSET label##4b-label##5b; \
52 .ifgt (label##4b- label##3b)-(label##2b- label##1b); \
53 .error "Feature section else case larger than body"; \
54 .endif; \
52 .popsection; 55 .popsection;
53 56
54 57
@@ -143,6 +146,19 @@ label##5: \
143 146
144#ifndef __ASSEMBLY__ 147#ifndef __ASSEMBLY__
145 148
149#define ASM_FTR_IF(section_if, section_else, msk, val) \
150 stringify_in_c(BEGIN_FTR_SECTION) \
151 section_if "; " \
152 stringify_in_c(FTR_SECTION_ELSE) \
153 section_else "; " \
154 stringify_in_c(ALT_FTR_SECTION_END((msk), (val)))
155
156#define ASM_FTR_IFSET(section_if, section_else, msk) \
157 ASM_FTR_IF(section_if, section_else, (msk), (msk))
158
159#define ASM_FTR_IFCLR(section_if, section_else, msk) \
160 ASM_FTR_IF(section_if, section_else, (msk), 0)
161
146#define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \ 162#define ASM_MMU_FTR_IF(section_if, section_else, msk, val) \
147 stringify_in_c(BEGIN_MMU_FTR_SECTION) \ 163 stringify_in_c(BEGIN_MMU_FTR_SECTION) \
148 section_if "; " \ 164 section_if "; " \
diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h
index 20778a405d7a..3a6c586c4e40 100644
--- a/arch/powerpc/include/asm/firmware.h
+++ b/arch/powerpc/include/asm/firmware.h
@@ -46,6 +46,8 @@
46#define FW_FEATURE_PS3_LV1 ASM_CONST(0x0000000000800000) 46#define FW_FEATURE_PS3_LV1 ASM_CONST(0x0000000000800000)
47#define FW_FEATURE_BEAT ASM_CONST(0x0000000001000000) 47#define FW_FEATURE_BEAT ASM_CONST(0x0000000001000000)
48#define FW_FEATURE_CMO ASM_CONST(0x0000000002000000) 48#define FW_FEATURE_CMO ASM_CONST(0x0000000002000000)
49#define FW_FEATURE_VPHN ASM_CONST(0x0000000004000000)
50#define FW_FEATURE_XCMO ASM_CONST(0x0000000008000000)
49 51
50#ifndef __ASSEMBLY__ 52#ifndef __ASSEMBLY__
51 53
@@ -59,7 +61,7 @@ enum {
59 FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN | 61 FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
60 FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR | 62 FW_FEATURE_BULK_REMOVE | FW_FEATURE_XDABR |
61 FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR | 63 FW_FEATURE_MULTITCE | FW_FEATURE_SPLPAR | FW_FEATURE_LPAR |
62 FW_FEATURE_CMO, 64 FW_FEATURE_CMO | FW_FEATURE_VPHN | FW_FEATURE_XCMO,
63 FW_FEATURE_PSERIES_ALWAYS = 0, 65 FW_FEATURE_PSERIES_ALWAYS = 0,
64 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR, 66 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
65 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | FW_FEATURE_LPAR, 67 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES | FW_FEATURE_LPAR,
diff --git a/arch/powerpc/include/asm/fsl_85xx_cache_sram.h b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h
new file mode 100644
index 000000000000..2af2bdc37b2e
--- /dev/null
+++ b/arch/powerpc/include/asm/fsl_85xx_cache_sram.h
@@ -0,0 +1,48 @@
1/*
2 * Copyright 2009 Freescale Semiconductor, Inc.
3 *
4 * Cache SRAM handling for QorIQ platform
5 *
6 * Author: Vivek Mahajan <vivek.mahajan@freescale.com>
7
8 * This file is derived from the original work done
9 * by Sylvain Munaut for the Bestcomm SRAM allocator.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#ifndef __ASM_POWERPC_FSL_85XX_CACHE_SRAM_H__
27#define __ASM_POWERPC_FSL_85XX_CACHE_SRAM_H__
28
29#include <asm/rheap.h>
30#include <linux/spinlock.h>
31
32/*
33 * Cache-SRAM
34 */
35
36struct mpc85xx_cache_sram {
37 phys_addr_t base_phys;
38 void *base_virt;
39 unsigned int size;
40 rh_info_t *rh;
41 spinlock_t lock;
42};
43
44extern void mpc85xx_cache_sram_free(void *ptr);
45extern void *mpc85xx_cache_sram_alloc(unsigned int size,
46 phys_addr_t *phys, unsigned int align);
47
48#endif /* __AMS_POWERPC_FSL_85XX_CACHE_SRAM_H__ */
diff --git a/arch/powerpc/include/asm/immap_86xx.h b/arch/powerpc/include/asm/fsl_guts.h
index 0f165e59c326..bebd12463ec9 100644
--- a/arch/powerpc/include/asm/immap_86xx.h
+++ b/arch/powerpc/include/asm/fsl_guts.h
@@ -1,5 +1,5 @@
1/** 1/**
2 * MPC86xx Internal Memory Map 2 * Freecale 85xx and 86xx Global Utilties register set
3 * 3 *
4 * Authors: Jeff Brown 4 * Authors: Jeff Brown
5 * Timur Tabi <timur@freescale.com> 5 * Timur Tabi <timur@freescale.com>
@@ -10,73 +10,112 @@
10 * under the terms of the GNU General Public License as published by the 10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your 11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version. 12 * option) any later version.
13 *
14 * This header file defines structures for various 86xx SOC devices that are
15 * used by multiple source files.
16 */ 13 */
17 14
18#ifndef __ASM_POWERPC_IMMAP_86XX_H__ 15#ifndef __ASM_POWERPC_FSL_GUTS_H__
19#define __ASM_POWERPC_IMMAP_86XX_H__ 16#define __ASM_POWERPC_FSL_GUTS_H__
20#ifdef __KERNEL__ 17#ifdef __KERNEL__
21 18
22/* Global Utility Registers */ 19/*
23struct ccsr_guts { 20 * These #ifdefs are safe because it's not possible to build a kernel that
21 * runs on e500 and e600 cores.
22 */
23
24#if !defined(CONFIG_PPC_85xx) && !defined(CONFIG_PPC_86xx)
25#error Only 85xx and 86xx SOCs are supported
26#endif
27
28/**
29 * Global Utility Registers.
30 *
31 * Not all registers defined in this structure are available on all chips, so
32 * you are expected to know whether a given register actually exists on your
33 * chip before you access it.
34 *
35 * Also, some registers are similar on different chips but have slightly
36 * different names. In these cases, one name is chosen to avoid extraneous
37 * #ifdefs.
38 */
39#ifdef CONFIG_PPC_85xx
40struct ccsr_guts_85xx {
41#else
42struct ccsr_guts_86xx {
43#endif
24 __be32 porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */ 44 __be32 porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */
25 __be32 porbmsr; /* 0x.0004 - POR Boot Mode Status Register */ 45 __be32 porbmsr; /* 0x.0004 - POR Boot Mode Status Register */
26 __be32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */ 46 __be32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */
27 __be32 pordevsr; /* 0x.000c - POR I/O Device Status Register */ 47 __be32 pordevsr; /* 0x.000c - POR I/O Device Status Register */
28 __be32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */ 48 __be32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */
29 u8 res1[0x20 - 0x14]; 49 __be32 pordevsr2; /* 0x.0014 - POR device status register 2 */
50 u8 res018[0x20 - 0x18];
30 __be32 porcir; /* 0x.0020 - POR Configuration Information Register */ 51 __be32 porcir; /* 0x.0020 - POR Configuration Information Register */
31 u8 res2[0x30 - 0x24]; 52 u8 res024[0x30 - 0x24];
32 __be32 gpiocr; /* 0x.0030 - GPIO Control Register */ 53 __be32 gpiocr; /* 0x.0030 - GPIO Control Register */
33 u8 res3[0x40 - 0x34]; 54 u8 res034[0x40 - 0x34];
34 __be32 gpoutdr; /* 0x.0040 - General-Purpose Output Data Register */ 55 __be32 gpoutdr; /* 0x.0040 - General-Purpose Output Data Register */
35 u8 res4[0x50 - 0x44]; 56 u8 res044[0x50 - 0x44];
36 __be32 gpindr; /* 0x.0050 - General-Purpose Input Data Register */ 57 __be32 gpindr; /* 0x.0050 - General-Purpose Input Data Register */
37 u8 res5[0x60 - 0x54]; 58 u8 res054[0x60 - 0x54];
38 __be32 pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */ 59 __be32 pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */
39 u8 res6[0x70 - 0x64]; 60 __be32 pmuxcr2; /* 0x.0064 - Alternate function signal multiplex control 2 */
61 __be32 dmuxcr; /* 0x.0068 - DMA Mux Control Register */
62 u8 res06c[0x70 - 0x6c];
40 __be32 devdisr; /* 0x.0070 - Device Disable Control */ 63 __be32 devdisr; /* 0x.0070 - Device Disable Control */
41 __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */ 64 __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */
42 u8 res7[0x80 - 0x78]; 65 u8 res078[0x7c - 0x78];
66 __be32 pmjcr; /* 0x.007c - 4 Power Management Jog Control Register */
43 __be32 powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */ 67 __be32 powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */
44 u8 res8[0x90 - 0x84]; 68 __be32 pmrccr; /* 0x.0084 - Power Management Reset Counter Configuration Register */
69 __be32 pmpdccr; /* 0x.0088 - Power Management Power Down Counter Configuration Register */
70 __be32 pmcdr; /* 0x.008c - 4Power management clock disable register */
45 __be32 mcpsumr; /* 0x.0090 - Machine Check Summary Register */ 71 __be32 mcpsumr; /* 0x.0090 - Machine Check Summary Register */
46 __be32 rstrscr; /* 0x.0094 - Reset Request Status and Control Register */ 72 __be32 rstrscr; /* 0x.0094 - Reset Request Status and Control Register */
47 u8 res9[0xA0 - 0x98]; 73 __be32 ectrstcr; /* 0x.0098 - Exception reset control register */
74 __be32 autorstsr; /* 0x.009c - Automatic reset status register */
48 __be32 pvr; /* 0x.00a0 - Processor Version Register */ 75 __be32 pvr; /* 0x.00a0 - Processor Version Register */
49 __be32 svr; /* 0x.00a4 - System Version Register */ 76 __be32 svr; /* 0x.00a4 - System Version Register */
50 u8 res10[0xB0 - 0xA8]; 77 u8 res0a8[0xb0 - 0xa8];
51 __be32 rstcr; /* 0x.00b0 - Reset Control Register */ 78 __be32 rstcr; /* 0x.00b0 - Reset Control Register */
52 u8 res11[0xC0 - 0xB4]; 79 u8 res0b4[0xc0 - 0xb4];
80#ifdef CONFIG_PPC_85xx
81 __be32 iovselsr; /* 0x.00c0 - I/O voltage select status register */
82#else
53 __be32 elbcvselcr; /* 0x.00c0 - eLBC Voltage Select Ctrl Reg */ 83 __be32 elbcvselcr; /* 0x.00c0 - eLBC Voltage Select Ctrl Reg */
54 u8 res12[0x800 - 0xC4]; 84#endif
85 u8 res0c4[0x224 - 0xc4];
86 __be32 iodelay1; /* 0x.0224 - IO delay control register 1 */
87 __be32 iodelay2; /* 0x.0228 - IO delay control register 2 */
88 u8 res22c[0x800 - 0x22c];
55 __be32 clkdvdr; /* 0x.0800 - Clock Divide Register */ 89 __be32 clkdvdr; /* 0x.0800 - Clock Divide Register */
56 u8 res13[0x900 - 0x804]; 90 u8 res804[0x900 - 0x804];
57 __be32 ircr; /* 0x.0900 - Infrared Control Register */ 91 __be32 ircr; /* 0x.0900 - Infrared Control Register */
58 u8 res14[0x908 - 0x904]; 92 u8 res904[0x908 - 0x904];
59 __be32 dmacr; /* 0x.0908 - DMA Control Register */ 93 __be32 dmacr; /* 0x.0908 - DMA Control Register */
60 u8 res15[0x914 - 0x90C]; 94 u8 res90c[0x914 - 0x90c];
61 __be32 elbccr; /* 0x.0914 - eLBC Control Register */ 95 __be32 elbccr; /* 0x.0914 - eLBC Control Register */
62 u8 res16[0xB20 - 0x918]; 96 u8 res918[0xb20 - 0x918];
63 __be32 ddr1clkdr; /* 0x.0b20 - DDR1 Clock Disable Register */ 97 __be32 ddr1clkdr; /* 0x.0b20 - DDR1 Clock Disable Register */
64 __be32 ddr2clkdr; /* 0x.0b24 - DDR2 Clock Disable Register */ 98 __be32 ddr2clkdr; /* 0x.0b24 - DDR2 Clock Disable Register */
65 __be32 ddrclkdr; /* 0x.0b28 - DDR Clock Disable Register */ 99 __be32 ddrclkdr; /* 0x.0b28 - DDR Clock Disable Register */
66 u8 res17[0xE00 - 0xB2C]; 100 u8 resb2c[0xe00 - 0xb2c];
67 __be32 clkocr; /* 0x.0e00 - Clock Out Select Register */ 101 __be32 clkocr; /* 0x.0e00 - Clock Out Select Register */
68 u8 res18[0xE10 - 0xE04]; 102 u8 rese04[0xe10 - 0xe04];
69 __be32 ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */ 103 __be32 ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */
70 u8 res19[0xE20 - 0xE14]; 104 u8 rese14[0xe20 - 0xe14];
71 __be32 lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */ 105 __be32 lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */
72 u8 res20[0xF04 - 0xE24]; 106 __be32 cpfor; /* 0x.0e24 - L2 charge pump fuse override register */
107 u8 rese28[0xf04 - 0xe28];
73 __be32 srds1cr0; /* 0x.0f04 - SerDes1 Control Register 0 */ 108 __be32 srds1cr0; /* 0x.0f04 - SerDes1 Control Register 0 */
74 __be32 srds1cr1; /* 0x.0f08 - SerDes1 Control Register 0 */ 109 __be32 srds1cr1; /* 0x.0f08 - SerDes1 Control Register 0 */
75 u8 res21[0xF40 - 0xF0C]; 110 u8 resf0c[0xf2c - 0xf0c];
76 __be32 srds2cr0; /* 0x.0f40 - SerDes1 Control Register 0 */ 111 __be32 itcr; /* 0x.0f2c - Internal transaction control register */
77 __be32 srds2cr1; /* 0x.0f44 - SerDes1 Control Register 0 */ 112 u8 resf30[0xf40 - 0xf30];
113 __be32 srds2cr0; /* 0x.0f40 - SerDes2 Control Register 0 */
114 __be32 srds2cr1; /* 0x.0f44 - SerDes2 Control Register 0 */
78} __attribute__ ((packed)); 115} __attribute__ ((packed));
79 116
117#ifdef CONFIG_PPC_86xx
118
80#define CCSR_GUTS_DMACR_DEV_SSI 0 /* DMA controller/channel set to SSI */ 119#define CCSR_GUTS_DMACR_DEV_SSI 0 /* DMA controller/channel set to SSI */
81#define CCSR_GUTS_DMACR_DEV_IR 1 /* DMA controller/channel set to IR */ 120#define CCSR_GUTS_DMACR_DEV_IR 1 /* DMA controller/channel set to IR */
82 121
@@ -93,7 +132,7 @@ struct ccsr_guts {
93 * ch: The channel on the DMA controller (0, 1, 2, or 3) 132 * ch: The channel on the DMA controller (0, 1, 2, or 3)
94 * device: The device to set as the source (CCSR_GUTS_DMACR_DEV_xx) 133 * device: The device to set as the source (CCSR_GUTS_DMACR_DEV_xx)
95 */ 134 */
96static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts, 135static inline void guts_set_dmacr(struct ccsr_guts_86xx __iomem *guts,
97 unsigned int co, unsigned int ch, unsigned int device) 136 unsigned int co, unsigned int ch, unsigned int device)
98{ 137{
99 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch)); 138 unsigned int shift = 16 + (8 * (1 - co) + 2 * (3 - ch));
@@ -129,7 +168,7 @@ static inline void guts_set_dmacr(struct ccsr_guts __iomem *guts,
129 * ch: The channel on the DMA controller (0, 1, 2, or 3) 168 * ch: The channel on the DMA controller (0, 1, 2, or 3)
130 * value: the new value for the bit (0 or 1) 169 * value: the new value for the bit (0 or 1)
131 */ 170 */
132static inline void guts_set_pmuxcr_dma(struct ccsr_guts __iomem *guts, 171static inline void guts_set_pmuxcr_dma(struct ccsr_guts_86xx __iomem *guts,
133 unsigned int co, unsigned int ch, unsigned int value) 172 unsigned int co, unsigned int ch, unsigned int value)
134{ 173{
135 if ((ch == 0) || (ch == 3)) { 174 if ((ch == 0) || (ch == 3)) {
@@ -152,5 +191,7 @@ static inline void guts_set_pmuxcr_dma(struct ccsr_guts __iomem *guts,
152#define CCSR_GUTS_CLKDVDR_SSICLK_MASK 0x000000FF 191#define CCSR_GUTS_CLKDVDR_SSICLK_MASK 0x000000FF
153#define CCSR_GUTS_CLKDVDR_SSICLK(x) ((x) & CCSR_GUTS_CLKDVDR_SSICLK_MASK) 192#define CCSR_GUTS_CLKDVDR_SSICLK(x) ((x) & CCSR_GUTS_CLKDVDR_SSICLK_MASK)
154 193
155#endif /* __ASM_POWERPC_IMMAP_86XX_H__ */ 194#endif
156#endif /* __KERNEL__ */ 195
196#endif
197#endif
diff --git a/arch/powerpc/include/asm/fsl_lbc.h b/arch/powerpc/include/asm/fsl_lbc.h
index 1b5a21041f9b..8a0b5ece8f76 100644
--- a/arch/powerpc/include/asm/fsl_lbc.h
+++ b/arch/powerpc/include/asm/fsl_lbc.h
@@ -1,9 +1,10 @@
1/* Freescale Local Bus Controller 1/* Freescale Local Bus Controller
2 * 2 *
3 * Copyright (c) 2006-2007 Freescale Semiconductor 3 * Copyright © 2006-2007, 2010 Freescale Semiconductor
4 * 4 *
5 * Authors: Nick Spence <nick.spence@freescale.com>, 5 * Authors: Nick Spence <nick.spence@freescale.com>,
6 * Scott Wood <scottwood@freescale.com> 6 * Scott Wood <scottwood@freescale.com>
7 * Jack Lan <jack.lan@freescale.com>
7 * 8 *
8 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
@@ -26,6 +27,8 @@
26#include <linux/compiler.h> 27#include <linux/compiler.h>
27#include <linux/types.h> 28#include <linux/types.h>
28#include <linux/io.h> 29#include <linux/io.h>
30#include <linux/device.h>
31#include <linux/spinlock.h>
29 32
30struct fsl_lbc_bank { 33struct fsl_lbc_bank {
31 __be32 br; /**< Base Register */ 34 __be32 br; /**< Base Register */
@@ -125,13 +128,23 @@ struct fsl_lbc_regs {
125#define LTESR_ATMW 0x00800000 128#define LTESR_ATMW 0x00800000
126#define LTESR_ATMR 0x00400000 129#define LTESR_ATMR 0x00400000
127#define LTESR_CS 0x00080000 130#define LTESR_CS 0x00080000
131#define LTESR_UPM 0x00000002
128#define LTESR_CC 0x00000001 132#define LTESR_CC 0x00000001
129#define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC) 133#define LTESR_NAND_MASK (LTESR_FCT | LTESR_PAR | LTESR_CC)
134#define LTESR_MASK (LTESR_BM | LTESR_FCT | LTESR_PAR | LTESR_WP \
135 | LTESR_ATMW | LTESR_ATMR | LTESR_CS | LTESR_UPM \
136 | LTESR_CC)
137#define LTESR_CLEAR 0xFFFFFFFF
138#define LTECCR_CLEAR 0xFFFFFFFF
139#define LTESR_STATUS LTESR_MASK
140#define LTEIR_ENABLE LTESR_MASK
141#define LTEDR_ENABLE 0x00000000
130 __be32 ltedr; /**< Transfer Error Disable Register */ 142 __be32 ltedr; /**< Transfer Error Disable Register */
131 __be32 lteir; /**< Transfer Error Interrupt Register */ 143 __be32 lteir; /**< Transfer Error Interrupt Register */
132 __be32 lteatr; /**< Transfer Error Attributes Register */ 144 __be32 lteatr; /**< Transfer Error Attributes Register */
133 __be32 ltear; /**< Transfer Error Address Register */ 145 __be32 ltear; /**< Transfer Error Address Register */
134 u8 res6[0xC]; 146 __be32 lteccr; /**< Transfer Error ECC Register */
147 u8 res6[0x8];
135 __be32 lbcr; /**< Configuration Register */ 148 __be32 lbcr; /**< Configuration Register */
136#define LBCR_LDIS 0x80000000 149#define LBCR_LDIS 0x80000000
137#define LBCR_LDIS_SHIFT 31 150#define LBCR_LDIS_SHIFT 31
@@ -144,6 +157,8 @@ struct fsl_lbc_regs {
144#define LBCR_EPAR_SHIFT 16 157#define LBCR_EPAR_SHIFT 16
145#define LBCR_BMT 0x0000FF00 158#define LBCR_BMT 0x0000FF00
146#define LBCR_BMT_SHIFT 8 159#define LBCR_BMT_SHIFT 8
160#define LBCR_BMTPS 0x0000000F
161#define LBCR_BMTPS_SHIFT 0
147#define LBCR_INIT 0x00040000 162#define LBCR_INIT 0x00040000
148 __be32 lcrr; /**< Clock Ratio Register */ 163 __be32 lcrr; /**< Clock Ratio Register */
149#define LCRR_DBYP 0x80000000 164#define LCRR_DBYP 0x80000000
@@ -235,6 +250,7 @@ struct fsl_upm {
235 int width; 250 int width;
236}; 251};
237 252
253extern u32 fsl_lbc_addr(phys_addr_t addr_base);
238extern int fsl_lbc_find(phys_addr_t addr_base); 254extern int fsl_lbc_find(phys_addr_t addr_base);
239extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm); 255extern int fsl_upm_find(phys_addr_t addr_base, struct fsl_upm *upm);
240 256
@@ -265,7 +281,23 @@ static inline void fsl_upm_end_pattern(struct fsl_upm *upm)
265 cpu_relax(); 281 cpu_relax();
266} 282}
267 283
284/* overview of the fsl lbc controller */
285
286struct fsl_lbc_ctrl {
287 /* device info */
288 struct device *dev;
289 struct fsl_lbc_regs __iomem *regs;
290 int irq;
291 wait_queue_head_t irq_wait;
292 spinlock_t lock;
293 void *nand;
294
295 /* status read from LTESR by irq handler */
296 unsigned int irq_status;
297};
298
268extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base, 299extern int fsl_upm_run_pattern(struct fsl_upm *upm, void __iomem *io_base,
269 u32 mar); 300 u32 mar);
301extern struct fsl_lbc_ctrl *fsl_lbc_ctrl_dev;
270 302
271#endif /* __ASM_FSL_LBC_H */ 303#endif /* __ASM_FSL_LBC_H */
diff --git a/arch/powerpc/include/asm/fsldma.h b/arch/powerpc/include/asm/fsldma.h
deleted file mode 100644
index debc5ed96d6e..000000000000
--- a/arch/powerpc/include/asm/fsldma.h
+++ /dev/null
@@ -1,137 +0,0 @@
1/*
2 * Freescale MPC83XX / MPC85XX DMA Controller
3 *
4 * Copyright (c) 2009 Ira W. Snyder <iws@ovro.caltech.edu>
5 *
6 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any
8 * kind, whether express or implied.
9 */
10
11#ifndef __ARCH_POWERPC_ASM_FSLDMA_H__
12#define __ARCH_POWERPC_ASM_FSLDMA_H__
13
14#include <linux/slab.h>
15#include <linux/dmaengine.h>
16
17/*
18 * Definitions for the Freescale DMA controller's DMA_SLAVE implemention
19 *
20 * The Freescale DMA_SLAVE implementation was designed to handle many-to-many
21 * transfers. An example usage would be an accelerated copy between two
22 * scatterlists. Another example use would be an accelerated copy from
23 * multiple non-contiguous device buffers into a single scatterlist.
24 *
25 * A DMA_SLAVE transaction is defined by a struct fsl_dma_slave. This
26 * structure contains a list of hardware addresses that should be copied
27 * to/from the scatterlist passed into device_prep_slave_sg(). The structure
28 * also has some fields to enable hardware-specific features.
29 */
30
31/**
32 * struct fsl_dma_hw_addr
33 * @entry: linked list entry
34 * @address: the hardware address
35 * @length: length to transfer
36 *
37 * Holds a single physical hardware address / length pair for use
38 * with the DMAEngine DMA_SLAVE API.
39 */
40struct fsl_dma_hw_addr {
41 struct list_head entry;
42
43 dma_addr_t address;
44 size_t length;
45};
46
47/**
48 * struct fsl_dma_slave
49 * @addresses: a linked list of struct fsl_dma_hw_addr structures
50 * @request_count: value for DMA request count
51 * @src_loop_size: setup and enable constant source-address DMA transfers
52 * @dst_loop_size: setup and enable constant destination address DMA transfers
53 * @external_start: enable externally started DMA transfers
54 * @external_pause: enable externally paused DMA transfers
55 *
56 * Holds a list of address / length pairs for use with the DMAEngine
57 * DMA_SLAVE API implementation for the Freescale DMA controller.
58 */
59struct fsl_dma_slave {
60
61 /* List of hardware address/length pairs */
62 struct list_head addresses;
63
64 /* Support for extra controller features */
65 unsigned int request_count;
66 unsigned int src_loop_size;
67 unsigned int dst_loop_size;
68 bool external_start;
69 bool external_pause;
70};
71
72/**
73 * fsl_dma_slave_append - add an address/length pair to a struct fsl_dma_slave
74 * @slave: the &struct fsl_dma_slave to add to
75 * @address: the hardware address to add
76 * @length: the length of bytes to transfer from @address
77 *
78 * Add a hardware address/length pair to a struct fsl_dma_slave. Returns 0 on
79 * success, -ERRNO otherwise.
80 */
81static inline int fsl_dma_slave_append(struct fsl_dma_slave *slave,
82 dma_addr_t address, size_t length)
83{
84 struct fsl_dma_hw_addr *addr;
85
86 addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
87 if (!addr)
88 return -ENOMEM;
89
90 INIT_LIST_HEAD(&addr->entry);
91 addr->address = address;
92 addr->length = length;
93
94 list_add_tail(&addr->entry, &slave->addresses);
95 return 0;
96}
97
98/**
99 * fsl_dma_slave_free - free a struct fsl_dma_slave
100 * @slave: the struct fsl_dma_slave to free
101 *
102 * Free a struct fsl_dma_slave and all associated address/length pairs
103 */
104static inline void fsl_dma_slave_free(struct fsl_dma_slave *slave)
105{
106 struct fsl_dma_hw_addr *addr, *tmp;
107
108 if (slave) {
109 list_for_each_entry_safe(addr, tmp, &slave->addresses, entry) {
110 list_del(&addr->entry);
111 kfree(addr);
112 }
113
114 kfree(slave);
115 }
116}
117
118/**
119 * fsl_dma_slave_alloc - allocate a struct fsl_dma_slave
120 * @gfp: the flags to pass to kmalloc when allocating this structure
121 *
122 * Allocate a struct fsl_dma_slave for use by the DMA_SLAVE API. Returns a new
123 * struct fsl_dma_slave on success, or NULL on failure.
124 */
125static inline struct fsl_dma_slave *fsl_dma_slave_alloc(gfp_t gfp)
126{
127 struct fsl_dma_slave *slave;
128
129 slave = kzalloc(sizeof(*slave), gfp);
130 if (!slave)
131 return NULL;
132
133 INIT_LIST_HEAD(&slave->addresses);
134 return slave;
135}
136
137#endif /* __ARCH_POWERPC_ASM_FSLDMA_H__ */
diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h
index dde1296b8b41..169d039ed402 100644
--- a/arch/powerpc/include/asm/ftrace.h
+++ b/arch/powerpc/include/asm/ftrace.h
@@ -60,4 +60,18 @@ struct dyn_arch_ftrace {
60 60
61#endif 61#endif
62 62
63#if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_PPC64) && !defined(__ASSEMBLY__)
64#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
65static inline bool arch_syscall_match_sym_name(const char *sym, const char *name)
66{
67 /*
68 * Compare the symbol name with the system call name. Skip the .sys or .SyS
69 * prefix from the symbol name and the sys prefix from the system call name and
70 * just match the rest. This is only needed on ppc64 since symbol names on
71 * 32bit do not start with a period so the generic function will work.
72 */
73 return !strcmp(sym + 4, name + 3);
74}
75#endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_PPC64 && !__ASSEMBLY__ */
76
63#endif /* _ASM_POWERPC_FTRACE */ 77#endif /* _ASM_POWERPC_FTRACE */
diff --git a/arch/powerpc/include/asm/futex.h b/arch/powerpc/include/asm/futex.h
index 7c589ef81fb0..c94e4a3fe2ef 100644
--- a/arch/powerpc/include/asm/futex.h
+++ b/arch/powerpc/include/asm/futex.h
@@ -30,7 +30,7 @@
30 : "b" (uaddr), "i" (-EFAULT), "r" (oparg) \ 30 : "b" (uaddr), "i" (-EFAULT), "r" (oparg) \
31 : "cr0", "memory") 31 : "cr0", "memory")
32 32
33static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr) 33static inline int futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
34{ 34{
35 int op = (encoded_op >> 28) & 7; 35 int op = (encoded_op >> 28) & 7;
36 int cmp = (encoded_op >> 24) & 15; 36 int cmp = (encoded_op >> 24) & 15;
@@ -40,7 +40,7 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
40 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28)) 40 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
41 oparg = 1 << oparg; 41 oparg = 1 << oparg;
42 42
43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int))) 43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(u32)))
44 return -EFAULT; 44 return -EFAULT;
45 45
46 pagefault_disable(); 46 pagefault_disable();
@@ -82,35 +82,38 @@ static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
82} 82}
83 83
84static inline int 84static inline int
85futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) 85futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
86 u32 oldval, u32 newval)
86{ 87{
87 int prev; 88 int ret = 0;
89 u32 prev;
88 90
89 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) 91 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
90 return -EFAULT; 92 return -EFAULT;
91 93
92 __asm__ __volatile__ ( 94 __asm__ __volatile__ (
93 PPC_RELEASE_BARRIER 95 PPC_RELEASE_BARRIER
94"1: lwarx %0,0,%2 # futex_atomic_cmpxchg_inatomic\n\ 96"1: lwarx %1,0,%3 # futex_atomic_cmpxchg_inatomic\n\
95 cmpw 0,%0,%3\n\ 97 cmpw 0,%1,%4\n\
96 bne- 3f\n" 98 bne- 3f\n"
97 PPC405_ERR77(0,%2) 99 PPC405_ERR77(0,%3)
98"2: stwcx. %4,0,%2\n\ 100"2: stwcx. %5,0,%3\n\
99 bne- 1b\n" 101 bne- 1b\n"
100 PPC_ACQUIRE_BARRIER 102 PPC_ACQUIRE_BARRIER
101"3: .section .fixup,\"ax\"\n\ 103"3: .section .fixup,\"ax\"\n\
1024: li %0,%5\n\ 1044: li %0,%6\n\
103 b 3b\n\ 105 b 3b\n\
104 .previous\n\ 106 .previous\n\
105 .section __ex_table,\"a\"\n\ 107 .section __ex_table,\"a\"\n\
106 .align 3\n\ 108 .align 3\n\
107 " PPC_LONG "1b,4b,2b,4b\n\ 109 " PPC_LONG "1b,4b,2b,4b\n\
108 .previous" \ 110 .previous" \
109 : "=&r" (prev), "+m" (*uaddr) 111 : "+r" (ret), "=&r" (prev), "+m" (*uaddr)
110 : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) 112 : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT)
111 : "cc", "memory"); 113 : "cc", "memory");
112 114
113 return prev; 115 *uval = prev;
116 return ret;
114} 117}
115 118
116#endif /* __KERNEL__ */ 119#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/highmem.h b/arch/powerpc/include/asm/highmem.h
index d10d64a4be38..dbc264010d0b 100644
--- a/arch/powerpc/include/asm/highmem.h
+++ b/arch/powerpc/include/asm/highmem.h
@@ -60,9 +60,8 @@ extern pte_t *pkmap_page_table;
60 60
61extern void *kmap_high(struct page *page); 61extern void *kmap_high(struct page *page);
62extern void kunmap_high(struct page *page); 62extern void kunmap_high(struct page *page);
63extern void *kmap_atomic_prot(struct page *page, enum km_type type, 63extern void *kmap_atomic_prot(struct page *page, pgprot_t prot);
64 pgprot_t prot); 64extern void __kunmap_atomic(void *kvaddr);
65extern void kunmap_atomic_notypecheck(void *kvaddr, enum km_type type);
66 65
67static inline void *kmap(struct page *page) 66static inline void *kmap(struct page *page)
68{ 67{
@@ -80,9 +79,9 @@ static inline void kunmap(struct page *page)
80 kunmap_high(page); 79 kunmap_high(page);
81} 80}
82 81
83static inline void *kmap_atomic(struct page *page, enum km_type type) 82static inline void *__kmap_atomic(struct page *page)
84{ 83{
85 return kmap_atomic_prot(page, type, kmap_prot); 84 return kmap_atomic_prot(page, kmap_prot);
86} 85}
87 86
88static inline struct page *kmap_atomic_to_page(void *ptr) 87static inline struct page *kmap_atomic_to_page(void *ptr)
diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h
index de03ca58db5d..fd8201dddd4b 100644
--- a/arch/powerpc/include/asm/hvcall.h
+++ b/arch/powerpc/include/asm/hvcall.h
@@ -102,6 +102,7 @@
102#define H_ANDCOND (1UL<<(63-33)) 102#define H_ANDCOND (1UL<<(63-33))
103#define H_ICACHE_INVALIDATE (1UL<<(63-40)) /* icbi, etc. (ignored for IO pages) */ 103#define H_ICACHE_INVALIDATE (1UL<<(63-40)) /* icbi, etc. (ignored for IO pages) */
104#define H_ICACHE_SYNCHRONIZE (1UL<<(63-41)) /* dcbst, icbi, etc (ignored for IO pages */ 104#define H_ICACHE_SYNCHRONIZE (1UL<<(63-41)) /* dcbst, icbi, etc (ignored for IO pages */
105#define H_COALESCE_CAND (1UL<<(63-42)) /* page is a good candidate for coalescing */
105#define H_ZERO_PAGE (1UL<<(63-48)) /* zero the page before mapping (ignored for IO pages) */ 106#define H_ZERO_PAGE (1UL<<(63-48)) /* zero the page before mapping (ignored for IO pages) */
106#define H_COPY_PAGE (1UL<<(63-49)) 107#define H_COPY_PAGE (1UL<<(63-49))
107#define H_N (1UL<<(63-61)) 108#define H_N (1UL<<(63-61))
@@ -122,7 +123,7 @@
122#define H_DABRX_KERNEL (1UL<<(63-62)) 123#define H_DABRX_KERNEL (1UL<<(63-62))
123#define H_DABRX_USER (1UL<<(63-63)) 124#define H_DABRX_USER (1UL<<(63-63))
124 125
125/* Each control block has to be on a 4K bondary */ 126/* Each control block has to be on a 4K boundary */
126#define H_CB_ALIGNMENT 4096 127#define H_CB_ALIGNMENT 4096
127 128
128/* pSeries hypervisor opcodes */ 129/* pSeries hypervisor opcodes */
@@ -232,7 +233,10 @@
232#define H_GET_EM_PARMS 0x2B8 233#define H_GET_EM_PARMS 0x2B8
233#define H_SET_MPP 0x2D0 234#define H_SET_MPP 0x2D0
234#define H_GET_MPP 0x2D4 235#define H_GET_MPP 0x2D4
235#define MAX_HCALL_OPCODE H_GET_MPP 236#define H_HOME_NODE_ASSOCIATIVITY 0x2EC
237#define H_BEST_ENERGY 0x2F4
238#define H_GET_MPP_X 0x314
239#define MAX_HCALL_OPCODE H_GET_MPP_X
236 240
237#ifndef __ASSEMBLY__ 241#ifndef __ASSEMBLY__
238 242
@@ -310,6 +314,16 @@ struct hvcall_mpp_data {
310 314
311int h_get_mpp(struct hvcall_mpp_data *); 315int h_get_mpp(struct hvcall_mpp_data *);
312 316
317struct hvcall_mpp_x_data {
318 unsigned long coalesced_bytes;
319 unsigned long pool_coalesced_bytes;
320 unsigned long pool_purr_cycles;
321 unsigned long pool_spurr_cycles;
322 unsigned long reserved[3];
323};
324
325int h_get_mpp_x(struct hvcall_mpp_x_data *mpp_x_data);
326
313#ifdef CONFIG_PPC_PSERIES 327#ifdef CONFIG_PPC_PSERIES
314extern int CMO_PrPSP; 328extern int CMO_PrPSP;
315extern int CMO_SecPSP; 329extern int CMO_SecPSP;
diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h
index bd100fcf40d0..bb712c9488b3 100644
--- a/arch/powerpc/include/asm/hw_irq.h
+++ b/arch/powerpc/include/asm/hw_irq.h
@@ -16,42 +16,57 @@ extern void timer_interrupt(struct pt_regs *);
16#ifdef CONFIG_PPC64 16#ifdef CONFIG_PPC64
17#include <asm/paca.h> 17#include <asm/paca.h>
18 18
19static inline unsigned long local_get_flags(void) 19static inline unsigned long arch_local_save_flags(void)
20{ 20{
21 unsigned long flags; 21 unsigned long flags;
22 22
23 __asm__ __volatile__("lbz %0,%1(13)" 23 asm volatile(
24 : "=r" (flags) 24 "lbz %0,%1(13)"
25 : "i" (offsetof(struct paca_struct, soft_enabled))); 25 : "=r" (flags)
26 : "i" (offsetof(struct paca_struct, soft_enabled)));
26 27
27 return flags; 28 return flags;
28} 29}
29 30
30static inline unsigned long raw_local_irq_disable(void) 31static inline unsigned long arch_local_irq_disable(void)
31{ 32{
32 unsigned long flags, zero; 33 unsigned long flags, zero;
33 34
34 __asm__ __volatile__("li %1,0; lbz %0,%2(13); stb %1,%2(13)" 35 asm volatile(
35 : "=r" (flags), "=&r" (zero) 36 "li %1,0; lbz %0,%2(13); stb %1,%2(13)"
36 : "i" (offsetof(struct paca_struct, soft_enabled)) 37 : "=r" (flags), "=&r" (zero)
37 : "memory"); 38 : "i" (offsetof(struct paca_struct, soft_enabled))
39 : "memory");
38 40
39 return flags; 41 return flags;
40} 42}
41 43
42extern void raw_local_irq_restore(unsigned long); 44extern void arch_local_irq_restore(unsigned long);
43extern void iseries_handle_interrupts(void); 45extern void iseries_handle_interrupts(void);
44 46
45#define raw_local_irq_enable() raw_local_irq_restore(1) 47static inline void arch_local_irq_enable(void)
46#define raw_local_save_flags(flags) ((flags) = local_get_flags()) 48{
47#define raw_local_irq_save(flags) ((flags) = raw_local_irq_disable()) 49 arch_local_irq_restore(1);
50}
51
52static inline unsigned long arch_local_irq_save(void)
53{
54 return arch_local_irq_disable();
55}
56
57static inline bool arch_irqs_disabled_flags(unsigned long flags)
58{
59 return flags == 0;
60}
48 61
49#define raw_irqs_disabled() (local_get_flags() == 0) 62static inline bool arch_irqs_disabled(void)
50#define raw_irqs_disabled_flags(flags) ((flags) == 0) 63{
64 return arch_irqs_disabled_flags(arch_local_save_flags());
65}
51 66
52#ifdef CONFIG_PPC_BOOK3E 67#ifdef CONFIG_PPC_BOOK3E
53#define __hard_irq_enable() __asm__ __volatile__("wrteei 1": : :"memory"); 68#define __hard_irq_enable() asm volatile("wrteei 1" : : : "memory");
54#define __hard_irq_disable() __asm__ __volatile__("wrteei 0": : :"memory"); 69#define __hard_irq_disable() asm volatile("wrteei 0" : : : "memory");
55#else 70#else
56#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1) 71#define __hard_irq_enable() __mtmsrd(mfmsr() | MSR_EE, 1)
57#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1) 72#define __hard_irq_disable() __mtmsrd(mfmsr() & ~MSR_EE, 1)
@@ -64,66 +79,70 @@ extern void iseries_handle_interrupts(void);
64 get_paca()->hard_enabled = 0; \ 79 get_paca()->hard_enabled = 0; \
65 } while(0) 80 } while(0)
66 81
67#else 82#else /* CONFIG_PPC64 */
68 83
69#if defined(CONFIG_BOOKE)
70#define SET_MSR_EE(x) mtmsr(x) 84#define SET_MSR_EE(x) mtmsr(x)
71#define raw_local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory") 85
86static inline unsigned long arch_local_save_flags(void)
87{
88 return mfmsr();
89}
90
91static inline void arch_local_irq_restore(unsigned long flags)
92{
93#if defined(CONFIG_BOOKE)
94 asm volatile("wrtee %0" : : "r" (flags) : "memory");
72#else 95#else
73#define SET_MSR_EE(x) mtmsr(x) 96 mtmsr(flags);
74#define raw_local_irq_restore(flags) mtmsr(flags)
75#endif 97#endif
98}
76 99
77static inline void raw_local_irq_disable(void) 100static inline unsigned long arch_local_irq_save(void)
78{ 101{
102 unsigned long flags = arch_local_save_flags();
79#ifdef CONFIG_BOOKE 103#ifdef CONFIG_BOOKE
80 __asm__ __volatile__("wrteei 0": : :"memory"); 104 asm volatile("wrteei 0" : : : "memory");
81#else 105#else
82 unsigned long msr; 106 SET_MSR_EE(flags & ~MSR_EE);
83
84 msr = mfmsr();
85 SET_MSR_EE(msr & ~MSR_EE);
86#endif 107#endif
108 return flags;
87} 109}
88 110
89static inline void raw_local_irq_enable(void) 111static inline void arch_local_irq_disable(void)
90{ 112{
91#ifdef CONFIG_BOOKE 113#ifdef CONFIG_BOOKE
92 __asm__ __volatile__("wrteei 1": : :"memory"); 114 asm volatile("wrteei 0" : : : "memory");
93#else 115#else
94 unsigned long msr; 116 arch_local_irq_save();
95
96 msr = mfmsr();
97 SET_MSR_EE(msr | MSR_EE);
98#endif 117#endif
99} 118}
100 119
101static inline void raw_local_irq_save_ptr(unsigned long *flags) 120static inline void arch_local_irq_enable(void)
102{ 121{
103 unsigned long msr;
104 msr = mfmsr();
105 *flags = msr;
106#ifdef CONFIG_BOOKE 122#ifdef CONFIG_BOOKE
107 __asm__ __volatile__("wrteei 0": : :"memory"); 123 asm volatile("wrteei 1" : : : "memory");
108#else 124#else
109 SET_MSR_EE(msr & ~MSR_EE); 125 unsigned long msr = mfmsr();
126 SET_MSR_EE(msr | MSR_EE);
110#endif 127#endif
111} 128}
112 129
113#define raw_local_save_flags(flags) ((flags) = mfmsr()) 130static inline bool arch_irqs_disabled_flags(unsigned long flags)
114#define raw_local_irq_save(flags) raw_local_irq_save_ptr(&flags)
115#define raw_irqs_disabled() ((mfmsr() & MSR_EE) == 0)
116#define raw_irqs_disabled_flags(flags) (((flags) & MSR_EE) == 0)
117
118#define hard_irq_disable() raw_local_irq_disable()
119
120static inline int irqs_disabled_flags(unsigned long flags)
121{ 131{
122 return (flags & MSR_EE) == 0; 132 return (flags & MSR_EE) == 0;
123} 133}
124 134
135static inline bool arch_irqs_disabled(void)
136{
137 return arch_irqs_disabled_flags(arch_local_save_flags());
138}
139
140#define hard_irq_disable() arch_local_irq_disable()
141
125#endif /* CONFIG_PPC64 */ 142#endif /* CONFIG_PPC64 */
126 143
144#define ARCH_IRQ_INIT_FLAGS IRQ_NOREQUEST
145
127/* 146/*
128 * interrupt-retrigger: should we handle this via lost interrupts and IPIs 147 * interrupt-retrigger: should we handle this via lost interrupts and IPIs
129 * or should we not care like we do now ? --BenH. 148 * or should we not care like we do now ? --BenH.
diff --git a/arch/powerpc/include/asm/hydra.h b/arch/powerpc/include/asm/hydra.h
index 1ad4eed07fbe..5b0c98bd46ab 100644
--- a/arch/powerpc/include/asm/hydra.h
+++ b/arch/powerpc/include/asm/hydra.h
@@ -10,7 +10,7 @@
10 * 10 *
11 * © Copyright 1995 Apple Computer, Inc. All rights reserved. 11 * © Copyright 1995 Apple Computer, Inc. All rights reserved.
12 * 12 *
13 * It's available online from http://chrp.apple.com/MacTech.pdf. 13 * It's available online from http://www.cpu.lu/~mlan/ftp/MacTech.pdf
14 * You can obtain paper copies of this book from computer bookstores or by 14 * You can obtain paper copies of this book from computer bookstores or by
15 * writing Morgan Kaufmann Publishers, Inc., 340 Pine Street, Sixth Floor, San 15 * writing Morgan Kaufmann Publishers, Inc., 340 Pine Street, Sixth Floor, San
16 * Francisco, CA 94104. Reference ISBN 1-55860-393-X. 16 * Francisco, CA 94104. Reference ISBN 1-55860-393-X.
diff --git a/arch/powerpc/include/asm/immap_qe.h b/arch/powerpc/include/asm/immap_qe.h
index 4e10f508570a..0edb6842b13d 100644
--- a/arch/powerpc/include/asm/immap_qe.h
+++ b/arch/powerpc/include/asm/immap_qe.h
@@ -467,13 +467,22 @@ struct qe_immap {
467extern struct qe_immap __iomem *qe_immr; 467extern struct qe_immap __iomem *qe_immr;
468extern phys_addr_t get_qe_base(void); 468extern phys_addr_t get_qe_base(void);
469 469
470static inline unsigned long immrbar_virt_to_phys(void *address) 470/*
471 * Returns the offset within the QE address space of the given pointer.
472 *
473 * Note that the QE does not support 36-bit physical addresses, so if
474 * get_qe_base() returns a number above 4GB, the caller will probably fail.
475 */
476static inline phys_addr_t immrbar_virt_to_phys(void *address)
471{ 477{
472 if ( ((u32)address >= (u32)qe_immr) && 478 void *q = (void *)qe_immr;
473 ((u32)address < ((u32)qe_immr + QE_IMMAP_SIZE)) ) 479
474 return (unsigned long)(address - (u32)qe_immr + 480 /* Is it a MURAM address? */
475 (u32)get_qe_base()); 481 if ((address >= q) && (address < (q + QE_IMMAP_SIZE)))
476 return (unsigned long)virt_to_phys(address); 482 return get_qe_base() + (address - q);
483
484 /* It's an address returned by kmalloc */
485 return virt_to_phys(address);
477} 486}
478 487
479#endif /* __KERNEL__ */ 488#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/io-workarounds.h b/arch/powerpc/include/asm/io-workarounds.h
new file mode 100644
index 000000000000..fbae49286926
--- /dev/null
+++ b/arch/powerpc/include/asm/io-workarounds.h
@@ -0,0 +1,48 @@
1/*
2 * Support PCI IO workaround
3 *
4 * (C) Copyright 2007-2008 TOSHIBA CORPORATION
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#ifndef _IO_WORKAROUNDS_H
22#define _IO_WORKAROUNDS_H
23
24#include <linux/io.h>
25#include <asm/pci-bridge.h>
26
27/* Bus info */
28struct iowa_bus {
29 struct pci_controller *phb;
30 struct ppc_pci_io *ops;
31 void *private;
32};
33
34void __devinit iowa_register_bus(struct pci_controller *, struct ppc_pci_io *,
35 int (*)(struct iowa_bus *, void *), void *);
36struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR);
37struct iowa_bus *iowa_pio_find_bus(unsigned long);
38
39extern struct ppc_pci_io spiderpci_ops;
40extern int spiderpci_iowa_init(struct iowa_bus *, void *);
41
42#define SPIDER_PCI_REG_BASE 0xd000
43#define SPIDER_PCI_REG_SIZE 0x1000
44#define SPIDER_PCI_VCI_CNTL_STAT 0x0110
45#define SPIDER_PCI_DUMMY_READ 0x0810
46#define SPIDER_PCI_DUMMY_READ_BASE 0x0814
47
48#endif /* _IO_WORKAROUNDS_H */
diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index 001f2f11c19b..45698d55cd6a 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -2,6 +2,8 @@
2#define _ASM_POWERPC_IO_H 2#define _ASM_POWERPC_IO_H
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#define ARCH_HAS_IOREMAP_WC
6
5/* 7/*
6 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License 9 * modify it under the terms of the GNU General Public License
@@ -481,10 +483,16 @@ __do_out_asm(_rec_outl, "stwbrx")
481 _memcpy_fromio(dst,PCI_FIX_ADDR(src),n) 483 _memcpy_fromio(dst,PCI_FIX_ADDR(src),n)
482#endif /* !CONFIG_EEH */ 484#endif /* !CONFIG_EEH */
483 485
484#ifdef CONFIG_PPC_INDIRECT_IO 486#ifdef CONFIG_PPC_INDIRECT_PIO
485#define DEF_PCI_HOOK(x) x 487#define DEF_PCI_HOOK_pio(x) x
488#else
489#define DEF_PCI_HOOK_pio(x) NULL
490#endif
491
492#ifdef CONFIG_PPC_INDIRECT_MMIO
493#define DEF_PCI_HOOK_mem(x) x
486#else 494#else
487#define DEF_PCI_HOOK(x) NULL 495#define DEF_PCI_HOOK_mem(x) NULL
488#endif 496#endif
489 497
490/* Structure containing all the hooks */ 498/* Structure containing all the hooks */
@@ -504,7 +512,7 @@ extern struct ppc_pci_io {
504#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \ 512#define DEF_PCI_AC_RET(name, ret, at, al, space, aa) \
505static inline ret name at \ 513static inline ret name at \
506{ \ 514{ \
507 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \ 515 if (DEF_PCI_HOOK_##space(ppc_pci_io.name) != NULL) \
508 return ppc_pci_io.name al; \ 516 return ppc_pci_io.name al; \
509 return __do_##name al; \ 517 return __do_##name al; \
510} 518}
@@ -512,7 +520,7 @@ static inline ret name at \
512#define DEF_PCI_AC_NORET(name, at, al, space, aa) \ 520#define DEF_PCI_AC_NORET(name, at, al, space, aa) \
513static inline void name at \ 521static inline void name at \
514{ \ 522{ \
515 if (DEF_PCI_HOOK(ppc_pci_io.name) != NULL) \ 523 if (DEF_PCI_HOOK_##space(ppc_pci_io.name) != NULL) \
516 ppc_pci_io.name al; \ 524 ppc_pci_io.name al; \
517 else \ 525 else \
518 __do_##name al; \ 526 __do_##name al; \
@@ -616,12 +624,13 @@ static inline void iosync(void)
616 * * ioremap is the standard one and provides non-cacheable guarded mappings 624 * * ioremap is the standard one and provides non-cacheable guarded mappings
617 * and can be hooked by the platform via ppc_md 625 * and can be hooked by the platform via ppc_md
618 * 626 *
619 * * ioremap_flags allows to specify the page flags as an argument and can 627 * * ioremap_prot allows to specify the page flags as an argument and can
620 * also be hooked by the platform via ppc_md. ioremap_prot is the exact 628 * also be hooked by the platform via ppc_md.
621 * same thing as ioremap_flags.
622 * 629 *
623 * * ioremap_nocache is identical to ioremap 630 * * ioremap_nocache is identical to ioremap
624 * 631 *
632 * * ioremap_wc enables write combining
633 *
625 * * iounmap undoes such a mapping and can be hooked 634 * * iounmap undoes such a mapping and can be hooked
626 * 635 *
627 * * __ioremap_at (and the pending __iounmap_at) are low level functions to 636 * * __ioremap_at (and the pending __iounmap_at) are low level functions to
@@ -629,7 +638,7 @@ static inline void iosync(void)
629 * currently be hooked. Must be page aligned. 638 * currently be hooked. Must be page aligned.
630 * 639 *
631 * * __ioremap is the low level implementation used by ioremap and 640 * * __ioremap is the low level implementation used by ioremap and
632 * ioremap_flags and cannot be hooked (but can be used by a hook on one 641 * ioremap_prot and cannot be hooked (but can be used by a hook on one
633 * of the previous ones) 642 * of the previous ones)
634 * 643 *
635 * * __ioremap_caller is the same as above but takes an explicit caller 644 * * __ioremap_caller is the same as above but takes an explicit caller
@@ -640,10 +649,10 @@ static inline void iosync(void)
640 * 649 *
641 */ 650 */
642extern void __iomem *ioremap(phys_addr_t address, unsigned long size); 651extern void __iomem *ioremap(phys_addr_t address, unsigned long size);
643extern void __iomem *ioremap_flags(phys_addr_t address, unsigned long size, 652extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size,
644 unsigned long flags); 653 unsigned long flags);
654extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
645#define ioremap_nocache(addr, size) ioremap((addr), (size)) 655#define ioremap_nocache(addr, size) ioremap((addr), (size))
646#define ioremap_prot(addr, size, prot) ioremap_flags((addr), (size), (prot))
647 656
648extern void iounmap(volatile void __iomem *addr); 657extern void iounmap(volatile void __iomem *addr);
649 658
diff --git a/arch/powerpc/include/asm/io_event_irq.h b/arch/powerpc/include/asm/io_event_irq.h
new file mode 100644
index 000000000000..b1a9a1be3c21
--- /dev/null
+++ b/arch/powerpc/include/asm/io_event_irq.h
@@ -0,0 +1,54 @@
1/*
2 * Copyright 2010, 2011 Mark Nelson and Tseng-Hui (Frank) Lin, IBM Corporation
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9
10#ifndef _ASM_POWERPC_IO_EVENT_IRQ_H
11#define _ASM_POWERPC_IO_EVENT_IRQ_H
12
13#include <linux/types.h>
14#include <linux/notifier.h>
15
16#define PSERIES_IOEI_RPC_MAX_LEN 216
17
18#define PSERIES_IOEI_TYPE_ERR_DETECTED 0x01
19#define PSERIES_IOEI_TYPE_ERR_RECOVERED 0x02
20#define PSERIES_IOEI_TYPE_EVENT 0x03
21#define PSERIES_IOEI_TYPE_RPC_PASS_THRU 0x04
22
23#define PSERIES_IOEI_SUBTYPE_NOT_APP 0x00
24#define PSERIES_IOEI_SUBTYPE_REBALANCE_REQ 0x01
25#define PSERIES_IOEI_SUBTYPE_NODE_ONLINE 0x03
26#define PSERIES_IOEI_SUBTYPE_NODE_OFFLINE 0x04
27#define PSERIES_IOEI_SUBTYPE_DUMP_SIZE_CHANGE 0x05
28#define PSERIES_IOEI_SUBTYPE_TORRENT_IRV_UPDATE 0x06
29#define PSERIES_IOEI_SUBTYPE_TORRENT_HFI_CFGED 0x07
30
31#define PSERIES_IOEI_SCOPE_NOT_APP 0x00
32#define PSERIES_IOEI_SCOPE_RIO_HUB 0x36
33#define PSERIES_IOEI_SCOPE_RIO_BRIDGE 0x37
34#define PSERIES_IOEI_SCOPE_PHB 0x38
35#define PSERIES_IOEI_SCOPE_EADS_GLOBAL 0x39
36#define PSERIES_IOEI_SCOPE_EADS_SLOT 0x3A
37#define PSERIES_IOEI_SCOPE_TORRENT_HUB 0x3B
38#define PSERIES_IOEI_SCOPE_SERVICE_PROC 0x51
39
40/* Platform Event Log Format, Version 6, data portition of IO event section */
41struct pseries_io_event {
42 uint8_t event_type; /* 0x00 IO-Event Type */
43 uint8_t rpc_data_len; /* 0x01 RPC data length */
44 uint8_t scope; /* 0x02 Error/Event Scope */
45 uint8_t event_subtype; /* 0x03 I/O-Event Sub-Type */
46 uint32_t drc_index; /* 0x04 DRC Index */
47 uint8_t rpc_data[PSERIES_IOEI_RPC_MAX_LEN];
48 /* 0x08 RPC Data (0-216 bytes, */
49 /* padded to 4 bytes alignment) */
50};
51
52extern struct atomic_notifier_head pseries_ioei_notifier_list;
53
54#endif /* _ASM_POWERPC_IO_EVENT_IRQ_H */
diff --git a/arch/powerpc/include/asm/ioctls.h b/arch/powerpc/include/asm/ioctls.h
index 851920052e08..e9b78870aaab 100644
--- a/arch/powerpc/include/asm/ioctls.h
+++ b/arch/powerpc/include/asm/ioctls.h
@@ -94,7 +94,9 @@
94#define TIOCSRS485 0x542f 94#define TIOCSRS485 0x542f
95#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 95#define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
96#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 96#define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */
97#define TIOCGDEV _IOR('T',0x32, unsigned int) /* Get primary device node of /dev/console */
97#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 98#define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */
99#define TIOCVHANGUP 0x5437
98 100
99#define TIOCSERCONFIG 0x5453 101#define TIOCSERCONFIG 0x5453
100#define TIOCSERGWILD 0x5454 102#define TIOCSERGWILD 0x5454
diff --git a/arch/powerpc/include/asm/irq.h b/arch/powerpc/include/asm/irq.h
index 67ab5fb7d153..1bff591f7f72 100644
--- a/arch/powerpc/include/asm/irq.h
+++ b/arch/powerpc/include/asm/irq.h
@@ -88,9 +88,6 @@ struct irq_host_ops {
88 /* Dispose of such a mapping */ 88 /* Dispose of such a mapping */
89 void (*unmap)(struct irq_host *h, unsigned int virq); 89 void (*unmap)(struct irq_host *h, unsigned int virq);
90 90
91 /* Update of such a mapping */
92 void (*remap)(struct irq_host *h, unsigned int virq, irq_hw_number_t hw);
93
94 /* Translate device-tree interrupt specifier from raw format coming 91 /* Translate device-tree interrupt specifier from raw format coming
95 * from the firmware to a irq_hw_number_t (interrupt line number) and 92 * from the firmware to a irq_hw_number_t (interrupt line number) and
96 * type (sense) that can be passed to set_irq_type(). In the absence 93 * type (sense) that can be passed to set_irq_type(). In the absence
@@ -128,19 +125,10 @@ struct irq_host {
128 struct device_node *of_node; 125 struct device_node *of_node;
129}; 126};
130 127
131/* The main irq map itself is an array of NR_IRQ entries containing the 128struct irq_data;
132 * associate host and irq number. An entry with a host of NULL is free. 129extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d);
133 * An entry can be allocated if it's free, the allocator always then sets
134 * hwirq first to the host's invalid irq number and then fills ops.
135 */
136struct irq_map_entry {
137 irq_hw_number_t hwirq;
138 struct irq_host *host;
139};
140
141extern struct irq_map_entry irq_map[NR_IRQS];
142
143extern irq_hw_number_t virq_to_hw(unsigned int virq); 130extern irq_hw_number_t virq_to_hw(unsigned int virq);
131extern bool virq_is_host(unsigned int virq, struct irq_host *host);
144 132
145/** 133/**
146 * irq_alloc_host - Allocate a new irq_host data structure 134 * irq_alloc_host - Allocate a new irq_host data structure
diff --git a/arch/powerpc/include/asm/irqflags.h b/arch/powerpc/include/asm/irqflags.h
index 5f68ecfdf516..b0b06d85788d 100644
--- a/arch/powerpc/include/asm/irqflags.h
+++ b/arch/powerpc/include/asm/irqflags.h
@@ -6,30 +6,50 @@
6 6
7#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
8/* 8/*
9 * Get definitions for raw_local_save_flags(x), etc. 9 * Get definitions for arch_local_save_flags(x), etc.
10 */ 10 */
11#include <asm/hw_irq.h> 11#include <asm/hw_irq.h>
12 12
13#else 13#else
14#ifdef CONFIG_TRACE_IRQFLAGS 14#ifdef CONFIG_TRACE_IRQFLAGS
15#ifdef CONFIG_IRQSOFF_TRACER
16/*
17 * Since the ftrace irqsoff latency trace checks CALLER_ADDR1,
18 * which is the stack frame here, we need to force a stack frame
19 * in case we came from user space.
20 */
21#define TRACE_WITH_FRAME_BUFFER(func) \
22 mflr r0; \
23 stdu r1, -32(r1); \
24 std r0, 16(r1); \
25 stdu r1, -32(r1); \
26 bl func; \
27 ld r1, 0(r1); \
28 ld r1, 0(r1);
29#else
30#define TRACE_WITH_FRAME_BUFFER(func) \
31 bl func;
32#endif
33
15/* 34/*
16 * Most of the CPU's IRQ-state tracing is done from assembly code; we 35 * Most of the CPU's IRQ-state tracing is done from assembly code; we
17 * have to call a C function so call a wrapper that saves all the 36 * have to call a C function so call a wrapper that saves all the
18 * C-clobbered registers. 37 * C-clobbered registers.
19 */ 38 */
20#define TRACE_ENABLE_INTS bl .trace_hardirqs_on 39#define TRACE_ENABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_on)
21#define TRACE_DISABLE_INTS bl .trace_hardirqs_off 40#define TRACE_DISABLE_INTS TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off)
22#define TRACE_AND_RESTORE_IRQ_PARTIAL(en,skip) \ 41
23 cmpdi en,0; \ 42#define TRACE_AND_RESTORE_IRQ_PARTIAL(en,skip) \
24 bne 95f; \ 43 cmpdi en,0; \
25 stb en,PACASOFTIRQEN(r13); \ 44 bne 95f; \
26 bl .trace_hardirqs_off; \ 45 stb en,PACASOFTIRQEN(r13); \
27 b skip; \ 46 TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_off) \
2895: bl .trace_hardirqs_on; \ 47 b skip; \
4895: TRACE_WITH_FRAME_BUFFER(.trace_hardirqs_on) \
29 li en,1; 49 li en,1;
30#define TRACE_AND_RESTORE_IRQ(en) \ 50#define TRACE_AND_RESTORE_IRQ(en) \
31 TRACE_AND_RESTORE_IRQ_PARTIAL(en,96f); \ 51 TRACE_AND_RESTORE_IRQ_PARTIAL(en,96f); \
32 stb en,PACASOFTIRQEN(r13); \ 52 stb en,PACASOFTIRQEN(r13); \
3396: 5396:
34#else 54#else
35#define TRACE_ENABLE_INTS 55#define TRACE_ENABLE_INTS
diff --git a/arch/powerpc/include/asm/kexec.h b/arch/powerpc/include/asm/kexec.h
index 076327f2eff7..8a33698c61bd 100644
--- a/arch/powerpc/include/asm/kexec.h
+++ b/arch/powerpc/include/asm/kexec.h
@@ -76,7 +76,7 @@ extern void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *));
76extern cpumask_t cpus_in_sr; 76extern cpumask_t cpus_in_sr;
77static inline int kexec_sr_activated(int cpu) 77static inline int kexec_sr_activated(int cpu)
78{ 78{
79 return cpu_isset(cpu,cpus_in_sr); 79 return cpumask_test_cpu(cpu, &cpus_in_sr);
80} 80}
81 81
82struct kimage; 82struct kimage;
@@ -91,6 +91,7 @@ extern void machine_kexec_simple(struct kimage *image);
91extern void crash_kexec_secondary(struct pt_regs *regs); 91extern void crash_kexec_secondary(struct pt_regs *regs);
92extern int overlaps_crashkernel(unsigned long start, unsigned long size); 92extern int overlaps_crashkernel(unsigned long start, unsigned long size);
93extern void reserve_crashkernel(void); 93extern void reserve_crashkernel(void);
94extern void machine_kexec_mask_interrupts(void);
94 95
95#else /* !CONFIG_KEXEC */ 96#else /* !CONFIG_KEXEC */
96static inline int kexec_sr_activated(int cpu) { return 0; } 97static inline int kexec_sr_activated(int cpu) { return 0; }
diff --git a/arch/powerpc/include/asm/kgdb.h b/arch/powerpc/include/asm/kgdb.h
index edd217006d27..9db24e77b9f4 100644
--- a/arch/powerpc/include/asm/kgdb.h
+++ b/arch/powerpc/include/asm/kgdb.h
@@ -31,6 +31,7 @@ static inline void arch_kgdb_breakpoint(void)
31 asm(".long 0x7d821008"); /* twge r2, r2 */ 31 asm(".long 0x7d821008"); /* twge r2, r2 */
32} 32}
33#define CACHE_FLUSH_IS_SAFE 1 33#define CACHE_FLUSH_IS_SAFE 1
34#define DBG_MAX_REG_NUM 70
34 35
35/* The number bytes of registers we have to save depends on a few 36/* The number bytes of registers we have to save depends on a few
36 * things. For 64bit we default to not including vector registers and 37 * things. For 64bit we default to not including vector registers and
diff --git a/arch/powerpc/include/asm/kprobes.h b/arch/powerpc/include/asm/kprobes.h
index d0e7701fa1f6..be0171afdc0f 100644
--- a/arch/powerpc/include/asm/kprobes.h
+++ b/arch/powerpc/include/asm/kprobes.h
@@ -50,7 +50,7 @@ typedef unsigned int kprobe_opcode_t;
50 * Handle cases where: 50 * Handle cases where:
51 * - User passes a <.symbol> or <module:.symbol> 51 * - User passes a <.symbol> or <module:.symbol>
52 * - User passes a <symbol> or <module:symbol> 52 * - User passes a <symbol> or <module:symbol>
53 * - User passes a non-existant symbol, kallsyms_lookup_name 53 * - User passes a non-existent symbol, kallsyms_lookup_name
54 * returns 0. Don't deref the NULL pointer in that case 54 * returns 0. Don't deref the NULL pointer in that case
55 */ 55 */
56#define kprobe_lookup_name(name, addr) \ 56#define kprobe_lookup_name(name, addr) \
diff --git a/arch/powerpc/include/asm/kvm.h b/arch/powerpc/include/asm/kvm.h
index 6c5547d82bbe..d2ca5ed3877b 100644
--- a/arch/powerpc/include/asm/kvm.h
+++ b/arch/powerpc/include/asm/kvm.h
@@ -45,6 +45,114 @@ struct kvm_regs {
45 __u64 gpr[32]; 45 __u64 gpr[32];
46}; 46};
47 47
48#define KVM_SREGS_E_IMPL_NONE 0
49#define KVM_SREGS_E_IMPL_FSL 1
50
51#define KVM_SREGS_E_FSL_PIDn (1 << 0) /* PID1/PID2 */
52
53/*
54 * Feature bits indicate which sections of the sregs struct are valid,
55 * both in KVM_GET_SREGS and KVM_SET_SREGS. On KVM_SET_SREGS, registers
56 * corresponding to unset feature bits will not be modified. This allows
57 * restoring a checkpoint made without that feature, while keeping the
58 * default values of the new registers.
59 *
60 * KVM_SREGS_E_BASE contains:
61 * CSRR0/1 (refers to SRR2/3 on 40x)
62 * ESR
63 * DEAR
64 * MCSR
65 * TSR
66 * TCR
67 * DEC
68 * TB
69 * VRSAVE (USPRG0)
70 */
71#define KVM_SREGS_E_BASE (1 << 0)
72
73/*
74 * KVM_SREGS_E_ARCH206 contains:
75 *
76 * PIR
77 * MCSRR0/1
78 * DECAR
79 * IVPR
80 */
81#define KVM_SREGS_E_ARCH206 (1 << 1)
82
83/*
84 * Contains EPCR, plus the upper half of 64-bit registers
85 * that are 32-bit on 32-bit implementations.
86 */
87#define KVM_SREGS_E_64 (1 << 2)
88
89#define KVM_SREGS_E_SPRG8 (1 << 3)
90#define KVM_SREGS_E_MCIVPR (1 << 4)
91
92/*
93 * IVORs are used -- contains IVOR0-15, plus additional IVORs
94 * in combination with an appropriate feature bit.
95 */
96#define KVM_SREGS_E_IVOR (1 << 5)
97
98/*
99 * Contains MAS0-4, MAS6-7, TLBnCFG, MMUCFG.
100 * Also TLBnPS if MMUCFG[MAVN] = 1.
101 */
102#define KVM_SREGS_E_ARCH206_MMU (1 << 6)
103
104/* DBSR, DBCR, IAC, DAC, DVC */
105#define KVM_SREGS_E_DEBUG (1 << 7)
106
107/* Enhanced debug -- DSRR0/1, SPRG9 */
108#define KVM_SREGS_E_ED (1 << 8)
109
110/* Embedded Floating Point (SPE) -- IVOR32-34 if KVM_SREGS_E_IVOR */
111#define KVM_SREGS_E_SPE (1 << 9)
112
113/* External Proxy (EXP) -- EPR */
114#define KVM_SREGS_EXP (1 << 10)
115
116/* External PID (E.PD) -- EPSC/EPLC */
117#define KVM_SREGS_E_PD (1 << 11)
118
119/* Processor Control (E.PC) -- IVOR36-37 if KVM_SREGS_E_IVOR */
120#define KVM_SREGS_E_PC (1 << 12)
121
122/* Page table (E.PT) -- EPTCFG */
123#define KVM_SREGS_E_PT (1 << 13)
124
125/* Embedded Performance Monitor (E.PM) -- IVOR35 if KVM_SREGS_E_IVOR */
126#define KVM_SREGS_E_PM (1 << 14)
127
128/*
129 * Special updates:
130 *
131 * Some registers may change even while a vcpu is not running.
132 * To avoid losing these changes, by default these registers are
133 * not updated by KVM_SET_SREGS. To force an update, set the bit
134 * in u.e.update_special corresponding to the register to be updated.
135 *
136 * The update_special field is zero on return from KVM_GET_SREGS.
137 *
138 * When restoring a checkpoint, the caller can set update_special
139 * to 0xffffffff to ensure that everything is restored, even new features
140 * that the caller doesn't know about.
141 */
142#define KVM_SREGS_E_UPDATE_MCSR (1 << 0)
143#define KVM_SREGS_E_UPDATE_TSR (1 << 1)
144#define KVM_SREGS_E_UPDATE_DEC (1 << 2)
145#define KVM_SREGS_E_UPDATE_DBSR (1 << 3)
146
147/*
148 * In KVM_SET_SREGS, reserved/pad fields must be left untouched from a
149 * previous KVM_GET_REGS.
150 *
151 * Unless otherwise indicated, setting any register with KVM_SET_SREGS
152 * directly sets its value. It does not trigger any special semantics such
153 * as write-one-to-clear. Calling KVM_SET_SREGS on an unmodified struct
154 * just received from KVM_GET_SREGS is always a no-op.
155 */
48struct kvm_sregs { 156struct kvm_sregs {
49 __u32 pvr; 157 __u32 pvr;
50 union { 158 union {
@@ -62,6 +170,82 @@ struct kvm_sregs {
62 __u64 dbat[8]; 170 __u64 dbat[8];
63 } ppc32; 171 } ppc32;
64 } s; 172 } s;
173 struct {
174 union {
175 struct { /* KVM_SREGS_E_IMPL_FSL */
176 __u32 features; /* KVM_SREGS_E_FSL_ */
177 __u32 svr;
178 __u64 mcar;
179 __u32 hid0;
180
181 /* KVM_SREGS_E_FSL_PIDn */
182 __u32 pid1, pid2;
183 } fsl;
184 __u8 pad[256];
185 } impl;
186
187 __u32 features; /* KVM_SREGS_E_ */
188 __u32 impl_id; /* KVM_SREGS_E_IMPL_ */
189 __u32 update_special; /* KVM_SREGS_E_UPDATE_ */
190 __u32 pir; /* read-only */
191 __u64 sprg8;
192 __u64 sprg9; /* E.ED */
193 __u64 csrr0;
194 __u64 dsrr0; /* E.ED */
195 __u64 mcsrr0;
196 __u32 csrr1;
197 __u32 dsrr1; /* E.ED */
198 __u32 mcsrr1;
199 __u32 esr;
200 __u64 dear;
201 __u64 ivpr;
202 __u64 mcivpr;
203 __u64 mcsr; /* KVM_SREGS_E_UPDATE_MCSR */
204
205 __u32 tsr; /* KVM_SREGS_E_UPDATE_TSR */
206 __u32 tcr;
207 __u32 decar;
208 __u32 dec; /* KVM_SREGS_E_UPDATE_DEC */
209
210 /*
211 * Userspace can read TB directly, but the
212 * value reported here is consistent with "dec".
213 *
214 * Read-only.
215 */
216 __u64 tb;
217
218 __u32 dbsr; /* KVM_SREGS_E_UPDATE_DBSR */
219 __u32 dbcr[3];
220 __u32 iac[4];
221 __u32 dac[2];
222 __u32 dvc[2];
223 __u8 num_iac; /* read-only */
224 __u8 num_dac; /* read-only */
225 __u8 num_dvc; /* read-only */
226 __u8 pad;
227
228 __u32 epr; /* EXP */
229 __u32 vrsave; /* a.k.a. USPRG0 */
230 __u32 epcr; /* KVM_SREGS_E_64 */
231
232 __u32 mas0;
233 __u32 mas1;
234 __u64 mas2;
235 __u64 mas7_3;
236 __u32 mas4;
237 __u32 mas6;
238
239 __u32 ivor_low[16]; /* IVOR0-15 */
240 __u32 ivor_high[18]; /* IVOR32+, plus room to expand */
241
242 __u32 mmucfg; /* read-only */
243 __u32 eptcfg; /* E.PT, read-only */
244 __u32 tlbcfg[4];/* read-only */
245 __u32 tlbps[4]; /* read-only */
246
247 __u32 eplc, epsc; /* E.PD */
248 } e;
65 __u8 pad[1020]; 249 __u8 pad[1020];
66 } u; 250 } u;
67}; 251};
@@ -86,5 +270,6 @@ struct kvm_guest_debug_arch {
86 270
87#define KVM_INTERRUPT_SET -1U 271#define KVM_INTERRUPT_SET -1U
88#define KVM_INTERRUPT_UNSET -2U 272#define KVM_INTERRUPT_UNSET -2U
273#define KVM_INTERRUPT_SET_LEVEL -3U
89 274
90#endif /* __LINUX_KVM_POWERPC_H */ 275#endif /* __LINUX_KVM_POWERPC_H */
diff --git a/arch/powerpc/include/asm/kvm_44x.h b/arch/powerpc/include/asm/kvm_44x.h
index d22d39942a92..a0e57618ff33 100644
--- a/arch/powerpc/include/asm/kvm_44x.h
+++ b/arch/powerpc/include/asm/kvm_44x.h
@@ -61,7 +61,6 @@ static inline struct kvmppc_vcpu_44x *to_44x(struct kvm_vcpu *vcpu)
61 return container_of(vcpu, struct kvmppc_vcpu_44x, vcpu); 61 return container_of(vcpu, struct kvmppc_vcpu_44x, vcpu);
62} 62}
63 63
64void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 new_pid);
65void kvmppc_44x_tlb_put(struct kvm_vcpu *vcpu); 64void kvmppc_44x_tlb_put(struct kvm_vcpu *vcpu);
66void kvmppc_44x_tlb_load(struct kvm_vcpu *vcpu); 65void kvmppc_44x_tlb_load(struct kvm_vcpu *vcpu);
67 66
diff --git a/arch/powerpc/include/asm/kvm_asm.h b/arch/powerpc/include/asm/kvm_asm.h
index c5ea4cda34b3..0951b17f4eb5 100644
--- a/arch/powerpc/include/asm/kvm_asm.h
+++ b/arch/powerpc/include/asm/kvm_asm.h
@@ -58,6 +58,8 @@
58#define BOOK3S_INTERRUPT_INST_STORAGE 0x400 58#define BOOK3S_INTERRUPT_INST_STORAGE 0x400
59#define BOOK3S_INTERRUPT_INST_SEGMENT 0x480 59#define BOOK3S_INTERRUPT_INST_SEGMENT 0x480
60#define BOOK3S_INTERRUPT_EXTERNAL 0x500 60#define BOOK3S_INTERRUPT_EXTERNAL 0x500
61#define BOOK3S_INTERRUPT_EXTERNAL_LEVEL 0x501
62#define BOOK3S_INTERRUPT_EXTERNAL_HV 0x502
61#define BOOK3S_INTERRUPT_ALIGNMENT 0x600 63#define BOOK3S_INTERRUPT_ALIGNMENT 0x600
62#define BOOK3S_INTERRUPT_PROGRAM 0x700 64#define BOOK3S_INTERRUPT_PROGRAM 0x700
63#define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800 65#define BOOK3S_INTERRUPT_FP_UNAVAIL 0x800
@@ -84,7 +86,8 @@
84#define BOOK3S_IRQPRIO_EXTERNAL 13 86#define BOOK3S_IRQPRIO_EXTERNAL 13
85#define BOOK3S_IRQPRIO_DECREMENTER 14 87#define BOOK3S_IRQPRIO_DECREMENTER 14
86#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15 88#define BOOK3S_IRQPRIO_PERFORMANCE_MONITOR 15
87#define BOOK3S_IRQPRIO_MAX 16 89#define BOOK3S_IRQPRIO_EXTERNAL_LEVEL 16
90#define BOOK3S_IRQPRIO_MAX 17
88 91
89#define BOOK3S_HFLAG_DCBZ32 0x1 92#define BOOK3S_HFLAG_DCBZ32 0x1
90#define BOOK3S_HFLAG_SLB 0x2 93#define BOOK3S_HFLAG_SLB 0x2
diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
index 8274a2d43925..d62e703f1214 100644
--- a/arch/powerpc/include/asm/kvm_book3s.h
+++ b/arch/powerpc/include/asm/kvm_book3s.h
@@ -38,15 +38,6 @@ struct kvmppc_slb {
38 bool class : 1; 38 bool class : 1;
39}; 39};
40 40
41struct kvmppc_sr {
42 u32 raw;
43 u32 vsid;
44 bool Ks : 1;
45 bool Kp : 1;
46 bool nx : 1;
47 bool valid : 1;
48};
49
50struct kvmppc_bat { 41struct kvmppc_bat {
51 u64 raw; 42 u64 raw;
52 u32 bepi; 43 u32 bepi;
@@ -69,6 +60,13 @@ struct kvmppc_sid_map {
69#define SID_MAP_NUM (1 << SID_MAP_BITS) 60#define SID_MAP_NUM (1 << SID_MAP_BITS)
70#define SID_MAP_MASK (SID_MAP_NUM - 1) 61#define SID_MAP_MASK (SID_MAP_NUM - 1)
71 62
63#ifdef CONFIG_PPC_BOOK3S_64
64#define SID_CONTEXTS 1
65#else
66#define SID_CONTEXTS 128
67#define VSID_POOL_SIZE (SID_CONTEXTS * 16)
68#endif
69
72struct kvmppc_vcpu_book3s { 70struct kvmppc_vcpu_book3s {
73 struct kvm_vcpu vcpu; 71 struct kvm_vcpu vcpu;
74 struct kvmppc_book3s_shadow_vcpu *shadow_vcpu; 72 struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
@@ -79,20 +77,22 @@ struct kvmppc_vcpu_book3s {
79 u64 vsid; 77 u64 vsid;
80 } slb_shadow[64]; 78 } slb_shadow[64];
81 u8 slb_shadow_max; 79 u8 slb_shadow_max;
82 struct kvmppc_sr sr[16];
83 struct kvmppc_bat ibat[8]; 80 struct kvmppc_bat ibat[8];
84 struct kvmppc_bat dbat[8]; 81 struct kvmppc_bat dbat[8];
85 u64 hid[6]; 82 u64 hid[6];
86 u64 gqr[8]; 83 u64 gqr[8];
87 int slb_nr; 84 int slb_nr;
88 u32 dsisr;
89 u64 sdr1; 85 u64 sdr1;
90 u64 hior; 86 u64 hior;
91 u64 msr_mask; 87 u64 msr_mask;
92 u64 vsid_first;
93 u64 vsid_next; 88 u64 vsid_next;
89#ifdef CONFIG_PPC_BOOK3S_32
90 u32 vsid_pool[VSID_POOL_SIZE];
91#else
92 u64 vsid_first;
94 u64 vsid_max; 93 u64 vsid_max;
95 int context_id; 94#endif
95 int context_id[SID_CONTEXTS];
96 ulong prog_flags; /* flags to inject when giving a 700 trap */ 96 ulong prog_flags; /* flags to inject when giving a 700 trap */
97}; 97};
98 98
@@ -131,9 +131,10 @@ extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
131 bool upper, u32 val); 131 bool upper, u32 val);
132extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr); 132extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
133extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu); 133extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu);
134extern pfn_t kvmppc_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn);
134 135
135extern u32 kvmppc_trampoline_lowmem; 136extern ulong kvmppc_trampoline_lowmem;
136extern u32 kvmppc_trampoline_enter; 137extern ulong kvmppc_trampoline_enter;
137extern void kvmppc_rmcall(ulong srr0, ulong srr1); 138extern void kvmppc_rmcall(ulong srr0, ulong srr1);
138extern void kvmppc_load_up_fpu(void); 139extern void kvmppc_load_up_fpu(void);
139extern void kvmppc_load_up_altivec(void); 140extern void kvmppc_load_up_altivec(void);
diff --git a/arch/powerpc/include/asm/kvm_book3s_asm.h b/arch/powerpc/include/asm/kvm_book3s_asm.h
index 36fdb3aff30b..d5a8a3861635 100644
--- a/arch/powerpc/include/asm/kvm_book3s_asm.h
+++ b/arch/powerpc/include/asm/kvm_book3s_asm.h
@@ -34,6 +34,7 @@
34 (\intno == BOOK3S_INTERRUPT_DATA_SEGMENT) || \ 34 (\intno == BOOK3S_INTERRUPT_DATA_SEGMENT) || \
35 (\intno == BOOK3S_INTERRUPT_INST_SEGMENT) || \ 35 (\intno == BOOK3S_INTERRUPT_INST_SEGMENT) || \
36 (\intno == BOOK3S_INTERRUPT_EXTERNAL) || \ 36 (\intno == BOOK3S_INTERRUPT_EXTERNAL) || \
37 (\intno == BOOK3S_INTERRUPT_EXTERNAL_HV) || \
37 (\intno == BOOK3S_INTERRUPT_ALIGNMENT) || \ 38 (\intno == BOOK3S_INTERRUPT_ALIGNMENT) || \
38 (\intno == BOOK3S_INTERRUPT_PROGRAM) || \ 39 (\intno == BOOK3S_INTERRUPT_PROGRAM) || \
39 (\intno == BOOK3S_INTERRUPT_FP_UNAVAIL) || \ 40 (\intno == BOOK3S_INTERRUPT_FP_UNAVAIL) || \
diff --git a/arch/powerpc/include/asm/kvm_e500.h b/arch/powerpc/include/asm/kvm_e500.h
index 7fea26fffb25..7a2a565f88c4 100644
--- a/arch/powerpc/include/asm/kvm_e500.h
+++ b/arch/powerpc/include/asm/kvm_e500.h
@@ -43,6 +43,7 @@ struct kvmppc_vcpu_e500 {
43 43
44 u32 host_pid[E500_PID_NUM]; 44 u32 host_pid[E500_PID_NUM];
45 u32 pid[E500_PID_NUM]; 45 u32 pid[E500_PID_NUM];
46 u32 svr;
46 47
47 u32 mas0; 48 u32 mas0;
48 u32 mas1; 49 u32 mas1;
@@ -58,6 +59,7 @@ struct kvmppc_vcpu_e500 {
58 u32 hid1; 59 u32 hid1;
59 u32 tlb0cfg; 60 u32 tlb0cfg;
60 u32 tlb1cfg; 61 u32 tlb1cfg;
62 u64 mcar;
61 63
62 struct kvm_vcpu vcpu; 64 struct kvm_vcpu vcpu;
63}; 65};
diff --git a/arch/powerpc/include/asm/kvm_fpu.h b/arch/powerpc/include/asm/kvm_fpu.h
index c3d4f0518a67..92daae132492 100644
--- a/arch/powerpc/include/asm/kvm_fpu.h
+++ b/arch/powerpc/include/asm/kvm_fpu.h
@@ -82,7 +82,7 @@ FPD_THREE_IN(fmadd)
82FPD_THREE_IN(fnmsub) 82FPD_THREE_IN(fnmsub)
83FPD_THREE_IN(fnmadd) 83FPD_THREE_IN(fnmadd)
84 84
85extern void kvm_cvt_fd(u32 *from, u64 *to, u64 *fpscr); 85extern void kvm_cvt_fd(u32 *from, u64 *to);
86extern void kvm_cvt_df(u64 *from, u32 *to, u64 *fpscr); 86extern void kvm_cvt_df(u64 *from, u32 *to);
87 87
88#endif 88#endif
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index b0b23c007d6e..186f150b9b89 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -25,6 +25,7 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/types.h> 26#include <linux/types.h>
27#include <linux/kvm_types.h> 27#include <linux/kvm_types.h>
28#include <linux/kvm_para.h>
28#include <asm/kvm_asm.h> 29#include <asm/kvm_asm.h>
29 30
30#define KVM_MAX_VCPUS 1 31#define KVM_MAX_VCPUS 1
@@ -41,12 +42,17 @@
41 42
42#define HPTEG_CACHE_NUM (1 << 15) 43#define HPTEG_CACHE_NUM (1 << 15)
43#define HPTEG_HASH_BITS_PTE 13 44#define HPTEG_HASH_BITS_PTE 13
45#define HPTEG_HASH_BITS_PTE_LONG 12
44#define HPTEG_HASH_BITS_VPTE 13 46#define HPTEG_HASH_BITS_VPTE 13
45#define HPTEG_HASH_BITS_VPTE_LONG 5 47#define HPTEG_HASH_BITS_VPTE_LONG 5
46#define HPTEG_HASH_NUM_PTE (1 << HPTEG_HASH_BITS_PTE) 48#define HPTEG_HASH_NUM_PTE (1 << HPTEG_HASH_BITS_PTE)
49#define HPTEG_HASH_NUM_PTE_LONG (1 << HPTEG_HASH_BITS_PTE_LONG)
47#define HPTEG_HASH_NUM_VPTE (1 << HPTEG_HASH_BITS_VPTE) 50#define HPTEG_HASH_NUM_VPTE (1 << HPTEG_HASH_BITS_VPTE)
48#define HPTEG_HASH_NUM_VPTE_LONG (1 << HPTEG_HASH_BITS_VPTE_LONG) 51#define HPTEG_HASH_NUM_VPTE_LONG (1 << HPTEG_HASH_BITS_VPTE_LONG)
49 52
53/* Physical Address Mask - allowed range of real mode RAM access */
54#define KVM_PAM 0x0fffffffffffffffULL
55
50struct kvm; 56struct kvm;
51struct kvm_run; 57struct kvm_run;
52struct kvm_vcpu; 58struct kvm_vcpu;
@@ -159,8 +165,10 @@ struct kvmppc_mmu {
159 165
160struct hpte_cache { 166struct hpte_cache {
161 struct hlist_node list_pte; 167 struct hlist_node list_pte;
168 struct hlist_node list_pte_long;
162 struct hlist_node list_vpte; 169 struct hlist_node list_vpte;
163 struct hlist_node list_vpte_long; 170 struct hlist_node list_vpte_long;
171 struct rcu_head rcu_head;
164 u64 host_va; 172 u64 host_va;
165 u64 pfn; 173 u64 pfn;
166 ulong slot; 174 ulong slot;
@@ -210,28 +218,24 @@ struct kvm_vcpu_arch {
210 u32 cr; 218 u32 cr;
211#endif 219#endif
212 220
213 ulong msr;
214#ifdef CONFIG_PPC_BOOK3S 221#ifdef CONFIG_PPC_BOOK3S
215 ulong shadow_msr; 222 ulong shadow_msr;
216 ulong hflags; 223 ulong hflags;
217 ulong guest_owned_ext; 224 ulong guest_owned_ext;
218#endif 225#endif
226 u32 vrsave; /* also USPRG0 */
219 u32 mmucr; 227 u32 mmucr;
220 ulong sprg0;
221 ulong sprg1;
222 ulong sprg2;
223 ulong sprg3;
224 ulong sprg4; 228 ulong sprg4;
225 ulong sprg5; 229 ulong sprg5;
226 ulong sprg6; 230 ulong sprg6;
227 ulong sprg7; 231 ulong sprg7;
228 ulong srr0;
229 ulong srr1;
230 ulong csrr0; 232 ulong csrr0;
231 ulong csrr1; 233 ulong csrr1;
232 ulong dsrr0; 234 ulong dsrr0;
233 ulong dsrr1; 235 ulong dsrr1;
234 ulong dear; 236 ulong mcsrr0;
237 ulong mcsrr1;
238 ulong mcsr;
235 ulong esr; 239 ulong esr;
236 u32 dec; 240 u32 dec;
237 u32 decar; 241 u32 decar;
@@ -255,6 +259,7 @@ struct kvm_vcpu_arch {
255 u32 dbsr; 259 u32 dbsr;
256 260
257#ifdef CONFIG_KVM_EXIT_TIMING 261#ifdef CONFIG_KVM_EXIT_TIMING
262 struct mutex exit_timing_lock;
258 struct kvmppc_exit_timing timing_exit; 263 struct kvmppc_exit_timing timing_exit;
259 struct kvmppc_exit_timing timing_last_enter; 264 struct kvmppc_exit_timing timing_last_enter;
260 u32 last_exit_type; 265 u32 last_exit_type;
@@ -290,12 +295,17 @@ struct kvm_vcpu_arch {
290 struct tasklet_struct tasklet; 295 struct tasklet_struct tasklet;
291 u64 dec_jiffies; 296 u64 dec_jiffies;
292 unsigned long pending_exceptions; 297 unsigned long pending_exceptions;
298 struct kvm_vcpu_arch_shared *shared;
299 unsigned long magic_page_pa; /* phys addr to map the magic page to */
300 unsigned long magic_page_ea; /* effect. addr to map the magic page to */
293 301
294#ifdef CONFIG_PPC_BOOK3S 302#ifdef CONFIG_PPC_BOOK3S
295 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE]; 303 struct hlist_head hpte_hash_pte[HPTEG_HASH_NUM_PTE];
304 struct hlist_head hpte_hash_pte_long[HPTEG_HASH_NUM_PTE_LONG];
296 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE]; 305 struct hlist_head hpte_hash_vpte[HPTEG_HASH_NUM_VPTE];
297 struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG]; 306 struct hlist_head hpte_hash_vpte_long[HPTEG_HASH_NUM_VPTE_LONG];
298 int hpte_cache_count; 307 int hpte_cache_count;
308 spinlock_t mmu_lock;
299#endif 309#endif
300}; 310};
301 311
diff --git a/arch/powerpc/include/asm/kvm_para.h b/arch/powerpc/include/asm/kvm_para.h
index 2d48f6a63d0b..50533f9adf40 100644
--- a/arch/powerpc/include/asm/kvm_para.h
+++ b/arch/powerpc/include/asm/kvm_para.h
@@ -20,16 +20,153 @@
20#ifndef __POWERPC_KVM_PARA_H__ 20#ifndef __POWERPC_KVM_PARA_H__
21#define __POWERPC_KVM_PARA_H__ 21#define __POWERPC_KVM_PARA_H__
22 22
23#include <linux/types.h>
24
25struct kvm_vcpu_arch_shared {
26 __u64 scratch1;
27 __u64 scratch2;
28 __u64 scratch3;
29 __u64 critical; /* Guest may not get interrupts if == r1 */
30 __u64 sprg0;
31 __u64 sprg1;
32 __u64 sprg2;
33 __u64 sprg3;
34 __u64 srr0;
35 __u64 srr1;
36 __u64 dar;
37 __u64 msr;
38 __u32 dsisr;
39 __u32 int_pending; /* Tells the guest if we have an interrupt */
40 __u32 sr[16];
41};
42
43#define KVM_SC_MAGIC_R0 0x4b564d21 /* "KVM!" */
44#define HC_VENDOR_KVM (42 << 16)
45#define HC_EV_SUCCESS 0
46#define HC_EV_UNIMPLEMENTED 12
47
48#define KVM_FEATURE_MAGIC_PAGE 1
49
50#define KVM_MAGIC_FEAT_SR (1 << 0)
51
23#ifdef __KERNEL__ 52#ifdef __KERNEL__
24 53
54#ifdef CONFIG_KVM_GUEST
55
56#include <linux/of.h>
57
58static inline int kvm_para_available(void)
59{
60 struct device_node *hyper_node;
61
62 hyper_node = of_find_node_by_path("/hypervisor");
63 if (!hyper_node)
64 return 0;
65
66 if (!of_device_is_compatible(hyper_node, "linux,kvm"))
67 return 0;
68
69 return 1;
70}
71
72extern unsigned long kvm_hypercall(unsigned long *in,
73 unsigned long *out,
74 unsigned long nr);
75
76#else
77
25static inline int kvm_para_available(void) 78static inline int kvm_para_available(void)
26{ 79{
27 return 0; 80 return 0;
28} 81}
29 82
83static unsigned long kvm_hypercall(unsigned long *in,
84 unsigned long *out,
85 unsigned long nr)
86{
87 return HC_EV_UNIMPLEMENTED;
88}
89
90#endif
91
92static inline long kvm_hypercall0_1(unsigned int nr, unsigned long *r2)
93{
94 unsigned long in[8];
95 unsigned long out[8];
96 unsigned long r;
97
98 r = kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
99 *r2 = out[0];
100
101 return r;
102}
103
104static inline long kvm_hypercall0(unsigned int nr)
105{
106 unsigned long in[8];
107 unsigned long out[8];
108
109 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
110}
111
112static inline long kvm_hypercall1(unsigned int nr, unsigned long p1)
113{
114 unsigned long in[8];
115 unsigned long out[8];
116
117 in[0] = p1;
118 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
119}
120
121static inline long kvm_hypercall2(unsigned int nr, unsigned long p1,
122 unsigned long p2)
123{
124 unsigned long in[8];
125 unsigned long out[8];
126
127 in[0] = p1;
128 in[1] = p2;
129 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
130}
131
132static inline long kvm_hypercall3(unsigned int nr, unsigned long p1,
133 unsigned long p2, unsigned long p3)
134{
135 unsigned long in[8];
136 unsigned long out[8];
137
138 in[0] = p1;
139 in[1] = p2;
140 in[2] = p3;
141 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
142}
143
144static inline long kvm_hypercall4(unsigned int nr, unsigned long p1,
145 unsigned long p2, unsigned long p3,
146 unsigned long p4)
147{
148 unsigned long in[8];
149 unsigned long out[8];
150
151 in[0] = p1;
152 in[1] = p2;
153 in[2] = p3;
154 in[3] = p4;
155 return kvm_hypercall(in, out, nr | HC_VENDOR_KVM);
156}
157
158
30static inline unsigned int kvm_arch_para_features(void) 159static inline unsigned int kvm_arch_para_features(void)
31{ 160{
32 return 0; 161 unsigned long r;
162
163 if (!kvm_para_available())
164 return 0;
165
166 if(kvm_hypercall0_1(KVM_HC_FEATURES, &r))
167 return 0;
168
169 return r;
33} 170}
34 171
35#endif /* __KERNEL__ */ 172#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
index 18d139ec2d22..9345238edecf 100644
--- a/arch/powerpc/include/asm/kvm_ppc.h
+++ b/arch/powerpc/include/asm/kvm_ppc.h
@@ -61,6 +61,7 @@ extern int kvmppc_emulate_instruction(struct kvm_run *run,
61 struct kvm_vcpu *vcpu); 61 struct kvm_vcpu *vcpu);
62extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu); 62extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu);
63extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu); 63extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu);
64extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb);
64 65
65/* Core-specific hooks */ 66/* Core-specific hooks */
66 67
@@ -107,6 +108,7 @@ extern int kvmppc_booke_init(void);
107extern void kvmppc_booke_exit(void); 108extern void kvmppc_booke_exit(void);
108 109
109extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); 110extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu);
111extern int kvmppc_kvm_pv(struct kvm_vcpu *vcpu);
110 112
111/* 113/*
112 * Cuts out inst bits with ordering according to spec. 114 * Cuts out inst bits with ordering according to spec.
@@ -141,4 +143,12 @@ static inline u32 kvmppc_set_field(u64 inst, int msb, int lsb, int value)
141 return r; 143 return r;
142} 144}
143 145
146void kvmppc_core_get_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
147int kvmppc_core_set_sregs(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
148
149void kvmppc_get_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
150int kvmppc_set_sregs_ivor(struct kvm_vcpu *vcpu, struct kvm_sregs *sregs);
151
152void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid);
153
144#endif /* __POWERPC_KVM_PPC_H__ */ 154#endif /* __POWERPC_KVM_PPC_H__ */
diff --git a/arch/powerpc/include/asm/lppaca.h b/arch/powerpc/include/asm/lppaca.h
index 14b592dfb4e8..e0298d26ce5d 100644
--- a/arch/powerpc/include/asm/lppaca.h
+++ b/arch/powerpc/include/asm/lppaca.h
@@ -33,9 +33,25 @@
33// 33//
34//---------------------------------------------------------------------------- 34//----------------------------------------------------------------------------
35#include <linux/cache.h> 35#include <linux/cache.h>
36#include <linux/threads.h>
36#include <asm/types.h> 37#include <asm/types.h>
37#include <asm/mmu.h> 38#include <asm/mmu.h>
38 39
40/*
41 * We only have to have statically allocated lppaca structs on
42 * legacy iSeries, which supports at most 64 cpus.
43 */
44#ifdef CONFIG_PPC_ISERIES
45#if NR_CPUS < 64
46#define NR_LPPACAS NR_CPUS
47#else
48#define NR_LPPACAS 64
49#endif
50#else /* not iSeries */
51#define NR_LPPACAS 1
52#endif
53
54
39/* The Hypervisor barfs if the lppaca crosses a page boundary. A 1k 55/* The Hypervisor barfs if the lppaca crosses a page boundary. A 1k
40 * alignment is sufficient to prevent this */ 56 * alignment is sufficient to prevent this */
41struct lppaca { 57struct lppaca {
@@ -62,7 +78,10 @@ struct lppaca {
62 volatile u32 dyn_pir; // Dynamic ProcIdReg value x20-x23 78 volatile u32 dyn_pir; // Dynamic ProcIdReg value x20-x23
63 u32 dsei_data; // DSEI data x24-x27 79 u32 dsei_data; // DSEI data x24-x27
64 u64 sprg3; // SPRG3 value x28-x2F 80 u64 sprg3; // SPRG3 value x28-x2F
65 u8 reserved3[80]; // Reserved x30-x7F 81 u8 reserved3[40]; // Reserved x30-x57
82 volatile u8 vphn_assoc_counts[8]; // Virtual processor home node
83 // associativity change counters x58-x5F
84 u8 reserved4[32]; // Reserved x60-x7F
66 85
67//============================================================================= 86//=============================================================================
68// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data 87// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data
@@ -86,7 +105,7 @@ struct lppaca {
86 // processing of external interrupts. Note that PLIC will store the 105 // processing of external interrupts. Note that PLIC will store the
87 // XIRR directly into the xXirrValue field so that another XIRR will 106 // XIRR directly into the xXirrValue field so that another XIRR will
88 // not be presented until this one clears. The layout of the low 107 // not be presented until this one clears. The layout of the low
89 // 4-bytes of this Dword is upto SLIC - PLIC just checks whether the 108 // 4-bytes of this Dword is up to SLIC - PLIC just checks whether the
90 // entire Dword is zero or not. A non-zero value in the low order 109 // entire Dword is zero or not. A non-zero value in the low order
91 // 2-bytes will result in SLIC being granted the highest thread 110 // 2-bytes will result in SLIC being granted the highest thread
92 // priority upon return. A 0 will return to SLIC as medium priority. 111 // priority upon return. A 0 will return to SLIC as medium priority.
@@ -153,6 +172,8 @@ struct lppaca {
153 172
154extern struct lppaca lppaca[]; 173extern struct lppaca lppaca[];
155 174
175#define lppaca_of(cpu) (*paca[cpu].lppaca_ptr)
176
156/* 177/*
157 * SLB shadow buffer structure as defined in the PAPR. The save_area 178 * SLB shadow buffer structure as defined in the PAPR. The save_area
158 * contains adjacent ESID and VSID pairs for each shadowed SLB. The 179 * contains adjacent ESID and VSID pairs for each shadowed SLB. The
@@ -170,6 +191,35 @@ struct slb_shadow {
170 191
171extern struct slb_shadow slb_shadow[]; 192extern struct slb_shadow slb_shadow[];
172 193
194/*
195 * Layout of entries in the hypervisor's dispatch trace log buffer.
196 */
197struct dtl_entry {
198 u8 dispatch_reason;
199 u8 preempt_reason;
200 u16 processor_id;
201 u32 enqueue_to_dispatch_time;
202 u32 ready_to_enqueue_time;
203 u32 waiting_to_ready_time;
204 u64 timebase;
205 u64 fault_addr;
206 u64 srr0;
207 u64 srr1;
208};
209
210#define DISPATCH_LOG_BYTES 4096 /* bytes per cpu */
211#define N_DISPATCH_LOG (DISPATCH_LOG_BYTES / sizeof(struct dtl_entry))
212
213extern struct kmem_cache *dtl_cache;
214
215/*
216 * When CONFIG_VIRT_CPU_ACCOUNTING = y, the cpu accounting code controls
217 * reading from the dispatch trace log. If other code wants to consume
218 * DTL entries, it can set this pointer to a function that will get
219 * called once for each DTL entry that gets processed.
220 */
221extern void (*dtl_consumer)(struct dtl_entry *entry, u64 index);
222
173#endif /* CONFIG_PPC_BOOK3S */ 223#endif /* CONFIG_PPC_BOOK3S */
174#endif /* __KERNEL__ */ 224#endif /* __KERNEL__ */
175#endif /* _ASM_POWERPC_LPPACA_H */ 225#endif /* _ASM_POWERPC_LPPACA_H */
diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h
index adc8e6cdf339..47cacddb14cf 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -27,24 +27,7 @@ struct iommu_table;
27struct rtc_time; 27struct rtc_time;
28struct file; 28struct file;
29struct pci_controller; 29struct pci_controller;
30#ifdef CONFIG_KEXEC
31struct kimage; 30struct kimage;
32#endif
33
34#ifdef CONFIG_SMP
35struct smp_ops_t {
36 void (*message_pass)(int target, int msg);
37 int (*probe)(void);
38 void (*kick_cpu)(int nr);
39 void (*setup_cpu)(int nr);
40 void (*take_timebase)(void);
41 void (*give_timebase)(void);
42 int (*cpu_enable)(unsigned int nr);
43 int (*cpu_disable)(void);
44 void (*cpu_die)(unsigned int nr);
45 int (*cpu_bootable)(unsigned int nr);
46};
47#endif
48 31
49struct machdep_calls { 32struct machdep_calls {
50 char *name; 33 char *name;
@@ -72,7 +55,7 @@ struct machdep_calls {
72 int psize, int ssize); 55 int psize, int ssize);
73 void (*flush_hash_range)(unsigned long number, int local); 56 void (*flush_hash_range)(unsigned long number, int local);
74 57
75 /* special for kexec, to be called in real mode, linar mapping is 58 /* special for kexec, to be called in real mode, linear mapping is
76 * destroyed as well */ 59 * destroyed as well */
77 void (*hpte_clear_all)(void); 60 void (*hpte_clear_all)(void);
78 61
@@ -102,6 +85,9 @@ struct machdep_calls {
102 void (*pci_dma_dev_setup)(struct pci_dev *dev); 85 void (*pci_dma_dev_setup)(struct pci_dev *dev);
103 void (*pci_dma_bus_setup)(struct pci_bus *bus); 86 void (*pci_dma_bus_setup)(struct pci_bus *bus);
104 87
88 /* Platform set_dma_mask override */
89 int (*dma_set_mask)(struct device *dev, u64 dma_mask);
90
105 int (*probe)(void); 91 int (*probe)(void);
106 void (*setup_arch)(void); /* Optional, may be NULL */ 92 void (*setup_arch)(void); /* Optional, may be NULL */
107 void (*init_early)(void); 93 void (*init_early)(void);
@@ -115,9 +101,6 @@ struct machdep_calls {
115 * If for some reason there is no irq, but the interrupt 101 * If for some reason there is no irq, but the interrupt
116 * shouldn't be counted as spurious, return NO_IRQ_IGNORE. */ 102 * shouldn't be counted as spurious, return NO_IRQ_IGNORE. */
117 unsigned int (*get_irq)(void); 103 unsigned int (*get_irq)(void);
118#ifdef CONFIG_KEXEC
119 void (*kexec_cpu_down)(int crash_shutdown, int secondary);
120#endif
121 104
122 /* PCI stuff */ 105 /* PCI stuff */
123 /* Called after scanning the bus, before allocating resources */ 106 /* Called after scanning the bus, before allocating resources */
@@ -234,11 +217,7 @@ struct machdep_calls {
234 void (*machine_shutdown)(void); 217 void (*machine_shutdown)(void);
235 218
236#ifdef CONFIG_KEXEC 219#ifdef CONFIG_KEXEC
237 /* Called to do the minimal shutdown needed to run a kexec'd kernel 220 void (*kexec_cpu_down)(int crash_shutdown, int secondary);
238 * to run successfully.
239 * XXX Should we move this one out of kexec scope?
240 */
241 void (*machine_crash_shutdown)(struct pt_regs *regs);
242 221
243 /* Called to do what every setup is needed on image and the 222 /* Called to do what every setup is needed on image and the
244 * reboot code buffer. Returns 0 on success. 223 * reboot code buffer. Returns 0 on success.
@@ -247,9 +226,6 @@ struct machdep_calls {
247 */ 226 */
248 int (*machine_kexec_prepare)(struct kimage *image); 227 int (*machine_kexec_prepare)(struct kimage *image);
249 228
250 /* Called to handle any machine specific cleanup on image */
251 void (*machine_kexec_cleanup)(struct kimage *image);
252
253 /* Called to perform the _real_ kexec. 229 /* Called to perform the _real_ kexec.
254 * Do NOT allocate memory or fail here. We are past the point of 230 * Do NOT allocate memory or fail here. We are past the point of
255 * no return. 231 * no return.
@@ -276,7 +252,7 @@ struct machdep_calls {
276 252
277extern void e500_idle(void); 253extern void e500_idle(void);
278extern void power4_idle(void); 254extern void power4_idle(void);
279extern void power4_cpu_offline_powersave(void); 255extern void power7_idle(void);
280extern void ppc6xx_idle(void); 256extern void ppc6xx_idle(void);
281extern void book3e_idle(void); 257extern void book3e_idle(void);
282 258
@@ -321,14 +297,6 @@ extern sys_ctrler_t sys_ctrler;
321 297
322#endif /* CONFIG_PPC_PMAC */ 298#endif /* CONFIG_PPC_PMAC */
323 299
324extern void setup_pci_ptrs(void);
325
326#ifdef CONFIG_SMP
327/* Poor default implementations */
328extern void __devinit smp_generic_give_timebase(void);
329extern void __devinit smp_generic_take_timebase(void);
330#endif /* CONFIG_SMP */
331
332 300
333/* Functions to produce codes on the leds. 301/* Functions to produce codes on the leds.
334 * The SRC code should be unique for the message category and should 302 * The SRC code should be unique for the message category and should
diff --git a/arch/powerpc/include/asm/memblock.h b/arch/powerpc/include/asm/memblock.h
index 3c29728b56b1..43efc345065e 100644
--- a/arch/powerpc/include/asm/memblock.h
+++ b/arch/powerpc/include/asm/memblock.h
@@ -5,11 +5,4 @@
5 5
6#define MEMBLOCK_DBG(fmt...) udbg_printf(fmt) 6#define MEMBLOCK_DBG(fmt...) udbg_printf(fmt)
7 7
8#ifdef CONFIG_PPC32
9extern phys_addr_t lowmem_end_addr;
10#define MEMBLOCK_REAL_LIMIT lowmem_end_addr
11#else
12#define MEMBLOCK_REAL_LIMIT 0
13#endif
14
15#endif /* _ASM_POWERPC_MEMBLOCK_H */ 8#endif /* _ASM_POWERPC_MEMBLOCK_H */
diff --git a/arch/powerpc/include/asm/mmu-book3e.h b/arch/powerpc/include/asm/mmu-book3e.h
index 87a1d787c5b6..3ea0f9a259d8 100644
--- a/arch/powerpc/include/asm/mmu-book3e.h
+++ b/arch/powerpc/include/asm/mmu-book3e.h
@@ -40,9 +40,10 @@
40 40
41/* MAS registers bit definitions */ 41/* MAS registers bit definitions */
42 42
43#define MAS0_TLBSEL(x) ((x << 28) & 0x30000000) 43#define MAS0_TLBSEL(x) (((x) << 28) & 0x30000000)
44#define MAS0_ESEL(x) ((x << 16) & 0x0FFF0000) 44#define MAS0_ESEL(x) (((x) << 16) & 0x0FFF0000)
45#define MAS0_NV(x) ((x) & 0x00000FFF) 45#define MAS0_NV(x) ((x) & 0x00000FFF)
46#define MAS0_ESEL_MASK 0x0FFF0000
46#define MAS0_HES 0x00004000 47#define MAS0_HES 0x00004000
47#define MAS0_WQ_ALLWAYS 0x00000000 48#define MAS0_WQ_ALLWAYS 0x00000000
48#define MAS0_WQ_COND 0x00001000 49#define MAS0_WQ_COND 0x00001000
@@ -50,12 +51,12 @@
50 51
51#define MAS1_VALID 0x80000000 52#define MAS1_VALID 0x80000000
52#define MAS1_IPROT 0x40000000 53#define MAS1_IPROT 0x40000000
53#define MAS1_TID(x) ((x << 16) & 0x3FFF0000) 54#define MAS1_TID(x) (((x) << 16) & 0x3FFF0000)
54#define MAS1_IND 0x00002000 55#define MAS1_IND 0x00002000
55#define MAS1_TS 0x00001000 56#define MAS1_TS 0x00001000
56#define MAS1_TSIZE_MASK 0x00000f80 57#define MAS1_TSIZE_MASK 0x00000f80
57#define MAS1_TSIZE_SHIFT 7 58#define MAS1_TSIZE_SHIFT 7
58#define MAS1_TSIZE(x) ((x << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK) 59#define MAS1_TSIZE(x) (((x) << MAS1_TSIZE_SHIFT) & MAS1_TSIZE_MASK)
59 60
60#define MAS2_EPN 0xFFFFF000 61#define MAS2_EPN 0xFFFFF000
61#define MAS2_X0 0x00000040 62#define MAS2_X0 0x00000040
@@ -114,6 +115,17 @@
114 115
115#define MAS7_RPN 0xFFFFFFFF 116#define MAS7_RPN 0xFFFFFFFF
116 117
118/* Bit definitions for MMUCFG */
119#define MMUCFG_MAVN 0x00000003 /* MMU Architecture Version Number */
120#define MMUCFG_MAVN_V1 0x00000000 /* v1.0 */
121#define MMUCFG_MAVN_V2 0x00000001 /* v2.0 */
122#define MMUCFG_NTLBS 0x0000000c /* Number of TLBs */
123#define MMUCFG_PIDSIZE 0x000007c0 /* PID Reg Size */
124#define MMUCFG_TWC 0x00008000 /* TLB Write Conditional (v2.0) */
125#define MMUCFG_LRAT 0x00010000 /* LRAT Supported (v2.0) */
126#define MMUCFG_RASIZE 0x00fe0000 /* Real Addr Size */
127#define MMUCFG_LPIDSIZE 0x0f000000 /* LPID Reg Size */
128
117/* Bit definitions for MMUCSR0 */ 129/* Bit definitions for MMUCSR0 */
118#define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */ 130#define MMUCSR0_TLB1FI 0x00000002 /* TLB1 Flash invalidate */
119#define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */ 131#define MMUCSR0_TLB0FI 0x00000004 /* TLB0 Flash invalidate */
@@ -126,6 +138,21 @@
126#define MMUCSR0_TLB2PS 0x00078000 /* TLB2 Page Size */ 138#define MMUCSR0_TLB2PS 0x00078000 /* TLB2 Page Size */
127#define MMUCSR0_TLB3PS 0x00780000 /* TLB3 Page Size */ 139#define MMUCSR0_TLB3PS 0x00780000 /* TLB3 Page Size */
128 140
141/* MMUCFG bits */
142#define MMUCFG_MAVN_NASK 0x00000003
143#define MMUCFG_MAVN_V1_0 0x00000000
144#define MMUCFG_MAVN_V2_0 0x00000001
145#define MMUCFG_NTLB_MASK 0x0000000c
146#define MMUCFG_NTLB_SHIFT 2
147#define MMUCFG_PIDSIZE_MASK 0x000007c0
148#define MMUCFG_PIDSIZE_SHIFT 6
149#define MMUCFG_TWC 0x00008000
150#define MMUCFG_LRAT 0x00010000
151#define MMUCFG_RASIZE_MASK 0x00fe0000
152#define MMUCFG_RASIZE_SHIFT 17
153#define MMUCFG_LPIDSIZE_MASK 0x0f000000
154#define MMUCFG_LPIDSIZE_SHIFT 24
155
129/* TLBnCFG encoding */ 156/* TLBnCFG encoding */
130#define TLBnCFG_N_ENTRY 0x00000fff /* number of entries */ 157#define TLBnCFG_N_ENTRY 0x00000fff /* number of entries */
131#define TLBnCFG_HES 0x00002000 /* HW select supported */ 158#define TLBnCFG_HES 0x00002000 /* HW select supported */
@@ -133,6 +160,10 @@
133#define TLBnCFG_GTWE 0x00010000 /* Guest can write */ 160#define TLBnCFG_GTWE 0x00010000 /* Guest can write */
134#define TLBnCFG_IND 0x00020000 /* IND entries supported */ 161#define TLBnCFG_IND 0x00020000 /* IND entries supported */
135#define TLBnCFG_PT 0x00040000 /* Can load from page table */ 162#define TLBnCFG_PT 0x00040000 /* Can load from page table */
163#define TLBnCFG_MINSIZE 0x00f00000 /* Minimum Page Size (v1.0) */
164#define TLBnCFG_MINSIZE_SHIFT 20
165#define TLBnCFG_MAXSIZE 0x000f0000 /* Maximum Page Size (v1.0) */
166#define TLBnCFG_MAXSIZE_SHIFT 16
136#define TLBnCFG_ASSOC 0xff000000 /* Associativity */ 167#define TLBnCFG_ASSOC 0xff000000 /* Associativity */
137 168
138/* TLBnPS encoding */ 169/* TLBnPS encoding */
@@ -214,6 +245,10 @@ extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
214extern int mmu_linear_psize; 245extern int mmu_linear_psize;
215extern int mmu_vmemmap_psize; 246extern int mmu_vmemmap_psize;
216 247
248#ifdef CONFIG_PPC64
249extern unsigned long linear_map_top;
250#endif
251
217#endif /* !__ASSEMBLY__ */ 252#endif /* !__ASSEMBLY__ */
218 253
219#endif /* _ASM_POWERPC_MMU_BOOK3E_H_ */ 254#endif /* _ASM_POWERPC_MMU_BOOK3E_H_ */
diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h
index acac35d5b382..d865bd909c7d 100644
--- a/arch/powerpc/include/asm/mmu-hash64.h
+++ b/arch/powerpc/include/asm/mmu-hash64.h
@@ -27,7 +27,7 @@
27#define STE_VSID_SHIFT 12 27#define STE_VSID_SHIFT 12
28 28
29/* Location of cpu0's segment table */ 29/* Location of cpu0's segment table */
30#define STAB0_PAGE 0x6 30#define STAB0_PAGE 0x8
31#define STAB0_OFFSET (STAB0_PAGE << 12) 31#define STAB0_OFFSET (STAB0_PAGE << 12)
32#define STAB0_PHYS_ADDR (STAB0_OFFSET + PHYSICAL_START) 32#define STAB0_PHYS_ADDR (STAB0_OFFSET + PHYSICAL_START)
33 33
@@ -408,6 +408,7 @@ static inline void subpage_prot_init_new_context(struct mm_struct *mm) { }
408#endif /* CONFIG_PPC_SUBPAGE_PROT */ 408#endif /* CONFIG_PPC_SUBPAGE_PROT */
409 409
410typedef unsigned long mm_context_id_t; 410typedef unsigned long mm_context_id_t;
411struct spinlock;
411 412
412typedef struct { 413typedef struct {
413 mm_context_id_t id; 414 mm_context_id_t id;
@@ -423,6 +424,11 @@ typedef struct {
423#ifdef CONFIG_PPC_SUBPAGE_PROT 424#ifdef CONFIG_PPC_SUBPAGE_PROT
424 struct subpage_prot_table spt; 425 struct subpage_prot_table spt;
425#endif /* CONFIG_PPC_SUBPAGE_PROT */ 426#endif /* CONFIG_PPC_SUBPAGE_PROT */
427#ifdef CONFIG_PPC_ICSWX
428 struct spinlock *cop_lockp; /* guard acop and cop_pid */
429 unsigned long acop; /* mask of enabled coprocessor types */
430 unsigned int cop_pid; /* pid value used with coprocessors */
431#endif /* CONFIG_PPC_ICSWX */
426} mm_context_t; 432} mm_context_t;
427 433
428 434
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 7ebf42ed84a2..4138b21ae80a 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -2,6 +2,8 @@
2#define _ASM_POWERPC_MMU_H_ 2#define _ASM_POWERPC_MMU_H_
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/types.h>
6
5#include <asm/asm-compat.h> 7#include <asm/asm-compat.h>
6#include <asm/feature-fixups.h> 8#include <asm/feature-fixups.h>
7 9
@@ -54,11 +56,6 @@
54 */ 56 */
55#define MMU_FTR_NEED_DTLB_SW_LRU ASM_CONST(0x00200000) 57#define MMU_FTR_NEED_DTLB_SW_LRU ASM_CONST(0x00200000)
56 58
57/* This indicates that the processor uses the ISA 2.06 server tlbie
58 * mnemonics
59 */
60#define MMU_FTR_TLBIE_206 ASM_CONST(0x00400000)
61
62/* Enable use of TLB reservation. Processor should support tlbsrx. 59/* Enable use of TLB reservation. Processor should support tlbsrx.
63 * instruction and MAS0[WQ]. 60 * instruction and MAS0[WQ].
64 */ 61 */
@@ -68,6 +65,53 @@
68 */ 65 */
69#define MMU_FTR_USE_PAIRED_MAS ASM_CONST(0x01000000) 66#define MMU_FTR_USE_PAIRED_MAS ASM_CONST(0x01000000)
70 67
68/* MMU is SLB-based
69 */
70#define MMU_FTR_SLB ASM_CONST(0x02000000)
71
72/* Support 16M large pages
73 */
74#define MMU_FTR_16M_PAGE ASM_CONST(0x04000000)
75
76/* Supports TLBIEL variant
77 */
78#define MMU_FTR_TLBIEL ASM_CONST(0x08000000)
79
80/* Supports tlbies w/o locking
81 */
82#define MMU_FTR_LOCKLESS_TLBIE ASM_CONST(0x10000000)
83
84/* Large pages can be marked CI
85 */
86#define MMU_FTR_CI_LARGE_PAGE ASM_CONST(0x20000000)
87
88/* 1T segments available
89 */
90#define MMU_FTR_1T_SEGMENT ASM_CONST(0x40000000)
91
92/* Doesn't support the B bit (1T segment) in SLBIE
93 */
94#define MMU_FTR_NO_SLBIE_B ASM_CONST(0x80000000)
95
96/* MMU feature bit sets for various CPUs */
97#define MMU_FTRS_DEFAULT_HPTE_ARCH_V2 \
98 MMU_FTR_HPTE_TABLE | MMU_FTR_PPCAS_ARCH_V2
99#define MMU_FTRS_POWER4 MMU_FTRS_DEFAULT_HPTE_ARCH_V2
100#define MMU_FTRS_PPC970 MMU_FTRS_POWER4
101#define MMU_FTRS_POWER5 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
102#define MMU_FTRS_POWER6 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
103#define MMU_FTRS_POWER7 MMU_FTRS_POWER4 | MMU_FTR_LOCKLESS_TLBIE
104#define MMU_FTRS_CELL MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
105 MMU_FTR_CI_LARGE_PAGE
106#define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
107 MMU_FTR_CI_LARGE_PAGE | MMU_FTR_NO_SLBIE_B
108#define MMU_FTRS_A2 MMU_FTR_TYPE_3E | MMU_FTR_USE_TLBILX | \
109 MMU_FTR_USE_TLBIVAX_BCAST | \
110 MMU_FTR_LOCK_BCAST_INVAL | \
111 MMU_FTR_USE_TLBRSRV | \
112 MMU_FTR_USE_PAIRED_MAS | \
113 MMU_FTR_TLBIEL | \
114 MMU_FTR_16M_PAGE
71#ifndef __ASSEMBLY__ 115#ifndef __ASSEMBLY__
72#include <asm/cputable.h> 116#include <asm/cputable.h>
73 117
@@ -82,6 +126,16 @@ extern unsigned int __start___mmu_ftr_fixup, __stop___mmu_ftr_fixup;
82extern void early_init_mmu(void); 126extern void early_init_mmu(void);
83extern void early_init_mmu_secondary(void); 127extern void early_init_mmu_secondary(void);
84 128
129extern void setup_initial_memory_limit(phys_addr_t first_memblock_base,
130 phys_addr_t first_memblock_size);
131
132#ifdef CONFIG_PPC64
133/* This is our real memory area size on ppc64 server, on embedded, we
134 * make it match the size our of bolted TLB area
135 */
136extern u64 ppc64_rma_size;
137#endif /* CONFIG_PPC64 */
138
85#endif /* !__ASSEMBLY__ */ 139#endif /* !__ASSEMBLY__ */
86 140
87/* The kernel use the constants below to index in the page sizes array. 141/* The kernel use the constants below to index in the page sizes array.
diff --git a/arch/powerpc/include/asm/mmu_context.h b/arch/powerpc/include/asm/mmu_context.h
index 81fb41289d6c..a73668a5f30d 100644
--- a/arch/powerpc/include/asm/mmu_context.h
+++ b/arch/powerpc/include/asm/mmu_context.h
@@ -32,6 +32,10 @@ extern void __destroy_context(unsigned long context_id);
32extern void mmu_context_init(void); 32extern void mmu_context_init(void);
33#endif 33#endif
34 34
35extern void switch_cop(struct mm_struct *next);
36extern int use_cop(unsigned long acop, struct mm_struct *mm);
37extern void drop_cop(unsigned long acop, struct mm_struct *mm);
38
35/* 39/*
36 * switch_mm is the entry point called from the architecture independent 40 * switch_mm is the entry point called from the architecture independent
37 * code in kernel/sched.c 41 * code in kernel/sched.c
@@ -55,6 +59,12 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
55 if (prev == next) 59 if (prev == next)
56 return; 60 return;
57 61
62#ifdef CONFIG_PPC_ICSWX
63 /* Switch coprocessor context only if prev or next uses a coprocessor */
64 if (prev->context.acop || next->context.acop)
65 switch_cop(next);
66#endif /* CONFIG_PPC_ICSWX */
67
58 /* We must stop all altivec streams before changing the HW 68 /* We must stop all altivec streams before changing the HW
59 * context 69 * context
60 */ 70 */
@@ -67,7 +77,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
67 * sub architectures. 77 * sub architectures.
68 */ 78 */
69#ifdef CONFIG_PPC_STD_MMU_64 79#ifdef CONFIG_PPC_STD_MMU_64
70 if (cpu_has_feature(CPU_FTR_SLB)) 80 if (mmu_has_feature(MMU_FTR_SLB))
71 switch_slb(tsk, next); 81 switch_slb(tsk, next);
72 else 82 else
73 switch_stab(tsk, next); 83 switch_stab(tsk, next);
diff --git a/arch/powerpc/include/asm/mmzone.h b/arch/powerpc/include/asm/mmzone.h
index aac87cbceb57..7b589178be46 100644
--- a/arch/powerpc/include/asm/mmzone.h
+++ b/arch/powerpc/include/asm/mmzone.h
@@ -33,15 +33,13 @@ extern int numa_cpu_lookup_table[];
33extern cpumask_var_t node_to_cpumask_map[]; 33extern cpumask_var_t node_to_cpumask_map[];
34#ifdef CONFIG_MEMORY_HOTPLUG 34#ifdef CONFIG_MEMORY_HOTPLUG
35extern unsigned long max_pfn; 35extern unsigned long max_pfn;
36u64 memory_hotplug_max(void);
37#else
38#define memory_hotplug_max() memblock_end_of_DRAM()
36#endif 39#endif
37 40
38/* 41#else
39 * Following are macros that each numa implmentation must define. 42#define memory_hotplug_max() memblock_end_of_DRAM()
40 */
41
42#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
43#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
44
45#endif /* CONFIG_NEED_MULTIPLE_NODES */ 43#endif /* CONFIG_NEED_MULTIPLE_NODES */
46 44
47#endif /* __KERNEL__ */ 45#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index e000cce8f6dd..df18989e78d4 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -3,7 +3,6 @@
3#ifdef __KERNEL__ 3#ifdef __KERNEL__
4 4
5#include <linux/irq.h> 5#include <linux/irq.h>
6#include <linux/sysdev.h>
7#include <asm/dcr.h> 6#include <asm/dcr.h>
8#include <asm/msi_bitmap.h> 7#include <asm/msi_bitmap.h>
9 8
@@ -263,6 +262,7 @@ struct mpic
263#ifdef CONFIG_SMP 262#ifdef CONFIG_SMP
264 struct irq_chip hc_ipi; 263 struct irq_chip hc_ipi;
265#endif 264#endif
265 struct irq_chip hc_tm;
266 const char *name; 266 const char *name;
267 /* Flags */ 267 /* Flags */
268 unsigned int flags; 268 unsigned int flags;
@@ -281,7 +281,7 @@ struct mpic
281 281
282 /* vector numbers used for internal sources (ipi/timers) */ 282 /* vector numbers used for internal sources (ipi/timers) */
283 unsigned int ipi_vecs[4]; 283 unsigned int ipi_vecs[4];
284 unsigned int timer_vecs[4]; 284 unsigned int timer_vecs[8];
285 285
286 /* Spurious vector to program into unused sources */ 286 /* Spurious vector to program into unused sources */
287 unsigned int spurious_vec; 287 unsigned int spurious_vec;
@@ -320,8 +320,6 @@ struct mpic
320 /* link */ 320 /* link */
321 struct mpic *next; 321 struct mpic *next;
322 322
323 struct sys_device sysdev;
324
325#ifdef CONFIG_PM 323#ifdef CONFIG_PM
326 struct mpic_irq_save *save_data; 324 struct mpic_irq_save *save_data;
327#endif 325#endif
@@ -367,6 +365,12 @@ struct mpic
367#define MPIC_SINGLE_DEST_CPU 0x00001000 365#define MPIC_SINGLE_DEST_CPU 0x00001000
368/* Enable CoreInt delivery of interrupts */ 366/* Enable CoreInt delivery of interrupts */
369#define MPIC_ENABLE_COREINT 0x00002000 367#define MPIC_ENABLE_COREINT 0x00002000
368/* Disable resetting of the MPIC.
369 * NOTE: This flag trumps MPIC_WANTS_RESET.
370 */
371#define MPIC_NO_RESET 0x00004000
372/* Freescale MPIC (compatible includes "fsl,mpic") */
373#define MPIC_FSL 0x00008000
370 374
371/* MPIC HW modification ID */ 375/* MPIC HW modification ID */
372#define MPIC_REGSET_MASK 0xf0000000 376#define MPIC_REGSET_MASK 0xf0000000
@@ -467,11 +471,11 @@ extern void mpic_request_ipis(void);
467void smp_mpic_message_pass(int target, int msg); 471void smp_mpic_message_pass(int target, int msg);
468 472
469/* Unmask a specific virq */ 473/* Unmask a specific virq */
470extern void mpic_unmask_irq(unsigned int irq); 474extern void mpic_unmask_irq(struct irq_data *d);
471/* Mask a specific virq */ 475/* Mask a specific virq */
472extern void mpic_mask_irq(unsigned int irq); 476extern void mpic_mask_irq(struct irq_data *d);
473/* EOI a specific virq */ 477/* EOI a specific virq */
474extern void mpic_end_irq(unsigned int irq); 478extern void mpic_end_irq(struct irq_data *d);
475 479
476/* Fetch interrupt from a given mpic */ 480/* Fetch interrupt from a given mpic */
477extern unsigned int mpic_get_one_irq(struct mpic *mpic); 481extern unsigned int mpic_get_one_irq(struct mpic *mpic);
diff --git a/arch/powerpc/include/asm/nvram.h b/arch/powerpc/include/asm/nvram.h
index 850b72f27445..9d1aafe607c7 100644
--- a/arch/powerpc/include/asm/nvram.h
+++ b/arch/powerpc/include/asm/nvram.h
@@ -10,31 +10,7 @@
10#ifndef _ASM_POWERPC_NVRAM_H 10#ifndef _ASM_POWERPC_NVRAM_H
11#define _ASM_POWERPC_NVRAM_H 11#define _ASM_POWERPC_NVRAM_H
12 12
13#include <linux/errno.h> 13/* Signatures for nvram partitions */
14
15#define NVRW_CNT 0x20
16#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
17#define NVRAM_BLOCK_LEN 16
18#define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
19#define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
20
21#define NVRAM_AS0 0x74
22#define NVRAM_AS1 0x75
23#define NVRAM_DATA 0x77
24
25
26/* RTC Offsets */
27
28#define MOTO_RTC_SECONDS 0x1FF9
29#define MOTO_RTC_MINUTES 0x1FFA
30#define MOTO_RTC_HOURS 0x1FFB
31#define MOTO_RTC_DAY_OF_WEEK 0x1FFC
32#define MOTO_RTC_DAY_OF_MONTH 0x1FFD
33#define MOTO_RTC_MONTH 0x1FFE
34#define MOTO_RTC_YEAR 0x1FFF
35#define MOTO_RTC_CONTROLA 0x1FF8
36#define MOTO_RTC_CONTROLB 0x1FF9
37
38#define NVRAM_SIG_SP 0x02 /* support processor */ 14#define NVRAM_SIG_SP 0x02 /* support processor */
39#define NVRAM_SIG_OF 0x50 /* open firmware config */ 15#define NVRAM_SIG_OF 0x50 /* open firmware config */
40#define NVRAM_SIG_FW 0x51 /* general firmware */ 16#define NVRAM_SIG_FW 0x51 /* general firmware */
@@ -49,32 +25,19 @@
49#define NVRAM_SIG_OS 0xa0 /* OS defined */ 25#define NVRAM_SIG_OS 0xa0 /* OS defined */
50#define NVRAM_SIG_PANIC 0xa1 /* Apple OSX "panic" */ 26#define NVRAM_SIG_PANIC 0xa1 /* Apple OSX "panic" */
51 27
52/* If change this size, then change the size of NVNAME_LEN */
53struct nvram_header {
54 unsigned char signature;
55 unsigned char checksum;
56 unsigned short length;
57 char name[12];
58};
59
60#ifdef __KERNEL__ 28#ifdef __KERNEL__
61 29
30#include <linux/errno.h>
62#include <linux/list.h> 31#include <linux/list.h>
63 32
64struct nvram_partition { 33#ifdef CONFIG_PPC_PSERIES
65 struct list_head partition;
66 struct nvram_header header;
67 unsigned int index;
68};
69
70
71extern int nvram_write_error_log(char * buff, int length, 34extern int nvram_write_error_log(char * buff, int length,
72 unsigned int err_type, unsigned int err_seq); 35 unsigned int err_type, unsigned int err_seq);
73extern int nvram_read_error_log(char * buff, int length, 36extern int nvram_read_error_log(char * buff, int length,
74 unsigned int * err_type, unsigned int *err_seq); 37 unsigned int * err_type, unsigned int *err_seq);
75extern int nvram_clear_error_log(void); 38extern int nvram_clear_error_log(void);
76
77extern int pSeries_nvram_init(void); 39extern int pSeries_nvram_init(void);
40#endif /* CONFIG_PPC_PSERIES */
78 41
79#ifdef CONFIG_MMIO_NVRAM 42#ifdef CONFIG_MMIO_NVRAM
80extern int mmio_nvram_init(void); 43extern int mmio_nvram_init(void);
@@ -85,6 +48,14 @@ static inline int mmio_nvram_init(void)
85} 48}
86#endif 49#endif
87 50
51extern int __init nvram_scan_partitions(void);
52extern loff_t nvram_create_partition(const char *name, int sig,
53 int req_size, int min_size);
54extern int nvram_remove_partition(const char *name, int sig,
55 const char *exceptions[]);
56extern int nvram_get_partition_size(loff_t data_index);
57extern loff_t nvram_find_partition(const char *name, int sig, int *out_size);
58
88#endif /* __KERNEL__ */ 59#endif /* __KERNEL__ */
89 60
90/* PowerMac specific nvram stuffs */ 61/* PowerMac specific nvram stuffs */
diff --git a/arch/powerpc/include/asm/pSeries_reconfig.h b/arch/powerpc/include/asm/pSeries_reconfig.h
index d4b4bfa26fb3..89d2f99c1bf4 100644
--- a/arch/powerpc/include/asm/pSeries_reconfig.h
+++ b/arch/powerpc/include/asm/pSeries_reconfig.h
@@ -18,13 +18,18 @@
18extern int pSeries_reconfig_notifier_register(struct notifier_block *); 18extern int pSeries_reconfig_notifier_register(struct notifier_block *);
19extern void pSeries_reconfig_notifier_unregister(struct notifier_block *); 19extern void pSeries_reconfig_notifier_unregister(struct notifier_block *);
20extern struct blocking_notifier_head pSeries_reconfig_chain; 20extern struct blocking_notifier_head pSeries_reconfig_chain;
21/* Not the best place to put this, will be fixed when we move some
22 * of the rtas suspend-me stuff to pseries */
23extern void pSeries_coalesce_init(void);
21#else /* !CONFIG_PPC_PSERIES */ 24#else /* !CONFIG_PPC_PSERIES */
22static inline int pSeries_reconfig_notifier_register(struct notifier_block *nb) 25static inline int pSeries_reconfig_notifier_register(struct notifier_block *nb)
23{ 26{
24 return 0; 27 return 0;
25} 28}
26static inline void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) { } 29static inline void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) { }
30static inline void pSeries_coalesce_init(void) { }
27#endif /* CONFIG_PPC_PSERIES */ 31#endif /* CONFIG_PPC_PSERIES */
28 32
33
29#endif /* __KERNEL__ */ 34#endif /* __KERNEL__ */
30#endif /* _PPC64_PSERIES_RECONFIG_H */ 35#endif /* _PPC64_PSERIES_RECONFIG_H */
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 1ff6662f7faf..74126765106a 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -85,14 +85,16 @@ struct paca_struct {
85 u8 kexec_state; /* set when kexec down has irqs off */ 85 u8 kexec_state; /* set when kexec down has irqs off */
86#ifdef CONFIG_PPC_STD_MMU_64 86#ifdef CONFIG_PPC_STD_MMU_64
87 struct slb_shadow *slb_shadow_ptr; 87 struct slb_shadow *slb_shadow_ptr;
88 struct dtl_entry *dispatch_log;
89 struct dtl_entry *dispatch_log_end;
88 90
89 /* 91 /*
90 * Now, starting in cacheline 2, the exception save areas 92 * Now, starting in cacheline 2, the exception save areas
91 */ 93 */
92 /* used for most interrupts/exceptions */ 94 /* used for most interrupts/exceptions */
93 u64 exgen[10] __attribute__((aligned(0x80))); 95 u64 exgen[11] __attribute__((aligned(0x80)));
94 u64 exmc[10]; /* used for machine checks */ 96 u64 exmc[11]; /* used for machine checks */
95 u64 exslb[10]; /* used for SLB/segment table misses 97 u64 exslb[11]; /* used for SLB/segment table misses
96 * on the linear mapping */ 98 * on the linear mapping */
97 /* SLB related definitions */ 99 /* SLB related definitions */
98 u16 vmalloc_sllp; 100 u16 vmalloc_sllp;
@@ -104,7 +106,8 @@ struct paca_struct {
104 pgd_t *pgd; /* Current PGD */ 106 pgd_t *pgd; /* Current PGD */
105 pgd_t *kernel_pgd; /* Kernel PGD */ 107 pgd_t *kernel_pgd; /* Kernel PGD */
106 u64 exgen[8] __attribute__((aligned(0x80))); 108 u64 exgen[8] __attribute__((aligned(0x80)));
107 u64 extlb[EX_TLB_SIZE*3] __attribute__((aligned(0x80))); 109 /* We can have up to 3 levels of reentrancy in the TLB miss handler */
110 u64 extlb[3][EX_TLB_SIZE / sizeof(u64)] __attribute__((aligned(0x80)));
108 u64 exmc[8]; /* used for machine checks */ 111 u64 exmc[8]; /* used for machine checks */
109 u64 excrit[8]; /* used for crit interrupts */ 112 u64 excrit[8]; /* used for crit interrupts */
110 u64 exdbg[8]; /* used for debug interrupts */ 113 u64 exdbg[8]; /* used for debug interrupts */
@@ -123,19 +126,25 @@ struct paca_struct {
123 struct task_struct *__current; /* Pointer to current */ 126 struct task_struct *__current; /* Pointer to current */
124 u64 kstack; /* Saved Kernel stack addr */ 127 u64 kstack; /* Saved Kernel stack addr */
125 u64 stab_rr; /* stab/slb round-robin counter */ 128 u64 stab_rr; /* stab/slb round-robin counter */
126 u64 saved_r1; /* r1 save for RTAS calls */ 129 u64 saved_r1; /* r1 save for RTAS calls or PM */
127 u64 saved_msr; /* MSR saved here by enter_rtas */ 130 u64 saved_msr; /* MSR saved here by enter_rtas */
128 u16 trap_save; /* Used when bad stack is encountered */ 131 u16 trap_save; /* Used when bad stack is encountered */
129 u8 soft_enabled; /* irq soft-enable flag */ 132 u8 soft_enabled; /* irq soft-enable flag */
130 u8 hard_enabled; /* set if irqs are enabled in MSR */ 133 u8 hard_enabled; /* set if irqs are enabled in MSR */
131 u8 io_sync; /* writel() needs spin_unlock sync */ 134 u8 io_sync; /* writel() needs spin_unlock sync */
132 u8 perf_event_pending; /* PM interrupt while soft-disabled */ 135 u8 irq_work_pending; /* IRQ_WORK interrupt while soft-disable */
133 136
134 /* Stuff for accurate time accounting */ 137 /* Stuff for accurate time accounting */
135 u64 user_time; /* accumulated usermode TB ticks */ 138 u64 user_time; /* accumulated usermode TB ticks */
136 u64 system_time; /* accumulated system TB ticks */ 139 u64 system_time; /* accumulated system TB ticks */
137 u64 startpurr; /* PURR/TB value snapshot */ 140 u64 user_time_scaled; /* accumulated usermode SPURR ticks */
141 u64 starttime; /* TB value snapshot */
142 u64 starttime_user; /* TB value on exit to usermode */
138 u64 startspurr; /* SPURR value snapshot */ 143 u64 startspurr; /* SPURR value snapshot */
144 u64 utime_sspurr; /* ->user_time when ->startspurr set */
145 u64 stolen_time; /* TB ticks taken by hypervisor */
146 u64 dtl_ridx; /* read index in dispatch log */
147 struct dtl_entry *dtl_curr; /* pointer corresponding to dtl_ridx */
139 148
140#ifdef CONFIG_KVM_BOOK3S_HANDLER 149#ifdef CONFIG_KVM_BOOK3S_HANDLER
141 /* We use this to store guest state in */ 150 /* We use this to store guest state in */
diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
index 53b64be40eb2..2cd664ef0a5e 100644
--- a/arch/powerpc/include/asm/page.h
+++ b/arch/powerpc/include/asm/page.h
@@ -100,8 +100,8 @@ extern phys_addr_t kernstart_addr;
100#endif 100#endif
101 101
102#ifdef CONFIG_FLATMEM 102#ifdef CONFIG_FLATMEM
103#define ARCH_PFN_OFFSET (MEMORY_START >> PAGE_SHIFT) 103#define ARCH_PFN_OFFSET ((unsigned long)(MEMORY_START >> PAGE_SHIFT))
104#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < (ARCH_PFN_OFFSET + max_mapnr)) 104#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && (pfn) < max_mapnr)
105#endif 105#endif
106 106
107#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 107#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index 358ff14ea25e..9356262fd3cc 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -59,24 +59,7 @@ static __inline__ void clear_page(void *addr)
59 : "ctr", "memory"); 59 : "ctr", "memory");
60} 60}
61 61
62extern void copy_4K_page(void *to, void *from); 62extern void copy_page(void *to, void *from);
63
64#ifdef CONFIG_PPC_64K_PAGES
65static inline void copy_page(void *to, void *from)
66{
67 unsigned int i;
68 for (i=0; i < (1 << (PAGE_SHIFT - 12)); i++) {
69 copy_4K_page(to, from);
70 to += 4096;
71 from += 4096;
72 }
73}
74#else /* CONFIG_PPC_64K_PAGES */
75static inline void copy_page(void *to, void *from)
76{
77 copy_4K_page(to, from);
78}
79#endif /* CONFIG_PPC_64K_PAGES */
80 63
81/* Log 2 of page table size */ 64/* Log 2 of page table size */
82extern u64 ppc64_pft_size; 65extern u64 ppc64_pft_size;
@@ -130,7 +113,7 @@ extern void slice_set_user_psize(struct mm_struct *mm, unsigned int psize);
130extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start, 113extern void slice_set_range_psize(struct mm_struct *mm, unsigned long start,
131 unsigned long len, unsigned int psize); 114 unsigned long len, unsigned int psize);
132 115
133#define slice_mm_new_context(mm) ((mm)->context.id == 0) 116#define slice_mm_new_context(mm) ((mm)->context.id == MMU_NO_CONTEXT)
134 117
135#endif /* __ASSEMBLY__ */ 118#endif /* __ASSEMBLY__ */
136#else 119#else
@@ -163,13 +146,13 @@ do { \
163#endif /* !CONFIG_HUGETLB_PAGE */ 146#endif /* !CONFIG_HUGETLB_PAGE */
164 147
165#define VM_DATA_DEFAULT_FLAGS \ 148#define VM_DATA_DEFAULT_FLAGS \
166 (test_thread_flag(TIF_32BIT) ? \ 149 (is_32bit_task() ? \
167 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64) 150 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
168 151
169/* 152/*
170 * This is the default if a program doesn't have a PT_GNU_STACK 153 * This is the default if a program doesn't have a PT_GNU_STACK
171 * program header entry. The PPC64 ELF ABI has a non executable stack 154 * program header entry. The PPC64 ELF ABI has a non executable stack
172 * stack by default, so in the absense of a PT_GNU_STACK program header 155 * stack by default, so in the absence of a PT_GNU_STACK program header
173 * we turn execute permission off. 156 * we turn execute permission off.
174 */ 157 */
175#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \ 158#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
@@ -179,7 +162,7 @@ do { \
179 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) 162 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
180 163
181#define VM_STACK_DEFAULT_FLAGS \ 164#define VM_STACK_DEFAULT_FLAGS \
182 (test_thread_flag(TIF_32BIT) ? \ 165 (is_32bit_task() ? \
183 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64) 166 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
184 167
185#include <asm-generic/getorder.h> 168#include <asm-generic/getorder.h>
diff --git a/arch/powerpc/include/asm/pasemi_dma.h b/arch/powerpc/include/asm/pasemi_dma.h
index 19fd7933e2d9..eafa5a5f56de 100644
--- a/arch/powerpc/include/asm/pasemi_dma.h
+++ b/arch/powerpc/include/asm/pasemi_dma.h
@@ -522,7 +522,7 @@ extern void *pasemi_dma_alloc_buf(struct pasemi_dmachan *chan, int size,
522extern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size, 522extern void pasemi_dma_free_buf(struct pasemi_dmachan *chan, int size,
523 dma_addr_t *handle); 523 dma_addr_t *handle);
524 524
525/* Routines to allocate flags (events) for channel syncronization */ 525/* Routines to allocate flags (events) for channel synchronization */
526extern int pasemi_dma_alloc_flag(void); 526extern int pasemi_dma_alloc_flag(void);
527extern void pasemi_dma_free_flag(int flag); 527extern void pasemi_dma_free_flag(int flag);
528extern void pasemi_dma_set_flag(int flag); 528extern void pasemi_dma_set_flag(int flag);
diff --git a/arch/powerpc/include/asm/pci-bridge.h b/arch/powerpc/include/asm/pci-bridge.h
index 51e9e6f90d12..b90dbf8e5cd9 100644
--- a/arch/powerpc/include/asm/pci-bridge.h
+++ b/arch/powerpc/include/asm/pci-bridge.h
@@ -106,7 +106,7 @@ struct pci_controller {
106 * Used for variants of PCI indirect handling and possible quirks: 106 * Used for variants of PCI indirect handling and possible quirks:
107 * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1 107 * SET_CFG_TYPE - used on 4xx or any PHB that does explicit type0/1
108 * EXT_REG - provides access to PCI-e extended registers 108 * EXT_REG - provides access to PCI-e extended registers
109 * SURPRESS_PRIMARY_BUS - we surpress the setting of PCI_PRIMARY_BUS 109 * SURPRESS_PRIMARY_BUS - we suppress the setting of PCI_PRIMARY_BUS
110 * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS 110 * on Freescale PCI-e controllers since they used the PCI_PRIMARY_BUS
111 * to determine which bus number to match on when generating type0 111 * to determine which bus number to match on when generating type0
112 * config cycles 112 * config cycles
@@ -164,13 +164,23 @@ extern void setup_indirect_pci(struct pci_controller* hose,
164 resource_size_t cfg_addr, 164 resource_size_t cfg_addr,
165 resource_size_t cfg_data, u32 flags); 165 resource_size_t cfg_data, u32 flags);
166 166
167#ifndef CONFIG_PPC64
168
169static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus) 167static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
170{ 168{
171 return bus->sysdata; 169 return bus->sysdata;
172} 170}
173 171
172#ifndef CONFIG_PPC64
173
174static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
175{
176 struct pci_controller *host;
177
178 if (bus->self)
179 return pci_device_to_OF_node(bus->self);
180 host = pci_bus_to_host(bus);
181 return host ? host->dn : NULL;
182}
183
174static inline int isa_vaddr_is_ioport(void __iomem *address) 184static inline int isa_vaddr_is_ioport(void __iomem *address)
175{ 185{
176 /* No specific ISA handling on ppc32 at this stage, it 186 /* No specific ISA handling on ppc32 at this stage, it
@@ -218,19 +228,10 @@ extern void * update_dn_pci_info(struct device_node *dn, void *data);
218 228
219/* Get a device_node from a pci_dev. This code must be fast except 229/* Get a device_node from a pci_dev. This code must be fast except
220 * in the case where the sysdata is incorrect and needs to be fixed 230 * in the case where the sysdata is incorrect and needs to be fixed
221 * up (this will only happen once). 231 * up (this will only happen once). */
222 * In this case the sysdata will have been inherited from a PCI host
223 * bridge or a PCI-PCI bridge further up the tree, so it will point
224 * to a valid struct pci_dn, just not the one we want.
225 */
226static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) 232static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
227{ 233{
228 struct device_node *dn = dev->sysdata; 234 return dev->dev.of_node ? dev->dev.of_node : fetch_dev_dn(dev);
229 struct pci_dn *pdn = dn->data;
230
231 if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number)
232 return dn; /* fast path. sysdata is good */
233 return fetch_dev_dn(dev);
234} 235}
235 236
236static inline int pci_device_from_OF_node(struct device_node *np, 237static inline int pci_device_from_OF_node(struct device_node *np,
@@ -248,7 +249,7 @@ static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
248 if (bus->self) 249 if (bus->self)
249 return pci_device_to_OF_node(bus->self); 250 return pci_device_to_OF_node(bus->self);
250 else 251 else
251 return bus->sysdata; /* Must be root bus (PHB) */ 252 return bus->dev.of_node; /* Must be root bus (PHB) */
252} 253}
253 254
254/** Find the bus corresponding to the indicated device node */ 255/** Find the bus corresponding to the indicated device node */
@@ -260,14 +261,6 @@ extern void pcibios_remove_pci_devices(struct pci_bus *bus);
260/** Discover new pci devices under this bus, and add them */ 261/** Discover new pci devices under this bus, and add them */
261extern void pcibios_add_pci_devices(struct pci_bus *bus); 262extern void pcibios_add_pci_devices(struct pci_bus *bus);
262 263
263static inline struct pci_controller *pci_bus_to_host(const struct pci_bus *bus)
264{
265 struct device_node *busdn = bus->sysdata;
266
267 BUG_ON(busdn == NULL);
268 return PCI_DN(busdn)->phb;
269}
270
271 264
272extern void isa_bridge_find_early(struct pci_controller *hose); 265extern void isa_bridge_find_early(struct pci_controller *hose);
273 266
diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc/include/asm/pci.h
index a20a9ad2258b..7d7790954e02 100644
--- a/arch/powerpc/include/asm/pci.h
+++ b/arch/powerpc/include/asm/pci.h
@@ -201,7 +201,7 @@ extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
201extern void pcibios_setup_bus_devices(struct pci_bus *bus); 201extern void pcibios_setup_bus_devices(struct pci_bus *bus);
202extern void pcibios_setup_bus_self(struct pci_bus *bus); 202extern void pcibios_setup_bus_self(struct pci_bus *bus);
203extern void pcibios_setup_phb_io_space(struct pci_controller *hose); 203extern void pcibios_setup_phb_io_space(struct pci_controller *hose);
204extern void pcibios_scan_phb(struct pci_controller *hose, void *sysdata); 204extern void pcibios_scan_phb(struct pci_controller *hose);
205 205
206#endif /* __KERNEL__ */ 206#endif /* __KERNEL__ */
207#endif /* __ASM_POWERPC_PCI_H */ 207#endif /* __ASM_POWERPC_PCI_H */
diff --git a/arch/powerpc/include/asm/pgalloc.h b/arch/powerpc/include/asm/pgalloc.h
index abe8532bd14e..bf301ac62f35 100644
--- a/arch/powerpc/include/asm/pgalloc.h
+++ b/arch/powerpc/include/asm/pgalloc.h
@@ -31,14 +31,29 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t ptepage)
31#endif 31#endif
32 32
33#ifdef CONFIG_SMP 33#ifdef CONFIG_SMP
34extern void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift); 34struct mmu_gather;
35extern void pte_free_finish(void); 35extern void tlb_remove_table(struct mmu_gather *, void *);
36
37static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, int shift)
38{
39 unsigned long pgf = (unsigned long)table;
40 BUG_ON(shift > MAX_PGTABLE_INDEX_SIZE);
41 pgf |= shift;
42 tlb_remove_table(tlb, (void *)pgf);
43}
44
45static inline void __tlb_remove_table(void *_table)
46{
47 void *table = (void *)((unsigned long)_table & ~MAX_PGTABLE_INDEX_SIZE);
48 unsigned shift = (unsigned long)_table & MAX_PGTABLE_INDEX_SIZE;
49
50 pgtable_free(table, shift);
51}
36#else /* CONFIG_SMP */ 52#else /* CONFIG_SMP */
37static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift) 53static inline void pgtable_free_tlb(struct mmu_gather *tlb, void *table, unsigned shift)
38{ 54{
39 pgtable_free(table, shift); 55 pgtable_free(table, shift);
40} 56}
41static inline void pte_free_finish(void) { }
42#endif /* !CONFIG_SMP */ 57#endif /* !CONFIG_SMP */
43 58
44static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage, 59static inline void __pte_free_tlb(struct mmu_gather *tlb, struct page *ptepage,
diff --git a/arch/powerpc/include/asm/pgtable-ppc32.h b/arch/powerpc/include/asm/pgtable-ppc32.h
index a7db96f2b5c3..47edde8c3556 100644
--- a/arch/powerpc/include/asm/pgtable-ppc32.h
+++ b/arch/powerpc/include/asm/pgtable-ppc32.h
@@ -308,12 +308,8 @@ static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry)
308#define pte_offset_kernel(dir, addr) \ 308#define pte_offset_kernel(dir, addr) \
309 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr)) 309 ((pte_t *) pmd_page_vaddr(*(dir)) + pte_index(addr))
310#define pte_offset_map(dir, addr) \ 310#define pte_offset_map(dir, addr) \
311 ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE0) + pte_index(addr)) 311 ((pte_t *) kmap_atomic(pmd_page(*(dir))) + pte_index(addr))
312#define pte_offset_map_nested(dir, addr) \ 312#define pte_unmap(pte) kunmap_atomic(pte)
313 ((pte_t *) kmap_atomic(pmd_page(*(dir)), KM_PTE1) + pte_index(addr))
314
315#define pte_unmap(pte) kunmap_atomic(pte, KM_PTE0)
316#define pte_unmap_nested(pte) kunmap_atomic(pte, KM_PTE1)
317 313
318/* 314/*
319 * Encode and decode a swap entry. 315 * Encode and decode a swap entry.
diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h b/arch/powerpc/include/asm/pgtable-ppc64.h
index 49865045d56f..81576ee0cfb1 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -193,9 +193,7 @@
193 (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1))) 193 (((pte_t *) pmd_page_vaddr(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
194 194
195#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr)) 195#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
196#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
197#define pte_unmap(pte) do { } while(0) 196#define pte_unmap(pte) do { } while(0)
198#define pte_unmap_nested(pte) do { } while(0)
199 197
200/* to find an entry in a kernel page-table-directory */ 198/* to find an entry in a kernel page-table-directory */
201/* This now only contains the vmalloc pages */ 199/* This now only contains the vmalloc pages */
@@ -259,21 +257,20 @@ static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
259static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr, 257static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
260 pte_t *ptep) 258 pte_t *ptep)
261{ 259{
262 unsigned long old;
263 260
264 if ((pte_val(*ptep) & _PAGE_RW) == 0) 261 if ((pte_val(*ptep) & _PAGE_RW) == 0)
265 return; 262 return;
266 old = pte_update(mm, addr, ptep, _PAGE_RW, 0); 263
264 pte_update(mm, addr, ptep, _PAGE_RW, 0);
267} 265}
268 266
269static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, 267static inline void huge_ptep_set_wrprotect(struct mm_struct *mm,
270 unsigned long addr, pte_t *ptep) 268 unsigned long addr, pte_t *ptep)
271{ 269{
272 unsigned long old;
273
274 if ((pte_val(*ptep) & _PAGE_RW) == 0) 270 if ((pte_val(*ptep) & _PAGE_RW) == 0)
275 return; 271 return;
276 old = pte_update(mm, addr, ptep, _PAGE_RW, 1); 272
273 pte_update(mm, addr, ptep, _PAGE_RW, 1);
277} 274}
278 275
279/* 276/*
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
index 89f158731ce3..88b0bd925a8b 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -170,6 +170,7 @@ extern int ptep_set_access_flags(struct vm_area_struct *vma, unsigned long addre
170#define pgprot_cached_wthru(prot) (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \ 170#define pgprot_cached_wthru(prot) (__pgprot((pgprot_val(prot) & ~_PAGE_CACHE_CTL) | \
171 _PAGE_COHERENT | _PAGE_WRITETHRU)) 171 _PAGE_COHERENT | _PAGE_WRITETHRU))
172 172
173#define pgprot_writecombine pgprot_noncached_wc
173 174
174struct file; 175struct file;
175extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 176extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
diff --git a/arch/powerpc/include/asm/pmac_feature.h b/arch/powerpc/include/asm/pmac_feature.h
index 00eedc5a4e61..10902c9375d0 100644
--- a/arch/powerpc/include/asm/pmac_feature.h
+++ b/arch/powerpc/include/asm/pmac_feature.h
@@ -53,8 +53,8 @@
53 53
54/* Here is the infamous serie of OHare based machines 54/* Here is the infamous serie of OHare based machines
55 */ 55 */
56#define PMAC_TYPE_COMET 0x20 /* Beleived to be PowerBook 2400 */ 56#define PMAC_TYPE_COMET 0x20 /* Believed to be PowerBook 2400 */
57#define PMAC_TYPE_HOOPER 0x21 /* Beleived to be PowerBook 3400 */ 57#define PMAC_TYPE_HOOPER 0x21 /* Believed to be PowerBook 3400 */
58#define PMAC_TYPE_KANGA 0x22 /* PowerBook 3500 (first G3) */ 58#define PMAC_TYPE_KANGA 0x22 /* PowerBook 3500 (first G3) */
59#define PMAC_TYPE_ALCHEMY 0x23 /* Alchemy motherboard base */ 59#define PMAC_TYPE_ALCHEMY 0x23 /* Alchemy motherboard base */
60#define PMAC_TYPE_GAZELLE 0x24 /* Spartacus, some 5xxx/6xxx */ 60#define PMAC_TYPE_GAZELLE 0x24 /* Spartacus, some 5xxx/6xxx */
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 43adc8b819ed..e472659d906c 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -36,9 +36,15 @@
36#define PPC_INST_NOP 0x60000000 36#define PPC_INST_NOP 0x60000000
37#define PPC_INST_POPCNTB 0x7c0000f4 37#define PPC_INST_POPCNTB 0x7c0000f4
38#define PPC_INST_POPCNTB_MASK 0xfc0007fe 38#define PPC_INST_POPCNTB_MASK 0xfc0007fe
39#define PPC_INST_POPCNTD 0x7c0003f4
40#define PPC_INST_POPCNTW 0x7c0002f4
39#define PPC_INST_RFCI 0x4c000066 41#define PPC_INST_RFCI 0x4c000066
40#define PPC_INST_RFDI 0x4c00004e 42#define PPC_INST_RFDI 0x4c00004e
41#define PPC_INST_RFMCI 0x4c00004c 43#define PPC_INST_RFMCI 0x4c00004c
44#define PPC_INST_MFSPR_DSCR 0x7c1102a6
45#define PPC_INST_MFSPR_DSCR_MASK 0xfc1fffff
46#define PPC_INST_MTSPR_DSCR 0x7c1103a6
47#define PPC_INST_MTSPR_DSCR_MASK 0xfc1fffff
42 48
43#define PPC_INST_STRING 0x7c00042a 49#define PPC_INST_STRING 0x7c00042a
44#define PPC_INST_STRING_MASK 0xfc0007fe 50#define PPC_INST_STRING_MASK 0xfc0007fe
@@ -54,6 +60,17 @@
54#define PPC_INST_TLBSRX_DOT 0x7c0006a5 60#define PPC_INST_TLBSRX_DOT 0x7c0006a5
55#define PPC_INST_XXLOR 0xf0000510 61#define PPC_INST_XXLOR 0xf0000510
56 62
63#define PPC_INST_NAP 0x4c000364
64#define PPC_INST_SLEEP 0x4c0003a4
65
66/* A2 specific instructions */
67#define PPC_INST_ERATWE 0x7c0001a6
68#define PPC_INST_ERATRE 0x7c000166
69#define PPC_INST_ERATILX 0x7c000066
70#define PPC_INST_ERATIVAX 0x7c000666
71#define PPC_INST_ERATSX 0x7c000126
72#define PPC_INST_ERATSX_DOT 0x7c000127
73
57/* macros to insert fields into opcodes */ 74/* macros to insert fields into opcodes */
58#define __PPC_RA(a) (((a) & 0x1f) << 16) 75#define __PPC_RA(a) (((a) & 0x1f) << 16)
59#define __PPC_RB(b) (((b) & 0x1f) << 11) 76#define __PPC_RB(b) (((b) & 0x1f) << 11)
@@ -65,6 +82,8 @@
65#define __PPC_XT(s) __PPC_XS(s) 82#define __PPC_XT(s) __PPC_XS(s)
66#define __PPC_T_TLB(t) (((t) & 0x3) << 21) 83#define __PPC_T_TLB(t) (((t) & 0x3) << 21)
67#define __PPC_WC(w) (((w) & 0x3) << 21) 84#define __PPC_WC(w) (((w) & 0x3) << 21)
85#define __PPC_WS(w) (((w) & 0x1f) << 11)
86
68/* 87/*
69 * Only use the larx hint bit on 64bit CPUs. e500v1/v2 based CPUs will treat a 88 * Only use the larx hint bit on 64bit CPUs. e500v1/v2 based CPUs will treat a
70 * larx with EH set as an illegal instruction. 89 * larx with EH set as an illegal instruction.
@@ -88,6 +107,12 @@
88 __PPC_RB(b) | __PPC_EH(eh)) 107 __PPC_RB(b) | __PPC_EH(eh))
89#define PPC_MSGSND(b) stringify_in_c(.long PPC_INST_MSGSND | \ 108#define PPC_MSGSND(b) stringify_in_c(.long PPC_INST_MSGSND | \
90 __PPC_RB(b)) 109 __PPC_RB(b))
110#define PPC_POPCNTB(a, s) stringify_in_c(.long PPC_INST_POPCNTB | \
111 __PPC_RA(a) | __PPC_RS(s))
112#define PPC_POPCNTD(a, s) stringify_in_c(.long PPC_INST_POPCNTD | \
113 __PPC_RA(a) | __PPC_RS(s))
114#define PPC_POPCNTW(a, s) stringify_in_c(.long PPC_INST_POPCNTW | \
115 __PPC_RA(a) | __PPC_RS(s))
91#define PPC_RFCI stringify_in_c(.long PPC_INST_RFCI) 116#define PPC_RFCI stringify_in_c(.long PPC_INST_RFCI)
92#define PPC_RFDI stringify_in_c(.long PPC_INST_RFDI) 117#define PPC_RFDI stringify_in_c(.long PPC_INST_RFDI)
93#define PPC_RFMCI stringify_in_c(.long PPC_INST_RFMCI) 118#define PPC_RFMCI stringify_in_c(.long PPC_INST_RFMCI)
@@ -105,6 +130,21 @@
105#define PPC_TLBIVAX(a,b) stringify_in_c(.long PPC_INST_TLBIVAX | \ 130#define PPC_TLBIVAX(a,b) stringify_in_c(.long PPC_INST_TLBIVAX | \
106 __PPC_RA(a) | __PPC_RB(b)) 131 __PPC_RA(a) | __PPC_RB(b))
107 132
133#define PPC_ERATWE(s, a, w) stringify_in_c(.long PPC_INST_ERATWE | \
134 __PPC_RS(s) | __PPC_RA(a) | __PPC_WS(w))
135#define PPC_ERATRE(s, a, w) stringify_in_c(.long PPC_INST_ERATRE | \
136 __PPC_RS(s) | __PPC_RA(a) | __PPC_WS(w))
137#define PPC_ERATILX(t, a, b) stringify_in_c(.long PPC_INST_ERATILX | \
138 __PPC_T_TLB(t) | __PPC_RA(a) | \
139 __PPC_RB(b))
140#define PPC_ERATIVAX(s, a, b) stringify_in_c(.long PPC_INST_ERATIVAX | \
141 __PPC_RS(s) | __PPC_RA(a) | __PPC_RB(b))
142#define PPC_ERATSX(t, a, w) stringify_in_c(.long PPC_INST_ERATSX | \
143 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b))
144#define PPC_ERATSX_DOT(t, a, w) stringify_in_c(.long PPC_INST_ERATSX_DOT | \
145 __PPC_RS(t) | __PPC_RA(a) | __PPC_RB(b))
146
147
108/* 148/*
109 * Define what the VSX XX1 form instructions will look like, then add 149 * Define what the VSX XX1 form instructions will look like, then add
110 * the 128 bit load store instructions based on that. 150 * the 128 bit load store instructions based on that.
@@ -118,4 +158,7 @@
118#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \ 158#define XXLOR(t, a, b) stringify_in_c(.long PPC_INST_XXLOR | \
119 VSX_XX3((t), (a), (b))) 159 VSX_XX3((t), (a), (b)))
120 160
161#define PPC_NAP stringify_in_c(.long PPC_INST_NAP)
162#define PPC_SLEEP stringify_in_c(.long PPC_INST_SLEEP)
163
121#endif /* _ASM_POWERPC_PPC_OPCODE_H */ 164#endif /* _ASM_POWERPC_PPC_OPCODE_H */
diff --git a/arch/powerpc/include/asm/ppc-pci.h b/arch/powerpc/include/asm/ppc-pci.h
index 42fdff0e4b32..43268f15004e 100644
--- a/arch/powerpc/include/asm/ppc-pci.h
+++ b/arch/powerpc/include/asm/ppc-pci.h
@@ -28,8 +28,8 @@ extern void find_and_init_phbs(void);
28extern struct pci_dev *isa_bridge_pcidev; /* may be NULL if no ISA bus */ 28extern struct pci_dev *isa_bridge_pcidev; /* may be NULL if no ISA bus */
29 29
30/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */ 30/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
31#define BUID_HI(buid) ((buid) >> 32) 31#define BUID_HI(buid) upper_32_bits(buid)
32#define BUID_LO(buid) ((buid) & 0xffffffff) 32#define BUID_LO(buid) lower_32_bits(buid)
33 33
34/* PCI device_node operations */ 34/* PCI device_node operations */
35struct device_node; 35struct device_node;
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h
index 498fe09263d3..1b422381fc16 100644
--- a/arch/powerpc/include/asm/ppc_asm.h
+++ b/arch/powerpc/include/asm/ppc_asm.h
@@ -9,6 +9,7 @@
9#include <asm/asm-compat.h> 9#include <asm/asm-compat.h>
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/ppc-opcode.h> 11#include <asm/ppc-opcode.h>
12#include <asm/firmware.h>
12 13
13#ifndef __ASSEMBLY__ 14#ifndef __ASSEMBLY__
14#error __FILE__ should only be used in assembler files 15#error __FILE__ should only be used in assembler files
@@ -26,17 +27,13 @@
26#ifndef CONFIG_VIRT_CPU_ACCOUNTING 27#ifndef CONFIG_VIRT_CPU_ACCOUNTING
27#define ACCOUNT_CPU_USER_ENTRY(ra, rb) 28#define ACCOUNT_CPU_USER_ENTRY(ra, rb)
28#define ACCOUNT_CPU_USER_EXIT(ra, rb) 29#define ACCOUNT_CPU_USER_EXIT(ra, rb)
30#define ACCOUNT_STOLEN_TIME
29#else 31#else
30#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \ 32#define ACCOUNT_CPU_USER_ENTRY(ra, rb) \
31 beq 2f; /* if from kernel mode */ \ 33 beq 2f; /* if from kernel mode */ \
32BEGIN_FTR_SECTION; \ 34 MFTB(ra); /* get timebase */ \
33 mfspr ra,SPRN_PURR; /* get processor util. reg */ \ 35 ld rb,PACA_STARTTIME_USER(r13); \
34END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ 36 std ra,PACA_STARTTIME(r13); \
35BEGIN_FTR_SECTION; \
36 MFTB(ra); /* or get TB if no PURR */ \
37END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
38 ld rb,PACA_STARTPURR(r13); \
39 std ra,PACA_STARTPURR(r13); \
40 subf rb,rb,ra; /* subtract start value */ \ 37 subf rb,rb,ra; /* subtract start value */ \
41 ld ra,PACA_USER_TIME(r13); \ 38 ld ra,PACA_USER_TIME(r13); \
42 add ra,ra,rb; /* add on to user time */ \ 39 add ra,ra,rb; /* add on to user time */ \
@@ -44,19 +41,34 @@ END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
442: 412:
45 42
46#define ACCOUNT_CPU_USER_EXIT(ra, rb) \ 43#define ACCOUNT_CPU_USER_EXIT(ra, rb) \
47BEGIN_FTR_SECTION; \ 44 MFTB(ra); /* get timebase */ \
48 mfspr ra,SPRN_PURR; /* get processor util. reg */ \ 45 ld rb,PACA_STARTTIME(r13); \
49END_FTR_SECTION_IFSET(CPU_FTR_PURR); \ 46 std ra,PACA_STARTTIME_USER(r13); \
50BEGIN_FTR_SECTION; \
51 MFTB(ra); /* or get TB if no PURR */ \
52END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
53 ld rb,PACA_STARTPURR(r13); \
54 std ra,PACA_STARTPURR(r13); \
55 subf rb,rb,ra; /* subtract start value */ \ 47 subf rb,rb,ra; /* subtract start value */ \
56 ld ra,PACA_SYSTEM_TIME(r13); \ 48 ld ra,PACA_SYSTEM_TIME(r13); \
57 add ra,ra,rb; /* add on to user time */ \ 49 add ra,ra,rb; /* add on to system time */ \
58 std ra,PACA_SYSTEM_TIME(r13); 50 std ra,PACA_SYSTEM_TIME(r13)
59#endif 51
52#ifdef CONFIG_PPC_SPLPAR
53#define ACCOUNT_STOLEN_TIME \
54BEGIN_FW_FTR_SECTION; \
55 beq 33f; \
56 /* from user - see if there are any DTL entries to process */ \
57 ld r10,PACALPPACAPTR(r13); /* get ptr to VPA */ \
58 ld r11,PACA_DTL_RIDX(r13); /* get log read index */ \
59 ld r10,LPPACA_DTLIDX(r10); /* get log write index */ \
60 cmpd cr1,r11,r10; \
61 beq+ cr1,33f; \
62 bl .accumulate_stolen_time; \
6333: \
64END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
65
66#else /* CONFIG_PPC_SPLPAR */
67#define ACCOUNT_STOLEN_TIME
68
69#endif /* CONFIG_PPC_SPLPAR */
70
71#endif /* CONFIG_VIRT_CPU_ACCOUNTING */
60 72
61/* 73/*
62 * Macros for storing registers into and loading registers from 74 * Macros for storing registers into and loading registers from
@@ -158,6 +170,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_PURR); \
158#define HMT_MEDIUM or 2,2,2 170#define HMT_MEDIUM or 2,2,2
159#define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority 171#define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority
160#define HMT_HIGH or 3,3,3 172#define HMT_HIGH or 3,3,3
173#define HMT_EXTRA_HIGH or 7,7,7 # power7 only
161 174
162#ifdef __KERNEL__ 175#ifdef __KERNEL__
163#ifdef CONFIG_PPC64 176#ifdef CONFIG_PPC64
diff --git a/arch/powerpc/include/asm/processor.h b/arch/powerpc/include/asm/processor.h
index 19c05b0f74be..d50c2b6d9bc3 100644
--- a/arch/powerpc/include/asm/processor.h
+++ b/arch/powerpc/include/asm/processor.h
@@ -118,17 +118,16 @@ extern struct task_struct *last_task_used_spe;
118#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4)) 118#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
119#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4)) 119#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
120 120
121#define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \ 121#define TASK_UNMAPPED_BASE ((is_32bit_task()) ? \
122 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 ) 122 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
123#endif 123#endif
124 124
125#ifdef __KERNEL__
126#ifdef __powerpc64__ 125#ifdef __powerpc64__
127 126
128#define STACK_TOP_USER64 TASK_SIZE_USER64 127#define STACK_TOP_USER64 TASK_SIZE_USER64
129#define STACK_TOP_USER32 TASK_SIZE_USER32 128#define STACK_TOP_USER32 TASK_SIZE_USER32
130 129
131#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \ 130#define STACK_TOP (is_32bit_task() ? \
132 STACK_TOP_USER32 : STACK_TOP_USER64) 131 STACK_TOP_USER32 : STACK_TOP_USER64)
133 132
134#define STACK_TOP_MAX STACK_TOP_USER64 133#define STACK_TOP_MAX STACK_TOP_USER64
@@ -139,7 +138,6 @@ extern struct task_struct *last_task_used_spe;
139#define STACK_TOP_MAX STACK_TOP 138#define STACK_TOP_MAX STACK_TOP
140 139
141#endif /* __powerpc64__ */ 140#endif /* __powerpc64__ */
142#endif /* __KERNEL__ */
143 141
144typedef struct { 142typedef struct {
145 unsigned long seg; 143 unsigned long seg;
@@ -240,6 +238,10 @@ struct thread_struct {
240#ifdef CONFIG_KVM_BOOK3S_32_HANDLER 238#ifdef CONFIG_KVM_BOOK3S_32_HANDLER
241 void* kvm_shadow_vcpu; /* KVM internal data */ 239 void* kvm_shadow_vcpu; /* KVM internal data */
242#endif /* CONFIG_KVM_BOOK3S_32_HANDLER */ 240#endif /* CONFIG_KVM_BOOK3S_32_HANDLER */
241#ifdef CONFIG_PPC64
242 unsigned long dscr;
243 int dscr_inherit;
244#endif
243}; 245};
244 246
245#define ARCH_MIN_TASKALIGN 16 247#define ARCH_MIN_TASKALIGN 16
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/prom.h
index ae26f2efd089..c189aa5fe1f4 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -42,7 +42,7 @@ extern void pci_create_OF_bus_map(void);
42 42
43/* Translate a DMA address from device space to CPU space */ 43/* Translate a DMA address from device space to CPU space */
44extern u64 of_translate_dma_address(struct device_node *dev, 44extern u64 of_translate_dma_address(struct device_node *dev,
45 const u32 *in_addr); 45 const __be32 *in_addr);
46 46
47#ifdef CONFIG_PCI 47#ifdef CONFIG_PCI
48extern unsigned long pci_address_to_pio(phys_addr_t address); 48extern unsigned long pci_address_to_pio(phys_addr_t address);
@@ -63,9 +63,6 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
63/* cache lookup */ 63/* cache lookup */
64struct device_node *of_find_next_cache_node(struct device_node *np); 64struct device_node *of_find_next_cache_node(struct device_node *np);
65 65
66/* Get the MAC address */
67extern const void *of_get_mac_address(struct device_node *np);
68
69#ifdef CONFIG_NUMA 66#ifdef CONFIG_NUMA
70extern int of_node_to_nid(struct device_node *device); 67extern int of_node_to_nid(struct device_node *device);
71#else 68#else
@@ -73,21 +70,6 @@ static inline int of_node_to_nid(struct device_node *device) { return 0; }
73#endif 70#endif
74#define of_node_to_nid of_node_to_nid 71#define of_node_to_nid of_node_to_nid
75 72
76/**
77 * of_irq_map_pci - Resolve the interrupt for a PCI device
78 * @pdev: the device whose interrupt is to be resolved
79 * @out_irq: structure of_irq filled by this function
80 *
81 * This function resolves the PCI interrupt for a given PCI device. If a
82 * device-node exists for a given pci_dev, it will use normal OF tree
83 * walking. If not, it will implement standard swizzling and walk up the
84 * PCI tree until an device-node is found, at which point it will finish
85 * resolving using the OF tree walking.
86 */
87struct pci_dev;
88struct of_irq;
89extern int of_irq_map_pci(struct pci_dev *pdev, struct of_irq *out_irq);
90
91extern void of_instantiate_rtc(void); 73extern void of_instantiate_rtc(void);
92 74
93/* These includes are put at the bottom because they may contain things 75/* These includes are put at the bottom because they may contain things
diff --git a/arch/powerpc/include/asm/pte-common.h b/arch/powerpc/include/asm/pte-common.h
index f2b370180a09..8d1569c29042 100644
--- a/arch/powerpc/include/asm/pte-common.h
+++ b/arch/powerpc/include/asm/pte-common.h
@@ -86,7 +86,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
86#define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1)) 86#define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1))
87#endif 87#endif
88 88
89/* _PAGE_CHG_MASK masks of bits that are to be preserved accross 89/* _PAGE_CHG_MASK masks of bits that are to be preserved across
90 * pgprot changes 90 * pgprot changes
91 */ 91 */
92#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ 92#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
@@ -162,7 +162,7 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
162 * on platforms where such control is possible. 162 * on platforms where such control is possible.
163 */ 163 */
164#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\ 164#if defined(CONFIG_KGDB) || defined(CONFIG_XMON) || defined(CONFIG_BDI_SWITCH) ||\
165 defined(CONFIG_KPROBES) 165 defined(CONFIG_KPROBES) || defined(CONFIG_DYNAMIC_FTRACE)
166#define PAGE_KERNEL_TEXT PAGE_KERNEL_X 166#define PAGE_KERNEL_TEXT PAGE_KERNEL_X
167#else 167#else
168#define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX 168#define PAGE_KERNEL_TEXT PAGE_KERNEL_ROX
@@ -171,6 +171,13 @@ extern unsigned long bad_call_to_PMD_PAGE_SIZE(void);
171/* Make modules code happy. We don't set RO yet */ 171/* Make modules code happy. We don't set RO yet */
172#define PAGE_KERNEL_EXEC PAGE_KERNEL_X 172#define PAGE_KERNEL_EXEC PAGE_KERNEL_X
173 173
174/*
175 * Don't just check for any non zero bits in __PAGE_USER, since for book3e
176 * and PTE_64BIT, PAGE_KERNEL_X contains _PAGE_BAP_SR which is also in
177 * _PAGE_USER. Need to explicitly match _PAGE_BAP_UR bit in that case too.
178 */
179#define pte_user(val) ((val & _PAGE_USER) == _PAGE_USER)
180
174/* Advertise special mapping type for AGP */ 181/* Advertise special mapping type for AGP */
175#define PAGE_AGP (PAGE_KERNEL_NC) 182#define PAGE_AGP (PAGE_KERNEL_NC)
176#define HAVE_PAGE_AGP 183#define HAVE_PAGE_AGP
diff --git a/arch/powerpc/include/asm/pte-hash64-64k.h b/arch/powerpc/include/asm/pte-hash64-64k.h
index c4490f9c67c4..59247e816ac5 100644
--- a/arch/powerpc/include/asm/pte-hash64-64k.h
+++ b/arch/powerpc/include/asm/pte-hash64-64k.h
@@ -22,7 +22,7 @@
22#define _PAGE_HASHPTE _PAGE_HPTE_SUB 22#define _PAGE_HASHPTE _PAGE_HPTE_SUB
23 23
24/* Note the full page bits must be in the same location as for normal 24/* Note the full page bits must be in the same location as for normal
25 * 4k pages as the same asssembly will be used to insert 64K pages 25 * 4k pages as the same assembly will be used to insert 64K pages
26 * wether the kernel has CONFIG_PPC_64K_PAGES or not 26 * wether the kernel has CONFIG_PPC_64K_PAGES or not
27 */ 27 */
28#define _PAGE_F_SECOND 0x00008000 /* full page: hidx bits */ 28#define _PAGE_F_SECOND 0x00008000 /* full page: hidx bits */
diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h
index 0175a676b34b..48223f9b8728 100644
--- a/arch/powerpc/include/asm/ptrace.h
+++ b/arch/powerpc/include/asm/ptrace.h
@@ -125,8 +125,10 @@ extern int ptrace_put_reg(struct task_struct *task, int regno,
125#endif /* ! __powerpc64__ */ 125#endif /* ! __powerpc64__ */
126#define TRAP(regs) ((regs)->trap & ~0xF) 126#define TRAP(regs) ((regs)->trap & ~0xF)
127#ifdef __powerpc64__ 127#ifdef __powerpc64__
128#define NV_REG_POISON 0xdeadbeefdeadbeefUL
128#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1) 129#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
129#else 130#else
131#define NV_REG_POISON 0xdeadbeef
130#define CHECK_FULL_REGS(regs) \ 132#define CHECK_FULL_REGS(regs) \
131do { \ 133do { \
132 if ((regs)->trap & 1) \ 134 if ((regs)->trap & 1) \
diff --git a/arch/powerpc/include/asm/qe_ic.h b/arch/powerpc/include/asm/qe_ic.h
index cf519663a791..f706164b0bd0 100644
--- a/arch/powerpc/include/asm/qe_ic.h
+++ b/arch/powerpc/include/asm/qe_ic.h
@@ -81,7 +81,7 @@ int qe_ic_set_high_priority(unsigned int virq, unsigned int priority, int high);
81static inline void qe_ic_cascade_low_ipic(unsigned int irq, 81static inline void qe_ic_cascade_low_ipic(unsigned int irq,
82 struct irq_desc *desc) 82 struct irq_desc *desc)
83{ 83{
84 struct qe_ic *qe_ic = desc->handler_data; 84 struct qe_ic *qe_ic = irq_desc_get_handler_data(desc);
85 unsigned int cascade_irq = qe_ic_get_low_irq(qe_ic); 85 unsigned int cascade_irq = qe_ic_get_low_irq(qe_ic);
86 86
87 if (cascade_irq != NO_IRQ) 87 if (cascade_irq != NO_IRQ)
@@ -91,7 +91,7 @@ static inline void qe_ic_cascade_low_ipic(unsigned int irq,
91static inline void qe_ic_cascade_high_ipic(unsigned int irq, 91static inline void qe_ic_cascade_high_ipic(unsigned int irq,
92 struct irq_desc *desc) 92 struct irq_desc *desc)
93{ 93{
94 struct qe_ic *qe_ic = desc->handler_data; 94 struct qe_ic *qe_ic = irq_desc_get_handler_data(desc);
95 unsigned int cascade_irq = qe_ic_get_high_irq(qe_ic); 95 unsigned int cascade_irq = qe_ic_get_high_irq(qe_ic);
96 96
97 if (cascade_irq != NO_IRQ) 97 if (cascade_irq != NO_IRQ)
@@ -101,32 +101,35 @@ static inline void qe_ic_cascade_high_ipic(unsigned int irq,
101static inline void qe_ic_cascade_low_mpic(unsigned int irq, 101static inline void qe_ic_cascade_low_mpic(unsigned int irq,
102 struct irq_desc *desc) 102 struct irq_desc *desc)
103{ 103{
104 struct qe_ic *qe_ic = desc->handler_data; 104 struct qe_ic *qe_ic = irq_desc_get_handler_data(desc);
105 unsigned int cascade_irq = qe_ic_get_low_irq(qe_ic); 105 unsigned int cascade_irq = qe_ic_get_low_irq(qe_ic);
106 struct irq_chip *chip = irq_desc_get_chip(desc);
106 107
107 if (cascade_irq != NO_IRQ) 108 if (cascade_irq != NO_IRQ)
108 generic_handle_irq(cascade_irq); 109 generic_handle_irq(cascade_irq);
109 110
110 desc->chip->eoi(irq); 111 chip->irq_eoi(&desc->irq_data);
111} 112}
112 113
113static inline void qe_ic_cascade_high_mpic(unsigned int irq, 114static inline void qe_ic_cascade_high_mpic(unsigned int irq,
114 struct irq_desc *desc) 115 struct irq_desc *desc)
115{ 116{
116 struct qe_ic *qe_ic = desc->handler_data; 117 struct qe_ic *qe_ic = irq_desc_get_handler_data(desc);
117 unsigned int cascade_irq = qe_ic_get_high_irq(qe_ic); 118 unsigned int cascade_irq = qe_ic_get_high_irq(qe_ic);
119 struct irq_chip *chip = irq_desc_get_chip(desc);
118 120
119 if (cascade_irq != NO_IRQ) 121 if (cascade_irq != NO_IRQ)
120 generic_handle_irq(cascade_irq); 122 generic_handle_irq(cascade_irq);
121 123
122 desc->chip->eoi(irq); 124 chip->irq_eoi(&desc->irq_data);
123} 125}
124 126
125static inline void qe_ic_cascade_muxed_mpic(unsigned int irq, 127static inline void qe_ic_cascade_muxed_mpic(unsigned int irq,
126 struct irq_desc *desc) 128 struct irq_desc *desc)
127{ 129{
128 struct qe_ic *qe_ic = desc->handler_data; 130 struct qe_ic *qe_ic = irq_desc_get_handler_data(desc);
129 unsigned int cascade_irq; 131 unsigned int cascade_irq;
132 struct irq_chip *chip = irq_desc_get_chip(desc);
130 133
131 cascade_irq = qe_ic_get_high_irq(qe_ic); 134 cascade_irq = qe_ic_get_high_irq(qe_ic);
132 if (cascade_irq == NO_IRQ) 135 if (cascade_irq == NO_IRQ)
@@ -135,7 +138,7 @@ static inline void qe_ic_cascade_muxed_mpic(unsigned int irq,
135 if (cascade_irq != NO_IRQ) 138 if (cascade_irq != NO_IRQ)
136 generic_handle_irq(cascade_irq); 139 generic_handle_irq(cascade_irq);
137 140
138 desc->chip->eoi(irq); 141 chip->irq_eoi(&desc->irq_data);
139} 142}
140 143
141#endif /* _ASM_POWERPC_QE_IC_H */ 144#endif /* _ASM_POWERPC_QE_IC_H */
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index ff0005eec7dd..c5cae0dd176c 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -99,17 +99,23 @@
99#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */ 99#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */
100 100
101#if defined(CONFIG_PPC_BOOK3S_64) 101#if defined(CONFIG_PPC_BOOK3S_64)
102#define MSR_64BIT MSR_SF
103
102/* Server variant */ 104/* Server variant */
103#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV 105#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF |MSR_HV
104#define MSR_KERNEL MSR_ | MSR_SF 106#define MSR_KERNEL MSR_ | MSR_64BIT
105#define MSR_USER32 MSR_ | MSR_PR | MSR_EE 107#define MSR_USER32 MSR_ | MSR_PR | MSR_EE
106#define MSR_USER64 MSR_USER32 | MSR_SF 108#define MSR_USER64 MSR_USER32 | MSR_64BIT
107#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_8xx) 109#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_8xx)
108/* Default MSR for kernel mode. */ 110/* Default MSR for kernel mode. */
109#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR) 111#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR)
110#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) 112#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
111#endif 113#endif
112 114
115#ifndef MSR_64BIT
116#define MSR_64BIT 0
117#endif
118
113/* Floating Point Status and Control Register (FPSCR) Fields */ 119/* Floating Point Status and Control Register (FPSCR) Fields */
114#define FPSCR_FX 0x80000000 /* FPU exception summary */ 120#define FPSCR_FX 0x80000000 /* FPU exception summary */
115#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */ 121#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */
@@ -170,8 +176,20 @@
170#define SPEFSCR_FRMC 0x00000003 /* Embedded FP rounding mode control */ 176#define SPEFSCR_FRMC 0x00000003 /* Embedded FP rounding mode control */
171 177
172/* Special Purpose Registers (SPRNs)*/ 178/* Special Purpose Registers (SPRNs)*/
179
180#ifdef CONFIG_40x
181#define SPRN_PID 0x3B1 /* Process ID */
182#else
183#define SPRN_PID 0x030 /* Process ID */
184#ifdef CONFIG_BOOKE
185#define SPRN_PID0 SPRN_PID/* Process ID Register 0 */
186#endif
187#endif
188
173#define SPRN_CTR 0x009 /* Count Register */ 189#define SPRN_CTR 0x009 /* Count Register */
174#define SPRN_DSCR 0x11 190#define SPRN_DSCR 0x11
191#define SPRN_CFAR 0x1c /* Come From Address Register */
192#define SPRN_ACOP 0x1F /* Available Coprocessor Register */
175#define SPRN_CTRLF 0x088 193#define SPRN_CTRLF 0x088
176#define SPRN_CTRLT 0x098 194#define SPRN_CTRLT 0x098
177#define CTRL_CT 0xc0000000 /* current thread */ 195#define CTRL_CT 0xc0000000 /* current thread */
@@ -200,8 +218,43 @@
200#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */ 218#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */
201#define SPRN_TBWU 0x11D /* Time Base Upper Register (super, R/W) */ 219#define SPRN_TBWU 0x11D /* Time Base Upper Register (super, R/W) */
202#define SPRN_SPURR 0x134 /* Scaled PURR */ 220#define SPRN_SPURR 0x134 /* Scaled PURR */
221#define SPRN_HSPRG0 0x130 /* Hypervisor Scratch 0 */
222#define SPRN_HSPRG1 0x131 /* Hypervisor Scratch 1 */
223#define SPRN_HDSISR 0x132
224#define SPRN_HDAR 0x133
225#define SPRN_HDEC 0x136 /* Hypervisor Decrementer */
203#define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ 226#define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */
227#define SPRN_RMOR 0x138 /* Real mode offset register */
228#define SPRN_HRMOR 0x139 /* Real mode offset register */
229#define SPRN_HSRR0 0x13A /* Hypervisor Save/Restore 0 */
230#define SPRN_HSRR1 0x13B /* Hypervisor Save/Restore 1 */
204#define SPRN_LPCR 0x13E /* LPAR Control Register */ 231#define SPRN_LPCR 0x13E /* LPAR Control Register */
232#define LPCR_VPM0 (1ul << (63-0))
233#define LPCR_VPM1 (1ul << (63-1))
234#define LPCR_ISL (1ul << (63-2))
235#define LPCR_DPFD_SH (63-11)
236#define LPCR_VRMA_L (1ul << (63-12))
237#define LPCR_VRMA_LP0 (1ul << (63-15))
238#define LPCR_VRMA_LP1 (1ul << (63-16))
239#define LPCR_RMLS 0x1C000000 /* impl dependent rmo limit sel */
240#define LPCR_ILE 0x02000000 /* !HV irqs set MSR:LE */
241#define LPCR_PECE 0x00007000 /* powersave exit cause enable */
242#define LPCR_PECE0 0x00004000 /* ext. exceptions can cause exit */
243#define LPCR_PECE1 0x00002000 /* decrementer can cause exit */
244#define LPCR_PECE2 0x00001000 /* machine check etc can cause exit */
245#define LPCR_MER 0x00000800 /* Mediated External Exception */
246#define LPCR_LPES0 0x00000008 /* LPAR Env selector 0 */
247#define LPCR_LPES1 0x00000004 /* LPAR Env selector 1 */
248#define LPCR_RMI 0x00000002 /* real mode is cache inhibit */
249#define LPCR_HDICE 0x00000001 /* Hyp Decr enable (HV,PR,EE) */
250#define SPRN_LPID 0x13F /* Logical Partition Identifier */
251#define SPRN_HMER 0x150 /* Hardware m? error recovery */
252#define SPRN_HMEER 0x151 /* Hardware m? enable error recovery */
253#define SPRN_HEIR 0x153 /* Hypervisor Emulated Instruction Register */
254#define SPRN_TLBINDEXR 0x154 /* P7 TLB control register */
255#define SPRN_TLBVPNR 0x155 /* P7 TLB control register */
256#define SPRN_TLBRPNR 0x156 /* P7 TLB control register */
257#define SPRN_TLBLPIDR 0x157 /* P7 TLB control register */
205#define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */ 258#define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */
206#define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */ 259#define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */
207#define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */ 260#define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */
@@ -283,6 +336,7 @@
283#define HID0_NOPTI (1<<0) /* No-op dcbt and dcbst instr. */ 336#define HID0_NOPTI (1<<0) /* No-op dcbt and dcbst instr. */
284 337
285#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ 338#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */
339#ifdef CONFIG_6xx
286#define HID1_EMCP (1<<31) /* 7450 Machine Check Pin Enable */ 340#define HID1_EMCP (1<<31) /* 7450 Machine Check Pin Enable */
287#define HID1_DFS (1<<22) /* 7447A Dynamic Frequency Scaling */ 341#define HID1_DFS (1<<22) /* 7447A Dynamic Frequency Scaling */
288#define HID1_PC0 (1<<16) /* 7450 PLL_CFG[0] */ 342#define HID1_PC0 (1<<16) /* 7450 PLL_CFG[0] */
@@ -292,6 +346,7 @@
292#define HID1_SYNCBE (1<<11) /* 7450 ABE for sync, eieio */ 346#define HID1_SYNCBE (1<<11) /* 7450 ABE for sync, eieio */
293#define HID1_ABE (1<<10) /* 7450 Address Broadcast Enable */ 347#define HID1_ABE (1<<10) /* 7450 Address Broadcast Enable */
294#define HID1_PS (1<<16) /* 750FX PLL selection */ 348#define HID1_PS (1<<16) /* 750FX PLL selection */
349#endif
295#define SPRN_HID2 0x3F8 /* Hardware Implementation Register 2 */ 350#define SPRN_HID2 0x3F8 /* Hardware Implementation Register 2 */
296#define SPRN_HID2_GEKKO 0x398 /* Gekko HID2 Register */ 351#define SPRN_HID2_GEKKO 0x398 /* Gekko HID2 Register */
297#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ 352#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */
@@ -422,16 +477,23 @@
422#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ 477#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */
423#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ 478#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */
424#define SRR1_WAKEMASK 0x00380000 /* reason for wakeup */ 479#define SRR1_WAKEMASK 0x00380000 /* reason for wakeup */
425#define SRR1_WAKERESET 0x00380000 /* System reset */
426#define SRR1_WAKESYSERR 0x00300000 /* System error */ 480#define SRR1_WAKESYSERR 0x00300000 /* System error */
427#define SRR1_WAKEEE 0x00200000 /* External interrupt */ 481#define SRR1_WAKEEE 0x00200000 /* External interrupt */
428#define SRR1_WAKEMT 0x00280000 /* mtctrl */ 482#define SRR1_WAKEMT 0x00280000 /* mtctrl */
483#define SRR1_WAKEHMI 0x00280000 /* Hypervisor maintenance */
429#define SRR1_WAKEDEC 0x00180000 /* Decrementer interrupt */ 484#define SRR1_WAKEDEC 0x00180000 /* Decrementer interrupt */
430#define SRR1_WAKETHERM 0x00100000 /* Thermal management interrupt */ 485#define SRR1_WAKETHERM 0x00100000 /* Thermal management interrupt */
486#define SRR1_WAKERESET 0x00100000 /* System reset */
487#define SRR1_WAKESTATE 0x00030000 /* Powersave exit mask [46:47] */
488#define SRR1_WS_DEEPEST 0x00030000 /* Some resources not maintained,
489 * may not be recoverable */
490#define SRR1_WS_DEEPER 0x00020000 /* Some resources not maintained */
491#define SRR1_WS_DEEP 0x00010000 /* All resources maintained */
431#define SRR1_PROGFPE 0x00100000 /* Floating Point Enabled */ 492#define SRR1_PROGFPE 0x00100000 /* Floating Point Enabled */
432#define SRR1_PROGPRIV 0x00040000 /* Privileged instruction */ 493#define SRR1_PROGPRIV 0x00040000 /* Privileged instruction */
433#define SRR1_PROGTRAP 0x00020000 /* Trap */ 494#define SRR1_PROGTRAP 0x00020000 /* Trap */
434#define SRR1_PROGADDR 0x00010000 /* SRR0 contains subsequent addr */ 495#define SRR1_PROGADDR 0x00010000 /* SRR0 contains subsequent addr */
496
435#define SPRN_HSRR0 0x13A /* Save/Restore Register 0 */ 497#define SPRN_HSRR0 0x13A /* Save/Restore Register 0 */
436#define SPRN_HSRR1 0x13B /* Save/Restore Register 1 */ 498#define SPRN_HSRR1 0x13B /* Save/Restore Register 1 */
437 499
@@ -661,12 +723,15 @@
661 * SPRG usage: 723 * SPRG usage:
662 * 724 *
663 * All 64-bit: 725 * All 64-bit:
664 * - SPRG1 stores PACA pointer 726 * - SPRG1 stores PACA pointer except 64-bit server in
727 * HV mode in which case it is HSPRG0
665 * 728 *
666 * 64-bit server: 729 * 64-bit server:
667 * - SPRG0 unused (reserved for HV on Power4) 730 * - SPRG0 unused (reserved for HV on Power4)
668 * - SPRG2 scratch for exception vectors 731 * - SPRG2 scratch for exception vectors
669 * - SPRG3 unused (user visible) 732 * - SPRG3 unused (user visible)
733 * - HSPRG0 stores PACA in HV mode
734 * - HSPRG1 scratch for "HV" exceptions
670 * 735 *
671 * 64-bit embedded 736 * 64-bit embedded
672 * - SPRG0 generic exception scratch 737 * - SPRG0 generic exception scratch
@@ -729,6 +794,41 @@
729 794
730#ifdef CONFIG_PPC_BOOK3S_64 795#ifdef CONFIG_PPC_BOOK3S_64
731#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2 796#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2
797#define SPRN_SPRG_HPACA SPRN_HSPRG0
798#define SPRN_SPRG_HSCRATCH0 SPRN_HSPRG1
799
800#define GET_PACA(rX) \
801 BEGIN_FTR_SECTION_NESTED(66); \
802 mfspr rX,SPRN_SPRG_PACA; \
803 FTR_SECTION_ELSE_NESTED(66); \
804 mfspr rX,SPRN_SPRG_HPACA; \
805 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
806
807#define SET_PACA(rX) \
808 BEGIN_FTR_SECTION_NESTED(66); \
809 mtspr SPRN_SPRG_PACA,rX; \
810 FTR_SECTION_ELSE_NESTED(66); \
811 mtspr SPRN_SPRG_HPACA,rX; \
812 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
813
814#define GET_SCRATCH0(rX) \
815 BEGIN_FTR_SECTION_NESTED(66); \
816 mfspr rX,SPRN_SPRG_SCRATCH0; \
817 FTR_SECTION_ELSE_NESTED(66); \
818 mfspr rX,SPRN_SPRG_HSCRATCH0; \
819 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
820
821#define SET_SCRATCH0(rX) \
822 BEGIN_FTR_SECTION_NESTED(66); \
823 mtspr SPRN_SPRG_SCRATCH0,rX; \
824 FTR_SECTION_ELSE_NESTED(66); \
825 mtspr SPRN_SPRG_HSCRATCH0,rX; \
826 ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE_206, 66)
827
828#else /* CONFIG_PPC_BOOK3S_64 */
829#define GET_SCRATCH0(rX) mfspr rX,SPRN_SPRG_SCRATCH0
830#define SET_SCRATCH0(rX) mtspr SPRN_SPRG_SCRATCH0,rX
831
732#endif 832#endif
733 833
734#ifdef CONFIG_PPC_BOOK3E_64 834#ifdef CONFIG_PPC_BOOK3E_64
@@ -738,6 +838,10 @@
738#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2 838#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2
739#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6 839#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6
740#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0 840#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0
841
842#define SET_PACA(rX) mtspr SPRN_SPRG_PACA,rX
843#define GET_PACA(rX) mfspr rX,SPRN_SPRG_PACA
844
741#endif 845#endif
742 846
743#ifdef CONFIG_PPC_BOOK3S_32 847#ifdef CONFIG_PPC_BOOK3S_32
@@ -788,6 +892,8 @@
788#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1 892#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1
789#endif 893#endif
790 894
895
896
791/* 897/*
792 * An mtfsf instruction with the L bit set. On CPUs that support this a 898 * An mtfsf instruction with the L bit set. On CPUs that support this a
793 * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored. 899 * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored.
@@ -850,6 +956,8 @@
850#define PVR_7450 0x80000000 956#define PVR_7450 0x80000000
851#define PVR_8540 0x80200000 957#define PVR_8540 0x80200000
852#define PVR_8560 0x80200000 958#define PVR_8560 0x80200000
959#define PVR_VER_E500V1 0x8020
960#define PVR_VER_E500V2 0x8021
853/* 961/*
854 * For the 8xx processors, all of them report the same PVR family for 962 * For the 8xx processors, all of them report the same PVR family for
855 * the PowerPC core. The various versions of these processors must be 963 * the PowerPC core. The various versions of these processors must be
@@ -878,7 +986,10 @@
878#define PV_970 0x0039 986#define PV_970 0x0039
879#define PV_POWER5 0x003A 987#define PV_POWER5 0x003A
880#define PV_POWER5p 0x003B 988#define PV_POWER5p 0x003B
989#define PV_POWER7 0x003F
881#define PV_970FX 0x003C 990#define PV_970FX 0x003C
991#define PV_POWER6 0x003E
992#define PV_POWER7 0x003F
882#define PV_630 0x0040 993#define PV_630 0x0040
883#define PV_630p 0x0041 994#define PV_630p 0x0041
884#define PV_970MP 0x0044 995#define PV_970MP 0x0044
diff --git a/arch/powerpc/include/asm/reg_a2.h b/arch/powerpc/include/asm/reg_a2.h
new file mode 100644
index 000000000000..3d52a1132f3d
--- /dev/null
+++ b/arch/powerpc/include/asm/reg_a2.h
@@ -0,0 +1,165 @@
1/*
2 * Register definitions specific to the A2 core
3 *
4 * Copyright (C) 2008 Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#ifndef __ASM_POWERPC_REG_A2_H__
13#define __ASM_POWERPC_REG_A2_H__
14
15#define SPRN_TENSR 0x1b5
16#define SPRN_TENS 0x1b6 /* Thread ENable Set */
17#define SPRN_TENC 0x1b7 /* Thread ENable Clear */
18
19#define SPRN_A2_CCR0 0x3f0 /* Core Configuration Register 0 */
20#define SPRN_A2_CCR1 0x3f1 /* Core Configuration Register 1 */
21#define SPRN_A2_CCR2 0x3f2 /* Core Configuration Register 2 */
22#define SPRN_MMUCR0 0x3fc /* MMU Control Register 0 */
23#define SPRN_MMUCR1 0x3fd /* MMU Control Register 1 */
24#define SPRN_MMUCR2 0x3fe /* MMU Control Register 2 */
25#define SPRN_MMUCR3 0x3ff /* MMU Control Register 3 */
26
27#define SPRN_IAR 0x372
28
29#define SPRN_IUCR0 0x3f3
30#define IUCR0_ICBI_ACK 0x1000
31
32#define SPRN_XUCR0 0x3f6 /* Execution Unit Config Register 0 */
33
34#define A2_IERAT_SIZE 16
35#define A2_DERAT_SIZE 32
36
37/* A2 MMUCR0 bits */
38#define MMUCR0_ECL 0x80000000 /* Extended Class for TLB fills */
39#define MMUCR0_TID_NZ 0x40000000 /* TID is non-zero */
40#define MMUCR0_TS 0x10000000 /* Translation space for TLB fills */
41#define MMUCR0_TGS 0x20000000 /* Guest space for TLB fills */
42#define MMUCR0_TLBSEL 0x0c000000 /* TLB or ERAT target for TLB fills */
43#define MMUCR0_TLBSEL_U 0x00000000 /* TLBSEL = UTLB */
44#define MMUCR0_TLBSEL_I 0x08000000 /* TLBSEL = I-ERAT */
45#define MMUCR0_TLBSEL_D 0x0c000000 /* TLBSEL = D-ERAT */
46#define MMUCR0_LOCKSRSH 0x02000000 /* Use TLB lock on tlbsx. */
47#define MMUCR0_TID_MASK 0x000000ff /* TID field */
48
49/* A2 MMUCR1 bits */
50#define MMUCR1_IRRE 0x80000000 /* I-ERAT round robin enable */
51#define MMUCR1_DRRE 0x40000000 /* D-ERAT round robin enable */
52#define MMUCR1_REE 0x20000000 /* Reference Exception Enable*/
53#define MMUCR1_CEE 0x10000000 /* Change exception enable */
54#define MMUCR1_CSINV_ALL 0x00000000 /* Inval ERAT on all CS evts */
55#define MMUCR1_CSINV_NISYNC 0x04000000 /* Inval ERAT on all ex isync*/
56#define MMUCR1_CSINV_NEVER 0x0c000000 /* Don't inval ERAT on CS */
57#define MMUCR1_ICTID 0x00080000 /* IERAT class field as TID */
58#define MMUCR1_ITTID 0x00040000 /* IERAT thdid field as TID */
59#define MMUCR1_DCTID 0x00020000 /* DERAT class field as TID */
60#define MMUCR1_DTTID 0x00010000 /* DERAT thdid field as TID */
61#define MMUCR1_DCCD 0x00008000 /* DERAT class ignore */
62#define MMUCR1_TLBWE_BINV 0x00004000 /* back invalidate on tlbwe */
63
64/* A2 MMUCR2 bits */
65#define MMUCR2_PSSEL_SHIFT 4
66
67/* A2 MMUCR3 bits */
68#define MMUCR3_THID 0x0000000f /* Thread ID */
69
70/* *** ERAT TLB bits definitions */
71#define TLB0_EPN_MASK ASM_CONST(0xfffffffffffff000)
72#define TLB0_CLASS_MASK ASM_CONST(0x0000000000000c00)
73#define TLB0_CLASS_00 ASM_CONST(0x0000000000000000)
74#define TLB0_CLASS_01 ASM_CONST(0x0000000000000400)
75#define TLB0_CLASS_10 ASM_CONST(0x0000000000000800)
76#define TLB0_CLASS_11 ASM_CONST(0x0000000000000c00)
77#define TLB0_V ASM_CONST(0x0000000000000200)
78#define TLB0_X ASM_CONST(0x0000000000000100)
79#define TLB0_SIZE_MASK ASM_CONST(0x00000000000000f0)
80#define TLB0_SIZE_4K ASM_CONST(0x0000000000000010)
81#define TLB0_SIZE_64K ASM_CONST(0x0000000000000030)
82#define TLB0_SIZE_1M ASM_CONST(0x0000000000000050)
83#define TLB0_SIZE_16M ASM_CONST(0x0000000000000070)
84#define TLB0_SIZE_1G ASM_CONST(0x00000000000000a0)
85#define TLB0_THDID_MASK ASM_CONST(0x000000000000000f)
86#define TLB0_THDID_0 ASM_CONST(0x0000000000000001)
87#define TLB0_THDID_1 ASM_CONST(0x0000000000000002)
88#define TLB0_THDID_2 ASM_CONST(0x0000000000000004)
89#define TLB0_THDID_3 ASM_CONST(0x0000000000000008)
90#define TLB0_THDID_ALL ASM_CONST(0x000000000000000f)
91
92#define TLB1_RESVATTR ASM_CONST(0x00f0000000000000)
93#define TLB1_U0 ASM_CONST(0x0008000000000000)
94#define TLB1_U1 ASM_CONST(0x0004000000000000)
95#define TLB1_U2 ASM_CONST(0x0002000000000000)
96#define TLB1_U3 ASM_CONST(0x0001000000000000)
97#define TLB1_R ASM_CONST(0x0000800000000000)
98#define TLB1_C ASM_CONST(0x0000400000000000)
99#define TLB1_RPN_MASK ASM_CONST(0x000003fffffff000)
100#define TLB1_W ASM_CONST(0x0000000000000800)
101#define TLB1_I ASM_CONST(0x0000000000000400)
102#define TLB1_M ASM_CONST(0x0000000000000200)
103#define TLB1_G ASM_CONST(0x0000000000000100)
104#define TLB1_E ASM_CONST(0x0000000000000080)
105#define TLB1_VF ASM_CONST(0x0000000000000040)
106#define TLB1_UX ASM_CONST(0x0000000000000020)
107#define TLB1_SX ASM_CONST(0x0000000000000010)
108#define TLB1_UW ASM_CONST(0x0000000000000008)
109#define TLB1_SW ASM_CONST(0x0000000000000004)
110#define TLB1_UR ASM_CONST(0x0000000000000002)
111#define TLB1_SR ASM_CONST(0x0000000000000001)
112
113#ifdef CONFIG_PPC_EARLY_DEBUG_WSP
114#define WSP_UART_PHYS 0xffc000c000
115/* This needs to be careful chosen to hit a !0 congruence class
116 * in the TLB since we bolt it in way 3, which is already occupied
117 * by our linear mapping primary bolted entry in CC 0.
118 */
119#define WSP_UART_VIRT 0xf000000000001000
120#endif
121
122/* A2 erativax attributes definitions */
123#define ERATIVAX_RS_IS_ALL 0x000
124#define ERATIVAX_RS_IS_TID 0x040
125#define ERATIVAX_RS_IS_CLASS 0x080
126#define ERATIVAX_RS_IS_FULLMATCH 0x0c0
127#define ERATIVAX_CLASS_00 0x000
128#define ERATIVAX_CLASS_01 0x010
129#define ERATIVAX_CLASS_10 0x020
130#define ERATIVAX_CLASS_11 0x030
131#define ERATIVAX_PSIZE_4K (TLB_PSIZE_4K >> 1)
132#define ERATIVAX_PSIZE_64K (TLB_PSIZE_64K >> 1)
133#define ERATIVAX_PSIZE_1M (TLB_PSIZE_1M >> 1)
134#define ERATIVAX_PSIZE_16M (TLB_PSIZE_16M >> 1)
135#define ERATIVAX_PSIZE_1G (TLB_PSIZE_1G >> 1)
136
137/* A2 eratilx attributes definitions */
138#define ERATILX_T_ALL 0
139#define ERATILX_T_TID 1
140#define ERATILX_T_TGS 2
141#define ERATILX_T_FULLMATCH 3
142#define ERATILX_T_CLASS0 4
143#define ERATILX_T_CLASS1 5
144#define ERATILX_T_CLASS2 6
145#define ERATILX_T_CLASS3 7
146
147/* XUCR0 bits */
148#define XUCR0_TRACE_UM_T0 0x40000000 /* Thread 0 */
149#define XUCR0_TRACE_UM_T1 0x20000000 /* Thread 1 */
150#define XUCR0_TRACE_UM_T2 0x10000000 /* Thread 2 */
151#define XUCR0_TRACE_UM_T3 0x08000000 /* Thread 3 */
152
153/* A2 CCR0 register */
154#define A2_CCR0_PME_DISABLED 0x00000000
155#define A2_CCR0_PME_SLEEP 0x40000000
156#define A2_CCR0_PME_RVW 0x80000000
157#define A2_CCR0_PME_DISABLED2 0xc0000000
158
159/* A2 CCR2 register */
160#define A2_CCR2_ERAT_ONLY_MODE 0x00000001
161#define A2_CCR2_ENABLE_ICSWX 0x00000002
162#define A2_CCR2_ENABLE_PC 0x20000000
163#define A2_CCR2_ENABLE_TRACE 0x40000000
164
165#endif /* __ASM_POWERPC_REG_A2_H__ */
diff --git a/arch/powerpc/include/asm/reg_booke.h b/arch/powerpc/include/asm/reg_booke.h
index 667a498eaee1..0f0ad9fa01c1 100644
--- a/arch/powerpc/include/asm/reg_booke.h
+++ b/arch/powerpc/include/asm/reg_booke.h
@@ -2,7 +2,7 @@
2 * Contains register definitions common to the Book E PowerPC 2 * Contains register definitions common to the Book E PowerPC
3 * specification. Notice that while the IBM-40x series of CPUs 3 * specification. Notice that while the IBM-40x series of CPUs
4 * are not true Book E PowerPCs, they borrowed a number of features 4 * are not true Book E PowerPCs, they borrowed a number of features
5 * before Book E was finalized, and are included here as well. Unfortunatly, 5 * before Book E was finalized, and are included here as well. Unfortunately,
6 * they sometimes used different locations than true Book E CPUs did. 6 * they sometimes used different locations than true Book E CPUs did.
7 * 7 *
8 * This program is free software; you can redistribute it and/or 8 * This program is free software; you can redistribute it and/or
@@ -27,10 +27,12 @@
27#define MSR_CM (1<<31) /* Computation Mode (0=32-bit, 1=64-bit) */ 27#define MSR_CM (1<<31) /* Computation Mode (0=32-bit, 1=64-bit) */
28 28
29#if defined(CONFIG_PPC_BOOK3E_64) 29#if defined(CONFIG_PPC_BOOK3E_64)
30#define MSR_64BIT MSR_CM
31
30#define MSR_ MSR_ME | MSR_CE 32#define MSR_ MSR_ME | MSR_CE
31#define MSR_KERNEL MSR_ | MSR_CM 33#define MSR_KERNEL MSR_ | MSR_64BIT
32#define MSR_USER32 MSR_ | MSR_PR | MSR_EE | MSR_DE 34#define MSR_USER32 MSR_ | MSR_PR | MSR_EE | MSR_DE
33#define MSR_USER64 MSR_USER32 | MSR_CM | MSR_DE 35#define MSR_USER64 MSR_USER32 | MSR_64BIT
34#elif defined (CONFIG_40x) 36#elif defined (CONFIG_40x)
35#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE) 37#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR|MSR_CE)
36#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) 38#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
@@ -81,6 +83,10 @@
81#define SPRN_IVOR13 0x19D /* Interrupt Vector Offset Register 13 */ 83#define SPRN_IVOR13 0x19D /* Interrupt Vector Offset Register 13 */
82#define SPRN_IVOR14 0x19E /* Interrupt Vector Offset Register 14 */ 84#define SPRN_IVOR14 0x19E /* Interrupt Vector Offset Register 14 */
83#define SPRN_IVOR15 0x19F /* Interrupt Vector Offset Register 15 */ 85#define SPRN_IVOR15 0x19F /* Interrupt Vector Offset Register 15 */
86#define SPRN_IVOR38 0x1B0 /* Interrupt Vector Offset Register 38 */
87#define SPRN_IVOR39 0x1B1 /* Interrupt Vector Offset Register 39 */
88#define SPRN_IVOR40 0x1B2 /* Interrupt Vector Offset Register 40 */
89#define SPRN_IVOR41 0x1B3 /* Interrupt Vector Offset Register 41 */
84#define SPRN_SPEFSCR 0x200 /* SPE & Embedded FP Status & Control */ 90#define SPRN_SPEFSCR 0x200 /* SPE & Embedded FP Status & Control */
85#define SPRN_BBEAR 0x201 /* Branch Buffer Entry Address Register */ 91#define SPRN_BBEAR 0x201 /* Branch Buffer Entry Address Register */
86#define SPRN_BBTAR 0x202 /* Branch Buffer Target Address Register */ 92#define SPRN_BBTAR 0x202 /* Branch Buffer Target Address Register */
@@ -110,7 +116,7 @@
110#define SPRN_MAS2 0x272 /* MMU Assist Register 2 */ 116#define SPRN_MAS2 0x272 /* MMU Assist Register 2 */
111#define SPRN_MAS3 0x273 /* MMU Assist Register 3 */ 117#define SPRN_MAS3 0x273 /* MMU Assist Register 3 */
112#define SPRN_MAS4 0x274 /* MMU Assist Register 4 */ 118#define SPRN_MAS4 0x274 /* MMU Assist Register 4 */
113#define SPRN_MAS5 0x275 /* MMU Assist Register 5 */ 119#define SPRN_MAS5 0x153 /* MMU Assist Register 5 */
114#define SPRN_MAS6 0x276 /* MMU Assist Register 6 */ 120#define SPRN_MAS6 0x276 /* MMU Assist Register 6 */
115#define SPRN_PID1 0x279 /* Process ID Register 1 */ 121#define SPRN_PID1 0x279 /* Process ID Register 1 */
116#define SPRN_PID2 0x27A /* Process ID Register 2 */ 122#define SPRN_PID2 0x27A /* Process ID Register 2 */
@@ -150,8 +156,6 @@
150 * or IBM 40x. 156 * or IBM 40x.
151 */ 157 */
152#ifdef CONFIG_BOOKE 158#ifdef CONFIG_BOOKE
153#define SPRN_PID 0x030 /* Process ID */
154#define SPRN_PID0 SPRN_PID/* Process ID Register 0 */
155#define SPRN_CSRR0 0x03A /* Critical Save and Restore Register 0 */ 159#define SPRN_CSRR0 0x03A /* Critical Save and Restore Register 0 */
156#define SPRN_CSRR1 0x03B /* Critical Save and Restore Register 1 */ 160#define SPRN_CSRR1 0x03B /* Critical Save and Restore Register 1 */
157#define SPRN_DEAR 0x03D /* Data Error Address Register */ 161#define SPRN_DEAR 0x03D /* Data Error Address Register */
@@ -168,7 +172,6 @@
168#define SPRN_TCR 0x154 /* Timer Control Register */ 172#define SPRN_TCR 0x154 /* Timer Control Register */
169#endif /* Book E */ 173#endif /* Book E */
170#ifdef CONFIG_40x 174#ifdef CONFIG_40x
171#define SPRN_PID 0x3B1 /* Process ID */
172#define SPRN_DBCR1 0x3BD /* Debug Control Register 1 */ 175#define SPRN_DBCR1 0x3BD /* Debug Control Register 1 */
173#define SPRN_ESR 0x3D4 /* Exception Syndrome Register */ 176#define SPRN_ESR 0x3D4 /* Exception Syndrome Register */
174#define SPRN_DEAR 0x3D5 /* Data Error Address Register */ 177#define SPRN_DEAR 0x3D5 /* Data Error Address Register */
@@ -246,6 +249,20 @@
246 store or cache line push */ 249 store or cache line push */
247#endif 250#endif
248 251
252/* Bit definitions for the HID1 */
253#ifdef CONFIG_E500
254/* e500v1/v2 */
255#define HID1_PLL_CFG_MASK 0xfc000000 /* PLL_CFG input pins */
256#define HID1_RFXE 0x00020000 /* Read fault exception enable */
257#define HID1_R1DPE 0x00008000 /* R1 data bus parity enable */
258#define HID1_R2DPE 0x00004000 /* R2 data bus parity enable */
259#define HID1_ASTME 0x00002000 /* Address bus streaming mode enable */
260#define HID1_ABE 0x00001000 /* Address broadcast enable */
261#define HID1_MPXTT 0x00000400 /* MPX re-map transfer type */
262#define HID1_ATS 0x00000080 /* Atomic status */
263#define HID1_MID_MASK 0x0000000f /* MID input pins */
264#endif
265
249/* Bit definitions for the DBSR. */ 266/* Bit definitions for the DBSR. */
250/* 267/*
251 * DBSR bits which have conflicting definitions on true Book E versus IBM 40x. 268 * DBSR bits which have conflicting definitions on true Book E versus IBM 40x.
diff --git a/arch/powerpc/include/asm/rio.h b/arch/powerpc/include/asm/rio.h
index 0018bf80cb25..b1d2deceeedb 100644
--- a/arch/powerpc/include/asm/rio.h
+++ b/arch/powerpc/include/asm/rio.h
@@ -14,5 +14,10 @@
14#define ASM_PPC_RIO_H 14#define ASM_PPC_RIO_H
15 15
16extern void platform_rio_init(void); 16extern void platform_rio_init(void);
17#ifdef CONFIG_FSL_RIO
18extern int fsl_rio_mcheck_exception(struct pt_regs *);
19#else
20static inline int fsl_rio_mcheck_exception(struct pt_regs *regs) {return 0; }
21#endif
17 22
18#endif /* ASM_PPC_RIO_H */ 23#endif /* ASM_PPC_RIO_H */
diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 3d35f8ae377e..58625d1e7802 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -158,7 +158,50 @@ struct rtas_error_log {
158 unsigned long target:4; /* Target of failed operation */ 158 unsigned long target:4; /* Target of failed operation */
159 unsigned long type:8; /* General event or error*/ 159 unsigned long type:8; /* General event or error*/
160 unsigned long extended_log_length:32; /* length in bytes */ 160 unsigned long extended_log_length:32; /* length in bytes */
161 unsigned char buffer[1]; 161 unsigned char buffer[1]; /* Start of extended log */
162 /* Variable length. */
163};
164
165#define RTAS_V6EXT_LOG_FORMAT_EVENT_LOG 14
166
167#define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8))
168
169/* RTAS general extended event log, Version 6. The extended log starts
170 * from "buffer" field of struct rtas_error_log defined above.
171 */
172struct rtas_ext_event_log_v6 {
173 /* Byte 0 */
174 uint32_t log_valid:1; /* 1:Log valid */
175 uint32_t unrecoverable_error:1; /* 1:Unrecoverable error */
176 uint32_t recoverable_error:1; /* 1:recoverable (correctable */
177 /* or successfully retried) */
178 uint32_t degraded_operation:1; /* 1:Unrecoverable err, bypassed*/
179 /* - degraded operation (e.g. */
180 /* CPU or mem taken off-line) */
181 uint32_t predictive_error:1;
182 uint32_t new_log:1; /* 1:"New" log (Always 1 for */
183 /* data returned from RTAS */
184 uint32_t big_endian:1; /* 1: Big endian */
185 uint32_t :1; /* reserved */
186 /* Byte 1 */
187 uint32_t :8; /* reserved */
188 /* Byte 2 */
189 uint32_t powerpc_format:1; /* Set to 1 (indicating log is */
190 /* in PowerPC format */
191 uint32_t :3; /* reserved */
192 uint32_t log_format:4; /* Log format indicator. Define */
193 /* format used for byte 12-2047 */
194 /* Byte 3 */
195 uint32_t :8; /* reserved */
196 /* Byte 4-11 */
197 uint8_t reserved[8]; /* reserved */
198 /* Byte 12-15 */
199 uint32_t company_id; /* Company ID of the company */
200 /* that defines the format for */
201 /* the vendor specific log type */
202 /* Byte 16-end of log */
203 uint8_t vendor_log[1]; /* Start of vendor specific log */
204 /* Variable length. */
162}; 205};
163 206
164/* 207/*
@@ -187,6 +230,7 @@ extern void rtas_progress(char *s, unsigned short hex);
187extern void rtas_initialize(void); 230extern void rtas_initialize(void);
188extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data); 231extern int rtas_suspend_cpu(struct rtas_suspend_me_data *data);
189extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data); 232extern int rtas_suspend_last_cpu(struct rtas_suspend_me_data *data);
233extern int rtas_ibm_suspend_me(struct rtas_args *);
190 234
191struct rtc_time; 235struct rtc_time;
192extern unsigned long rtas_get_boot_time(void); 236extern unsigned long rtas_get_boot_time(void);
diff --git a/arch/powerpc/include/asm/rwsem.h b/arch/powerpc/include/asm/rwsem.h
index 8447d89fbe72..bb1e2cdeb9bf 100644
--- a/arch/powerpc/include/asm/rwsem.h
+++ b/arch/powerpc/include/asm/rwsem.h
@@ -13,11 +13,6 @@
13 * by Paul Mackerras <paulus@samba.org>. 13 * by Paul Mackerras <paulus@samba.org>.
14 */ 14 */
15 15
16#include <linux/list.h>
17#include <linux/spinlock.h>
18#include <asm/atomic.h>
19#include <asm/system.h>
20
21/* 16/*
22 * the semaphore definition 17 * the semaphore definition
23 */ 18 */
@@ -33,47 +28,6 @@
33#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS 28#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
34#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS) 29#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
35 30
36struct rw_semaphore {
37 long count;
38 spinlock_t wait_lock;
39 struct list_head wait_list;
40#ifdef CONFIG_DEBUG_LOCK_ALLOC
41 struct lockdep_map dep_map;
42#endif
43};
44
45#ifdef CONFIG_DEBUG_LOCK_ALLOC
46# define __RWSEM_DEP_MAP_INIT(lockname) , .dep_map = { .name = #lockname }
47#else
48# define __RWSEM_DEP_MAP_INIT(lockname)
49#endif
50
51#define __RWSEM_INITIALIZER(name) \
52{ \
53 RWSEM_UNLOCKED_VALUE, \
54 __SPIN_LOCK_UNLOCKED((name).wait_lock), \
55 LIST_HEAD_INIT((name).wait_list) \
56 __RWSEM_DEP_MAP_INIT(name) \
57}
58
59#define DECLARE_RWSEM(name) \
60 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
61
62extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
63extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
64extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
65extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
66
67extern void __init_rwsem(struct rw_semaphore *sem, const char *name,
68 struct lock_class_key *key);
69
70#define init_rwsem(sem) \
71 do { \
72 static struct lock_class_key __key; \
73 \
74 __init_rwsem((sem), #sem, &__key); \
75 } while (0)
76
77/* 31/*
78 * lock for reading 32 * lock for reading
79 */ 33 */
@@ -174,10 +128,5 @@ static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
174 return atomic_long_add_return(delta, (atomic_long_t *)&sem->count); 128 return atomic_long_add_return(delta, (atomic_long_t *)&sem->count);
175} 129}
176 130
177static inline int rwsem_is_locked(struct rw_semaphore *sem)
178{
179 return sem->count != 0;
180}
181
182#endif /* __KERNEL__ */ 131#endif /* __KERNEL__ */
183#endif /* _ASM_POWERPC_RWSEM_H */ 132#endif /* _ASM_POWERPC_RWSEM_H */
diff --git a/arch/powerpc/include/asm/scom.h b/arch/powerpc/include/asm/scom.h
new file mode 100644
index 000000000000..0cabfd7bc2d1
--- /dev/null
+++ b/arch/powerpc/include/asm/scom.h
@@ -0,0 +1,156 @@
1/*
2 * Copyright 2010 Benjamin Herrenschmidt, IBM Corp
3 * <benh@kernel.crashing.org>
4 * and David Gibson, IBM Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
14 * the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef _ASM_POWERPC_SCOM_H
22#define _ASM_POWERPC_SCOM_H
23
24#ifdef __KERNEL__
25#ifndef __ASSEMBLY__
26#ifdef CONFIG_PPC_SCOM
27
28/*
29 * The SCOM bus is a sideband bus used for accessing various internal
30 * registers of the processor or the chipset. The implementation details
31 * differ between processors and platforms, and the access method as
32 * well.
33 *
34 * This API allows to "map" ranges of SCOM register numbers associated
35 * with a given SCOM controller. The later must be represented by a
36 * device node, though some implementations might support NULL if there
37 * is no possible ambiguity
38 *
39 * Then, scom_read/scom_write can be used to accesses registers inside
40 * that range. The argument passed is a register number relative to
41 * the beginning of the range mapped.
42 */
43
44typedef void *scom_map_t;
45
46/* Value for an invalid SCOM map */
47#define SCOM_MAP_INVALID (NULL)
48
49/* The scom_controller data structure is what the platform passes
50 * to the core code in scom_init, it provides the actual implementation
51 * of all the SCOM functions
52 */
53struct scom_controller {
54 scom_map_t (*map)(struct device_node *ctrl_dev, u64 reg, u64 count);
55 void (*unmap)(scom_map_t map);
56
57 u64 (*read)(scom_map_t map, u32 reg);
58 void (*write)(scom_map_t map, u32 reg, u64 value);
59};
60
61extern const struct scom_controller *scom_controller;
62
63/**
64 * scom_init - Initialize the SCOM backend, called by the platform
65 * @controller: The platform SCOM controller
66 */
67static inline void scom_init(const struct scom_controller *controller)
68{
69 scom_controller = controller;
70}
71
72/**
73 * scom_map_ok - Test is a SCOM mapping is successful
74 * @map: The result of scom_map to test
75 */
76static inline int scom_map_ok(scom_map_t map)
77{
78 return map != SCOM_MAP_INVALID;
79}
80
81/**
82 * scom_map - Map a block of SCOM registers
83 * @ctrl_dev: Device node of the SCOM controller
84 * some implementations allow NULL here
85 * @reg: first SCOM register to map
86 * @count: Number of SCOM registers to map
87 */
88
89static inline scom_map_t scom_map(struct device_node *ctrl_dev,
90 u64 reg, u64 count)
91{
92 return scom_controller->map(ctrl_dev, reg, count);
93}
94
95/**
96 * scom_find_parent - Find the SCOM controller for a device
97 * @dev: OF node of the device
98 *
99 * This is not meant for general usage, but in combination with
100 * scom_map() allows to map registers not represented by the
101 * device own scom-reg property. Useful for applying HW workarounds
102 * on things not properly represented in the device-tree for example.
103 */
104struct device_node *scom_find_parent(struct device_node *dev);
105
106
107/**
108 * scom_map_device - Map a device's block of SCOM registers
109 * @dev: OF node of the device
110 * @index: Register bank index (index in "scom-reg" property)
111 *
112 * This function will use the device-tree binding for SCOM which
113 * is to follow "scom-parent" properties until it finds a node with
114 * a "scom-controller" property to find the controller. It will then
115 * use the "scom-reg" property which is made of reg/count pairs,
116 * each of them having a size defined by the controller's #scom-cells
117 * property
118 */
119extern scom_map_t scom_map_device(struct device_node *dev, int index);
120
121
122/**
123 * scom_unmap - Unmap a block of SCOM registers
124 * @map: Result of scom_map is to be unmapped
125 */
126static inline void scom_unmap(scom_map_t map)
127{
128 if (scom_map_ok(map))
129 scom_controller->unmap(map);
130}
131
132/**
133 * scom_read - Read a SCOM register
134 * @map: Result of scom_map
135 * @reg: Register index within that map
136 */
137static inline u64 scom_read(scom_map_t map, u32 reg)
138{
139 return scom_controller->read(map, reg);
140}
141
142/**
143 * scom_write - Write to a SCOM register
144 * @map: Result of scom_map
145 * @reg: Register index within that map
146 * @value: Value to write
147 */
148static inline void scom_write(scom_map_t map, u32 reg, u64 value)
149{
150 scom_controller->write(map, reg, value);
151}
152
153#endif /* CONFIG_PPC_SCOM */
154#endif /* __ASSEMBLY__ */
155#endif /* __KERNEL__ */
156#endif /* _ASM_POWERPC_SCOM_H */
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
index 66e237bbe15f..11eb404b5606 100644
--- a/arch/powerpc/include/asm/smp.h
+++ b/arch/powerpc/include/asm/smp.h
@@ -20,6 +20,7 @@
20#include <linux/threads.h> 20#include <linux/threads.h>
21#include <linux/cpumask.h> 21#include <linux/cpumask.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/irqreturn.h>
23 24
24#ifndef __ASSEMBLY__ 25#ifndef __ASSEMBLY__
25 26
@@ -29,22 +30,41 @@
29#include <asm/percpu.h> 30#include <asm/percpu.h>
30 31
31extern int boot_cpuid; 32extern int boot_cpuid;
33extern int boot_cpu_count;
32 34
33extern void cpu_die(void); 35extern void cpu_die(void);
34 36
35#ifdef CONFIG_SMP 37#ifdef CONFIG_SMP
36 38
37extern void smp_send_debugger_break(int cpu); 39struct smp_ops_t {
38extern void smp_message_recv(int); 40 void (*message_pass)(int cpu, int msg);
41#ifdef CONFIG_PPC_SMP_MUXED_IPI
42 void (*cause_ipi)(int cpu, unsigned long data);
43#endif
44 int (*probe)(void);
45 int (*kick_cpu)(int nr);
46 void (*setup_cpu)(int nr);
47 void (*bringup_done)(void);
48 void (*take_timebase)(void);
49 void (*give_timebase)(void);
50 int (*cpu_disable)(void);
51 void (*cpu_die)(unsigned int nr);
52 int (*cpu_bootable)(unsigned int nr);
53};
54
55extern void smp_send_debugger_break(void);
56extern void start_secondary_resume(void);
57extern void __devinit smp_generic_give_timebase(void);
58extern void __devinit smp_generic_take_timebase(void);
39 59
40DECLARE_PER_CPU(unsigned int, cpu_pvr); 60DECLARE_PER_CPU(unsigned int, cpu_pvr);
41 61
42#ifdef CONFIG_HOTPLUG_CPU 62#ifdef CONFIG_HOTPLUG_CPU
43extern void fixup_irqs(const struct cpumask *map); 63extern void migrate_irqs(void);
44int generic_cpu_disable(void); 64int generic_cpu_disable(void);
45int generic_cpu_enable(unsigned int cpu);
46void generic_cpu_die(unsigned int cpu); 65void generic_cpu_die(unsigned int cpu);
47void generic_mach_cpu_die(void); 66void generic_mach_cpu_die(void);
67void generic_set_cpu_dead(unsigned int cpu);
48#endif 68#endif
49 69
50#ifdef CONFIG_PPC64 70#ifdef CONFIG_PPC64
@@ -92,13 +112,16 @@ extern int cpu_to_core_id(int cpu);
92#define PPC_MSG_CALL_FUNC_SINGLE 2 112#define PPC_MSG_CALL_FUNC_SINGLE 2
93#define PPC_MSG_DEBUGGER_BREAK 3 113#define PPC_MSG_DEBUGGER_BREAK 3
94 114
95/* 115/* for irq controllers that have dedicated ipis per message (4) */
96 * irq controllers that have dedicated ipis per message and don't
97 * need additional code in the action handler may use this
98 */
99extern int smp_request_message_ipi(int virq, int message); 116extern int smp_request_message_ipi(int virq, int message);
100extern const char *smp_ipi_name[]; 117extern const char *smp_ipi_name[];
101 118
119/* for irq controllers with only a single ipi */
120extern void smp_muxed_ipi_set_data(int cpu, unsigned long data);
121extern void smp_muxed_ipi_message_pass(int cpu, int msg);
122extern void smp_muxed_ipi_resend(void);
123extern irqreturn_t smp_ipi_demux(void);
124
102void smp_init_iSeries(void); 125void smp_init_iSeries(void);
103void smp_init_pSeries(void); 126void smp_init_pSeries(void);
104void smp_init_cell(void); 127void smp_init_cell(void);
@@ -148,7 +171,7 @@ extern int smt_enabled_at_boot;
148 171
149extern int smp_mpic_probe(void); 172extern int smp_mpic_probe(void);
150extern void smp_mpic_setup_cpu(int cpu); 173extern void smp_mpic_setup_cpu(int cpu);
151extern void smp_generic_kick_cpu(int nr); 174extern int smp_generic_kick_cpu(int nr);
152 175
153extern void smp_generic_give_timebase(void); 176extern void smp_generic_give_timebase(void);
154extern void smp_generic_take_timebase(void); 177extern void smp_generic_take_timebase(void);
diff --git a/arch/powerpc/include/asm/spu.h b/arch/powerpc/include/asm/spu.h
index 0ab8d869e3d6..0c8b35d75232 100644
--- a/arch/powerpc/include/asm/spu.h
+++ b/arch/powerpc/include/asm/spu.h
@@ -203,14 +203,6 @@ void spu_irq_setaffinity(struct spu *spu, int cpu);
203void spu_setup_kernel_slbs(struct spu *spu, struct spu_lscsa *lscsa, 203void spu_setup_kernel_slbs(struct spu *spu, struct spu_lscsa *lscsa,
204 void *code, int code_size); 204 void *code, int code_size);
205 205
206#ifdef CONFIG_KEXEC
207void crash_register_spus(struct list_head *list);
208#else
209static inline void crash_register_spus(struct list_head *list)
210{
211}
212#endif
213
214extern void spu_invalidate_slbs(struct spu *spu); 206extern void spu_invalidate_slbs(struct spu *spu);
215extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm); 207extern void spu_associate_mm(struct spu *spu, struct mm_struct *mm);
216int spu_64k_pages_available(void); 208int spu_64k_pages_available(void);
diff --git a/arch/powerpc/include/asm/spu_priv1.h b/arch/powerpc/include/asm/spu_priv1.h
index 25020a34ce7f..d8f5c60f61c1 100644
--- a/arch/powerpc/include/asm/spu_priv1.h
+++ b/arch/powerpc/include/asm/spu_priv1.h
@@ -223,7 +223,7 @@ spu_disable_spu (struct spu_context *ctx)
223} 223}
224 224
225/* 225/*
226 * The declarations folowing are put here for convenience 226 * The declarations following are put here for convenience
227 * and only intended to be used by the platform setup code. 227 * and only intended to be used by the platform setup code.
228 */ 228 */
229 229
diff --git a/arch/powerpc/include/asm/suspend.h b/arch/powerpc/include/asm/suspend.h
deleted file mode 100644
index c6efc3466aa6..000000000000
--- a/arch/powerpc/include/asm/suspend.h
+++ /dev/null
@@ -1,6 +0,0 @@
1#ifndef __ASM_POWERPC_SUSPEND_H
2#define __ASM_POWERPC_SUSPEND_H
3
4static inline int arch_prepare_suspend(void) { return 0; }
5
6#endif /* __ASM_POWERPC_SUSPEND_H */
diff --git a/arch/powerpc/include/asm/syscall.h b/arch/powerpc/include/asm/syscall.h
index 23913e902fc3..b54b2add07be 100644
--- a/arch/powerpc/include/asm/syscall.h
+++ b/arch/powerpc/include/asm/syscall.h
@@ -15,6 +15,11 @@
15 15
16#include <linux/sched.h> 16#include <linux/sched.h>
17 17
18/* ftrace syscalls requires exporting the sys_call_table */
19#ifdef CONFIG_FTRACE_SYSCALLS
20extern const unsigned long *sys_call_table;
21#endif /* CONFIG_FTRACE_SYSCALLS */
22
18static inline long syscall_get_nr(struct task_struct *task, 23static inline long syscall_get_nr(struct task_struct *task,
19 struct pt_regs *regs) 24 struct pt_regs *regs)
20{ 25{
diff --git a/arch/powerpc/include/asm/systbl.h b/arch/powerpc/include/asm/systbl.h
index 3d212669a130..f6736b7da463 100644
--- a/arch/powerpc/include/asm/systbl.h
+++ b/arch/powerpc/include/asm/systbl.h
@@ -329,3 +329,28 @@ COMPAT_SYS(rt_tgsigqueueinfo)
329SYSCALL(fanotify_init) 329SYSCALL(fanotify_init)
330COMPAT_SYS(fanotify_mark) 330COMPAT_SYS(fanotify_mark)
331SYSCALL_SPU(prlimit64) 331SYSCALL_SPU(prlimit64)
332SYSCALL_SPU(socket)
333SYSCALL_SPU(bind)
334SYSCALL_SPU(connect)
335SYSCALL_SPU(listen)
336SYSCALL_SPU(accept)
337SYSCALL_SPU(getsockname)
338SYSCALL_SPU(getpeername)
339SYSCALL_SPU(socketpair)
340SYSCALL_SPU(send)
341SYSCALL_SPU(sendto)
342COMPAT_SYS_SPU(recv)
343COMPAT_SYS_SPU(recvfrom)
344SYSCALL_SPU(shutdown)
345COMPAT_SYS_SPU(setsockopt)
346COMPAT_SYS_SPU(getsockopt)
347COMPAT_SYS_SPU(sendmsg)
348COMPAT_SYS_SPU(recvmsg)
349COMPAT_SYS_SPU(recvmmsg)
350SYSCALL_SPU(accept4)
351SYSCALL_SPU(name_to_handle_at)
352COMPAT_SYS_SPU(open_by_handle_at)
353COMPAT_SYS_SPU(clock_adjtime)
354SYSCALL_SPU(syncfs)
355COMPAT_SYS_SPU(sendmmsg)
356SYSCALL_SPU(setns)
diff --git a/arch/powerpc/include/asm/system.h b/arch/powerpc/include/asm/system.h
index 6c294acac848..2dc595dda03b 100644
--- a/arch/powerpc/include/asm/system.h
+++ b/arch/powerpc/include/asm/system.h
@@ -154,8 +154,8 @@ extern void enable_kernel_spe(void);
154extern void giveup_spe(struct task_struct *); 154extern void giveup_spe(struct task_struct *);
155extern void load_up_spe(struct task_struct *); 155extern void load_up_spe(struct task_struct *);
156extern int fix_alignment(struct pt_regs *); 156extern int fix_alignment(struct pt_regs *);
157extern void cvt_fd(float *from, double *to, struct thread_struct *thread); 157extern void cvt_fd(float *from, double *to);
158extern void cvt_df(double *from, float *to, struct thread_struct *thread); 158extern void cvt_df(double *from, float *to);
159 159
160#ifndef CONFIG_SMP 160#ifndef CONFIG_SMP
161extern void discard_lazy_cpu_state(void); 161extern void discard_lazy_cpu_state(void);
@@ -219,8 +219,6 @@ extern int mem_init_done; /* set on boot once kmalloc can be called */
219extern int init_bootmem_done; /* set once bootmem is available */ 219extern int init_bootmem_done; /* set once bootmem is available */
220extern phys_addr_t memory_limit; 220extern phys_addr_t memory_limit;
221extern unsigned long klimit; 221extern unsigned long klimit;
222
223extern void *alloc_maybe_bootmem(size_t size, gfp_t mask);
224extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); 222extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask);
225 223
226extern int powersave_nap; /* set if nap mode can be used in idle loop */ 224extern int powersave_nap; /* set if nap mode can be used in idle loop */
@@ -542,10 +540,6 @@ extern void reloc_got2(unsigned long);
542 540
543#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x))) 541#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x)))
544 542
545#ifdef CONFIG_VIRT_CPU_ACCOUNTING
546extern void account_system_vtime(struct task_struct *);
547#endif
548
549extern struct dentry *powerpc_debugfs_root; 543extern struct dentry *powerpc_debugfs_root;
550 544
551#endif /* __KERNEL__ */ 545#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
index 65eb85976a03..836f231ec1f0 100644
--- a/arch/powerpc/include/asm/thread_info.h
+++ b/arch/powerpc/include/asm/thread_info.h
@@ -72,7 +72,7 @@ struct thread_info {
72 72
73#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR 73#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
74 74
75extern struct thread_info *alloc_thread_info(struct task_struct *tsk); 75extern struct thread_info *alloc_thread_info_node(struct task_struct *tsk, int node);
76extern void free_thread_info(struct thread_info *ti); 76extern void free_thread_info(struct thread_info *ti);
77 77
78#endif /* THREAD_SHIFT < PAGE_SHIFT */ 78#endif /* THREAD_SHIFT < PAGE_SHIFT */
@@ -110,7 +110,8 @@ static inline struct thread_info *current_thread_info(void)
110#define TIF_NOERROR 12 /* Force successful syscall return */ 110#define TIF_NOERROR 12 /* Force successful syscall return */
111#define TIF_NOTIFY_RESUME 13 /* callback before returning to user */ 111#define TIF_NOTIFY_RESUME 13 /* callback before returning to user */
112#define TIF_FREEZE 14 /* Freezing for suspend */ 112#define TIF_FREEZE 14 /* Freezing for suspend */
113#define TIF_RUNLATCH 15 /* Is the runlatch enabled? */ 113#define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
114#define TIF_RUNLATCH 16 /* Is the runlatch enabled? */
114 115
115/* as above, but as bit values */ 116/* as above, but as bit values */
116#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 117#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
@@ -127,8 +128,10 @@ static inline struct thread_info *current_thread_info(void)
127#define _TIF_NOERROR (1<<TIF_NOERROR) 128#define _TIF_NOERROR (1<<TIF_NOERROR)
128#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 129#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
129#define _TIF_FREEZE (1<<TIF_FREEZE) 130#define _TIF_FREEZE (1<<TIF_FREEZE)
131#define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
130#define _TIF_RUNLATCH (1<<TIF_RUNLATCH) 132#define _TIF_RUNLATCH (1<<TIF_RUNLATCH)
131#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP) 133#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
134 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
132 135
133#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 136#define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
134 _TIF_NOTIFY_RESUME) 137 _TIF_NOTIFY_RESUME)
@@ -139,10 +142,12 @@ static inline struct thread_info *current_thread_info(void)
139#define TLF_NAPPING 0 /* idle thread enabled NAP mode */ 142#define TLF_NAPPING 0 /* idle thread enabled NAP mode */
140#define TLF_SLEEPING 1 /* suspend code enabled SLEEP mode */ 143#define TLF_SLEEPING 1 /* suspend code enabled SLEEP mode */
141#define TLF_RESTORE_SIGMASK 2 /* Restore signal mask in do_signal */ 144#define TLF_RESTORE_SIGMASK 2 /* Restore signal mask in do_signal */
145#define TLF_LAZY_MMU 3 /* tlb_batch is active */
142 146
143#define _TLF_NAPPING (1 << TLF_NAPPING) 147#define _TLF_NAPPING (1 << TLF_NAPPING)
144#define _TLF_SLEEPING (1 << TLF_SLEEPING) 148#define _TLF_SLEEPING (1 << TLF_SLEEPING)
145#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK) 149#define _TLF_RESTORE_SIGMASK (1 << TLF_RESTORE_SIGMASK)
150#define _TLF_LAZY_MMU (1 << TLF_LAZY_MMU)
146 151
147#ifndef __ASSEMBLY__ 152#ifndef __ASSEMBLY__
148#define HAVE_SET_RESTORE_SIGMASK 1 153#define HAVE_SET_RESTORE_SIGMASK 1
diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
index dc779dfcf258..fe6f7c2c9c68 100644
--- a/arch/powerpc/include/asm/time.h
+++ b/arch/powerpc/include/asm/time.h
@@ -34,7 +34,6 @@ extern void to_tm(int tim, struct rtc_time * tm);
34extern void GregorianDay(struct rtc_time *tm); 34extern void GregorianDay(struct rtc_time *tm);
35 35
36extern void generic_calibrate_decr(void); 36extern void generic_calibrate_decr(void);
37extern void snapshot_timebase(void);
38 37
39extern void set_dec_cpu6(unsigned int val); 38extern void set_dec_cpu6(unsigned int val);
40 39
@@ -212,12 +211,8 @@ struct cpu_usage {
212DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array); 211DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
213 212
214#if defined(CONFIG_VIRT_CPU_ACCOUNTING) 213#if defined(CONFIG_VIRT_CPU_ACCOUNTING)
215extern void calculate_steal_time(void);
216extern void snapshot_timebases(void);
217#define account_process_vtime(tsk) account_process_tick(tsk, 0) 214#define account_process_vtime(tsk) account_process_tick(tsk, 0)
218#else 215#else
219#define calculate_steal_time() do { } while (0)
220#define snapshot_timebases() do { } while (0)
221#define account_process_vtime(tsk) do { } while (0) 216#define account_process_vtime(tsk) do { } while (0)
222#endif 217#endif
223 218
diff --git a/arch/powerpc/include/asm/tlbflush.h b/arch/powerpc/include/asm/tlbflush.h
index d50a380b2b6f..81143fcbd113 100644
--- a/arch/powerpc/include/asm/tlbflush.h
+++ b/arch/powerpc/include/asm/tlbflush.h
@@ -79,6 +79,8 @@ static inline void local_flush_tlb_mm(struct mm_struct *mm)
79 79
80#elif defined(CONFIG_PPC_STD_MMU_64) 80#elif defined(CONFIG_PPC_STD_MMU_64)
81 81
82#define MMU_NO_CONTEXT 0
83
82/* 84/*
83 * TLB flushing for 64-bit hash-MMU CPUs 85 * TLB flushing for 64-bit hash-MMU CPUs
84 */ 86 */
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h
index afe4aaa65c3b..7ef0d90defc8 100644
--- a/arch/powerpc/include/asm/topology.h
+++ b/arch/powerpc/include/asm/topology.h
@@ -106,9 +106,22 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
106 int nid) 106 int nid)
107{ 107{
108} 108}
109
110#endif /* CONFIG_NUMA */ 109#endif /* CONFIG_NUMA */
111 110
111#if defined(CONFIG_NUMA) && defined(CONFIG_PPC_SPLPAR)
112extern int start_topology_update(void);
113extern int stop_topology_update(void);
114#else
115static inline int start_topology_update(void)
116{
117 return 0;
118}
119static inline int stop_topology_update(void)
120{
121 return 0;
122}
123#endif /* CONFIG_NUMA && CONFIG_PPC_SPLPAR */
124
112#include <asm-generic/topology.h> 125#include <asm-generic/topology.h>
113 126
114#ifdef CONFIG_SMP 127#ifdef CONFIG_SMP
diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h
index a5aea0ca34e9..8947b9827bc4 100644
--- a/arch/powerpc/include/asm/types.h
+++ b/arch/powerpc/include/asm/types.h
@@ -44,13 +44,6 @@ typedef struct {
44 44
45typedef __vector128 vector128; 45typedef __vector128 vector128;
46 46
47#if defined(__powerpc64__) || defined(CONFIG_PHYS_64BIT)
48typedef u64 dma_addr_t;
49#else
50typedef u32 dma_addr_t;
51#endif
52typedef u64 dma64_addr_t;
53
54typedef struct { 47typedef struct {
55 unsigned long entry; 48 unsigned long entry;
56 unsigned long toc; 49 unsigned long toc;
diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h
index 11ae699135ba..58580e94a2bb 100644
--- a/arch/powerpc/include/asm/udbg.h
+++ b/arch/powerpc/include/asm/udbg.h
@@ -52,6 +52,7 @@ extern void __init udbg_init_44x_as1(void);
52extern void __init udbg_init_40x_realmode(void); 52extern void __init udbg_init_40x_realmode(void);
53extern void __init udbg_init_cpm(void); 53extern void __init udbg_init_cpm(void);
54extern void __init udbg_init_usbgecko(void); 54extern void __init udbg_init_usbgecko(void);
55extern void __init udbg_init_wsp(void);
55 56
56#endif /* __KERNEL__ */ 57#endif /* __KERNEL__ */
57#endif /* _ASM_POWERPC_UDBG_H */ 58#endif /* _ASM_POWERPC_UDBG_H */
diff --git a/arch/powerpc/include/asm/uninorth.h b/arch/powerpc/include/asm/uninorth.h
index f737732c3861..d12b11d7641e 100644
--- a/arch/powerpc/include/asm/uninorth.h
+++ b/arch/powerpc/include/asm/uninorth.h
@@ -60,7 +60,7 @@
60 * 60 *
61 * Obviously, the GART is not cache coherent and so any change to it 61 * Obviously, the GART is not cache coherent and so any change to it
62 * must be flushed to memory (or maybe just make the GART space non 62 * must be flushed to memory (or maybe just make the GART space non
63 * cachable). AGP memory itself doens't seem to be cache coherent neither. 63 * cachable). AGP memory itself doesn't seem to be cache coherent neither.
64 * 64 *
65 * In order to invalidate the GART (which is probably necessary to inval 65 * In order to invalidate the GART (which is probably necessary to inval
66 * the bridge internal TLBs), the following sequence has to be written, 66 * the bridge internal TLBs), the following sequence has to be written,
diff --git a/arch/powerpc/include/asm/unistd.h b/arch/powerpc/include/asm/unistd.h
index 597e6f9d094a..b8b3f599362b 100644
--- a/arch/powerpc/include/asm/unistd.h
+++ b/arch/powerpc/include/asm/unistd.h
@@ -348,10 +348,35 @@
348#define __NR_fanotify_init 323 348#define __NR_fanotify_init 323
349#define __NR_fanotify_mark 324 349#define __NR_fanotify_mark 324
350#define __NR_prlimit64 325 350#define __NR_prlimit64 325
351#define __NR_socket 326
352#define __NR_bind 327
353#define __NR_connect 328
354#define __NR_listen 329
355#define __NR_accept 330
356#define __NR_getsockname 331
357#define __NR_getpeername 332
358#define __NR_socketpair 333
359#define __NR_send 334
360#define __NR_sendto 335
361#define __NR_recv 336
362#define __NR_recvfrom 337
363#define __NR_shutdown 338
364#define __NR_setsockopt 339
365#define __NR_getsockopt 340
366#define __NR_sendmsg 341
367#define __NR_recvmsg 342
368#define __NR_recvmmsg 343
369#define __NR_accept4 344
370#define __NR_name_to_handle_at 345
371#define __NR_open_by_handle_at 346
372#define __NR_clock_adjtime 347
373#define __NR_syncfs 348
374#define __NR_sendmmsg 349
375#define __NR_setns 350
351 376
352#ifdef __KERNEL__ 377#ifdef __KERNEL__
353 378
354#define __NR_syscalls 326 379#define __NR_syscalls 351
355 380
356#define __NR__exit __NR_exit 381#define __NR__exit __NR_exit
357#define NR_syscalls __NR_syscalls 382#define NR_syscalls __NR_syscalls
diff --git a/arch/powerpc/include/asm/vdso_datapage.h b/arch/powerpc/include/asm/vdso_datapage.h
index 08679c5319b8..b73a8199f161 100644
--- a/arch/powerpc/include/asm/vdso_datapage.h
+++ b/arch/powerpc/include/asm/vdso_datapage.h
@@ -57,7 +57,7 @@ struct vdso_data {
57 } version; 57 } version;
58 58
59 /* Note about the platform flags: it now only contains the lpar 59 /* Note about the platform flags: it now only contains the lpar
60 * bit. The actual platform number is dead and burried 60 * bit. The actual platform number is dead and buried
61 */ 61 */
62 __u32 platform; /* Platform flags 0x18 */ 62 __u32 platform; /* Platform flags 0x18 */
63 __u32 processor; /* Processor type 0x1C */ 63 __u32 processor; /* Processor type 0x1C */
@@ -116,9 +116,7 @@ struct vdso_data {
116 116
117#endif /* CONFIG_PPC64 */ 117#endif /* CONFIG_PPC64 */
118 118
119#ifdef __KERNEL__
120extern struct vdso_data *vdso_data; 119extern struct vdso_data *vdso_data;
121#endif
122 120
123#endif /* __ASSEMBLY__ */ 121#endif /* __ASSEMBLY__ */
124 122
diff --git a/arch/powerpc/include/asm/wsp.h b/arch/powerpc/include/asm/wsp.h
new file mode 100644
index 000000000000..c7dc83088a33
--- /dev/null
+++ b/arch/powerpc/include/asm/wsp.h
@@ -0,0 +1,14 @@
1/*
2 * Copyright 2011 Michael Ellerman, IBM Corp.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9#ifndef __ASM_POWERPC_WSP_H
10#define __ASM_POWERPC_WSP_H
11
12extern int wsp_get_chip_id(struct device_node *dn);
13
14#endif /* __ASM_POWERPC_WSP_H */
diff --git a/arch/powerpc/include/asm/xics.h b/arch/powerpc/include/asm/xics.h
new file mode 100644
index 000000000000..b183a4062011
--- /dev/null
+++ b/arch/powerpc/include/asm/xics.h
@@ -0,0 +1,142 @@
1/*
2 * Common definitions accross all variants of ICP and ICS interrupt
3 * controllers.
4 */
5
6#ifndef _XICS_H
7#define _XICS_H
8
9#include <linux/interrupt.h>
10
11#define XICS_IPI 2
12#define XICS_IRQ_SPURIOUS 0
13
14/* Want a priority other than 0. Various HW issues require this. */
15#define DEFAULT_PRIORITY 5
16
17/*
18 * Mark IPIs as higher priority so we can take them inside interrupts that
19 * arent marked IRQF_DISABLED
20 */
21#define IPI_PRIORITY 4
22
23/* The least favored priority */
24#define LOWEST_PRIORITY 0xFF
25
26/* The number of priorities defined above */
27#define MAX_NUM_PRIORITIES 3
28
29/* Native ICP */
30extern int icp_native_init(void);
31
32/* PAPR ICP */
33extern int icp_hv_init(void);
34
35/* ICP ops */
36struct icp_ops {
37 unsigned int (*get_irq)(void);
38 void (*eoi)(struct irq_data *d);
39 void (*set_priority)(unsigned char prio);
40 void (*teardown_cpu)(void);
41 void (*flush_ipi)(void);
42#ifdef CONFIG_SMP
43 void (*cause_ipi)(int cpu, unsigned long data);
44 irq_handler_t ipi_action;
45#endif
46};
47
48extern const struct icp_ops *icp_ops;
49
50/* Native ICS */
51extern int ics_native_init(void);
52
53/* RTAS ICS */
54extern int ics_rtas_init(void);
55
56/* ICS instance, hooked up to chip_data of an irq */
57struct ics {
58 struct list_head link;
59 int (*map)(struct ics *ics, unsigned int virq);
60 void (*mask_unknown)(struct ics *ics, unsigned long vec);
61 long (*get_server)(struct ics *ics, unsigned long vec);
62 int (*host_match)(struct ics *ics, struct device_node *node);
63 char data[];
64};
65
66/* Commons */
67extern unsigned int xics_default_server;
68extern unsigned int xics_default_distrib_server;
69extern unsigned int xics_interrupt_server_size;
70extern struct irq_host *xics_host;
71
72struct xics_cppr {
73 unsigned char stack[MAX_NUM_PRIORITIES];
74 int index;
75};
76
77DECLARE_PER_CPU(struct xics_cppr, xics_cppr);
78
79static inline void xics_push_cppr(unsigned int vec)
80{
81 struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
82
83 if (WARN_ON(os_cppr->index >= MAX_NUM_PRIORITIES - 1))
84 return;
85
86 if (vec == XICS_IPI)
87 os_cppr->stack[++os_cppr->index] = IPI_PRIORITY;
88 else
89 os_cppr->stack[++os_cppr->index] = DEFAULT_PRIORITY;
90}
91
92static inline unsigned char xics_pop_cppr(void)
93{
94 struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
95
96 if (WARN_ON(os_cppr->index < 1))
97 return LOWEST_PRIORITY;
98
99 return os_cppr->stack[--os_cppr->index];
100}
101
102static inline void xics_set_base_cppr(unsigned char cppr)
103{
104 struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
105
106 /* we only really want to set the priority when there's
107 * just one cppr value on the stack
108 */
109 WARN_ON(os_cppr->index != 0);
110
111 os_cppr->stack[0] = cppr;
112}
113
114static inline unsigned char xics_cppr_top(void)
115{
116 struct xics_cppr *os_cppr = &__get_cpu_var(xics_cppr);
117
118 return os_cppr->stack[os_cppr->index];
119}
120
121DECLARE_PER_CPU_SHARED_ALIGNED(unsigned long, xics_ipi_message);
122
123extern void xics_init(void);
124extern void xics_setup_cpu(void);
125extern void xics_update_irq_servers(void);
126extern void xics_set_cpu_giq(unsigned int gserver, unsigned int join);
127extern void xics_mask_unknown_vec(unsigned int vec);
128extern irqreturn_t xics_ipi_dispatch(int cpu);
129extern int xics_smp_probe(void);
130extern void xics_register_ics(struct ics *ics);
131extern void xics_teardown_cpu(void);
132extern void xics_kexec_teardown_cpu(int secondary);
133extern void xics_migrate_irqs_away(void);
134#ifdef CONFIG_SMP
135extern int xics_get_irq_server(unsigned int virq, const struct cpumask *cpumask,
136 unsigned int strict_check);
137#else
138#define xics_get_irq_server(virq, cpumask, strict_check) (xics_default_server)
139#endif
140
141
142#endif /* _XICS_H */