aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-powerpc
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
committerLen Brown <len.brown@intel.com>2005-12-06 17:31:30 -0500
commit3d5271f9883cba7b54762bc4fe027d4172f06db7 (patch)
treeab8a881a14478598a0c8bda0d26c62cdccfffd6d /include/asm-powerpc
parent378b2556f4e09fa6f87ff0cb5c4395ff28257d02 (diff)
parent9115a6c787596e687df03010d97fccc5e0762506 (diff)
Pull release into acpica branch
Diffstat (limited to 'include/asm-powerpc')
-rw-r--r--include/asm-powerpc/a.out.h36
-rw-r--r--include/asm-powerpc/abs_addr.h73
-rw-r--r--include/asm-powerpc/asm-compat.h55
-rw-r--r--include/asm-powerpc/atomic.h406
-rw-r--r--include/asm-powerpc/auxvec.h19
-rw-r--r--include/asm-powerpc/backlight.h31
-rw-r--r--include/asm-powerpc/bitops.h428
-rw-r--r--include/asm-powerpc/btext.h27
-rw-r--r--include/asm-powerpc/bug.h70
-rw-r--r--include/asm-powerpc/byteorder.h89
-rw-r--r--include/asm-powerpc/cache.h40
-rw-r--r--include/asm-powerpc/cacheflush.h68
-rw-r--r--include/asm-powerpc/checksum.h132
-rw-r--r--include/asm-powerpc/compat.h205
-rw-r--r--include/asm-powerpc/cputable.h436
-rw-r--r--include/asm-powerpc/current.h27
-rw-r--r--include/asm-powerpc/dbdma.h102
-rw-r--r--include/asm-powerpc/delay.h19
-rw-r--r--include/asm-powerpc/dma-mapping.h285
-rw-r--r--include/asm-powerpc/dma.h390
-rw-r--r--include/asm-powerpc/eeh.h366
-rw-r--r--include/asm-powerpc/eeh_event.h52
-rw-r--r--include/asm-powerpc/elf.h415
-rw-r--r--include/asm-powerpc/firmware.h103
-rw-r--r--include/asm-powerpc/floppy.h105
-rw-r--r--include/asm-powerpc/futex.h85
-rw-r--r--include/asm-powerpc/grackle.h7
-rw-r--r--include/asm-powerpc/hardirq.h27
-rw-r--r--include/asm-powerpc/heathrow.h62
-rw-r--r--include/asm-powerpc/hvcall.h173
-rw-r--r--include/asm-powerpc/hvconsole.h49
-rw-r--r--include/asm-powerpc/hvcserver.h57
-rw-r--r--include/asm-powerpc/hw_irq.h113
-rw-r--r--include/asm-powerpc/i8259.h12
-rw-r--r--include/asm-powerpc/ide.h83
-rw-r--r--include/asm-powerpc/io.h462
-rw-r--r--include/asm-powerpc/ioctls.h3
-rw-r--r--include/asm-powerpc/iommu.h118
-rw-r--r--include/asm-powerpc/ipcbuf.h34
-rw-r--r--include/asm-powerpc/irq.h504
-rw-r--r--include/asm-powerpc/iseries/hv_call.h113
-rw-r--r--include/asm-powerpc/iseries/hv_call_event.h253
-rw-r--r--include/asm-powerpc/iseries/hv_call_sc.h51
-rw-r--r--include/asm-powerpc/iseries/hv_call_xm.h78
-rw-r--r--include/asm-powerpc/iseries/hv_lp_config.h138
-rw-r--r--include/asm-powerpc/iseries/hv_lp_event.h142
-rw-r--r--include/asm-powerpc/iseries/hv_types.h113
-rw-r--r--include/asm-powerpc/iseries/iseries_io.h49
-rw-r--r--include/asm-powerpc/iseries/it_exp_vpd_panel.h52
-rw-r--r--include/asm-powerpc/iseries/it_lp_naca.h80
-rw-r--r--include/asm-powerpc/iseries/it_lp_queue.h81
-rw-r--r--include/asm-powerpc/iseries/it_lp_reg_save.h84
-rw-r--r--include/asm-powerpc/iseries/lpar_map.h83
-rw-r--r--include/asm-powerpc/iseries/mf.h57
-rw-r--r--include/asm-powerpc/iseries/vio.h130
-rw-r--r--include/asm-powerpc/kdebug.h42
-rw-r--r--include/asm-powerpc/kexec.h50
-rw-r--r--include/asm-powerpc/keylargo.h248
-rw-r--r--include/asm-powerpc/kmap_types.h33
-rw-r--r--include/asm-powerpc/kprobes.h81
-rw-r--r--include/asm-powerpc/lmb.h81
-rw-r--r--include/asm-powerpc/lppaca.h131
-rw-r--r--include/asm-powerpc/machdep.h291
-rw-r--r--include/asm-powerpc/macio.h140
-rw-r--r--include/asm-powerpc/mediabay.h31
-rw-r--r--include/asm-powerpc/mmu.h399
-rw-r--r--include/asm-powerpc/mmu_context.h89
-rw-r--r--include/asm-powerpc/mmzone.h50
-rw-r--r--include/asm-powerpc/mpic.h287
-rw-r--r--include/asm-powerpc/numnodes.h7
-rw-r--r--include/asm-powerpc/nvram.h119
-rw-r--r--include/asm-powerpc/of_device.h64
-rw-r--r--include/asm-powerpc/ohare.h48
-rw-r--r--include/asm-powerpc/oprofile_impl.h123
-rw-r--r--include/asm-powerpc/pSeries_reconfig.h25
-rw-r--r--include/asm-powerpc/paca.h120
-rw-r--r--include/asm-powerpc/page.h179
-rw-r--r--include/asm-powerpc/page_32.h40
-rw-r--r--include/asm-powerpc/page_64.h183
-rw-r--r--include/asm-powerpc/parport.h18
-rw-r--r--include/asm-powerpc/pci-bridge.h153
-rw-r--r--include/asm-powerpc/pci.h247
-rw-r--r--include/asm-powerpc/pgalloc.h156
-rw-r--r--include/asm-powerpc/pgtable-4k.h91
-rw-r--r--include/asm-powerpc/pgtable-64k.h90
-rw-r--r--include/asm-powerpc/pgtable.h524
-rw-r--r--include/asm-powerpc/pmac_feature.h380
-rw-r--r--include/asm-powerpc/pmac_low_i2c.h43
-rw-r--r--include/asm-powerpc/pmc.h47
-rw-r--r--include/asm-powerpc/posix_types.h129
-rw-r--r--include/asm-powerpc/ppc-pci.h96
-rw-r--r--include/asm-powerpc/ppc_asm.h491
-rw-r--r--include/asm-powerpc/processor.h287
-rw-r--r--include/asm-powerpc/prom.h227
-rw-r--r--include/asm-powerpc/ptrace.h248
-rw-r--r--include/asm-powerpc/reg.h625
-rw-r--r--include/asm-powerpc/reg_8xx.h42
-rw-r--r--include/asm-powerpc/rtas.h232
-rw-r--r--include/asm-powerpc/rtc.h78
-rw-r--r--include/asm-powerpc/rwsem.h168
-rw-r--r--include/asm-powerpc/scatterlist.h45
-rw-r--r--include/asm-powerpc/seccomp.h16
-rw-r--r--include/asm-powerpc/sections.h20
-rw-r--r--include/asm-powerpc/semaphore.h95
-rw-r--r--include/asm-powerpc/serial.h18
-rw-r--r--include/asm-powerpc/sigcontext.h52
-rw-r--r--include/asm-powerpc/signal.h150
-rw-r--r--include/asm-powerpc/smp.h121
-rw-r--r--include/asm-powerpc/smu.h570
-rw-r--r--include/asm-powerpc/sparsemem.h20
-rw-r--r--include/asm-powerpc/spinlock.h269
-rw-r--r--include/asm-powerpc/spinlock_types.h20
-rw-r--r--include/asm-powerpc/sstep.h26
-rw-r--r--include/asm-powerpc/stat.h81
-rw-r--r--include/asm-powerpc/statfs.h60
-rw-r--r--include/asm-powerpc/synch.h51
-rw-r--r--include/asm-powerpc/system.h411
-rw-r--r--include/asm-powerpc/tce.h64
-rw-r--r--include/asm-powerpc/termios.h135
-rw-r--r--include/asm-powerpc/thread_info.h146
-rw-r--r--include/asm-powerpc/time.h226
-rw-r--r--include/asm-powerpc/timex.h2
-rw-r--r--include/asm-powerpc/tlb.h70
-rw-r--r--include/asm-powerpc/tlbflush.h147
-rw-r--r--include/asm-powerpc/topology.h16
-rw-r--r--include/asm-powerpc/types.h110
-rw-r--r--include/asm-powerpc/uaccess.h464
-rw-r--r--include/asm-powerpc/ucontext.h40
-rw-r--r--include/asm-powerpc/udbg.h31
-rw-r--r--include/asm-powerpc/uninorth.h229
-rw-r--r--include/asm-powerpc/unistd.h509
-rw-r--r--include/asm-powerpc/vdso.h83
-rw-r--r--include/asm-powerpc/vdso_datapage.h108
-rw-r--r--include/asm-powerpc/vga.h54
-rw-r--r--include/asm-powerpc/vio.h106
-rw-r--r--include/asm-powerpc/xmon.h12
136 files changed, 18936 insertions, 146 deletions
diff --git a/include/asm-powerpc/a.out.h b/include/asm-powerpc/a.out.h
new file mode 100644
index 000000000000..c7393a977364
--- /dev/null
+++ b/include/asm-powerpc/a.out.h
@@ -0,0 +1,36 @@
1#ifndef _ASM_POWERPC_A_OUT_H
2#define _ASM_POWERPC_A_OUT_H
3
4struct exec
5{
6 unsigned long a_info; /* Use macros N_MAGIC, etc for access */
7 unsigned a_text; /* length of text, in bytes */
8 unsigned a_data; /* length of data, in bytes */
9 unsigned a_bss; /* length of uninitialized data area for file, in bytes */
10 unsigned a_syms; /* length of symbol table data in file, in bytes */
11 unsigned a_entry; /* start address */
12 unsigned a_trsize; /* length of relocation info for text, in bytes */
13 unsigned a_drsize; /* length of relocation info for data, in bytes */
14};
15
16#define N_TRSIZE(a) ((a).a_trsize)
17#define N_DRSIZE(a) ((a).a_drsize)
18#define N_SYMSIZE(a) ((a).a_syms)
19
20#ifdef __KERNEL__
21#ifdef __powerpc64__
22
23#define STACK_TOP_USER64 TASK_SIZE_USER64
24#define STACK_TOP_USER32 TASK_SIZE_USER32
25
26#define STACK_TOP (test_thread_flag(TIF_32BIT) ? \
27 STACK_TOP_USER32 : STACK_TOP_USER64)
28
29#else /* __powerpc64__ */
30
31#define STACK_TOP TASK_SIZE
32
33#endif /* __powerpc64__ */
34#endif /* __KERNEL__ */
35
36#endif /* _ASM_POWERPC_A_OUT_H */
diff --git a/include/asm-powerpc/abs_addr.h b/include/asm-powerpc/abs_addr.h
new file mode 100644
index 000000000000..18415108fc56
--- /dev/null
+++ b/include/asm-powerpc/abs_addr.h
@@ -0,0 +1,73 @@
1#ifndef _ASM_POWERPC_ABS_ADDR_H
2#define _ASM_POWERPC_ABS_ADDR_H
3
4#include <linux/config.h>
5
6/*
7 * c 2001 PPC 64 Team, IBM Corp
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15#include <asm/types.h>
16#include <asm/page.h>
17#include <asm/prom.h>
18#include <asm/lmb.h>
19#include <asm/firmware.h>
20
21struct mschunks_map {
22 unsigned long num_chunks;
23 unsigned long chunk_size;
24 unsigned long chunk_shift;
25 unsigned long chunk_mask;
26 u32 *mapping;
27};
28
29extern struct mschunks_map mschunks_map;
30
31/* Chunks are 256 KB */
32#define MSCHUNKS_CHUNK_SHIFT (18)
33#define MSCHUNKS_CHUNK_SIZE (1UL << MSCHUNKS_CHUNK_SHIFT)
34#define MSCHUNKS_OFFSET_MASK (MSCHUNKS_CHUNK_SIZE - 1)
35
36static inline unsigned long chunk_to_addr(unsigned long chunk)
37{
38 return chunk << MSCHUNKS_CHUNK_SHIFT;
39}
40
41static inline unsigned long addr_to_chunk(unsigned long addr)
42{
43 return addr >> MSCHUNKS_CHUNK_SHIFT;
44}
45
46static inline unsigned long phys_to_abs(unsigned long pa)
47{
48 unsigned long chunk;
49
50 /* This is a no-op on non-iSeries */
51 if (!firmware_has_feature(FW_FEATURE_ISERIES))
52 return pa;
53
54 chunk = addr_to_chunk(pa);
55
56 if (chunk < mschunks_map.num_chunks)
57 chunk = mschunks_map.mapping[chunk];
58
59 return chunk_to_addr(chunk) + (pa & MSCHUNKS_OFFSET_MASK);
60}
61
62/* Convenience macros */
63#define virt_to_abs(va) phys_to_abs(__pa(va))
64#define abs_to_virt(aa) __va(aa)
65
66/*
67 * Converts Virtual Address to Real Address for
68 * Legacy iSeries Hypervisor calls
69 */
70#define iseries_hv_addr(virtaddr) \
71 (0x8000000000000000 | virt_to_abs(virtaddr))
72
73#endif /* _ASM_POWERPC_ABS_ADDR_H */
diff --git a/include/asm-powerpc/asm-compat.h b/include/asm-powerpc/asm-compat.h
new file mode 100644
index 000000000000..8b133efc9f79
--- /dev/null
+++ b/include/asm-powerpc/asm-compat.h
@@ -0,0 +1,55 @@
1#ifndef _ASM_POWERPC_ASM_COMPAT_H
2#define _ASM_POWERPC_ASM_COMPAT_H
3
4#include <linux/config.h>
5#include <asm/types.h>
6
7#ifdef __ASSEMBLY__
8# define stringify_in_c(...) __VA_ARGS__
9# define ASM_CONST(x) x
10#else
11/* This version of stringify will deal with commas... */
12# define __stringify_in_c(...) #__VA_ARGS__
13# define stringify_in_c(...) __stringify_in_c(__VA_ARGS__) " "
14# define __ASM_CONST(x) x##UL
15# define ASM_CONST(x) __ASM_CONST(x)
16#endif
17
18#ifdef __powerpc64__
19
20/* operations for longs and pointers */
21#define PPC_LL stringify_in_c(ld)
22#define PPC_STL stringify_in_c(std)
23#define PPC_LCMPI stringify_in_c(cmpdi)
24#define PPC_LONG stringify_in_c(.llong)
25#define PPC_TLNEI stringify_in_c(tdnei)
26#define PPC_LLARX stringify_in_c(ldarx)
27#define PPC_STLCX stringify_in_c(stdcx.)
28#define PPC_CNTLZL stringify_in_c(cntlzd)
29
30#else /* 32-bit */
31
32/* operations for longs and pointers */
33#define PPC_LL stringify_in_c(lwz)
34#define PPC_STL stringify_in_c(stw)
35#define PPC_LCMPI stringify_in_c(cmpwi)
36#define PPC_LONG stringify_in_c(.long)
37#define PPC_TLNEI stringify_in_c(twnei)
38#define PPC_LLARX stringify_in_c(lwarx)
39#define PPC_STLCX stringify_in_c(stwcx.)
40#define PPC_CNTLZL stringify_in_c(cntlzw)
41
42#endif
43
44#ifdef CONFIG_IBM405_ERR77
45/* Erratum #77 on the 405 means we need a sync or dcbt before every
46 * stwcx. The old ATOMIC_SYNC_FIX covered some but not all of this.
47 */
48#define PPC405_ERR77(ra,rb) stringify_in_c(dcbt ra, rb;)
49#define PPC405_ERR77_SYNC stringify_in_c(sync;)
50#else
51#define PPC405_ERR77(ra,rb)
52#define PPC405_ERR77_SYNC
53#endif
54
55#endif /* _ASM_POWERPC_ASM_COMPAT_H */
diff --git a/include/asm-powerpc/atomic.h b/include/asm-powerpc/atomic.h
new file mode 100644
index 000000000000..ec4b14468959
--- /dev/null
+++ b/include/asm-powerpc/atomic.h
@@ -0,0 +1,406 @@
1#ifndef _ASM_POWERPC_ATOMIC_H_
2#define _ASM_POWERPC_ATOMIC_H_
3
4/*
5 * PowerPC atomic operations
6 */
7
8typedef struct { volatile int counter; } atomic_t;
9
10#ifdef __KERNEL__
11#include <asm/synch.h>
12#include <asm/asm-compat.h>
13
14#define ATOMIC_INIT(i) { (i) }
15
16#define atomic_read(v) ((v)->counter)
17#define atomic_set(v,i) (((v)->counter) = (i))
18
19static __inline__ void atomic_add(int a, atomic_t *v)
20{
21 int t;
22
23 __asm__ __volatile__(
24"1: lwarx %0,0,%3 # atomic_add\n\
25 add %0,%2,%0\n"
26 PPC405_ERR77(0,%3)
27" stwcx. %0,0,%3 \n\
28 bne- 1b"
29 : "=&r" (t), "=m" (v->counter)
30 : "r" (a), "r" (&v->counter), "m" (v->counter)
31 : "cc");
32}
33
34static __inline__ int atomic_add_return(int a, atomic_t *v)
35{
36 int t;
37
38 __asm__ __volatile__(
39 EIEIO_ON_SMP
40"1: lwarx %0,0,%2 # atomic_add_return\n\
41 add %0,%1,%0\n"
42 PPC405_ERR77(0,%2)
43" stwcx. %0,0,%2 \n\
44 bne- 1b"
45 ISYNC_ON_SMP
46 : "=&r" (t)
47 : "r" (a), "r" (&v->counter)
48 : "cc", "memory");
49
50 return t;
51}
52
53#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
54
55static __inline__ void atomic_sub(int a, atomic_t *v)
56{
57 int t;
58
59 __asm__ __volatile__(
60"1: lwarx %0,0,%3 # atomic_sub\n\
61 subf %0,%2,%0\n"
62 PPC405_ERR77(0,%3)
63" stwcx. %0,0,%3 \n\
64 bne- 1b"
65 : "=&r" (t), "=m" (v->counter)
66 : "r" (a), "r" (&v->counter), "m" (v->counter)
67 : "cc");
68}
69
70static __inline__ int atomic_sub_return(int a, atomic_t *v)
71{
72 int t;
73
74 __asm__ __volatile__(
75 EIEIO_ON_SMP
76"1: lwarx %0,0,%2 # atomic_sub_return\n\
77 subf %0,%1,%0\n"
78 PPC405_ERR77(0,%2)
79" stwcx. %0,0,%2 \n\
80 bne- 1b"
81 ISYNC_ON_SMP
82 : "=&r" (t)
83 : "r" (a), "r" (&v->counter)
84 : "cc", "memory");
85
86 return t;
87}
88
89static __inline__ void atomic_inc(atomic_t *v)
90{
91 int t;
92
93 __asm__ __volatile__(
94"1: lwarx %0,0,%2 # atomic_inc\n\
95 addic %0,%0,1\n"
96 PPC405_ERR77(0,%2)
97" stwcx. %0,0,%2 \n\
98 bne- 1b"
99 : "=&r" (t), "=m" (v->counter)
100 : "r" (&v->counter), "m" (v->counter)
101 : "cc");
102}
103
104static __inline__ int atomic_inc_return(atomic_t *v)
105{
106 int t;
107
108 __asm__ __volatile__(
109 EIEIO_ON_SMP
110"1: lwarx %0,0,%1 # atomic_inc_return\n\
111 addic %0,%0,1\n"
112 PPC405_ERR77(0,%1)
113" stwcx. %0,0,%1 \n\
114 bne- 1b"
115 ISYNC_ON_SMP
116 : "=&r" (t)
117 : "r" (&v->counter)
118 : "cc", "memory");
119
120 return t;
121}
122
123/*
124 * atomic_inc_and_test - increment and test
125 * @v: pointer of type atomic_t
126 *
127 * Atomically increments @v by 1
128 * and returns true if the result is zero, or false for all
129 * other cases.
130 */
131#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
132
133static __inline__ void atomic_dec(atomic_t *v)
134{
135 int t;
136
137 __asm__ __volatile__(
138"1: lwarx %0,0,%2 # atomic_dec\n\
139 addic %0,%0,-1\n"
140 PPC405_ERR77(0,%2)\
141" stwcx. %0,0,%2\n\
142 bne- 1b"
143 : "=&r" (t), "=m" (v->counter)
144 : "r" (&v->counter), "m" (v->counter)
145 : "cc");
146}
147
148static __inline__ int atomic_dec_return(atomic_t *v)
149{
150 int t;
151
152 __asm__ __volatile__(
153 EIEIO_ON_SMP
154"1: lwarx %0,0,%1 # atomic_dec_return\n\
155 addic %0,%0,-1\n"
156 PPC405_ERR77(0,%1)
157" stwcx. %0,0,%1\n\
158 bne- 1b"
159 ISYNC_ON_SMP
160 : "=&r" (t)
161 : "r" (&v->counter)
162 : "cc", "memory");
163
164 return t;
165}
166
167#define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))
168
169/**
170 * atomic_add_unless - add unless the number is a given value
171 * @v: pointer of type atomic_t
172 * @a: the amount to add to v...
173 * @u: ...unless v is equal to u.
174 *
175 * Atomically adds @a to @v, so long as it was not @u.
176 * Returns non-zero if @v was not @u, and zero otherwise.
177 */
178#define atomic_add_unless(v, a, u) \
179({ \
180 int c, old; \
181 c = atomic_read(v); \
182 for (;;) { \
183 if (unlikely(c == (u))) \
184 break; \
185 old = atomic_cmpxchg((v), c, c + (a)); \
186 if (likely(old == c)) \
187 break; \
188 c = old; \
189 } \
190 c != (u); \
191})
192#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
193
194#define atomic_sub_and_test(a, v) (atomic_sub_return((a), (v)) == 0)
195#define atomic_dec_and_test(v) (atomic_dec_return((v)) == 0)
196
197/*
198 * Atomically test *v and decrement if it is greater than 0.
199 * The function returns the old value of *v minus 1.
200 */
201static __inline__ int atomic_dec_if_positive(atomic_t *v)
202{
203 int t;
204
205 __asm__ __volatile__(
206 EIEIO_ON_SMP
207"1: lwarx %0,0,%1 # atomic_dec_if_positive\n\
208 addic. %0,%0,-1\n\
209 blt- 2f\n"
210 PPC405_ERR77(0,%1)
211" stwcx. %0,0,%1\n\
212 bne- 1b"
213 ISYNC_ON_SMP
214 "\n\
2152:" : "=&r" (t)
216 : "r" (&v->counter)
217 : "cc", "memory");
218
219 return t;
220}
221
222#define smp_mb__before_atomic_dec() smp_mb()
223#define smp_mb__after_atomic_dec() smp_mb()
224#define smp_mb__before_atomic_inc() smp_mb()
225#define smp_mb__after_atomic_inc() smp_mb()
226
227#ifdef __powerpc64__
228
229typedef struct { volatile long counter; } atomic64_t;
230
231#define ATOMIC64_INIT(i) { (i) }
232
233#define atomic64_read(v) ((v)->counter)
234#define atomic64_set(v,i) (((v)->counter) = (i))
235
236static __inline__ void atomic64_add(long a, atomic64_t *v)
237{
238 long t;
239
240 __asm__ __volatile__(
241"1: ldarx %0,0,%3 # atomic64_add\n\
242 add %0,%2,%0\n\
243 stdcx. %0,0,%3 \n\
244 bne- 1b"
245 : "=&r" (t), "=m" (v->counter)
246 : "r" (a), "r" (&v->counter), "m" (v->counter)
247 : "cc");
248}
249
250static __inline__ long atomic64_add_return(long a, atomic64_t *v)
251{
252 long t;
253
254 __asm__ __volatile__(
255 EIEIO_ON_SMP
256"1: ldarx %0,0,%2 # atomic64_add_return\n\
257 add %0,%1,%0\n\
258 stdcx. %0,0,%2 \n\
259 bne- 1b"
260 ISYNC_ON_SMP
261 : "=&r" (t)
262 : "r" (a), "r" (&v->counter)
263 : "cc", "memory");
264
265 return t;
266}
267
268#define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
269
270static __inline__ void atomic64_sub(long a, atomic64_t *v)
271{
272 long t;
273
274 __asm__ __volatile__(
275"1: ldarx %0,0,%3 # atomic64_sub\n\
276 subf %0,%2,%0\n\
277 stdcx. %0,0,%3 \n\
278 bne- 1b"
279 : "=&r" (t), "=m" (v->counter)
280 : "r" (a), "r" (&v->counter), "m" (v->counter)
281 : "cc");
282}
283
284static __inline__ long atomic64_sub_return(long a, atomic64_t *v)
285{
286 long t;
287
288 __asm__ __volatile__(
289 EIEIO_ON_SMP
290"1: ldarx %0,0,%2 # atomic64_sub_return\n\
291 subf %0,%1,%0\n\
292 stdcx. %0,0,%2 \n\
293 bne- 1b"
294 ISYNC_ON_SMP
295 : "=&r" (t)
296 : "r" (a), "r" (&v->counter)
297 : "cc", "memory");
298
299 return t;
300}
301
302static __inline__ void atomic64_inc(atomic64_t *v)
303{
304 long t;
305
306 __asm__ __volatile__(
307"1: ldarx %0,0,%2 # atomic64_inc\n\
308 addic %0,%0,1\n\
309 stdcx. %0,0,%2 \n\
310 bne- 1b"
311 : "=&r" (t), "=m" (v->counter)
312 : "r" (&v->counter), "m" (v->counter)
313 : "cc");
314}
315
316static __inline__ long atomic64_inc_return(atomic64_t *v)
317{
318 long t;
319
320 __asm__ __volatile__(
321 EIEIO_ON_SMP
322"1: ldarx %0,0,%1 # atomic64_inc_return\n\
323 addic %0,%0,1\n\
324 stdcx. %0,0,%1 \n\
325 bne- 1b"
326 ISYNC_ON_SMP
327 : "=&r" (t)
328 : "r" (&v->counter)
329 : "cc", "memory");
330
331 return t;
332}
333
334/*
335 * atomic64_inc_and_test - increment and test
336 * @v: pointer of type atomic64_t
337 *
338 * Atomically increments @v by 1
339 * and returns true if the result is zero, or false for all
340 * other cases.
341 */
342#define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
343
344static __inline__ void atomic64_dec(atomic64_t *v)
345{
346 long t;
347
348 __asm__ __volatile__(
349"1: ldarx %0,0,%2 # atomic64_dec\n\
350 addic %0,%0,-1\n\
351 stdcx. %0,0,%2\n\
352 bne- 1b"
353 : "=&r" (t), "=m" (v->counter)
354 : "r" (&v->counter), "m" (v->counter)
355 : "cc");
356}
357
358static __inline__ long atomic64_dec_return(atomic64_t *v)
359{
360 long t;
361
362 __asm__ __volatile__(
363 EIEIO_ON_SMP
364"1: ldarx %0,0,%1 # atomic64_dec_return\n\
365 addic %0,%0,-1\n\
366 stdcx. %0,0,%1\n\
367 bne- 1b"
368 ISYNC_ON_SMP
369 : "=&r" (t)
370 : "r" (&v->counter)
371 : "cc", "memory");
372
373 return t;
374}
375
376#define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
377#define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
378
379/*
380 * Atomically test *v and decrement if it is greater than 0.
381 * The function returns the old value of *v minus 1.
382 */
383static __inline__ long atomic64_dec_if_positive(atomic64_t *v)
384{
385 long t;
386
387 __asm__ __volatile__(
388 EIEIO_ON_SMP
389"1: ldarx %0,0,%1 # atomic64_dec_if_positive\n\
390 addic. %0,%0,-1\n\
391 blt- 2f\n\
392 stdcx. %0,0,%1\n\
393 bne- 1b"
394 ISYNC_ON_SMP
395 "\n\
3962:" : "=&r" (t)
397 : "r" (&v->counter)
398 : "cc", "memory");
399
400 return t;
401}
402
403#endif /* __powerpc64__ */
404
405#endif /* __KERNEL__ */
406#endif /* _ASM_POWERPC_ATOMIC_H_ */
diff --git a/include/asm-powerpc/auxvec.h b/include/asm-powerpc/auxvec.h
new file mode 100644
index 000000000000..19a099b62cd6
--- /dev/null
+++ b/include/asm-powerpc/auxvec.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_POWERPC_AUXVEC_H
2#define _ASM_POWERPC_AUXVEC_H
3
4/*
5 * We need to put in some extra aux table entries to tell glibc what
6 * the cache block size is, so it can use the dcbz instruction safely.
7 */
8#define AT_DCACHEBSIZE 19
9#define AT_ICACHEBSIZE 20
10#define AT_UCACHEBSIZE 21
11/* A special ignored type value for PPC, for glibc compatibility. */
12#define AT_IGNOREPPC 22
13
14/* The vDSO location. We have to use the same value as x86 for glibc's
15 * sake :-)
16 */
17#define AT_SYSINFO_EHDR 33
18
19#endif
diff --git a/include/asm-powerpc/backlight.h b/include/asm-powerpc/backlight.h
new file mode 100644
index 000000000000..1ba1f27a0b63
--- /dev/null
+++ b/include/asm-powerpc/backlight.h
@@ -0,0 +1,31 @@
1/*
2 * Routines for handling backlight control on PowerBooks
3 *
4 * For now, implementation resides in
5 * arch/powerpc/platforms/powermac/pmac_support.c
6 *
7 */
8#ifndef __ASM_POWERPC_BACKLIGHT_H
9#define __ASM_POWERPC_BACKLIGHT_H
10#ifdef __KERNEL__
11
12/* Abstract values */
13#define BACKLIGHT_OFF 0
14#define BACKLIGHT_MIN 1
15#define BACKLIGHT_MAX 0xf
16
17struct backlight_controller {
18 int (*set_enable)(int enable, int level, void *data);
19 int (*set_level)(int level, void *data);
20};
21
22extern void register_backlight_controller(struct backlight_controller *ctrler, void *data, char *type);
23extern void unregister_backlight_controller(struct backlight_controller *ctrler, void *data);
24
25extern int set_backlight_enable(int enable);
26extern int get_backlight_enable(void);
27extern int set_backlight_level(int level);
28extern int get_backlight_level(void);
29
30#endif /* __KERNEL__ */
31#endif
diff --git a/include/asm-powerpc/bitops.h b/include/asm-powerpc/bitops.h
new file mode 100644
index 000000000000..5727229b0444
--- /dev/null
+++ b/include/asm-powerpc/bitops.h
@@ -0,0 +1,428 @@
1/*
2 * PowerPC atomic bit operations.
3 *
4 * Merged version by David Gibson <david@gibson.dropbear.id.au>.
5 * Based on ppc64 versions by: Dave Engebretsen, Todd Inglett, Don
6 * Reed, Pat McCarthy, Peter Bergner, Anton Blanchard. They
7 * originally took it from the ppc32 code.
8 *
9 * Within a word, bits are numbered LSB first. Lot's of places make
10 * this assumption by directly testing bits with (val & (1<<nr)).
11 * This can cause confusion for large (> 1 word) bitmaps on a
12 * big-endian system because, unlike little endian, the number of each
13 * bit depends on the word size.
14 *
15 * The bitop functions are defined to work on unsigned longs, so for a
16 * ppc64 system the bits end up numbered:
17 * |63..............0|127............64|191...........128|255...........196|
18 * and on ppc32:
19 * |31.....0|63....31|95....64|127...96|159..128|191..160|223..192|255..224|
20 *
21 * There are a few little-endian macros used mostly for filesystem
22 * bitmaps, these work on similar bit arrays layouts, but
23 * byte-oriented:
24 * |7...0|15...8|23...16|31...24|39...32|47...40|55...48|63...56|
25 *
26 * The main difference is that bit 3-5 (64b) or 3-4 (32b) in the bit
27 * number field needs to be reversed compared to the big-endian bit
28 * fields. This can be achieved by XOR with 0x38 (64b) or 0x18 (32b).
29 *
30 * This program is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU General Public License
32 * as published by the Free Software Foundation; either version
33 * 2 of the License, or (at your option) any later version.
34 */
35
36#ifndef _ASM_POWERPC_BITOPS_H
37#define _ASM_POWERPC_BITOPS_H
38
39#ifdef __KERNEL__
40
41#include <linux/compiler.h>
42#include <asm/atomic.h>
43#include <asm/asm-compat.h>
44#include <asm/synch.h>
45
46/*
47 * clear_bit doesn't imply a memory barrier
48 */
49#define smp_mb__before_clear_bit() smp_mb()
50#define smp_mb__after_clear_bit() smp_mb()
51
52#define BITOP_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
53#define BITOP_WORD(nr) ((nr) / BITS_PER_LONG)
54#define BITOP_LE_SWIZZLE ((BITS_PER_LONG-1) & ~0x7)
55
56static __inline__ void set_bit(int nr, volatile unsigned long *addr)
57{
58 unsigned long old;
59 unsigned long mask = BITOP_MASK(nr);
60 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
61
62 __asm__ __volatile__(
63"1:" PPC_LLARX "%0,0,%3 # set_bit\n"
64 "or %0,%0,%2\n"
65 PPC405_ERR77(0,%3)
66 PPC_STLCX "%0,0,%3\n"
67 "bne- 1b"
68 : "=&r"(old), "=m"(*p)
69 : "r"(mask), "r"(p), "m"(*p)
70 : "cc" );
71}
72
73static __inline__ void clear_bit(int nr, volatile unsigned long *addr)
74{
75 unsigned long old;
76 unsigned long mask = BITOP_MASK(nr);
77 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
78
79 __asm__ __volatile__(
80"1:" PPC_LLARX "%0,0,%3 # clear_bit\n"
81 "andc %0,%0,%2\n"
82 PPC405_ERR77(0,%3)
83 PPC_STLCX "%0,0,%3\n"
84 "bne- 1b"
85 : "=&r"(old), "=m"(*p)
86 : "r"(mask), "r"(p), "m"(*p)
87 : "cc" );
88}
89
90static __inline__ void change_bit(int nr, volatile unsigned long *addr)
91{
92 unsigned long old;
93 unsigned long mask = BITOP_MASK(nr);
94 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
95
96 __asm__ __volatile__(
97"1:" PPC_LLARX "%0,0,%3 # change_bit\n"
98 "xor %0,%0,%2\n"
99 PPC405_ERR77(0,%3)
100 PPC_STLCX "%0,0,%3\n"
101 "bne- 1b"
102 : "=&r"(old), "=m"(*p)
103 : "r"(mask), "r"(p), "m"(*p)
104 : "cc" );
105}
106
107static __inline__ int test_and_set_bit(unsigned long nr,
108 volatile unsigned long *addr)
109{
110 unsigned long old, t;
111 unsigned long mask = BITOP_MASK(nr);
112 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
113
114 __asm__ __volatile__(
115 EIEIO_ON_SMP
116"1:" PPC_LLARX "%0,0,%3 # test_and_set_bit\n"
117 "or %1,%0,%2 \n"
118 PPC405_ERR77(0,%3)
119 PPC_STLCX "%1,0,%3 \n"
120 "bne- 1b"
121 ISYNC_ON_SMP
122 : "=&r" (old), "=&r" (t)
123 : "r" (mask), "r" (p)
124 : "cc", "memory");
125
126 return (old & mask) != 0;
127}
128
129static __inline__ int test_and_clear_bit(unsigned long nr,
130 volatile unsigned long *addr)
131{
132 unsigned long old, t;
133 unsigned long mask = BITOP_MASK(nr);
134 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
135
136 __asm__ __volatile__(
137 EIEIO_ON_SMP
138"1:" PPC_LLARX "%0,0,%3 # test_and_clear_bit\n"
139 "andc %1,%0,%2 \n"
140 PPC405_ERR77(0,%3)
141 PPC_STLCX "%1,0,%3 \n"
142 "bne- 1b"
143 ISYNC_ON_SMP
144 : "=&r" (old), "=&r" (t)
145 : "r" (mask), "r" (p)
146 : "cc", "memory");
147
148 return (old & mask) != 0;
149}
150
151static __inline__ int test_and_change_bit(unsigned long nr,
152 volatile unsigned long *addr)
153{
154 unsigned long old, t;
155 unsigned long mask = BITOP_MASK(nr);
156 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
157
158 __asm__ __volatile__(
159 EIEIO_ON_SMP
160"1:" PPC_LLARX "%0,0,%3 # test_and_change_bit\n"
161 "xor %1,%0,%2 \n"
162 PPC405_ERR77(0,%3)
163 PPC_STLCX "%1,0,%3 \n"
164 "bne- 1b"
165 ISYNC_ON_SMP
166 : "=&r" (old), "=&r" (t)
167 : "r" (mask), "r" (p)
168 : "cc", "memory");
169
170 return (old & mask) != 0;
171}
172
173static __inline__ void set_bits(unsigned long mask, unsigned long *addr)
174{
175 unsigned long old;
176
177 __asm__ __volatile__(
178"1:" PPC_LLARX "%0,0,%3 # set_bits\n"
179 "or %0,%0,%2\n"
180 PPC_STLCX "%0,0,%3\n"
181 "bne- 1b"
182 : "=&r" (old), "=m" (*addr)
183 : "r" (mask), "r" (addr), "m" (*addr)
184 : "cc");
185}
186
187/* Non-atomic versions */
188static __inline__ int test_bit(unsigned long nr,
189 __const__ volatile unsigned long *addr)
190{
191 return 1UL & (addr[BITOP_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
192}
193
194static __inline__ void __set_bit(unsigned long nr,
195 volatile unsigned long *addr)
196{
197 unsigned long mask = BITOP_MASK(nr);
198 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
199
200 *p |= mask;
201}
202
203static __inline__ void __clear_bit(unsigned long nr,
204 volatile unsigned long *addr)
205{
206 unsigned long mask = BITOP_MASK(nr);
207 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
208
209 *p &= ~mask;
210}
211
212static __inline__ void __change_bit(unsigned long nr,
213 volatile unsigned long *addr)
214{
215 unsigned long mask = BITOP_MASK(nr);
216 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
217
218 *p ^= mask;
219}
220
221static __inline__ int __test_and_set_bit(unsigned long nr,
222 volatile unsigned long *addr)
223{
224 unsigned long mask = BITOP_MASK(nr);
225 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
226 unsigned long old = *p;
227
228 *p = old | mask;
229 return (old & mask) != 0;
230}
231
232static __inline__ int __test_and_clear_bit(unsigned long nr,
233 volatile unsigned long *addr)
234{
235 unsigned long mask = BITOP_MASK(nr);
236 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
237 unsigned long old = *p;
238
239 *p = old & ~mask;
240 return (old & mask) != 0;
241}
242
243static __inline__ int __test_and_change_bit(unsigned long nr,
244 volatile unsigned long *addr)
245{
246 unsigned long mask = BITOP_MASK(nr);
247 unsigned long *p = ((unsigned long *)addr) + BITOP_WORD(nr);
248 unsigned long old = *p;
249
250 *p = old ^ mask;
251 return (old & mask) != 0;
252}
253
254/*
255 * Return the zero-based bit position (LE, not IBM bit numbering) of
256 * the most significant 1-bit in a double word.
257 */
258static __inline__ int __ilog2(unsigned long x)
259{
260 int lz;
261
262 asm (PPC_CNTLZL "%0,%1" : "=r" (lz) : "r" (x));
263 return BITS_PER_LONG - 1 - lz;
264}
265
266/*
267 * Determines the bit position of the least significant 0 bit in the
268 * specified double word. The returned bit position will be
269 * zero-based, starting from the right side (63/31 - 0).
270 */
271static __inline__ unsigned long ffz(unsigned long x)
272{
273 /* no zero exists anywhere in the 8 byte area. */
274 if ((x = ~x) == 0)
275 return BITS_PER_LONG;
276
277 /*
278 * Calculate the bit position of the least signficant '1' bit in x
279 * (since x has been changed this will actually be the least signficant
280 * '0' bit in * the original x). Note: (x & -x) gives us a mask that
281 * is the least significant * (RIGHT-most) 1-bit of the value in x.
282 */
283 return __ilog2(x & -x);
284}
285
286static __inline__ int __ffs(unsigned long x)
287{
288 return __ilog2(x & -x);
289}
290
291/*
292 * ffs: find first bit set. This is defined the same way as
293 * the libc and compiler builtin ffs routines, therefore
294 * differs in spirit from the above ffz (man ffs).
295 */
296static __inline__ int ffs(int x)
297{
298 unsigned long i = (unsigned long)x;
299 return __ilog2(i & -i) + 1;
300}
301
302/*
303 * fls: find last (most-significant) bit set.
304 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
305 */
306static __inline__ int fls(unsigned int x)
307{
308 int lz;
309
310 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
311 return 32 - lz;
312}
313
314/*
315 * hweightN: returns the hamming weight (i.e. the number
316 * of bits set) of a N-bit word
317 */
318#define hweight64(x) generic_hweight64(x)
319#define hweight32(x) generic_hweight32(x)
320#define hweight16(x) generic_hweight16(x)
321#define hweight8(x) generic_hweight8(x)
322
323#define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
324unsigned long find_next_zero_bit(const unsigned long *addr,
325 unsigned long size, unsigned long offset);
326/**
327 * find_first_bit - find the first set bit in a memory region
328 * @addr: The address to start the search at
329 * @size: The maximum size to search
330 *
331 * Returns the bit-number of the first set bit, not the number of the byte
332 * containing a bit.
333 */
334#define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
335unsigned long find_next_bit(const unsigned long *addr,
336 unsigned long size, unsigned long offset);
337
338/* Little-endian versions */
339
340static __inline__ int test_le_bit(unsigned long nr,
341 __const__ unsigned long *addr)
342{
343 __const__ unsigned char *tmp = (__const__ unsigned char *) addr;
344 return (tmp[nr >> 3] >> (nr & 7)) & 1;
345}
346
347#define __set_le_bit(nr, addr) \
348 __set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
349#define __clear_le_bit(nr, addr) \
350 __clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
351
352#define test_and_set_le_bit(nr, addr) \
353 test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
354#define test_and_clear_le_bit(nr, addr) \
355 test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
356
357#define __test_and_set_le_bit(nr, addr) \
358 __test_and_set_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
359#define __test_and_clear_le_bit(nr, addr) \
360 __test_and_clear_bit((nr) ^ BITOP_LE_SWIZZLE, (addr))
361
362#define find_first_zero_le_bit(addr, size) find_next_zero_le_bit((addr), (size), 0)
363unsigned long find_next_zero_le_bit(const unsigned long *addr,
364 unsigned long size, unsigned long offset);
365
366/* Bitmap functions for the ext2 filesystem */
367
368#define ext2_set_bit(nr,addr) \
369 __test_and_set_le_bit((nr), (unsigned long*)addr)
370#define ext2_clear_bit(nr, addr) \
371 __test_and_clear_le_bit((nr), (unsigned long*)addr)
372
373#define ext2_set_bit_atomic(lock, nr, addr) \
374 test_and_set_le_bit((nr), (unsigned long*)addr)
375#define ext2_clear_bit_atomic(lock, nr, addr) \
376 test_and_clear_le_bit((nr), (unsigned long*)addr)
377
378#define ext2_test_bit(nr, addr) test_le_bit((nr),(unsigned long*)addr)
379
380#define ext2_find_first_zero_bit(addr, size) \
381 find_first_zero_le_bit((unsigned long*)addr, size)
382#define ext2_find_next_zero_bit(addr, size, off) \
383 find_next_zero_le_bit((unsigned long*)addr, size, off)
384
385/* Bitmap functions for the minix filesystem. */
386
387#define minix_test_and_set_bit(nr,addr) \
388 __test_and_set_le_bit(nr, (unsigned long *)addr)
389#define minix_set_bit(nr,addr) \
390 __set_le_bit(nr, (unsigned long *)addr)
391#define minix_test_and_clear_bit(nr,addr) \
392 __test_and_clear_le_bit(nr, (unsigned long *)addr)
393#define minix_test_bit(nr,addr) \
394 test_le_bit(nr, (unsigned long *)addr)
395
396#define minix_find_first_zero_bit(addr,size) \
397 find_first_zero_le_bit((unsigned long *)addr, size)
398
399/*
400 * Every architecture must define this function. It's the fastest
401 * way of searching a 140-bit bitmap where the first 100 bits are
402 * unlikely to be set. It's guaranteed that at least one of the 140
403 * bits is cleared.
404 */
405static inline int sched_find_first_bit(const unsigned long *b)
406{
407#ifdef CONFIG_PPC64
408 if (unlikely(b[0]))
409 return __ffs(b[0]);
410 if (unlikely(b[1]))
411 return __ffs(b[1]) + 64;
412 return __ffs(b[2]) + 128;
413#else
414 if (unlikely(b[0]))
415 return __ffs(b[0]);
416 if (unlikely(b[1]))
417 return __ffs(b[1]) + 32;
418 if (unlikely(b[2]))
419 return __ffs(b[2]) + 64;
420 if (b[3])
421 return __ffs(b[3]) + 96;
422 return __ffs(b[4]) + 128;
423#endif
424}
425
426#endif /* __KERNEL__ */
427
428#endif /* _ASM_POWERPC_BITOPS_H */
diff --git a/include/asm-powerpc/btext.h b/include/asm-powerpc/btext.h
new file mode 100644
index 000000000000..71cce36bc630
--- /dev/null
+++ b/include/asm-powerpc/btext.h
@@ -0,0 +1,27 @@
1/*
2 * Definitions for using the procedures in btext.c.
3 *
4 * Benjamin Herrenschmidt <benh@kernel.crashing.org>
5 */
6#ifndef __PPC_BTEXT_H
7#define __PPC_BTEXT_H
8#ifdef __KERNEL__
9
10extern void btext_clearscreen(void);
11extern void btext_flushscreen(void);
12
13extern int boot_text_mapped;
14
15extern int btext_initialize(struct device_node *np);
16
17extern void map_boot_text(void);
18extern void init_boot_display(void);
19extern void btext_update_display(unsigned long phys, int width, int height,
20 int depth, int pitch);
21
22extern void btext_drawchar(char c);
23extern void btext_drawstring(const char *str);
24extern void btext_drawhex(unsigned long v);
25
26#endif /* __KERNEL__ */
27#endif /* __PPC_BTEXT_H */
diff --git a/include/asm-powerpc/bug.h b/include/asm-powerpc/bug.h
new file mode 100644
index 000000000000..b001ecb3cd99
--- /dev/null
+++ b/include/asm-powerpc/bug.h
@@ -0,0 +1,70 @@
1#ifndef _ASM_POWERPC_BUG_H
2#define _ASM_POWERPC_BUG_H
3
4#include <asm/asm-compat.h>
5/*
6 * Define an illegal instr to trap on the bug.
7 * We don't use 0 because that marks the end of a function
8 * in the ELF ABI. That's "Boo Boo" in case you wonder...
9 */
10#define BUG_OPCODE .long 0x00b00b00 /* For asm */
11#define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
12
13#ifndef __ASSEMBLY__
14
15struct bug_entry {
16 unsigned long bug_addr;
17 long line;
18 const char *file;
19 const char *function;
20};
21
22struct bug_entry *find_bug(unsigned long bugaddr);
23
24/*
25 * If this bit is set in the line number it means that the trap
26 * is for WARN_ON rather than BUG or BUG_ON.
27 */
28#define BUG_WARNING_TRAP 0x1000000
29
30#ifdef CONFIG_BUG
31
32#define BUG() do { \
33 __asm__ __volatile__( \
34 "1: twi 31,0,0\n" \
35 ".section __bug_table,\"a\"\n" \
36 "\t"PPC_LONG" 1b,%0,%1,%2\n" \
37 ".previous" \
38 : : "i" (__LINE__), "i" (__FILE__), "i" (__FUNCTION__)); \
39} while (0)
40
41#define BUG_ON(x) do { \
42 __asm__ __volatile__( \
43 "1: "PPC_TLNEI" %0,0\n" \
44 ".section __bug_table,\"a\"\n" \
45 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
46 ".previous" \
47 : : "r" ((long)(x)), "i" (__LINE__), \
48 "i" (__FILE__), "i" (__FUNCTION__)); \
49} while (0)
50
51#define WARN_ON(x) do { \
52 __asm__ __volatile__( \
53 "1: "PPC_TLNEI" %0,0\n" \
54 ".section __bug_table,\"a\"\n" \
55 "\t"PPC_LONG" 1b,%1,%2,%3\n" \
56 ".previous" \
57 : : "r" ((long)(x)), \
58 "i" (__LINE__ + BUG_WARNING_TRAP), \
59 "i" (__FILE__), "i" (__FUNCTION__)); \
60} while (0)
61
62#define HAVE_ARCH_BUG
63#define HAVE_ARCH_BUG_ON
64#define HAVE_ARCH_WARN_ON
65#endif /* CONFIG_BUG */
66#endif /* __ASSEMBLY __ */
67
68#include <asm-generic/bug.h>
69
70#endif /* _ASM_POWERPC_BUG_H */
diff --git a/include/asm-powerpc/byteorder.h b/include/asm-powerpc/byteorder.h
new file mode 100644
index 000000000000..b37752214a16
--- /dev/null
+++ b/include/asm-powerpc/byteorder.h
@@ -0,0 +1,89 @@
1#ifndef _ASM_POWERPC_BYTEORDER_H
2#define _ASM_POWERPC_BYTEORDER_H
3
4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#include <asm/types.h>
12#include <linux/compiler.h>
13
14#ifdef __GNUC__
15#ifdef __KERNEL__
16
17static __inline__ __u16 ld_le16(const volatile __u16 *addr)
18{
19 __u16 val;
20
21 __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
22 return val;
23}
24
25static __inline__ void st_le16(volatile __u16 *addr, const __u16 val)
26{
27 __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
28}
29
30static __inline__ __u32 ld_le32(const volatile __u32 *addr)
31{
32 __u32 val;
33
34 __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" (addr), "m" (*addr));
35 return val;
36}
37
38static __inline__ void st_le32(volatile __u32 *addr, const __u32 val)
39{
40 __asm__ __volatile__ ("stwbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr));
41}
42
43static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 value)
44{
45 __u16 result;
46
47 __asm__("rlwimi %0,%1,8,16,23"
48 : "=r" (result)
49 : "r" (value), "0" (value >> 8));
50 return result;
51}
52
53static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 value)
54{
55 __u32 result;
56
57 __asm__("rlwimi %0,%1,24,16,23\n\t"
58 "rlwimi %0,%1,8,8,15\n\t"
59 "rlwimi %0,%1,24,0,7"
60 : "=r" (result)
61 : "r" (value), "0" (value >> 24));
62 return result;
63}
64
65#define __arch__swab16(x) ___arch__swab16(x)
66#define __arch__swab32(x) ___arch__swab32(x)
67
68/* The same, but returns converted value from the location pointer by addr. */
69#define __arch__swab16p(addr) ld_le16(addr)
70#define __arch__swab32p(addr) ld_le32(addr)
71
72/* The same, but do the conversion in situ, ie. put the value back to addr. */
73#define __arch__swab16s(addr) st_le16(addr,*addr)
74#define __arch__swab32s(addr) st_le32(addr,*addr)
75
76#endif /* __KERNEL__ */
77
78#ifndef __STRICT_ANSI__
79#define __BYTEORDER_HAS_U64__
80#ifndef __powerpc64__
81#define __SWAB_64_THRU_32__
82#endif /* __powerpc64__ */
83#endif /* __STRICT_ANSI__ */
84
85#endif /* __GNUC__ */
86
87#include <linux/byteorder/big_endian.h>
88
89#endif /* _ASM_POWERPC_BYTEORDER_H */
diff --git a/include/asm-powerpc/cache.h b/include/asm-powerpc/cache.h
new file mode 100644
index 000000000000..26ce502e76e8
--- /dev/null
+++ b/include/asm-powerpc/cache.h
@@ -0,0 +1,40 @@
1#ifndef _ASM_POWERPC_CACHE_H
2#define _ASM_POWERPC_CACHE_H
3
4#ifdef __KERNEL__
5
6#include <linux/config.h>
7
8/* bytes per L1 cache line */
9#if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
10#define L1_CACHE_SHIFT 4
11#define MAX_COPY_PREFETCH 1
12#elif defined(CONFIG_PPC32)
13#define L1_CACHE_SHIFT 5
14#define MAX_COPY_PREFETCH 4
15#else /* CONFIG_PPC64 */
16#define L1_CACHE_SHIFT 7
17#endif
18
19#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
20
21#define SMP_CACHE_BYTES L1_CACHE_BYTES
22#define L1_CACHE_SHIFT_MAX 7 /* largest L1 which this arch supports */
23
24#if defined(__powerpc64__) && !defined(__ASSEMBLY__)
25struct ppc64_caches {
26 u32 dsize; /* L1 d-cache size */
27 u32 dline_size; /* L1 d-cache line size */
28 u32 log_dline_size;
29 u32 dlines_per_page;
30 u32 isize; /* L1 i-cache size */
31 u32 iline_size; /* L1 i-cache line size */
32 u32 log_iline_size;
33 u32 ilines_per_page;
34};
35
36extern struct ppc64_caches ppc64_caches;
37#endif /* __powerpc64__ && ! __ASSEMBLY__ */
38
39#endif /* __KERNEL__ */
40#endif /* _ASM_POWERPC_CACHE_H */
diff --git a/include/asm-powerpc/cacheflush.h b/include/asm-powerpc/cacheflush.h
new file mode 100644
index 000000000000..8a740c88d93d
--- /dev/null
+++ b/include/asm-powerpc/cacheflush.h
@@ -0,0 +1,68 @@
1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version
5 * 2 of the License, or (at your option) any later version.
6 */
7#ifndef _ASM_POWERPC_CACHEFLUSH_H
8#define _ASM_POWERPC_CACHEFLUSH_H
9
10#ifdef __KERNEL__
11
12#include <linux/mm.h>
13#include <asm/cputable.h>
14
15/*
16 * No cache flushing is required when address mappings are changed,
17 * because the caches on PowerPCs are physically addressed.
18 */
19#define flush_cache_all() do { } while (0)
20#define flush_cache_mm(mm) do { } while (0)
21#define flush_cache_range(vma, start, end) do { } while (0)
22#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
23#define flush_icache_page(vma, page) do { } while (0)
24#define flush_cache_vmap(start, end) do { } while (0)
25#define flush_cache_vunmap(start, end) do { } while (0)
26
27extern void flush_dcache_page(struct page *page);
28#define flush_dcache_mmap_lock(mapping) do { } while (0)
29#define flush_dcache_mmap_unlock(mapping) do { } while (0)
30
31extern void __flush_icache_range(unsigned long, unsigned long);
32static inline void flush_icache_range(unsigned long start, unsigned long stop)
33{
34 if (!cpu_has_feature(CPU_FTR_COHERENT_ICACHE))
35 __flush_icache_range(start, stop);
36}
37
38extern void flush_icache_user_range(struct vm_area_struct *vma,
39 struct page *page, unsigned long addr,
40 int len);
41extern void __flush_dcache_icache(void *page_va);
42extern void flush_dcache_icache_page(struct page *page);
43#if defined(CONFIG_PPC32) && !defined(CONFIG_BOOKE)
44extern void __flush_dcache_icache_phys(unsigned long physaddr);
45#endif /* CONFIG_PPC32 && !CONFIG_BOOKE */
46
47extern void flush_dcache_range(unsigned long start, unsigned long stop);
48#ifdef CONFIG_PPC32
49extern void clean_dcache_range(unsigned long start, unsigned long stop);
50extern void invalidate_dcache_range(unsigned long start, unsigned long stop);
51#endif /* CONFIG_PPC32 */
52#ifdef CONFIG_PPC64
53extern void flush_inval_dcache_range(unsigned long start, unsigned long stop);
54extern void flush_dcache_phys_range(unsigned long start, unsigned long stop);
55#endif
56
57#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
58 do { \
59 memcpy(dst, src, len); \
60 flush_icache_user_range(vma, page, vaddr, len); \
61 } while (0)
62#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
63 memcpy(dst, src, len)
64
65
66#endif /* __KERNEL__ */
67
68#endif /* _ASM_POWERPC_CACHEFLUSH_H */
diff --git a/include/asm-powerpc/checksum.h b/include/asm-powerpc/checksum.h
new file mode 100644
index 000000000000..d8354d8a49ce
--- /dev/null
+++ b/include/asm-powerpc/checksum.h
@@ -0,0 +1,132 @@
1#ifndef _ASM_POWERPC_CHECKSUM_H
2#define _ASM_POWERPC_CHECKSUM_H
3
4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11/*
12 * This is a version of ip_compute_csum() optimized for IP headers,
13 * which always checksum on 4 octet boundaries. ihl is the number
14 * of 32-bit words and is always >= 5.
15 */
16extern unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl);
17
18/*
19 * computes the checksum of the TCP/UDP pseudo-header
20 * returns a 16-bit checksum, already complemented
21 */
22extern unsigned short csum_tcpudp_magic(unsigned long saddr,
23 unsigned long daddr,
24 unsigned short len,
25 unsigned short proto,
26 unsigned int sum);
27
28/*
29 * computes the checksum of a memory block at buff, length len,
30 * and adds in "sum" (32-bit)
31 *
32 * returns a 32-bit number suitable for feeding into itself
33 * or csum_tcpudp_magic
34 *
35 * this function must be called with even lengths, except
36 * for the last fragment, which may be odd
37 *
38 * it's best to have buff aligned on a 32-bit boundary
39 */
40extern unsigned int csum_partial(const unsigned char * buff, int len,
41 unsigned int sum);
42
43/*
44 * Computes the checksum of a memory block at src, length len,
45 * and adds in "sum" (32-bit), while copying the block to dst.
46 * If an access exception occurs on src or dst, it stores -EFAULT
47 * to *src_err or *dst_err respectively (if that pointer is not
48 * NULL), and, for an error on src, zeroes the rest of dst.
49 *
50 * Like csum_partial, this must be called with even lengths,
51 * except for the last fragment.
52 */
53extern unsigned int csum_partial_copy_generic(const char *src, char *dst,
54 int len, unsigned int sum,
55 int *src_err, int *dst_err);
56/*
57 * the same as csum_partial, but copies from src to dst while it
58 * checksums.
59 */
60unsigned int csum_partial_copy_nocheck(const char *src,
61 char *dst,
62 int len,
63 unsigned int sum);
64
65#define csum_partial_copy_from_user(src, dst, len, sum, errp) \
66 csum_partial_copy_generic((src), (dst), (len), (sum), (errp), NULL)
67
68#define csum_partial_copy_nocheck(src, dst, len, sum) \
69 csum_partial_copy_generic((src), (dst), (len), (sum), NULL, NULL)
70
71
72/*
73 * turns a 32-bit partial checksum (e.g. from csum_partial) into a
74 * 1's complement 16-bit checksum.
75 */
76static inline unsigned int csum_fold(unsigned int sum)
77{
78 unsigned int tmp;
79
80 /* swap the two 16-bit halves of sum */
81 __asm__("rlwinm %0,%1,16,0,31" : "=r" (tmp) : "r" (sum));
82 /* if there is a carry from adding the two 16-bit halves,
83 it will carry from the lower half into the upper half,
84 giving us the correct sum in the upper half. */
85 sum = ~(sum + tmp) >> 16;
86 return sum;
87}
88
89/*
90 * this routine is used for miscellaneous IP-like checksums, mainly
91 * in icmp.c
92 */
93static inline unsigned short ip_compute_csum(unsigned char * buff, int len)
94{
95 return csum_fold(csum_partial(buff, len, 0));
96}
97
98#ifdef __powerpc64__
99static inline u32 csum_tcpudp_nofold(u32 saddr,
100 u32 daddr,
101 unsigned short len,
102 unsigned short proto,
103 unsigned int sum)
104{
105 unsigned long s = sum;
106
107 s += saddr;
108 s += daddr;
109 s += (proto << 16) + len;
110 s += (s >> 32);
111 return (u32) s;
112}
113#else
114static inline unsigned long csum_tcpudp_nofold(unsigned long saddr,
115 unsigned long daddr,
116 unsigned short len,
117 unsigned short proto,
118 unsigned int sum)
119{
120 __asm__("\n\
121 addc %0,%0,%1 \n\
122 adde %0,%0,%2 \n\
123 adde %0,%0,%3 \n\
124 addze %0,%0 \n\
125 "
126 : "=r" (sum)
127 : "r" (daddr), "r"(saddr), "r"((proto<<16)+len), "0"(sum));
128 return sum;
129}
130
131#endif
132#endif
diff --git a/include/asm-powerpc/compat.h b/include/asm-powerpc/compat.h
new file mode 100644
index 000000000000..4db4360c4d4a
--- /dev/null
+++ b/include/asm-powerpc/compat.h
@@ -0,0 +1,205 @@
1#ifndef _ASM_POWERPC_COMPAT_H
2#define _ASM_POWERPC_COMPAT_H
3/*
4 * Architecture specific compatibility types
5 */
6#include <linux/types.h>
7#include <linux/sched.h>
8
9#define COMPAT_USER_HZ 100
10
11typedef u32 compat_size_t;
12typedef s32 compat_ssize_t;
13typedef s32 compat_time_t;
14typedef s32 compat_clock_t;
15typedef s32 compat_pid_t;
16typedef u32 __compat_uid_t;
17typedef u32 __compat_gid_t;
18typedef u32 __compat_uid32_t;
19typedef u32 __compat_gid32_t;
20typedef u32 compat_mode_t;
21typedef u32 compat_ino_t;
22typedef u32 compat_dev_t;
23typedef s32 compat_off_t;
24typedef s64 compat_loff_t;
25typedef s16 compat_nlink_t;
26typedef u16 compat_ipc_pid_t;
27typedef s32 compat_daddr_t;
28typedef u32 compat_caddr_t;
29typedef __kernel_fsid_t compat_fsid_t;
30typedef s32 compat_key_t;
31typedef s32 compat_timer_t;
32
33typedef s32 compat_int_t;
34typedef s32 compat_long_t;
35typedef u32 compat_uint_t;
36typedef u32 compat_ulong_t;
37
38struct compat_timespec {
39 compat_time_t tv_sec;
40 s32 tv_nsec;
41};
42
43struct compat_timeval {
44 compat_time_t tv_sec;
45 s32 tv_usec;
46};
47
48struct compat_stat {
49 compat_dev_t st_dev;
50 compat_ino_t st_ino;
51 compat_mode_t st_mode;
52 compat_nlink_t st_nlink;
53 __compat_uid32_t st_uid;
54 __compat_gid32_t st_gid;
55 compat_dev_t st_rdev;
56 compat_off_t st_size;
57 compat_off_t st_blksize;
58 compat_off_t st_blocks;
59 compat_time_t st_atime;
60 u32 st_atime_nsec;
61 compat_time_t st_mtime;
62 u32 st_mtime_nsec;
63 compat_time_t st_ctime;
64 u32 st_ctime_nsec;
65 u32 __unused4[2];
66};
67
68struct compat_flock {
69 short l_type;
70 short l_whence;
71 compat_off_t l_start;
72 compat_off_t l_len;
73 compat_pid_t l_pid;
74};
75
76#define F_GETLK64 12 /* using 'struct flock64' */
77#define F_SETLK64 13
78#define F_SETLKW64 14
79
80struct compat_flock64 {
81 short l_type;
82 short l_whence;
83 compat_loff_t l_start;
84 compat_loff_t l_len;
85 compat_pid_t l_pid;
86};
87
88struct compat_statfs {
89 int f_type;
90 int f_bsize;
91 int f_blocks;
92 int f_bfree;
93 int f_bavail;
94 int f_files;
95 int f_ffree;
96 compat_fsid_t f_fsid;
97 int f_namelen; /* SunOS ignores this field. */
98 int f_frsize;
99 int f_spare[5];
100};
101
102#define COMPAT_RLIM_OLD_INFINITY 0x7fffffff
103#define COMPAT_RLIM_INFINITY 0xffffffff
104
105typedef u32 compat_old_sigset_t;
106
107#define _COMPAT_NSIG 64
108#define _COMPAT_NSIG_BPW 32
109
110typedef u32 compat_sigset_word;
111
112#define COMPAT_OFF_T_MAX 0x7fffffff
113#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
114
115/*
116 * A pointer passed in from user mode. This should not
117 * be used for syscall parameters, just declare them
118 * as pointers because the syscall entry code will have
119 * appropriately comverted them already.
120 */
121typedef u32 compat_uptr_t;
122
123static inline void __user *compat_ptr(compat_uptr_t uptr)
124{
125 return (void __user *)(unsigned long)uptr;
126}
127
128static inline void __user *compat_alloc_user_space(long len)
129{
130 struct pt_regs *regs = current->thread.regs;
131 unsigned long usp = regs->gpr[1];
132
133 /*
134 * We cant access below the stack pointer in the 32bit ABI and
135 * can access 288 bytes in the 64bit ABI
136 */
137 if (!(test_thread_flag(TIF_32BIT)))
138 usp -= 288;
139
140 return (void __user *) (usp - len);
141}
142
143/*
144 * ipc64_perm is actually 32/64bit clean but since the compat layer refers to
145 * it we may as well define it.
146 */
147struct compat_ipc64_perm {
148 compat_key_t key;
149 __compat_uid_t uid;
150 __compat_gid_t gid;
151 __compat_uid_t cuid;
152 __compat_gid_t cgid;
153 compat_mode_t mode;
154 unsigned int seq;
155 unsigned int __pad2;
156 unsigned long __unused1; /* yes they really are 64bit pads */
157 unsigned long __unused2;
158};
159
160struct compat_semid64_ds {
161 struct compat_ipc64_perm sem_perm;
162 unsigned int __unused1;
163 compat_time_t sem_otime;
164 unsigned int __unused2;
165 compat_time_t sem_ctime;
166 compat_ulong_t sem_nsems;
167 compat_ulong_t __unused3;
168 compat_ulong_t __unused4;
169};
170
171struct compat_msqid64_ds {
172 struct compat_ipc64_perm msg_perm;
173 unsigned int __unused1;
174 compat_time_t msg_stime;
175 unsigned int __unused2;
176 compat_time_t msg_rtime;
177 unsigned int __unused3;
178 compat_time_t msg_ctime;
179 compat_ulong_t msg_cbytes;
180 compat_ulong_t msg_qnum;
181 compat_ulong_t msg_qbytes;
182 compat_pid_t msg_lspid;
183 compat_pid_t msg_lrpid;
184 compat_ulong_t __unused4;
185 compat_ulong_t __unused5;
186};
187
188struct compat_shmid64_ds {
189 struct compat_ipc64_perm shm_perm;
190 unsigned int __unused1;
191 compat_time_t shm_atime;
192 unsigned int __unused2;
193 compat_time_t shm_dtime;
194 unsigned int __unused3;
195 compat_time_t shm_ctime;
196 unsigned int __unused4;
197 compat_size_t shm_segsz;
198 compat_pid_t shm_cpid;
199 compat_pid_t shm_lpid;
200 compat_ulong_t shm_nattch;
201 compat_ulong_t __unused5;
202 compat_ulong_t __unused6;
203};
204
205#endif /* _ASM_POWERPC_COMPAT_H */
diff --git a/include/asm-powerpc/cputable.h b/include/asm-powerpc/cputable.h
new file mode 100644
index 000000000000..d1cfa3f515ea
--- /dev/null
+++ b/include/asm-powerpc/cputable.h
@@ -0,0 +1,436 @@
1#ifndef __ASM_POWERPC_CPUTABLE_H
2#define __ASM_POWERPC_CPUTABLE_H
3
4#include <linux/config.h>
5#include <asm/asm-compat.h>
6
7#define PPC_FEATURE_32 0x80000000
8#define PPC_FEATURE_64 0x40000000
9#define PPC_FEATURE_601_INSTR 0x20000000
10#define PPC_FEATURE_HAS_ALTIVEC 0x10000000
11#define PPC_FEATURE_HAS_FPU 0x08000000
12#define PPC_FEATURE_HAS_MMU 0x04000000
13#define PPC_FEATURE_HAS_4xxMAC 0x02000000
14#define PPC_FEATURE_UNIFIED_CACHE 0x01000000
15#define PPC_FEATURE_HAS_SPE 0x00800000
16#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000
17#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000
18#define PPC_FEATURE_NO_TB 0x00100000
19#define PPC_FEATURE_POWER4 0x00080000
20#define PPC_FEATURE_POWER5 0x00040000
21#define PPC_FEATURE_POWER5_PLUS 0x00020000
22#define PPC_FEATURE_CELL 0x00010000
23
24#ifdef __KERNEL__
25#ifndef __ASSEMBLY__
26
27/* This structure can grow, it's real size is used by head.S code
28 * via the mkdefs mechanism.
29 */
30struct cpu_spec;
31struct op_powerpc_model;
32
33typedef void (*cpu_setup_t)(unsigned long offset, struct cpu_spec* spec);
34
35struct cpu_spec {
36 /* CPU is matched via (PVR & pvr_mask) == pvr_value */
37 unsigned int pvr_mask;
38 unsigned int pvr_value;
39
40 char *cpu_name;
41 unsigned long cpu_features; /* Kernel features */
42 unsigned int cpu_user_features; /* Userland features */
43
44 /* cache line sizes */
45 unsigned int icache_bsize;
46 unsigned int dcache_bsize;
47
48 /* number of performance monitor counters */
49 unsigned int num_pmcs;
50
51 /* this is called to initialize various CPU bits like L1 cache,
52 * BHT, SPD, etc... from head.S before branching to identify_machine
53 */
54 cpu_setup_t cpu_setup;
55
56 /* Used by oprofile userspace to select the right counters */
57 char *oprofile_cpu_type;
58
59 /* Processor specific oprofile operations */
60 struct op_powerpc_model *oprofile_model;
61};
62
63extern struct cpu_spec *cur_cpu_spec;
64
65extern void identify_cpu(unsigned long offset, unsigned long cpu);
66extern void do_cpu_ftr_fixups(unsigned long offset);
67
68#endif /* __ASSEMBLY__ */
69
70/* CPU kernel features */
71
72/* Retain the 32b definitions all use bottom half of word */
73#define CPU_FTR_SPLIT_ID_CACHE ASM_CONST(0x0000000000000001)
74#define CPU_FTR_L2CR ASM_CONST(0x0000000000000002)
75#define CPU_FTR_SPEC7450 ASM_CONST(0x0000000000000004)
76#define CPU_FTR_ALTIVEC ASM_CONST(0x0000000000000008)
77#define CPU_FTR_TAU ASM_CONST(0x0000000000000010)
78#define CPU_FTR_CAN_DOZE ASM_CONST(0x0000000000000020)
79#define CPU_FTR_USE_TB ASM_CONST(0x0000000000000040)
80#define CPU_FTR_604_PERF_MON ASM_CONST(0x0000000000000080)
81#define CPU_FTR_601 ASM_CONST(0x0000000000000100)
82#define CPU_FTR_HPTE_TABLE ASM_CONST(0x0000000000000200)
83#define CPU_FTR_CAN_NAP ASM_CONST(0x0000000000000400)
84#define CPU_FTR_L3CR ASM_CONST(0x0000000000000800)
85#define CPU_FTR_L3_DISABLE_NAP ASM_CONST(0x0000000000001000)
86#define CPU_FTR_NAP_DISABLE_L2_PR ASM_CONST(0x0000000000002000)
87#define CPU_FTR_DUAL_PLL_750FX ASM_CONST(0x0000000000004000)
88#define CPU_FTR_NO_DPM ASM_CONST(0x0000000000008000)
89#define CPU_FTR_HAS_HIGH_BATS ASM_CONST(0x0000000000010000)
90#define CPU_FTR_NEED_COHERENT ASM_CONST(0x0000000000020000)
91#define CPU_FTR_NO_BTIC ASM_CONST(0x0000000000040000)
92#define CPU_FTR_BIG_PHYS ASM_CONST(0x0000000000080000)
93#define CPU_FTR_NODSISRALIGN ASM_CONST(0x0000000000100000)
94
95#ifdef __powerpc64__
96/* Add the 64b processor unique features in the top half of the word */
97#define CPU_FTR_SLB ASM_CONST(0x0000000100000000)
98#define CPU_FTR_16M_PAGE ASM_CONST(0x0000000200000000)
99#define CPU_FTR_TLBIEL ASM_CONST(0x0000000400000000)
100#define CPU_FTR_NOEXECUTE ASM_CONST(0x0000000800000000)
101#define CPU_FTR_IABR ASM_CONST(0x0000002000000000)
102#define CPU_FTR_MMCRA ASM_CONST(0x0000004000000000)
103#define CPU_FTR_CTRL ASM_CONST(0x0000008000000000)
104#define CPU_FTR_SMT ASM_CONST(0x0000010000000000)
105#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0000020000000000)
106#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0000040000000000)
107#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0000080000000000)
108#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0000100000000000)
109#else
110/* ensure on 32b processors the flags are available for compiling but
111 * don't do anything */
112#define CPU_FTR_SLB ASM_CONST(0x0)
113#define CPU_FTR_16M_PAGE ASM_CONST(0x0)
114#define CPU_FTR_TLBIEL ASM_CONST(0x0)
115#define CPU_FTR_NOEXECUTE ASM_CONST(0x0)
116#define CPU_FTR_IABR ASM_CONST(0x0)
117#define CPU_FTR_MMCRA ASM_CONST(0x0)
118#define CPU_FTR_CTRL ASM_CONST(0x0)
119#define CPU_FTR_SMT ASM_CONST(0x0)
120#define CPU_FTR_COHERENT_ICACHE ASM_CONST(0x0)
121#define CPU_FTR_LOCKLESS_TLBIE ASM_CONST(0x0)
122#define CPU_FTR_MMCRA_SIHV ASM_CONST(0x0)
123#define CPU_FTR_CI_LARGE_PAGE ASM_CONST(0x0)
124#endif
125
126#ifndef __ASSEMBLY__
127
128#define CPU_FTR_PPCAS_ARCH_V2_BASE (CPU_FTR_SLB | \
129 CPU_FTR_TLBIEL | CPU_FTR_NOEXECUTE | \
130 CPU_FTR_NODSISRALIGN | CPU_FTR_CTRL)
131
132/* iSeries doesn't support large pages */
133#ifdef CONFIG_PPC_ISERIES
134#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE)
135#else
136#define CPU_FTR_PPCAS_ARCH_V2 (CPU_FTR_PPCAS_ARCH_V2_BASE | CPU_FTR_16M_PAGE)
137#endif /* CONFIG_PPC_ISERIES */
138
139/* We only set the altivec features if the kernel was compiled with altivec
140 * support
141 */
142#ifdef CONFIG_ALTIVEC
143#define CPU_FTR_ALTIVEC_COMP CPU_FTR_ALTIVEC
144#define PPC_FEATURE_HAS_ALTIVEC_COMP PPC_FEATURE_HAS_ALTIVEC
145#else
146#define CPU_FTR_ALTIVEC_COMP 0
147#define PPC_FEATURE_HAS_ALTIVEC_COMP 0
148#endif
149
150/* We need to mark all pages as being coherent if we're SMP or we
151 * have a 74[45]x and an MPC107 host bridge.
152 */
153#if defined(CONFIG_SMP) || defined(CONFIG_MPC10X_BRIDGE)
154#define CPU_FTR_COMMON CPU_FTR_NEED_COHERENT
155#else
156#define CPU_FTR_COMMON 0
157#endif
158
159/* The powersave features NAP & DOZE seems to confuse BDI when
160 debugging. So if a BDI is used, disable theses
161 */
162#ifndef CONFIG_BDI_SWITCH
163#define CPU_FTR_MAYBE_CAN_DOZE CPU_FTR_CAN_DOZE
164#define CPU_FTR_MAYBE_CAN_NAP CPU_FTR_CAN_NAP
165#else
166#define CPU_FTR_MAYBE_CAN_DOZE 0
167#define CPU_FTR_MAYBE_CAN_NAP 0
168#endif
169
170#define CLASSIC_PPC (!defined(CONFIG_8xx) && !defined(CONFIG_4xx) && \
171 !defined(CONFIG_POWER3) && !defined(CONFIG_POWER4) && \
172 !defined(CONFIG_BOOKE))
173
174enum {
175 CPU_FTRS_PPC601 = CPU_FTR_COMMON | CPU_FTR_601 | CPU_FTR_HPTE_TABLE,
176 CPU_FTRS_603 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
177 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB |
178 CPU_FTR_MAYBE_CAN_NAP,
179 CPU_FTRS_604 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
180 CPU_FTR_USE_TB | CPU_FTR_604_PERF_MON | CPU_FTR_HPTE_TABLE,
181 CPU_FTRS_740_NOTAU = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
182 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
183 CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
184 CPU_FTRS_740 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
185 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
186 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
187 CPU_FTRS_750 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
188 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
189 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP,
190 CPU_FTRS_750FX1 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
191 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
192 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
193 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_NO_DPM,
194 CPU_FTRS_750FX2 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
195 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
196 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
197 CPU_FTR_NO_DPM,
198 CPU_FTRS_750FX = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
199 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
200 CPU_FTR_TAU | CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
201 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
202 CPU_FTRS_750GX = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
203 CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_TAU |
204 CPU_FTR_HPTE_TABLE | CPU_FTR_MAYBE_CAN_NAP |
205 CPU_FTR_DUAL_PLL_750FX | CPU_FTR_HAS_HIGH_BATS,
206 CPU_FTRS_7400_NOTAU = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
207 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
208 CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
209 CPU_FTR_MAYBE_CAN_NAP,
210 CPU_FTRS_7400 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
211 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB | CPU_FTR_L2CR |
212 CPU_FTR_TAU | CPU_FTR_ALTIVEC_COMP | CPU_FTR_HPTE_TABLE |
213 CPU_FTR_MAYBE_CAN_NAP,
214 CPU_FTRS_7450_20 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
215 CPU_FTR_USE_TB | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
216 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
217 CPU_FTR_NEED_COHERENT,
218 CPU_FTRS_7450_21 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
219 CPU_FTR_USE_TB |
220 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
221 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
222 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP |
223 CPU_FTR_NEED_COHERENT,
224 CPU_FTRS_7450_23 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
225 CPU_FTR_USE_TB |
226 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
227 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
228 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_NEED_COHERENT,
229 CPU_FTRS_7455_1 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
230 CPU_FTR_USE_TB |
231 CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP | CPU_FTR_L3CR |
232 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 | CPU_FTR_HAS_HIGH_BATS |
233 CPU_FTR_NEED_COHERENT,
234 CPU_FTRS_7455_20 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
235 CPU_FTR_USE_TB |
236 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
237 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
238 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_L3_DISABLE_NAP |
239 CPU_FTR_NEED_COHERENT | CPU_FTR_HAS_HIGH_BATS,
240 CPU_FTRS_7455 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
241 CPU_FTR_USE_TB |
242 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
243 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
244 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
245 CPU_FTR_NEED_COHERENT,
246 CPU_FTRS_7447_10 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
247 CPU_FTR_USE_TB |
248 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
249 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
250 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
251 CPU_FTR_NEED_COHERENT | CPU_FTR_NO_BTIC,
252 CPU_FTRS_7447 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
253 CPU_FTR_USE_TB |
254 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
255 CPU_FTR_L3CR | CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
256 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
257 CPU_FTR_NEED_COHERENT,
258 CPU_FTRS_7447A = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
259 CPU_FTR_USE_TB |
260 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_L2CR | CPU_FTR_ALTIVEC_COMP |
261 CPU_FTR_HPTE_TABLE | CPU_FTR_SPEC7450 |
262 CPU_FTR_NAP_DISABLE_L2_PR | CPU_FTR_HAS_HIGH_BATS |
263 CPU_FTR_NEED_COHERENT,
264 CPU_FTRS_82XX = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
265 CPU_FTR_MAYBE_CAN_DOZE | CPU_FTR_USE_TB,
266 CPU_FTRS_G2_LE = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
267 CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_HAS_HIGH_BATS,
268 CPU_FTRS_E300 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_MAYBE_CAN_DOZE |
269 CPU_FTR_USE_TB | CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_HAS_HIGH_BATS,
270 CPU_FTRS_CLASSIC32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
271 CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
272 CPU_FTRS_POWER3_32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
273 CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE,
274 CPU_FTRS_POWER4_32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
275 CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_NODSISRALIGN,
276 CPU_FTRS_970_32 = CPU_FTR_COMMON | CPU_FTR_SPLIT_ID_CACHE |
277 CPU_FTR_USE_TB | CPU_FTR_HPTE_TABLE | CPU_FTR_ALTIVEC_COMP |
278 CPU_FTR_MAYBE_CAN_NAP | CPU_FTR_NODSISRALIGN,
279 CPU_FTRS_8XX = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB,
280 CPU_FTRS_40X = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
281 CPU_FTR_NODSISRALIGN,
282 CPU_FTRS_44X = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
283 CPU_FTR_NODSISRALIGN,
284 CPU_FTRS_E200 = CPU_FTR_USE_TB | CPU_FTR_NODSISRALIGN,
285 CPU_FTRS_E500 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
286 CPU_FTR_NODSISRALIGN,
287 CPU_FTRS_E500_2 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
288 CPU_FTR_BIG_PHYS | CPU_FTR_NODSISRALIGN,
289 CPU_FTRS_GENERIC_32 = CPU_FTR_COMMON | CPU_FTR_NODSISRALIGN,
290#ifdef __powerpc64__
291 CPU_FTRS_POWER3 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
292 CPU_FTR_HPTE_TABLE | CPU_FTR_IABR,
293 CPU_FTRS_RS64 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
294 CPU_FTR_HPTE_TABLE | CPU_FTR_IABR |
295 CPU_FTR_MMCRA | CPU_FTR_CTRL,
296 CPU_FTRS_POWER4 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
297 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_MMCRA,
298 CPU_FTRS_PPC970 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
299 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
300 CPU_FTR_ALTIVEC_COMP | CPU_FTR_CAN_NAP | CPU_FTR_MMCRA,
301 CPU_FTRS_POWER5 = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
302 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
303 CPU_FTR_MMCRA | CPU_FTR_SMT |
304 CPU_FTR_COHERENT_ICACHE | CPU_FTR_LOCKLESS_TLBIE |
305 CPU_FTR_MMCRA_SIHV,
306 CPU_FTRS_CELL = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
307 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2 |
308 CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT,
309 CPU_FTRS_COMPATIBLE = CPU_FTR_SPLIT_ID_CACHE | CPU_FTR_USE_TB |
310 CPU_FTR_HPTE_TABLE | CPU_FTR_PPCAS_ARCH_V2,
311#endif
312
313 CPU_FTRS_POSSIBLE =
314#if CLASSIC_PPC
315 CPU_FTRS_PPC601 | CPU_FTRS_603 | CPU_FTRS_604 | CPU_FTRS_740_NOTAU |
316 CPU_FTRS_740 | CPU_FTRS_750 | CPU_FTRS_750FX1 |
317 CPU_FTRS_750FX2 | CPU_FTRS_750FX | CPU_FTRS_750GX |
318 CPU_FTRS_7400_NOTAU | CPU_FTRS_7400 | CPU_FTRS_7450_20 |
319 CPU_FTRS_7450_21 | CPU_FTRS_7450_23 | CPU_FTRS_7455_1 |
320 CPU_FTRS_7455_20 | CPU_FTRS_7455 | CPU_FTRS_7447_10 |
321 CPU_FTRS_7447 | CPU_FTRS_7447A | CPU_FTRS_82XX |
322 CPU_FTRS_G2_LE | CPU_FTRS_E300 | CPU_FTRS_CLASSIC32 |
323#else
324 CPU_FTRS_GENERIC_32 |
325#endif
326#ifdef CONFIG_PPC64BRIDGE
327 CPU_FTRS_POWER3_32 |
328#endif
329#ifdef CONFIG_POWER4
330 CPU_FTRS_POWER4_32 | CPU_FTRS_970_32 |
331#endif
332#ifdef CONFIG_8xx
333 CPU_FTRS_8XX |
334#endif
335#ifdef CONFIG_40x
336 CPU_FTRS_40X |
337#endif
338#ifdef CONFIG_44x
339 CPU_FTRS_44X |
340#endif
341#ifdef CONFIG_E200
342 CPU_FTRS_E200 |
343#endif
344#ifdef CONFIG_E500
345 CPU_FTRS_E500 | CPU_FTRS_E500_2 |
346#endif
347#ifdef __powerpc64__
348 CPU_FTRS_POWER3 | CPU_FTRS_RS64 | CPU_FTRS_POWER4 |
349 CPU_FTRS_PPC970 | CPU_FTRS_POWER5 | CPU_FTRS_CELL |
350 CPU_FTR_CI_LARGE_PAGE |
351#endif
352 0,
353
354 CPU_FTRS_ALWAYS =
355#if CLASSIC_PPC
356 CPU_FTRS_PPC601 & CPU_FTRS_603 & CPU_FTRS_604 & CPU_FTRS_740_NOTAU &
357 CPU_FTRS_740 & CPU_FTRS_750 & CPU_FTRS_750FX1 &
358 CPU_FTRS_750FX2 & CPU_FTRS_750FX & CPU_FTRS_750GX &
359 CPU_FTRS_7400_NOTAU & CPU_FTRS_7400 & CPU_FTRS_7450_20 &
360 CPU_FTRS_7450_21 & CPU_FTRS_7450_23 & CPU_FTRS_7455_1 &
361 CPU_FTRS_7455_20 & CPU_FTRS_7455 & CPU_FTRS_7447_10 &
362 CPU_FTRS_7447 & CPU_FTRS_7447A & CPU_FTRS_82XX &
363 CPU_FTRS_G2_LE & CPU_FTRS_E300 & CPU_FTRS_CLASSIC32 &
364#else
365 CPU_FTRS_GENERIC_32 &
366#endif
367#ifdef CONFIG_PPC64BRIDGE
368 CPU_FTRS_POWER3_32 &
369#endif
370#ifdef CONFIG_POWER4
371 CPU_FTRS_POWER4_32 & CPU_FTRS_970_32 &
372#endif
373#ifdef CONFIG_8xx
374 CPU_FTRS_8XX &
375#endif
376#ifdef CONFIG_40x
377 CPU_FTRS_40X &
378#endif
379#ifdef CONFIG_44x
380 CPU_FTRS_44X &
381#endif
382#ifdef CONFIG_E200
383 CPU_FTRS_E200 &
384#endif
385#ifdef CONFIG_E500
386 CPU_FTRS_E500 & CPU_FTRS_E500_2 &
387#endif
388#ifdef __powerpc64__
389 CPU_FTRS_POWER3 & CPU_FTRS_RS64 & CPU_FTRS_POWER4 &
390 CPU_FTRS_PPC970 & CPU_FTRS_POWER5 & CPU_FTRS_CELL &
391#endif
392 CPU_FTRS_POSSIBLE,
393};
394
395static inline int cpu_has_feature(unsigned long feature)
396{
397 return (CPU_FTRS_ALWAYS & feature) ||
398 (CPU_FTRS_POSSIBLE
399 & cur_cpu_spec->cpu_features
400 & feature);
401}
402
403#endif /* !__ASSEMBLY__ */
404
405#ifdef __ASSEMBLY__
406
407#define BEGIN_FTR_SECTION 98:
408
409#ifndef __powerpc64__
410#define END_FTR_SECTION(msk, val) \
41199: \
412 .section __ftr_fixup,"a"; \
413 .align 2; \
414 .long msk; \
415 .long val; \
416 .long 98b; \
417 .long 99b; \
418 .previous
419#else /* __powerpc64__ */
420#define END_FTR_SECTION(msk, val) \
42199: \
422 .section __ftr_fixup,"a"; \
423 .align 3; \
424 .llong msk; \
425 .llong val; \
426 .llong 98b; \
427 .llong 99b; \
428 .previous
429#endif /* __powerpc64__ */
430
431#define END_FTR_SECTION_IFSET(msk) END_FTR_SECTION((msk), (msk))
432#define END_FTR_SECTION_IFCLR(msk) END_FTR_SECTION((msk), 0)
433#endif /* __ASSEMBLY__ */
434
435#endif /* __KERNEL__ */
436#endif /* __ASM_POWERPC_CPUTABLE_H */
diff --git a/include/asm-powerpc/current.h b/include/asm-powerpc/current.h
new file mode 100644
index 000000000000..82cd4a9ca99a
--- /dev/null
+++ b/include/asm-powerpc/current.h
@@ -0,0 +1,27 @@
1#ifndef _ASM_POWERPC_CURRENT_H
2#define _ASM_POWERPC_CURRENT_H
3
4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11struct task_struct;
12
13#ifdef __powerpc64__
14#include <asm/paca.h>
15
16#define current (get_paca()->__current)
17
18#else
19
20/*
21 * We keep `current' in r2 for speed.
22 */
23register struct task_struct *current asm ("r2");
24
25#endif
26
27#endif /* _ASM_POWERPC_CURRENT_H */
diff --git a/include/asm-powerpc/dbdma.h b/include/asm-powerpc/dbdma.h
new file mode 100644
index 000000000000..8973565f95d3
--- /dev/null
+++ b/include/asm-powerpc/dbdma.h
@@ -0,0 +1,102 @@
1/*
2 * Definitions for using the Apple Descriptor-Based DMA controller
3 * in Power Macintosh computers.
4 *
5 * Copyright (C) 1996 Paul Mackerras.
6 */
7
8#ifdef __KERNEL__
9#ifndef _ASM_DBDMA_H_
10#define _ASM_DBDMA_H_
11/*
12 * DBDMA control/status registers. All little-endian.
13 */
14struct dbdma_regs {
15 unsigned int control; /* lets you change bits in status */
16 unsigned int status; /* DMA and device status bits (see below) */
17 unsigned int cmdptr_hi; /* upper 32 bits of command address */
18 unsigned int cmdptr; /* (lower 32 bits of) command address (phys) */
19 unsigned int intr_sel; /* select interrupt condition bit */
20 unsigned int br_sel; /* select branch condition bit */
21 unsigned int wait_sel; /* select wait condition bit */
22 unsigned int xfer_mode;
23 unsigned int data2ptr_hi;
24 unsigned int data2ptr;
25 unsigned int res1;
26 unsigned int address_hi;
27 unsigned int br_addr_hi;
28 unsigned int res2[3];
29};
30
31/* Bits in control and status registers */
32#define RUN 0x8000
33#define PAUSE 0x4000
34#define FLUSH 0x2000
35#define WAKE 0x1000
36#define DEAD 0x0800
37#define ACTIVE 0x0400
38#define BT 0x0100
39#define DEVSTAT 0x00ff
40
41/*
42 * DBDMA command structure. These fields are all little-endian!
43 */
44struct dbdma_cmd {
45 unsigned short req_count; /* requested byte transfer count */
46 unsigned short command; /* command word (has bit-fields) */
47 unsigned int phy_addr; /* physical data address */
48 unsigned int cmd_dep; /* command-dependent field */
49 unsigned short res_count; /* residual count after completion */
50 unsigned short xfer_status; /* transfer status */
51};
52
53/* DBDMA command values in command field */
54#define OUTPUT_MORE 0 /* transfer memory data to stream */
55#define OUTPUT_LAST 0x1000 /* ditto followed by end marker */
56#define INPUT_MORE 0x2000 /* transfer stream data to memory */
57#define INPUT_LAST 0x3000 /* ditto, expect end marker */
58#define STORE_WORD 0x4000 /* write word (4 bytes) to device reg */
59#define LOAD_WORD 0x5000 /* read word (4 bytes) from device reg */
60#define DBDMA_NOP 0x6000 /* do nothing */
61#define DBDMA_STOP 0x7000 /* suspend processing */
62
63/* Key values in command field */
64#define KEY_STREAM0 0 /* usual data stream */
65#define KEY_STREAM1 0x100 /* control/status stream */
66#define KEY_STREAM2 0x200 /* device-dependent stream */
67#define KEY_STREAM3 0x300 /* device-dependent stream */
68#define KEY_REGS 0x500 /* device register space */
69#define KEY_SYSTEM 0x600 /* system memory-mapped space */
70#define KEY_DEVICE 0x700 /* device memory-mapped space */
71
72/* Interrupt control values in command field */
73#define INTR_NEVER 0 /* don't interrupt */
74#define INTR_IFSET 0x10 /* intr if condition bit is 1 */
75#define INTR_IFCLR 0x20 /* intr if condition bit is 0 */
76#define INTR_ALWAYS 0x30 /* always interrupt */
77
78/* Branch control values in command field */
79#define BR_NEVER 0 /* don't branch */
80#define BR_IFSET 0x4 /* branch if condition bit is 1 */
81#define BR_IFCLR 0x8 /* branch if condition bit is 0 */
82#define BR_ALWAYS 0xc /* always branch */
83
84/* Wait control values in command field */
85#define WAIT_NEVER 0 /* don't wait */
86#define WAIT_IFSET 1 /* wait if condition bit is 1 */
87#define WAIT_IFCLR 2 /* wait if condition bit is 0 */
88#define WAIT_ALWAYS 3 /* always wait */
89
90/* Align an address for a DBDMA command structure */
91#define DBDMA_ALIGN(x) (((unsigned long)(x) + sizeof(struct dbdma_cmd) - 1) \
92 & -sizeof(struct dbdma_cmd))
93
94/* Useful macros */
95#define DBDMA_DO_STOP(regs) do { \
96 out_le32(&((regs)->control), (RUN|FLUSH)<<16); \
97 while(in_le32(&((regs)->status)) & (ACTIVE|FLUSH)) \
98 ; \
99} while(0)
100
101#endif /* _ASM_DBDMA_H_ */
102#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/delay.h b/include/asm-powerpc/delay.h
new file mode 100644
index 000000000000..54fe1f4f8fd0
--- /dev/null
+++ b/include/asm-powerpc/delay.h
@@ -0,0 +1,19 @@
1#ifndef _ASM_POWERPC_DELAY_H
2#define _ASM_POWERPC_DELAY_H
3
4/*
5 * Copyright 1996, Paul Mackerras.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 *
12 * PPC64 Support added by Dave Engebretsen, Todd Inglett, Mike Corrigan,
13 * Anton Blanchard.
14 */
15
16extern void __delay(unsigned long loops);
17extern void udelay(unsigned long usecs);
18
19#endif /* _ASM_POWERPC_DELAY_H */
diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h
new file mode 100644
index 000000000000..59a80163f75f
--- /dev/null
+++ b/include/asm-powerpc/dma-mapping.h
@@ -0,0 +1,285 @@
1/*
2 * Copyright (C) 2004 IBM
3 *
4 * Implements the generic device dma API for powerpc.
5 * the pci and vio busses
6 */
7#ifndef _ASM_DMA_MAPPING_H
8#define _ASM_DMA_MAPPING_H
9
10#include <linux/config.h>
11#include <linux/types.h>
12#include <linux/cache.h>
13/* need struct page definitions */
14#include <linux/mm.h>
15#include <asm/scatterlist.h>
16#include <asm/io.h>
17#include <asm/bug.h>
18
19#define DMA_ERROR_CODE (~(dma_addr_t)0x0)
20
21#ifdef CONFIG_NOT_COHERENT_CACHE
22/*
23 * DMA-consistent mapping functions for PowerPCs that don't support
24 * cache snooping. These allocate/free a region of uncached mapped
25 * memory space for use with DMA devices. Alternatively, you could
26 * allocate the space "normally" and use the cache management functions
27 * to ensure it is consistent.
28 */
29extern void *__dma_alloc_coherent(size_t size, dma_addr_t *handle, gfp_t gfp);
30extern void __dma_free_coherent(size_t size, void *vaddr);
31extern void __dma_sync(void *vaddr, size_t size, int direction);
32extern void __dma_sync_page(struct page *page, unsigned long offset,
33 size_t size, int direction);
34
35#else /* ! CONFIG_NOT_COHERENT_CACHE */
36/*
37 * Cache coherent cores.
38 */
39
40#define __dma_alloc_coherent(gfp, size, handle) NULL
41#define __dma_free_coherent(size, addr) do { } while (0)
42#define __dma_sync(addr, size, rw) do { } while (0)
43#define __dma_sync_page(pg, off, sz, rw) do { } while (0)
44
45#endif /* ! CONFIG_NOT_COHERENT_CACHE */
46
47#ifdef CONFIG_PPC64
48
49extern int dma_supported(struct device *dev, u64 mask);
50extern int dma_set_mask(struct device *dev, u64 dma_mask);
51extern void *dma_alloc_coherent(struct device *dev, size_t size,
52 dma_addr_t *dma_handle, gfp_t flag);
53extern void dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
54 dma_addr_t dma_handle);
55extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
56 size_t size, enum dma_data_direction direction);
57extern void dma_unmap_single(struct device *dev, dma_addr_t dma_addr,
58 size_t size, enum dma_data_direction direction);
59extern dma_addr_t dma_map_page(struct device *dev, struct page *page,
60 unsigned long offset, size_t size,
61 enum dma_data_direction direction);
62extern void dma_unmap_page(struct device *dev, dma_addr_t dma_address,
63 size_t size, enum dma_data_direction direction);
64extern int dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
65 enum dma_data_direction direction);
66extern void dma_unmap_sg(struct device *dev, struct scatterlist *sg,
67 int nhwentries, enum dma_data_direction direction);
68
69#else /* CONFIG_PPC64 */
70
71#define dma_supported(dev, mask) (1)
72
73static inline int dma_set_mask(struct device *dev, u64 dma_mask)
74{
75 if (!dev->dma_mask || !dma_supported(dev, mask))
76 return -EIO;
77
78 *dev->dma_mask = dma_mask;
79
80 return 0;
81}
82
83static inline void *dma_alloc_coherent(struct device *dev, size_t size,
84 dma_addr_t * dma_handle,
85 gfp_t gfp)
86{
87#ifdef CONFIG_NOT_COHERENT_CACHE
88 return __dma_alloc_coherent(size, dma_handle, gfp);
89#else
90 void *ret;
91 /* ignore region specifiers */
92 gfp &= ~(__GFP_DMA | __GFP_HIGHMEM);
93
94 if (dev == NULL || dev->coherent_dma_mask < 0xffffffff)
95 gfp |= GFP_DMA;
96
97 ret = (void *)__get_free_pages(gfp, get_order(size));
98
99 if (ret != NULL) {
100 memset(ret, 0, size);
101 *dma_handle = virt_to_bus(ret);
102 }
103
104 return ret;
105#endif
106}
107
108static inline void
109dma_free_coherent(struct device *dev, size_t size, void *vaddr,
110 dma_addr_t dma_handle)
111{
112#ifdef CONFIG_NOT_COHERENT_CACHE
113 __dma_free_coherent(size, vaddr);
114#else
115 free_pages((unsigned long)vaddr, get_order(size));
116#endif
117}
118
119static inline dma_addr_t
120dma_map_single(struct device *dev, void *ptr, size_t size,
121 enum dma_data_direction direction)
122{
123 BUG_ON(direction == DMA_NONE);
124
125 __dma_sync(ptr, size, direction);
126
127 return virt_to_bus(ptr);
128}
129
130/* We do nothing. */
131#define dma_unmap_single(dev, addr, size, dir) do { } while (0)
132
133static inline dma_addr_t
134dma_map_page(struct device *dev, struct page *page,
135 unsigned long offset, size_t size,
136 enum dma_data_direction direction)
137{
138 BUG_ON(direction == DMA_NONE);
139
140 __dma_sync_page(page, offset, size, direction);
141
142 return page_to_bus(page) + offset;
143}
144
145/* We do nothing. */
146#define dma_unmap_page(dev, handle, size, dir) do { } while (0)
147
148static inline int
149dma_map_sg(struct device *dev, struct scatterlist *sg, int nents,
150 enum dma_data_direction direction)
151{
152 int i;
153
154 BUG_ON(direction == DMA_NONE);
155
156 for (i = 0; i < nents; i++, sg++) {
157 BUG_ON(!sg->page);
158 __dma_sync_page(sg->page, sg->offset, sg->length, direction);
159 sg->dma_address = page_to_bus(sg->page) + sg->offset;
160 }
161
162 return nents;
163}
164
165/* We don't do anything here. */
166#define dma_unmap_sg(dev, sg, nents, dir) do { } while (0)
167
168#endif /* CONFIG_PPC64 */
169
170static inline void dma_sync_single_for_cpu(struct device *dev,
171 dma_addr_t dma_handle, size_t size,
172 enum dma_data_direction direction)
173{
174 BUG_ON(direction == DMA_NONE);
175 __dma_sync(bus_to_virt(dma_handle), size, direction);
176}
177
178static inline void dma_sync_single_for_device(struct device *dev,
179 dma_addr_t dma_handle, size_t size,
180 enum dma_data_direction direction)
181{
182 BUG_ON(direction == DMA_NONE);
183 __dma_sync(bus_to_virt(dma_handle), size, direction);
184}
185
186static inline void dma_sync_sg_for_cpu(struct device *dev,
187 struct scatterlist *sg, int nents,
188 enum dma_data_direction direction)
189{
190 int i;
191
192 BUG_ON(direction == DMA_NONE);
193
194 for (i = 0; i < nents; i++, sg++)
195 __dma_sync_page(sg->page, sg->offset, sg->length, direction);
196}
197
198static inline void dma_sync_sg_for_device(struct device *dev,
199 struct scatterlist *sg, int nents,
200 enum dma_data_direction direction)
201{
202 int i;
203
204 BUG_ON(direction == DMA_NONE);
205
206 for (i = 0; i < nents; i++, sg++)
207 __dma_sync_page(sg->page, sg->offset, sg->length, direction);
208}
209
210static inline int dma_mapping_error(dma_addr_t dma_addr)
211{
212#ifdef CONFIG_PPC64
213 return (dma_addr == DMA_ERROR_CODE);
214#else
215 return 0;
216#endif
217}
218
219#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent(d, s, h, f)
220#define dma_free_noncoherent(d, s, v, h) dma_free_coherent(d, s, v, h)
221#ifdef CONFIG_NOT_COHERENT_CACHE
222#define dma_is_consistent(d) (0)
223#else
224#define dma_is_consistent(d) (1)
225#endif
226
227static inline int dma_get_cache_alignment(void)
228{
229#ifdef CONFIG_PPC64
230 /* no easy way to get cache size on all processors, so return
231 * the maximum possible, to be safe */
232 return (1 << L1_CACHE_SHIFT_MAX);
233#else
234 /*
235 * Each processor family will define its own L1_CACHE_SHIFT,
236 * L1_CACHE_BYTES wraps to this, so this is always safe.
237 */
238 return L1_CACHE_BYTES;
239#endif
240}
241
242static inline void dma_sync_single_range_for_cpu(struct device *dev,
243 dma_addr_t dma_handle, unsigned long offset, size_t size,
244 enum dma_data_direction direction)
245{
246 /* just sync everything for now */
247 dma_sync_single_for_cpu(dev, dma_handle, offset + size, direction);
248}
249
250static inline void dma_sync_single_range_for_device(struct device *dev,
251 dma_addr_t dma_handle, unsigned long offset, size_t size,
252 enum dma_data_direction direction)
253{
254 /* just sync everything for now */
255 dma_sync_single_for_device(dev, dma_handle, offset + size, direction);
256}
257
258static inline void dma_cache_sync(void *vaddr, size_t size,
259 enum dma_data_direction direction)
260{
261 BUG_ON(direction == DMA_NONE);
262 __dma_sync(vaddr, size, (int)direction);
263}
264
265/*
266 * DMA operations are abstracted for G5 vs. i/pSeries, PCI vs. VIO
267 */
268struct dma_mapping_ops {
269 void * (*alloc_coherent)(struct device *dev, size_t size,
270 dma_addr_t *dma_handle, gfp_t flag);
271 void (*free_coherent)(struct device *dev, size_t size,
272 void *vaddr, dma_addr_t dma_handle);
273 dma_addr_t (*map_single)(struct device *dev, void *ptr,
274 size_t size, enum dma_data_direction direction);
275 void (*unmap_single)(struct device *dev, dma_addr_t dma_addr,
276 size_t size, enum dma_data_direction direction);
277 int (*map_sg)(struct device *dev, struct scatterlist *sg,
278 int nents, enum dma_data_direction direction);
279 void (*unmap_sg)(struct device *dev, struct scatterlist *sg,
280 int nents, enum dma_data_direction direction);
281 int (*dma_supported)(struct device *dev, u64 mask);
282 int (*dac_dma_supported)(struct device *dev, u64 mask);
283};
284
285#endif /* _ASM_DMA_MAPPING_H */
diff --git a/include/asm-powerpc/dma.h b/include/asm-powerpc/dma.h
new file mode 100644
index 000000000000..926378d2cd94
--- /dev/null
+++ b/include/asm-powerpc/dma.h
@@ -0,0 +1,390 @@
1#ifndef _ASM_POWERPC_DMA_H
2#define _ASM_POWERPC_DMA_H
3
4/*
5 * Defines for using and allocating dma channels.
6 * Written by Hennus Bergman, 1992.
7 * High DMA channel support & info by Hannu Savolainen
8 * and John Boyd, Nov. 1992.
9 * Changes for ppc sound by Christoph Nadig
10 */
11
12/*
13 * Note: Adapted for PowerPC by Gary Thomas
14 * Modified by Cort Dougan <cort@cs.nmt.edu>
15 *
16 * None of this really applies for Power Macintoshes. There is
17 * basically just enough here to get kernel/dma.c to compile.
18 *
19 * There may be some comments or restrictions made here which are
20 * not valid for the PReP platform. Take what you read
21 * with a grain of salt.
22 */
23
24#include <linux/config.h>
25#include <asm/io.h>
26#include <linux/spinlock.h>
27#include <asm/system.h>
28
29#ifndef MAX_DMA_CHANNELS
30#define MAX_DMA_CHANNELS 8
31#endif
32
33/* The maximum address that we can perform a DMA transfer to on this platform */
34/* Doesn't really apply... */
35#define MAX_DMA_ADDRESS (~0UL)
36
37#if !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI)
38
39#ifdef HAVE_REALLY_SLOW_DMA_CONTROLLER
40#define dma_outb outb_p
41#else
42#define dma_outb outb
43#endif
44
45#define dma_inb inb
46
47/*
48 * NOTES about DMA transfers:
49 *
50 * controller 1: channels 0-3, byte operations, ports 00-1F
51 * controller 2: channels 4-7, word operations, ports C0-DF
52 *
53 * - ALL registers are 8 bits only, regardless of transfer size
54 * - channel 4 is not used - cascades 1 into 2.
55 * - channels 0-3 are byte - addresses/counts are for physical bytes
56 * - channels 5-7 are word - addresses/counts are for physical words
57 * - transfers must not cross physical 64K (0-3) or 128K (5-7) boundaries
58 * - transfer count loaded to registers is 1 less than actual count
59 * - controller 2 offsets are all even (2x offsets for controller 1)
60 * - page registers for 5-7 don't use data bit 0, represent 128K pages
61 * - page registers for 0-3 use bit 0, represent 64K pages
62 *
63 * On PReP, DMA transfers are limited to the lower 16MB of _physical_ memory.
64 * On CHRP, the W83C553F (and VLSI Tollgate?) support full 32 bit addressing.
65 * Note that addresses loaded into registers must be _physical_ addresses,
66 * not logical addresses (which may differ if paging is active).
67 *
68 * Address mapping for channels 0-3:
69 *
70 * A23 ... A16 A15 ... A8 A7 ... A0 (Physical addresses)
71 * | ... | | ... | | ... |
72 * | ... | | ... | | ... |
73 * | ... | | ... | | ... |
74 * P7 ... P0 A7 ... A0 A7 ... A0
75 * | Page | Addr MSB | Addr LSB | (DMA registers)
76 *
77 * Address mapping for channels 5-7:
78 *
79 * A23 ... A17 A16 A15 ... A9 A8 A7 ... A1 A0 (Physical addresses)
80 * | ... | \ \ ... \ \ \ ... \ \
81 * | ... | \ \ ... \ \ \ ... \ (not used)
82 * | ... | \ \ ... \ \ \ ... \
83 * P7 ... P1 (0) A7 A6 ... A0 A7 A6 ... A0
84 * | Page | Addr MSB | Addr LSB | (DMA registers)
85 *
86 * Again, channels 5-7 transfer _physical_ words (16 bits), so addresses
87 * and counts _must_ be word-aligned (the lowest address bit is _ignored_ at
88 * the hardware level, so odd-byte transfers aren't possible).
89 *
90 * Transfer count (_not # bytes_) is limited to 64K, represented as actual
91 * count - 1 : 64K => 0xFFFF, 1 => 0x0000. Thus, count is always 1 or more,
92 * and up to 128K bytes may be transferred on channels 5-7 in one operation.
93 *
94 */
95
96/* see prep_setup_arch() for detailed informations */
97#if defined(CONFIG_SOUND_CS4232) && defined(CONFIG_PPC_PREP)
98extern long ppc_cs4232_dma, ppc_cs4232_dma2;
99#define SND_DMA1 ppc_cs4232_dma
100#define SND_DMA2 ppc_cs4232_dma2
101#else
102#define SND_DMA1 -1
103#define SND_DMA2 -1
104#endif
105
106/* 8237 DMA controllers */
107#define IO_DMA1_BASE 0x00 /* 8 bit slave DMA, channels 0..3 */
108#define IO_DMA2_BASE 0xC0 /* 16 bit master DMA, ch 4(=slave input)..7 */
109
110/* DMA controller registers */
111#define DMA1_CMD_REG 0x08 /* command register (w) */
112#define DMA1_STAT_REG 0x08 /* status register (r) */
113#define DMA1_REQ_REG 0x09 /* request register (w) */
114#define DMA1_MASK_REG 0x0A /* single-channel mask (w) */
115#define DMA1_MODE_REG 0x0B /* mode register (w) */
116#define DMA1_CLEAR_FF_REG 0x0C /* clear pointer flip-flop (w) */
117#define DMA1_TEMP_REG 0x0D /* Temporary Register (r) */
118#define DMA1_RESET_REG 0x0D /* Master Clear (w) */
119#define DMA1_CLR_MASK_REG 0x0E /* Clear Mask */
120#define DMA1_MASK_ALL_REG 0x0F /* all-channels mask (w) */
121
122#define DMA2_CMD_REG 0xD0 /* command register (w) */
123#define DMA2_STAT_REG 0xD0 /* status register (r) */
124#define DMA2_REQ_REG 0xD2 /* request register (w) */
125#define DMA2_MASK_REG 0xD4 /* single-channel mask (w) */
126#define DMA2_MODE_REG 0xD6 /* mode register (w) */
127#define DMA2_CLEAR_FF_REG 0xD8 /* clear pointer flip-flop (w) */
128#define DMA2_TEMP_REG 0xDA /* Temporary Register (r) */
129#define DMA2_RESET_REG 0xDA /* Master Clear (w) */
130#define DMA2_CLR_MASK_REG 0xDC /* Clear Mask */
131#define DMA2_MASK_ALL_REG 0xDE /* all-channels mask (w) */
132
133#define DMA_ADDR_0 0x00 /* DMA address registers */
134#define DMA_ADDR_1 0x02
135#define DMA_ADDR_2 0x04
136#define DMA_ADDR_3 0x06
137#define DMA_ADDR_4 0xC0
138#define DMA_ADDR_5 0xC4
139#define DMA_ADDR_6 0xC8
140#define DMA_ADDR_7 0xCC
141
142#define DMA_CNT_0 0x01 /* DMA count registers */
143#define DMA_CNT_1 0x03
144#define DMA_CNT_2 0x05
145#define DMA_CNT_3 0x07
146#define DMA_CNT_4 0xC2
147#define DMA_CNT_5 0xC6
148#define DMA_CNT_6 0xCA
149#define DMA_CNT_7 0xCE
150
151#define DMA_LO_PAGE_0 0x87 /* DMA page registers */
152#define DMA_LO_PAGE_1 0x83
153#define DMA_LO_PAGE_2 0x81
154#define DMA_LO_PAGE_3 0x82
155#define DMA_LO_PAGE_5 0x8B
156#define DMA_LO_PAGE_6 0x89
157#define DMA_LO_PAGE_7 0x8A
158
159#define DMA_HI_PAGE_0 0x487 /* DMA page registers */
160#define DMA_HI_PAGE_1 0x483
161#define DMA_HI_PAGE_2 0x481
162#define DMA_HI_PAGE_3 0x482
163#define DMA_HI_PAGE_5 0x48B
164#define DMA_HI_PAGE_6 0x489
165#define DMA_HI_PAGE_7 0x48A
166
167#define DMA1_EXT_REG 0x40B
168#define DMA2_EXT_REG 0x4D6
169
170#ifndef __powerpc64__
171 /* in arch/ppc/kernel/setup.c -- Cort */
172 extern unsigned int DMA_MODE_WRITE;
173 extern unsigned int DMA_MODE_READ;
174 extern unsigned long ISA_DMA_THRESHOLD;
175#else
176 #define DMA_MODE_READ 0x44 /* I/O to memory, no autoinit, increment, single mode */
177 #define DMA_MODE_WRITE 0x48 /* memory to I/O, no autoinit, increment, single mode */
178#endif
179
180#define DMA_MODE_CASCADE 0xC0 /* pass thru DREQ->HRQ, DACK<-HLDA only */
181
182#define DMA_AUTOINIT 0x10
183
184extern spinlock_t dma_spin_lock;
185
186static __inline__ unsigned long claim_dma_lock(void)
187{
188 unsigned long flags;
189 spin_lock_irqsave(&dma_spin_lock, flags);
190 return flags;
191}
192
193static __inline__ void release_dma_lock(unsigned long flags)
194{
195 spin_unlock_irqrestore(&dma_spin_lock, flags);
196}
197
198/* enable/disable a specific DMA channel */
199static __inline__ void enable_dma(unsigned int dmanr)
200{
201 unsigned char ucDmaCmd = 0x00;
202
203 if (dmanr != 4) {
204 dma_outb(0, DMA2_MASK_REG); /* This may not be enabled */
205 dma_outb(ucDmaCmd, DMA2_CMD_REG); /* Enable group */
206 }
207 if (dmanr <= 3) {
208 dma_outb(dmanr, DMA1_MASK_REG);
209 dma_outb(ucDmaCmd, DMA1_CMD_REG); /* Enable group */
210 } else {
211 dma_outb(dmanr & 3, DMA2_MASK_REG);
212 }
213}
214
215static __inline__ void disable_dma(unsigned int dmanr)
216{
217 if (dmanr <= 3)
218 dma_outb(dmanr | 4, DMA1_MASK_REG);
219 else
220 dma_outb((dmanr & 3) | 4, DMA2_MASK_REG);
221}
222
223/* Clear the 'DMA Pointer Flip Flop'.
224 * Write 0 for LSB/MSB, 1 for MSB/LSB access.
225 * Use this once to initialize the FF to a known state.
226 * After that, keep track of it. :-)
227 * --- In order to do that, the DMA routines below should ---
228 * --- only be used while interrupts are disabled! ---
229 */
230static __inline__ void clear_dma_ff(unsigned int dmanr)
231{
232 if (dmanr <= 3)
233 dma_outb(0, DMA1_CLEAR_FF_REG);
234 else
235 dma_outb(0, DMA2_CLEAR_FF_REG);
236}
237
238/* set mode (above) for a specific DMA channel */
239static __inline__ void set_dma_mode(unsigned int dmanr, char mode)
240{
241 if (dmanr <= 3)
242 dma_outb(mode | dmanr, DMA1_MODE_REG);
243 else
244 dma_outb(mode | (dmanr & 3), DMA2_MODE_REG);
245}
246
247/* Set only the page register bits of the transfer address.
248 * This is used for successive transfers when we know the contents of
249 * the lower 16 bits of the DMA current address register, but a 64k boundary
250 * may have been crossed.
251 */
252static __inline__ void set_dma_page(unsigned int dmanr, int pagenr)
253{
254 switch (dmanr) {
255 case 0:
256 dma_outb(pagenr, DMA_LO_PAGE_0);
257 dma_outb(pagenr >> 8, DMA_HI_PAGE_0);
258 break;
259 case 1:
260 dma_outb(pagenr, DMA_LO_PAGE_1);
261 dma_outb(pagenr >> 8, DMA_HI_PAGE_1);
262 break;
263 case 2:
264 dma_outb(pagenr, DMA_LO_PAGE_2);
265 dma_outb(pagenr >> 8, DMA_HI_PAGE_2);
266 break;
267 case 3:
268 dma_outb(pagenr, DMA_LO_PAGE_3);
269 dma_outb(pagenr >> 8, DMA_HI_PAGE_3);
270 break;
271 case 5:
272 if (SND_DMA1 == 5 || SND_DMA2 == 5)
273 dma_outb(pagenr, DMA_LO_PAGE_5);
274 else
275 dma_outb(pagenr & 0xfe, DMA_LO_PAGE_5);
276 dma_outb(pagenr >> 8, DMA_HI_PAGE_5);
277 break;
278 case 6:
279 if (SND_DMA1 == 6 || SND_DMA2 == 6)
280 dma_outb(pagenr, DMA_LO_PAGE_6);
281 else
282 dma_outb(pagenr & 0xfe, DMA_LO_PAGE_6);
283 dma_outb(pagenr >> 8, DMA_HI_PAGE_6);
284 break;
285 case 7:
286 if (SND_DMA1 == 7 || SND_DMA2 == 7)
287 dma_outb(pagenr, DMA_LO_PAGE_7);
288 else
289 dma_outb(pagenr & 0xfe, DMA_LO_PAGE_7);
290 dma_outb(pagenr >> 8, DMA_HI_PAGE_7);
291 break;
292 }
293}
294
295/* Set transfer address & page bits for specific DMA channel.
296 * Assumes dma flipflop is clear.
297 */
298static __inline__ void set_dma_addr(unsigned int dmanr, unsigned int phys)
299{
300 if (dmanr <= 3) {
301 dma_outb(phys & 0xff,
302 ((dmanr & 3) << 1) + IO_DMA1_BASE);
303 dma_outb((phys >> 8) & 0xff,
304 ((dmanr & 3) << 1) + IO_DMA1_BASE);
305 } else if (dmanr == SND_DMA1 || dmanr == SND_DMA2) {
306 dma_outb(phys & 0xff,
307 ((dmanr & 3) << 2) + IO_DMA2_BASE);
308 dma_outb((phys >> 8) & 0xff,
309 ((dmanr & 3) << 2) + IO_DMA2_BASE);
310 dma_outb((dmanr & 3), DMA2_EXT_REG);
311 } else {
312 dma_outb((phys >> 1) & 0xff,
313 ((dmanr & 3) << 2) + IO_DMA2_BASE);
314 dma_outb((phys >> 9) & 0xff,
315 ((dmanr & 3) << 2) + IO_DMA2_BASE);
316 }
317 set_dma_page(dmanr, phys >> 16);
318}
319
320
321/* Set transfer size (max 64k for DMA1..3, 128k for DMA5..7) for
322 * a specific DMA channel.
323 * You must ensure the parameters are valid.
324 * NOTE: from a manual: "the number of transfers is one more
325 * than the initial word count"! This is taken into account.
326 * Assumes dma flip-flop is clear.
327 * NOTE 2: "count" represents _bytes_ and must be even for channels 5-7.
328 */
329static __inline__ void set_dma_count(unsigned int dmanr, unsigned int count)
330{
331 count--;
332 if (dmanr <= 3) {
333 dma_outb(count & 0xff,
334 ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE);
335 dma_outb((count >> 8) & 0xff,
336 ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE);
337 } else if (dmanr == SND_DMA1 || dmanr == SND_DMA2) {
338 dma_outb(count & 0xff,
339 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
340 dma_outb((count >> 8) & 0xff,
341 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
342 } else {
343 dma_outb((count >> 1) & 0xff,
344 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
345 dma_outb((count >> 9) & 0xff,
346 ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE);
347 }
348}
349
350
351/* Get DMA residue count. After a DMA transfer, this
352 * should return zero. Reading this while a DMA transfer is
353 * still in progress will return unpredictable results.
354 * If called before the channel has been used, it may return 1.
355 * Otherwise, it returns the number of _bytes_ left to transfer.
356 *
357 * Assumes DMA flip-flop is clear.
358 */
359static __inline__ int get_dma_residue(unsigned int dmanr)
360{
361 unsigned int io_port = (dmanr <= 3)
362 ? ((dmanr & 3) << 1) + 1 + IO_DMA1_BASE
363 : ((dmanr & 3) << 2) + 2 + IO_DMA2_BASE;
364
365 /* using short to get 16-bit wrap around */
366 unsigned short count;
367
368 count = 1 + dma_inb(io_port);
369 count += dma_inb(io_port) << 8;
370
371 return (dmanr <= 3 || dmanr == SND_DMA1 || dmanr == SND_DMA2)
372 ? count : (count << 1);
373}
374
375/* These are in kernel/dma.c: */
376
377/* reserve a DMA channel */
378extern int request_dma(unsigned int dmanr, const char *device_id);
379/* release it again */
380extern void free_dma(unsigned int dmanr);
381
382#ifdef CONFIG_PCI
383extern int isa_dma_bridge_buggy;
384#else
385#define isa_dma_bridge_buggy (0)
386#endif
387
388#endif /* !defined(CONFIG_PPC_ISERIES) || defined(CONFIG_PCI) */
389
390#endif /* _ASM_POWERPC_DMA_H */
diff --git a/include/asm-powerpc/eeh.h b/include/asm-powerpc/eeh.h
new file mode 100644
index 000000000000..f8633aafe4ba
--- /dev/null
+++ b/include/asm-powerpc/eeh.h
@@ -0,0 +1,366 @@
1/*
2 * eeh.h
3 * Copyright (C) 2001 Dave Engebretsen & Todd Inglett IBM Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef _PPC64_EEH_H
21#define _PPC64_EEH_H
22
23#include <linux/config.h>
24#include <linux/init.h>
25#include <linux/list.h>
26#include <linux/string.h>
27
28struct pci_dev;
29struct device_node;
30
31#ifdef CONFIG_EEH
32
33extern int eeh_subsystem_enabled;
34
35/* Values for eeh_mode bits in device_node */
36#define EEH_MODE_SUPPORTED (1<<0)
37#define EEH_MODE_NOCHECK (1<<1)
38#define EEH_MODE_ISOLATED (1<<2)
39
40/* Max number of EEH freezes allowed before we consider the device
41 * to be permanently disabled. */
42#define EEH_MAX_ALLOWED_FREEZES 5
43
44void __init eeh_init(void);
45unsigned long eeh_check_failure(const volatile void __iomem *token,
46 unsigned long val);
47int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev);
48void __init pci_addr_cache_build(void);
49
50/**
51 * eeh_add_device_early
52 * eeh_add_device_late
53 *
54 * Perform eeh initialization for devices added after boot.
55 * Call eeh_add_device_early before doing any i/o to the
56 * device (including config space i/o). Call eeh_add_device_late
57 * to finish the eeh setup for this device.
58 */
59void eeh_add_device_early(struct device_node *);
60void eeh_add_device_late(struct pci_dev *);
61
62/**
63 * eeh_remove_device - undo EEH setup for the indicated pci device
64 * @dev: pci device to be removed
65 *
66 * This routine should be called when a device is removed from
67 * a running system (e.g. by hotplug or dlpar). It unregisters
68 * the PCI device from the EEH subsystem. I/O errors affecting
69 * this device will no longer be detected after this call; thus,
70 * i/o errors affecting this slot may leave this device unusable.
71 */
72void eeh_remove_device(struct pci_dev *);
73
74/**
75 * EEH_POSSIBLE_ERROR() -- test for possible MMIO failure.
76 *
77 * If this macro yields TRUE, the caller relays to eeh_check_failure()
78 * which does further tests out of line.
79 */
80#define EEH_POSSIBLE_ERROR(val, type) ((val) == (type)~0 && eeh_subsystem_enabled)
81
82/*
83 * Reads from a device which has been isolated by EEH will return
84 * all 1s. This macro gives an all-1s value of the given size (in
85 * bytes: 1, 2, or 4) for comparing with the result of a read.
86 */
87#define EEH_IO_ERROR_VALUE(size) (~0U >> ((4 - (size)) * 8))
88
89#else /* !CONFIG_EEH */
90static inline void eeh_init(void) { }
91
92static inline unsigned long eeh_check_failure(const volatile void __iomem *token, unsigned long val)
93{
94 return val;
95}
96
97static inline int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
98{
99 return 0;
100}
101
102static inline void pci_addr_cache_build(void) { }
103
104static inline void eeh_add_device_early(struct device_node *dn) { }
105
106static inline void eeh_add_device_late(struct pci_dev *dev) { }
107
108static inline void eeh_remove_device(struct pci_dev *dev) { }
109
110#define EEH_POSSIBLE_ERROR(val, type) (0)
111#define EEH_IO_ERROR_VALUE(size) (-1UL)
112#endif /* CONFIG_EEH */
113
114/*
115 * MMIO read/write operations with EEH support.
116 */
117static inline u8 eeh_readb(const volatile void __iomem *addr)
118{
119 u8 val = in_8(addr);
120 if (EEH_POSSIBLE_ERROR(val, u8))
121 return eeh_check_failure(addr, val);
122 return val;
123}
124static inline void eeh_writeb(u8 val, volatile void __iomem *addr)
125{
126 out_8(addr, val);
127}
128
129static inline u16 eeh_readw(const volatile void __iomem *addr)
130{
131 u16 val = in_le16(addr);
132 if (EEH_POSSIBLE_ERROR(val, u16))
133 return eeh_check_failure(addr, val);
134 return val;
135}
136static inline void eeh_writew(u16 val, volatile void __iomem *addr)
137{
138 out_le16(addr, val);
139}
140static inline u16 eeh_raw_readw(const volatile void __iomem *addr)
141{
142 u16 val = in_be16(addr);
143 if (EEH_POSSIBLE_ERROR(val, u16))
144 return eeh_check_failure(addr, val);
145 return val;
146}
147static inline void eeh_raw_writew(u16 val, volatile void __iomem *addr) {
148 volatile u16 __iomem *vaddr = (volatile u16 __iomem *) addr;
149 out_be16(vaddr, val);
150}
151
152static inline u32 eeh_readl(const volatile void __iomem *addr)
153{
154 u32 val = in_le32(addr);
155 if (EEH_POSSIBLE_ERROR(val, u32))
156 return eeh_check_failure(addr, val);
157 return val;
158}
159static inline void eeh_writel(u32 val, volatile void __iomem *addr)
160{
161 out_le32(addr, val);
162}
163static inline u32 eeh_raw_readl(const volatile void __iomem *addr)
164{
165 u32 val = in_be32(addr);
166 if (EEH_POSSIBLE_ERROR(val, u32))
167 return eeh_check_failure(addr, val);
168 return val;
169}
170static inline void eeh_raw_writel(u32 val, volatile void __iomem *addr)
171{
172 out_be32(addr, val);
173}
174
175static inline u64 eeh_readq(const volatile void __iomem *addr)
176{
177 u64 val = in_le64(addr);
178 if (EEH_POSSIBLE_ERROR(val, u64))
179 return eeh_check_failure(addr, val);
180 return val;
181}
182static inline void eeh_writeq(u64 val, volatile void __iomem *addr)
183{
184 out_le64(addr, val);
185}
186static inline u64 eeh_raw_readq(const volatile void __iomem *addr)
187{
188 u64 val = in_be64(addr);
189 if (EEH_POSSIBLE_ERROR(val, u64))
190 return eeh_check_failure(addr, val);
191 return val;
192}
193static inline void eeh_raw_writeq(u64 val, volatile void __iomem *addr)
194{
195 out_be64(addr, val);
196}
197
198#define EEH_CHECK_ALIGN(v,a) \
199 ((((unsigned long)(v)) & ((a) - 1)) == 0)
200
201static inline void eeh_memset_io(volatile void __iomem *addr, int c,
202 unsigned long n)
203{
204 void *p = (void __force *)addr;
205 u32 lc = c;
206 lc |= lc << 8;
207 lc |= lc << 16;
208
209 while(n && !EEH_CHECK_ALIGN(p, 4)) {
210 *((volatile u8 *)p) = c;
211 p++;
212 n--;
213 }
214 while(n >= 4) {
215 *((volatile u32 *)p) = lc;
216 p += 4;
217 n -= 4;
218 }
219 while(n) {
220 *((volatile u8 *)p) = c;
221 p++;
222 n--;
223 }
224 __asm__ __volatile__ ("sync" : : : "memory");
225}
226static inline void eeh_memcpy_fromio(void *dest, const volatile void __iomem *src,
227 unsigned long n)
228{
229 void *vsrc = (void __force *) src;
230 void *destsave = dest;
231 unsigned long nsave = n;
232
233 while(n && (!EEH_CHECK_ALIGN(vsrc, 4) || !EEH_CHECK_ALIGN(dest, 4))) {
234 *((u8 *)dest) = *((volatile u8 *)vsrc);
235 __asm__ __volatile__ ("eieio" : : : "memory");
236 vsrc++;
237 dest++;
238 n--;
239 }
240 while(n > 4) {
241 *((u32 *)dest) = *((volatile u32 *)vsrc);
242 __asm__ __volatile__ ("eieio" : : : "memory");
243 vsrc += 4;
244 dest += 4;
245 n -= 4;
246 }
247 while(n) {
248 *((u8 *)dest) = *((volatile u8 *)vsrc);
249 __asm__ __volatile__ ("eieio" : : : "memory");
250 vsrc++;
251 dest++;
252 n--;
253 }
254 __asm__ __volatile__ ("sync" : : : "memory");
255
256 /* Look for ffff's here at dest[n]. Assume that at least 4 bytes
257 * were copied. Check all four bytes.
258 */
259 if ((nsave >= 4) &&
260 (EEH_POSSIBLE_ERROR((*((u32 *) destsave+nsave-4)), u32))) {
261 eeh_check_failure(src, (*((u32 *) destsave+nsave-4)));
262 }
263}
264
265static inline void eeh_memcpy_toio(volatile void __iomem *dest, const void *src,
266 unsigned long n)
267{
268 void *vdest = (void __force *) dest;
269
270 while(n && (!EEH_CHECK_ALIGN(vdest, 4) || !EEH_CHECK_ALIGN(src, 4))) {
271 *((volatile u8 *)vdest) = *((u8 *)src);
272 src++;
273 vdest++;
274 n--;
275 }
276 while(n > 4) {
277 *((volatile u32 *)vdest) = *((volatile u32 *)src);
278 src += 4;
279 vdest += 4;
280 n-=4;
281 }
282 while(n) {
283 *((volatile u8 *)vdest) = *((u8 *)src);
284 src++;
285 vdest++;
286 n--;
287 }
288 __asm__ __volatile__ ("sync" : : : "memory");
289}
290
291#undef EEH_CHECK_ALIGN
292
293static inline u8 eeh_inb(unsigned long port)
294{
295 u8 val;
296 if (!_IO_IS_VALID(port))
297 return ~0;
298 val = in_8((u8 __iomem *)(port+pci_io_base));
299 if (EEH_POSSIBLE_ERROR(val, u8))
300 return eeh_check_failure((void __iomem *)(port), val);
301 return val;
302}
303
304static inline void eeh_outb(u8 val, unsigned long port)
305{
306 if (_IO_IS_VALID(port))
307 out_8((u8 __iomem *)(port+pci_io_base), val);
308}
309
310static inline u16 eeh_inw(unsigned long port)
311{
312 u16 val;
313 if (!_IO_IS_VALID(port))
314 return ~0;
315 val = in_le16((u16 __iomem *)(port+pci_io_base));
316 if (EEH_POSSIBLE_ERROR(val, u16))
317 return eeh_check_failure((void __iomem *)(port), val);
318 return val;
319}
320
321static inline void eeh_outw(u16 val, unsigned long port)
322{
323 if (_IO_IS_VALID(port))
324 out_le16((u16 __iomem *)(port+pci_io_base), val);
325}
326
327static inline u32 eeh_inl(unsigned long port)
328{
329 u32 val;
330 if (!_IO_IS_VALID(port))
331 return ~0;
332 val = in_le32((u32 __iomem *)(port+pci_io_base));
333 if (EEH_POSSIBLE_ERROR(val, u32))
334 return eeh_check_failure((void __iomem *)(port), val);
335 return val;
336}
337
338static inline void eeh_outl(u32 val, unsigned long port)
339{
340 if (_IO_IS_VALID(port))
341 out_le32((u32 __iomem *)(port+pci_io_base), val);
342}
343
344/* in-string eeh macros */
345static inline void eeh_insb(unsigned long port, void * buf, int ns)
346{
347 _insb((u8 __iomem *)(port+pci_io_base), buf, ns);
348 if (EEH_POSSIBLE_ERROR((*(((u8*)buf)+ns-1)), u8))
349 eeh_check_failure((void __iomem *)(port), *(u8*)buf);
350}
351
352static inline void eeh_insw_ns(unsigned long port, void * buf, int ns)
353{
354 _insw_ns((u16 __iomem *)(port+pci_io_base), buf, ns);
355 if (EEH_POSSIBLE_ERROR((*(((u16*)buf)+ns-1)), u16))
356 eeh_check_failure((void __iomem *)(port), *(u16*)buf);
357}
358
359static inline void eeh_insl_ns(unsigned long port, void * buf, int nl)
360{
361 _insl_ns((u32 __iomem *)(port+pci_io_base), buf, nl);
362 if (EEH_POSSIBLE_ERROR((*(((u32*)buf)+nl-1)), u32))
363 eeh_check_failure((void __iomem *)(port), *(u32*)buf);
364}
365
366#endif /* _PPC64_EEH_H */
diff --git a/include/asm-powerpc/eeh_event.h b/include/asm-powerpc/eeh_event.h
new file mode 100644
index 000000000000..d168a30b3866
--- /dev/null
+++ b/include/asm-powerpc/eeh_event.h
@@ -0,0 +1,52 @@
1/*
2 * eeh_event.h
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Copyright (c) 2005 Linas Vepstas <linas@linas.org>
19 */
20
21#ifndef ASM_PPC64_EEH_EVENT_H
22#define ASM_PPC64_EEH_EVENT_H
23
24/** EEH event -- structure holding pci controller data that describes
25 * a change in the isolation status of a PCI slot. A pointer
26 * to this struct is passed as the data pointer in a notify callback.
27 */
28struct eeh_event {
29 struct list_head list;
30 struct device_node *dn; /* struct device node */
31 struct pci_dev *dev; /* affected device */
32 int state;
33 int time_unavail; /* milliseconds until device might be available */
34};
35
36/**
37 * eeh_send_failure_event - generate a PCI error event
38 * @dev pci device
39 *
40 * This routine builds a PCI error event which will be delivered
41 * to all listeners on the peh_notifier_chain.
42 *
43 * This routine can be called within an interrupt context;
44 * the actual event will be delivered in a normal context
45 * (from a workqueue).
46 */
47int eeh_send_failure_event (struct device_node *dn,
48 struct pci_dev *dev,
49 int reset_state,
50 int time_unavail);
51
52#endif /* ASM_PPC64_EEH_EVENT_H */
diff --git a/include/asm-powerpc/elf.h b/include/asm-powerpc/elf.h
new file mode 100644
index 000000000000..3dcd65edf978
--- /dev/null
+++ b/include/asm-powerpc/elf.h
@@ -0,0 +1,415 @@
1#ifndef _ASM_POWERPC_ELF_H
2#define _ASM_POWERPC_ELF_H
3
4#include <linux/sched.h> /* for task_struct */
5#include <asm/types.h>
6#include <asm/ptrace.h>
7#include <asm/cputable.h>
8#include <asm/auxvec.h>
9#include <asm/page.h>
10#include <asm/string.h>
11
12/* PowerPC relocations defined by the ABIs */
13#define R_PPC_NONE 0
14#define R_PPC_ADDR32 1 /* 32bit absolute address */
15#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */
16#define R_PPC_ADDR16 3 /* 16bit absolute address */
17#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */
18#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */
19#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */
20#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */
21#define R_PPC_ADDR14_BRTAKEN 8
22#define R_PPC_ADDR14_BRNTAKEN 9
23#define R_PPC_REL24 10 /* PC relative 26 bit */
24#define R_PPC_REL14 11 /* PC relative 16 bit */
25#define R_PPC_REL14_BRTAKEN 12
26#define R_PPC_REL14_BRNTAKEN 13
27#define R_PPC_GOT16 14
28#define R_PPC_GOT16_LO 15
29#define R_PPC_GOT16_HI 16
30#define R_PPC_GOT16_HA 17
31#define R_PPC_PLTREL24 18
32#define R_PPC_COPY 19
33#define R_PPC_GLOB_DAT 20
34#define R_PPC_JMP_SLOT 21
35#define R_PPC_RELATIVE 22
36#define R_PPC_LOCAL24PC 23
37#define R_PPC_UADDR32 24
38#define R_PPC_UADDR16 25
39#define R_PPC_REL32 26
40#define R_PPC_PLT32 27
41#define R_PPC_PLTREL32 28
42#define R_PPC_PLT16_LO 29
43#define R_PPC_PLT16_HI 30
44#define R_PPC_PLT16_HA 31
45#define R_PPC_SDAREL16 32
46#define R_PPC_SECTOFF 33
47#define R_PPC_SECTOFF_LO 34
48#define R_PPC_SECTOFF_HI 35
49#define R_PPC_SECTOFF_HA 36
50
51/* PowerPC relocations defined for the TLS access ABI. */
52#define R_PPC_TLS 67 /* none (sym+add)@tls */
53#define R_PPC_DTPMOD32 68 /* word32 (sym+add)@dtpmod */
54#define R_PPC_TPREL16 69 /* half16* (sym+add)@tprel */
55#define R_PPC_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
56#define R_PPC_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
57#define R_PPC_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
58#define R_PPC_TPREL32 73 /* word32 (sym+add)@tprel */
59#define R_PPC_DTPREL16 74 /* half16* (sym+add)@dtprel */
60#define R_PPC_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
61#define R_PPC_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
62#define R_PPC_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
63#define R_PPC_DTPREL32 78 /* word32 (sym+add)@dtprel */
64#define R_PPC_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
65#define R_PPC_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
66#define R_PPC_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
67#define R_PPC_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
68#define R_PPC_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
69#define R_PPC_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
70#define R_PPC_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
71#define R_PPC_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
72#define R_PPC_GOT_TPREL16 87 /* half16* (sym+add)@got@tprel */
73#define R_PPC_GOT_TPREL16_LO 88 /* half16 (sym+add)@got@tprel@l */
74#define R_PPC_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
75#define R_PPC_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
76#define R_PPC_GOT_DTPREL16 91 /* half16* (sym+add)@got@dtprel */
77#define R_PPC_GOT_DTPREL16_LO 92 /* half16* (sym+add)@got@dtprel@l */
78#define R_PPC_GOT_DTPREL16_HI 93 /* half16* (sym+add)@got@dtprel@h */
79#define R_PPC_GOT_DTPREL16_HA 94 /* half16* (sym+add)@got@dtprel@ha */
80
81/* keep this the last entry. */
82#define R_PPC_NUM 95
83
84/*
85 * ELF register definitions..
86 *
87 * This program is free software; you can redistribute it and/or
88 * modify it under the terms of the GNU General Public License
89 * as published by the Free Software Foundation; either version
90 * 2 of the License, or (at your option) any later version.
91 */
92#include <asm/ptrace.h>
93
94#define ELF_NGREG 48 /* includes nip, msr, lr, etc. */
95#define ELF_NFPREG 33 /* includes fpscr */
96
97typedef unsigned long elf_greg_t64;
98typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
99
100typedef unsigned int elf_greg_t32;
101typedef elf_greg_t32 elf_gregset_t32[ELF_NGREG];
102
103/*
104 * ELF_ARCH, CLASS, and DATA are used to set parameters in the core dumps.
105 */
106#ifdef __powerpc64__
107# define ELF_NVRREG32 33 /* includes vscr & vrsave stuffed together */
108# define ELF_NVRREG 34 /* includes vscr & vrsave in split vectors */
109# define ELF_GREG_TYPE elf_greg_t64
110#else
111# define ELF_NEVRREG 34 /* includes acc (as 2) */
112# define ELF_NVRREG 33 /* includes vscr */
113# define ELF_GREG_TYPE elf_greg_t32
114# define ELF_ARCH EM_PPC
115# define ELF_CLASS ELFCLASS32
116# define ELF_DATA ELFDATA2MSB
117#endif /* __powerpc64__ */
118
119#ifndef ELF_ARCH
120# define ELF_ARCH EM_PPC64
121# define ELF_CLASS ELFCLASS64
122# define ELF_DATA ELFDATA2MSB
123 typedef elf_greg_t64 elf_greg_t;
124 typedef elf_gregset_t64 elf_gregset_t;
125# define elf_addr_t unsigned long
126#else
127 /* Assumption: ELF_ARCH == EM_PPC and ELF_CLASS == ELFCLASS32 */
128 typedef elf_greg_t32 elf_greg_t;
129 typedef elf_gregset_t32 elf_gregset_t;
130# define elf_addr_t u32
131#endif /* ELF_ARCH */
132
133/* Floating point registers */
134typedef double elf_fpreg_t;
135typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
136
137/* Altivec registers */
138/*
139 * The entries with indexes 0-31 contain the corresponding vector registers.
140 * The entry with index 32 contains the vscr as the last word (offset 12)
141 * within the quadword. This allows the vscr to be stored as either a
142 * quadword (since it must be copied via a vector register to/from storage)
143 * or as a word.
144 *
145 * 64-bit kernel notes: The entry at index 33 contains the vrsave as the first
146 * word (offset 0) within the quadword.
147 *
148 * This definition of the VMX state is compatible with the current PPC32
149 * ptrace interface. This allows signal handling and ptrace to use the same
150 * structures. This also simplifies the implementation of a bi-arch
151 * (combined (32- and 64-bit) gdb.
152 *
153 * Note that it's _not_ compatible with 32 bits ucontext which stuffs the
154 * vrsave along with vscr and so only uses 33 vectors for the register set
155 */
156typedef __vector128 elf_vrreg_t;
157typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
158#ifdef __powerpc64__
159typedef elf_vrreg_t elf_vrregset_t32[ELF_NVRREG32];
160#endif
161
162/*
163 * This is used to ensure we don't load something for the wrong architecture.
164 */
165#define elf_check_arch(x) ((x)->e_machine == ELF_ARCH)
166
167#define USE_ELF_CORE_DUMP
168#define ELF_EXEC_PAGESIZE PAGE_SIZE
169
170/* This is the location that an ET_DYN program is loaded if exec'ed. Typical
171 use of this is to invoke "./ld.so someprog" to test out a new version of
172 the loader. We need to make sure that it is out of the way of the program
173 that it will "exec", and that there is sufficient room for the brk. */
174
175#define ELF_ET_DYN_BASE (0x08000000)
176
177#ifdef __KERNEL__
178
179/* Common routine for both 32-bit and 64-bit processes */
180static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
181 struct pt_regs *regs)
182{
183 int i, nregs;
184
185 memset((void *)elf_regs, 0, sizeof(elf_gregset_t));
186
187 /* Our registers are always unsigned longs, whether we're a 32 bit
188 * process or 64 bit, on either a 64 bit or 32 bit kernel.
189 * Don't use ELF_GREG_TYPE here. */
190 nregs = sizeof(struct pt_regs) / sizeof(unsigned long);
191 if (nregs > ELF_NGREG)
192 nregs = ELF_NGREG;
193
194 for (i = 0; i < nregs; i++) {
195 /* This will correctly truncate 64 bit registers to 32 bits
196 * for a 32 bit process on a 64 bit kernel. */
197 elf_regs[i] = (elf_greg_t)((ELF_GREG_TYPE *)regs)[i];
198 }
199}
200#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, regs);
201
202static inline int dump_task_regs(struct task_struct *tsk,
203 elf_gregset_t *elf_regs)
204{
205 struct pt_regs *regs = tsk->thread.regs;
206 if (regs)
207 ppc_elf_core_copy_regs(*elf_regs, regs);
208
209 return 1;
210}
211#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
212
213extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
214#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
215
216#endif /* __KERNEL__ */
217
218/* ELF_HWCAP yields a mask that user programs can use to figure out what
219 instruction set this cpu supports. This could be done in userspace,
220 but it's not easy, and we've already done it here. */
221# define ELF_HWCAP (cur_cpu_spec->cpu_user_features)
222#ifdef __powerpc64__
223# define ELF_PLAT_INIT(_r, load_addr) do { \
224 _r->gpr[2] = load_addr; \
225} while (0)
226#endif /* __powerpc64__ */
227
228/* This yields a string that ld.so will use to load implementation
229 specific libraries for optimization. This is more specific in
230 intent than poking at uname or /proc/cpuinfo.
231
232 For the moment, we have only optimizations for the Intel generations,
233 but that could change... */
234
235#define ELF_PLATFORM (NULL)
236
237#ifdef __KERNEL__
238
239#ifdef __powerpc64__
240# define SET_PERSONALITY(ex, ibcs2) \
241do { \
242 unsigned long new_flags = 0; \
243 if ((ex).e_ident[EI_CLASS] == ELFCLASS32) \
244 new_flags = _TIF_32BIT; \
245 if ((current_thread_info()->flags & _TIF_32BIT) \
246 != new_flags) \
247 set_thread_flag(TIF_ABI_PENDING); \
248 else \
249 clear_thread_flag(TIF_ABI_PENDING); \
250 if (personality(current->personality) != PER_LINUX32) \
251 set_personality(PER_LINUX); \
252} while (0)
253/*
254 * An executable for which elf_read_implies_exec() returns TRUE will
255 * have the READ_IMPLIES_EXEC personality flag set automatically. This
256 * is only required to work around bugs in old 32bit toolchains. Since
257 * the 64bit ABI has never had these issues dont enable the workaround
258 * even if we have an executable stack.
259 */
260# define elf_read_implies_exec(ex, exec_stk) (test_thread_flag(TIF_32BIT) ? \
261 (exec_stk != EXSTACK_DISABLE_X) : 0)
262#else
263# define SET_PERSONALITY(ex, ibcs2) set_personality((ibcs2)?PER_SVR4:PER_LINUX)
264#endif /* __powerpc64__ */
265
266#endif /* __KERNEL__ */
267
268extern int dcache_bsize;
269extern int icache_bsize;
270extern int ucache_bsize;
271
272/* vDSO has arch_setup_additional_pages */
273#define ARCH_HAS_SETUP_ADDITIONAL_PAGES
274struct linux_binprm;
275extern int arch_setup_additional_pages(struct linux_binprm *bprm,
276 int executable_stack);
277#define VDSO_AUX_ENT(a,b) NEW_AUX_ENT(a,b);
278
279/*
280 * The requirements here are:
281 * - keep the final alignment of sp (sp & 0xf)
282 * - make sure the 32-bit value at the first 16 byte aligned position of
283 * AUXV is greater than 16 for glibc compatibility.
284 * AT_IGNOREPPC is used for that.
285 * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC,
286 * even if DLINFO_ARCH_ITEMS goes to zero or is undefined.
287 */
288#define ARCH_DLINFO \
289do { \
290 /* Handle glibc compatibility. */ \
291 NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
292 NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
293 /* Cache size items */ \
294 NEW_AUX_ENT(AT_DCACHEBSIZE, dcache_bsize); \
295 NEW_AUX_ENT(AT_ICACHEBSIZE, icache_bsize); \
296 NEW_AUX_ENT(AT_UCACHEBSIZE, ucache_bsize); \
297 VDSO_AUX_ENT(AT_SYSINFO_EHDR, current->thread.vdso_base) \
298} while (0)
299
300/* PowerPC64 relocations defined by the ABIs */
301#define R_PPC64_NONE R_PPC_NONE
302#define R_PPC64_ADDR32 R_PPC_ADDR32 /* 32bit absolute address. */
303#define R_PPC64_ADDR24 R_PPC_ADDR24 /* 26bit address, word aligned. */
304#define R_PPC64_ADDR16 R_PPC_ADDR16 /* 16bit absolute address. */
305#define R_PPC64_ADDR16_LO R_PPC_ADDR16_LO /* lower 16bits of abs. address. */
306#define R_PPC64_ADDR16_HI R_PPC_ADDR16_HI /* high 16bits of abs. address. */
307#define R_PPC64_ADDR16_HA R_PPC_ADDR16_HA /* adjusted high 16bits. */
308#define R_PPC64_ADDR14 R_PPC_ADDR14 /* 16bit address, word aligned. */
309#define R_PPC64_ADDR14_BRTAKEN R_PPC_ADDR14_BRTAKEN
310#define R_PPC64_ADDR14_BRNTAKEN R_PPC_ADDR14_BRNTAKEN
311#define R_PPC64_REL24 R_PPC_REL24 /* PC relative 26 bit, word aligned. */
312#define R_PPC64_REL14 R_PPC_REL14 /* PC relative 16 bit. */
313#define R_PPC64_REL14_BRTAKEN R_PPC_REL14_BRTAKEN
314#define R_PPC64_REL14_BRNTAKEN R_PPC_REL14_BRNTAKEN
315#define R_PPC64_GOT16 R_PPC_GOT16
316#define R_PPC64_GOT16_LO R_PPC_GOT16_LO
317#define R_PPC64_GOT16_HI R_PPC_GOT16_HI
318#define R_PPC64_GOT16_HA R_PPC_GOT16_HA
319
320#define R_PPC64_COPY R_PPC_COPY
321#define R_PPC64_GLOB_DAT R_PPC_GLOB_DAT
322#define R_PPC64_JMP_SLOT R_PPC_JMP_SLOT
323#define R_PPC64_RELATIVE R_PPC_RELATIVE
324
325#define R_PPC64_UADDR32 R_PPC_UADDR32
326#define R_PPC64_UADDR16 R_PPC_UADDR16
327#define R_PPC64_REL32 R_PPC_REL32
328#define R_PPC64_PLT32 R_PPC_PLT32
329#define R_PPC64_PLTREL32 R_PPC_PLTREL32
330#define R_PPC64_PLT16_LO R_PPC_PLT16_LO
331#define R_PPC64_PLT16_HI R_PPC_PLT16_HI
332#define R_PPC64_PLT16_HA R_PPC_PLT16_HA
333
334#define R_PPC64_SECTOFF R_PPC_SECTOFF
335#define R_PPC64_SECTOFF_LO R_PPC_SECTOFF_LO
336#define R_PPC64_SECTOFF_HI R_PPC_SECTOFF_HI
337#define R_PPC64_SECTOFF_HA R_PPC_SECTOFF_HA
338#define R_PPC64_ADDR30 37 /* word30 (S + A - P) >> 2. */
339#define R_PPC64_ADDR64 38 /* doubleword64 S + A. */
340#define R_PPC64_ADDR16_HIGHER 39 /* half16 #higher(S + A). */
341#define R_PPC64_ADDR16_HIGHERA 40 /* half16 #highera(S + A). */
342#define R_PPC64_ADDR16_HIGHEST 41 /* half16 #highest(S + A). */
343#define R_PPC64_ADDR16_HIGHESTA 42 /* half16 #highesta(S + A). */
344#define R_PPC64_UADDR64 43 /* doubleword64 S + A. */
345#define R_PPC64_REL64 44 /* doubleword64 S + A - P. */
346#define R_PPC64_PLT64 45 /* doubleword64 L + A. */
347#define R_PPC64_PLTREL64 46 /* doubleword64 L + A - P. */
348#define R_PPC64_TOC16 47 /* half16* S + A - .TOC. */
349#define R_PPC64_TOC16_LO 48 /* half16 #lo(S + A - .TOC.). */
350#define R_PPC64_TOC16_HI 49 /* half16 #hi(S + A - .TOC.). */
351#define R_PPC64_TOC16_HA 50 /* half16 #ha(S + A - .TOC.). */
352#define R_PPC64_TOC 51 /* doubleword64 .TOC. */
353#define R_PPC64_PLTGOT16 52 /* half16* M + A. */
354#define R_PPC64_PLTGOT16_LO 53 /* half16 #lo(M + A). */
355#define R_PPC64_PLTGOT16_HI 54 /* half16 #hi(M + A). */
356#define R_PPC64_PLTGOT16_HA 55 /* half16 #ha(M + A). */
357
358#define R_PPC64_ADDR16_DS 56 /* half16ds* (S + A) >> 2. */
359#define R_PPC64_ADDR16_LO_DS 57 /* half16ds #lo(S + A) >> 2. */
360#define R_PPC64_GOT16_DS 58 /* half16ds* (G + A) >> 2. */
361#define R_PPC64_GOT16_LO_DS 59 /* half16ds #lo(G + A) >> 2. */
362#define R_PPC64_PLT16_LO_DS 60 /* half16ds #lo(L + A) >> 2. */
363#define R_PPC64_SECTOFF_DS 61 /* half16ds* (R + A) >> 2. */
364#define R_PPC64_SECTOFF_LO_DS 62 /* half16ds #lo(R + A) >> 2. */
365#define R_PPC64_TOC16_DS 63 /* half16ds* (S + A - .TOC.) >> 2. */
366#define R_PPC64_TOC16_LO_DS 64 /* half16ds #lo(S + A - .TOC.) >> 2. */
367#define R_PPC64_PLTGOT16_DS 65 /* half16ds* (M + A) >> 2. */
368#define R_PPC64_PLTGOT16_LO_DS 66 /* half16ds #lo(M + A) >> 2. */
369
370/* PowerPC64 relocations defined for the TLS access ABI. */
371#define R_PPC64_TLS 67 /* none (sym+add)@tls */
372#define R_PPC64_DTPMOD64 68 /* doubleword64 (sym+add)@dtpmod */
373#define R_PPC64_TPREL16 69 /* half16* (sym+add)@tprel */
374#define R_PPC64_TPREL16_LO 70 /* half16 (sym+add)@tprel@l */
375#define R_PPC64_TPREL16_HI 71 /* half16 (sym+add)@tprel@h */
376#define R_PPC64_TPREL16_HA 72 /* half16 (sym+add)@tprel@ha */
377#define R_PPC64_TPREL64 73 /* doubleword64 (sym+add)@tprel */
378#define R_PPC64_DTPREL16 74 /* half16* (sym+add)@dtprel */
379#define R_PPC64_DTPREL16_LO 75 /* half16 (sym+add)@dtprel@l */
380#define R_PPC64_DTPREL16_HI 76 /* half16 (sym+add)@dtprel@h */
381#define R_PPC64_DTPREL16_HA 77 /* half16 (sym+add)@dtprel@ha */
382#define R_PPC64_DTPREL64 78 /* doubleword64 (sym+add)@dtprel */
383#define R_PPC64_GOT_TLSGD16 79 /* half16* (sym+add)@got@tlsgd */
384#define R_PPC64_GOT_TLSGD16_LO 80 /* half16 (sym+add)@got@tlsgd@l */
385#define R_PPC64_GOT_TLSGD16_HI 81 /* half16 (sym+add)@got@tlsgd@h */
386#define R_PPC64_GOT_TLSGD16_HA 82 /* half16 (sym+add)@got@tlsgd@ha */
387#define R_PPC64_GOT_TLSLD16 83 /* half16* (sym+add)@got@tlsld */
388#define R_PPC64_GOT_TLSLD16_LO 84 /* half16 (sym+add)@got@tlsld@l */
389#define R_PPC64_GOT_TLSLD16_HI 85 /* half16 (sym+add)@got@tlsld@h */
390#define R_PPC64_GOT_TLSLD16_HA 86 /* half16 (sym+add)@got@tlsld@ha */
391#define R_PPC64_GOT_TPREL16_DS 87 /* half16ds* (sym+add)@got@tprel */
392#define R_PPC64_GOT_TPREL16_LO_DS 88 /* half16ds (sym+add)@got@tprel@l */
393#define R_PPC64_GOT_TPREL16_HI 89 /* half16 (sym+add)@got@tprel@h */
394#define R_PPC64_GOT_TPREL16_HA 90 /* half16 (sym+add)@got@tprel@ha */
395#define R_PPC64_GOT_DTPREL16_DS 91 /* half16ds* (sym+add)@got@dtprel */
396#define R_PPC64_GOT_DTPREL16_LO_DS 92 /* half16ds (sym+add)@got@dtprel@l */
397#define R_PPC64_GOT_DTPREL16_HI 93 /* half16 (sym+add)@got@dtprel@h */
398#define R_PPC64_GOT_DTPREL16_HA 94 /* half16 (sym+add)@got@dtprel@ha */
399#define R_PPC64_TPREL16_DS 95 /* half16ds* (sym+add)@tprel */
400#define R_PPC64_TPREL16_LO_DS 96 /* half16ds (sym+add)@tprel@l */
401#define R_PPC64_TPREL16_HIGHER 97 /* half16 (sym+add)@tprel@higher */
402#define R_PPC64_TPREL16_HIGHERA 98 /* half16 (sym+add)@tprel@highera */
403#define R_PPC64_TPREL16_HIGHEST 99 /* half16 (sym+add)@tprel@highest */
404#define R_PPC64_TPREL16_HIGHESTA 100 /* half16 (sym+add)@tprel@highesta */
405#define R_PPC64_DTPREL16_DS 101 /* half16ds* (sym+add)@dtprel */
406#define R_PPC64_DTPREL16_LO_DS 102 /* half16ds (sym+add)@dtprel@l */
407#define R_PPC64_DTPREL16_HIGHER 103 /* half16 (sym+add)@dtprel@higher */
408#define R_PPC64_DTPREL16_HIGHERA 104 /* half16 (sym+add)@dtprel@highera */
409#define R_PPC64_DTPREL16_HIGHEST 105 /* half16 (sym+add)@dtprel@highest */
410#define R_PPC64_DTPREL16_HIGHESTA 106 /* half16 (sym+add)@dtprel@highesta */
411
412/* Keep this the last entry. */
413#define R_PPC64_NUM 107
414
415#endif /* _ASM_POWERPC_ELF_H */
diff --git a/include/asm-powerpc/firmware.h b/include/asm-powerpc/firmware.h
new file mode 100644
index 000000000000..12fabbcb04f0
--- /dev/null
+++ b/include/asm-powerpc/firmware.h
@@ -0,0 +1,103 @@
1/*
2 * Copyright (C) 2001 Ben. Herrenschmidt (benh@kernel.crashing.org)
3 *
4 * Modifications for ppc64:
5 * Copyright (C) 2003 Dave Engebretsen <engebret@us.ibm.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12#ifndef __ASM_POWERPC_FIRMWARE_H
13#define __ASM_POWERPC_FIRMWARE_H
14
15#ifdef __KERNEL__
16
17#ifndef __ASSEMBLY__
18
19/* firmware feature bitmask values */
20#define FIRMWARE_MAX_FEATURES 63
21
22#define FW_FEATURE_PFT (1UL<<0)
23#define FW_FEATURE_TCE (1UL<<1)
24#define FW_FEATURE_SPRG0 (1UL<<2)
25#define FW_FEATURE_DABR (1UL<<3)
26#define FW_FEATURE_COPY (1UL<<4)
27#define FW_FEATURE_ASR (1UL<<5)
28#define FW_FEATURE_DEBUG (1UL<<6)
29#define FW_FEATURE_TERM (1UL<<7)
30#define FW_FEATURE_PERF (1UL<<8)
31#define FW_FEATURE_DUMP (1UL<<9)
32#define FW_FEATURE_INTERRUPT (1UL<<10)
33#define FW_FEATURE_MIGRATE (1UL<<11)
34#define FW_FEATURE_PERFMON (1UL<<12)
35#define FW_FEATURE_CRQ (1UL<<13)
36#define FW_FEATURE_VIO (1UL<<14)
37#define FW_FEATURE_RDMA (1UL<<15)
38#define FW_FEATURE_LLAN (1UL<<16)
39#define FW_FEATURE_BULK (1UL<<17)
40#define FW_FEATURE_XDABR (1UL<<18)
41#define FW_FEATURE_MULTITCE (1UL<<19)
42#define FW_FEATURE_SPLPAR (1UL<<20)
43#define FW_FEATURE_ISERIES (1UL<<21)
44
45enum {
46#ifdef CONFIG_PPC64
47 FW_FEATURE_PSERIES_POSSIBLE = FW_FEATURE_PFT | FW_FEATURE_TCE |
48 FW_FEATURE_SPRG0 | FW_FEATURE_DABR | FW_FEATURE_COPY |
49 FW_FEATURE_ASR | FW_FEATURE_DEBUG | FW_FEATURE_TERM |
50 FW_FEATURE_PERF | FW_FEATURE_DUMP | FW_FEATURE_INTERRUPT |
51 FW_FEATURE_MIGRATE | FW_FEATURE_PERFMON | FW_FEATURE_CRQ |
52 FW_FEATURE_VIO | FW_FEATURE_RDMA | FW_FEATURE_LLAN |
53 FW_FEATURE_BULK | FW_FEATURE_XDABR | FW_FEATURE_MULTITCE |
54 FW_FEATURE_SPLPAR,
55 FW_FEATURE_PSERIES_ALWAYS = 0,
56 FW_FEATURE_ISERIES_POSSIBLE = FW_FEATURE_ISERIES,
57 FW_FEATURE_ISERIES_ALWAYS = FW_FEATURE_ISERIES,
58 FW_FEATURE_POSSIBLE =
59#ifdef CONFIG_PPC_PSERIES
60 FW_FEATURE_PSERIES_POSSIBLE |
61#endif
62#ifdef CONFIG_PPC_ISERIES
63 FW_FEATURE_ISERIES_POSSIBLE |
64#endif
65 0,
66 FW_FEATURE_ALWAYS =
67#ifdef CONFIG_PPC_PSERIES
68 FW_FEATURE_PSERIES_ALWAYS &
69#endif
70#ifdef CONFIG_PPC_ISERIES
71 FW_FEATURE_ISERIES_ALWAYS &
72#endif
73 FW_FEATURE_POSSIBLE,
74
75#else /* CONFIG_PPC64 */
76 FW_FEATURE_POSSIBLE = 0,
77 FW_FEATURE_ALWAYS = 0,
78#endif
79};
80
81/* This is used to identify firmware features which are available
82 * to the kernel.
83 */
84extern unsigned long ppc64_firmware_features;
85
86static inline unsigned long firmware_has_feature(unsigned long feature)
87{
88 return (FW_FEATURE_ALWAYS & feature) ||
89 (FW_FEATURE_POSSIBLE & ppc64_firmware_features & feature);
90}
91
92#ifdef CONFIG_PPC_PSERIES
93typedef struct {
94 unsigned long val;
95 char * name;
96} firmware_feature_t;
97
98extern firmware_feature_t firmware_features_table[];
99#endif
100
101#endif /* __ASSEMBLY__ */
102#endif /* __KERNEL__ */
103#endif /* __ASM_POWERPC_FIRMWARE_H */
diff --git a/include/asm-powerpc/floppy.h b/include/asm-powerpc/floppy.h
new file mode 100644
index 000000000000..64276a3f6153
--- /dev/null
+++ b/include/asm-powerpc/floppy.h
@@ -0,0 +1,105 @@
1/*
2 * Architecture specific parts of the Floppy driver
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1995
9 */
10#ifndef __ASM_POWERPC_FLOPPY_H
11#define __ASM_POWERPC_FLOPPY_H
12
13#include <linux/config.h>
14#include <asm/machdep.h>
15
16#define fd_inb(port) inb_p(port)
17#define fd_outb(value,port) outb_p(value,port)
18
19#define fd_enable_dma() enable_dma(FLOPPY_DMA)
20#define fd_disable_dma() disable_dma(FLOPPY_DMA)
21#define fd_request_dma() request_dma(FLOPPY_DMA, "floppy")
22#define fd_free_dma() free_dma(FLOPPY_DMA)
23#define fd_clear_dma_ff() clear_dma_ff(FLOPPY_DMA)
24#define fd_set_dma_mode(mode) set_dma_mode(FLOPPY_DMA, mode)
25#define fd_set_dma_count(count) set_dma_count(FLOPPY_DMA, count)
26#define fd_enable_irq() enable_irq(FLOPPY_IRQ)
27#define fd_disable_irq() disable_irq(FLOPPY_IRQ)
28#define fd_cacheflush(addr,size) /* nothing */
29#define fd_request_irq() request_irq(FLOPPY_IRQ, floppy_interrupt, \
30 SA_INTERRUPT|SA_SAMPLE_RANDOM, \
31 "floppy", NULL)
32#define fd_free_irq() free_irq(FLOPPY_IRQ, NULL);
33
34#ifdef CONFIG_PCI
35
36#include <linux/pci.h>
37
38#define fd_dma_setup(addr,size,mode,io) powerpc_fd_dma_setup(addr,size,mode,io)
39
40static __inline__ int powerpc_fd_dma_setup(char *addr, unsigned long size,
41 int mode, int io)
42{
43 static unsigned long prev_size;
44 static dma_addr_t bus_addr = 0;
45 static char *prev_addr;
46 static int prev_dir;
47 int dir;
48
49 dir = (mode == DMA_MODE_READ) ? PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE;
50
51 if (bus_addr
52 && (addr != prev_addr || size != prev_size || dir != prev_dir)) {
53 /* different from last time -- unmap prev */
54 pci_unmap_single(NULL, bus_addr, prev_size, prev_dir);
55 bus_addr = 0;
56 }
57
58 if (!bus_addr) /* need to map it */
59 bus_addr = pci_map_single(NULL, addr, size, dir);
60
61 /* remember this one as prev */
62 prev_addr = addr;
63 prev_size = size;
64 prev_dir = dir;
65
66 fd_clear_dma_ff();
67 fd_cacheflush(addr, size);
68 fd_set_dma_mode(mode);
69 set_dma_addr(FLOPPY_DMA, bus_addr);
70 fd_set_dma_count(size);
71 virtual_dma_port = io;
72 fd_enable_dma();
73
74 return 0;
75}
76
77#endif /* CONFIG_PCI */
78
79__inline__ void virtual_dma_init(void)
80{
81 /* Nothing to do on PowerPC */
82}
83
84static int FDC1 = 0x3f0;
85static int FDC2 = -1;
86
87/*
88 * Again, the CMOS information not available
89 */
90#define FLOPPY0_TYPE 6
91#define FLOPPY1_TYPE 0
92
93#define N_FDC 2 /* Don't change this! */
94#define N_DRIVE 8
95
96#define FLOPPY_MOTOR_MASK 0xf0
97
98/*
99 * The PowerPC has no problems with floppy DMA crossing 64k borders.
100 */
101#define CROSS_64KB(a,s) (0)
102
103#define EXTRA_FLOPPY_PARAMS
104
105#endif /* __ASM_POWERPC_FLOPPY_H */
diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h
new file mode 100644
index 000000000000..f0319d50b129
--- /dev/null
+++ b/include/asm-powerpc/futex.h
@@ -0,0 +1,85 @@
1#ifndef _ASM_POWERPC_FUTEX_H
2#define _ASM_POWERPC_FUTEX_H
3
4#ifdef __KERNEL__
5
6#include <linux/futex.h>
7#include <asm/errno.h>
8#include <asm/synch.h>
9#include <asm/uaccess.h>
10#include <asm/asm-compat.h>
11
12#define __futex_atomic_op(insn, ret, oldval, uaddr, oparg) \
13 __asm__ __volatile ( \
14 SYNC_ON_SMP \
15"1: lwarx %0,0,%2\n" \
16 insn \
17 PPC405_ERR77(0, %2) \
18"2: stwcx. %1,0,%2\n" \
19 "bne- 1b\n" \
20 "li %1,0\n" \
21"3: .section .fixup,\"ax\"\n" \
22"4: li %1,%3\n" \
23 "b 3b\n" \
24 ".previous\n" \
25 ".section __ex_table,\"a\"\n" \
26 ".align 3\n" \
27 PPC_LONG "1b,4b,2b,4b\n" \
28 ".previous" \
29 : "=&r" (oldval), "=&r" (ret) \
30 : "b" (uaddr), "i" (-EFAULT), "1" (oparg) \
31 : "cr0", "memory")
32
33static inline int futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
34{
35 int op = (encoded_op >> 28) & 7;
36 int cmp = (encoded_op >> 24) & 15;
37 int oparg = (encoded_op << 8) >> 20;
38 int cmparg = (encoded_op << 20) >> 20;
39 int oldval = 0, ret;
40 if (encoded_op & (FUTEX_OP_OPARG_SHIFT << 28))
41 oparg = 1 << oparg;
42
43 if (! access_ok (VERIFY_WRITE, uaddr, sizeof(int)))
44 return -EFAULT;
45
46 inc_preempt_count();
47
48 switch (op) {
49 case FUTEX_OP_SET:
50 __futex_atomic_op("", ret, oldval, uaddr, oparg);
51 break;
52 case FUTEX_OP_ADD:
53 __futex_atomic_op("add %1,%0,%1\n", ret, oldval, uaddr, oparg);
54 break;
55 case FUTEX_OP_OR:
56 __futex_atomic_op("or %1,%0,%1\n", ret, oldval, uaddr, oparg);
57 break;
58 case FUTEX_OP_ANDN:
59 __futex_atomic_op("andc %1,%0,%1\n", ret, oldval, uaddr, oparg);
60 break;
61 case FUTEX_OP_XOR:
62 __futex_atomic_op("xor %1,%0,%1\n", ret, oldval, uaddr, oparg);
63 break;
64 default:
65 ret = -ENOSYS;
66 }
67
68 dec_preempt_count();
69
70 if (!ret) {
71 switch (cmp) {
72 case FUTEX_OP_CMP_EQ: ret = (oldval == cmparg); break;
73 case FUTEX_OP_CMP_NE: ret = (oldval != cmparg); break;
74 case FUTEX_OP_CMP_LT: ret = (oldval < cmparg); break;
75 case FUTEX_OP_CMP_GE: ret = (oldval >= cmparg); break;
76 case FUTEX_OP_CMP_LE: ret = (oldval <= cmparg); break;
77 case FUTEX_OP_CMP_GT: ret = (oldval > cmparg); break;
78 default: ret = -ENOSYS;
79 }
80 }
81 return ret;
82}
83
84#endif /* __KERNEL__ */
85#endif /* _ASM_POWERPC_FUTEX_H */
diff --git a/include/asm-powerpc/grackle.h b/include/asm-powerpc/grackle.h
new file mode 100644
index 000000000000..563c7a5e64c9
--- /dev/null
+++ b/include/asm-powerpc/grackle.h
@@ -0,0 +1,7 @@
1/*
2 * Functions for setting up and using a MPC106 northbridge
3 */
4
5#include <asm/pci-bridge.h>
6
7extern void setup_grackle(struct pci_controller *hose);
diff --git a/include/asm-powerpc/hardirq.h b/include/asm-powerpc/hardirq.h
new file mode 100644
index 000000000000..3b3e3b49ec12
--- /dev/null
+++ b/include/asm-powerpc/hardirq.h
@@ -0,0 +1,27 @@
1#ifndef _ASM_POWERPC_HARDIRQ_H
2#define _ASM_POWERPC_HARDIRQ_H
3
4#include <asm/irq.h>
5#include <asm/bug.h>
6
7/* The __last_jiffy_stamp field is needed to ensure that no decrementer
8 * interrupt is lost on SMP machines. Since on most CPUs it is in the same
9 * cache line as local_irq_count, it is cheap to access and is also used on UP
10 * for uniformity.
11 */
12typedef struct {
13 unsigned int __softirq_pending; /* set_bit is used on this */
14 unsigned int __last_jiffy_stamp;
15} ____cacheline_aligned irq_cpustat_t;
16
17#include <linux/irq_cpustat.h> /* Standard mappings for irq_cpustat_t above */
18
19#define last_jiffy_stamp(cpu) __IRQ_STAT((cpu), __last_jiffy_stamp)
20
21static inline void ack_bad_irq(int irq)
22{
23 printk(KERN_CRIT "illegal vector %d received!\n", irq);
24 BUG();
25}
26
27#endif /* _ASM_POWERPC_HARDIRQ_H */
diff --git a/include/asm-powerpc/heathrow.h b/include/asm-powerpc/heathrow.h
new file mode 100644
index 000000000000..22ac179856b9
--- /dev/null
+++ b/include/asm-powerpc/heathrow.h
@@ -0,0 +1,62 @@
1/*
2 * heathrow.h: definitions for using the "Heathrow" I/O controller chip.
3 *
4 * Grabbed from Open Firmware definitions on a PowerBook G3 Series
5 *
6 * Copyright (C) 1997 Paul Mackerras.
7 */
8
9/* Front light color on Yikes/B&W G3. 32 bits */
10#define HEATHROW_FRONT_LIGHT 0x32 /* (set to 0 or 0xffffffff) */
11
12/* Brightness/contrast (gossamer iMac ?). 8 bits */
13#define HEATHROW_BRIGHTNESS_CNTL 0x32
14#define HEATHROW_CONTRAST_CNTL 0x33
15
16/* offset from ohare base for feature control register */
17#define HEATHROW_MBCR 0x34 /* Media bay control */
18#define HEATHROW_FCR 0x38 /* Feature control */
19#define HEATHROW_AUX_CNTL_REG 0x3c /* Aux control */
20
21/*
22 * Bits in feature control register.
23 * Bits postfixed with a _N are in inverse logic
24 */
25#define HRW_SCC_TRANS_EN_N 0x00000001 /* Also controls modem power */
26#define HRW_BAY_POWER_N 0x00000002
27#define HRW_BAY_PCI_ENABLE 0x00000004
28#define HRW_BAY_IDE_ENABLE 0x00000008
29#define HRW_BAY_FLOPPY_ENABLE 0x00000010
30#define HRW_IDE0_ENABLE 0x00000020
31#define HRW_IDE0_RESET_N 0x00000040
32#define HRW_BAY_DEV_MASK 0x0000001c
33#define HRW_BAY_RESET_N 0x00000080
34#define HRW_IOBUS_ENABLE 0x00000100 /* Internal IDE ? */
35#define HRW_SCC_ENABLE 0x00000200
36#define HRW_MESH_ENABLE 0x00000400
37#define HRW_SWIM_ENABLE 0x00000800
38#define HRW_SOUND_POWER_N 0x00001000
39#define HRW_SOUND_CLK_ENABLE 0x00002000
40#define HRW_SCCA_IO 0x00004000
41#define HRW_SCCB_IO 0x00008000
42#define HRW_PORT_OR_DESK_VIA_N 0x00010000 /* This one is 0 on PowerBook */
43#define HRW_PWM_MON_ID_N 0x00020000 /* ??? (0) */
44#define HRW_HOOK_MB_CNT_N 0x00040000 /* ??? (0) */
45#define HRW_SWIM_CLONE_FLOPPY 0x00080000 /* ??? (0) */
46#define HRW_AUD_RUN22 0x00100000 /* ??? (1) */
47#define HRW_SCSI_LINK_MODE 0x00200000 /* Read ??? (1) */
48#define HRW_ARB_BYPASS 0x00400000 /* Disable internal PCI arbitrer */
49#define HRW_IDE1_RESET_N 0x00800000 /* Media bay */
50#define HRW_SLOW_SCC_PCLK 0x01000000 /* ??? (0) */
51#define HRW_RESET_SCC 0x02000000
52#define HRW_MFDC_CELL_ENABLE 0x04000000 /* ??? (0) */
53#define HRW_USE_MFDC 0x08000000 /* ??? (0) */
54#define HRW_BMAC_IO_ENABLE 0x60000000 /* two bits, not documented in OF */
55#define HRW_BMAC_RESET 0x80000000 /* not documented in OF */
56
57/* We OR those features at boot on desktop G3s */
58#define HRW_DEFAULTS (HRW_SCCA_IO | HRW_SCCB_IO | HRW_SCC_ENABLE)
59
60/* Looks like Heathrow has some sort of GPIOs as well... */
61#define HRW_GPIO_MODEM_RESET 0x6d
62
diff --git a/include/asm-powerpc/hvcall.h b/include/asm-powerpc/hvcall.h
new file mode 100644
index 000000000000..d36da61dbc53
--- /dev/null
+++ b/include/asm-powerpc/hvcall.h
@@ -0,0 +1,173 @@
1#ifndef _ASM_POWERPC_HVCALL_H
2#define _ASM_POWERPC_HVCALL_H
3
4#define HVSC .long 0x44000022
5
6#define H_Success 0
7#define H_Busy 1 /* Hardware busy -- retry later */
8#define H_Constrained 4 /* Resource request constrained to max allowed */
9#define H_LongBusyStartRange 9900 /* Start of long busy range */
10#define H_LongBusyOrder1msec 9900 /* Long busy, hint that 1msec is a good time to retry */
11#define H_LongBusyOrder10msec 9901 /* Long busy, hint that 10msec is a good time to retry */
12#define H_LongBusyOrder100msec 9902 /* Long busy, hint that 100msec is a good time to retry */
13#define H_LongBusyOrder1sec 9903 /* Long busy, hint that 1sec is a good time to retry */
14#define H_LongBusyOrder10sec 9904 /* Long busy, hint that 10sec is a good time to retry */
15#define H_LongBusyOrder100sec 9905 /* Long busy, hint that 100sec is a good time to retry */
16#define H_LongBusyEndRange 9905 /* End of long busy range */
17#define H_Hardware -1 /* Hardware error */
18#define H_Function -2 /* Function not supported */
19#define H_Privilege -3 /* Caller not privileged */
20#define H_Parameter -4 /* Parameter invalid, out-of-range or conflicting */
21#define H_Bad_Mode -5 /* Illegal msr value */
22#define H_PTEG_Full -6 /* PTEG is full */
23#define H_Not_Found -7 /* PTE was not found" */
24#define H_Reserved_DABR -8 /* DABR address is reserved by the hypervisor on this processor" */
25#define H_NoMem -9
26#define H_Authority -10
27#define H_Permission -11
28#define H_Dropped -12
29#define H_SourceParm -13
30#define H_DestParm -14
31#define H_RemoteParm -15
32#define H_Resource -16
33
34/* Long Busy is a condition that can be returned by the firmware
35 * when a call cannot be completed now, but the identical call
36 * should be retried later. This prevents calls blocking in the
37 * firmware for long periods of time. Annoyingly the firmware can return
38 * a range of return codes, hinting at how long we should wait before
39 * retrying. If you don't care for the hint, the macro below is a good
40 * way to check for the long_busy return codes
41 */
42#define H_isLongBusy(x) ((x >= H_LongBusyStartRange) && (x <= H_LongBusyEndRange))
43
44/* Flags */
45#define H_LARGE_PAGE (1UL<<(63-16))
46#define H_EXACT (1UL<<(63-24)) /* Use exact PTE or return H_PTEG_FULL */
47#define H_R_XLATE (1UL<<(63-25)) /* include a valid logical page num in the pte if the valid bit is set */
48#define H_READ_4 (1UL<<(63-26)) /* Return 4 PTEs */
49#define H_AVPN (1UL<<(63-32)) /* An avpn is provided as a sanity test */
50#define H_ANDCOND (1UL<<(63-33))
51#define H_ICACHE_INVALIDATE (1UL<<(63-40)) /* icbi, etc. (ignored for IO pages) */
52#define H_ICACHE_SYNCHRONIZE (1UL<<(63-41)) /* dcbst, icbi, etc (ignored for IO pages */
53#define H_ZERO_PAGE (1UL<<(63-48)) /* zero the page before mapping (ignored for IO pages) */
54#define H_COPY_PAGE (1UL<<(63-49))
55#define H_N (1UL<<(63-61))
56#define H_PP1 (1UL<<(63-62))
57#define H_PP2 (1UL<<(63-63))
58
59/* DABRX flags */
60#define H_DABRX_HYPERVISOR (1UL<<(63-61))
61#define H_DABRX_KERNEL (1UL<<(63-62))
62#define H_DABRX_USER (1UL<<(63-63))
63
64/* pSeries hypervisor opcodes */
65#define H_REMOVE 0x04
66#define H_ENTER 0x08
67#define H_READ 0x0c
68#define H_CLEAR_MOD 0x10
69#define H_CLEAR_REF 0x14
70#define H_PROTECT 0x18
71#define H_GET_TCE 0x1c
72#define H_PUT_TCE 0x20
73#define H_SET_SPRG0 0x24
74#define H_SET_DABR 0x28
75#define H_PAGE_INIT 0x2c
76#define H_SET_ASR 0x30
77#define H_ASR_ON 0x34
78#define H_ASR_OFF 0x38
79#define H_LOGICAL_CI_LOAD 0x3c
80#define H_LOGICAL_CI_STORE 0x40
81#define H_LOGICAL_CACHE_LOAD 0x44
82#define H_LOGICAL_CACHE_STORE 0x48
83#define H_LOGICAL_ICBI 0x4c
84#define H_LOGICAL_DCBF 0x50
85#define H_GET_TERM_CHAR 0x54
86#define H_PUT_TERM_CHAR 0x58
87#define H_REAL_TO_LOGICAL 0x5c
88#define H_HYPERVISOR_DATA 0x60
89#define H_EOI 0x64
90#define H_CPPR 0x68
91#define H_IPI 0x6c
92#define H_IPOLL 0x70
93#define H_XIRR 0x74
94#define H_PERFMON 0x7c
95#define H_MIGRATE_DMA 0x78
96#define H_REGISTER_VPA 0xDC
97#define H_CEDE 0xE0
98#define H_CONFER 0xE4
99#define H_PROD 0xE8
100#define H_GET_PPP 0xEC
101#define H_SET_PPP 0xF0
102#define H_PURR 0xF4
103#define H_PIC 0xF8
104#define H_REG_CRQ 0xFC
105#define H_FREE_CRQ 0x100
106#define H_VIO_SIGNAL 0x104
107#define H_SEND_CRQ 0x108
108#define H_COPY_RDMA 0x110
109#define H_SET_XDABR 0x134
110#define H_STUFF_TCE 0x138
111#define H_PUT_TCE_INDIRECT 0x13C
112#define H_VTERM_PARTNER_INFO 0x150
113#define H_REGISTER_VTERM 0x154
114#define H_FREE_VTERM 0x158
115#define H_POLL_PENDING 0x1D8
116
117#ifndef __ASSEMBLY__
118
119/* plpar_hcall() -- Generic call interface using above opcodes
120 *
121 * The actual call interface is a hypervisor call instruction with
122 * the opcode in R3 and input args in R4-R7.
123 * Status is returned in R3 with variable output values in R4-R11.
124 * Only H_PTE_READ with H_READ_4 uses R6-R11 so we ignore it for now
125 * and return only two out args which MUST ALWAYS BE PROVIDED.
126 */
127long plpar_hcall(unsigned long opcode,
128 unsigned long arg1,
129 unsigned long arg2,
130 unsigned long arg3,
131 unsigned long arg4,
132 unsigned long *out1,
133 unsigned long *out2,
134 unsigned long *out3);
135
136/* Same as plpar_hcall but for those opcodes that return no values
137 * other than status. Slightly more efficient.
138 */
139long plpar_hcall_norets(unsigned long opcode, ...);
140
141/*
142 * Special hcall interface for ibmveth support.
143 * Takes 8 input parms. Returns a rc and stores the
144 * R4 return value in *out1.
145 */
146long plpar_hcall_8arg_2ret(unsigned long opcode,
147 unsigned long arg1,
148 unsigned long arg2,
149 unsigned long arg3,
150 unsigned long arg4,
151 unsigned long arg5,
152 unsigned long arg6,
153 unsigned long arg7,
154 unsigned long arg8,
155 unsigned long *out1);
156
157/* plpar_hcall_4out()
158 *
159 * same as plpar_hcall except with 4 output arguments.
160 *
161 */
162long plpar_hcall_4out(unsigned long opcode,
163 unsigned long arg1,
164 unsigned long arg2,
165 unsigned long arg3,
166 unsigned long arg4,
167 unsigned long *out1,
168 unsigned long *out2,
169 unsigned long *out3,
170 unsigned long *out4);
171
172#endif /* __ASSEMBLY__ */
173#endif /* _ASM_POWERPC_HVCALL_H */
diff --git a/include/asm-powerpc/hvconsole.h b/include/asm-powerpc/hvconsole.h
new file mode 100644
index 000000000000..6da93ce74dc0
--- /dev/null
+++ b/include/asm-powerpc/hvconsole.h
@@ -0,0 +1,49 @@
1/*
2 * hvconsole.h
3 * Copyright (C) 2004 Ryan S Arnold, IBM Corporation
4 *
5 * LPAR console support.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _PPC64_HVCONSOLE_H
23#define _PPC64_HVCONSOLE_H
24
25/*
26 * This is the max number of console adapters that can/will be found as
27 * console devices on first stage console init. Any number beyond this range
28 * can't be used as a console device but is still a valid tty device.
29 */
30#define MAX_NR_HVC_CONSOLES 16
31
32/* implemented by a low level driver */
33struct hv_ops {
34 int (*get_chars)(uint32_t vtermno, char *buf, int count);
35 int (*put_chars)(uint32_t vtermno, const char *buf, int count);
36};
37extern int hvc_get_chars(uint32_t vtermno, char *buf, int count);
38extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count);
39
40struct hvc_struct;
41
42/* Register a vterm and a slot index for use as a console (console_init) */
43extern int hvc_instantiate(uint32_t vtermno, int index, struct hv_ops *ops);
44/* register a vterm for hvc tty operation (module_init or hotplug add) */
45extern struct hvc_struct * __devinit hvc_alloc(uint32_t vtermno, int irq,
46 struct hv_ops *ops);
47/* remove a vterm from hvc tty operation (modele_exit or hotplug remove) */
48extern int __devexit hvc_remove(struct hvc_struct *hp);
49#endif /* _PPC64_HVCONSOLE_H */
diff --git a/include/asm-powerpc/hvcserver.h b/include/asm-powerpc/hvcserver.h
new file mode 100644
index 000000000000..aecba9665796
--- /dev/null
+++ b/include/asm-powerpc/hvcserver.h
@@ -0,0 +1,57 @@
1/*
2 * hvcserver.h
3 * Copyright (C) 2004 Ryan S Arnold, IBM Corporation
4 *
5 * PPC64 virtual I/O console server support.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#ifndef _PPC64_HVCSERVER_H
23#define _PPC64_HVCSERVER_H
24
25#include <linux/list.h>
26
27/* Converged Location Code length */
28#define HVCS_CLC_LENGTH 79
29
30/**
31 * hvcs_partner_info - an element in a list of partner info
32 * @node: list_head denoting this partner_info struct's position in the list of
33 * partner info.
34 * @unit_address: The partner unit address of this entry.
35 * @partition_ID: The partner partition ID of this entry.
36 * @location_code: The converged location code of this entry + 1 char for the
37 * null-term.
38 *
39 * This structure outlines the format that partner info is presented to a caller
40 * of the hvcs partner info fetching functions. These are strung together into
41 * a list using linux kernel lists.
42 */
43struct hvcs_partner_info {
44 struct list_head node;
45 uint32_t unit_address;
46 uint32_t partition_ID;
47 char location_code[HVCS_CLC_LENGTH + 1]; /* CLC + 1 null-term char */
48};
49
50extern int hvcs_free_partner_info(struct list_head *head);
51extern int hvcs_get_partner_info(uint32_t unit_address,
52 struct list_head *head, unsigned long *pi_buff);
53extern int hvcs_register_connection(uint32_t unit_address,
54 uint32_t p_partition_ID, uint32_t p_unit_address);
55extern int hvcs_free_connection(uint32_t unit_address);
56
57#endif /* _PPC64_HVCSERVER_H */
diff --git a/include/asm-powerpc/hw_irq.h b/include/asm-powerpc/hw_irq.h
new file mode 100644
index 000000000000..26b89d859c56
--- /dev/null
+++ b/include/asm-powerpc/hw_irq.h
@@ -0,0 +1,113 @@
1/*
2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
3 */
4#ifndef _ASM_POWERPC_HW_IRQ_H
5#define _ASM_POWERPC_HW_IRQ_H
6
7#ifdef __KERNEL__
8
9#include <linux/config.h>
10#include <linux/errno.h>
11#include <asm/ptrace.h>
12#include <asm/processor.h>
13
14extern void timer_interrupt(struct pt_regs *);
15
16#ifdef CONFIG_PPC_ISERIES
17
18extern unsigned long local_get_flags(void);
19extern unsigned long local_irq_disable(void);
20extern void local_irq_restore(unsigned long);
21
22#define local_irq_enable() local_irq_restore(1)
23#define local_save_flags(flags) ((flags) = local_get_flags())
24#define local_irq_save(flags) ((flags) = local_irq_disable())
25
26#define irqs_disabled() (local_get_flags() == 0)
27
28#else
29
30#if defined(CONFIG_BOOKE)
31#define SET_MSR_EE(x) mtmsr(x)
32#define local_irq_restore(flags) __asm__ __volatile__("wrtee %0" : : "r" (flags) : "memory")
33#elif defined(__powerpc64__)
34#define SET_MSR_EE(x) __mtmsrd(x, 1)
35#define local_irq_restore(flags) do { \
36 __asm__ __volatile__("": : :"memory"); \
37 __mtmsrd((flags), 1); \
38} while(0)
39#else
40#define SET_MSR_EE(x) mtmsr(x)
41#define local_irq_restore(flags) mtmsr(flags)
42#endif
43
44static inline void local_irq_disable(void)
45{
46#ifdef CONFIG_BOOKE
47 __asm__ __volatile__("wrteei 0": : :"memory");
48#else
49 unsigned long msr;
50 __asm__ __volatile__("": : :"memory");
51 msr = mfmsr();
52 SET_MSR_EE(msr & ~MSR_EE);
53#endif
54}
55
56static inline void local_irq_enable(void)
57{
58#ifdef CONFIG_BOOKE
59 __asm__ __volatile__("wrteei 1": : :"memory");
60#else
61 unsigned long msr;
62 __asm__ __volatile__("": : :"memory");
63 msr = mfmsr();
64 SET_MSR_EE(msr | MSR_EE);
65#endif
66}
67
68static inline void local_irq_save_ptr(unsigned long *flags)
69{
70 unsigned long msr;
71 msr = mfmsr();
72 *flags = msr;
73#ifdef CONFIG_BOOKE
74 __asm__ __volatile__("wrteei 0": : :"memory");
75#else
76 SET_MSR_EE(msr & ~MSR_EE);
77#endif
78 __asm__ __volatile__("": : :"memory");
79}
80
81#define local_save_flags(flags) ((flags) = mfmsr())
82#define local_irq_save(flags) local_irq_save_ptr(&flags)
83#define irqs_disabled() ((mfmsr() & MSR_EE) == 0)
84
85#endif /* CONFIG_PPC_ISERIES */
86
87#define mask_irq(irq) \
88 ({ \
89 irq_desc_t *desc = get_irq_desc(irq); \
90 if (desc->handler && desc->handler->disable) \
91 desc->handler->disable(irq); \
92 })
93#define unmask_irq(irq) \
94 ({ \
95 irq_desc_t *desc = get_irq_desc(irq); \
96 if (desc->handler && desc->handler->enable) \
97 desc->handler->enable(irq); \
98 })
99#define ack_irq(irq) \
100 ({ \
101 irq_desc_t *desc = get_irq_desc(irq); \
102 if (desc->handler && desc->handler->ack) \
103 desc->handler->ack(irq); \
104 })
105
106/* Should we handle this via lost interrupts and IPIs or should we don't care like
107 * we do now ? --BenH.
108 */
109struct hw_interrupt_type;
110static inline void hw_resend_irq(struct hw_interrupt_type *h, unsigned int i) {}
111
112#endif /* __KERNEL__ */
113#endif /* _ASM_POWERPC_HW_IRQ_H */
diff --git a/include/asm-powerpc/i8259.h b/include/asm-powerpc/i8259.h
new file mode 100644
index 000000000000..fc4bfee124d7
--- /dev/null
+++ b/include/asm-powerpc/i8259.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_POWERPC_I8259_H
2#define _ASM_POWERPC_I8259_H
3
4#include <linux/irq.h>
5
6extern struct hw_interrupt_type i8259_pic;
7
8extern void i8259_init(unsigned long intack_addr, int offset);
9extern int i8259_irq(struct pt_regs *regs);
10extern int i8259_irq_cascade(struct pt_regs *regs, void *unused);
11
12#endif /* _ASM_POWERPC_I8259_H */
diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h
new file mode 100644
index 000000000000..da5f640480cf
--- /dev/null
+++ b/include/asm-powerpc/ide.h
@@ -0,0 +1,83 @@
1/*
2 * Copyright (C) 1994-1996 Linus Torvalds & authors
3 *
4 * This file contains the powerpc architecture specific IDE code.
5 */
6#ifndef _ASM_POWERPC_IDE_H
7#define _ASM_POWERPC_IDE_H
8
9#ifdef __KERNEL__
10
11#ifndef __powerpc64__
12#include <linux/sched.h>
13#include <asm/mpc8xx.h>
14#endif
15
16#ifndef MAX_HWIFS
17#ifdef __powerpc64__
18#define MAX_HWIFS 10
19#else
20#define MAX_HWIFS 8
21#endif
22#endif
23
24#ifndef __powerpc64__
25#include <linux/config.h>
26#include <linux/hdreg.h>
27#include <linux/ioport.h>
28#include <asm/io.h>
29
30extern void __ide_mm_insw(void __iomem *port, void *addr, u32 count);
31extern void __ide_mm_outsw(void __iomem *port, void *addr, u32 count);
32extern void __ide_mm_insl(void __iomem *port, void *addr, u32 count);
33extern void __ide_mm_outsl(void __iomem *port, void *addr, u32 count);
34
35struct ide_machdep_calls {
36 int (*default_irq)(unsigned long base);
37 unsigned long (*default_io_base)(int index);
38 void (*ide_init_hwif)(hw_regs_t *hw,
39 unsigned long data_port,
40 unsigned long ctrl_port,
41 int *irq);
42};
43
44extern struct ide_machdep_calls ppc_ide_md;
45
46#undef SUPPORT_SLOW_DATA_PORTS
47#define SUPPORT_SLOW_DATA_PORTS 0
48
49#define IDE_ARCH_OBSOLETE_DEFAULTS
50
51static __inline__ int ide_default_irq(unsigned long base)
52{
53 if (ppc_ide_md.default_irq)
54 return ppc_ide_md.default_irq(base);
55 return 0;
56}
57
58static __inline__ unsigned long ide_default_io_base(int index)
59{
60 if (ppc_ide_md.default_io_base)
61 return ppc_ide_md.default_io_base(index);
62 return 0;
63}
64
65#ifdef CONFIG_PCI
66#define ide_init_default_irq(base) (0)
67#else
68#define ide_init_default_irq(base) ide_default_irq(base)
69#endif
70
71#if (defined CONFIG_APUS || defined CONFIG_BLK_DEV_MPC8xx_IDE )
72#define IDE_ARCH_ACK_INTR 1
73#define ide_ack_intr(hwif) (hwif->hw.ack_intr ? hwif->hw.ack_intr(hwif) : 1)
74#endif
75
76#endif /* __powerpc64__ */
77
78#define IDE_ARCH_OBSOLETE_INIT
79#define ide_default_io_ctl(base) ((base) + 0x206) /* obsolete */
80
81#endif /* __KERNEL__ */
82
83#endif /* _ASM_POWERPC_IDE_H */
diff --git a/include/asm-powerpc/io.h b/include/asm-powerpc/io.h
new file mode 100644
index 000000000000..48938d84d055
--- /dev/null
+++ b/include/asm-powerpc/io.h
@@ -0,0 +1,462 @@
1#ifndef _ASM_POWERPC_IO_H
2#define _ASM_POWERPC_IO_H
3
4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10
11#ifndef CONFIG_PPC64
12#include <asm-ppc/io.h>
13#else
14
15#include <linux/compiler.h>
16#include <asm/page.h>
17#include <asm/byteorder.h>
18#ifdef CONFIG_PPC_ISERIES
19#include <asm/iseries/iseries_io.h>
20#endif
21#include <asm/synch.h>
22#include <asm/delay.h>
23
24#include <asm-generic/iomap.h>
25
26#define __ide_mm_insw(p, a, c) _insw_ns((volatile u16 __iomem *)(p), (a), (c))
27#define __ide_mm_insl(p, a, c) _insl_ns((volatile u32 __iomem *)(p), (a), (c))
28#define __ide_mm_outsw(p, a, c) _outsw_ns((volatile u16 __iomem *)(p), (a), (c))
29#define __ide_mm_outsl(p, a, c) _outsl_ns((volatile u32 __iomem *)(p), (a), (c))
30
31
32#define SIO_CONFIG_RA 0x398
33#define SIO_CONFIG_RD 0x399
34
35#define SLOW_DOWN_IO
36
37extern unsigned long isa_io_base;
38extern unsigned long pci_io_base;
39extern unsigned long io_page_mask;
40
41#define MAX_ISA_PORT 0x10000
42
43#define _IO_IS_VALID(port) ((port) >= MAX_ISA_PORT || (1 << (port>>PAGE_SHIFT)) \
44 & io_page_mask)
45
46#ifdef CONFIG_PPC_ISERIES
47/* __raw_* accessors aren't supported on iSeries */
48#define __raw_readb(addr) { BUG(); 0; }
49#define __raw_readw(addr) { BUG(); 0; }
50#define __raw_readl(addr) { BUG(); 0; }
51#define __raw_readq(addr) { BUG(); 0; }
52#define __raw_writeb(v, addr) { BUG(); 0; }
53#define __raw_writew(v, addr) { BUG(); 0; }
54#define __raw_writel(v, addr) { BUG(); 0; }
55#define __raw_writeq(v, addr) { BUG(); 0; }
56#define readb(addr) iSeries_Read_Byte(addr)
57#define readw(addr) iSeries_Read_Word(addr)
58#define readl(addr) iSeries_Read_Long(addr)
59#define writeb(data, addr) iSeries_Write_Byte((data),(addr))
60#define writew(data, addr) iSeries_Write_Word((data),(addr))
61#define writel(data, addr) iSeries_Write_Long((data),(addr))
62#define memset_io(a,b,c) iSeries_memset_io((a),(b),(c))
63#define memcpy_fromio(a,b,c) iSeries_memcpy_fromio((a), (b), (c))
64#define memcpy_toio(a,b,c) iSeries_memcpy_toio((a), (b), (c))
65
66#define inb(addr) readb(((void __iomem *)(long)(addr)))
67#define inw(addr) readw(((void __iomem *)(long)(addr)))
68#define inl(addr) readl(((void __iomem *)(long)(addr)))
69#define outb(data,addr) writeb(data,((void __iomem *)(long)(addr)))
70#define outw(data,addr) writew(data,((void __iomem *)(long)(addr)))
71#define outl(data,addr) writel(data,((void __iomem *)(long)(addr)))
72/*
73 * The *_ns versions below don't do byte-swapping.
74 * Neither do the standard versions now, these are just here
75 * for older code.
76 */
77#define insw_ns(port, buf, ns) _insw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
78#define insl_ns(port, buf, nl) _insl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
79#else
80
81static inline unsigned char __raw_readb(const volatile void __iomem *addr)
82{
83 return *(volatile unsigned char __force *)addr;
84}
85static inline unsigned short __raw_readw(const volatile void __iomem *addr)
86{
87 return *(volatile unsigned short __force *)addr;
88}
89static inline unsigned int __raw_readl(const volatile void __iomem *addr)
90{
91 return *(volatile unsigned int __force *)addr;
92}
93static inline unsigned long __raw_readq(const volatile void __iomem *addr)
94{
95 return *(volatile unsigned long __force *)addr;
96}
97static inline void __raw_writeb(unsigned char v, volatile void __iomem *addr)
98{
99 *(volatile unsigned char __force *)addr = v;
100}
101static inline void __raw_writew(unsigned short v, volatile void __iomem *addr)
102{
103 *(volatile unsigned short __force *)addr = v;
104}
105static inline void __raw_writel(unsigned int v, volatile void __iomem *addr)
106{
107 *(volatile unsigned int __force *)addr = v;
108}
109static inline void __raw_writeq(unsigned long v, volatile void __iomem *addr)
110{
111 *(volatile unsigned long __force *)addr = v;
112}
113#define readb(addr) eeh_readb(addr)
114#define readw(addr) eeh_readw(addr)
115#define readl(addr) eeh_readl(addr)
116#define readq(addr) eeh_readq(addr)
117#define writeb(data, addr) eeh_writeb((data), (addr))
118#define writew(data, addr) eeh_writew((data), (addr))
119#define writel(data, addr) eeh_writel((data), (addr))
120#define writeq(data, addr) eeh_writeq((data), (addr))
121#define memset_io(a,b,c) eeh_memset_io((a),(b),(c))
122#define memcpy_fromio(a,b,c) eeh_memcpy_fromio((a),(b),(c))
123#define memcpy_toio(a,b,c) eeh_memcpy_toio((a),(b),(c))
124#define inb(port) eeh_inb((unsigned long)port)
125#define outb(val, port) eeh_outb(val, (unsigned long)port)
126#define inw(port) eeh_inw((unsigned long)port)
127#define outw(val, port) eeh_outw(val, (unsigned long)port)
128#define inl(port) eeh_inl((unsigned long)port)
129#define outl(val, port) eeh_outl(val, (unsigned long)port)
130
131/*
132 * The insw/outsw/insl/outsl macros don't do byte-swapping.
133 * They are only used in practice for transferring buffers which
134 * are arrays of bytes, and byte-swapping is not appropriate in
135 * that case. - paulus */
136#define insb(port, buf, ns) eeh_insb((port), (buf), (ns))
137#define insw(port, buf, ns) eeh_insw_ns((port), (buf), (ns))
138#define insl(port, buf, nl) eeh_insl_ns((port), (buf), (nl))
139#define insw_ns(port, buf, ns) eeh_insw_ns((port), (buf), (ns))
140#define insl_ns(port, buf, nl) eeh_insl_ns((port), (buf), (nl))
141
142#define outsb(port, buf, ns) _outsb((u8 __iomem *)((port)+pci_io_base), (buf), (ns))
143#define outsw(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
144#define outsl(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
145
146#endif
147
148#define readb_relaxed(addr) readb(addr)
149#define readw_relaxed(addr) readw(addr)
150#define readl_relaxed(addr) readl(addr)
151#define readq_relaxed(addr) readq(addr)
152
153extern void _insb(volatile u8 __iomem *port, void *buf, int ns);
154extern void _outsb(volatile u8 __iomem *port, const void *buf, int ns);
155extern void _insw(volatile u16 __iomem *port, void *buf, int ns);
156extern void _outsw(volatile u16 __iomem *port, const void *buf, int ns);
157extern void _insl(volatile u32 __iomem *port, void *buf, int nl);
158extern void _outsl(volatile u32 __iomem *port, const void *buf, int nl);
159extern void _insw_ns(volatile u16 __iomem *port, void *buf, int ns);
160extern void _outsw_ns(volatile u16 __iomem *port, const void *buf, int ns);
161extern void _insl_ns(volatile u32 __iomem *port, void *buf, int nl);
162extern void _outsl_ns(volatile u32 __iomem *port, const void *buf, int nl);
163
164#define mmiowb()
165
166/*
167 * output pause versions need a delay at least for the
168 * w83c105 ide controller in a p610.
169 */
170#define inb_p(port) inb(port)
171#define outb_p(val, port) (udelay(1), outb((val), (port)))
172#define inw_p(port) inw(port)
173#define outw_p(val, port) (udelay(1), outw((val), (port)))
174#define inl_p(port) inl(port)
175#define outl_p(val, port) (udelay(1), outl((val), (port)))
176
177/*
178 * The *_ns versions below don't do byte-swapping.
179 * Neither do the standard versions now, these are just here
180 * for older code.
181 */
182#define outsw_ns(port, buf, ns) _outsw_ns((u16 __iomem *)((port)+pci_io_base), (buf), (ns))
183#define outsl_ns(port, buf, nl) _outsl_ns((u32 __iomem *)((port)+pci_io_base), (buf), (nl))
184
185
186#define IO_SPACE_LIMIT ~(0UL)
187
188
189#ifdef __KERNEL__
190extern int __ioremap_explicit(unsigned long p_addr, unsigned long v_addr,
191 unsigned long size, unsigned long flags);
192extern void __iomem *__ioremap(unsigned long address, unsigned long size,
193 unsigned long flags);
194
195/**
196 * ioremap - map bus memory into CPU space
197 * @address: bus address of the memory
198 * @size: size of the resource to map
199 *
200 * ioremap performs a platform specific sequence of operations to
201 * make bus memory CPU accessible via the readb/readw/readl/writeb/
202 * writew/writel functions and the other mmio helpers. The returned
203 * address is not guaranteed to be usable directly as a virtual
204 * address.
205 */
206extern void __iomem *ioremap(unsigned long address, unsigned long size);
207
208#define ioremap_nocache(addr, size) ioremap((addr), (size))
209extern int iounmap_explicit(volatile void __iomem *addr, unsigned long size);
210extern void iounmap(volatile void __iomem *addr);
211extern void __iomem * reserve_phb_iospace(unsigned long size);
212
213/**
214 * virt_to_phys - map virtual addresses to physical
215 * @address: address to remap
216 *
217 * The returned physical address is the physical (CPU) mapping for
218 * the memory address given. It is only valid to use this function on
219 * addresses directly mapped or allocated via kmalloc.
220 *
221 * This function does not give bus mappings for DMA transfers. In
222 * almost all conceivable cases a device driver should not be using
223 * this function
224 */
225static inline unsigned long virt_to_phys(volatile void * address)
226{
227 return __pa((unsigned long)address);
228}
229
230/**
231 * phys_to_virt - map physical address to virtual
232 * @address: address to remap
233 *
234 * The returned virtual address is a current CPU mapping for
235 * the memory address given. It is only valid to use this function on
236 * addresses that have a kernel mapping
237 *
238 * This function does not handle bus mappings for DMA transfers. In
239 * almost all conceivable cases a device driver should not be using
240 * this function
241 */
242static inline void * phys_to_virt(unsigned long address)
243{
244 return (void *)__va(address);
245}
246
247/*
248 * Change "struct page" to physical address.
249 */
250#define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT)
251
252/* We do NOT want virtual merging, it would put too much pressure on
253 * our iommu allocator. Instead, we want drivers to be smart enough
254 * to coalesce sglists that happen to have been mapped in a contiguous
255 * way by the iommu
256 */
257#define BIO_VMERGE_BOUNDARY 0
258
259#endif /* __KERNEL__ */
260
261static inline void iosync(void)
262{
263 __asm__ __volatile__ ("sync" : : : "memory");
264}
265
266/* Enforce in-order execution of data I/O.
267 * No distinction between read/write on PPC; use eieio for all three.
268 */
269#define iobarrier_rw() eieio()
270#define iobarrier_r() eieio()
271#define iobarrier_w() eieio()
272
273/*
274 * 8, 16 and 32 bit, big and little endian I/O operations, with barrier.
275 * These routines do not perform EEH-related I/O address translation,
276 * and should not be used directly by device drivers. Use inb/readb
277 * instead.
278 */
279static inline int in_8(const volatile unsigned char __iomem *addr)
280{
281 int ret;
282
283 __asm__ __volatile__("lbz%U1%X1 %0,%1; twi 0,%0,0; isync"
284 : "=r" (ret) : "m" (*addr));
285 return ret;
286}
287
288static inline void out_8(volatile unsigned char __iomem *addr, int val)
289{
290 __asm__ __volatile__("stb%U0%X0 %1,%0; sync"
291 : "=m" (*addr) : "r" (val));
292}
293
294static inline int in_le16(const volatile unsigned short __iomem *addr)
295{
296 int ret;
297
298 __asm__ __volatile__("lhbrx %0,0,%1; twi 0,%0,0; isync"
299 : "=r" (ret) : "r" (addr), "m" (*addr));
300 return ret;
301}
302
303static inline int in_be16(const volatile unsigned short __iomem *addr)
304{
305 int ret;
306
307 __asm__ __volatile__("lhz%U1%X1 %0,%1; twi 0,%0,0; isync"
308 : "=r" (ret) : "m" (*addr));
309 return ret;
310}
311
312static inline void out_le16(volatile unsigned short __iomem *addr, int val)
313{
314 __asm__ __volatile__("sthbrx %1,0,%2; sync"
315 : "=m" (*addr) : "r" (val), "r" (addr));
316}
317
318static inline void out_be16(volatile unsigned short __iomem *addr, int val)
319{
320 __asm__ __volatile__("sth%U0%X0 %1,%0; sync"
321 : "=m" (*addr) : "r" (val));
322}
323
324static inline unsigned in_le32(const volatile unsigned __iomem *addr)
325{
326 unsigned ret;
327
328 __asm__ __volatile__("lwbrx %0,0,%1; twi 0,%0,0; isync"
329 : "=r" (ret) : "r" (addr), "m" (*addr));
330 return ret;
331}
332
333static inline unsigned in_be32(const volatile unsigned __iomem *addr)
334{
335 unsigned ret;
336
337 __asm__ __volatile__("lwz%U1%X1 %0,%1; twi 0,%0,0; isync"
338 : "=r" (ret) : "m" (*addr));
339 return ret;
340}
341
342static inline void out_le32(volatile unsigned __iomem *addr, int val)
343{
344 __asm__ __volatile__("stwbrx %1,0,%2; sync" : "=m" (*addr)
345 : "r" (val), "r" (addr));
346}
347
348static inline void out_be32(volatile unsigned __iomem *addr, int val)
349{
350 __asm__ __volatile__("stw%U0%X0 %1,%0; sync"
351 : "=m" (*addr) : "r" (val));
352}
353
354static inline unsigned long in_le64(const volatile unsigned long __iomem *addr)
355{
356 unsigned long tmp, ret;
357
358 __asm__ __volatile__(
359 "ld %1,0(%2)\n"
360 "twi 0,%1,0\n"
361 "isync\n"
362 "rldimi %0,%1,5*8,1*8\n"
363 "rldimi %0,%1,3*8,2*8\n"
364 "rldimi %0,%1,1*8,3*8\n"
365 "rldimi %0,%1,7*8,4*8\n"
366 "rldicl %1,%1,32,0\n"
367 "rlwimi %0,%1,8,8,31\n"
368 "rlwimi %0,%1,24,16,23\n"
369 : "=r" (ret) , "=r" (tmp) : "b" (addr) , "m" (*addr));
370 return ret;
371}
372
373static inline unsigned long in_be64(const volatile unsigned long __iomem *addr)
374{
375 unsigned long ret;
376
377 __asm__ __volatile__("ld%U1%X1 %0,%1; twi 0,%0,0; isync"
378 : "=r" (ret) : "m" (*addr));
379 return ret;
380}
381
382static inline void out_le64(volatile unsigned long __iomem *addr, unsigned long val)
383{
384 unsigned long tmp;
385
386 __asm__ __volatile__(
387 "rldimi %0,%1,5*8,1*8\n"
388 "rldimi %0,%1,3*8,2*8\n"
389 "rldimi %0,%1,1*8,3*8\n"
390 "rldimi %0,%1,7*8,4*8\n"
391 "rldicl %1,%1,32,0\n"
392 "rlwimi %0,%1,8,8,31\n"
393 "rlwimi %0,%1,24,16,23\n"
394 "std %0,0(%3)\n"
395 "sync"
396 : "=&r" (tmp) , "=&r" (val) : "1" (val) , "b" (addr) , "m" (*addr));
397}
398
399static inline void out_be64(volatile unsigned long __iomem *addr, unsigned long val)
400{
401 __asm__ __volatile__("std%U0%X0 %1,%0; sync" : "=m" (*addr) : "r" (val));
402}
403
404#ifndef CONFIG_PPC_ISERIES
405#include <asm/eeh.h>
406#endif
407
408#ifdef __KERNEL__
409
410/**
411 * check_signature - find BIOS signatures
412 * @io_addr: mmio address to check
413 * @signature: signature block
414 * @length: length of signature
415 *
416 * Perform a signature comparison with the mmio address io_addr. This
417 * address should have been obtained by ioremap.
418 * Returns 1 on a match.
419 */
420static inline int check_signature(const volatile void __iomem * io_addr,
421 const unsigned char *signature, int length)
422{
423 int retval = 0;
424#ifndef CONFIG_PPC_ISERIES
425 do {
426 if (readb(io_addr) != *signature)
427 goto out;
428 io_addr++;
429 signature++;
430 length--;
431 } while (length);
432 retval = 1;
433out:
434#endif
435 return retval;
436}
437
438/* Nothing to do */
439
440#define dma_cache_inv(_start,_size) do { } while (0)
441#define dma_cache_wback(_start,_size) do { } while (0)
442#define dma_cache_wback_inv(_start,_size) do { } while (0)
443
444/* Check of existence of legacy devices */
445extern int check_legacy_ioport(unsigned long base_port);
446
447
448/*
449 * Convert a physical pointer to a virtual kernel pointer for /dev/mem
450 * access
451 */
452#define xlate_dev_mem_ptr(p) __va(p)
453
454/*
455 * Convert a virtual cached pointer to an uncached pointer
456 */
457#define xlate_dev_kmem_ptr(p) p
458
459#endif /* __KERNEL__ */
460
461#endif /* CONFIG_PPC64 */
462#endif /* _ASM_POWERPC_IO_H */
diff --git a/include/asm-powerpc/ioctls.h b/include/asm-powerpc/ioctls.h
index 5b94ff489b8b..279a6229584b 100644
--- a/include/asm-powerpc/ioctls.h
+++ b/include/asm-powerpc/ioctls.h
@@ -62,6 +62,9 @@
62# define TIOCM_DSR 0x100 62# define TIOCM_DSR 0x100
63# define TIOCM_CD TIOCM_CAR 63# define TIOCM_CD TIOCM_CAR
64# define TIOCM_RI TIOCM_RNG 64# define TIOCM_RI TIOCM_RNG
65#define TIOCM_OUT1 0x2000
66#define TIOCM_OUT2 0x4000
67#define TIOCM_LOOP 0x8000
65 68
66#define TIOCGSOFTCAR 0x5419 69#define TIOCGSOFTCAR 0x5419
67#define TIOCSSOFTCAR 0x541A 70#define TIOCSSOFTCAR 0x541A
diff --git a/include/asm-powerpc/iommu.h b/include/asm-powerpc/iommu.h
new file mode 100644
index 000000000000..f89f06050893
--- /dev/null
+++ b/include/asm-powerpc/iommu.h
@@ -0,0 +1,118 @@
1/*
2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
3 * Rewrite, cleanup:
4 * Copyright (C) 2004 Olof Johansson <olof@lixom.net>, 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 the
14 * 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_IOMMU_H
22#define _ASM_IOMMU_H
23
24#include <linux/config.h>
25#include <asm/types.h>
26#include <linux/spinlock.h>
27#include <linux/device.h>
28#include <linux/dma-mapping.h>
29
30/*
31 * IOMAP_MAX_ORDER defines the largest contiguous block
32 * of dma space we can get. IOMAP_MAX_ORDER = 13
33 * allows up to 2**12 pages (4096 * 4096) = 16 MB
34 */
35#define IOMAP_MAX_ORDER 13
36
37struct iommu_table {
38 unsigned long it_busno; /* Bus number this table belongs to */
39 unsigned long it_size; /* Size of iommu table in entries */
40 unsigned long it_offset; /* Offset into global table */
41 unsigned long it_base; /* mapped address of tce table */
42 unsigned long it_index; /* which iommu table this is */
43 unsigned long it_type; /* type: PCI or Virtual Bus */
44 unsigned long it_blocksize; /* Entries in each block (cacheline) */
45 unsigned long it_hint; /* Hint for next alloc */
46 unsigned long it_largehint; /* Hint for large allocs */
47 unsigned long it_halfpoint; /* Breaking point for small/large allocs */
48 spinlock_t it_lock; /* Protects it_map */
49 unsigned long *it_map; /* A simple allocation bitmap for now */
50};
51
52struct scatterlist;
53struct device_node;
54
55#ifdef CONFIG_PPC_MULTIPLATFORM
56
57/* Walks all buses and creates iommu tables */
58extern void iommu_setup_pSeries(void);
59extern void iommu_setup_u3(void);
60
61/* Frees table for an individual device node */
62extern void iommu_free_table(struct device_node *dn);
63
64#endif /* CONFIG_PPC_MULTIPLATFORM */
65
66#ifdef CONFIG_PPC_PSERIES
67
68/* Creates table for an individual device node */
69extern void iommu_devnode_init_pSeries(struct device_node *dn);
70
71#endif /* CONFIG_PPC_PSERIES */
72
73#ifdef CONFIG_PPC_ISERIES
74
75/* Creates table for an individual device node */
76extern void iommu_devnode_init_iSeries(struct device_node *dn);
77/* Get table parameters from HV */
78extern void iommu_table_getparms_iSeries(unsigned long busno,
79 unsigned char slotno,
80 unsigned char virtbus,
81 struct iommu_table* tbl);
82
83#endif /* CONFIG_PPC_ISERIES */
84
85/* Initializes an iommu_table based in values set in the passed-in
86 * structure
87 */
88extern struct iommu_table *iommu_init_table(struct iommu_table * tbl);
89
90extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl,
91 struct scatterlist *sglist, int nelems,
92 enum dma_data_direction direction);
93extern void iommu_unmap_sg(struct iommu_table *tbl, struct scatterlist *sglist,
94 int nelems, enum dma_data_direction direction);
95
96extern void *iommu_alloc_coherent(struct iommu_table *tbl, size_t size,
97 dma_addr_t *dma_handle, gfp_t flag);
98extern void iommu_free_coherent(struct iommu_table *tbl, size_t size,
99 void *vaddr, dma_addr_t dma_handle);
100extern dma_addr_t iommu_map_single(struct iommu_table *tbl, void *vaddr,
101 size_t size, enum dma_data_direction direction);
102extern void iommu_unmap_single(struct iommu_table *tbl, dma_addr_t dma_handle,
103 size_t size, enum dma_data_direction direction);
104
105extern void iommu_init_early_pSeries(void);
106extern void iommu_init_early_iSeries(void);
107extern void iommu_init_early_u3(void);
108
109#ifdef CONFIG_PCI
110extern void pci_iommu_init(void);
111extern void pci_direct_iommu_init(void);
112#else
113static inline void pci_iommu_init(void) { }
114#endif
115
116extern void alloc_u3_dart_table(void);
117
118#endif /* _ASM_IOMMU_H */
diff --git a/include/asm-powerpc/ipcbuf.h b/include/asm-powerpc/ipcbuf.h
new file mode 100644
index 000000000000..2c3e1d94db1d
--- /dev/null
+++ b/include/asm-powerpc/ipcbuf.h
@@ -0,0 +1,34 @@
1#ifndef _ASM_POWERPC_IPCBUF_H
2#define _ASM_POWERPC_IPCBUF_H
3
4/*
5 * The ipc64_perm structure for the powerpc is identical to
6 * kern_ipc_perm as we have always had 32-bit UIDs and GIDs in the
7 * kernel. Note extra padding because this structure is passed back
8 * and forth between kernel and user space. Pad space is left for:
9 * - 1 32-bit value to fill up for 8-byte alignment
10 * - 2 miscellaneous 64-bit values
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17
18#include <linux/types.h>
19
20struct ipc64_perm
21{
22 __kernel_key_t key;
23 __kernel_uid_t uid;
24 __kernel_gid_t gid;
25 __kernel_uid_t cuid;
26 __kernel_gid_t cgid;
27 __kernel_mode_t mode;
28 unsigned int seq;
29 unsigned int __pad1;
30 unsigned long long __unused1;
31 unsigned long long __unused2;
32};
33
34#endif /* _ASM_POWERPC_IPCBUF_H */
diff --git a/include/asm-powerpc/irq.h b/include/asm-powerpc/irq.h
new file mode 100644
index 000000000000..8eb7e857ec4c
--- /dev/null
+++ b/include/asm-powerpc/irq.h
@@ -0,0 +1,504 @@
1#ifdef __KERNEL__
2#ifndef _ASM_POWERPC_IRQ_H
3#define _ASM_POWERPC_IRQ_H
4
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#include <linux/config.h>
13#include <linux/threads.h>
14
15#include <asm/types.h>
16#include <asm/atomic.h>
17
18/* this number is used when no interrupt has been assigned */
19#define NO_IRQ (-1)
20
21/*
22 * These constants are used for passing information about interrupt
23 * signal polarity and level/edge sensing to the low-level PIC chip
24 * drivers.
25 */
26#define IRQ_SENSE_MASK 0x1
27#define IRQ_SENSE_LEVEL 0x1 /* interrupt on active level */
28#define IRQ_SENSE_EDGE 0x0 /* interrupt triggered by edge */
29
30#define IRQ_POLARITY_MASK 0x2
31#define IRQ_POLARITY_POSITIVE 0x2 /* high level or low->high edge */
32#define IRQ_POLARITY_NEGATIVE 0x0 /* low level or high->low edge */
33
34/*
35 * IRQ line status macro IRQ_PER_CPU is used
36 */
37#define ARCH_HAS_IRQ_PER_CPU
38
39#define get_irq_desc(irq) (&irq_desc[(irq)])
40
41/* Define a way to iterate across irqs. */
42#define for_each_irq(i) \
43 for ((i) = 0; (i) < NR_IRQS; ++(i))
44
45#ifdef CONFIG_PPC64
46
47/*
48 * Maximum number of interrupt sources that we can handle.
49 */
50#define NR_IRQS 512
51
52/* Interrupt numbers are virtual in case they are sparsely
53 * distributed by the hardware.
54 */
55extern unsigned int virt_irq_to_real_map[NR_IRQS];
56
57/* Create a mapping for a real_irq if it doesn't already exist.
58 * Return the virtual irq as a convenience.
59 */
60int virt_irq_create_mapping(unsigned int real_irq);
61void virt_irq_init(void);
62
63static inline unsigned int virt_irq_to_real(unsigned int virt_irq)
64{
65 return virt_irq_to_real_map[virt_irq];
66}
67
68extern unsigned int real_irq_to_virt_slowpath(unsigned int real_irq);
69
70/*
71 * List of interrupt controllers.
72 */
73#define IC_INVALID 0
74#define IC_OPEN_PIC 1
75#define IC_PPC_XIC 2
76#define IC_CELL_PIC 3
77#define IC_ISERIES 4
78
79extern u64 ppc64_interrupt_controller;
80
81#else /* 32-bit */
82
83#if defined(CONFIG_40x)
84#include <asm/ibm4xx.h>
85
86#ifndef NR_BOARD_IRQS
87#define NR_BOARD_IRQS 0
88#endif
89
90#ifndef UIC_WIDTH /* Number of interrupts per device */
91#define UIC_WIDTH 32
92#endif
93
94#ifndef NR_UICS /* number of UIC devices */
95#define NR_UICS 1
96#endif
97
98#if defined (CONFIG_403)
99/*
100 * The PowerPC 403 cores' Asynchronous Interrupt Controller (AIC) has
101 * 32 possible interrupts, a majority of which are not implemented on
102 * all cores. There are six configurable, external interrupt pins and
103 * there are eight internal interrupts for the on-chip serial port
104 * (SPU), DMA controller, and JTAG controller.
105 *
106 */
107
108#define NR_AIC_IRQS 32
109#define NR_IRQS (NR_AIC_IRQS + NR_BOARD_IRQS)
110
111#elif !defined (CONFIG_403)
112
113/*
114 * The PowerPC 405 cores' Universal Interrupt Controller (UIC) has 32
115 * possible interrupts as well. There are seven, configurable external
116 * interrupt pins and there are 17 internal interrupts for the on-chip
117 * serial port, DMA controller, on-chip Ethernet controller, PCI, etc.
118 *
119 */
120
121
122#define NR_UIC_IRQS UIC_WIDTH
123#define NR_IRQS ((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS)
124#endif
125
126#elif defined(CONFIG_44x)
127#include <asm/ibm44x.h>
128
129#define NR_UIC_IRQS 32
130#define NR_IRQS ((NR_UIC_IRQS * NR_UICS) + NR_BOARD_IRQS)
131
132#elif defined(CONFIG_8xx)
133
134/* Now include the board configuration specific associations.
135*/
136#include <asm/mpc8xx.h>
137
138/* The MPC8xx cores have 16 possible interrupts. There are eight
139 * possible level sensitive interrupts assigned and generated internally
140 * from such devices as CPM, PCMCIA, RTC, PIT, TimeBase and Decrementer.
141 * There are eight external interrupts (IRQs) that can be configured
142 * as either level or edge sensitive.
143 *
144 * On some implementations, there is also the possibility of an 8259
145 * through the PCI and PCI-ISA bridges.
146 *
147 * We are "flattening" the interrupt vectors of the cascaded CPM
148 * and 8259 interrupt controllers so that we can uniquely identify
149 * any interrupt source with a single integer.
150 */
151#define NR_SIU_INTS 16
152#define NR_CPM_INTS 32
153#ifndef NR_8259_INTS
154#define NR_8259_INTS 0
155#endif
156
157#define SIU_IRQ_OFFSET 0
158#define CPM_IRQ_OFFSET (SIU_IRQ_OFFSET + NR_SIU_INTS)
159#define I8259_IRQ_OFFSET (CPM_IRQ_OFFSET + NR_CPM_INTS)
160
161#define NR_IRQS (NR_SIU_INTS + NR_CPM_INTS + NR_8259_INTS)
162
163/* These values must be zero-based and map 1:1 with the SIU configuration.
164 * They are used throughout the 8xx I/O subsystem to generate
165 * interrupt masks, flags, and other control patterns. This is why the
166 * current kernel assumption of the 8259 as the base controller is such
167 * a pain in the butt.
168 */
169#define SIU_IRQ0 (0) /* Highest priority */
170#define SIU_LEVEL0 (1)
171#define SIU_IRQ1 (2)
172#define SIU_LEVEL1 (3)
173#define SIU_IRQ2 (4)
174#define SIU_LEVEL2 (5)
175#define SIU_IRQ3 (6)
176#define SIU_LEVEL3 (7)
177#define SIU_IRQ4 (8)
178#define SIU_LEVEL4 (9)
179#define SIU_IRQ5 (10)
180#define SIU_LEVEL5 (11)
181#define SIU_IRQ6 (12)
182#define SIU_LEVEL6 (13)
183#define SIU_IRQ7 (14)
184#define SIU_LEVEL7 (15)
185
186#define MPC8xx_INT_FEC1 SIU_LEVEL1
187#define MPC8xx_INT_FEC2 SIU_LEVEL3
188
189#define MPC8xx_INT_SCC1 (CPM_IRQ_OFFSET + CPMVEC_SCC1)
190#define MPC8xx_INT_SCC2 (CPM_IRQ_OFFSET + CPMVEC_SCC2)
191#define MPC8xx_INT_SCC3 (CPM_IRQ_OFFSET + CPMVEC_SCC3)
192#define MPC8xx_INT_SCC4 (CPM_IRQ_OFFSET + CPMVEC_SCC4)
193#define MPC8xx_INT_SMC1 (CPM_IRQ_OFFSET + CPMVEC_SMC1)
194#define MPC8xx_INT_SMC2 (CPM_IRQ_OFFSET + CPMVEC_SMC2)
195
196/* The internal interrupts we can configure as we see fit.
197 * My personal preference is CPM at level 2, which puts it above the
198 * MBX PCI/ISA/IDE interrupts.
199 */
200#ifndef PIT_INTERRUPT
201#define PIT_INTERRUPT SIU_LEVEL0
202#endif
203#ifndef CPM_INTERRUPT
204#define CPM_INTERRUPT SIU_LEVEL2
205#endif
206#ifndef PCMCIA_INTERRUPT
207#define PCMCIA_INTERRUPT SIU_LEVEL6
208#endif
209#ifndef DEC_INTERRUPT
210#define DEC_INTERRUPT SIU_LEVEL7
211#endif
212
213/* Some internal interrupt registers use an 8-bit mask for the interrupt
214 * level instead of a number.
215 */
216#define mk_int_int_mask(IL) (1 << (7 - (IL/2)))
217
218#elif defined(CONFIG_83xx)
219#include <asm/mpc83xx.h>
220
221#define NR_IRQS (NR_IPIC_INTS)
222
223#elif defined(CONFIG_85xx)
224/* Now include the board configuration specific associations.
225*/
226#include <asm/mpc85xx.h>
227
228/* The MPC8548 openpic has 48 internal interrupts and 12 external
229 * interrupts.
230 *
231 * We are "flattening" the interrupt vectors of the cascaded CPM
232 * so that we can uniquely identify any interrupt source with a
233 * single integer.
234 */
235#define NR_CPM_INTS 64
236#define NR_EPIC_INTS 60
237#ifndef NR_8259_INTS
238#define NR_8259_INTS 0
239#endif
240#define NUM_8259_INTERRUPTS NR_8259_INTS
241
242#ifndef CPM_IRQ_OFFSET
243#define CPM_IRQ_OFFSET 0
244#endif
245
246#define NR_IRQS (NR_EPIC_INTS + NR_CPM_INTS + NR_8259_INTS)
247
248/* Internal IRQs on MPC85xx OpenPIC */
249
250#ifndef MPC85xx_OPENPIC_IRQ_OFFSET
251#ifdef CONFIG_CPM2
252#define MPC85xx_OPENPIC_IRQ_OFFSET (CPM_IRQ_OFFSET + NR_CPM_INTS)
253#else
254#define MPC85xx_OPENPIC_IRQ_OFFSET 0
255#endif
256#endif
257
258/* Not all of these exist on all MPC85xx implementations */
259#define MPC85xx_IRQ_L2CACHE ( 0 + MPC85xx_OPENPIC_IRQ_OFFSET)
260#define MPC85xx_IRQ_ECM ( 1 + MPC85xx_OPENPIC_IRQ_OFFSET)
261#define MPC85xx_IRQ_DDR ( 2 + MPC85xx_OPENPIC_IRQ_OFFSET)
262#define MPC85xx_IRQ_LBIU ( 3 + MPC85xx_OPENPIC_IRQ_OFFSET)
263#define MPC85xx_IRQ_DMA0 ( 4 + MPC85xx_OPENPIC_IRQ_OFFSET)
264#define MPC85xx_IRQ_DMA1 ( 5 + MPC85xx_OPENPIC_IRQ_OFFSET)
265#define MPC85xx_IRQ_DMA2 ( 6 + MPC85xx_OPENPIC_IRQ_OFFSET)
266#define MPC85xx_IRQ_DMA3 ( 7 + MPC85xx_OPENPIC_IRQ_OFFSET)
267#define MPC85xx_IRQ_PCI1 ( 8 + MPC85xx_OPENPIC_IRQ_OFFSET)
268#define MPC85xx_IRQ_PCI2 ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET)
269#define MPC85xx_IRQ_RIO_ERROR ( 9 + MPC85xx_OPENPIC_IRQ_OFFSET)
270#define MPC85xx_IRQ_RIO_BELL (10 + MPC85xx_OPENPIC_IRQ_OFFSET)
271#define MPC85xx_IRQ_RIO_TX (11 + MPC85xx_OPENPIC_IRQ_OFFSET)
272#define MPC85xx_IRQ_RIO_RX (12 + MPC85xx_OPENPIC_IRQ_OFFSET)
273#define MPC85xx_IRQ_TSEC1_TX (13 + MPC85xx_OPENPIC_IRQ_OFFSET)
274#define MPC85xx_IRQ_TSEC1_RX (14 + MPC85xx_OPENPIC_IRQ_OFFSET)
275#define MPC85xx_IRQ_TSEC3_TX (15 + MPC85xx_OPENPIC_IRQ_OFFSET)
276#define MPC85xx_IRQ_TSEC3_RX (16 + MPC85xx_OPENPIC_IRQ_OFFSET)
277#define MPC85xx_IRQ_TSEC3_ERROR (17 + MPC85xx_OPENPIC_IRQ_OFFSET)
278#define MPC85xx_IRQ_TSEC1_ERROR (18 + MPC85xx_OPENPIC_IRQ_OFFSET)
279#define MPC85xx_IRQ_TSEC2_TX (19 + MPC85xx_OPENPIC_IRQ_OFFSET)
280#define MPC85xx_IRQ_TSEC2_RX (20 + MPC85xx_OPENPIC_IRQ_OFFSET)
281#define MPC85xx_IRQ_TSEC4_TX (21 + MPC85xx_OPENPIC_IRQ_OFFSET)
282#define MPC85xx_IRQ_TSEC4_RX (22 + MPC85xx_OPENPIC_IRQ_OFFSET)
283#define MPC85xx_IRQ_TSEC4_ERROR (23 + MPC85xx_OPENPIC_IRQ_OFFSET)
284#define MPC85xx_IRQ_TSEC2_ERROR (24 + MPC85xx_OPENPIC_IRQ_OFFSET)
285#define MPC85xx_IRQ_FEC (25 + MPC85xx_OPENPIC_IRQ_OFFSET)
286#define MPC85xx_IRQ_DUART (26 + MPC85xx_OPENPIC_IRQ_OFFSET)
287#define MPC85xx_IRQ_IIC1 (27 + MPC85xx_OPENPIC_IRQ_OFFSET)
288#define MPC85xx_IRQ_PERFMON (28 + MPC85xx_OPENPIC_IRQ_OFFSET)
289#define MPC85xx_IRQ_SEC2 (29 + MPC85xx_OPENPIC_IRQ_OFFSET)
290#define MPC85xx_IRQ_CPM (30 + MPC85xx_OPENPIC_IRQ_OFFSET)
291
292/* The 12 external interrupt lines */
293#define MPC85xx_IRQ_EXT0 (48 + MPC85xx_OPENPIC_IRQ_OFFSET)
294#define MPC85xx_IRQ_EXT1 (49 + MPC85xx_OPENPIC_IRQ_OFFSET)
295#define MPC85xx_IRQ_EXT2 (50 + MPC85xx_OPENPIC_IRQ_OFFSET)
296#define MPC85xx_IRQ_EXT3 (51 + MPC85xx_OPENPIC_IRQ_OFFSET)
297#define MPC85xx_IRQ_EXT4 (52 + MPC85xx_OPENPIC_IRQ_OFFSET)
298#define MPC85xx_IRQ_EXT5 (53 + MPC85xx_OPENPIC_IRQ_OFFSET)
299#define MPC85xx_IRQ_EXT6 (54 + MPC85xx_OPENPIC_IRQ_OFFSET)
300#define MPC85xx_IRQ_EXT7 (55 + MPC85xx_OPENPIC_IRQ_OFFSET)
301#define MPC85xx_IRQ_EXT8 (56 + MPC85xx_OPENPIC_IRQ_OFFSET)
302#define MPC85xx_IRQ_EXT9 (57 + MPC85xx_OPENPIC_IRQ_OFFSET)
303#define MPC85xx_IRQ_EXT10 (58 + MPC85xx_OPENPIC_IRQ_OFFSET)
304#define MPC85xx_IRQ_EXT11 (59 + MPC85xx_OPENPIC_IRQ_OFFSET)
305
306/* CPM related interrupts */
307#define SIU_INT_ERROR ((uint)0x00+CPM_IRQ_OFFSET)
308#define SIU_INT_I2C ((uint)0x01+CPM_IRQ_OFFSET)
309#define SIU_INT_SPI ((uint)0x02+CPM_IRQ_OFFSET)
310#define SIU_INT_RISC ((uint)0x03+CPM_IRQ_OFFSET)
311#define SIU_INT_SMC1 ((uint)0x04+CPM_IRQ_OFFSET)
312#define SIU_INT_SMC2 ((uint)0x05+CPM_IRQ_OFFSET)
313#define SIU_INT_USB ((uint)0x0b+CPM_IRQ_OFFSET)
314#define SIU_INT_TIMER1 ((uint)0x0c+CPM_IRQ_OFFSET)
315#define SIU_INT_TIMER2 ((uint)0x0d+CPM_IRQ_OFFSET)
316#define SIU_INT_TIMER3 ((uint)0x0e+CPM_IRQ_OFFSET)
317#define SIU_INT_TIMER4 ((uint)0x0f+CPM_IRQ_OFFSET)
318#define SIU_INT_FCC1 ((uint)0x20+CPM_IRQ_OFFSET)
319#define SIU_INT_FCC2 ((uint)0x21+CPM_IRQ_OFFSET)
320#define SIU_INT_FCC3 ((uint)0x22+CPM_IRQ_OFFSET)
321#define SIU_INT_MCC1 ((uint)0x24+CPM_IRQ_OFFSET)
322#define SIU_INT_MCC2 ((uint)0x25+CPM_IRQ_OFFSET)
323#define SIU_INT_SCC1 ((uint)0x28+CPM_IRQ_OFFSET)
324#define SIU_INT_SCC2 ((uint)0x29+CPM_IRQ_OFFSET)
325#define SIU_INT_SCC3 ((uint)0x2a+CPM_IRQ_OFFSET)
326#define SIU_INT_SCC4 ((uint)0x2b+CPM_IRQ_OFFSET)
327#define SIU_INT_PC15 ((uint)0x30+CPM_IRQ_OFFSET)
328#define SIU_INT_PC14 ((uint)0x31+CPM_IRQ_OFFSET)
329#define SIU_INT_PC13 ((uint)0x32+CPM_IRQ_OFFSET)
330#define SIU_INT_PC12 ((uint)0x33+CPM_IRQ_OFFSET)
331#define SIU_INT_PC11 ((uint)0x34+CPM_IRQ_OFFSET)
332#define SIU_INT_PC10 ((uint)0x35+CPM_IRQ_OFFSET)
333#define SIU_INT_PC9 ((uint)0x36+CPM_IRQ_OFFSET)
334#define SIU_INT_PC8 ((uint)0x37+CPM_IRQ_OFFSET)
335#define SIU_INT_PC7 ((uint)0x38+CPM_IRQ_OFFSET)
336#define SIU_INT_PC6 ((uint)0x39+CPM_IRQ_OFFSET)
337#define SIU_INT_PC5 ((uint)0x3a+CPM_IRQ_OFFSET)
338#define SIU_INT_PC4 ((uint)0x3b+CPM_IRQ_OFFSET)
339#define SIU_INT_PC3 ((uint)0x3c+CPM_IRQ_OFFSET)
340#define SIU_INT_PC2 ((uint)0x3d+CPM_IRQ_OFFSET)
341#define SIU_INT_PC1 ((uint)0x3e+CPM_IRQ_OFFSET)
342#define SIU_INT_PC0 ((uint)0x3f+CPM_IRQ_OFFSET)
343
344#else /* CONFIG_40x + CONFIG_8xx */
345/*
346 * this is the # irq's for all ppc arch's (pmac/chrp/prep)
347 * so it is the max of them all
348 */
349#define NR_IRQS 256
350#define __DO_IRQ_CANON 1
351
352#ifndef CONFIG_8260
353
354#define NUM_8259_INTERRUPTS 16
355
356#else /* CONFIG_8260 */
357
358/* The 8260 has an internal interrupt controller with a maximum of
359 * 64 IRQs. We will use NR_IRQs from above since it is large enough.
360 * Don't be confused by the 8260 documentation where they list an
361 * "interrupt number" and "interrupt vector". We are only interested
362 * in the interrupt vector. There are "reserved" holes where the
363 * vector number increases, but the interrupt number in the table does not.
364 * (Document errata updates have fixed this...make sure you have up to
365 * date processor documentation -- Dan).
366 */
367
368#ifndef CPM_IRQ_OFFSET
369#define CPM_IRQ_OFFSET 0
370#endif
371
372#define NR_CPM_INTS 64
373
374#define SIU_INT_ERROR ((uint)0x00 + CPM_IRQ_OFFSET)
375#define SIU_INT_I2C ((uint)0x01 + CPM_IRQ_OFFSET)
376#define SIU_INT_SPI ((uint)0x02 + CPM_IRQ_OFFSET)
377#define SIU_INT_RISC ((uint)0x03 + CPM_IRQ_OFFSET)
378#define SIU_INT_SMC1 ((uint)0x04 + CPM_IRQ_OFFSET)
379#define SIU_INT_SMC2 ((uint)0x05 + CPM_IRQ_OFFSET)
380#define SIU_INT_IDMA1 ((uint)0x06 + CPM_IRQ_OFFSET)
381#define SIU_INT_IDMA2 ((uint)0x07 + CPM_IRQ_OFFSET)
382#define SIU_INT_IDMA3 ((uint)0x08 + CPM_IRQ_OFFSET)
383#define SIU_INT_IDMA4 ((uint)0x09 + CPM_IRQ_OFFSET)
384#define SIU_INT_SDMA ((uint)0x0a + CPM_IRQ_OFFSET)
385#define SIU_INT_USB ((uint)0x0b + CPM_IRQ_OFFSET)
386#define SIU_INT_TIMER1 ((uint)0x0c + CPM_IRQ_OFFSET)
387#define SIU_INT_TIMER2 ((uint)0x0d + CPM_IRQ_OFFSET)
388#define SIU_INT_TIMER3 ((uint)0x0e + CPM_IRQ_OFFSET)
389#define SIU_INT_TIMER4 ((uint)0x0f + CPM_IRQ_OFFSET)
390#define SIU_INT_TMCNT ((uint)0x10 + CPM_IRQ_OFFSET)
391#define SIU_INT_PIT ((uint)0x11 + CPM_IRQ_OFFSET)
392#define SIU_INT_PCI ((uint)0x12 + CPM_IRQ_OFFSET)
393#define SIU_INT_IRQ1 ((uint)0x13 + CPM_IRQ_OFFSET)
394#define SIU_INT_IRQ2 ((uint)0x14 + CPM_IRQ_OFFSET)
395#define SIU_INT_IRQ3 ((uint)0x15 + CPM_IRQ_OFFSET)
396#define SIU_INT_IRQ4 ((uint)0x16 + CPM_IRQ_OFFSET)
397#define SIU_INT_IRQ5 ((uint)0x17 + CPM_IRQ_OFFSET)
398#define SIU_INT_IRQ6 ((uint)0x18 + CPM_IRQ_OFFSET)
399#define SIU_INT_IRQ7 ((uint)0x19 + CPM_IRQ_OFFSET)
400#define SIU_INT_FCC1 ((uint)0x20 + CPM_IRQ_OFFSET)
401#define SIU_INT_FCC2 ((uint)0x21 + CPM_IRQ_OFFSET)
402#define SIU_INT_FCC3 ((uint)0x22 + CPM_IRQ_OFFSET)
403#define SIU_INT_MCC1 ((uint)0x24 + CPM_IRQ_OFFSET)
404#define SIU_INT_MCC2 ((uint)0x25 + CPM_IRQ_OFFSET)
405#define SIU_INT_SCC1 ((uint)0x28 + CPM_IRQ_OFFSET)
406#define SIU_INT_SCC2 ((uint)0x29 + CPM_IRQ_OFFSET)
407#define SIU_INT_SCC3 ((uint)0x2a + CPM_IRQ_OFFSET)
408#define SIU_INT_SCC4 ((uint)0x2b + CPM_IRQ_OFFSET)
409#define SIU_INT_PC15 ((uint)0x30 + CPM_IRQ_OFFSET)
410#define SIU_INT_PC14 ((uint)0x31 + CPM_IRQ_OFFSET)
411#define SIU_INT_PC13 ((uint)0x32 + CPM_IRQ_OFFSET)
412#define SIU_INT_PC12 ((uint)0x33 + CPM_IRQ_OFFSET)
413#define SIU_INT_PC11 ((uint)0x34 + CPM_IRQ_OFFSET)
414#define SIU_INT_PC10 ((uint)0x35 + CPM_IRQ_OFFSET)
415#define SIU_INT_PC9 ((uint)0x36 + CPM_IRQ_OFFSET)
416#define SIU_INT_PC8 ((uint)0x37 + CPM_IRQ_OFFSET)
417#define SIU_INT_PC7 ((uint)0x38 + CPM_IRQ_OFFSET)
418#define SIU_INT_PC6 ((uint)0x39 + CPM_IRQ_OFFSET)
419#define SIU_INT_PC5 ((uint)0x3a + CPM_IRQ_OFFSET)
420#define SIU_INT_PC4 ((uint)0x3b + CPM_IRQ_OFFSET)
421#define SIU_INT_PC3 ((uint)0x3c + CPM_IRQ_OFFSET)
422#define SIU_INT_PC2 ((uint)0x3d + CPM_IRQ_OFFSET)
423#define SIU_INT_PC1 ((uint)0x3e + CPM_IRQ_OFFSET)
424#define SIU_INT_PC0 ((uint)0x3f + CPM_IRQ_OFFSET)
425
426#endif /* CONFIG_8260 */
427
428#endif
429
430#define NR_MASK_WORDS ((NR_IRQS + 31) / 32)
431/* pedantic: these are long because they are used with set_bit --RR */
432extern unsigned long ppc_cached_irq_mask[NR_MASK_WORDS];
433extern atomic_t ppc_n_lost_interrupts;
434
435#define virt_irq_create_mapping(x) (x)
436
437#endif
438
439/*
440 * Because many systems have two overlapping names spaces for
441 * interrupts (ISA and XICS for example), and the ISA interrupts
442 * have historically not been easy to renumber, we allow ISA
443 * interrupts to take values 0 - 15, and shift up the remaining
444 * interrupts by 0x10.
445 */
446#define NUM_ISA_INTERRUPTS 0x10
447extern int __irq_offset_value;
448
449static inline int irq_offset_up(int irq)
450{
451 return(irq + __irq_offset_value);
452}
453
454static inline int irq_offset_down(int irq)
455{
456 return(irq - __irq_offset_value);
457}
458
459static inline int irq_offset_value(void)
460{
461 return __irq_offset_value;
462}
463
464#ifdef __DO_IRQ_CANON
465extern int ppc_do_canonicalize_irqs;
466#else
467#define ppc_do_canonicalize_irqs 0
468#endif
469
470static __inline__ int irq_canonicalize(int irq)
471{
472 if (ppc_do_canonicalize_irqs && irq == 2)
473 irq = 9;
474 return irq;
475}
476
477extern int distribute_irqs;
478
479struct irqaction;
480struct pt_regs;
481
482#ifdef CONFIG_IRQSTACKS
483/*
484 * Per-cpu stacks for handling hard and soft interrupts.
485 */
486extern struct thread_info *hardirq_ctx[NR_CPUS];
487extern struct thread_info *softirq_ctx[NR_CPUS];
488
489extern void irq_ctx_init(void);
490extern void call_do_softirq(struct thread_info *tp);
491extern int call___do_IRQ(int irq, struct pt_regs *regs,
492 struct thread_info *tp);
493
494#define __ARCH_HAS_DO_SOFTIRQ
495
496#else
497#define irq_ctx_init()
498
499#endif /* CONFIG_IRQSTACKS */
500
501extern void do_IRQ(struct pt_regs *regs);
502
503#endif /* _ASM_IRQ_H */
504#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/iseries/hv_call.h b/include/asm-powerpc/iseries/hv_call.h
new file mode 100644
index 000000000000..e9f831c9a5e5
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_call.h
@@ -0,0 +1,113 @@
1/*
2 * HvCall.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19/*
20 * This file contains the "hypervisor call" interface which is used to
21 * drive the hypervisor from the OS.
22 */
23#ifndef _ASM_POWERPC_ISERIES_HV_CALL_H
24#define _ASM_POWERPC_ISERIES_HV_CALL_H
25
26#include <asm/iseries/hv_call_sc.h>
27#include <asm/iseries/hv_types.h>
28#include <asm/paca.h>
29
30/* Type of yield for HvCallBaseYieldProcessor */
31#define HvCall_YieldTimed 0 /* Yield until specified time (tb) */
32#define HvCall_YieldToActive 1 /* Yield until all active procs have run */
33#define HvCall_YieldToProc 2 /* Yield until the specified processor has run */
34
35/* interrupt masks for setEnabledInterrupts */
36#define HvCall_MaskIPI 0x00000001
37#define HvCall_MaskLpEvent 0x00000002
38#define HvCall_MaskLpProd 0x00000004
39#define HvCall_MaskTimeout 0x00000008
40
41/* Log buffer formats */
42#define HvCall_LogBuffer_ASCII 0
43#define HvCall_LogBuffer_EBCDIC 1
44
45#define HvCallBaseAckDeferredInts HvCallBase + 0
46#define HvCallBaseCpmPowerOff HvCallBase + 1
47#define HvCallBaseGetHwPatch HvCallBase + 2
48#define HvCallBaseReIplSpAttn HvCallBase + 3
49#define HvCallBaseSetASR HvCallBase + 4
50#define HvCallBaseSetASRAndRfi HvCallBase + 5
51#define HvCallBaseSetIMR HvCallBase + 6
52#define HvCallBaseSendIPI HvCallBase + 7
53#define HvCallBaseTerminateMachine HvCallBase + 8
54#define HvCallBaseTerminateMachineSrc HvCallBase + 9
55#define HvCallBaseProcessPlicInterrupts HvCallBase + 10
56#define HvCallBaseIsPrimaryCpmOrMsdIpl HvCallBase + 11
57#define HvCallBaseSetVirtualSIT HvCallBase + 12
58#define HvCallBaseVaryOffThisProcessor HvCallBase + 13
59#define HvCallBaseVaryOffMemoryChunk HvCallBase + 14
60#define HvCallBaseVaryOffInteractivePercentage HvCallBase + 15
61#define HvCallBaseSendLpProd HvCallBase + 16
62#define HvCallBaseSetEnabledInterrupts HvCallBase + 17
63#define HvCallBaseYieldProcessor HvCallBase + 18
64#define HvCallBaseVaryOffSharedProcUnits HvCallBase + 19
65#define HvCallBaseSetVirtualDecr HvCallBase + 20
66#define HvCallBaseClearLogBuffer HvCallBase + 21
67#define HvCallBaseGetLogBufferCodePage HvCallBase + 22
68#define HvCallBaseGetLogBufferFormat HvCallBase + 23
69#define HvCallBaseGetLogBufferLength HvCallBase + 24
70#define HvCallBaseReadLogBuffer HvCallBase + 25
71#define HvCallBaseSetLogBufferFormatAndCodePage HvCallBase + 26
72#define HvCallBaseWriteLogBuffer HvCallBase + 27
73#define HvCallBaseRouter28 HvCallBase + 28
74#define HvCallBaseRouter29 HvCallBase + 29
75#define HvCallBaseRouter30 HvCallBase + 30
76#define HvCallBaseSetDebugBus HvCallBase + 31
77
78#define HvCallCcSetDABR HvCallCc + 7
79
80static inline void HvCall_setVirtualDecr(void)
81{
82 /*
83 * Ignore any error return codes - most likely means that the
84 * target value for the LP has been increased and this vary off
85 * would bring us below the new target.
86 */
87 HvCall0(HvCallBaseSetVirtualDecr);
88}
89
90static inline void HvCall_yieldProcessor(unsigned typeOfYield, u64 yieldParm)
91{
92 HvCall2(HvCallBaseYieldProcessor, typeOfYield, yieldParm);
93}
94
95static inline void HvCall_setEnabledInterrupts(u64 enabledInterrupts)
96{
97 HvCall1(HvCallBaseSetEnabledInterrupts, enabledInterrupts);
98}
99
100static inline void HvCall_setLogBufferFormatAndCodepage(int format,
101 u32 codePage)
102{
103 HvCall2(HvCallBaseSetLogBufferFormatAndCodePage, format, codePage);
104}
105
106extern void HvCall_writeLogBuffer(const void *buffer, u64 bufLen);
107
108static inline void HvCall_sendIPI(struct paca_struct *targetPaca)
109{
110 HvCall1(HvCallBaseSendIPI, targetPaca->paca_index);
111}
112
113#endif /* _ASM_POWERPC_ISERIES_HV_CALL_H */
diff --git a/include/asm-powerpc/iseries/hv_call_event.h b/include/asm-powerpc/iseries/hv_call_event.h
new file mode 100644
index 000000000000..46763a30590a
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_call_event.h
@@ -0,0 +1,253 @@
1/*
2 * HvCallEvent.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19/*
20 * This file contains the "hypervisor call" interface which is used to
21 * drive the hypervisor from the OS.
22 */
23#ifndef _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
24#define _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H
25
26#include <asm/iseries/hv_call_sc.h>
27#include <asm/iseries/hv_types.h>
28#include <asm/abs_addr.h>
29
30struct HvLpEvent;
31
32typedef u8 HvLpEvent_Type;
33typedef u8 HvLpEvent_AckInd;
34typedef u8 HvLpEvent_AckType;
35
36struct HvCallEvent_PackedParms {
37 u8 xAckType:1;
38 u8 xAckInd:1;
39 u8 xRsvd:1;
40 u8 xTargetLp:5;
41 u8 xType;
42 u16 xSubtype;
43 HvLpInstanceId xSourceInstId;
44 HvLpInstanceId xTargetInstId;
45};
46
47typedef u8 HvLpDma_Direction;
48typedef u8 HvLpDma_AddressType;
49
50struct HvCallEvent_PackedDmaParms {
51 u8 xDirection:1;
52 u8 xLocalAddrType:1;
53 u8 xRemoteAddrType:1;
54 u8 xRsvd1:5;
55 HvLpIndex xRemoteLp;
56 u8 xType;
57 u8 xRsvd2;
58 HvLpInstanceId xLocalInstId;
59 HvLpInstanceId xRemoteInstId;
60};
61
62typedef u64 HvLpEvent_Rc;
63typedef u64 HvLpDma_Rc;
64
65#define HvCallEventAckLpEvent HvCallEvent + 0
66#define HvCallEventCancelLpEvent HvCallEvent + 1
67#define HvCallEventCloseLpEventPath HvCallEvent + 2
68#define HvCallEventDmaBufList HvCallEvent + 3
69#define HvCallEventDmaSingle HvCallEvent + 4
70#define HvCallEventDmaToSp HvCallEvent + 5
71#define HvCallEventGetOverflowLpEvents HvCallEvent + 6
72#define HvCallEventGetSourceLpInstanceId HvCallEvent + 7
73#define HvCallEventGetTargetLpInstanceId HvCallEvent + 8
74#define HvCallEventOpenLpEventPath HvCallEvent + 9
75#define HvCallEventSetLpEventStack HvCallEvent + 10
76#define HvCallEventSignalLpEvent HvCallEvent + 11
77#define HvCallEventSignalLpEventParms HvCallEvent + 12
78#define HvCallEventSetInterLpQueueIndex HvCallEvent + 13
79#define HvCallEventSetLpEventQueueInterruptProc HvCallEvent + 14
80#define HvCallEventRouter15 HvCallEvent + 15
81
82static inline void HvCallEvent_getOverflowLpEvents(u8 queueIndex)
83{
84 HvCall1(HvCallEventGetOverflowLpEvents, queueIndex);
85}
86
87static inline void HvCallEvent_setInterLpQueueIndex(u8 queueIndex)
88{
89 HvCall1(HvCallEventSetInterLpQueueIndex, queueIndex);
90}
91
92static inline void HvCallEvent_setLpEventStack(u8 queueIndex,
93 char *eventStackAddr, u32 eventStackSize)
94{
95 u64 abs_addr;
96
97 abs_addr = virt_to_abs(eventStackAddr);
98 HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr,
99 eventStackSize);
100}
101
102static inline void HvCallEvent_setLpEventQueueInterruptProc(u8 queueIndex,
103 u16 lpLogicalProcIndex)
104{
105 HvCall2(HvCallEventSetLpEventQueueInterruptProc, queueIndex,
106 lpLogicalProcIndex);
107}
108
109static inline HvLpEvent_Rc HvCallEvent_signalLpEvent(struct HvLpEvent *event)
110{
111 u64 abs_addr;
112
113#ifdef DEBUG_SENDEVENT
114 printk("HvCallEvent_signalLpEvent: *event = %016lx\n ",
115 (unsigned long)event);
116#endif
117 abs_addr = virt_to_abs(event);
118 return HvCall1(HvCallEventSignalLpEvent, abs_addr);
119}
120
121static inline HvLpEvent_Rc HvCallEvent_signalLpEventFast(HvLpIndex targetLp,
122 HvLpEvent_Type type, u16 subtype, HvLpEvent_AckInd ackInd,
123 HvLpEvent_AckType ackType, HvLpInstanceId sourceInstanceId,
124 HvLpInstanceId targetInstanceId, u64 correlationToken,
125 u64 eventData1, u64 eventData2, u64 eventData3,
126 u64 eventData4, u64 eventData5)
127{
128 /* Pack the misc bits into a single Dword to pass to PLIC */
129 union {
130 struct HvCallEvent_PackedParms parms;
131 u64 dword;
132 } packed;
133 packed.parms.xAckType = ackType;
134 packed.parms.xAckInd = ackInd;
135 packed.parms.xRsvd = 0;
136 packed.parms.xTargetLp = targetLp;
137 packed.parms.xType = type;
138 packed.parms.xSubtype = subtype;
139 packed.parms.xSourceInstId = sourceInstanceId;
140 packed.parms.xTargetInstId = targetInstanceId;
141
142 return HvCall7(HvCallEventSignalLpEventParms, packed.dword,
143 correlationToken, eventData1, eventData2,
144 eventData3, eventData4, eventData5);
145}
146
147static inline HvLpEvent_Rc HvCallEvent_ackLpEvent(struct HvLpEvent *event)
148{
149 u64 abs_addr;
150
151 abs_addr = virt_to_abs(event);
152 return HvCall1(HvCallEventAckLpEvent, abs_addr);
153}
154
155static inline HvLpEvent_Rc HvCallEvent_cancelLpEvent(struct HvLpEvent *event)
156{
157 u64 abs_addr;
158
159 abs_addr = virt_to_abs(event);
160 return HvCall1(HvCallEventCancelLpEvent, abs_addr);
161}
162
163static inline HvLpInstanceId HvCallEvent_getSourceLpInstanceId(
164 HvLpIndex targetLp, HvLpEvent_Type type)
165{
166 return HvCall2(HvCallEventGetSourceLpInstanceId, targetLp, type);
167}
168
169static inline HvLpInstanceId HvCallEvent_getTargetLpInstanceId(
170 HvLpIndex targetLp, HvLpEvent_Type type)
171{
172 return HvCall2(HvCallEventGetTargetLpInstanceId, targetLp, type);
173}
174
175static inline void HvCallEvent_openLpEventPath(HvLpIndex targetLp,
176 HvLpEvent_Type type)
177{
178 HvCall2(HvCallEventOpenLpEventPath, targetLp, type);
179}
180
181static inline void HvCallEvent_closeLpEventPath(HvLpIndex targetLp,
182 HvLpEvent_Type type)
183{
184 HvCall2(HvCallEventCloseLpEventPath, targetLp, type);
185}
186
187static inline HvLpDma_Rc HvCallEvent_dmaBufList(HvLpEvent_Type type,
188 HvLpIndex remoteLp, HvLpDma_Direction direction,
189 HvLpInstanceId localInstanceId,
190 HvLpInstanceId remoteInstanceId,
191 HvLpDma_AddressType localAddressType,
192 HvLpDma_AddressType remoteAddressType,
193 /* Do these need to be converted to absolute addresses? */
194 u64 localBufList, u64 remoteBufList, u32 transferLength)
195{
196 /* Pack the misc bits into a single Dword to pass to PLIC */
197 union {
198 struct HvCallEvent_PackedDmaParms parms;
199 u64 dword;
200 } packed;
201
202 packed.parms.xDirection = direction;
203 packed.parms.xLocalAddrType = localAddressType;
204 packed.parms.xRemoteAddrType = remoteAddressType;
205 packed.parms.xRsvd1 = 0;
206 packed.parms.xRemoteLp = remoteLp;
207 packed.parms.xType = type;
208 packed.parms.xRsvd2 = 0;
209 packed.parms.xLocalInstId = localInstanceId;
210 packed.parms.xRemoteInstId = remoteInstanceId;
211
212 return HvCall4(HvCallEventDmaBufList, packed.dword, localBufList,
213 remoteBufList, transferLength);
214}
215
216static inline HvLpDma_Rc HvCallEvent_dmaSingle(HvLpEvent_Type type,
217 HvLpIndex remoteLp, HvLpDma_Direction direction,
218 HvLpInstanceId localInstanceId,
219 HvLpInstanceId remoteInstanceId,
220 HvLpDma_AddressType localAddressType,
221 HvLpDma_AddressType remoteAddressType,
222 u64 localAddrOrTce, u64 remoteAddrOrTce, u32 transferLength)
223{
224 /* Pack the misc bits into a single Dword to pass to PLIC */
225 union {
226 struct HvCallEvent_PackedDmaParms parms;
227 u64 dword;
228 } packed;
229
230 packed.parms.xDirection = direction;
231 packed.parms.xLocalAddrType = localAddressType;
232 packed.parms.xRemoteAddrType = remoteAddressType;
233 packed.parms.xRsvd1 = 0;
234 packed.parms.xRemoteLp = remoteLp;
235 packed.parms.xType = type;
236 packed.parms.xRsvd2 = 0;
237 packed.parms.xLocalInstId = localInstanceId;
238 packed.parms.xRemoteInstId = remoteInstanceId;
239
240 return (HvLpDma_Rc)HvCall4(HvCallEventDmaSingle, packed.dword,
241 localAddrOrTce, remoteAddrOrTce, transferLength);
242}
243
244static inline HvLpDma_Rc HvCallEvent_dmaToSp(void *local, u32 remote,
245 u32 length, HvLpDma_Direction dir)
246{
247 u64 abs_addr;
248
249 abs_addr = virt_to_abs(local);
250 return HvCall4(HvCallEventDmaToSp, abs_addr, remote, length, dir);
251}
252
253#endif /* _ASM_POWERPC_ISERIES_HV_CALL_EVENT_H */
diff --git a/include/asm-powerpc/iseries/hv_call_sc.h b/include/asm-powerpc/iseries/hv_call_sc.h
new file mode 100644
index 000000000000..dec7e9d9ab78
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_call_sc.h
@@ -0,0 +1,51 @@
1/*
2 * HvCallSc.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_HV_CALL_SC_H
20#define _ASM_POWERPC_ISERIES_HV_CALL_SC_H
21
22#include <linux/types.h>
23
24#define HvCallBase 0x8000000000000000ul
25#define HvCallCc 0x8001000000000000ul
26#define HvCallCfg 0x8002000000000000ul
27#define HvCallEvent 0x8003000000000000ul
28#define HvCallHpt 0x8004000000000000ul
29#define HvCallPci 0x8005000000000000ul
30#define HvCallSm 0x8007000000000000ul
31#define HvCallXm 0x8009000000000000ul
32
33extern u64 HvCall0(u64);
34extern u64 HvCall1(u64, u64);
35extern u64 HvCall2(u64, u64, u64);
36extern u64 HvCall3(u64, u64, u64, u64);
37extern u64 HvCall4(u64, u64, u64, u64, u64);
38extern u64 HvCall5(u64, u64, u64, u64, u64, u64);
39extern u64 HvCall6(u64, u64, u64, u64, u64, u64, u64);
40extern u64 HvCall7(u64, u64, u64, u64, u64, u64, u64, u64);
41
42extern u64 HvCall0Ret16(u64, void *);
43extern u64 HvCall1Ret16(u64, void *, u64);
44extern u64 HvCall2Ret16(u64, void *, u64, u64);
45extern u64 HvCall3Ret16(u64, void *, u64, u64, u64);
46extern u64 HvCall4Ret16(u64, void *, u64, u64, u64, u64);
47extern u64 HvCall5Ret16(u64, void *, u64, u64, u64, u64, u64);
48extern u64 HvCall6Ret16(u64, void *, u64, u64, u64, u64, u64, u64);
49extern u64 HvCall7Ret16(u64, void *, u64, u64 ,u64 ,u64 ,u64 ,u64 ,u64);
50
51#endif /* _ASM_POWERPC_ISERIES_HV_CALL_SC_H */
diff --git a/include/asm-powerpc/iseries/hv_call_xm.h b/include/asm-powerpc/iseries/hv_call_xm.h
new file mode 100644
index 000000000000..ca9202cb01ed
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_call_xm.h
@@ -0,0 +1,78 @@
1/*
2 * This file contains the "hypervisor call" interface which is used to
3 * drive the hypervisor from SLIC.
4 */
5#ifndef _ASM_POWERPC_ISERIES_HV_CALL_XM_H
6#define _ASM_POWERPC_ISERIES_HV_CALL_XM_H
7
8#include <asm/iseries/hv_call_sc.h>
9#include <asm/iseries/hv_types.h>
10
11#define HvCallXmGetTceTableParms HvCallXm + 0
12#define HvCallXmTestBus HvCallXm + 1
13#define HvCallXmConnectBusUnit HvCallXm + 2
14#define HvCallXmLoadTod HvCallXm + 8
15#define HvCallXmTestBusUnit HvCallXm + 9
16#define HvCallXmSetTce HvCallXm + 11
17#define HvCallXmSetTces HvCallXm + 13
18
19/*
20 * Structure passed to HvCallXm_getTceTableParms
21 */
22struct iommu_table_cb {
23 unsigned long itc_busno; /* Bus number for this tce table */
24 unsigned long itc_start; /* Will be NULL for secondary */
25 unsigned long itc_totalsize; /* Size (in pages) of whole table */
26 unsigned long itc_offset; /* Index into real tce table of the
27 start of our section */
28 unsigned long itc_size; /* Size (in pages) of our section */
29 unsigned long itc_index; /* Index of this tce table */
30 unsigned short itc_maxtables; /* Max num of tables for partition */
31 unsigned char itc_virtbus; /* Flag to indicate virtual bus */
32 unsigned char itc_slotno; /* IOA Tce Slot Index */
33 unsigned char itc_rsvd[4];
34};
35
36static inline void HvCallXm_getTceTableParms(u64 cb)
37{
38 HvCall1(HvCallXmGetTceTableParms, cb);
39}
40
41static inline u64 HvCallXm_setTce(u64 tceTableToken, u64 tceOffset, u64 tce)
42{
43 return HvCall3(HvCallXmSetTce, tceTableToken, tceOffset, tce);
44}
45
46static inline u64 HvCallXm_setTces(u64 tceTableToken, u64 tceOffset,
47 u64 numTces, u64 tce1, u64 tce2, u64 tce3, u64 tce4)
48{
49 return HvCall7(HvCallXmSetTces, tceTableToken, tceOffset, numTces,
50 tce1, tce2, tce3, tce4);
51}
52
53static inline u64 HvCallXm_testBus(u16 busNumber)
54{
55 return HvCall1(HvCallXmTestBus, busNumber);
56}
57
58static inline u64 HvCallXm_testBusUnit(u16 busNumber, u8 subBusNumber,
59 u8 deviceId)
60{
61 return HvCall2(HvCallXmTestBusUnit, busNumber,
62 (subBusNumber << 8) | deviceId);
63}
64
65static inline u64 HvCallXm_connectBusUnit(u16 busNumber, u8 subBusNumber,
66 u8 deviceId, u64 interruptToken)
67{
68 return HvCall5(HvCallXmConnectBusUnit, busNumber,
69 (subBusNumber << 8) | deviceId, interruptToken, 0,
70 0 /* HvLpConfig::mapDsaToQueueIndex(HvLpDSA(busNumber, xBoard, xCard)) */);
71}
72
73static inline u64 HvCallXm_loadTod(void)
74{
75 return HvCall0(HvCallXmLoadTod);
76}
77
78#endif /* _ASM_POWERPC_ISERIES_HV_CALL_XM_H */
diff --git a/include/asm-powerpc/iseries/hv_lp_config.h b/include/asm-powerpc/iseries/hv_lp_config.h
new file mode 100644
index 000000000000..bc00f036bca0
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_lp_config.h
@@ -0,0 +1,138 @@
1/*
2 * HvLpConfig.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H
20#define _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H
21
22/*
23 * This file contains the interface to the LPAR configuration data
24 * to determine which resources should be allocated to each partition.
25 */
26
27#include <asm/iseries/hv_call_sc.h>
28#include <asm/iseries/hv_types.h>
29#include <asm/iseries/it_lp_naca.h>
30
31enum {
32 HvCallCfg_Cur = 0,
33 HvCallCfg_Init = 1,
34 HvCallCfg_Max = 2,
35 HvCallCfg_Min = 3
36};
37
38#define HvCallCfgGetSystemPhysicalProcessors HvCallCfg + 6
39#define HvCallCfgGetPhysicalProcessors HvCallCfg + 7
40#define HvCallCfgGetMsChunks HvCallCfg + 9
41#define HvCallCfgGetSharedPoolIndex HvCallCfg + 20
42#define HvCallCfgGetSharedProcUnits HvCallCfg + 21
43#define HvCallCfgGetNumProcsInSharedPool HvCallCfg + 22
44#define HvCallCfgGetVirtualLanIndexMap HvCallCfg + 30
45#define HvCallCfgGetHostingLpIndex HvCallCfg + 32
46
47extern HvLpIndex HvLpConfig_getLpIndex_outline(void);
48
49static inline HvLpIndex HvLpConfig_getLpIndex(void)
50{
51 return itLpNaca.xLpIndex;
52}
53
54static inline HvLpIndex HvLpConfig_getPrimaryLpIndex(void)
55{
56 return itLpNaca.xPrimaryLpIndex;
57}
58
59static inline u64 HvLpConfig_getMsChunks(void)
60{
61 return HvCall2(HvCallCfgGetMsChunks, HvLpConfig_getLpIndex(),
62 HvCallCfg_Cur);
63}
64
65static inline u64 HvLpConfig_getSystemPhysicalProcessors(void)
66{
67 return HvCall0(HvCallCfgGetSystemPhysicalProcessors);
68}
69
70static inline u64 HvLpConfig_getNumProcsInSharedPool(HvLpSharedPoolIndex sPI)
71{
72 return (u16)HvCall1(HvCallCfgGetNumProcsInSharedPool, sPI);
73}
74
75static inline u64 HvLpConfig_getPhysicalProcessors(void)
76{
77 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
78 HvCallCfg_Cur);
79}
80
81static inline HvLpSharedPoolIndex HvLpConfig_getSharedPoolIndex(void)
82{
83 return HvCall1(HvCallCfgGetSharedPoolIndex, HvLpConfig_getLpIndex());
84}
85
86static inline u64 HvLpConfig_getSharedProcUnits(void)
87{
88 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
89 HvCallCfg_Cur);
90}
91
92static inline u64 HvLpConfig_getMaxSharedProcUnits(void)
93{
94 return HvCall2(HvCallCfgGetSharedProcUnits, HvLpConfig_getLpIndex(),
95 HvCallCfg_Max);
96}
97
98static inline u64 HvLpConfig_getMaxPhysicalProcessors(void)
99{
100 return HvCall2(HvCallCfgGetPhysicalProcessors, HvLpConfig_getLpIndex(),
101 HvCallCfg_Max);
102}
103
104static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMapForLp(
105 HvLpIndex lp)
106{
107 /*
108 * This is a new function in V5R1 so calls to this on older
109 * hypervisors will return -1
110 */
111 u64 retVal = HvCall1(HvCallCfgGetVirtualLanIndexMap, lp);
112 if (retVal == -1)
113 retVal = 0;
114 return retVal;
115}
116
117static inline HvLpVirtualLanIndexMap HvLpConfig_getVirtualLanIndexMap(void)
118{
119 return HvLpConfig_getVirtualLanIndexMapForLp(
120 HvLpConfig_getLpIndex_outline());
121}
122
123static inline int HvLpConfig_doLpsCommunicateOnVirtualLan(HvLpIndex lp1,
124 HvLpIndex lp2)
125{
126 HvLpVirtualLanIndexMap virtualLanIndexMap1 =
127 HvLpConfig_getVirtualLanIndexMapForLp(lp1);
128 HvLpVirtualLanIndexMap virtualLanIndexMap2 =
129 HvLpConfig_getVirtualLanIndexMapForLp(lp2);
130 return ((virtualLanIndexMap1 & virtualLanIndexMap2) != 0);
131}
132
133static inline HvLpIndex HvLpConfig_getHostingLpIndex(HvLpIndex lp)
134{
135 return HvCall1(HvCallCfgGetHostingLpIndex, lp);
136}
137
138#endif /* _ASM_POWERPC_ISERIES_HV_LP_CONFIG_H */
diff --git a/include/asm-powerpc/iseries/hv_lp_event.h b/include/asm-powerpc/iseries/hv_lp_event.h
new file mode 100644
index 000000000000..499ab1ad0185
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_lp_event.h
@@ -0,0 +1,142 @@
1/*
2 * HvLpEvent.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20/* This file contains the class for HV events in the system. */
21
22#ifndef _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
23#define _ASM_POWERPC_ISERIES_HV_LP_EVENT_H
24
25#include <asm/types.h>
26#include <asm/ptrace.h>
27#include <asm/iseries/hv_types.h>
28#include <asm/iseries/hv_call_event.h>
29
30/*
31 * HvLpEvent is the structure for Lp Event messages passed between
32 * partitions through PLIC.
33 */
34
35struct HvEventFlags {
36 u8 xValid:1; /* Indicates a valid request x00-x00 */
37 u8 xRsvd1:4; /* Reserved ... */
38 u8 xAckType:1; /* Immediate or deferred ... */
39 u8 xAckInd:1; /* Indicates if ACK required ... */
40 u8 xFunction:1; /* Interrupt or Acknowledge ... */
41};
42
43
44struct HvLpEvent {
45 struct HvEventFlags xFlags; /* Event flags x00-x00 */
46 u8 xType; /* Type of message x01-x01 */
47 u16 xSubtype; /* Subtype for event x02-x03 */
48 u8 xSourceLp; /* Source LP x04-x04 */
49 u8 xTargetLp; /* Target LP x05-x05 */
50 u8 xSizeMinus1; /* Size of Derived class - 1 x06-x06 */
51 u8 xRc; /* RC for Ack flows x07-x07 */
52 u16 xSourceInstanceId; /* Source sides instance id x08-x09 */
53 u16 xTargetInstanceId; /* Target sides instance id x0A-x0B */
54 union {
55 u32 xSubtypeData; /* Data usable by the subtype x0C-x0F */
56 u16 xSubtypeDataShort[2]; /* Data as 2 shorts */
57 u8 xSubtypeDataChar[4]; /* Data as 4 chars */
58 } x;
59
60 u64 xCorrelationToken; /* Unique value for source/type x10-x17 */
61};
62
63typedef void (*LpEventHandler)(struct HvLpEvent *, struct pt_regs *);
64
65/* Register a handler for an event type - returns 0 on success */
66extern int HvLpEvent_registerHandler(HvLpEvent_Type eventType,
67 LpEventHandler hdlr);
68
69/*
70 * Unregister a handler for an event type
71 *
72 * This call will sleep until the handler being removed is guaranteed to
73 * be no longer executing on any CPU. Do not call with locks held.
74 *
75 * returns 0 on success
76 * Unregister will fail if there are any paths open for the type
77 */
78extern int HvLpEvent_unregisterHandler(HvLpEvent_Type eventType);
79
80/*
81 * Open an Lp Event Path for an event type
82 * returns 0 on success
83 * openPath will fail if there is no handler registered for the event type.
84 * The lpIndex specified is the partition index for the target partition
85 * (for VirtualIo, VirtualLan and SessionMgr) other types specify zero)
86 */
87extern int HvLpEvent_openPath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
88
89/*
90 * Close an Lp Event Path for a type and partition
91 * returns 0 on sucess
92 */
93extern int HvLpEvent_closePath(HvLpEvent_Type eventType, HvLpIndex lpIndex);
94
95#define HvLpEvent_Type_Hypervisor 0
96#define HvLpEvent_Type_MachineFac 1
97#define HvLpEvent_Type_SessionMgr 2
98#define HvLpEvent_Type_SpdIo 3
99#define HvLpEvent_Type_VirtualBus 4
100#define HvLpEvent_Type_PciIo 5
101#define HvLpEvent_Type_RioIo 6
102#define HvLpEvent_Type_VirtualLan 7
103#define HvLpEvent_Type_VirtualIo 8
104#define HvLpEvent_Type_NumTypes 9
105
106#define HvLpEvent_Rc_Good 0
107#define HvLpEvent_Rc_BufferNotAvailable 1
108#define HvLpEvent_Rc_Cancelled 2
109#define HvLpEvent_Rc_GenericError 3
110#define HvLpEvent_Rc_InvalidAddress 4
111#define HvLpEvent_Rc_InvalidPartition 5
112#define HvLpEvent_Rc_InvalidSize 6
113#define HvLpEvent_Rc_InvalidSubtype 7
114#define HvLpEvent_Rc_InvalidSubtypeData 8
115#define HvLpEvent_Rc_InvalidType 9
116#define HvLpEvent_Rc_PartitionDead 10
117#define HvLpEvent_Rc_PathClosed 11
118#define HvLpEvent_Rc_SubtypeError 12
119
120#define HvLpEvent_Function_Ack 0
121#define HvLpEvent_Function_Int 1
122
123#define HvLpEvent_AckInd_NoAck 0
124#define HvLpEvent_AckInd_DoAck 1
125
126#define HvLpEvent_AckType_ImmediateAck 0
127#define HvLpEvent_AckType_DeferredAck 1
128
129#define HvLpDma_Direction_LocalToRemote 0
130#define HvLpDma_Direction_RemoteToLocal 1
131
132#define HvLpDma_AddressType_TceIndex 0
133#define HvLpDma_AddressType_RealAddress 1
134
135#define HvLpDma_Rc_Good 0
136#define HvLpDma_Rc_Error 1
137#define HvLpDma_Rc_PartitionDead 2
138#define HvLpDma_Rc_PathClosed 3
139#define HvLpDma_Rc_InvalidAddress 4
140#define HvLpDma_Rc_InvalidLength 5
141
142#endif /* _ASM_POWERPC_ISERIES_HV_LP_EVENT_H */
diff --git a/include/asm-powerpc/iseries/hv_types.h b/include/asm-powerpc/iseries/hv_types.h
new file mode 100644
index 000000000000..c38f7e3d01dc
--- /dev/null
+++ b/include/asm-powerpc/iseries/hv_types.h
@@ -0,0 +1,113 @@
1/*
2 * HvTypes.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_HV_TYPES_H
20#define _ASM_POWERPC_ISERIES_HV_TYPES_H
21
22/*
23 * General typedefs for the hypervisor.
24 */
25
26#include <asm/types.h>
27
28typedef u8 HvLpIndex;
29typedef u16 HvLpInstanceId;
30typedef u64 HvLpTOD;
31typedef u64 HvLpSystemSerialNum;
32typedef u8 HvLpDeviceSerialNum[12];
33typedef u16 HvLpSanHwSet;
34typedef u16 HvLpBus;
35typedef u16 HvLpBoard;
36typedef u16 HvLpCard;
37typedef u8 HvLpDeviceType[4];
38typedef u8 HvLpDeviceModel[3];
39typedef u64 HvIoToken;
40typedef u8 HvLpName[8];
41typedef u32 HvIoId;
42typedef u64 HvRealMemoryIndex;
43typedef u32 HvLpIndexMap; /* Must hold HVMAXARCHITECTEDLPS bits!!! */
44typedef u16 HvLpVrmIndex;
45typedef u32 HvXmGenerationId;
46typedef u8 HvLpBusPool;
47typedef u8 HvLpSharedPoolIndex;
48typedef u16 HvLpSharedProcUnitsX100;
49typedef u8 HvLpVirtualLanIndex;
50typedef u16 HvLpVirtualLanIndexMap; /* Must hold HVMAXARCHITECTEDVIRTUALLANS bits!!! */
51typedef u16 HvBusNumber; /* Hypervisor Bus Number */
52typedef u8 HvSubBusNumber; /* Hypervisor SubBus Number */
53typedef u8 HvAgentId; /* Hypervisor DevFn */
54
55
56#define HVMAXARCHITECTEDLPS 32
57#define HVMAXARCHITECTEDVIRTUALLANS 16
58#define HVMAXARCHITECTEDVIRTUALDISKS 32
59#define HVMAXARCHITECTEDVIRTUALCDROMS 8
60#define HVMAXARCHITECTEDVIRTUALTAPES 8
61#define HVCHUNKSIZE (256 * 1024)
62#define HVPAGESIZE (4 * 1024)
63#define HVLPMINMEGSPRIMARY 256
64#define HVLPMINMEGSSECONDARY 64
65#define HVCHUNKSPERMEG 4
66#define HVPAGESPERMEG 256
67#define HVPAGESPERCHUNK 64
68
69#define HvLpIndexInvalid ((HvLpIndex)0xff)
70
71/*
72 * Enums for the sub-components under PLIC
73 * Used in HvCall and HvPrimaryCall
74 */
75enum {
76 HvCallCompId = 0,
77 HvCallCpuCtlsCompId = 1,
78 HvCallCfgCompId = 2,
79 HvCallEventCompId = 3,
80 HvCallHptCompId = 4,
81 HvCallPciCompId = 5,
82 HvCallSlmCompId = 6,
83 HvCallSmCompId = 7,
84 HvCallSpdCompId = 8,
85 HvCallXmCompId = 9,
86 HvCallRioCompId = 10,
87 HvCallRsvd3CompId = 11,
88 HvCallRsvd2CompId = 12,
89 HvCallRsvd1CompId = 13,
90 HvCallMaxCompId = 14,
91 HvPrimaryCallCompId = 0,
92 HvPrimaryCallCfgCompId = 1,
93 HvPrimaryCallPciCompId = 2,
94 HvPrimaryCallSmCompId = 3,
95 HvPrimaryCallSpdCompId = 4,
96 HvPrimaryCallXmCompId = 5,
97 HvPrimaryCallRioCompId = 6,
98 HvPrimaryCallRsvd7CompId = 7,
99 HvPrimaryCallRsvd6CompId = 8,
100 HvPrimaryCallRsvd5CompId = 9,
101 HvPrimaryCallRsvd4CompId = 10,
102 HvPrimaryCallRsvd3CompId = 11,
103 HvPrimaryCallRsvd2CompId = 12,
104 HvPrimaryCallRsvd1CompId = 13,
105 HvPrimaryCallMaxCompId = HvCallMaxCompId
106};
107
108struct HvLpBufferList {
109 u64 addr;
110 u64 len;
111};
112
113#endif /* _ASM_POWERPC_ISERIES_HV_TYPES_H */
diff --git a/include/asm-powerpc/iseries/iseries_io.h b/include/asm-powerpc/iseries/iseries_io.h
new file mode 100644
index 000000000000..56b2113ff0f5
--- /dev/null
+++ b/include/asm-powerpc/iseries/iseries_io.h
@@ -0,0 +1,49 @@
1#ifndef _ASM_POWERPC_ISERIES_ISERIES_IO_H
2#define _ASM_POWERPC_ISERIES_ISERIES_IO_H
3
4#include <linux/config.h>
5
6#ifdef CONFIG_PPC_ISERIES
7#include <linux/types.h>
8/*
9 * File iSeries_io.h created by Allan Trautman on Thu Dec 28 2000.
10 *
11 * Remaps the io.h for the iSeries Io
12 * Copyright (C) 2000 Allan H Trautman, IBM Corporation
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the:
26 * Free Software Foundation, Inc.,
27 * 59 Temple Place, Suite 330,
28 * Boston, MA 02111-1307 USA
29 *
30 * Change Activity:
31 * Created December 28, 2000
32 * End Change Activity
33 */
34
35extern u8 iSeries_Read_Byte(const volatile void __iomem * IoAddress);
36extern u16 iSeries_Read_Word(const volatile void __iomem * IoAddress);
37extern u32 iSeries_Read_Long(const volatile void __iomem * IoAddress);
38extern void iSeries_Write_Byte(u8 IoData, volatile void __iomem * IoAddress);
39extern void iSeries_Write_Word(u16 IoData, volatile void __iomem * IoAddress);
40extern void iSeries_Write_Long(u32 IoData, volatile void __iomem * IoAddress);
41
42extern void iSeries_memset_io(volatile void __iomem *dest, char x, size_t n);
43extern void iSeries_memcpy_toio(volatile void __iomem *dest, void *source,
44 size_t n);
45extern void iSeries_memcpy_fromio(void *dest,
46 const volatile void __iomem *source, size_t n);
47
48#endif /* CONFIG_PPC_ISERIES */
49#endif /* _ASM_POWERPC_ISERIES_ISERIES_IO_H */
diff --git a/include/asm-powerpc/iseries/it_exp_vpd_panel.h b/include/asm-powerpc/iseries/it_exp_vpd_panel.h
new file mode 100644
index 000000000000..66a17a230c52
--- /dev/null
+++ b/include/asm-powerpc/iseries/it_exp_vpd_panel.h
@@ -0,0 +1,52 @@
1/*
2 * ItExtVpdPanel.h
3 * Copyright (C) 2002 Dave Boutcher IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H
20#define _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H
21
22/*
23 * This struct maps the panel information
24 *
25 * Warning:
26 * This data must match the architecture for the panel information
27 */
28
29#include <asm/types.h>
30
31struct ItExtVpdPanel {
32 /* Definition of the Extended Vpd On Panel Data Area */
33 char systemSerial[8];
34 char mfgID[4];
35 char reserved1[24];
36 char machineType[4];
37 char systemID[6];
38 char somUniqueCnt[4];
39 char serialNumberCount;
40 char reserved2[7];
41 u16 bbu3;
42 u16 bbu2;
43 u16 bbu1;
44 char xLocationLabel[8];
45 u8 xRsvd1[6];
46 u16 xFrameId;
47 u8 xRsvd2[48];
48};
49
50extern struct ItExtVpdPanel xItExtVpdPanel;
51
52#endif /* _ASM_POWERPC_ISERIES_IT_EXT_VPD_PANEL_H */
diff --git a/include/asm-powerpc/iseries/it_lp_naca.h b/include/asm-powerpc/iseries/it_lp_naca.h
new file mode 100644
index 000000000000..c3ef1de45d82
--- /dev/null
+++ b/include/asm-powerpc/iseries/it_lp_naca.h
@@ -0,0 +1,80 @@
1/*
2 * ItLpNaca.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_IT_LP_NACA_H
20#define _ASM_POWERPC_ISERIES_IT_LP_NACA_H
21
22#include <linux/types.h>
23
24/*
25 * This control block contains the data that is shared between the
26 * hypervisor (PLIC) and the OS.
27 */
28
29struct ItLpNaca {
30// CACHE_LINE_1 0x0000 - 0x007F Contains read-only data
31 u32 xDesc; // Eye catcher x00-x03
32 u16 xSize; // Size of this class x04-x05
33 u16 xIntHdlrOffset; // Offset to IntHdlr array x06-x07
34 u8 xMaxIntHdlrEntries; // Number of entries in array x08-x08
35 u8 xPrimaryLpIndex; // LP Index of Primary x09-x09
36 u8 xServiceLpIndex; // LP Ind of Service Focal Pointx0A-x0A
37 u8 xLpIndex; // LP Index x0B-x0B
38 u16 xMaxLpQueues; // Number of allocated queues x0C-x0D
39 u16 xLpQueueOffset; // Offset to start of LP queues x0E-x0F
40 u8 xPirEnvironMode:8; // Piranha or hardware x10-x10
41 u8 xPirConsoleMode:8; // Piranha console indicator x11-x11
42 u8 xPirDasdMode:8; // Piranha dasd indicator x12-x12
43 u8 xRsvd1_0[5]; // Reserved for Piranha related x13-x17
44 u8 xLparInstalled:1; // Is LPAR installed on system x18-x1F
45 u8 xSysPartitioned:1; // Is the system partitioned ...
46 u8 xHwSyncedTBs:1; // Hardware synced TBs ...
47 u8 xIntProcUtilHmt:1; // Utilize HMT for interrupts ...
48 u8 xRsvd1_1:4; // Reserved ...
49 u8 xSpVpdFormat:8; // VPD areas are in CSP format ...
50 u8 xIntProcRatio:8; // Ratio of int procs to procs ...
51 u8 xRsvd1_2[5]; // Reserved ...
52 u16 xRsvd1_3; // Reserved x20-x21
53 u16 xPlicVrmIndex; // VRM index of PLIC x22-x23
54 u16 xMinSupportedSlicVrmInd;// Min supported OS VRM index x24-x25
55 u16 xMinCompatableSlicVrmInd;// Min compatible OS VRM index x26-x27
56 u64 xLoadAreaAddr; // ER address of load area x28-x2F
57 u32 xLoadAreaChunks; // Chunks for the load area x30-x33
58 u32 xPaseSysCallCRMask; // Mask used to test CR before x34-x37
59 // doing an ASR switch on PASE
60 // system call.
61 u64 xSlicSegmentTablePtr; // Pointer to Slic seg table. x38-x3f
62 u8 xRsvd1_4[64]; // x40-x7F
63
64// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data
65 u8 xRsvd2_0[128]; // Reserved x00-x7F
66
67// CACHE_LINE_3-6 0x0100 - 0x02FF Contains LP Queue indicators
68// NB: Padding required to keep xInterrruptHdlr at x300 which is required
69// for v4r4 PLIC.
70 u8 xOldLpQueue[128]; // LP Queue needed for v4r4 100-17F
71 u8 xRsvd3_0[384]; // Reserved 180-2FF
72
73// CACHE_LINE_7-8 0x0300 - 0x03FF Contains the address of the OS interrupt
74// handlers
75 u64 xInterruptHdlr[32]; // Interrupt handlers 300-x3FF
76};
77
78extern struct ItLpNaca itLpNaca;
79
80#endif /* _ASM_POWERPC_ISERIES_IT_LP_NACA_H */
diff --git a/include/asm-powerpc/iseries/it_lp_queue.h b/include/asm-powerpc/iseries/it_lp_queue.h
new file mode 100644
index 000000000000..a60d03afbf95
--- /dev/null
+++ b/include/asm-powerpc/iseries/it_lp_queue.h
@@ -0,0 +1,81 @@
1/*
2 * ItLpQueue.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_IT_LP_QUEUE_H
20#define _ASM_POWERPC_ISERIES_IT_LP_QUEUE_H
21
22/*
23 * This control block defines the simple LP queue structure that is
24 * shared between the hypervisor (PLIC) and the OS in order to send
25 * events to an LP.
26 */
27
28#include <asm/types.h>
29#include <asm/ptrace.h>
30
31struct HvLpEvent;
32
33#define ITMaxLpQueues 8
34
35#define NotUsed 0 // Queue will not be used by PLIC
36#define DedicatedIo 1 // Queue dedicated to IO processor specified
37#define DedicatedLp 2 // Queue dedicated to LP specified
38#define Shared 3 // Queue shared for both IO and LP
39
40#define LpEventStackSize 4096
41#define LpEventMaxSize 256
42#define LpEventAlign 64
43
44struct hvlpevent_queue {
45/*
46 * The xSlicCurEventPtr is the pointer to the next event stack entry
47 * that will become valid. The OS must peek at this entry to determine
48 * if it is valid. PLIC will set the valid indicator as the very last
49 * store into that entry.
50 *
51 * When the OS has completed processing of the event then it will mark
52 * the event as invalid so that PLIC knows it can store into that event
53 * location again.
54 *
55 * If the event stack fills and there are overflow events, then PLIC
56 * will set the xPlicOverflowIntPending flag in which case the OS will
57 * have to fetch the additional LP events once they have drained the
58 * event stack.
59 *
60 * The first 16-bytes are known by both the OS and PLIC. The remainder
61 * of the cache line is for use by the OS.
62 */
63 u8 xPlicOverflowIntPending;// 0x00 Overflow events are pending
64 u8 xPlicStatus; // 0x01 DedicatedIo or DedicatedLp or NotUsed
65 u16 xSlicLogicalProcIndex; // 0x02 Logical Proc Index for correlation
66 u8 xPlicRsvd[12]; // 0x04
67 char *xSlicCurEventPtr; // 0x10
68 char *xSlicLastValidEventPtr; // 0x18
69 char *xSlicEventStackPtr; // 0x20
70 u8 xIndex; // 0x28 unique sequential index.
71 u8 xSlicRsvd[3]; // 0x29-2b
72 spinlock_t lock;
73};
74
75extern struct hvlpevent_queue hvlpevent_queue;
76
77extern int hvlpevent_is_pending(void);
78extern void process_hvlpevents(struct pt_regs *);
79extern void setup_hvlpevent_queue(void);
80
81#endif /* _ASM_POWERPC_ISERIES_IT_LP_QUEUE_H */
diff --git a/include/asm-powerpc/iseries/it_lp_reg_save.h b/include/asm-powerpc/iseries/it_lp_reg_save.h
new file mode 100644
index 000000000000..288044b702de
--- /dev/null
+++ b/include/asm-powerpc/iseries/it_lp_reg_save.h
@@ -0,0 +1,84 @@
1/*
2 * ItLpRegSave.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H
20#define _ASM_POWERPC_ISERIES_IT_LP_REG_SAVE_H
21
22/*
23 * This control block contains the data that is shared between PLIC
24 * and the OS
25 */
26
27struct ItLpRegSave {
28 u32 xDesc; // Eye catcher "LpRS" ebcdic 000-003
29 u16 xSize; // Size of this class 004-005
30 u8 xInUse; // Area is live 006-007
31 u8 xRsvd1[9]; // Reserved 007-00F
32
33 u8 xFixedRegSave[352]; // Fixed Register Save Area 010-16F
34 u32 xCTRL; // Control Register 170-173
35 u32 xDEC; // Decrementer 174-177
36 u32 xFPSCR; // FP Status and Control Reg 178-17B
37 u32 xPVR; // Processor Version Number 17C-17F
38
39 u64 xMMCR0; // Monitor Mode Control Reg 0 180-187
40 u32 xPMC1; // Perf Monitor Counter 1 188-18B
41 u32 xPMC2; // Perf Monitor Counter 2 18C-18F
42 u32 xPMC3; // Perf Monitor Counter 3 190-193
43 u32 xPMC4; // Perf Monitor Counter 4 194-197
44 u32 xPIR; // Processor ID Reg 198-19B
45
46 u32 xMMCR1; // Monitor Mode Control Reg 1 19C-19F
47 u32 xMMCRA; // Monitor Mode Control Reg A 1A0-1A3
48 u32 xPMC5; // Perf Monitor Counter 5 1A4-1A7
49 u32 xPMC6; // Perf Monitor Counter 6 1A8-1AB
50 u32 xPMC7; // Perf Monitor Counter 7 1AC-1AF
51 u32 xPMC8; // Perf Monitor Counter 8 1B0-1B3
52 u32 xTSC; // Thread Switch Control 1B4-1B7
53 u32 xTST; // Thread Switch Timeout 1B8-1BB
54 u32 xRsvd; // Reserved 1BC-1BF
55
56 u64 xACCR; // Address Compare Control Reg 1C0-1C7
57 u64 xIMR; // Instruction Match Register 1C8-1CF
58 u64 xSDR1; // Storage Description Reg 1 1D0-1D7
59 u64 xSPRG0; // Special Purpose Reg General0 1D8-1DF
60 u64 xSPRG1; // Special Purpose Reg General1 1E0-1E7
61 u64 xSPRG2; // Special Purpose Reg General2 1E8-1EF
62 u64 xSPRG3; // Special Purpose Reg General3 1F0-1F7
63 u64 xTB; // Time Base Register 1F8-1FF
64
65 u64 xFPR[32]; // Floating Point Registers 200-2FF
66
67 u64 xMSR; // Machine State Register 300-307
68 u64 xNIA; // Next Instruction Address 308-30F
69
70 u64 xDABR; // Data Address Breakpoint Reg 310-317
71 u64 xIABR; // Inst Address Breakpoint Reg 318-31F
72
73 u64 xHID0; // HW Implementation Dependent0 320-327
74
75 u64 xHID4; // HW Implementation Dependent4 328-32F
76 u64 xSCOMd; // SCON Data Reg (SPRG4) 330-337
77 u64 xSCOMc; // SCON Command Reg (SPRG5) 338-33F
78 u64 xSDAR; // Sample Data Address Register 340-347
79 u64 xSIAR; // Sample Inst Address Register 348-34F
80
81 u8 xRsvd3[176]; // Reserved 350-3FF
82};
83
84#endif /* _ITLPREGSAVE_H */
diff --git a/include/asm-powerpc/iseries/lpar_map.h b/include/asm-powerpc/iseries/lpar_map.h
new file mode 100644
index 000000000000..84fc321615bf
--- /dev/null
+++ b/include/asm-powerpc/iseries/lpar_map.h
@@ -0,0 +1,83 @@
1/*
2 * LparMap.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_ISERIES_LPAR_MAP_H
20#define _ASM_POWERPC_ISERIES_LPAR_MAP_H
21
22#ifndef __ASSEMBLY__
23
24#include <asm/types.h>
25
26/*
27 * The iSeries hypervisor will set up mapping for one or more
28 * ESID/VSID pairs (in SLB/segment registers) and will set up
29 * mappings of one or more ranges of pages to VAs.
30 * We will have the hypervisor set up the ESID->VSID mapping
31 * for the four kernel segments (C-F). With shared processors,
32 * the hypervisor will clear all segment registers and reload
33 * these four whenever the processor is switched from one
34 * partition to another.
35 */
36
37/* The Vsid and Esid identified below will be used by the hypervisor
38 * to set up a memory mapping for part of the load area before giving
39 * control to the Linux kernel. The load area is 64 MB, but this must
40 * not attempt to map the whole load area. The Hashed Page Table may
41 * need to be located within the load area (if the total partition size
42 * is 64 MB), but cannot be mapped. Typically, this should specify
43 * to map half (32 MB) of the load area.
44 *
45 * The hypervisor will set up page table entries for the number of
46 * pages specified.
47 *
48 * In 32-bit mode, the hypervisor will load all four of the
49 * segment registers (identified by the low-order four bits of the
50 * Esid field. In 64-bit mode, the hypervisor will load one SLB
51 * entry to map the Esid to the Vsid.
52*/
53
54#define HvEsidsToMap 2
55#define HvRangesToMap 1
56
57/* Hypervisor initially maps 32MB of the load area */
58#define HvPagesToMap 8192
59
60struct LparMap {
61 u64 xNumberEsids; // Number of ESID/VSID pairs
62 u64 xNumberRanges; // Number of VA ranges to map
63 u64 xSegmentTableOffs; // Page number within load area of seg table
64 u64 xRsvd[5];
65 struct {
66 u64 xKernelEsid; // Esid used to map kernel load
67 u64 xKernelVsid; // Vsid used to map kernel load
68 } xEsids[HvEsidsToMap];
69 struct {
70 u64 xPages; // Number of pages to be mapped
71 u64 xOffset; // Offset from start of load area
72 u64 xVPN; // Virtual Page Number
73 } xRanges[HvRangesToMap];
74};
75
76extern const struct LparMap xLparMap;
77
78#endif /* __ASSEMBLY__ */
79
80/* the fixed address where the LparMap exists */
81#define LPARMAP_PHYS 0x7000
82
83#endif /* _ASM_POWERPC_ISERIES_LPAR_MAP_H */
diff --git a/include/asm-powerpc/iseries/mf.h b/include/asm-powerpc/iseries/mf.h
new file mode 100644
index 000000000000..e7bd57a03fb1
--- /dev/null
+++ b/include/asm-powerpc/iseries/mf.h
@@ -0,0 +1,57 @@
1/*
2 * mf.h
3 * Copyright (C) 2001 Troy D. Armstrong IBM Corporation
4 * Copyright (C) 2004 Stephen Rothwell IBM Corporation
5 *
6 * This modules exists as an interface between a Linux secondary partition
7 * running on an iSeries and the primary partition's Virtual Service
8 * Processor (VSP) object. The VSP has final authority over powering on/off
9 * all partitions in the iSeries. It also provides miscellaneous low-level
10 * machine facility type operations.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */
26#ifndef _ASM_POWERPC_ISERIES_MF_H
27#define _ASM_POWERPC_ISERIES_MF_H
28
29#include <linux/types.h>
30
31#include <asm/iseries/hv_types.h>
32#include <asm/iseries/hv_call_event.h>
33
34struct rtc_time;
35
36typedef void (*MFCompleteHandler)(void *clientToken, int returnCode);
37
38extern void mf_allocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type,
39 unsigned size, unsigned amount, MFCompleteHandler hdlr,
40 void *userToken);
41extern void mf_deallocate_lp_events(HvLpIndex targetLp, HvLpEvent_Type type,
42 unsigned count, MFCompleteHandler hdlr, void *userToken);
43
44extern void mf_power_off(void);
45extern void mf_reboot(void);
46
47extern void mf_display_src(u32 word);
48extern void mf_display_progress(u16 value);
49extern void mf_clear_src(void);
50
51extern void mf_init(void);
52
53extern int mf_get_rtc(struct rtc_time *tm);
54extern int mf_get_boot_rtc(struct rtc_time *tm);
55extern int mf_set_rtc(struct rtc_time *tm);
56
57#endif /* _ASM_POWERPC_ISERIES_MF_H */
diff --git a/include/asm-powerpc/iseries/vio.h b/include/asm-powerpc/iseries/vio.h
new file mode 100644
index 000000000000..7e3a469420dd
--- /dev/null
+++ b/include/asm-powerpc/iseries/vio.h
@@ -0,0 +1,130 @@
1/* -*- linux-c -*-
2 * drivers/char/vio.h
3 *
4 * iSeries Virtual I/O Message Path header
5 *
6 * Authors: Dave Boutcher <boutcher@us.ibm.com>
7 * Ryan Arnold <ryanarn@us.ibm.com>
8 * Colin Devilbiss <devilbis@us.ibm.com>
9 *
10 * (C) Copyright 2000 IBM Corporation
11 *
12 * This header file is used by the iSeries virtual I/O device
13 * drivers. It defines the interfaces to the common functions
14 * (implemented in drivers/char/viopath.h) as well as defining
15 * common functions and structures. Currently (at the time I
16 * wrote this comment) the iSeries virtual I/O device drivers
17 * that use this are
18 * drivers/block/viodasd.c
19 * drivers/char/viocons.c
20 * drivers/char/viotape.c
21 * drivers/cdrom/viocd.c
22 *
23 * The iSeries virtual ethernet support (veth.c) uses a whole
24 * different set of functions.
25 *
26 * This program is free software; you can redistribute it and/or
27 * modify it under the terms of the GNU General Public License as
28 * published by the Free Software Foundation; either version 2 of the
29 * License, or (at your option) anyu later version.
30 *
31 * This program is distributed in the hope that it will be useful, but
32 * WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 * General Public License for more details.
35 *
36 * You should have received a copy of the GNU General Public License
37 * along with this program; if not, write to the Free Software Foundation,
38 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
39 *
40 */
41#ifndef _ASM_POWERPC_ISERIES_VIO_H
42#define _ASM_POWERPC_ISERIES_VIO_H
43
44#include <asm/iseries/hv_types.h>
45#include <asm/iseries/hv_lp_event.h>
46
47/*
48 * iSeries virtual I/O events use the subtype field in
49 * HvLpEvent to figure out what kind of vio event is coming
50 * in. We use a table to route these, and this defines
51 * the maximum number of distinct subtypes
52 */
53#define VIO_MAX_SUBTYPES 8
54
55/*
56 * Each subtype can register a handler to process their events.
57 * The handler must have this interface.
58 */
59typedef void (vio_event_handler_t) (struct HvLpEvent * event);
60
61extern int viopath_open(HvLpIndex remoteLp, int subtype, int numReq);
62extern int viopath_close(HvLpIndex remoteLp, int subtype, int numReq);
63extern int vio_setHandler(int subtype, vio_event_handler_t * beh);
64extern int vio_clearHandler(int subtype);
65extern int viopath_isactive(HvLpIndex lp);
66extern HvLpInstanceId viopath_sourceinst(HvLpIndex lp);
67extern HvLpInstanceId viopath_targetinst(HvLpIndex lp);
68extern void vio_set_hostlp(void);
69extern void *vio_get_event_buffer(int subtype);
70extern void vio_free_event_buffer(int subtype, void *buffer);
71
72extern HvLpIndex viopath_hostLp;
73extern HvLpIndex viopath_ourLp;
74
75#define VIOCHAR_MAX_DATA 200
76
77#define VIOMAJOR_SUBTYPE_MASK 0xff00
78#define VIOMINOR_SUBTYPE_MASK 0x00ff
79#define VIOMAJOR_SUBTYPE_SHIFT 8
80
81#define VIOVERSION 0x0101
82
83/*
84 * This is the general structure for VIO errors; each module should have
85 * a table of them, and each table should be terminated by an entry of
86 * { 0, 0, NULL }. Then, to find a specific error message, a module
87 * should pass its local table and the return code.
88 */
89struct vio_error_entry {
90 u16 rc;
91 int errno;
92 const char *msg;
93};
94extern const struct vio_error_entry *vio_lookup_rc(
95 const struct vio_error_entry *local_table, u16 rc);
96
97enum viosubtypes {
98 viomajorsubtype_monitor = 0x0100,
99 viomajorsubtype_blockio = 0x0200,
100 viomajorsubtype_chario = 0x0300,
101 viomajorsubtype_config = 0x0400,
102 viomajorsubtype_cdio = 0x0500,
103 viomajorsubtype_tape = 0x0600,
104 viomajorsubtype_scsi = 0x0700
105};
106
107enum vioconfigsubtype {
108 vioconfigget = 0x0001,
109};
110
111enum viorc {
112 viorc_good = 0x0000,
113 viorc_noConnection = 0x0001,
114 viorc_noReceiver = 0x0002,
115 viorc_noBufferAvailable = 0x0003,
116 viorc_invalidMessageType = 0x0004,
117 viorc_invalidRange = 0x0201,
118 viorc_invalidToken = 0x0202,
119 viorc_DMAError = 0x0203,
120 viorc_useError = 0x0204,
121 viorc_releaseError = 0x0205,
122 viorc_invalidDisk = 0x0206,
123 viorc_openRejected = 0x0301
124};
125
126struct device;
127
128extern struct device *iSeries_vio_dev;
129
130#endif /* _ASM_POWERPC_ISERIES_VIO_H */
diff --git a/include/asm-powerpc/kdebug.h b/include/asm-powerpc/kdebug.h
new file mode 100644
index 000000000000..9dcbac674811
--- /dev/null
+++ b/include/asm-powerpc/kdebug.h
@@ -0,0 +1,42 @@
1#ifndef _ASM_POWERPC_KDEBUG_H
2#define _ASM_POWERPC_KDEBUG_H
3
4/* nearly identical to x86_64/i386 code */
5
6#include <linux/notifier.h>
7
8struct pt_regs;
9
10struct die_args {
11 struct pt_regs *regs;
12 const char *str;
13 long err;
14 int trapnr;
15 int signr;
16};
17
18/*
19 Note - you should never unregister because that can race with NMIs.
20 If you really want to do it first unregister - then synchronize_sched -
21 then free.
22 */
23int register_die_notifier(struct notifier_block *nb);
24extern struct notifier_block *powerpc_die_chain;
25
26/* Grossly misnamed. */
27enum die_val {
28 DIE_OOPS = 1,
29 DIE_IABR_MATCH,
30 DIE_DABR_MATCH,
31 DIE_BPT,
32 DIE_SSTEP,
33 DIE_PAGE_FAULT,
34};
35
36static inline int notify_die(enum die_val val,char *str,struct pt_regs *regs,long err,int trap, int sig)
37{
38 struct die_args args = { .regs=regs, .str=str, .err=err, .trapnr=trap,.signr=sig };
39 return notifier_call_chain(&powerpc_die_chain, val, &args);
40}
41
42#endif /* _ASM_POWERPC_KDEBUG_H */
diff --git a/include/asm-powerpc/kexec.h b/include/asm-powerpc/kexec.h
new file mode 100644
index 000000000000..c72ffc709ea8
--- /dev/null
+++ b/include/asm-powerpc/kexec.h
@@ -0,0 +1,50 @@
1#ifndef _ASM_POWERPC_KEXEC_H
2#define _ASM_POWERPC_KEXEC_H
3
4/*
5 * Maximum page that is mapped directly into kernel memory.
6 * XXX: Since we copy virt we can use any page we allocate
7 */
8#define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
9
10/*
11 * Maximum address we can reach in physical address mode.
12 * XXX: I want to allow initrd in highmem. Otherwise set to rmo on LPAR.
13 */
14#define KEXEC_DESTINATION_MEMORY_LIMIT (-1UL)
15
16/* Maximum address we can use for the control code buffer */
17#ifdef __powerpc64__
18#define KEXEC_CONTROL_MEMORY_LIMIT (-1UL)
19#else
20/* TASK_SIZE, probably left over from use_mm ?? */
21#define KEXEC_CONTROL_MEMORY_LIMIT TASK_SIZE
22#endif
23
24#define KEXEC_CONTROL_CODE_SIZE 4096
25
26/* The native architecture */
27#ifdef __powerpc64__
28#define KEXEC_ARCH KEXEC_ARCH_PPC64
29#else
30#define KEXEC_ARCH KEXEC_ARCH_PPC
31#endif
32
33#ifndef __ASSEMBLY__
34
35#define MAX_NOTE_BYTES 1024
36typedef u32 note_buf_t[MAX_NOTE_BYTES / sizeof(u32)];
37
38extern note_buf_t crash_notes[];
39
40#ifdef __powerpc64__
41extern void kexec_smp_wait(void); /* get and clear naca physid, wait for
42 master to copy new code to 0 */
43extern void __init kexec_setup(void);
44#else
45struct kimage;
46extern void machine_kexec_simple(struct kimage *image);
47#endif
48
49#endif /* ! __ASSEMBLY__ */
50#endif /* _ASM_POWERPC_KEXEC_H */
diff --git a/include/asm-powerpc/keylargo.h b/include/asm-powerpc/keylargo.h
new file mode 100644
index 000000000000..a669a3f0f5a2
--- /dev/null
+++ b/include/asm-powerpc/keylargo.h
@@ -0,0 +1,248 @@
1/*
2 * keylargo.h: definitions for using the "KeyLargo" I/O controller chip.
3 *
4 */
5
6/* "Pangea" chipset has keylargo device-id 0x25 while core99
7 * has device-id 0x22. The rev. of the pangea one is 0, so we
8 * fake an artificial rev. in keylargo_rev by oring 0x100
9 */
10#define KL_PANGEA_REV 0x100
11
12/* offset from base for feature control registers */
13#define KEYLARGO_MBCR 0x34 /* KL Only, Media bay control/status */
14#define KEYLARGO_FCR0 0x38
15#define KEYLARGO_FCR1 0x3c
16#define KEYLARGO_FCR2 0x40
17#define KEYLARGO_FCR3 0x44
18#define KEYLARGO_FCR4 0x48
19#define KEYLARGO_FCR5 0x4c /* Pangea only */
20
21/* K2 aditional FCRs */
22#define K2_FCR6 0x34
23#define K2_FCR7 0x30
24#define K2_FCR8 0x2c
25#define K2_FCR9 0x28
26#define K2_FCR10 0x24
27
28/* GPIO registers */
29#define KEYLARGO_GPIO_LEVELS0 0x50
30#define KEYLARGO_GPIO_LEVELS1 0x54
31#define KEYLARGO_GPIO_EXTINT_0 0x58
32#define KEYLARGO_GPIO_EXTINT_CNT 18
33#define KEYLARGO_GPIO_0 0x6A
34#define KEYLARGO_GPIO_CNT 17
35#define KEYLARGO_GPIO_EXTINT_DUAL_EDGE 0x80
36#define KEYLARGO_GPIO_OUTPUT_ENABLE 0x04
37#define KEYLARGO_GPIO_OUTOUT_DATA 0x01
38#define KEYLARGO_GPIO_INPUT_DATA 0x02
39
40/* K2 does only extint GPIOs and does 51 of them */
41#define K2_GPIO_EXTINT_0 0x58
42#define K2_GPIO_EXTINT_CNT 51
43
44/* Specific GPIO regs */
45
46#define KL_GPIO_MODEM_RESET (KEYLARGO_GPIO_0+0x03)
47#define KL_GPIO_MODEM_POWER (KEYLARGO_GPIO_0+0x02) /* Pangea */
48
49#define KL_GPIO_SOUND_POWER (KEYLARGO_GPIO_0+0x05)
50
51/* Hrm... this one is only to be used on Pismo. It seeem to also
52 * control the timebase enable on other machines. Still to be
53 * experimented... --BenH.
54 */
55#define KL_GPIO_FW_CABLE_POWER (KEYLARGO_GPIO_0+0x09)
56#define KL_GPIO_TB_ENABLE (KEYLARGO_GPIO_0+0x09)
57
58#define KL_GPIO_ETH_PHY_RESET (KEYLARGO_GPIO_0+0x10)
59
60#define KL_GPIO_EXTINT_CPU1 (KEYLARGO_GPIO_0+0x0a)
61#define KL_GPIO_EXTINT_CPU1_ASSERT 0x04
62#define KL_GPIO_EXTINT_CPU1_RELEASE 0x38
63
64#define KL_GPIO_RESET_CPU0 (KEYLARGO_GPIO_EXTINT_0+0x03)
65#define KL_GPIO_RESET_CPU1 (KEYLARGO_GPIO_EXTINT_0+0x04)
66#define KL_GPIO_RESET_CPU2 (KEYLARGO_GPIO_EXTINT_0+0x0f)
67#define KL_GPIO_RESET_CPU3 (KEYLARGO_GPIO_EXTINT_0+0x10)
68
69#define KL_GPIO_PMU_MESSAGE_IRQ (KEYLARGO_GPIO_EXTINT_0+0x09)
70#define KL_GPIO_PMU_MESSAGE_BIT KEYLARGO_GPIO_INPUT_DATA
71
72#define KL_GPIO_MEDIABAY_IRQ (KEYLARGO_GPIO_EXTINT_0+0x0e)
73
74#define KL_GPIO_AIRPORT_0 (KEYLARGO_GPIO_EXTINT_0+0x0a)
75#define KL_GPIO_AIRPORT_1 (KEYLARGO_GPIO_EXTINT_0+0x0d)
76#define KL_GPIO_AIRPORT_2 (KEYLARGO_GPIO_0+0x0d)
77#define KL_GPIO_AIRPORT_3 (KEYLARGO_GPIO_0+0x0e)
78#define KL_GPIO_AIRPORT_4 (KEYLARGO_GPIO_0+0x0f)
79
80/*
81 * Bits in feature control register. Those bits different for K2 are
82 * listed separately
83 */
84#define KL_MBCR_MB0_PCI_ENABLE 0x00000800 /* exist ? */
85#define KL_MBCR_MB0_IDE_ENABLE 0x00001000
86#define KL_MBCR_MB0_FLOPPY_ENABLE 0x00002000 /* exist ? */
87#define KL_MBCR_MB0_SOUND_ENABLE 0x00004000 /* hrm... */
88#define KL_MBCR_MB0_DEV_MASK 0x00007800
89#define KL_MBCR_MB0_DEV_POWER 0x00000400
90#define KL_MBCR_MB0_DEV_RESET 0x00000200
91#define KL_MBCR_MB0_ENABLE 0x00000100
92#define KL_MBCR_MB1_PCI_ENABLE 0x08000000 /* exist ? */
93#define KL_MBCR_MB1_IDE_ENABLE 0x10000000
94#define KL_MBCR_MB1_FLOPPY_ENABLE 0x20000000 /* exist ? */
95#define KL_MBCR_MB1_SOUND_ENABLE 0x40000000 /* hrm... */
96#define KL_MBCR_MB1_DEV_MASK 0x78000000
97#define KL_MBCR_MB1_DEV_POWER 0x04000000
98#define KL_MBCR_MB1_DEV_RESET 0x02000000
99#define KL_MBCR_MB1_ENABLE 0x01000000
100
101#define KL0_SCC_B_INTF_ENABLE 0x00000001 /* (KL Only) */
102#define KL0_SCC_A_INTF_ENABLE 0x00000002
103#define KL0_SCC_SLOWPCLK 0x00000004
104#define KL0_SCC_RESET 0x00000008
105#define KL0_SCCA_ENABLE 0x00000010
106#define KL0_SCCB_ENABLE 0x00000020
107#define KL0_SCC_CELL_ENABLE 0x00000040
108#define KL0_IRDA_HIGH_BAND 0x00000100 /* (KL Only) */
109#define KL0_IRDA_SOURCE2_SEL 0x00000200 /* (KL Only) */
110#define KL0_IRDA_SOURCE1_SEL 0x00000400 /* (KL Only) */
111#define KL0_PG_USB0_PMI_ENABLE 0x00000400 /* (Pangea/Intrepid Only) */
112#define KL0_IRDA_RESET 0x00000800 /* (KL Only) */
113#define KL0_PG_USB0_REF_SUSPEND_SEL 0x00000800 /* (Pangea/Intrepid Only) */
114#define KL0_IRDA_DEFAULT1 0x00001000 /* (KL Only) */
115#define KL0_PG_USB0_REF_SUSPEND 0x00001000 /* (Pangea/Intrepid Only) */
116#define KL0_IRDA_DEFAULT0 0x00002000 /* (KL Only) */
117#define KL0_PG_USB0_PAD_SUSPEND 0x00002000 /* (Pangea/Intrepid Only) */
118#define KL0_IRDA_FAST_CONNECT 0x00004000 /* (KL Only) */
119#define KL0_PG_USB1_PMI_ENABLE 0x00004000 /* (Pangea/Intrepid Only) */
120#define KL0_IRDA_ENABLE 0x00008000 /* (KL Only) */
121#define KL0_PG_USB1_REF_SUSPEND_SEL 0x00008000 /* (Pangea/Intrepid Only) */
122#define KL0_IRDA_CLK32_ENABLE 0x00010000 /* (KL Only) */
123#define KL0_PG_USB1_REF_SUSPEND 0x00010000 /* (Pangea/Intrepid Only) */
124#define KL0_IRDA_CLK19_ENABLE 0x00020000 /* (KL Only) */
125#define KL0_PG_USB1_PAD_SUSPEND 0x00020000 /* (Pangea/Intrepid Only) */
126#define KL0_USB0_PAD_SUSPEND0 0x00040000
127#define KL0_USB0_PAD_SUSPEND1 0x00080000
128#define KL0_USB0_CELL_ENABLE 0x00100000
129#define KL0_USB1_PAD_SUSPEND0 0x00400000
130#define KL0_USB1_PAD_SUSPEND1 0x00800000
131#define KL0_USB1_CELL_ENABLE 0x01000000
132#define KL0_USB_REF_SUSPEND 0x10000000 /* (KL Only) */
133
134#define KL0_SERIAL_ENABLE (KL0_SCC_B_INTF_ENABLE | \
135 KL0_SCC_SLOWPCLK | \
136 KL0_SCC_CELL_ENABLE | KL0_SCCA_ENABLE)
137
138#define KL1_USB2_PMI_ENABLE 0x00000001 /* Intrepid only */
139#define KL1_AUDIO_SEL_22MCLK 0x00000002 /* KL/Pangea only */
140#define KL1_USB2_REF_SUSPEND_SEL 0x00000002 /* Intrepid only */
141#define KL1_USB2_REF_SUSPEND 0x00000004 /* Intrepid only */
142#define KL1_AUDIO_CLK_ENABLE_BIT 0x00000008 /* KL/Pangea only */
143#define KL1_USB2_PAD_SUSPEND_SEL 0x00000008 /* Intrepid only */
144#define KL1_USB2_PAD_SUSPEND0 0x00000010 /* Intrepid only */
145#define KL1_AUDIO_CLK_OUT_ENABLE 0x00000020 /* KL/Pangea only */
146#define KL1_USB2_PAD_SUSPEND1 0x00000020 /* Intrepid only */
147#define KL1_AUDIO_CELL_ENABLE 0x00000040 /* KL/Pangea only */
148#define KL1_USB2_CELL_ENABLE 0x00000040 /* Intrepid only */
149#define KL1_AUDIO_CHOOSE 0x00000080 /* KL/Pangea only */
150#define KL1_I2S0_CHOOSE 0x00000200 /* KL Only */
151#define KL1_I2S0_CELL_ENABLE 0x00000400
152#define KL1_I2S0_CLK_ENABLE_BIT 0x00001000
153#define KL1_I2S0_ENABLE 0x00002000
154#define KL1_I2S1_CELL_ENABLE 0x00020000
155#define KL1_I2S1_CLK_ENABLE_BIT 0x00080000
156#define KL1_I2S1_ENABLE 0x00100000
157#define KL1_EIDE0_ENABLE 0x00800000 /* KL/Intrepid Only */
158#define KL1_EIDE0_RESET_N 0x01000000 /* KL/Intrepid Only */
159#define KL1_EIDE1_ENABLE 0x04000000 /* KL Only */
160#define KL1_EIDE1_RESET_N 0x08000000 /* KL Only */
161#define KL1_UIDE_ENABLE 0x20000000 /* KL/Pangea Only */
162#define KL1_UIDE_RESET_N 0x40000000 /* KL/Pangea Only */
163
164#define KL2_IOBUS_ENABLE 0x00000002
165#define KL2_SLEEP_STATE_BIT 0x00000100 /* KL Only */
166#define KL2_PG_STOP_ALL_CLOCKS 0x00000100 /* Pangea Only */
167#define KL2_MPIC_ENABLE 0x00020000
168#define KL2_CARDSLOT_RESET 0x00040000 /* Pangea/Intrepid Only */
169#define KL2_ALT_DATA_OUT 0x02000000 /* KL Only ??? */
170#define KL2_MEM_IS_BIG 0x04000000
171#define KL2_CARDSEL_16 0x08000000
172
173#define KL3_SHUTDOWN_PLL_TOTAL 0x00000001 /* KL/Pangea only */
174#define KL3_SHUTDOWN_PLLKW6 0x00000002 /* KL/Pangea only */
175#define KL3_IT_SHUTDOWN_PLL3 0x00000002 /* Intrepid only */
176#define KL3_SHUTDOWN_PLLKW4 0x00000004 /* KL/Pangea only */
177#define KL3_IT_SHUTDOWN_PLL2 0x00000004 /* Intrepid only */
178#define KL3_SHUTDOWN_PLLKW35 0x00000008 /* KL/Pangea only */
179#define KL3_IT_SHUTDOWN_PLL1 0x00000008 /* Intrepid only */
180#define KL3_SHUTDOWN_PLLKW12 0x00000010 /* KL Only */
181#define KL3_IT_ENABLE_PLL3_SHUTDOWN 0x00000010 /* Intrepid only */
182#define KL3_PLL_RESET 0x00000020 /* KL/Pangea only */
183#define KL3_IT_ENABLE_PLL2_SHUTDOWN 0x00000020 /* Intrepid only */
184#define KL3_IT_ENABLE_PLL1_SHUTDOWN 0x00000010 /* Intrepid only */
185#define KL3_SHUTDOWN_PLL2X 0x00000080 /* KL Only */
186#define KL3_CLK66_ENABLE 0x00000100 /* KL Only */
187#define KL3_CLK49_ENABLE 0x00000200
188#define KL3_CLK45_ENABLE 0x00000400
189#define KL3_CLK31_ENABLE 0x00000800 /* KL/Pangea only */
190#define KL3_TIMER_CLK18_ENABLE 0x00001000
191#define KL3_I2S1_CLK18_ENABLE 0x00002000
192#define KL3_I2S0_CLK18_ENABLE 0x00004000
193#define KL3_VIA_CLK16_ENABLE 0x00008000 /* KL/Pangea only */
194#define KL3_IT_VIA_CLK32_ENABLE 0x00008000 /* Intrepid only */
195#define KL3_STOPPING33_ENABLED 0x00080000 /* KL Only */
196#define KL3_PG_PLL_ENABLE_TEST 0x00080000 /* Pangea Only */
197
198/* Intrepid USB bus 2, port 0,1 */
199#define KL3_IT_PORT_WAKEUP_ENABLE(p) (0x00080000 << ((p)<<3))
200#define KL3_IT_PORT_RESUME_WAKE_EN(p) (0x00040000 << ((p)<<3))
201#define KL3_IT_PORT_CONNECT_WAKE_EN(p) (0x00020000 << ((p)<<3))
202#define KL3_IT_PORT_DISCONNECT_WAKE_EN(p) (0x00010000 << ((p)<<3))
203#define KL3_IT_PORT_RESUME_STAT(p) (0x00300000 << ((p)<<3))
204#define KL3_IT_PORT_CONNECT_STAT(p) (0x00200000 << ((p)<<3))
205#define KL3_IT_PORT_DISCONNECT_STAT(p) (0x00100000 << ((p)<<3))
206
207/* Port 0,1 : bus 0, port 2,3 : bus 1 */
208#define KL4_PORT_WAKEUP_ENABLE(p) (0x00000008 << ((p)<<3))
209#define KL4_PORT_RESUME_WAKE_EN(p) (0x00000004 << ((p)<<3))
210#define KL4_PORT_CONNECT_WAKE_EN(p) (0x00000002 << ((p)<<3))
211#define KL4_PORT_DISCONNECT_WAKE_EN(p) (0x00000001 << ((p)<<3))
212#define KL4_PORT_RESUME_STAT(p) (0x00000040 << ((p)<<3))
213#define KL4_PORT_CONNECT_STAT(p) (0x00000020 << ((p)<<3))
214#define KL4_PORT_DISCONNECT_STAT(p) (0x00000010 << ((p)<<3))
215
216/* Pangea and Intrepid only */
217#define KL5_VIA_USE_CLK31 0000000001 /* Pangea Only */
218#define KL5_SCC_USE_CLK31 0x00000002 /* Pangea Only */
219#define KL5_PWM_CLK32_EN 0x00000004
220#define KL5_CLK3_68_EN 0x00000010
221#define KL5_CLK32_EN 0x00000020
222
223
224/* K2 definitions */
225#define K2_FCR0_USB0_SWRESET 0x00200000
226#define K2_FCR0_USB1_SWRESET 0x02000000
227#define K2_FCR0_RING_PME_DISABLE 0x08000000
228
229#define K2_FCR1_PCI1_BUS_RESET_N 0x00000010
230#define K2_FCR1_PCI1_SLEEP_RESET_EN 0x00000020
231#define K2_FCR1_I2S0_CELL_ENABLE 0x00000400
232#define K2_FCR1_I2S0_RESET 0x00000800
233#define K2_FCR1_I2S0_CLK_ENABLE_BIT 0x00001000
234#define K2_FCR1_I2S0_ENABLE 0x00002000
235
236#define K2_FCR1_PCI1_CLK_ENABLE 0x00004000
237#define K2_FCR1_FW_CLK_ENABLE 0x00008000
238#define K2_FCR1_FW_RESET_N 0x00010000
239#define K2_FCR1_GMAC_CLK_ENABLE 0x00400000
240#define K2_FCR1_GMAC_POWER_DOWN 0x00800000
241#define K2_FCR1_GMAC_RESET_N 0x01000000
242#define K2_FCR1_SATA_CLK_ENABLE 0x02000000
243#define K2_FCR1_SATA_POWER_DOWN 0x04000000
244#define K2_FCR1_SATA_RESET_N 0x08000000
245#define K2_FCR1_UATA_CLK_ENABLE 0x10000000
246#define K2_FCR1_UATA_RESET_N 0x40000000
247#define K2_FCR1_UATA_CHOOSE_CLK66 0x80000000
248
diff --git a/include/asm-powerpc/kmap_types.h b/include/asm-powerpc/kmap_types.h
new file mode 100644
index 000000000000..b6bac6f61c16
--- /dev/null
+++ b/include/asm-powerpc/kmap_types.h
@@ -0,0 +1,33 @@
1#ifndef _ASM_POWERPC_KMAP_TYPES_H
2#define _ASM_POWERPC_KMAP_TYPES_H
3
4#ifdef __KERNEL__
5
6/*
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13enum km_type {
14 KM_BOUNCE_READ,
15 KM_SKB_SUNRPC_DATA,
16 KM_SKB_DATA_SOFTIRQ,
17 KM_USER0,
18 KM_USER1,
19 KM_BIO_SRC_IRQ,
20 KM_BIO_DST_IRQ,
21 KM_PTE0,
22 KM_PTE1,
23 KM_IRQ0,
24 KM_IRQ1,
25 KM_SOFTIRQ0,
26 KM_SOFTIRQ1,
27 KM_PPC_SYNC_PAGE,
28 KM_PPC_SYNC_ICACHE,
29 KM_TYPE_NR
30};
31
32#endif /* __KERNEL__ */
33#endif /* _ASM_POWERPC_KMAP_TYPES_H */
diff --git a/include/asm-powerpc/kprobes.h b/include/asm-powerpc/kprobes.h
new file mode 100644
index 000000000000..6cd0a3bfa280
--- /dev/null
+++ b/include/asm-powerpc/kprobes.h
@@ -0,0 +1,81 @@
1#ifndef _ASM_POWERPC_KPROBES_H
2#define _ASM_POWERPC_KPROBES_H
3/*
4 * Kernel Probes (KProbes)
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
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 * Copyright (C) IBM Corporation, 2002, 2004
21 *
22 * 2002-Oct Created by Vamsi Krishna S <vamsi_krishna@in.ibm.com> Kernel
23 * Probes initial implementation ( includes suggestions from
24 * Rusty Russell).
25 * 2004-Nov Modified for PPC64 by Ananth N Mavinakayanahalli
26 * <ananth@in.ibm.com>
27 */
28#include <linux/types.h>
29#include <linux/ptrace.h>
30#include <linux/percpu.h>
31
32struct pt_regs;
33
34typedef unsigned int kprobe_opcode_t;
35#define BREAKPOINT_INSTRUCTION 0x7fe00008 /* trap */
36#define MAX_INSN_SIZE 1
37
38#define IS_TW(instr) (((instr) & 0xfc0007fe) == 0x7c000008)
39#define IS_TD(instr) (((instr) & 0xfc0007fe) == 0x7c000088)
40#define IS_TDI(instr) (((instr) & 0xfc000000) == 0x08000000)
41#define IS_TWI(instr) (((instr) & 0xfc000000) == 0x0c000000)
42
43#define JPROBE_ENTRY(pentry) (kprobe_opcode_t *)((func_descr_t *)pentry)
44
45#define is_trap(instr) (IS_TW(instr) || IS_TD(instr) || \
46 IS_TWI(instr) || IS_TDI(instr))
47
48#define ARCH_SUPPORTS_KRETPROBES
49void kretprobe_trampoline(void);
50
51/* Architecture specific copy of original instruction */
52struct arch_specific_insn {
53 /* copy of original instruction */
54 kprobe_opcode_t *insn;
55};
56
57struct prev_kprobe {
58 struct kprobe *kp;
59 unsigned long status;
60 unsigned long saved_msr;
61};
62
63/* per-cpu kprobe control block */
64struct kprobe_ctlblk {
65 unsigned long kprobe_status;
66 unsigned long kprobe_saved_msr;
67 struct pt_regs jprobe_saved_regs;
68 struct prev_kprobe prev_kprobe;
69};
70
71#ifdef CONFIG_KPROBES
72extern int kprobe_exceptions_notify(struct notifier_block *self,
73 unsigned long val, void *data);
74#else /* !CONFIG_KPROBES */
75static inline int kprobe_exceptions_notify(struct notifier_block *self,
76 unsigned long val, void *data)
77{
78 return 0;
79}
80#endif
81#endif /* _ASM_POWERPC_KPROBES_H */
diff --git a/include/asm-powerpc/lmb.h b/include/asm-powerpc/lmb.h
new file mode 100644
index 000000000000..ea0afe343545
--- /dev/null
+++ b/include/asm-powerpc/lmb.h
@@ -0,0 +1,81 @@
1#ifndef _PPC64_LMB_H
2#define _PPC64_LMB_H
3
4/*
5 * Definitions for talking to the Open Firmware PROM on
6 * Power Macintosh computers.
7 *
8 * Copyright (C) 2001 Peter Bergner, IBM Corp.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#include <linux/init.h>
17#include <asm/prom.h>
18
19#define MAX_LMB_REGIONS 128
20
21#define LMB_ALLOC_ANYWHERE 0
22
23struct lmb_property {
24 unsigned long base;
25 unsigned long size;
26};
27
28struct lmb_region {
29 unsigned long cnt;
30 unsigned long size;
31 struct lmb_property region[MAX_LMB_REGIONS+1];
32};
33
34struct lmb {
35 unsigned long debug;
36 unsigned long rmo_size;
37 struct lmb_region memory;
38 struct lmb_region reserved;
39};
40
41extern struct lmb lmb;
42
43extern void __init lmb_init(void);
44extern void __init lmb_analyze(void);
45extern long __init lmb_add(unsigned long, unsigned long);
46extern long __init lmb_reserve(unsigned long, unsigned long);
47extern unsigned long __init lmb_alloc(unsigned long, unsigned long);
48extern unsigned long __init lmb_alloc_base(unsigned long, unsigned long,
49 unsigned long);
50extern unsigned long __init lmb_phys_mem_size(void);
51extern unsigned long __init lmb_end_of_DRAM(void);
52extern unsigned long __init lmb_abs_to_phys(unsigned long);
53extern void __init lmb_enforce_memory_limit(unsigned long);
54
55extern void lmb_dump_all(void);
56
57extern unsigned long io_hole_start;
58
59static inline unsigned long
60lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
61{
62 return type->region[region_nr].size;
63}
64static inline unsigned long
65lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
66{
67 return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
68}
69static inline unsigned long
70lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
71{
72 return type->region[region_nr].base >> PAGE_SHIFT;
73}
74static inline unsigned long
75lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
76{
77 return lmb_start_pfn(type, region_nr) +
78 lmb_size_pages(type, region_nr);
79}
80
81#endif /* _PPC64_LMB_H */
diff --git a/include/asm-powerpc/lppaca.h b/include/asm-powerpc/lppaca.h
new file mode 100644
index 000000000000..c1bedab1515b
--- /dev/null
+++ b/include/asm-powerpc/lppaca.h
@@ -0,0 +1,131 @@
1/*
2 * lppaca.h
3 * Copyright (C) 2001 Mike Corrigan IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _ASM_POWERPC_LPPACA_H
20#define _ASM_POWERPC_LPPACA_H
21
22//=============================================================================
23//
24// This control block contains the data that is shared between the
25// hypervisor (PLIC) and the OS.
26//
27//
28//----------------------------------------------------------------------------
29#include <asm/types.h>
30
31struct lppaca {
32//=============================================================================
33// CACHE_LINE_1 0x0000 - 0x007F Contains read-only data
34// NOTE: The xDynXyz fields are fields that will be dynamically changed by
35// PLIC when preparing to bring a processor online or when dispatching a
36// virtual processor!
37//=============================================================================
38 u32 desc; // Eye catcher 0xD397D781 x00-x03
39 u16 size; // Size of this struct x04-x05
40 u16 reserved1; // Reserved x06-x07
41 u16 reserved2:14; // Reserved x08-x09
42 u8 shared_proc:1; // Shared processor indicator ...
43 u8 secondary_thread:1; // Secondary thread indicator ...
44 volatile u8 dyn_proc_status:8; // Dynamic Status of this proc x0A-x0A
45 u8 secondary_thread_count; // Secondary thread count x0B-x0B
46 volatile u16 dyn_hv_phys_proc_index;// Dynamic HV Physical Proc Index0C-x0D
47 volatile u16 dyn_hv_log_proc_index;// Dynamic HV Logical Proc Indexx0E-x0F
48 u32 decr_val; // Value for Decr programming x10-x13
49 u32 pmc_val; // Value for PMC regs x14-x17
50 volatile u32 dyn_hw_node_id; // Dynamic Hardware Node id x18-x1B
51 volatile u32 dyn_hw_proc_id; // Dynamic Hardware Proc Id x1C-x1F
52 volatile u32 dyn_pir; // Dynamic ProcIdReg value x20-x23
53 u32 dsei_data; // DSEI data x24-x27
54 u64 sprg3; // SPRG3 value x28-x2F
55 u8 reserved3[80]; // Reserved x30-x7F
56
57//=============================================================================
58// CACHE_LINE_2 0x0080 - 0x00FF Contains local read-write data
59//=============================================================================
60 // This Dword contains a byte for each type of interrupt that can occur.
61 // The IPI is a count while the others are just a binary 1 or 0.
62 union {
63 u64 any_int;
64 struct {
65 u16 reserved; // Reserved - cleared by #mpasmbl
66 u8 xirr_int; // Indicates xXirrValue is valid or Immed IO
67 u8 ipi_cnt; // IPI Count
68 u8 decr_int; // DECR interrupt occurred
69 u8 pdc_int; // PDC interrupt occurred
70 u8 quantum_int; // Interrupt quantum reached
71 u8 old_plic_deferred_ext_int; // Old PLIC has a deferred XIRR pending
72 } fields;
73 } int_dword;
74
75 // Whenever any fields in this Dword are set then PLIC will defer the
76 // processing of external interrupts. Note that PLIC will store the
77 // XIRR directly into the xXirrValue field so that another XIRR will
78 // not be presented until this one clears. The layout of the low
79 // 4-bytes of this Dword is upto SLIC - PLIC just checks whether the
80 // entire Dword is zero or not. A non-zero value in the low order
81 // 2-bytes will result in SLIC being granted the highest thread
82 // priority upon return. A 0 will return to SLIC as medium priority.
83 u64 plic_defer_ints_area; // Entire Dword
84
85 // Used to pass the real SRR0/1 from PLIC to SLIC as well as to
86 // pass the target SRR0/1 from SLIC to PLIC on a SetAsrAndRfid.
87 u64 saved_srr0; // Saved SRR0 x10-x17
88 u64 saved_srr1; // Saved SRR1 x18-x1F
89
90 // Used to pass parms from the OS to PLIC for SetAsrAndRfid
91 u64 saved_gpr3; // Saved GPR3 x20-x27
92 u64 saved_gpr4; // Saved GPR4 x28-x2F
93 u64 saved_gpr5; // Saved GPR5 x30-x37
94
95 u8 reserved4; // Reserved x38-x38
96 u8 cpuctls_task_attrs; // Task attributes for cpuctls x39-x39
97 u8 fpregs_in_use; // FP regs in use x3A-x3A
98 u8 pmcregs_in_use; // PMC regs in use x3B-x3B
99 volatile u32 saved_decr; // Saved Decr Value x3C-x3F
100 volatile u64 emulated_time_base;// Emulated TB for this thread x40-x47
101 volatile u64 cur_plic_latency; // Unaccounted PLIC latency x48-x4F
102 u64 tot_plic_latency; // Accumulated PLIC latency x50-x57
103 u64 wait_state_cycles; // Wait cycles for this proc x58-x5F
104 u64 end_of_quantum; // TB at end of quantum x60-x67
105 u64 pdc_saved_sprg1; // Saved SPRG1 for PMC int x68-x6F
106 u64 pdc_saved_srr0; // Saved SRR0 for PMC int x70-x77
107 volatile u32 virtual_decr; // Virtual DECR for shared procsx78-x7B
108 u16 slb_count; // # of SLBs to maintain x7C-x7D
109 u8 idle; // Indicate OS is idle x7E
110 u8 vmxregs_in_use; // VMX registers in use x7F
111
112
113//=============================================================================
114// CACHE_LINE_3 0x0100 - 0x007F: This line is shared with other processors
115//=============================================================================
116 // This is the yield_count. An "odd" value (low bit on) means that
117 // the processor is yielded (either because of an OS yield or a PLIC
118 // preempt). An even value implies that the processor is currently
119 // executing.
120 // NOTE: This value will ALWAYS be zero for dedicated processors and
121 // will NEVER be zero for shared processors (ie, initialized to a 1).
122 volatile u32 yield_count; // PLIC increments each dispatchx00-x03
123 u8 reserved6[124]; // Reserved x04-x7F
124
125//=============================================================================
126// CACHE_LINE_4-5 0x0100 - 0x01FF Contains PMC interrupt data
127//=============================================================================
128 u8 pmc_save_area[256]; // PMC interrupt Area x00-xFF
129};
130
131#endif /* _ASM_POWERPC_LPPACA_H */
diff --git a/include/asm-powerpc/machdep.h b/include/asm-powerpc/machdep.h
new file mode 100644
index 000000000000..c011abb8b600
--- /dev/null
+++ b/include/asm-powerpc/machdep.h
@@ -0,0 +1,291 @@
1#ifndef _ASM_POWERPC_MACHDEP_H
2#define _ASM_POWERPC_MACHDEP_H
3#ifdef __KERNEL__
4
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#include <linux/config.h>
13#include <linux/seq_file.h>
14#include <linux/init.h>
15#include <linux/dma-mapping.h>
16
17#include <asm/setup.h>
18
19/* We export this macro for external modules like Alsa to know if
20 * ppc_md.feature_call is implemented or not
21 */
22#define CONFIG_PPC_HAS_FEATURE_CALLS
23
24struct pt_regs;
25struct pci_bus;
26struct device_node;
27struct iommu_table;
28struct rtc_time;
29struct file;
30
31#ifdef CONFIG_SMP
32struct smp_ops_t {
33 void (*message_pass)(int target, int msg);
34 int (*probe)(void);
35 void (*kick_cpu)(int nr);
36 void (*setup_cpu)(int nr);
37 void (*take_timebase)(void);
38 void (*give_timebase)(void);
39 int (*cpu_enable)(unsigned int nr);
40 int (*cpu_disable)(void);
41 void (*cpu_die)(unsigned int nr);
42 int (*cpu_bootable)(unsigned int nr);
43};
44#endif
45
46struct machdep_calls {
47#ifdef CONFIG_PPC64
48 void (*hpte_invalidate)(unsigned long slot,
49 unsigned long va,
50 int psize,
51 int local);
52 long (*hpte_updatepp)(unsigned long slot,
53 unsigned long newpp,
54 unsigned long va,
55 int pize,
56 int local);
57 void (*hpte_updateboltedpp)(unsigned long newpp,
58 unsigned long ea,
59 int psize);
60 long (*hpte_insert)(unsigned long hpte_group,
61 unsigned long va,
62 unsigned long prpn,
63 unsigned long rflags,
64 unsigned long vflags,
65 int psize);
66 long (*hpte_remove)(unsigned long hpte_group);
67 void (*flush_hash_range)(unsigned long number, int local);
68
69 /* special for kexec, to be called in real mode, linar mapping is
70 * destroyed as well */
71 void (*hpte_clear_all)(void);
72
73 void (*tce_build)(struct iommu_table * tbl,
74 long index,
75 long npages,
76 unsigned long uaddr,
77 enum dma_data_direction direction);
78 void (*tce_free)(struct iommu_table *tbl,
79 long index,
80 long npages);
81 void (*tce_flush)(struct iommu_table *tbl);
82 void (*iommu_dev_setup)(struct pci_dev *dev);
83 void (*iommu_bus_setup)(struct pci_bus *bus);
84 void (*irq_bus_setup)(struct pci_bus *bus);
85#endif
86
87 int (*probe)(int platform);
88 void (*setup_arch)(void);
89 void (*init_early)(void);
90 /* Optional, may be NULL. */
91 void (*show_cpuinfo)(struct seq_file *m);
92 void (*show_percpuinfo)(struct seq_file *m, int i);
93
94 void (*init_IRQ)(void);
95 int (*get_irq)(struct pt_regs *);
96#ifdef CONFIG_KEXEC
97 void (*kexec_cpu_down)(int crash_shutdown, int secondary);
98#endif
99
100 /* PCI stuff */
101 /* Called after scanning the bus, before allocating resources */
102 void (*pcibios_fixup)(void);
103 int (*pci_probe_mode)(struct pci_bus *);
104
105 void (*restart)(char *cmd);
106 void (*power_off)(void);
107 void (*halt)(void);
108 void (*panic)(char *str);
109 void (*cpu_die)(void);
110
111 long (*time_init)(void); /* Optional, may be NULL */
112
113 int (*set_rtc_time)(struct rtc_time *);
114 void (*get_rtc_time)(struct rtc_time *);
115 unsigned long (*get_boot_time)(void);
116 unsigned char (*rtc_read_val)(int addr);
117 void (*rtc_write_val)(int addr, unsigned char val);
118
119 void (*calibrate_decr)(void);
120
121 void (*progress)(char *, unsigned short);
122
123 /* Interface for platform error logging */
124 void (*log_error)(char *buf, unsigned int err_type, int fatal);
125
126 unsigned char (*nvram_read_val)(int addr);
127 void (*nvram_write_val)(int addr, unsigned char val);
128 ssize_t (*nvram_write)(char *buf, size_t count, loff_t *index);
129 ssize_t (*nvram_read)(char *buf, size_t count, loff_t *index);
130 ssize_t (*nvram_size)(void);
131 void (*nvram_sync)(void);
132
133 /* Exception handlers */
134 void (*system_reset_exception)(struct pt_regs *regs);
135 int (*machine_check_exception)(struct pt_regs *regs);
136
137 /* Motherboard/chipset features. This is a kind of general purpose
138 * hook used to control some machine specific features (like reset
139 * lines, chip power control, etc...).
140 */
141 long (*feature_call)(unsigned int feature, ...);
142
143 /* Check availability of legacy devices like i8042 */
144 int (*check_legacy_ioport)(unsigned int baseport);
145
146 /* Get legacy PCI/IDE interrupt mapping */
147 int (*pci_get_legacy_ide_irq)(struct pci_dev *dev, int channel);
148
149 /* Get access protection for /dev/mem */
150 pgprot_t (*phys_mem_access_prot)(struct file *file,
151 unsigned long pfn,
152 unsigned long size,
153 pgprot_t vma_prot);
154
155 /* Idle loop for this platform, leave empty for default idle loop */
156 void (*idle_loop)(void);
157
158 /* Function to enable performance monitor counters for this
159 platform, called once per cpu. */
160 void (*enable_pmcs)(void);
161
162 /* Set DABR for this platform, leave empty for default implemenation */
163 int (*set_dabr)(unsigned long dabr);
164
165#ifdef CONFIG_PPC32 /* XXX for now */
166 /* A general init function, called by ppc_init in init/main.c.
167 May be NULL. */
168 void (*init)(void);
169
170 void (*idle)(void);
171 void (*power_save)(void);
172
173 void (*heartbeat)(void);
174 unsigned long heartbeat_reset;
175 unsigned long heartbeat_count;
176
177 void (*setup_io_mappings)(void);
178
179 void (*early_serial_map)(void);
180 void (*kgdb_map_scc)(void);
181
182 /*
183 * optional PCI "hooks"
184 */
185
186 /* Called after PPC generic resource fixup to perform
187 machine specific fixups */
188 void (*pcibios_fixup_resources)(struct pci_dev *);
189
190 /* Called for each PCI bus in the system when it's probed */
191 void (*pcibios_fixup_bus)(struct pci_bus *);
192
193 /* Called when pci_enable_device() is called (initial=0) or
194 * when a device with no assigned resource is found (initial=1).
195 * Returns 0 to allow assignment/enabling of the device. */
196 int (*pcibios_enable_device_hook)(struct pci_dev *, int initial);
197
198 /* For interrupt routing */
199 unsigned char (*pci_swizzle)(struct pci_dev *, unsigned char *);
200 int (*pci_map_irq)(struct pci_dev *, unsigned char, unsigned char);
201
202 /* Called in indirect_* to avoid touching devices */
203 int (*pci_exclude_device)(unsigned char, unsigned char);
204
205 /* Called at then very end of pcibios_init() */
206 void (*pcibios_after_init)(void);
207
208 /* this is for modules, since _machine can be a define -- Cort */
209 int ppc_machine;
210
211#ifdef CONFIG_KEXEC
212 /* Called to shutdown machine specific hardware not already controlled
213 * by other drivers.
214 * XXX Should we move this one out of kexec scope?
215 */
216 void (*machine_shutdown)(void);
217
218 /* Called to do the minimal shutdown needed to run a kexec'd kernel
219 * to run successfully.
220 * XXX Should we move this one out of kexec scope?
221 */
222 void (*machine_crash_shutdown)(void);
223
224 /* Called to do what every setup is needed on image and the
225 * reboot code buffer. Returns 0 on success.
226 * Provide your own (maybe dummy) implementation if your platform
227 * claims to support kexec.
228 */
229 int (*machine_kexec_prepare)(struct kimage *image);
230
231 /* Called to handle any machine specific cleanup on image */
232 void (*machine_kexec_cleanup)(struct kimage *image);
233
234 /* Called to perform the _real_ kexec.
235 * Do NOT allocate memory or fail here. We are past the point of
236 * no return.
237 */
238 void (*machine_kexec)(struct kimage *image);
239#endif /* CONFIG_KEXEC */
240#endif /* CONFIG_PPC32 */
241};
242
243extern void default_idle(void);
244extern void native_idle(void);
245
246extern struct machdep_calls ppc_md;
247extern char cmd_line[COMMAND_LINE_SIZE];
248
249#ifdef CONFIG_PPC_PMAC
250/*
251 * Power macintoshes have either a CUDA, PMU or SMU controlling
252 * system reset, power, NVRAM, RTC.
253 */
254typedef enum sys_ctrler_kind {
255 SYS_CTRLER_UNKNOWN = 0,
256 SYS_CTRLER_CUDA = 1,
257 SYS_CTRLER_PMU = 2,
258 SYS_CTRLER_SMU = 3,
259} sys_ctrler_t;
260extern sys_ctrler_t sys_ctrler;
261
262#endif /* CONFIG_PPC_PMAC */
263
264extern void setup_pci_ptrs(void);
265
266#ifdef CONFIG_SMP
267/* Poor default implementations */
268extern void __devinit smp_generic_give_timebase(void);
269extern void __devinit smp_generic_take_timebase(void);
270#endif /* CONFIG_SMP */
271
272
273/* Functions to produce codes on the leds.
274 * The SRC code should be unique for the message category and should
275 * be limited to the lower 24 bits (the upper 8 are set by these funcs),
276 * and (for boot & dump) should be sorted numerically in the order
277 * the events occur.
278 */
279/* Print a boot progress message. */
280void ppc64_boot_msg(unsigned int src, const char *msg);
281/* Print a termination message (print only -- does not stop the kernel) */
282void ppc64_terminate_msg(unsigned int src, const char *msg);
283
284static inline void log_error(char *buf, unsigned int err_type, int fatal)
285{
286 if (ppc_md.log_error)
287 ppc_md.log_error(buf, err_type, fatal);
288}
289
290#endif /* __KERNEL__ */
291#endif /* _ASM_POWERPC_MACHDEP_H */
diff --git a/include/asm-powerpc/macio.h b/include/asm-powerpc/macio.h
new file mode 100644
index 000000000000..b553dd4b139e
--- /dev/null
+++ b/include/asm-powerpc/macio.h
@@ -0,0 +1,140 @@
1#ifndef __MACIO_ASIC_H__
2#define __MACIO_ASIC_H__
3
4#include <asm/of_device.h>
5
6extern struct bus_type macio_bus_type;
7
8/* MacIO device driver is defined later */
9struct macio_driver;
10struct macio_chip;
11
12#define MACIO_DEV_COUNT_RESOURCES 8
13#define MACIO_DEV_COUNT_IRQS 8
14
15/*
16 * the macio_bus structure is used to describe a "virtual" bus
17 * within a MacIO ASIC. It's typically provided by a macio_pci_asic
18 * PCI device, but could be provided differently as well (nubus
19 * machines using a fake OF tree).
20 *
21 * The pdev field can be NULL on non-PCI machines
22 */
23struct macio_bus
24{
25 struct macio_chip *chip; /* macio_chip (private use) */
26 int index; /* macio chip index in system */
27#ifdef CONFIG_PCI
28 struct pci_dev *pdev; /* PCI device hosting this bus */
29#endif
30};
31
32/*
33 * the macio_dev structure is used to describe a device
34 * within an Apple MacIO ASIC.
35 */
36struct macio_dev
37{
38 struct macio_bus *bus; /* macio bus this device is on */
39 struct macio_dev *media_bay; /* Device is part of a media bay */
40 struct of_device ofdev;
41 int n_resources;
42 struct resource resource[MACIO_DEV_COUNT_RESOURCES];
43 int n_interrupts;
44 struct resource interrupt[MACIO_DEV_COUNT_IRQS];
45};
46#define to_macio_device(d) container_of(d, struct macio_dev, ofdev.dev)
47#define of_to_macio_device(d) container_of(d, struct macio_dev, ofdev)
48
49extern struct macio_dev *macio_dev_get(struct macio_dev *dev);
50extern void macio_dev_put(struct macio_dev *dev);
51
52/*
53 * Accessors to resources & interrupts and other device
54 * fields
55 */
56
57static inline int macio_resource_count(struct macio_dev *dev)
58{
59 return dev->n_resources;
60}
61
62static inline unsigned long macio_resource_start(struct macio_dev *dev, int resource_no)
63{
64 return dev->resource[resource_no].start;
65}
66
67static inline unsigned long macio_resource_end(struct macio_dev *dev, int resource_no)
68{
69 return dev->resource[resource_no].end;
70}
71
72static inline unsigned long macio_resource_len(struct macio_dev *dev, int resource_no)
73{
74 struct resource *res = &dev->resource[resource_no];
75 if (res->start == 0 || res->end == 0 || res->end < res->start)
76 return 0;
77 return res->end - res->start + 1;
78}
79
80extern int macio_request_resource(struct macio_dev *dev, int resource_no, const char *name);
81extern void macio_release_resource(struct macio_dev *dev, int resource_no);
82extern int macio_request_resources(struct macio_dev *dev, const char *name);
83extern void macio_release_resources(struct macio_dev *dev);
84
85static inline int macio_irq_count(struct macio_dev *dev)
86{
87 return dev->n_interrupts;
88}
89
90static inline int macio_irq(struct macio_dev *dev, int irq_no)
91{
92 return dev->interrupt[irq_no].start;
93}
94
95static inline void macio_set_drvdata(struct macio_dev *dev, void *data)
96{
97 dev_set_drvdata(&dev->ofdev.dev, data);
98}
99
100static inline void* macio_get_drvdata(struct macio_dev *dev)
101{
102 return dev_get_drvdata(&dev->ofdev.dev);
103}
104
105static inline struct device_node *macio_get_of_node(struct macio_dev *mdev)
106{
107 return mdev->ofdev.node;
108}
109
110#ifdef CONFIG_PCI
111static inline struct pci_dev *macio_get_pci_dev(struct macio_dev *mdev)
112{
113 return mdev->bus->pdev;
114}
115#endif
116
117/*
118 * A driver for a mac-io chip based device
119 */
120struct macio_driver
121{
122 char *name;
123 struct of_device_id *match_table;
124 struct module *owner;
125
126 int (*probe)(struct macio_dev* dev, const struct of_device_id *match);
127 int (*remove)(struct macio_dev* dev);
128
129 int (*suspend)(struct macio_dev* dev, pm_message_t state);
130 int (*resume)(struct macio_dev* dev);
131 int (*shutdown)(struct macio_dev* dev);
132
133 struct device_driver driver;
134};
135#define to_macio_driver(drv) container_of(drv,struct macio_driver, driver)
136
137extern int macio_register_driver(struct macio_driver *);
138extern void macio_unregister_driver(struct macio_driver *);
139
140#endif /* __MACIO_ASIC_H__ */
diff --git a/include/asm-powerpc/mediabay.h b/include/asm-powerpc/mediabay.h
new file mode 100644
index 000000000000..9daa3252d7b6
--- /dev/null
+++ b/include/asm-powerpc/mediabay.h
@@ -0,0 +1,31 @@
1/*
2 * mediabay.h: definitions for using the media bay
3 * on PowerBook 3400 and similar computers.
4 *
5 * Copyright (C) 1997 Paul Mackerras.
6 */
7#ifndef _PPC_MEDIABAY_H
8#define _PPC_MEDIABAY_H
9
10#ifdef __KERNEL__
11
12#define MB_FD 0 /* media bay contains floppy drive (automatic eject ?) */
13#define MB_FD1 1 /* media bay contains floppy drive (manual eject ?) */
14#define MB_SOUND 2 /* sound device ? */
15#define MB_CD 3 /* media bay contains ATA drive such as CD or ZIP */
16#define MB_PCI 5 /* media bay contains a PCI device */
17#define MB_POWER 6 /* media bay contains a Power device (???) */
18#define MB_NO 7 /* media bay contains nothing */
19
20int check_media_bay(struct device_node *which_bay, int what);
21int check_media_bay_by_base(unsigned long base, int what);
22
23/* Number of bays in the machine or 0 */
24extern int media_bay_count;
25
26/* called by pmac-ide.c to register IDE controller for media bay */
27extern int media_bay_set_ide_infos(struct device_node* which_bay,
28 unsigned long base, int irq, int index);
29
30#endif /* __KERNEL__ */
31#endif /* _PPC_MEDIABAY_H */
diff --git a/include/asm-powerpc/mmu.h b/include/asm-powerpc/mmu.h
new file mode 100644
index 000000000000..c1b4bbabbe97
--- /dev/null
+++ b/include/asm-powerpc/mmu.h
@@ -0,0 +1,399 @@
1#ifndef _ASM_POWERPC_MMU_H_
2#define _ASM_POWERPC_MMU_H_
3
4#ifndef CONFIG_PPC64
5#include <asm-ppc/mmu.h>
6#else
7
8/*
9 * PowerPC memory management structures
10 *
11 * Dave Engebretsen & Mike Corrigan <{engebret|mikejc}@us.ibm.com>
12 * PPC64 rework.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19
20#include <asm/asm-compat.h>
21#include <asm/page.h>
22
23/*
24 * Segment table
25 */
26
27#define STE_ESID_V 0x80
28#define STE_ESID_KS 0x20
29#define STE_ESID_KP 0x10
30#define STE_ESID_N 0x08
31
32#define STE_VSID_SHIFT 12
33
34/* Location of cpu0's segment table */
35#define STAB0_PAGE 0x6
36#define STAB0_PHYS_ADDR (STAB0_PAGE<<12)
37
38#ifndef __ASSEMBLY__
39extern char initial_stab[];
40#endif /* ! __ASSEMBLY */
41
42/*
43 * SLB
44 */
45
46#define SLB_NUM_BOLTED 3
47#define SLB_CACHE_ENTRIES 8
48
49/* Bits in the SLB ESID word */
50#define SLB_ESID_V ASM_CONST(0x0000000008000000) /* valid */
51
52/* Bits in the SLB VSID word */
53#define SLB_VSID_SHIFT 12
54#define SLB_VSID_B ASM_CONST(0xc000000000000000)
55#define SLB_VSID_B_256M ASM_CONST(0x0000000000000000)
56#define SLB_VSID_B_1T ASM_CONST(0x4000000000000000)
57#define SLB_VSID_KS ASM_CONST(0x0000000000000800)
58#define SLB_VSID_KP ASM_CONST(0x0000000000000400)
59#define SLB_VSID_N ASM_CONST(0x0000000000000200) /* no-execute */
60#define SLB_VSID_L ASM_CONST(0x0000000000000100)
61#define SLB_VSID_C ASM_CONST(0x0000000000000080) /* class */
62#define SLB_VSID_LP ASM_CONST(0x0000000000000030)
63#define SLB_VSID_LP_00 ASM_CONST(0x0000000000000000)
64#define SLB_VSID_LP_01 ASM_CONST(0x0000000000000010)
65#define SLB_VSID_LP_10 ASM_CONST(0x0000000000000020)
66#define SLB_VSID_LP_11 ASM_CONST(0x0000000000000030)
67#define SLB_VSID_LLP (SLB_VSID_L|SLB_VSID_LP)
68
69#define SLB_VSID_KERNEL (SLB_VSID_KP)
70#define SLB_VSID_USER (SLB_VSID_KP|SLB_VSID_KS|SLB_VSID_C)
71
72#define SLBIE_C (0x08000000)
73
74/*
75 * Hash table
76 */
77
78#define HPTES_PER_GROUP 8
79
80#define HPTE_V_AVPN_SHIFT 7
81#define HPTE_V_AVPN ASM_CONST(0xffffffffffffff80)
82#define HPTE_V_AVPN_VAL(x) (((x) & HPTE_V_AVPN) >> HPTE_V_AVPN_SHIFT)
83#define HPTE_V_COMPARE(x,y) (!(((x) ^ (y)) & HPTE_V_AVPN))
84#define HPTE_V_BOLTED ASM_CONST(0x0000000000000010)
85#define HPTE_V_LOCK ASM_CONST(0x0000000000000008)
86#define HPTE_V_LARGE ASM_CONST(0x0000000000000004)
87#define HPTE_V_SECONDARY ASM_CONST(0x0000000000000002)
88#define HPTE_V_VALID ASM_CONST(0x0000000000000001)
89
90#define HPTE_R_PP0 ASM_CONST(0x8000000000000000)
91#define HPTE_R_TS ASM_CONST(0x4000000000000000)
92#define HPTE_R_RPN_SHIFT 12
93#define HPTE_R_RPN ASM_CONST(0x3ffffffffffff000)
94#define HPTE_R_FLAGS ASM_CONST(0x00000000000003ff)
95#define HPTE_R_PP ASM_CONST(0x0000000000000003)
96#define HPTE_R_N ASM_CONST(0x0000000000000004)
97
98/* Values for PP (assumes Ks=0, Kp=1) */
99/* pp0 will always be 0 for linux */
100#define PP_RWXX 0 /* Supervisor read/write, User none */
101#define PP_RWRX 1 /* Supervisor read/write, User read */
102#define PP_RWRW 2 /* Supervisor read/write, User read/write */
103#define PP_RXRX 3 /* Supervisor read, User read */
104
105#ifndef __ASSEMBLY__
106
107typedef struct {
108 unsigned long v;
109 unsigned long r;
110} hpte_t;
111
112extern hpte_t *htab_address;
113extern unsigned long htab_hash_mask;
114
115/*
116 * Page size definition
117 *
118 * shift : is the "PAGE_SHIFT" value for that page size
119 * sllp : is a bit mask with the value of SLB L || LP to be or'ed
120 * directly to a slbmte "vsid" value
121 * penc : is the HPTE encoding mask for the "LP" field:
122 *
123 */
124struct mmu_psize_def
125{
126 unsigned int shift; /* number of bits */
127 unsigned int penc; /* HPTE encoding */
128 unsigned int tlbiel; /* tlbiel supported for that page size */
129 unsigned long avpnm; /* bits to mask out in AVPN in the HPTE */
130 unsigned long sllp; /* SLB L||LP (exact mask to use in slbmte) */
131};
132
133#endif /* __ASSEMBLY__ */
134
135/*
136 * The kernel use the constants below to index in the page sizes array.
137 * The use of fixed constants for this purpose is better for performances
138 * of the low level hash refill handlers.
139 *
140 * A non supported page size has a "shift" field set to 0
141 *
142 * Any new page size being implemented can get a new entry in here. Whether
143 * the kernel will use it or not is a different matter though. The actual page
144 * size used by hugetlbfs is not defined here and may be made variable
145 */
146
147#define MMU_PAGE_4K 0 /* 4K */
148#define MMU_PAGE_64K 1 /* 64K */
149#define MMU_PAGE_64K_AP 2 /* 64K Admixed (in a 4K segment) */
150#define MMU_PAGE_1M 3 /* 1M */
151#define MMU_PAGE_16M 4 /* 16M */
152#define MMU_PAGE_16G 5 /* 16G */
153#define MMU_PAGE_COUNT 6
154
155#ifndef __ASSEMBLY__
156
157/*
158 * The current system page sizes
159 */
160extern struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT];
161extern int mmu_linear_psize;
162extern int mmu_virtual_psize;
163
164#ifdef CONFIG_HUGETLB_PAGE
165/*
166 * The page size index of the huge pages for use by hugetlbfs
167 */
168extern int mmu_huge_psize;
169
170#endif /* CONFIG_HUGETLB_PAGE */
171
172/*
173 * This function sets the AVPN and L fields of the HPTE appropriately
174 * for the page size
175 */
176static inline unsigned long hpte_encode_v(unsigned long va, int psize)
177{
178 unsigned long v =
179 v = (va >> 23) & ~(mmu_psize_defs[psize].avpnm);
180 v <<= HPTE_V_AVPN_SHIFT;
181 if (psize != MMU_PAGE_4K)
182 v |= HPTE_V_LARGE;
183 return v;
184}
185
186/*
187 * This function sets the ARPN, and LP fields of the HPTE appropriately
188 * for the page size. We assume the pa is already "clean" that is properly
189 * aligned for the requested page size
190 */
191static inline unsigned long hpte_encode_r(unsigned long pa, int psize)
192{
193 unsigned long r;
194
195 /* A 4K page needs no special encoding */
196 if (psize == MMU_PAGE_4K)
197 return pa & HPTE_R_RPN;
198 else {
199 unsigned int penc = mmu_psize_defs[psize].penc;
200 unsigned int shift = mmu_psize_defs[psize].shift;
201 return (pa & ~((1ul << shift) - 1)) | (penc << 12);
202 }
203 return r;
204}
205
206/*
207 * This hashes a virtual address for a 256Mb segment only for now
208 */
209
210static inline unsigned long hpt_hash(unsigned long va, unsigned int shift)
211{
212 return ((va >> 28) & 0x7fffffffffUL) ^ ((va & 0x0fffffffUL) >> shift);
213}
214
215extern int __hash_page_4K(unsigned long ea, unsigned long access,
216 unsigned long vsid, pte_t *ptep, unsigned long trap,
217 unsigned int local);
218extern int __hash_page_64K(unsigned long ea, unsigned long access,
219 unsigned long vsid, pte_t *ptep, unsigned long trap,
220 unsigned int local);
221struct mm_struct;
222extern int hash_huge_page(struct mm_struct *mm, unsigned long access,
223 unsigned long ea, unsigned long vsid, int local);
224
225extern void htab_finish_init(void);
226extern int htab_bolt_mapping(unsigned long vstart, unsigned long vend,
227 unsigned long pstart, unsigned long mode,
228 int psize);
229
230extern void htab_initialize(void);
231extern void htab_initialize_secondary(void);
232extern void hpte_init_native(void);
233extern void hpte_init_lpar(void);
234extern void hpte_init_iSeries(void);
235extern void mm_init_ppc64(void);
236
237extern long pSeries_lpar_hpte_insert(unsigned long hpte_group,
238 unsigned long va, unsigned long prpn,
239 unsigned long rflags,
240 unsigned long vflags, int psize);
241
242extern long native_hpte_insert(unsigned long hpte_group,
243 unsigned long va, unsigned long prpn,
244 unsigned long rflags,
245 unsigned long vflags, int psize);
246
247extern long iSeries_hpte_insert(unsigned long hpte_group,
248 unsigned long va, unsigned long prpn,
249 unsigned long rflags,
250 unsigned long vflags, int psize);
251
252extern void stabs_alloc(void);
253extern void slb_initialize(void);
254extern void stab_initialize(unsigned long stab);
255
256#endif /* __ASSEMBLY__ */
257
258/*
259 * VSID allocation
260 *
261 * We first generate a 36-bit "proto-VSID". For kernel addresses this
262 * is equal to the ESID, for user addresses it is:
263 * (context << 15) | (esid & 0x7fff)
264 *
265 * The two forms are distinguishable because the top bit is 0 for user
266 * addresses, whereas the top two bits are 1 for kernel addresses.
267 * Proto-VSIDs with the top two bits equal to 0b10 are reserved for
268 * now.
269 *
270 * The proto-VSIDs are then scrambled into real VSIDs with the
271 * multiplicative hash:
272 *
273 * VSID = (proto-VSID * VSID_MULTIPLIER) % VSID_MODULUS
274 * where VSID_MULTIPLIER = 268435399 = 0xFFFFFC7
275 * VSID_MODULUS = 2^36-1 = 0xFFFFFFFFF
276 *
277 * This scramble is only well defined for proto-VSIDs below
278 * 0xFFFFFFFFF, so both proto-VSID and actual VSID 0xFFFFFFFFF are
279 * reserved. VSID_MULTIPLIER is prime, so in particular it is
280 * co-prime to VSID_MODULUS, making this a 1:1 scrambling function.
281 * Because the modulus is 2^n-1 we can compute it efficiently without
282 * a divide or extra multiply (see below).
283 *
284 * This scheme has several advantages over older methods:
285 *
286 * - We have VSIDs allocated for every kernel address
287 * (i.e. everything above 0xC000000000000000), except the very top
288 * segment, which simplifies several things.
289 *
290 * - We allow for 15 significant bits of ESID and 20 bits of
291 * context for user addresses. i.e. 8T (43 bits) of address space for
292 * up to 1M contexts (although the page table structure and context
293 * allocation will need changes to take advantage of this).
294 *
295 * - The scramble function gives robust scattering in the hash
296 * table (at least based on some initial results). The previous
297 * method was more susceptible to pathological cases giving excessive
298 * hash collisions.
299 */
300/*
301 * WARNING - If you change these you must make sure the asm
302 * implementations in slb_allocate (slb_low.S), do_stab_bolted
303 * (head.S) and ASM_VSID_SCRAMBLE (below) are changed accordingly.
304 *
305 * You'll also need to change the precomputed VSID values in head.S
306 * which are used by the iSeries firmware.
307 */
308
309#define VSID_MULTIPLIER ASM_CONST(200730139) /* 28-bit prime */
310#define VSID_BITS 36
311#define VSID_MODULUS ((1UL<<VSID_BITS)-1)
312
313#define CONTEXT_BITS 19
314#define USER_ESID_BITS 16
315
316#define USER_VSID_RANGE (1UL << (USER_ESID_BITS + SID_SHIFT))
317
318/*
319 * This macro generates asm code to compute the VSID scramble
320 * function. Used in slb_allocate() and do_stab_bolted. The function
321 * computed is: (protovsid*VSID_MULTIPLIER) % VSID_MODULUS
322 *
323 * rt = register continaing the proto-VSID and into which the
324 * VSID will be stored
325 * rx = scratch register (clobbered)
326 *
327 * - rt and rx must be different registers
328 * - The answer will end up in the low 36 bits of rt. The higher
329 * bits may contain other garbage, so you may need to mask the
330 * result.
331 */
332#define ASM_VSID_SCRAMBLE(rt, rx) \
333 lis rx,VSID_MULTIPLIER@h; \
334 ori rx,rx,VSID_MULTIPLIER@l; \
335 mulld rt,rt,rx; /* rt = rt * MULTIPLIER */ \
336 \
337 srdi rx,rt,VSID_BITS; \
338 clrldi rt,rt,(64-VSID_BITS); \
339 add rt,rt,rx; /* add high and low bits */ \
340 /* Now, r3 == VSID (mod 2^36-1), and lies between 0 and \
341 * 2^36-1+2^28-1. That in particular means that if r3 >= \
342 * 2^36-1, then r3+1 has the 2^36 bit set. So, if r3+1 has \
343 * the bit clear, r3 already has the answer we want, if it \
344 * doesn't, the answer is the low 36 bits of r3+1. So in all \
345 * cases the answer is the low 36 bits of (r3 + ((r3+1) >> 36))*/\
346 addi rx,rt,1; \
347 srdi rx,rx,VSID_BITS; /* extract 2^36 bit */ \
348 add rt,rt,rx
349
350
351#ifndef __ASSEMBLY__
352
353typedef unsigned long mm_context_id_t;
354
355typedef struct {
356 mm_context_id_t id;
357#ifdef CONFIG_HUGETLB_PAGE
358 u16 low_htlb_areas, high_htlb_areas;
359#endif
360} mm_context_t;
361
362
363static inline unsigned long vsid_scramble(unsigned long protovsid)
364{
365#if 0
366 /* The code below is equivalent to this function for arguments
367 * < 2^VSID_BITS, which is all this should ever be called
368 * with. However gcc is not clever enough to compute the
369 * modulus (2^n-1) without a second multiply. */
370 return ((protovsid * VSID_MULTIPLIER) % VSID_MODULUS);
371#else /* 1 */
372 unsigned long x;
373
374 x = protovsid * VSID_MULTIPLIER;
375 x = (x >> VSID_BITS) + (x & VSID_MODULUS);
376 return (x + ((x+1) >> VSID_BITS)) & VSID_MODULUS;
377#endif /* 1 */
378}
379
380/* This is only valid for addresses >= KERNELBASE */
381static inline unsigned long get_kernel_vsid(unsigned long ea)
382{
383 return vsid_scramble(ea >> SID_SHIFT);
384}
385
386/* This is only valid for user addresses (which are below 2^41) */
387static inline unsigned long get_vsid(unsigned long context, unsigned long ea)
388{
389 return vsid_scramble((context << USER_ESID_BITS)
390 | (ea >> SID_SHIFT));
391}
392
393#define VSID_SCRAMBLE(pvsid) (((pvsid) * VSID_MULTIPLIER) % VSID_MODULUS)
394#define KERNEL_VSID(ea) VSID_SCRAMBLE(GET_ESID(ea))
395
396#endif /* __ASSEMBLY */
397
398#endif /* CONFIG_PPC64 */
399#endif /* _ASM_POWERPC_MMU_H_ */
diff --git a/include/asm-powerpc/mmu_context.h b/include/asm-powerpc/mmu_context.h
new file mode 100644
index 000000000000..ea6798c7d5fc
--- /dev/null
+++ b/include/asm-powerpc/mmu_context.h
@@ -0,0 +1,89 @@
1#ifndef __ASM_POWERPC_MMU_CONTEXT_H
2#define __ASM_POWERPC_MMU_CONTEXT_H
3
4#ifndef CONFIG_PPC64
5#include <asm-ppc/mmu_context.h>
6#else
7
8#include <linux/kernel.h>
9#include <linux/mm.h>
10#include <asm/mmu.h>
11#include <asm/cputable.h>
12
13/*
14 * Copyright (C) 2001 PPC 64 Team, IBM Corp
15 *
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License
18 * as published by the Free Software Foundation; either version
19 * 2 of the License, or (at your option) any later version.
20 */
21
22/*
23 * Getting into a kernel thread, there is no valid user segment, mark
24 * paca->pgdir NULL so that SLB miss on user addresses will fault
25 */
26static inline void enter_lazy_tlb(struct mm_struct *mm,
27 struct task_struct *tsk)
28{
29#ifdef CONFIG_PPC_64K_PAGES
30 get_paca()->pgdir = NULL;
31#endif /* CONFIG_PPC_64K_PAGES */
32}
33
34#define NO_CONTEXT 0
35#define MAX_CONTEXT (0x100000-1)
36
37extern int init_new_context(struct task_struct *tsk, struct mm_struct *mm);
38extern void destroy_context(struct mm_struct *mm);
39
40extern void switch_stab(struct task_struct *tsk, struct mm_struct *mm);
41extern void switch_slb(struct task_struct *tsk, struct mm_struct *mm);
42
43/*
44 * switch_mm is the entry point called from the architecture independent
45 * code in kernel/sched.c
46 */
47static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
48 struct task_struct *tsk)
49{
50 if (!cpu_isset(smp_processor_id(), next->cpu_vm_mask))
51 cpu_set(smp_processor_id(), next->cpu_vm_mask);
52
53 /* No need to flush userspace segments if the mm doesnt change */
54#ifdef CONFIG_PPC_64K_PAGES
55 if (prev == next && get_paca()->pgdir == next->pgd)
56 return;
57#else
58 if (prev == next)
59 return;
60#endif /* CONFIG_PPC_64K_PAGES */
61
62#ifdef CONFIG_ALTIVEC
63 if (cpu_has_feature(CPU_FTR_ALTIVEC))
64 asm volatile ("dssall");
65#endif /* CONFIG_ALTIVEC */
66
67 if (cpu_has_feature(CPU_FTR_SLB))
68 switch_slb(tsk, next);
69 else
70 switch_stab(tsk, next);
71}
72
73#define deactivate_mm(tsk,mm) do { } while (0)
74
75/*
76 * After we have set current->mm to a new value, this activates
77 * the context for the new mm so we see the new mappings.
78 */
79static inline void activate_mm(struct mm_struct *prev, struct mm_struct *next)
80{
81 unsigned long flags;
82
83 local_irq_save(flags);
84 switch_mm(prev, next, current);
85 local_irq_restore(flags);
86}
87
88#endif /* CONFIG_PPC64 */
89#endif /* __ASM_POWERPC_MMU_CONTEXT_H */
diff --git a/include/asm-powerpc/mmzone.h b/include/asm-powerpc/mmzone.h
new file mode 100644
index 000000000000..54958d6cae04
--- /dev/null
+++ b/include/asm-powerpc/mmzone.h
@@ -0,0 +1,50 @@
1/*
2 * Written by Kanoj Sarcar (kanoj@sgi.com) Aug 99
3 *
4 * PowerPC64 port:
5 * Copyright (C) 2002 Anton Blanchard, IBM Corp.
6 */
7#ifndef _ASM_MMZONE_H_
8#define _ASM_MMZONE_H_
9
10#include <linux/config.h>
11
12/*
13 * generic non-linear memory support:
14 *
15 * 1) we will not split memory into more chunks than will fit into the
16 * flags field of the struct page
17 */
18
19#ifdef CONFIG_NEED_MULTIPLE_NODES
20
21extern struct pglist_data *node_data[];
22/*
23 * Return a pointer to the node data for node n.
24 */
25#define NODE_DATA(nid) (node_data[nid])
26
27/*
28 * Following are specific to this numa platform.
29 */
30
31extern int numa_cpu_lookup_table[];
32extern cpumask_t numa_cpumask_lookup_table[];
33#ifdef CONFIG_MEMORY_HOTPLUG
34extern unsigned long max_pfn;
35#endif
36
37/*
38 * Following are macros that each numa implmentation must define.
39 */
40
41#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
42#define node_end_pfn(nid) (NODE_DATA(nid)->node_end_pfn)
43
44#endif /* CONFIG_NEED_MULTIPLE_NODES */
45
46#ifdef CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID
47extern int __init early_pfn_to_nid(unsigned long pfn);
48#endif
49
50#endif /* _ASM_MMZONE_H_ */
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
new file mode 100644
index 000000000000..7083d1f74260
--- /dev/null
+++ b/include/asm-powerpc/mpic.h
@@ -0,0 +1,287 @@
1#ifndef _ASM_POWERPC_MPIC_H
2#define _ASM_POWERPC_MPIC_H
3
4#include <linux/irq.h>
5
6/*
7 * Global registers
8 */
9
10#define MPIC_GREG_BASE 0x01000
11
12#define MPIC_GREG_FEATURE_0 0x00000
13#define MPIC_GREG_FEATURE_LAST_SRC_MASK 0x07ff0000
14#define MPIC_GREG_FEATURE_LAST_SRC_SHIFT 16
15#define MPIC_GREG_FEATURE_LAST_CPU_MASK 0x00001f00
16#define MPIC_GREG_FEATURE_LAST_CPU_SHIFT 8
17#define MPIC_GREG_FEATURE_VERSION_MASK 0xff
18#define MPIC_GREG_FEATURE_1 0x00010
19#define MPIC_GREG_GLOBAL_CONF_0 0x00020
20#define MPIC_GREG_GCONF_RESET 0x80000000
21#define MPIC_GREG_GCONF_8259_PTHROU_DIS 0x20000000
22#define MPIC_GREG_GCONF_BASE_MASK 0x000fffff
23#define MPIC_GREG_GLOBAL_CONF_1 0x00030
24#define MPIC_GREG_VENDOR_0 0x00040
25#define MPIC_GREG_VENDOR_1 0x00050
26#define MPIC_GREG_VENDOR_2 0x00060
27#define MPIC_GREG_VENDOR_3 0x00070
28#define MPIC_GREG_VENDOR_ID 0x00080
29#define MPIC_GREG_VENDOR_ID_STEPPING_MASK 0x00ff0000
30#define MPIC_GREG_VENDOR_ID_STEPPING_SHIFT 16
31#define MPIC_GREG_VENDOR_ID_DEVICE_ID_MASK 0x0000ff00
32#define MPIC_GREG_VENDOR_ID_DEVICE_ID_SHIFT 8
33#define MPIC_GREG_VENDOR_ID_VENDOR_ID_MASK 0x000000ff
34#define MPIC_GREG_PROCESSOR_INIT 0x00090
35#define MPIC_GREG_IPI_VECTOR_PRI_0 0x000a0
36#define MPIC_GREG_IPI_VECTOR_PRI_1 0x000b0
37#define MPIC_GREG_IPI_VECTOR_PRI_2 0x000c0
38#define MPIC_GREG_IPI_VECTOR_PRI_3 0x000d0
39#define MPIC_GREG_SPURIOUS 0x000e0
40#define MPIC_GREG_TIMER_FREQ 0x000f0
41
42/*
43 *
44 * Timer registers
45 */
46#define MPIC_TIMER_BASE 0x01100
47#define MPIC_TIMER_STRIDE 0x40
48
49#define MPIC_TIMER_CURRENT_CNT 0x00000
50#define MPIC_TIMER_BASE_CNT 0x00010
51#define MPIC_TIMER_VECTOR_PRI 0x00020
52#define MPIC_TIMER_DESTINATION 0x00030
53
54/*
55 * Per-Processor registers
56 */
57
58#define MPIC_CPU_THISBASE 0x00000
59#define MPIC_CPU_BASE 0x20000
60#define MPIC_CPU_STRIDE 0x01000
61
62#define MPIC_CPU_IPI_DISPATCH_0 0x00040
63#define MPIC_CPU_IPI_DISPATCH_1 0x00050
64#define MPIC_CPU_IPI_DISPATCH_2 0x00060
65#define MPIC_CPU_IPI_DISPATCH_3 0x00070
66#define MPIC_CPU_CURRENT_TASK_PRI 0x00080
67#define MPIC_CPU_TASKPRI_MASK 0x0000000f
68#define MPIC_CPU_WHOAMI 0x00090
69#define MPIC_CPU_WHOAMI_MASK 0x0000001f
70#define MPIC_CPU_INTACK 0x000a0
71#define MPIC_CPU_EOI 0x000b0
72
73/*
74 * Per-source registers
75 */
76
77#define MPIC_IRQ_BASE 0x10000
78#define MPIC_IRQ_STRIDE 0x00020
79#define MPIC_IRQ_VECTOR_PRI 0x00000
80#define MPIC_VECPRI_MASK 0x80000000
81#define MPIC_VECPRI_ACTIVITY 0x40000000 /* Read Only */
82#define MPIC_VECPRI_PRIORITY_MASK 0x000f0000
83#define MPIC_VECPRI_PRIORITY_SHIFT 16
84#define MPIC_VECPRI_VECTOR_MASK 0x000007ff
85#define MPIC_VECPRI_POLARITY_POSITIVE 0x00800000
86#define MPIC_VECPRI_POLARITY_NEGATIVE 0x00000000
87#define MPIC_VECPRI_POLARITY_MASK 0x00800000
88#define MPIC_VECPRI_SENSE_LEVEL 0x00400000
89#define MPIC_VECPRI_SENSE_EDGE 0x00000000
90#define MPIC_VECPRI_SENSE_MASK 0x00400000
91#define MPIC_IRQ_DESTINATION 0x00010
92
93#define MPIC_MAX_IRQ_SOURCES 2048
94#define MPIC_MAX_CPUS 32
95#define MPIC_MAX_ISU 32
96
97/*
98 * Special vector numbers (internal use only)
99 */
100#define MPIC_VEC_SPURRIOUS 255
101#define MPIC_VEC_IPI_3 254
102#define MPIC_VEC_IPI_2 253
103#define MPIC_VEC_IPI_1 252
104#define MPIC_VEC_IPI_0 251
105
106/* unused */
107#define MPIC_VEC_TIMER_3 250
108#define MPIC_VEC_TIMER_2 249
109#define MPIC_VEC_TIMER_1 248
110#define MPIC_VEC_TIMER_0 247
111
112/* Type definition of the cascade handler */
113typedef int (*mpic_cascade_t)(struct pt_regs *regs, void *data);
114
115#ifdef CONFIG_MPIC_BROKEN_U3
116/* Fixup table entry */
117struct mpic_irq_fixup
118{
119 u8 __iomem *base;
120 unsigned int irq;
121};
122#endif /* CONFIG_MPIC_BROKEN_U3 */
123
124
125/* The instance data of a given MPIC */
126struct mpic
127{
128 /* The "linux" controller struct */
129 hw_irq_controller hc_irq;
130#ifdef CONFIG_SMP
131 hw_irq_controller hc_ipi;
132#endif
133 const char *name;
134 /* Flags */
135 unsigned int flags;
136 /* How many irq sources in a given ISU */
137 unsigned int isu_size;
138 unsigned int isu_shift;
139 unsigned int isu_mask;
140 /* Offset of irq vector numbers */
141 unsigned int irq_offset;
142 unsigned int irq_count;
143 /* Offset of ipi vector numbers */
144 unsigned int ipi_offset;
145 /* Number of sources */
146 unsigned int num_sources;
147 /* Number of CPUs */
148 unsigned int num_cpus;
149 /* cascade handler */
150 mpic_cascade_t cascade;
151 void *cascade_data;
152 unsigned int cascade_vec;
153 /* senses array */
154 unsigned char *senses;
155 unsigned int senses_count;
156
157#ifdef CONFIG_MPIC_BROKEN_U3
158 /* The fixup table */
159 struct mpic_irq_fixup *fixups;
160 spinlock_t fixup_lock;
161#endif
162
163 /* The various ioremap'ed bases */
164 volatile u32 __iomem *gregs;
165 volatile u32 __iomem *tmregs;
166 volatile u32 __iomem *cpuregs[MPIC_MAX_CPUS];
167 volatile u32 __iomem *isus[MPIC_MAX_ISU];
168
169 /* link */
170 struct mpic *next;
171};
172
173/* This is the primary controller, only that one has IPIs and
174 * has afinity control. A non-primary MPIC always uses CPU0
175 * registers only
176 */
177#define MPIC_PRIMARY 0x00000001
178/* Set this for a big-endian MPIC */
179#define MPIC_BIG_ENDIAN 0x00000002
180/* Broken U3 MPIC */
181#define MPIC_BROKEN_U3 0x00000004
182/* Broken IPI registers (autodetected) */
183#define MPIC_BROKEN_IPI 0x00000008
184/* MPIC wants a reset */
185#define MPIC_WANTS_RESET 0x00000010
186
187/* Allocate the controller structure and setup the linux irq descs
188 * for the range if interrupts passed in. No HW initialization is
189 * actually performed.
190 *
191 * @phys_addr: physial base address of the MPIC
192 * @flags: flags, see constants above
193 * @isu_size: number of interrupts in an ISU. Use 0 to use a
194 * standard ISU-less setup (aka powermac)
195 * @irq_offset: first irq number to assign to this mpic
196 * @irq_count: number of irqs to use with this mpic IRQ sources. Pass 0
197 * to match the number of sources
198 * @ipi_offset: first irq number to assign to this mpic IPI sources,
199 * used only on primary mpic
200 * @senses: array of sense values
201 * @senses_num: number of entries in the array
202 *
203 * Note about the sense array. If none is passed, all interrupts are
204 * setup to be level negative unless MPIC_BROKEN_U3 is set in which
205 * case they are edge positive (and the array is ignored anyway).
206 * The values in the array start at the first source of the MPIC,
207 * that is senses[0] correspond to linux irq "irq_offset".
208 */
209extern struct mpic *mpic_alloc(unsigned long phys_addr,
210 unsigned int flags,
211 unsigned int isu_size,
212 unsigned int irq_offset,
213 unsigned int irq_count,
214 unsigned int ipi_offset,
215 unsigned char *senses,
216 unsigned int senses_num,
217 const char *name);
218
219/* Assign ISUs, to call before mpic_init()
220 *
221 * @mpic: controller structure as returned by mpic_alloc()
222 * @isu_num: ISU number
223 * @phys_addr: physical address of the ISU
224 */
225extern void mpic_assign_isu(struct mpic *mpic, unsigned int isu_num,
226 unsigned long phys_addr);
227
228/* Initialize the controller. After this has been called, none of the above
229 * should be called again for this mpic
230 */
231extern void mpic_init(struct mpic *mpic);
232
233/* Setup a cascade. Currently, only one cascade is supported this
234 * way, though you can always do a normal request_irq() and add
235 * other cascades this way. You should call this _after_ having
236 * added all the ISUs
237 *
238 * @irq_no: "linux" irq number of the cascade (that is offset'ed vector)
239 * @handler: cascade handler function
240 */
241extern void mpic_setup_cascade(unsigned int irq_no, mpic_cascade_t hanlder,
242 void *data);
243
244/*
245 * All of the following functions must only be used after the
246 * ISUs have been assigned and the controller fully initialized
247 * with mpic_init()
248 */
249
250
251/* Change/Read the priority of an interrupt. Default is 8 for irqs and
252 * 10 for IPIs. You can call this on both IPIs and IRQ numbers, but the
253 * IPI number is then the offset'ed (linux irq number mapped to the IPI)
254 */
255extern void mpic_irq_set_priority(unsigned int irq, unsigned int pri);
256extern unsigned int mpic_irq_get_priority(unsigned int irq);
257
258/* Setup a non-boot CPU */
259extern void mpic_setup_this_cpu(void);
260
261/* Clean up for kexec (or cpu offline or ...) */
262extern void mpic_teardown_this_cpu(int secondary);
263
264/* Get the current cpu priority for this cpu (0..15) */
265extern int mpic_cpu_get_priority(void);
266
267/* Set the current cpu priority for this cpu */
268extern void mpic_cpu_set_priority(int prio);
269
270/* Request IPIs on primary mpic */
271extern void mpic_request_ipis(void);
272
273/* Send an IPI (non offseted number 0..3) */
274extern void mpic_send_ipi(unsigned int ipi_no, unsigned int cpu_mask);
275
276/* Send a message (IPI) to a given target (cpu number or MSG_*) */
277void smp_mpic_message_pass(int target, int msg);
278
279/* Fetch interrupt from a given mpic */
280extern int mpic_get_one_irq(struct mpic *mpic, struct pt_regs *regs);
281/* This one gets to the primary mpic */
282extern int mpic_get_irq(struct pt_regs *regs);
283
284/* global mpic for pSeries */
285extern struct mpic *pSeries_mpic;
286
287#endif /* _ASM_POWERPC_MPIC_H */
diff --git a/include/asm-powerpc/numnodes.h b/include/asm-powerpc/numnodes.h
new file mode 100644
index 000000000000..795533aca095
--- /dev/null
+++ b/include/asm-powerpc/numnodes.h
@@ -0,0 +1,7 @@
1#ifndef _ASM_POWERPC_MAX_NUMNODES_H
2#define _ASM_POWERPC_MAX_NUMNODES_H
3
4/* Max 16 Nodes */
5#define NODES_SHIFT 4
6
7#endif /* _ASM_POWERPC_MAX_NUMNODES_H */
diff --git a/include/asm-powerpc/nvram.h b/include/asm-powerpc/nvram.h
new file mode 100644
index 000000000000..24bd8c2388ea
--- /dev/null
+++ b/include/asm-powerpc/nvram.h
@@ -0,0 +1,119 @@
1/*
2 * NVRAM definitions and access functions.
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_NVRAM_H
11#define _ASM_POWERPC_NVRAM_H
12
13#define NVRW_CNT 0x20
14#define NVRAM_HEADER_LEN 16 /* sizeof(struct nvram_header) */
15#define NVRAM_BLOCK_LEN 16
16#define NVRAM_MAX_REQ (2080/NVRAM_BLOCK_LEN)
17#define NVRAM_MIN_REQ (1056/NVRAM_BLOCK_LEN)
18
19#define NVRAM_AS0 0x74
20#define NVRAM_AS1 0x75
21#define NVRAM_DATA 0x77
22
23
24/* RTC Offsets */
25
26#define MOTO_RTC_SECONDS 0x1FF9
27#define MOTO_RTC_MINUTES 0x1FFA
28#define MOTO_RTC_HOURS 0x1FFB
29#define MOTO_RTC_DAY_OF_WEEK 0x1FFC
30#define MOTO_RTC_DAY_OF_MONTH 0x1FFD
31#define MOTO_RTC_MONTH 0x1FFE
32#define MOTO_RTC_YEAR 0x1FFF
33#define MOTO_RTC_CONTROLA 0x1FF8
34#define MOTO_RTC_CONTROLB 0x1FF9
35
36#define NVRAM_SIG_SP 0x02 /* support processor */
37#define NVRAM_SIG_OF 0x50 /* open firmware config */
38#define NVRAM_SIG_FW 0x51 /* general firmware */
39#define NVRAM_SIG_HW 0x52 /* hardware (VPD) */
40#define NVRAM_SIG_FLIP 0x5a /* Apple flip/flop header */
41#define NVRAM_SIG_APPL 0x5f /* Apple "system" (???) */
42#define NVRAM_SIG_SYS 0x70 /* system env vars */
43#define NVRAM_SIG_CFG 0x71 /* config data */
44#define NVRAM_SIG_ELOG 0x72 /* error log */
45#define NVRAM_SIG_VEND 0x7e /* vendor defined */
46#define NVRAM_SIG_FREE 0x7f /* Free space */
47#define NVRAM_SIG_OS 0xa0 /* OS defined */
48#define NVRAM_SIG_PANIC 0xa1 /* Apple OSX "panic" */
49
50/* If change this size, then change the size of NVNAME_LEN */
51struct nvram_header {
52 unsigned char signature;
53 unsigned char checksum;
54 unsigned short length;
55 char name[12];
56};
57
58struct nvram_partition {
59 struct list_head partition;
60 struct nvram_header header;
61 unsigned int index;
62};
63
64
65extern int nvram_write_error_log(char * buff, int length, unsigned int err_type);
66extern int nvram_read_error_log(char * buff, int length, unsigned int * err_type);
67extern int nvram_clear_error_log(void);
68extern struct nvram_partition *nvram_find_partition(int sig, const char *name);
69
70extern int pSeries_nvram_init(void);
71extern int mmio_nvram_init(void);
72
73/* PowerMac specific nvram stuffs */
74
75enum {
76 pmac_nvram_OF, /* Open Firmware partition */
77 pmac_nvram_XPRAM, /* MacOS XPRAM partition */
78 pmac_nvram_NR /* MacOS Name Registry partition */
79};
80
81/* Return partition offset in nvram */
82extern int pmac_get_partition(int partition);
83
84/* Direct access to XPRAM on PowerMacs */
85extern u8 pmac_xpram_read(int xpaddr);
86extern void pmac_xpram_write(int xpaddr, u8 data);
87
88/* Synchronize NVRAM */
89extern void nvram_sync(void);
90
91/* Normal access to NVRAM */
92extern unsigned char nvram_read_byte(int i);
93extern void nvram_write_byte(unsigned char c, int i);
94
95/* Some offsets in XPRAM */
96#define PMAC_XPRAM_MACHINE_LOC 0xe4
97#define PMAC_XPRAM_SOUND_VOLUME 0x08
98
99/* Machine location structure in PowerMac XPRAM */
100struct pmac_machine_location {
101 unsigned int latitude; /* 2+30 bit Fractional number */
102 unsigned int longitude; /* 2+30 bit Fractional number */
103 unsigned int delta; /* mix of GMT delta and DLS */
104};
105
106/*
107 * /dev/nvram ioctls
108 *
109 * Note that PMAC_NVRAM_GET_OFFSET is still supported, but is
110 * definitely obsolete. Do not use it if you can avoid it
111 */
112
113#define OBSOLETE_PMAC_NVRAM_GET_OFFSET \
114 _IOWR('p', 0x40, int)
115
116#define IOC_NVRAM_GET_OFFSET _IOWR('p', 0x42, int) /* Get NVRAM partition offset */
117#define IOC_NVRAM_SYNC _IO('p', 0x43) /* Sync NVRAM image */
118
119#endif /* _ASM_POWERPC_NVRAM_H */
diff --git a/include/asm-powerpc/of_device.h b/include/asm-powerpc/of_device.h
new file mode 100644
index 000000000000..ddb16aae0bd6
--- /dev/null
+++ b/include/asm-powerpc/of_device.h
@@ -0,0 +1,64 @@
1#ifndef _ASM_POWERPC_OF_DEVICE_H
2#define _ASM_POWERPC_OF_DEVICE_H
3
4#include <linux/device.h>
5#include <linux/mod_devicetable.h>
6#include <asm/prom.h>
7
8/*
9 * The of_platform_bus_type is a bus type used by drivers that do not
10 * attach to a macio or similar bus but still use OF probing
11 * mecanism
12 */
13extern struct bus_type of_platform_bus_type;
14
15/*
16 * The of_device is a kind of "base class" that is a superset of
17 * struct device for use by devices attached to an OF node and
18 * probed using OF properties
19 */
20struct of_device
21{
22 struct device_node *node; /* OF device node */
23 u64 dma_mask; /* DMA mask */
24 struct device dev; /* Generic device interface */
25};
26#define to_of_device(d) container_of(d, struct of_device, dev)
27
28extern const struct of_device_id *of_match_device(
29 const struct of_device_id *matches, const struct of_device *dev);
30
31extern struct of_device *of_dev_get(struct of_device *dev);
32extern void of_dev_put(struct of_device *dev);
33
34/*
35 * An of_platform_driver driver is attached to a basic of_device on
36 * the "platform bus" (of_platform_bus_type)
37 */
38struct of_platform_driver
39{
40 char *name;
41 struct of_device_id *match_table;
42 struct module *owner;
43
44 int (*probe)(struct of_device* dev, const struct of_device_id *match);
45 int (*remove)(struct of_device* dev);
46
47 int (*suspend)(struct of_device* dev, pm_message_t state);
48 int (*resume)(struct of_device* dev);
49 int (*shutdown)(struct of_device* dev);
50
51 struct device_driver driver;
52};
53#define to_of_platform_driver(drv) container_of(drv,struct of_platform_driver, driver)
54
55extern int of_register_driver(struct of_platform_driver *drv);
56extern void of_unregister_driver(struct of_platform_driver *drv);
57extern int of_device_register(struct of_device *ofdev);
58extern void of_device_unregister(struct of_device *ofdev);
59extern struct of_device *of_platform_device_create(struct device_node *np,
60 const char *bus_id,
61 struct device *parent);
62extern void of_release_dev(struct device *dev);
63
64#endif /* _ASM_POWERPC_OF_DEVICE_H */
diff --git a/include/asm-powerpc/ohare.h b/include/asm-powerpc/ohare.h
new file mode 100644
index 000000000000..023b59772231
--- /dev/null
+++ b/include/asm-powerpc/ohare.h
@@ -0,0 +1,48 @@
1/*
2 * ohare.h: definitions for using the "O'Hare" I/O controller chip.
3 *
4 * Copyright (C) 1997 Paul Mackerras.
5 *
6 * BenH: Changed to match those of heathrow (but not all of them). Please
7 * check if I didn't break anything (especially the media bay).
8 */
9
10/* offset from ohare base for feature control register */
11#define OHARE_MBCR 0x34
12#define OHARE_FCR 0x38
13
14/*
15 * Bits in feature control register.
16 * These were mostly derived by experiment on a powerbook 3400
17 * and may differ for other machines.
18 */
19#define OH_SCC_RESET 1
20#define OH_BAY_POWER_N 2 /* a guess */
21#define OH_BAY_PCI_ENABLE 4 /* a guess */
22#define OH_BAY_IDE_ENABLE 8
23#define OH_BAY_FLOPPY_ENABLE 0x10
24#define OH_IDE0_ENABLE 0x20
25#define OH_IDE0_RESET_N 0x40 /* a guess */
26#define OH_BAY_DEV_MASK 0x1c
27#define OH_BAY_RESET_N 0x80
28#define OH_IOBUS_ENABLE 0x100 /* IOBUS seems to be IDE */
29#define OH_SCC_ENABLE 0x200
30#define OH_MESH_ENABLE 0x400
31#define OH_FLOPPY_ENABLE 0x800
32#define OH_SCCA_IO 0x4000
33#define OH_SCCB_IO 0x8000
34#define OH_VIA_ENABLE 0x10000 /* Is apparently wrong, to be verified */
35#define OH_IDE1_RESET_N 0x800000
36
37/*
38 * Bits to set in the feature control register on PowerBooks.
39 */
40#define PBOOK_FEATURES (OH_IDE_ENABLE | OH_SCC_ENABLE | \
41 OH_MESH_ENABLE | OH_SCCA_IO | OH_SCCB_IO)
42
43/*
44 * A magic value to put into the feature control register of the
45 * "ohare" I/O controller on Starmaxes to enable the IDE CD interface.
46 * Contributed by Harry Eaton.
47 */
48#define STARMAX_FEATURES 0xbeff7a
diff --git a/include/asm-powerpc/oprofile_impl.h b/include/asm-powerpc/oprofile_impl.h
new file mode 100644
index 000000000000..8013cd273ced
--- /dev/null
+++ b/include/asm-powerpc/oprofile_impl.h
@@ -0,0 +1,123 @@
1/*
2 * Copyright (C) 2004 Anton Blanchard <anton@au.ibm.com>, IBM
3 *
4 * Based on alpha version.
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_OPROFILE_IMPL_H
13#define _ASM_POWERPC_OPROFILE_IMPL_H
14
15#define OP_MAX_COUNTER 8
16
17/* Per-counter configuration as set via oprofilefs. */
18struct op_counter_config {
19#ifdef __powerpc64__
20 unsigned long valid;
21#endif
22 unsigned long enabled;
23 unsigned long event;
24 unsigned long count;
25 unsigned long kernel;
26#ifdef __powerpc64__
27 /* We dont support per counter user/kernel selection */
28#endif
29 unsigned long user;
30 unsigned long unit_mask;
31};
32
33/* System-wide configuration as set via oprofilefs. */
34struct op_system_config {
35#ifdef __powerpc64__
36 unsigned long mmcr0;
37 unsigned long mmcr1;
38 unsigned long mmcra;
39#endif
40 unsigned long enable_kernel;
41 unsigned long enable_user;
42#ifdef __powerpc64__
43 unsigned long backtrace_spinlocks;
44#endif
45};
46
47/* Per-arch configuration */
48struct op_powerpc_model {
49 void (*reg_setup) (struct op_counter_config *,
50 struct op_system_config *,
51 int num_counters);
52#ifdef __powerpc64__
53 void (*cpu_setup) (void *);
54#endif
55 void (*start) (struct op_counter_config *);
56 void (*stop) (void);
57 void (*handle_interrupt) (struct pt_regs *,
58 struct op_counter_config *);
59 int num_counters;
60};
61
62#ifdef __powerpc64__
63extern struct op_powerpc_model op_model_rs64;
64extern struct op_powerpc_model op_model_power4;
65
66static inline unsigned int ctr_read(unsigned int i)
67{
68 switch(i) {
69 case 0:
70 return mfspr(SPRN_PMC1);
71 case 1:
72 return mfspr(SPRN_PMC2);
73 case 2:
74 return mfspr(SPRN_PMC3);
75 case 3:
76 return mfspr(SPRN_PMC4);
77 case 4:
78 return mfspr(SPRN_PMC5);
79 case 5:
80 return mfspr(SPRN_PMC6);
81 case 6:
82 return mfspr(SPRN_PMC7);
83 case 7:
84 return mfspr(SPRN_PMC8);
85 default:
86 return 0;
87 }
88}
89
90static inline void ctr_write(unsigned int i, unsigned int val)
91{
92 switch(i) {
93 case 0:
94 mtspr(SPRN_PMC1, val);
95 break;
96 case 1:
97 mtspr(SPRN_PMC2, val);
98 break;
99 case 2:
100 mtspr(SPRN_PMC3, val);
101 break;
102 case 3:
103 mtspr(SPRN_PMC4, val);
104 break;
105 case 4:
106 mtspr(SPRN_PMC5, val);
107 break;
108 case 5:
109 mtspr(SPRN_PMC6, val);
110 break;
111 case 6:
112 mtspr(SPRN_PMC7, val);
113 break;
114 case 7:
115 mtspr(SPRN_PMC8, val);
116 break;
117 default:
118 break;
119 }
120}
121#endif /* __powerpc64__ */
122
123#endif /* _ASM_POWERPC_OPROFILE_IMPL_H */
diff --git a/include/asm-powerpc/pSeries_reconfig.h b/include/asm-powerpc/pSeries_reconfig.h
new file mode 100644
index 000000000000..c0db1ea7f7d1
--- /dev/null
+++ b/include/asm-powerpc/pSeries_reconfig.h
@@ -0,0 +1,25 @@
1#ifndef _PPC64_PSERIES_RECONFIG_H
2#define _PPC64_PSERIES_RECONFIG_H
3
4#include <linux/notifier.h>
5
6/*
7 * Use this API if your code needs to know about OF device nodes being
8 * added or removed on pSeries systems.
9 */
10
11#define PSERIES_RECONFIG_ADD 0x0001
12#define PSERIES_RECONFIG_REMOVE 0x0002
13
14#ifdef CONFIG_PPC_PSERIES
15extern int pSeries_reconfig_notifier_register(struct notifier_block *);
16extern void pSeries_reconfig_notifier_unregister(struct notifier_block *);
17#else /* !CONFIG_PPC_PSERIES */
18static inline int pSeries_reconfig_notifier_register(struct notifier_block *nb)
19{
20 return 0;
21}
22static inline void pSeries_reconfig_notifier_unregister(struct notifier_block *nb) { }
23#endif /* CONFIG_PPC_PSERIES */
24
25#endif /* _PPC64_PSERIES_RECONFIG_H */
diff --git a/include/asm-powerpc/paca.h b/include/asm-powerpc/paca.h
new file mode 100644
index 000000000000..92c765c35bd0
--- /dev/null
+++ b/include/asm-powerpc/paca.h
@@ -0,0 +1,120 @@
1/*
2 * include/asm-powerpc/paca.h
3 *
4 * This control block defines the PACA which defines the processor
5 * specific data for each logical processor on the system.
6 * There are some pointers defined that are utilized by PLIC.
7 *
8 * C 2001 PPC 64 Team, IBM Corp
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15#ifndef _ASM_POWERPC_PACA_H
16#define _ASM_POWERPC_PACA_H
17
18#include <linux/config.h>
19#include <asm/types.h>
20#include <asm/lppaca.h>
21#include <asm/iseries/it_lp_reg_save.h>
22#include <asm/mmu.h>
23
24register struct paca_struct *local_paca asm("r13");
25#define get_paca() local_paca
26
27struct task_struct;
28
29/*
30 * Defines the layout of the paca.
31 *
32 * This structure is not directly accessed by firmware or the service
33 * processor except for the first two pointers that point to the
34 * lppaca area and the ItLpRegSave area for this CPU. Both the
35 * lppaca and ItLpRegSave objects are currently contained within the
36 * PACA but they do not need to be.
37 */
38struct paca_struct {
39 /*
40 * Because hw_cpu_id, unlike other paca fields, is accessed
41 * routinely from other CPUs (from the IRQ code), we stick to
42 * read-only (after boot) fields in the first cacheline to
43 * avoid cacheline bouncing.
44 */
45
46 /*
47 * MAGIC: These first two pointers can't be moved - they're
48 * accessed by the firmware
49 */
50 struct lppaca *lppaca_ptr; /* Pointer to LpPaca for PLIC */
51 struct ItLpRegSave *reg_save_ptr; /* Pointer to LpRegSave for PLIC */
52
53 /*
54 * MAGIC: the spinlock functions in arch/ppc64/lib/locks.c
55 * load lock_token and paca_index with a single lwz
56 * instruction. They must travel together and be properly
57 * aligned.
58 */
59 u16 lock_token; /* Constant 0x8000, used in locks */
60 u16 paca_index; /* Logical processor number */
61
62 u32 default_decr; /* Default decrementer value */
63 u64 kernel_toc; /* Kernel TOC address */
64 u64 stab_real; /* Absolute address of segment table */
65 u64 stab_addr; /* Virtual address of segment table */
66 void *emergency_sp; /* pointer to emergency stack */
67 s16 hw_cpu_id; /* Physical processor number */
68 u8 cpu_start; /* At startup, processor spins until */
69 /* this becomes non-zero. */
70
71 /*
72 * Now, starting in cacheline 2, the exception save areas
73 */
74 /* used for most interrupts/exceptions */
75 u64 exgen[10] __attribute__((aligned(0x80)));
76 u64 exmc[10]; /* used for machine checks */
77 u64 exslb[10]; /* used for SLB/segment table misses
78 * on the linear mapping */
79#ifdef CONFIG_PPC_64K_PAGES
80 pgd_t *pgdir;
81#endif /* CONFIG_PPC_64K_PAGES */
82
83 mm_context_t context;
84 u16 slb_cache[SLB_CACHE_ENTRIES];
85 u16 slb_cache_ptr;
86
87 /*
88 * then miscellaneous read-write fields
89 */
90 struct task_struct *__current; /* Pointer to current */
91 u64 kstack; /* Saved Kernel stack addr */
92 u64 stab_rr; /* stab/slb round-robin counter */
93 u64 next_jiffy_update_tb; /* TB value for next jiffy update */
94 u64 saved_r1; /* r1 save for RTAS calls */
95 u64 saved_msr; /* MSR saved here by enter_rtas */
96 u8 proc_enabled; /* irq soft-enable flag */
97
98 /* not yet used */
99 u64 exdsi[8]; /* used for linear mapping hash table misses */
100
101 /*
102 * iSeries structure which the hypervisor knows about -
103 * this structure should not cross a page boundary.
104 * The vpa_init/register_vpa call is now known to fail if the
105 * lppaca structure crosses a page boundary.
106 * The lppaca is also used on POWER5 pSeries boxes.
107 * The lppaca is 640 bytes long, and cannot readily change
108 * since the hypervisor knows its layout, so a 1kB
109 * alignment will suffice to ensure that it doesn't
110 * cross a page boundary.
111 */
112 struct lppaca lppaca __attribute__((__aligned__(0x400)));
113#ifdef CONFIG_PPC_ISERIES
114 struct ItLpRegSave reg_save;
115#endif
116};
117
118extern struct paca_struct paca[];
119
120#endif /* _ASM_POWERPC_PACA_H */
diff --git a/include/asm-powerpc/page.h b/include/asm-powerpc/page.h
new file mode 100644
index 000000000000..18c1e5ee81a3
--- /dev/null
+++ b/include/asm-powerpc/page.h
@@ -0,0 +1,179 @@
1#ifndef _ASM_POWERPC_PAGE_H
2#define _ASM_POWERPC_PAGE_H
3
4/*
5 * Copyright (C) 2001,2005 IBM Corporation.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifdef __KERNEL__
14#include <linux/config.h>
15#include <asm/asm-compat.h>
16
17/*
18 * On PPC32 page size is 4K. For PPC64 we support either 4K or 64K software
19 * page size. When using 64K pages however, whether we are really supporting
20 * 64K pages in HW or not is irrelevant to those definitions.
21 */
22#ifdef CONFIG_PPC_64K_PAGES
23#define PAGE_SHIFT 16
24#else
25#define PAGE_SHIFT 12
26#endif
27
28#define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT)
29
30/* We do define AT_SYSINFO_EHDR but don't use the gate mechanism */
31#define __HAVE_ARCH_GATE_AREA 1
32
33/*
34 * Subtle: (1 << PAGE_SHIFT) is an int, not an unsigned long. So if we
35 * assign PAGE_MASK to a larger type it gets extended the way we want
36 * (i.e. with 1s in the high bits)
37 */
38#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
39
40#define PAGE_OFFSET ASM_CONST(CONFIG_KERNEL_START)
41#define KERNELBASE PAGE_OFFSET
42
43#ifdef CONFIG_DISCONTIGMEM
44#define page_to_pfn(page) discontigmem_page_to_pfn(page)
45#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn)
46#define pfn_valid(pfn) discontigmem_pfn_valid(pfn)
47#endif
48
49#ifdef CONFIG_FLATMEM
50#define pfn_to_page(pfn) (mem_map + (pfn))
51#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
52#define pfn_valid(pfn) ((pfn) < max_mapnr)
53#endif
54
55#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
56#define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT)
57#define virt_addr_valid(kaddr) pfn_valid(__pa(kaddr) >> PAGE_SHIFT)
58
59#define __va(x) ((void *)((unsigned long)(x) + KERNELBASE))
60#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
61
62/*
63 * Unfortunately the PLT is in the BSS in the PPC32 ELF ABI,
64 * and needs to be executable. This means the whole heap ends
65 * up being executable.
66 */
67#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
68 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
69
70#define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
71 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
72
73#ifdef __powerpc64__
74#include <asm/page_64.h>
75#else
76#include <asm/page_32.h>
77#endif
78
79/* align addr on a size boundary - adjust address up/down if needed */
80#define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1)))
81#define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1)))
82
83/* align addr on a size boundary - adjust address up if needed */
84#define _ALIGN(addr,size) _ALIGN_UP(addr,size)
85
86/* to align the pointer to the (next) page boundary */
87#define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE)
88
89#ifndef __ASSEMBLY__
90
91#undef STRICT_MM_TYPECHECKS
92
93#ifdef STRICT_MM_TYPECHECKS
94/* These are used to make use of C type-checking. */
95
96/* PTE level */
97typedef struct { pte_basic_t pte; } pte_t;
98#define pte_val(x) ((x).pte)
99#define __pte(x) ((pte_t) { (x) })
100
101/* 64k pages additionally define a bigger "real PTE" type that gathers
102 * the "second half" part of the PTE for pseudo 64k pages
103 */
104#ifdef CONFIG_PPC_64K_PAGES
105typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
106#else
107typedef struct { pte_t pte; } real_pte_t;
108#endif
109
110/* PMD level */
111typedef struct { unsigned long pmd; } pmd_t;
112#define pmd_val(x) ((x).pmd)
113#define __pmd(x) ((pmd_t) { (x) })
114
115/* PUD level exusts only on 4k pages */
116#ifndef CONFIG_PPC_64K_PAGES
117typedef struct { unsigned long pud; } pud_t;
118#define pud_val(x) ((x).pud)
119#define __pud(x) ((pud_t) { (x) })
120#endif
121
122/* PGD level */
123typedef struct { unsigned long pgd; } pgd_t;
124#define pgd_val(x) ((x).pgd)
125#define __pgd(x) ((pgd_t) { (x) })
126
127/* Page protection bits */
128typedef struct { unsigned long pgprot; } pgprot_t;
129#define pgprot_val(x) ((x).pgprot)
130#define __pgprot(x) ((pgprot_t) { (x) })
131
132#else
133
134/*
135 * .. while these make it easier on the compiler
136 */
137
138typedef pte_basic_t pte_t;
139#define pte_val(x) (x)
140#define __pte(x) (x)
141
142#ifdef CONFIG_PPC_64K_PAGES
143typedef struct { pte_t pte; unsigned long hidx; } real_pte_t;
144#else
145typedef unsigned long real_pte_t;
146#endif
147
148
149typedef unsigned long pmd_t;
150#define pmd_val(x) (x)
151#define __pmd(x) (x)
152
153#ifndef CONFIG_PPC_64K_PAGES
154typedef unsigned long pud_t;
155#define pud_val(x) (x)
156#define __pud(x) (x)
157#endif
158
159typedef unsigned long pgd_t;
160#define pgd_val(x) (x)
161#define pgprot_val(x) (x)
162
163typedef unsigned long pgprot_t;
164#define __pgd(x) (x)
165#define __pgprot(x) (x)
166
167#endif
168
169struct page;
170extern void clear_user_page(void *page, unsigned long vaddr, struct page *pg);
171extern void copy_user_page(void *to, void *from, unsigned long vaddr,
172 struct page *p);
173extern int page_is_ram(unsigned long pfn);
174
175#endif /* __ASSEMBLY__ */
176
177#endif /* __KERNEL__ */
178
179#endif /* _ASM_POWERPC_PAGE_H */
diff --git a/include/asm-powerpc/page_32.h b/include/asm-powerpc/page_32.h
new file mode 100644
index 000000000000..7259cfd85da9
--- /dev/null
+++ b/include/asm-powerpc/page_32.h
@@ -0,0 +1,40 @@
1#ifndef _ASM_POWERPC_PAGE_32_H
2#define _ASM_POWERPC_PAGE_32_H
3
4#define VM_DATA_DEFAULT_FLAGS VM_DATA_DEFAULT_FLAGS32
5
6#define PPC_MEMSTART 0
7
8#ifndef __ASSEMBLY__
9/*
10 * The basic type of a PTE - 64 bits for those CPUs with > 32 bit
11 * physical addressing. For now this just the IBM PPC440.
12 */
13#ifdef CONFIG_PTE_64BIT
14typedef unsigned long long pte_basic_t;
15#define PTE_SHIFT (PAGE_SHIFT - 3) /* 512 ptes per page */
16#define PTE_FMT "%16Lx"
17#else
18typedef unsigned long pte_basic_t;
19#define PTE_SHIFT (PAGE_SHIFT - 2) /* 1024 ptes per page */
20#define PTE_FMT "%.8lx"
21#endif
22
23struct page;
24extern void clear_pages(void *page, int order);
25static inline void clear_page(void *page) { clear_pages(page, 0); }
26extern void copy_page(void *to, void *from);
27
28/* Pure 2^n version of get_order */
29extern __inline__ int get_order(unsigned long size)
30{
31 int lz;
32
33 size = (size-1) >> PAGE_SHIFT;
34 asm ("cntlzw %0,%1" : "=r" (lz) : "r" (size));
35 return 32 - lz;
36}
37
38#endif /* __ASSEMBLY__ */
39
40#endif /* _ASM_POWERPC_PAGE_32_H */
diff --git a/include/asm-powerpc/page_64.h b/include/asm-powerpc/page_64.h
new file mode 100644
index 000000000000..6642c0125001
--- /dev/null
+++ b/include/asm-powerpc/page_64.h
@@ -0,0 +1,183 @@
1#ifndef _ASM_POWERPC_PAGE_64_H
2#define _ASM_POWERPC_PAGE_64_H
3
4/*
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13/*
14 * We always define HW_PAGE_SHIFT to 12 as use of 64K pages remains Linux
15 * specific, every notion of page number shared with the firmware, TCEs,
16 * iommu, etc... still uses a page size of 4K.
17 */
18#define HW_PAGE_SHIFT 12
19#define HW_PAGE_SIZE (ASM_CONST(1) << HW_PAGE_SHIFT)
20#define HW_PAGE_MASK (~(HW_PAGE_SIZE-1))
21
22/*
23 * PAGE_FACTOR is the number of bits factor between PAGE_SHIFT and
24 * HW_PAGE_SHIFT, that is 4K pages.
25 */
26#define PAGE_FACTOR (PAGE_SHIFT - HW_PAGE_SHIFT)
27
28#define REGION_SIZE 4UL
29#define REGION_SHIFT 60UL
30#define REGION_MASK (((1UL<<REGION_SIZE)-1UL)<<REGION_SHIFT)
31
32#define VMALLOCBASE ASM_CONST(0xD000000000000000)
33#define VMALLOC_REGION_ID (VMALLOCBASE >> REGION_SHIFT)
34#define KERNEL_REGION_ID (KERNELBASE >> REGION_SHIFT)
35#define USER_REGION_ID (0UL)
36#define REGION_ID(ea) (((unsigned long)(ea)) >> REGION_SHIFT)
37
38/* Segment size */
39#define SID_SHIFT 28
40#define SID_MASK 0xfffffffffUL
41#define ESID_MASK 0xfffffffff0000000UL
42#define GET_ESID(x) (((x) >> SID_SHIFT) & SID_MASK)
43
44#ifndef __ASSEMBLY__
45#include <asm/cache.h>
46
47typedef unsigned long pte_basic_t;
48
49static __inline__ void clear_page(void *addr)
50{
51 unsigned long lines, line_size;
52
53 line_size = ppc64_caches.dline_size;
54 lines = ppc64_caches.dlines_per_page;
55
56 __asm__ __volatile__(
57 "mtctr %1 # clear_page\n\
581: dcbz 0,%0\n\
59 add %0,%0,%3\n\
60 bdnz+ 1b"
61 : "=r" (addr)
62 : "r" (lines), "0" (addr), "r" (line_size)
63 : "ctr", "memory");
64}
65
66extern void copy_4K_page(void *to, void *from);
67
68#ifdef CONFIG_PPC_64K_PAGES
69static inline void copy_page(void *to, void *from)
70{
71 unsigned int i;
72 for (i=0; i < (1 << (PAGE_SHIFT - 12)); i++) {
73 copy_4K_page(to, from);
74 to += 4096;
75 from += 4096;
76 }
77}
78#else /* CONFIG_PPC_64K_PAGES */
79static inline void copy_page(void *to, void *from)
80{
81 copy_4K_page(to, from);
82}
83#endif /* CONFIG_PPC_64K_PAGES */
84
85/* Log 2 of page table size */
86extern u64 ppc64_pft_size;
87
88/* Large pages size */
89#ifdef CONFIG_HUGETLB_PAGE
90extern unsigned int HPAGE_SHIFT;
91#else
92#define HPAGE_SHIFT PAGE_SHIFT
93#endif
94#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
95#define HPAGE_MASK (~(HPAGE_SIZE - 1))
96#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
97
98#endif /* __ASSEMBLY__ */
99
100#ifdef CONFIG_HUGETLB_PAGE
101
102#define HTLB_AREA_SHIFT 40
103#define HTLB_AREA_SIZE (1UL << HTLB_AREA_SHIFT)
104#define GET_HTLB_AREA(x) ((x) >> HTLB_AREA_SHIFT)
105
106#define LOW_ESID_MASK(addr, len) \
107 (((1U << (GET_ESID(min((addr)+(len)-1, 0x100000000UL))+1)) \
108 - (1U << GET_ESID(min((addr), 0x100000000UL)))) & 0xffff)
109#define HTLB_AREA_MASK(addr, len) (((1U << (GET_HTLB_AREA(addr+len-1)+1)) \
110 - (1U << GET_HTLB_AREA(addr))) & 0xffff)
111
112#define ARCH_HAS_HUGEPAGE_ONLY_RANGE
113#define ARCH_HAS_PREPARE_HUGEPAGE_RANGE
114#define ARCH_HAS_SETCLEAR_HUGE_PTE
115
116#define touches_hugepage_low_range(mm, addr, len) \
117 (((addr) < 0x100000000UL) \
118 && (LOW_ESID_MASK((addr), (len)) & (mm)->context.low_htlb_areas))
119#define touches_hugepage_high_range(mm, addr, len) \
120 ((((addr) + (len)) > 0x100000000UL) \
121 && (HTLB_AREA_MASK((addr), (len)) & (mm)->context.high_htlb_areas))
122
123#define __within_hugepage_low_range(addr, len, segmask) \
124 ( (((addr)+(len)) <= 0x100000000UL) \
125 && ((LOW_ESID_MASK((addr), (len)) | (segmask)) == (segmask)))
126#define within_hugepage_low_range(addr, len) \
127 __within_hugepage_low_range((addr), (len), \
128 current->mm->context.low_htlb_areas)
129#define __within_hugepage_high_range(addr, len, zonemask) \
130 ( ((addr) >= 0x100000000UL) \
131 && ((HTLB_AREA_MASK((addr), (len)) | (zonemask)) == (zonemask)))
132#define within_hugepage_high_range(addr, len) \
133 __within_hugepage_high_range((addr), (len), \
134 current->mm->context.high_htlb_areas)
135
136#define is_hugepage_only_range(mm, addr, len) \
137 (touches_hugepage_high_range((mm), (addr), (len)) || \
138 touches_hugepage_low_range((mm), (addr), (len)))
139#define HAVE_ARCH_HUGETLB_UNMAPPED_AREA
140
141#define in_hugepage_area(context, addr) \
142 (cpu_has_feature(CPU_FTR_16M_PAGE) && \
143 ( ( (addr) >= 0x100000000UL) \
144 ? ((1 << GET_HTLB_AREA(addr)) & (context).high_htlb_areas) \
145 : ((1 << GET_ESID(addr)) & (context).low_htlb_areas) ) )
146
147#else /* !CONFIG_HUGETLB_PAGE */
148
149#define in_hugepage_area(mm, addr) 0
150
151#endif /* !CONFIG_HUGETLB_PAGE */
152
153#ifdef MODULE
154#define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
155#else
156#define __page_aligned \
157 __attribute__((__aligned__(PAGE_SIZE), \
158 __section__(".data.page_aligned")))
159#endif
160
161#define VM_DATA_DEFAULT_FLAGS \
162 (test_thread_flag(TIF_32BIT) ? \
163 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
164
165/*
166 * This is the default if a program doesn't have a PT_GNU_STACK
167 * program header entry. The PPC64 ELF ABI has a non executable stack
168 * stack by default, so in the absense of a PT_GNU_STACK program header
169 * we turn execute permission off.
170 */
171#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
172 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
173
174#define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
175 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
176
177#define VM_STACK_DEFAULT_FLAGS \
178 (test_thread_flag(TIF_32BIT) ? \
179 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
180
181#include <asm-generic/page.h>
182
183#endif /* _ASM_POWERPC_PAGE_64_H */
diff --git a/include/asm-powerpc/parport.h b/include/asm-powerpc/parport.h
new file mode 100644
index 000000000000..d86b410a6f8b
--- /dev/null
+++ b/include/asm-powerpc/parport.h
@@ -0,0 +1,18 @@
1/*
2 * parport.h: platform-specific PC-style parport initialisation
3 *
4 * Copyright (C) 1999, 2000 Tim Waugh <tim@cyberelk.demon.co.uk>
5 *
6 * This file should only be included by drivers/parport/parport_pc.c.
7 */
8
9#ifndef _ASM_POWERPC_PARPORT_H
10#define _ASM_POWERPC_PARPORT_H
11
12static int __devinit parport_pc_find_isa_ports (int autoirq, int autodma);
13static int __devinit parport_pc_find_nonpci_ports (int autoirq, int autodma)
14{
15 return parport_pc_find_isa_ports (autoirq, autodma);
16}
17
18#endif /* !(_ASM_POWERPC_PARPORT_H) */
diff --git a/include/asm-powerpc/pci-bridge.h b/include/asm-powerpc/pci-bridge.h
new file mode 100644
index 000000000000..223ec7bd81da
--- /dev/null
+++ b/include/asm-powerpc/pci-bridge.h
@@ -0,0 +1,153 @@
1#ifndef _ASM_POWERPC_PCI_BRIDGE_H
2#define _ASM_POWERPC_PCI_BRIDGE_H
3
4#ifndef CONFIG_PPC64
5#include <asm-ppc/pci-bridge.h>
6#else
7
8#include <linux/pci.h>
9#include <linux/list.h>
10
11/*
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version
15 * 2 of the License, or (at your option) any later version.
16 */
17
18/*
19 * Structure of a PCI controller (host bridge)
20 */
21struct pci_controller {
22 struct pci_bus *bus;
23 char is_dynamic;
24 void *arch_data;
25 struct list_head list_node;
26
27 int first_busno;
28 int last_busno;
29
30 void __iomem *io_base_virt;
31 unsigned long io_base_phys;
32
33 /* Some machines have a non 1:1 mapping of
34 * the PCI memory space in the CPU bus space
35 */
36 unsigned long pci_mem_offset;
37 unsigned long pci_io_size;
38
39 struct pci_ops *ops;
40 volatile unsigned int __iomem *cfg_addr;
41 volatile void __iomem *cfg_data;
42
43 /* Currently, we limit ourselves to 1 IO range and 3 mem
44 * ranges since the common pci_bus structure can't handle more
45 */
46 struct resource io_resource;
47 struct resource mem_resources[3];
48 int global_number;
49 int local_number;
50 unsigned long buid;
51 unsigned long dma_window_base_cur;
52 unsigned long dma_window_size;
53};
54
55/*
56 * PCI stuff, for nodes representing PCI devices, pointed to
57 * by device_node->data.
58 */
59struct pci_controller;
60struct iommu_table;
61
62struct pci_dn {
63 int busno; /* for pci devices */
64 int bussubno; /* for pci devices */
65 int devfn; /* for pci devices */
66
67#ifdef CONFIG_PPC_PSERIES
68 int eeh_mode; /* See eeh.h for possible EEH_MODEs */
69 int eeh_config_addr;
70 int eeh_check_count; /* # times driver ignored error */
71 int eeh_freeze_count; /* # times this device froze up. */
72 int eeh_is_bridge; /* device is pci-to-pci bridge */
73#endif
74 int pci_ext_config_space; /* for pci devices */
75 struct pci_controller *phb; /* for pci devices */
76 struct iommu_table *iommu_table; /* for phb's or bridges */
77 struct pci_dev *pcidev; /* back-pointer to the pci device */
78 struct device_node *node; /* back-pointer to the device_node */
79#ifdef CONFIG_PPC_ISERIES
80 struct list_head Device_List;
81 int Irq; /* Assigned IRQ */
82 int Flags; /* Possible flags(disable/bist)*/
83 u8 LogicalSlot; /* Hv Slot Index for Tces */
84#endif
85 u32 config_space[16]; /* saved PCI config space */
86};
87
88/* Get the pointer to a device_node's pci_dn */
89#define PCI_DN(dn) ((struct pci_dn *) (dn)->data)
90
91struct device_node *fetch_dev_dn(struct pci_dev *dev);
92
93/* Get a device_node from a pci_dev. This code must be fast except
94 * in the case where the sysdata is incorrect and needs to be fixed
95 * up (this will only happen once).
96 * In this case the sysdata will have been inherited from a PCI host
97 * bridge or a PCI-PCI bridge further up the tree, so it will point
98 * to a valid struct pci_dn, just not the one we want.
99 */
100static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
101{
102 struct device_node *dn = dev->sysdata;
103 struct pci_dn *pdn = dn->data;
104
105 if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number)
106 return dn; /* fast path. sysdata is good */
107 return fetch_dev_dn(dev);
108}
109
110static inline int pci_device_from_OF_node(struct device_node *np,
111 u8 *bus, u8 *devfn)
112{
113 if (!PCI_DN(np))
114 return -ENODEV;
115 *bus = PCI_DN(np)->busno;
116 *devfn = PCI_DN(np)->devfn;
117 return 0;
118}
119
120static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus)
121{
122 if (bus->self)
123 return pci_device_to_OF_node(bus->self);
124 else
125 return bus->sysdata; /* Must be root bus (PHB) */
126}
127
128extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
129 struct device_node *dev, int primary);
130
131extern int pcibios_remove_root_bus(struct pci_controller *phb);
132
133extern void phbs_remap_io(void);
134
135static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
136{
137 struct device_node *busdn = bus->sysdata;
138
139 BUG_ON(busdn == NULL);
140 return PCI_DN(busdn)->phb;
141}
142
143extern struct pci_controller *
144pcibios_alloc_controller(struct device_node *dev);
145extern void pcibios_free_controller(struct pci_controller *phb);
146
147/* Return values for ppc_md.pci_probe_mode function */
148#define PCI_PROBE_NONE -1 /* Don't look at this bus at all */
149#define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */
150#define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */
151
152#endif /* CONFIG_PPC64 */
153#endif
diff --git a/include/asm-powerpc/pci.h b/include/asm-powerpc/pci.h
new file mode 100644
index 000000000000..d5934a076bd0
--- /dev/null
+++ b/include/asm-powerpc/pci.h
@@ -0,0 +1,247 @@
1#ifndef __ASM_POWERPC_PCI_H
2#define __ASM_POWERPC_PCI_H
3#ifdef __KERNEL__
4
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#include <linux/types.h>
13#include <linux/slab.h>
14#include <linux/string.h>
15#include <linux/dma-mapping.h>
16
17#include <asm/machdep.h>
18#include <asm/scatterlist.h>
19#include <asm/io.h>
20#include <asm/prom.h>
21#include <asm/pci-bridge.h>
22
23#include <asm-generic/pci-dma-compat.h>
24
25#define PCIBIOS_MIN_IO 0x1000
26#define PCIBIOS_MIN_MEM 0x10000000
27
28struct pci_dev;
29
30/* Values for the `which' argument to sys_pciconfig_iobase syscall. */
31#define IOBASE_BRIDGE_NUMBER 0
32#define IOBASE_MEMORY 1
33#define IOBASE_IO 2
34#define IOBASE_ISA_IO 3
35#define IOBASE_ISA_MEM 4
36
37/*
38 * Set this to 1 if you want the kernel to re-assign all PCI
39 * bus numbers
40 */
41extern int pci_assign_all_buses;
42#define pcibios_assign_all_busses() (pci_assign_all_buses)
43
44#define pcibios_scan_all_fns(a, b) 0
45
46static inline void pcibios_set_master(struct pci_dev *dev)
47{
48 /* No special bus mastering setup handling */
49}
50
51static inline void pcibios_penalize_isa_irq(int irq, int active)
52{
53 /* We don't do dynamic PCI IRQ allocation */
54}
55
56#define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
57static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
58{
59 if (ppc_md.pci_get_legacy_ide_irq)
60 return ppc_md.pci_get_legacy_ide_irq(dev, channel);
61 return channel ? 15 : 14;
62}
63
64#ifdef CONFIG_PPC64
65#define HAVE_ARCH_PCI_MWI 1
66static inline int pcibios_prep_mwi(struct pci_dev *dev)
67{
68 /*
69 * We would like to avoid touching the cacheline size or MWI bit
70 * but we cant do that with the current pcibios_prep_mwi
71 * interface. pSeries firmware sets the cacheline size (which is not
72 * the cpu cacheline size in all cases) and hardware treats MWI
73 * the same as memory write. So we dont touch the cacheline size
74 * here and allow the generic code to set the MWI bit.
75 */
76 return 0;
77}
78
79extern struct dma_mapping_ops pci_dma_ops;
80
81/* For DAC DMA, we currently don't support it by default, but
82 * we let 64-bit platforms override this.
83 */
84static inline int pci_dac_dma_supported(struct pci_dev *hwdev,u64 mask)
85{
86 if (pci_dma_ops.dac_dma_supported)
87 return pci_dma_ops.dac_dma_supported(&hwdev->dev, mask);
88 return 0;
89}
90
91#ifdef CONFIG_PCI
92static inline void pci_dma_burst_advice(struct pci_dev *pdev,
93 enum pci_dma_burst_strategy *strat,
94 unsigned long *strategy_parameter)
95{
96 unsigned long cacheline_size;
97 u8 byte;
98
99 pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &byte);
100 if (byte == 0)
101 cacheline_size = 1024;
102 else
103 cacheline_size = (int) byte * 4;
104
105 *strat = PCI_DMA_BURST_MULTIPLE;
106 *strategy_parameter = cacheline_size;
107}
108#endif
109
110extern int pci_domain_nr(struct pci_bus *bus);
111
112/* Decide whether to display the domain number in /proc */
113extern int pci_proc_domain(struct pci_bus *bus);
114
115#else /* 32-bit */
116
117#ifdef CONFIG_PCI
118static inline void pci_dma_burst_advice(struct pci_dev *pdev,
119 enum pci_dma_burst_strategy *strat,
120 unsigned long *strategy_parameter)
121{
122 *strat = PCI_DMA_BURST_INFINITY;
123 *strategy_parameter = ~0UL;
124}
125#endif
126
127/*
128 * At present there are very few 32-bit PPC machines that can have
129 * memory above the 4GB point, and we don't support that.
130 */
131#define pci_dac_dma_supported(pci_dev, mask) (0)
132
133/* Return the index of the PCI controller for device PDEV. */
134#define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
135
136/* Set the name of the bus as it appears in /proc/bus/pci */
137static inline int pci_proc_domain(struct pci_bus *bus)
138{
139 return 0;
140}
141
142#endif /* CONFIG_PPC64 */
143
144struct vm_area_struct;
145/* Map a range of PCI memory or I/O space for a device into user space */
146int pci_mmap_page_range(struct pci_dev *pdev, struct vm_area_struct *vma,
147 enum pci_mmap_state mmap_state, int write_combine);
148
149/* Tell drivers/pci/proc.c that we have pci_mmap_page_range() */
150#define HAVE_PCI_MMAP 1
151
152#ifdef CONFIG_PPC64
153/* pci_unmap_{single,page} is not a nop, thus... */
154#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME) \
155 dma_addr_t ADDR_NAME;
156#define DECLARE_PCI_UNMAP_LEN(LEN_NAME) \
157 __u32 LEN_NAME;
158#define pci_unmap_addr(PTR, ADDR_NAME) \
159 ((PTR)->ADDR_NAME)
160#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) \
161 (((PTR)->ADDR_NAME) = (VAL))
162#define pci_unmap_len(PTR, LEN_NAME) \
163 ((PTR)->LEN_NAME)
164#define pci_unmap_len_set(PTR, LEN_NAME, VAL) \
165 (((PTR)->LEN_NAME) = (VAL))
166
167/* The PCI address space does not equal the physical memory address
168 * space (we have an IOMMU). The IDE and SCSI device layers use
169 * this boolean for bounce buffer decisions.
170 */
171#define PCI_DMA_BUS_IS_PHYS (0)
172
173#else /* 32-bit */
174
175/* The PCI address space does equal the physical memory
176 * address space (no IOMMU). The IDE and SCSI device layers use
177 * this boolean for bounce buffer decisions.
178 */
179#define PCI_DMA_BUS_IS_PHYS (1)
180
181/* pci_unmap_{page,single} is a nop so... */
182#define DECLARE_PCI_UNMAP_ADDR(ADDR_NAME)
183#define DECLARE_PCI_UNMAP_LEN(LEN_NAME)
184#define pci_unmap_addr(PTR, ADDR_NAME) (0)
185#define pci_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
186#define pci_unmap_len(PTR, LEN_NAME) (0)
187#define pci_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
188
189#endif /* CONFIG_PPC64 */
190
191extern void pcibios_resource_to_bus(struct pci_dev *dev,
192 struct pci_bus_region *region,
193 struct resource *res);
194
195extern void pcibios_bus_to_resource(struct pci_dev *dev,
196 struct resource *res,
197 struct pci_bus_region *region);
198
199static inline struct resource *pcibios_select_root(struct pci_dev *pdev,
200 struct resource *res)
201{
202 struct resource *root = NULL;
203
204 if (res->flags & IORESOURCE_IO)
205 root = &ioport_resource;
206 if (res->flags & IORESOURCE_MEM)
207 root = &iomem_resource;
208
209 return root;
210}
211
212extern int unmap_bus_range(struct pci_bus *bus);
213
214extern int remap_bus_range(struct pci_bus *bus);
215
216extern void pcibios_fixup_device_resources(struct pci_dev *dev,
217 struct pci_bus *bus);
218
219extern struct pci_controller *init_phb_dynamic(struct device_node *dn);
220
221extern struct pci_dev *of_create_pci_dev(struct device_node *node,
222 struct pci_bus *bus, int devfn);
223
224extern void of_scan_pci_bridge(struct device_node *node,
225 struct pci_dev *dev);
226
227extern void of_scan_bus(struct device_node *node, struct pci_bus *bus);
228
229extern int pci_read_irq_line(struct pci_dev *dev);
230
231extern void pcibios_add_platform_entries(struct pci_dev *dev);
232
233struct file;
234extern pgprot_t pci_phys_mem_access_prot(struct file *file,
235 unsigned long pfn,
236 unsigned long size,
237 pgprot_t prot);
238
239#if defined(CONFIG_PPC_MULTIPLATFORM) || defined(CONFIG_PPC32)
240#define HAVE_ARCH_PCI_RESOURCE_TO_USER
241extern void pci_resource_to_user(const struct pci_dev *dev, int bar,
242 const struct resource *rsrc,
243 u64 *start, u64 *end);
244#endif /* CONFIG_PPC_MULTIPLATFORM || CONFIG_PPC32 */
245
246#endif /* __KERNEL__ */
247#endif /* __ASM_POWERPC_PCI_H */
diff --git a/include/asm-powerpc/pgalloc.h b/include/asm-powerpc/pgalloc.h
new file mode 100644
index 000000000000..bfc2113b3630
--- /dev/null
+++ b/include/asm-powerpc/pgalloc.h
@@ -0,0 +1,156 @@
1#ifndef _ASM_POWERPC_PGALLOC_H
2#define _ASM_POWERPC_PGALLOC_H
3
4#ifndef CONFIG_PPC64
5#include <asm-ppc/pgalloc.h>
6#else
7
8#include <linux/mm.h>
9#include <linux/slab.h>
10#include <linux/cpumask.h>
11#include <linux/percpu.h>
12
13extern kmem_cache_t *pgtable_cache[];
14
15#ifdef CONFIG_PPC_64K_PAGES
16#define PTE_CACHE_NUM 0
17#define PMD_CACHE_NUM 1
18#define PGD_CACHE_NUM 2
19#else
20#define PTE_CACHE_NUM 0
21#define PMD_CACHE_NUM 1
22#define PUD_CACHE_NUM 1
23#define PGD_CACHE_NUM 0
24#endif
25
26/*
27 * This program is free software; you can redistribute it and/or
28 * modify it under the terms of the GNU General Public License
29 * as published by the Free Software Foundation; either version
30 * 2 of the License, or (at your option) any later version.
31 */
32
33static inline pgd_t *pgd_alloc(struct mm_struct *mm)
34{
35 return kmem_cache_alloc(pgtable_cache[PGD_CACHE_NUM], GFP_KERNEL);
36}
37
38static inline void pgd_free(pgd_t *pgd)
39{
40 kmem_cache_free(pgtable_cache[PGD_CACHE_NUM], pgd);
41}
42
43#ifndef CONFIG_PPC_64K_PAGES
44
45#define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
46
47static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
48{
49 return kmem_cache_alloc(pgtable_cache[PUD_CACHE_NUM],
50 GFP_KERNEL|__GFP_REPEAT);
51}
52
53static inline void pud_free(pud_t *pud)
54{
55 kmem_cache_free(pgtable_cache[PUD_CACHE_NUM], pud);
56}
57
58static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
59{
60 pud_set(pud, (unsigned long)pmd);
61}
62
63#define pmd_populate(mm, pmd, pte_page) \
64 pmd_populate_kernel(mm, pmd, page_address(pte_page))
65#define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
66
67
68#else /* CONFIG_PPC_64K_PAGES */
69
70#define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
71
72static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
73 pte_t *pte)
74{
75 pmd_set(pmd, (unsigned long)pte);
76}
77
78#define pmd_populate(mm, pmd, pte_page) \
79 pmd_populate_kernel(mm, pmd, page_address(pte_page))
80
81#endif /* CONFIG_PPC_64K_PAGES */
82
83static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
84{
85 return kmem_cache_alloc(pgtable_cache[PMD_CACHE_NUM],
86 GFP_KERNEL|__GFP_REPEAT);
87}
88
89static inline void pmd_free(pmd_t *pmd)
90{
91 kmem_cache_free(pgtable_cache[PMD_CACHE_NUM], pmd);
92}
93
94static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm,
95 unsigned long address)
96{
97 return kmem_cache_alloc(pgtable_cache[PTE_CACHE_NUM],
98 GFP_KERNEL|__GFP_REPEAT);
99}
100
101static inline struct page *pte_alloc_one(struct mm_struct *mm,
102 unsigned long address)
103{
104 return virt_to_page(pte_alloc_one_kernel(mm, address));
105}
106
107static inline void pte_free_kernel(pte_t *pte)
108{
109 kmem_cache_free(pgtable_cache[PTE_CACHE_NUM], pte);
110}
111
112static inline void pte_free(struct page *ptepage)
113{
114 pte_free_kernel(page_address(ptepage));
115}
116
117#define PGF_CACHENUM_MASK 0xf
118
119typedef struct pgtable_free {
120 unsigned long val;
121} pgtable_free_t;
122
123static inline pgtable_free_t pgtable_free_cache(void *p, int cachenum,
124 unsigned long mask)
125{
126 BUG_ON(cachenum > PGF_CACHENUM_MASK);
127
128 return (pgtable_free_t){.val = ((unsigned long) p & ~mask) | cachenum};
129}
130
131static inline void pgtable_free(pgtable_free_t pgf)
132{
133 void *p = (void *)(pgf.val & ~PGF_CACHENUM_MASK);
134 int cachenum = pgf.val & PGF_CACHENUM_MASK;
135
136 kmem_cache_free(pgtable_cache[cachenum], p);
137}
138
139extern void pgtable_free_tlb(struct mmu_gather *tlb, pgtable_free_t pgf);
140
141#define __pte_free_tlb(tlb, ptepage) \
142 pgtable_free_tlb(tlb, pgtable_free_cache(page_address(ptepage), \
143 PTE_CACHE_NUM, PTE_TABLE_SIZE-1))
144#define __pmd_free_tlb(tlb, pmd) \
145 pgtable_free_tlb(tlb, pgtable_free_cache(pmd, \
146 PMD_CACHE_NUM, PMD_TABLE_SIZE-1))
147#ifndef CONFIG_PPC_64K_PAGES
148#define __pud_free_tlb(tlb, pmd) \
149 pgtable_free_tlb(tlb, pgtable_free_cache(pud, \
150 PUD_CACHE_NUM, PUD_TABLE_SIZE-1))
151#endif /* CONFIG_PPC_64K_PAGES */
152
153#define check_pgt_cache() do { } while (0)
154
155#endif /* CONFIG_PPC64 */
156#endif /* _ASM_POWERPC_PGALLOC_H */
diff --git a/include/asm-powerpc/pgtable-4k.h b/include/asm-powerpc/pgtable-4k.h
new file mode 100644
index 000000000000..e9590c06ad92
--- /dev/null
+++ b/include/asm-powerpc/pgtable-4k.h
@@ -0,0 +1,91 @@
1/*
2 * Entries per page directory level. The PTE level must use a 64b record
3 * for each page table entry. The PMD and PGD level use a 32b record for
4 * each entry by assuming that each entry is page aligned.
5 */
6#define PTE_INDEX_SIZE 9
7#define PMD_INDEX_SIZE 7
8#define PUD_INDEX_SIZE 7
9#define PGD_INDEX_SIZE 9
10
11#define PTE_TABLE_SIZE (sizeof(pte_t) << PTE_INDEX_SIZE)
12#define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE)
13#define PUD_TABLE_SIZE (sizeof(pud_t) << PUD_INDEX_SIZE)
14#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
15
16#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)
17#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
18#define PTRS_PER_PUD (1 << PMD_INDEX_SIZE)
19#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
20
21/* PMD_SHIFT determines what a second-level page table entry can map */
22#define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
23#define PMD_SIZE (1UL << PMD_SHIFT)
24#define PMD_MASK (~(PMD_SIZE-1))
25
26/* With 4k base page size, hugepage PTEs go at the PMD level */
27#define MIN_HUGEPTE_SHIFT PMD_SHIFT
28
29/* PUD_SHIFT determines what a third-level page table entry can map */
30#define PUD_SHIFT (PMD_SHIFT + PMD_INDEX_SIZE)
31#define PUD_SIZE (1UL << PUD_SHIFT)
32#define PUD_MASK (~(PUD_SIZE-1))
33
34/* PGDIR_SHIFT determines what a fourth-level page table entry can map */
35#define PGDIR_SHIFT (PUD_SHIFT + PUD_INDEX_SIZE)
36#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
37#define PGDIR_MASK (~(PGDIR_SIZE-1))
38
39/* PTE bits */
40#define _PAGE_SECONDARY 0x8000 /* software: HPTE is in secondary group */
41#define _PAGE_GROUP_IX 0x7000 /* software: HPTE index within group */
42#define _PAGE_F_SECOND _PAGE_SECONDARY
43#define _PAGE_F_GIX _PAGE_GROUP_IX
44
45/* PTE flags to conserve for HPTE identification */
46#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | \
47 _PAGE_SECONDARY | _PAGE_GROUP_IX)
48
49/* PAGE_MASK gives the right answer below, but only by accident */
50/* It should be preserving the high 48 bits and then specifically */
51/* preserving _PAGE_SECONDARY | _PAGE_GROUP_IX */
52#define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | \
53 _PAGE_HPTEFLAGS)
54
55/* Bits to mask out from a PMD to get to the PTE page */
56#define PMD_MASKED_BITS 0
57/* Bits to mask out from a PUD to get to the PMD page */
58#define PUD_MASKED_BITS 0
59/* Bits to mask out from a PGD to get to the PUD page */
60#define PGD_MASKED_BITS 0
61
62/* shift to put page number into pte */
63#define PTE_RPN_SHIFT (17)
64
65#define __real_pte(e,p) ((real_pte_t)(e))
66#define __rpte_to_pte(r) (r)
67#define __rpte_to_hidx(r,index) (pte_val((r)) >> 12)
68
69#define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \
70 do { \
71 index = 0; \
72 shift = mmu_psize_defs[psize].shift; \
73
74#define pte_iterate_hashed_end() } while(0)
75
76/*
77 * 4-level page tables related bits
78 */
79
80#define pgd_none(pgd) (!pgd_val(pgd))
81#define pgd_bad(pgd) (pgd_val(pgd) == 0)
82#define pgd_present(pgd) (pgd_val(pgd) != 0)
83#define pgd_clear(pgdp) (pgd_val(*(pgdp)) = 0)
84#define pgd_page(pgd) (pgd_val(pgd) & ~PGD_MASKED_BITS)
85
86#define pud_offset(pgdp, addr) \
87 (((pud_t *) pgd_page(*(pgdp))) + \
88 (((addr) >> PUD_SHIFT) & (PTRS_PER_PUD - 1)))
89
90#define pud_ERROR(e) \
91 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pud_val(e))
diff --git a/include/asm-powerpc/pgtable-64k.h b/include/asm-powerpc/pgtable-64k.h
new file mode 100644
index 000000000000..154f1840ece4
--- /dev/null
+++ b/include/asm-powerpc/pgtable-64k.h
@@ -0,0 +1,90 @@
1#include <asm-generic/pgtable-nopud.h>
2
3
4#define PTE_INDEX_SIZE 12
5#define PMD_INDEX_SIZE 12
6#define PUD_INDEX_SIZE 0
7#define PGD_INDEX_SIZE 4
8
9#define PTE_TABLE_SIZE (sizeof(real_pte_t) << PTE_INDEX_SIZE)
10#define PMD_TABLE_SIZE (sizeof(pmd_t) << PMD_INDEX_SIZE)
11#define PGD_TABLE_SIZE (sizeof(pgd_t) << PGD_INDEX_SIZE)
12
13#define PTRS_PER_PTE (1 << PTE_INDEX_SIZE)
14#define PTRS_PER_PMD (1 << PMD_INDEX_SIZE)
15#define PTRS_PER_PGD (1 << PGD_INDEX_SIZE)
16
17/* With 4k base page size, hugepage PTEs go at the PMD level */
18#define MIN_HUGEPTE_SHIFT PAGE_SHIFT
19
20/* PMD_SHIFT determines what a second-level page table entry can map */
21#define PMD_SHIFT (PAGE_SHIFT + PTE_INDEX_SIZE)
22#define PMD_SIZE (1UL << PMD_SHIFT)
23#define PMD_MASK (~(PMD_SIZE-1))
24
25/* PGDIR_SHIFT determines what a third-level page table entry can map */
26#define PGDIR_SHIFT (PMD_SHIFT + PMD_INDEX_SIZE)
27#define PGDIR_SIZE (1UL << PGDIR_SHIFT)
28#define PGDIR_MASK (~(PGDIR_SIZE-1))
29
30/* Additional PTE bits (don't change without checking asm in hash_low.S) */
31#define _PAGE_HPTE_SUB 0x0ffff000 /* combo only: sub pages HPTE bits */
32#define _PAGE_HPTE_SUB0 0x08000000 /* combo only: first sub page */
33#define _PAGE_COMBO 0x10000000 /* this is a combo 4k page */
34#define _PAGE_F_SECOND 0x00008000 /* full page: hidx bits */
35#define _PAGE_F_GIX 0x00007000 /* full page: hidx bits */
36
37/* PTE flags to conserve for HPTE identification */
38#define _PAGE_HPTEFLAGS (_PAGE_BUSY | _PAGE_HASHPTE | _PAGE_HPTE_SUB |\
39 _PAGE_COMBO)
40
41/* Shift to put page number into pte.
42 *
43 * That gives us a max RPN of 32 bits, which means a max of 48 bits
44 * of addressable physical space.
45 * We could get 3 more bits here by setting PTE_RPN_SHIFT to 29 but
46 * 32 makes PTEs more readable for debugging for now :)
47 */
48#define PTE_RPN_SHIFT (32)
49#define PTE_RPN_MAX (1UL << (64 - PTE_RPN_SHIFT))
50#define PTE_RPN_MASK (~((1UL<<PTE_RPN_SHIFT)-1))
51
52/* _PAGE_CHG_MASK masks of bits that are to be preserved accross
53 * pgprot changes
54 */
55#define _PAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \
56 _PAGE_ACCESSED)
57
58/* Bits to mask out from a PMD to get to the PTE page */
59#define PMD_MASKED_BITS 0x1ff
60/* Bits to mask out from a PGD/PUD to get to the PMD page */
61#define PUD_MASKED_BITS 0x1ff
62
63#ifndef __ASSEMBLY__
64
65/* Manipulate "rpte" values */
66#define __real_pte(e,p) ((real_pte_t) { \
67 (e), pte_val(*((p) + PTRS_PER_PTE)) })
68#define __rpte_to_hidx(r,index) ((pte_val((r).pte) & _PAGE_COMBO) ? \
69 (((r).hidx >> ((index)<<2)) & 0xf) : ((pte_val((r).pte) >> 12) & 0xf))
70#define __rpte_to_pte(r) ((r).pte)
71#define __rpte_sub_valid(rpte, index) \
72 (pte_val(rpte.pte) & (_PAGE_HPTE_SUB0 >> (index)))
73
74
75/* Trick: we set __end to va + 64k, which happens works for
76 * a 16M page as well as we want only one iteration
77 */
78#define pte_iterate_hashed_subpages(rpte, psize, va, index, shift) \
79 do { \
80 unsigned long __end = va + PAGE_SIZE; \
81 unsigned __split = (psize == MMU_PAGE_4K || \
82 psize == MMU_PAGE_64K_AP); \
83 shift = mmu_psize_defs[psize].shift; \
84 for (index = 0; va < __end; index++, va += (1 << shift)) { \
85 if (!__split || __rpte_sub_valid(rpte, index)) do { \
86
87#define pte_iterate_hashed_end() } while(0); } } while(0)
88
89
90#endif /* __ASSEMBLY__ */
diff --git a/include/asm-powerpc/pgtable.h b/include/asm-powerpc/pgtable.h
new file mode 100644
index 000000000000..0303f57366c1
--- /dev/null
+++ b/include/asm-powerpc/pgtable.h
@@ -0,0 +1,524 @@
1#ifndef _ASM_POWERPC_PGTABLE_H
2#define _ASM_POWERPC_PGTABLE_H
3
4#ifndef CONFIG_PPC64
5#include <asm-ppc/pgtable.h>
6#else
7
8/*
9 * This file contains the functions and defines necessary to modify and use
10 * the ppc64 hashed page table.
11 */
12
13#ifndef __ASSEMBLY__
14#include <linux/config.h>
15#include <linux/stddef.h>
16#include <asm/processor.h> /* For TASK_SIZE */
17#include <asm/mmu.h>
18#include <asm/page.h>
19#include <asm/tlbflush.h>
20struct mm_struct;
21#endif /* __ASSEMBLY__ */
22
23#ifdef CONFIG_PPC_64K_PAGES
24#include <asm/pgtable-64k.h>
25#else
26#include <asm/pgtable-4k.h>
27#endif
28
29#define FIRST_USER_ADDRESS 0
30
31/*
32 * Size of EA range mapped by our pagetables.
33 */
34#define PGTABLE_EADDR_SIZE (PTE_INDEX_SIZE + PMD_INDEX_SIZE + \
35 PUD_INDEX_SIZE + PGD_INDEX_SIZE + PAGE_SHIFT)
36#define PGTABLE_RANGE (1UL << PGTABLE_EADDR_SIZE)
37
38#if TASK_SIZE_USER64 > PGTABLE_RANGE
39#error TASK_SIZE_USER64 exceeds pagetable range
40#endif
41
42#if TASK_SIZE_USER64 > (1UL << (USER_ESID_BITS + SID_SHIFT))
43#error TASK_SIZE_USER64 exceeds user VSID range
44#endif
45
46/*
47 * Define the address range of the vmalloc VM area.
48 */
49#define VMALLOC_START (0xD000000000000000ul)
50#define VMALLOC_SIZE (0x80000000000UL)
51#define VMALLOC_END (VMALLOC_START + VMALLOC_SIZE)
52
53/*
54 * Define the address range of the imalloc VM area.
55 */
56#define PHBS_IO_BASE VMALLOC_END
57#define IMALLOC_BASE (PHBS_IO_BASE + 0x80000000ul) /* Reserve 2 gigs for PHBs */
58#define IMALLOC_END (VMALLOC_START + PGTABLE_RANGE)
59
60/*
61 * Common bits in a linux-style PTE. These match the bits in the
62 * (hardware-defined) PowerPC PTE as closely as possible. Additional
63 * bits may be defined in pgtable-*.h
64 */
65#define _PAGE_PRESENT 0x0001 /* software: pte contains a translation */
66#define _PAGE_USER 0x0002 /* matches one of the PP bits */
67#define _PAGE_FILE 0x0002 /* (!present only) software: pte holds file offset */
68#define _PAGE_EXEC 0x0004 /* No execute on POWER4 and newer (we invert) */
69#define _PAGE_GUARDED 0x0008
70#define _PAGE_COHERENT 0x0010 /* M: enforce memory coherence (SMP systems) */
71#define _PAGE_NO_CACHE 0x0020 /* I: cache inhibit */
72#define _PAGE_WRITETHRU 0x0040 /* W: cache write-through */
73#define _PAGE_DIRTY 0x0080 /* C: page changed */
74#define _PAGE_ACCESSED 0x0100 /* R: page referenced */
75#define _PAGE_RW 0x0200 /* software: user write access allowed */
76#define _PAGE_HASHPTE 0x0400 /* software: pte has an associated HPTE */
77#define _PAGE_BUSY 0x0800 /* software: PTE & hash are busy */
78
79#define _PAGE_BASE (_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_COHERENT)
80
81#define _PAGE_WRENABLE (_PAGE_RW | _PAGE_DIRTY)
82
83/* __pgprot defined in asm-powerpc/page.h */
84#define PAGE_NONE __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED)
85
86#define PAGE_SHARED __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_USER)
87#define PAGE_SHARED_X __pgprot(_PAGE_BASE | _PAGE_RW | _PAGE_USER | _PAGE_EXEC)
88#define PAGE_COPY __pgprot(_PAGE_BASE | _PAGE_USER)
89#define PAGE_COPY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
90#define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER)
91#define PAGE_READONLY_X __pgprot(_PAGE_BASE | _PAGE_USER | _PAGE_EXEC)
92#define PAGE_KERNEL __pgprot(_PAGE_BASE | _PAGE_WRENABLE)
93#define PAGE_KERNEL_CI __pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | \
94 _PAGE_WRENABLE | _PAGE_NO_CACHE | _PAGE_GUARDED)
95#define PAGE_KERNEL_EXEC __pgprot(_PAGE_BASE | _PAGE_WRENABLE | _PAGE_EXEC)
96
97#define PAGE_AGP __pgprot(_PAGE_BASE | _PAGE_WRENABLE | _PAGE_NO_CACHE)
98#define HAVE_PAGE_AGP
99
100/* PTEIDX nibble */
101#define _PTEIDX_SECONDARY 0x8
102#define _PTEIDX_GROUP_IX 0x7
103
104
105/*
106 * POWER4 and newer have per page execute protection, older chips can only
107 * do this on a segment (256MB) basis.
108 *
109 * Also, write permissions imply read permissions.
110 * This is the closest we can get..
111 *
112 * Note due to the way vm flags are laid out, the bits are XWR
113 */
114#define __P000 PAGE_NONE
115#define __P001 PAGE_READONLY
116#define __P010 PAGE_COPY
117#define __P011 PAGE_COPY
118#define __P100 PAGE_READONLY_X
119#define __P101 PAGE_READONLY_X
120#define __P110 PAGE_COPY_X
121#define __P111 PAGE_COPY_X
122
123#define __S000 PAGE_NONE
124#define __S001 PAGE_READONLY
125#define __S010 PAGE_SHARED
126#define __S011 PAGE_SHARED
127#define __S100 PAGE_READONLY_X
128#define __S101 PAGE_READONLY_X
129#define __S110 PAGE_SHARED_X
130#define __S111 PAGE_SHARED_X
131
132#ifndef __ASSEMBLY__
133
134/*
135 * ZERO_PAGE is a global shared page that is always zero: used
136 * for zero-mapped memory areas etc..
137 */
138extern unsigned long empty_zero_page[PAGE_SIZE/sizeof(unsigned long)];
139#define ZERO_PAGE(vaddr) (virt_to_page(empty_zero_page))
140#endif /* __ASSEMBLY__ */
141
142#ifdef CONFIG_HUGETLB_PAGE
143
144#define HAVE_ARCH_UNMAPPED_AREA
145#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
146
147#endif
148
149#ifndef __ASSEMBLY__
150
151/*
152 * Conversion functions: convert a page and protection to a page entry,
153 * and a page entry and page directory to the page they refer to.
154 *
155 * mk_pte takes a (struct page *) as input
156 */
157#define mk_pte(page, pgprot) pfn_pte(page_to_pfn(page), (pgprot))
158
159static inline pte_t pfn_pte(unsigned long pfn, pgprot_t pgprot)
160{
161 pte_t pte;
162
163
164 pte_val(pte) = (pfn << PTE_RPN_SHIFT) | pgprot_val(pgprot);
165 return pte;
166}
167
168#define pte_modify(_pte, newprot) \
169 (__pte((pte_val(_pte) & _PAGE_CHG_MASK) | pgprot_val(newprot)))
170
171#define pte_none(pte) ((pte_val(pte) & ~_PAGE_HPTEFLAGS) == 0)
172#define pte_present(pte) (pte_val(pte) & _PAGE_PRESENT)
173
174/* pte_clear moved to later in this file */
175
176#define pte_pfn(x) ((unsigned long)((pte_val(x)>>PTE_RPN_SHIFT)))
177#define pte_page(x) pfn_to_page(pte_pfn(x))
178
179#define pmd_set(pmdp, pmdval) (pmd_val(*(pmdp)) = (pmdval))
180#define pmd_none(pmd) (!pmd_val(pmd))
181#define pmd_bad(pmd) (pmd_val(pmd) == 0)
182#define pmd_present(pmd) (pmd_val(pmd) != 0)
183#define pmd_clear(pmdp) (pmd_val(*(pmdp)) = 0)
184#define pmd_page_kernel(pmd) (pmd_val(pmd) & ~PMD_MASKED_BITS)
185#define pmd_page(pmd) virt_to_page(pmd_page_kernel(pmd))
186
187#define pud_set(pudp, pudval) (pud_val(*(pudp)) = (pudval))
188#define pud_none(pud) (!pud_val(pud))
189#define pud_bad(pud) ((pud_val(pud)) == 0)
190#define pud_present(pud) (pud_val(pud) != 0)
191#define pud_clear(pudp) (pud_val(*(pudp)) = 0)
192#define pud_page(pud) (pud_val(pud) & ~PUD_MASKED_BITS)
193
194#define pgd_set(pgdp, pudp) ({pgd_val(*(pgdp)) = (unsigned long)(pudp);})
195
196/*
197 * Find an entry in a page-table-directory. We combine the address region
198 * (the high order N bits) and the pgd portion of the address.
199 */
200/* to avoid overflow in free_pgtables we don't use PTRS_PER_PGD here */
201#define pgd_index(address) (((address) >> (PGDIR_SHIFT)) & 0x1ff)
202
203#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
204
205#define pmd_offset(pudp,addr) \
206 (((pmd_t *) pud_page(*(pudp))) + (((addr) >> PMD_SHIFT) & (PTRS_PER_PMD - 1)))
207
208#define pte_offset_kernel(dir,addr) \
209 (((pte_t *) pmd_page_kernel(*(dir))) + (((addr) >> PAGE_SHIFT) & (PTRS_PER_PTE - 1)))
210
211#define pte_offset_map(dir,addr) pte_offset_kernel((dir), (addr))
212#define pte_offset_map_nested(dir,addr) pte_offset_kernel((dir), (addr))
213#define pte_unmap(pte) do { } while(0)
214#define pte_unmap_nested(pte) do { } while(0)
215
216/* to find an entry in a kernel page-table-directory */
217/* This now only contains the vmalloc pages */
218#define pgd_offset_k(address) pgd_offset(&init_mm, address)
219
220/*
221 * The following only work if pte_present() is true.
222 * Undefined behaviour if not..
223 */
224static inline int pte_read(pte_t pte) { return pte_val(pte) & _PAGE_USER;}
225static inline int pte_write(pte_t pte) { return pte_val(pte) & _PAGE_RW;}
226static inline int pte_exec(pte_t pte) { return pte_val(pte) & _PAGE_EXEC;}
227static inline int pte_dirty(pte_t pte) { return pte_val(pte) & _PAGE_DIRTY;}
228static inline int pte_young(pte_t pte) { return pte_val(pte) & _PAGE_ACCESSED;}
229static inline int pte_file(pte_t pte) { return pte_val(pte) & _PAGE_FILE;}
230
231static inline void pte_uncache(pte_t pte) { pte_val(pte) |= _PAGE_NO_CACHE; }
232static inline void pte_cache(pte_t pte) { pte_val(pte) &= ~_PAGE_NO_CACHE; }
233
234static inline pte_t pte_rdprotect(pte_t pte) {
235 pte_val(pte) &= ~_PAGE_USER; return pte; }
236static inline pte_t pte_exprotect(pte_t pte) {
237 pte_val(pte) &= ~_PAGE_EXEC; return pte; }
238static inline pte_t pte_wrprotect(pte_t pte) {
239 pte_val(pte) &= ~(_PAGE_RW); return pte; }
240static inline pte_t pte_mkclean(pte_t pte) {
241 pte_val(pte) &= ~(_PAGE_DIRTY); return pte; }
242static inline pte_t pte_mkold(pte_t pte) {
243 pte_val(pte) &= ~_PAGE_ACCESSED; return pte; }
244static inline pte_t pte_mkread(pte_t pte) {
245 pte_val(pte) |= _PAGE_USER; return pte; }
246static inline pte_t pte_mkexec(pte_t pte) {
247 pte_val(pte) |= _PAGE_USER | _PAGE_EXEC; return pte; }
248static inline pte_t pte_mkwrite(pte_t pte) {
249 pte_val(pte) |= _PAGE_RW; return pte; }
250static inline pte_t pte_mkdirty(pte_t pte) {
251 pte_val(pte) |= _PAGE_DIRTY; return pte; }
252static inline pte_t pte_mkyoung(pte_t pte) {
253 pte_val(pte) |= _PAGE_ACCESSED; return pte; }
254static inline pte_t pte_mkhuge(pte_t pte) {
255 return pte; }
256
257/* Atomic PTE updates */
258static inline unsigned long pte_update(pte_t *p, unsigned long clr)
259{
260 unsigned long old, tmp;
261
262 __asm__ __volatile__(
263 "1: ldarx %0,0,%3 # pte_update\n\
264 andi. %1,%0,%6\n\
265 bne- 1b \n\
266 andc %1,%0,%4 \n\
267 stdcx. %1,0,%3 \n\
268 bne- 1b"
269 : "=&r" (old), "=&r" (tmp), "=m" (*p)
270 : "r" (p), "r" (clr), "m" (*p), "i" (_PAGE_BUSY)
271 : "cc" );
272 return old;
273}
274
275/* PTE updating functions, this function puts the PTE in the
276 * batch, doesn't actually triggers the hash flush immediately,
277 * you need to call flush_tlb_pending() to do that.
278 * Pass -1 for "normal" size (4K or 64K)
279 */
280extern void hpte_update(struct mm_struct *mm, unsigned long addr,
281 pte_t *ptep, unsigned long pte, int huge);
282
283static inline int __ptep_test_and_clear_young(struct mm_struct *mm,
284 unsigned long addr, pte_t *ptep)
285{
286 unsigned long old;
287
288 if ((pte_val(*ptep) & (_PAGE_ACCESSED | _PAGE_HASHPTE)) == 0)
289 return 0;
290 old = pte_update(ptep, _PAGE_ACCESSED);
291 if (old & _PAGE_HASHPTE) {
292 hpte_update(mm, addr, ptep, old, 0);
293 flush_tlb_pending();
294 }
295 return (old & _PAGE_ACCESSED) != 0;
296}
297#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG
298#define ptep_test_and_clear_young(__vma, __addr, __ptep) \
299({ \
300 int __r; \
301 __r = __ptep_test_and_clear_young((__vma)->vm_mm, __addr, __ptep); \
302 __r; \
303})
304
305/*
306 * On RW/DIRTY bit transitions we can avoid flushing the hpte. For the
307 * moment we always flush but we need to fix hpte_update and test if the
308 * optimisation is worth it.
309 */
310static inline int __ptep_test_and_clear_dirty(struct mm_struct *mm,
311 unsigned long addr, pte_t *ptep)
312{
313 unsigned long old;
314
315 if ((pte_val(*ptep) & _PAGE_DIRTY) == 0)
316 return 0;
317 old = pte_update(ptep, _PAGE_DIRTY);
318 if (old & _PAGE_HASHPTE)
319 hpte_update(mm, addr, ptep, old, 0);
320 return (old & _PAGE_DIRTY) != 0;
321}
322#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_DIRTY
323#define ptep_test_and_clear_dirty(__vma, __addr, __ptep) \
324({ \
325 int __r; \
326 __r = __ptep_test_and_clear_dirty((__vma)->vm_mm, __addr, __ptep); \
327 __r; \
328})
329
330#define __HAVE_ARCH_PTEP_SET_WRPROTECT
331static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addr,
332 pte_t *ptep)
333{
334 unsigned long old;
335
336 if ((pte_val(*ptep) & _PAGE_RW) == 0)
337 return;
338 old = pte_update(ptep, _PAGE_RW);
339 if (old & _PAGE_HASHPTE)
340 hpte_update(mm, addr, ptep, old, 0);
341}
342
343/*
344 * We currently remove entries from the hashtable regardless of whether
345 * the entry was young or dirty. The generic routines only flush if the
346 * entry was young or dirty which is not good enough.
347 *
348 * We should be more intelligent about this but for the moment we override
349 * these functions and force a tlb flush unconditionally
350 */
351#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH
352#define ptep_clear_flush_young(__vma, __address, __ptep) \
353({ \
354 int __young = __ptep_test_and_clear_young((__vma)->vm_mm, __address, \
355 __ptep); \
356 __young; \
357})
358
359#define __HAVE_ARCH_PTEP_CLEAR_DIRTY_FLUSH
360#define ptep_clear_flush_dirty(__vma, __address, __ptep) \
361({ \
362 int __dirty = __ptep_test_and_clear_dirty((__vma)->vm_mm, __address, \
363 __ptep); \
364 flush_tlb_page(__vma, __address); \
365 __dirty; \
366})
367
368#define __HAVE_ARCH_PTEP_GET_AND_CLEAR
369static inline pte_t ptep_get_and_clear(struct mm_struct *mm,
370 unsigned long addr, pte_t *ptep)
371{
372 unsigned long old = pte_update(ptep, ~0UL);
373
374 if (old & _PAGE_HASHPTE)
375 hpte_update(mm, addr, ptep, old, 0);
376 return __pte(old);
377}
378
379static inline void pte_clear(struct mm_struct *mm, unsigned long addr,
380 pte_t * ptep)
381{
382 unsigned long old = pte_update(ptep, ~0UL);
383
384 if (old & _PAGE_HASHPTE)
385 hpte_update(mm, addr, ptep, old, 0);
386}
387
388/*
389 * set_pte stores a linux PTE into the linux page table.
390 */
391static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
392 pte_t *ptep, pte_t pte)
393{
394 if (pte_present(*ptep)) {
395 pte_clear(mm, addr, ptep);
396 flush_tlb_pending();
397 }
398 pte = __pte(pte_val(pte) & ~_PAGE_HPTEFLAGS);
399
400#ifdef CONFIG_PPC_64K_PAGES
401 if (mmu_virtual_psize != MMU_PAGE_64K)
402 pte = __pte(pte_val(pte) | _PAGE_COMBO);
403#endif /* CONFIG_PPC_64K_PAGES */
404
405 *ptep = pte;
406}
407
408/* Set the dirty and/or accessed bits atomically in a linux PTE, this
409 * function doesn't need to flush the hash entry
410 */
411#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS
412static inline void __ptep_set_access_flags(pte_t *ptep, pte_t entry, int dirty)
413{
414 unsigned long bits = pte_val(entry) &
415 (_PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_RW | _PAGE_EXEC);
416 unsigned long old, tmp;
417
418 __asm__ __volatile__(
419 "1: ldarx %0,0,%4\n\
420 andi. %1,%0,%6\n\
421 bne- 1b \n\
422 or %0,%3,%0\n\
423 stdcx. %0,0,%4\n\
424 bne- 1b"
425 :"=&r" (old), "=&r" (tmp), "=m" (*ptep)
426 :"r" (bits), "r" (ptep), "m" (*ptep), "i" (_PAGE_BUSY)
427 :"cc");
428}
429#define ptep_set_access_flags(__vma, __address, __ptep, __entry, __dirty) \
430 do { \
431 __ptep_set_access_flags(__ptep, __entry, __dirty); \
432 flush_tlb_page_nohash(__vma, __address); \
433 } while(0)
434
435/*
436 * Macro to mark a page protection value as "uncacheable".
437 */
438#define pgprot_noncached(prot) (__pgprot(pgprot_val(prot) | _PAGE_NO_CACHE | _PAGE_GUARDED))
439
440struct file;
441extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
442 unsigned long size, pgprot_t vma_prot);
443#define __HAVE_PHYS_MEM_ACCESS_PROT
444
445#define __HAVE_ARCH_PTE_SAME
446#define pte_same(A,B) (((pte_val(A) ^ pte_val(B)) & ~_PAGE_HPTEFLAGS) == 0)
447
448#define pte_ERROR(e) \
449 printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))
450#define pmd_ERROR(e) \
451 printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e))
452#define pgd_ERROR(e) \
453 printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))
454
455extern pgd_t swapper_pg_dir[];
456
457extern void paging_init(void);
458
459#ifdef CONFIG_HUGETLB_PAGE
460#define hugetlb_free_pgd_range(tlb, addr, end, floor, ceiling) \
461 free_pgd_range(tlb, addr, end, floor, ceiling)
462#endif
463
464/*
465 * This gets called at the end of handling a page fault, when
466 * the kernel has put a new PTE into the page table for the process.
467 * We use it to put a corresponding HPTE into the hash table
468 * ahead of time, instead of waiting for the inevitable extra
469 * hash-table miss exception.
470 */
471struct vm_area_struct;
472extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
473
474/* Encode and de-code a swap entry */
475#define __swp_type(entry) (((entry).val >> 1) & 0x3f)
476#define __swp_offset(entry) ((entry).val >> 8)
477#define __swp_entry(type, offset) ((swp_entry_t){((type)<< 1)|((offset)<<8)})
478#define __pte_to_swp_entry(pte) ((swp_entry_t){pte_val(pte) >> PTE_RPN_SHIFT})
479#define __swp_entry_to_pte(x) ((pte_t) { (x).val << PTE_RPN_SHIFT })
480#define pte_to_pgoff(pte) (pte_val(pte) >> PTE_RPN_SHIFT)
481#define pgoff_to_pte(off) ((pte_t) {((off) << PTE_RPN_SHIFT)|_PAGE_FILE})
482#define PTE_FILE_MAX_BITS (BITS_PER_LONG - PTE_RPN_SHIFT)
483
484/*
485 * kern_addr_valid is intended to indicate whether an address is a valid
486 * kernel address. Most 32-bit archs define it as always true (like this)
487 * but most 64-bit archs actually perform a test. What should we do here?
488 * The only use is in fs/ncpfs/dir.c
489 */
490#define kern_addr_valid(addr) (1)
491
492#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
493 remap_pfn_range(vma, vaddr, pfn, size, prot)
494
495void pgtable_cache_init(void);
496
497/*
498 * find_linux_pte returns the address of a linux pte for a given
499 * effective address and directory. If not found, it returns zero.
500 */static inline pte_t *find_linux_pte(pgd_t *pgdir, unsigned long ea)
501{
502 pgd_t *pg;
503 pud_t *pu;
504 pmd_t *pm;
505 pte_t *pt = NULL;
506
507 pg = pgdir + pgd_index(ea);
508 if (!pgd_none(*pg)) {
509 pu = pud_offset(pg, ea);
510 if (!pud_none(*pu)) {
511 pm = pmd_offset(pu, ea);
512 if (pmd_present(*pm))
513 pt = pte_offset_kernel(pm, ea);
514 }
515 }
516 return pt;
517}
518
519#include <asm-generic/pgtable.h>
520
521#endif /* __ASSEMBLY__ */
522
523#endif /* CONFIG_PPC64 */
524#endif /* _ASM_POWERPC_PGTABLE_H */
diff --git a/include/asm-powerpc/pmac_feature.h b/include/asm-powerpc/pmac_feature.h
new file mode 100644
index 000000000000..e9683bcff19b
--- /dev/null
+++ b/include/asm-powerpc/pmac_feature.h
@@ -0,0 +1,380 @@
1/*
2 * Definition of platform feature hooks for PowerMacs
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1998 Paul Mackerras &
9 * Ben. Herrenschmidt.
10 *
11 *
12 * Note: I removed media-bay details from the feature stuff, I believe it's
13 * not worth it, the media-bay driver can directly use the mac-io
14 * ASIC registers.
15 *
16 * Implementation note: Currently, none of these functions will block.
17 * However, they may internally protect themselves with a spinlock
18 * for way too long. Be prepared for at least some of these to block
19 * in the future.
20 *
21 * Unless specifically defined, the result code is assumed to be an
22 * error when negative, 0 is the default success result. Some functions
23 * may return additional positive result values.
24 *
25 * To keep implementation simple, all feature calls are assumed to have
26 * the prototype parameters (struct device_node* node, int value).
27 * When either is not used, pass 0.
28 */
29
30#ifdef __KERNEL__
31#ifndef __PPC_ASM_PMAC_FEATURE_H
32#define __PPC_ASM_PMAC_FEATURE_H
33
34#include <asm/macio.h>
35#include <asm/machdep.h>
36
37/*
38 * Known Mac motherboard models
39 *
40 * Please, report any error here to benh@kernel.crashing.org, thanks !
41 *
42 * Note that I don't fully maintain this list for Core99 & MacRISC2
43 * and I'm considering removing all NewWorld entries from it and
44 * entirely rely on the model string.
45 */
46
47/* PowerSurge are the first generation of PCI Pmacs. This include
48 * all of the Grand-Central based machines. We currently don't
49 * differenciate most of them.
50 */
51#define PMAC_TYPE_PSURGE 0x10 /* PowerSurge */
52#define PMAC_TYPE_ANS 0x11 /* Apple Network Server */
53
54/* Here is the infamous serie of OHare based machines
55 */
56#define PMAC_TYPE_COMET 0x20 /* Beleived to be PowerBook 2400 */
57#define PMAC_TYPE_HOOPER 0x21 /* Beleived to be PowerBook 3400 */
58#define PMAC_TYPE_KANGA 0x22 /* PowerBook 3500 (first G3) */
59#define PMAC_TYPE_ALCHEMY 0x23 /* Alchemy motherboard base */
60#define PMAC_TYPE_GAZELLE 0x24 /* Spartacus, some 5xxx/6xxx */
61#define PMAC_TYPE_UNKNOWN_OHARE 0x2f /* Unknown, but OHare based */
62
63/* Here are the Heathrow based machines
64 * FIXME: Differenciate wallstreet,mainstreet,wallstreetII
65 */
66#define PMAC_TYPE_GOSSAMER 0x30 /* Gossamer motherboard */
67#define PMAC_TYPE_SILK 0x31 /* Desktop PowerMac G3 */
68#define PMAC_TYPE_WALLSTREET 0x32 /* Wallstreet/Mainstreet PowerBook*/
69#define PMAC_TYPE_UNKNOWN_HEATHROW 0x3f /* Unknown but heathrow based */
70
71/* Here are newworld machines based on Paddington (heathrow derivative)
72 */
73#define PMAC_TYPE_101_PBOOK 0x40 /* 101 PowerBook (aka Lombard) */
74#define PMAC_TYPE_ORIG_IMAC 0x41 /* First generation iMac */
75#define PMAC_TYPE_YOSEMITE 0x42 /* B&W G3 */
76#define PMAC_TYPE_YIKES 0x43 /* Yikes G4 (PCI graphics) */
77#define PMAC_TYPE_UNKNOWN_PADDINGTON 0x4f /* Unknown but paddington based */
78
79/* Core99 machines based on UniNorth 1.0 and 1.5
80 *
81 * Note: A single entry here may cover several actual models according
82 * to the device-tree. (Sawtooth is most tower G4s, FW_IMAC is most
83 * FireWire based iMacs, etc...). Those machines are too similar to be
84 * distinguished here, when they need to be differencied, use the
85 * device-tree "model" or "compatible" property.
86 */
87#define PMAC_TYPE_ORIG_IBOOK 0x40 /* First iBook model (no firewire) */
88#define PMAC_TYPE_SAWTOOTH 0x41 /* Desktop G4s */
89#define PMAC_TYPE_FW_IMAC 0x42 /* FireWire iMacs (except Pangea based) */
90#define PMAC_TYPE_FW_IBOOK 0x43 /* FireWire iBooks (except iBook2) */
91#define PMAC_TYPE_CUBE 0x44 /* Cube PowerMac */
92#define PMAC_TYPE_QUICKSILVER 0x45 /* QuickSilver G4s */
93#define PMAC_TYPE_PISMO 0x46 /* Pismo PowerBook */
94#define PMAC_TYPE_TITANIUM 0x47 /* Titanium PowerBook */
95#define PMAC_TYPE_TITANIUM2 0x48 /* Titanium II PowerBook (no L3, M6) */
96#define PMAC_TYPE_TITANIUM3 0x49 /* Titanium III PowerBook (with L3 & M7) */
97#define PMAC_TYPE_TITANIUM4 0x50 /* Titanium IV PowerBook (with L3 & M9) */
98#define PMAC_TYPE_EMAC 0x50 /* eMac */
99#define PMAC_TYPE_UNKNOWN_CORE99 0x5f
100
101/* MacRisc2 with UniNorth 2.0 */
102#define PMAC_TYPE_RACKMAC 0x80 /* XServe */
103#define PMAC_TYPE_WINDTUNNEL 0x81
104
105/* MacRISC2 machines based on the Pangea chipset
106 */
107#define PMAC_TYPE_PANGEA_IMAC 0x100 /* Flower Power iMac */
108#define PMAC_TYPE_IBOOK2 0x101 /* iBook2 (polycarbonate) */
109#define PMAC_TYPE_FLAT_PANEL_IMAC 0x102 /* Flat panel iMac */
110#define PMAC_TYPE_UNKNOWN_PANGEA 0x10f
111
112/* MacRISC2 machines based on the Intrepid chipset
113 */
114#define PMAC_TYPE_UNKNOWN_INTREPID 0x11f /* Generic */
115
116/* MacRISC4 / G5 machines. We don't have per-machine selection here anymore,
117 * but rather machine families
118 */
119#define PMAC_TYPE_POWERMAC_G5 0x150 /* U3 & U3H based */
120#define PMAC_TYPE_POWERMAC_G5_U3L 0x151 /* U3L based desktop */
121#define PMAC_TYPE_IMAC_G5 0x152 /* iMac G5 */
122#define PMAC_TYPE_XSERVE_G5 0x153 /* Xserve G5 */
123#define PMAC_TYPE_UNKNOWN_K2 0x19f /* Any other K2 based */
124
125/*
126 * Motherboard flags
127 */
128
129#define PMAC_MB_CAN_SLEEP 0x00000001
130#define PMAC_MB_HAS_FW_POWER 0x00000002
131#define PMAC_MB_OLD_CORE99 0x00000004
132#define PMAC_MB_MOBILE 0x00000008
133#define PMAC_MB_MAY_SLEEP 0x00000010
134
135/*
136 * Feature calls supported on pmac
137 *
138 */
139
140/*
141 * Use this inline wrapper
142 */
143struct device_node;
144
145static inline long pmac_call_feature(int selector, struct device_node* node,
146 long param, long value)
147{
148 if (!ppc_md.feature_call)
149 return -ENODEV;
150 return ppc_md.feature_call(selector, node, param, value);
151}
152
153/* PMAC_FTR_SERIAL_ENABLE (struct device_node* node, int param, int value)
154 * enable/disable an SCC side. Pass the node corresponding to the
155 * channel side as a parameter.
156 * param is the type of port
157 * if param is ored with PMAC_SCC_FLAG_XMON, then the SCC is locked enabled
158 * for use by xmon.
159 */
160#define PMAC_FTR_SCC_ENABLE PMAC_FTR_DEF(0)
161 #define PMAC_SCC_ASYNC 0
162 #define PMAC_SCC_IRDA 1
163 #define PMAC_SCC_I2S1 2
164 #define PMAC_SCC_FLAG_XMON 0x00001000
165
166/* PMAC_FTR_MODEM_ENABLE (struct device_node* node, 0, int value)
167 * enable/disable the internal modem.
168 */
169#define PMAC_FTR_MODEM_ENABLE PMAC_FTR_DEF(1)
170
171/* PMAC_FTR_SWIM3_ENABLE (struct device_node* node, 0,int value)
172 * enable/disable the swim3 (floppy) cell of a mac-io ASIC
173 */
174#define PMAC_FTR_SWIM3_ENABLE PMAC_FTR_DEF(2)
175
176/* PMAC_FTR_MESH_ENABLE (struct device_node* node, 0, int value)
177 * enable/disable the mesh (scsi) cell of a mac-io ASIC
178 */
179#define PMAC_FTR_MESH_ENABLE PMAC_FTR_DEF(3)
180
181/* PMAC_FTR_IDE_ENABLE (struct device_node* node, int busID, int value)
182 * enable/disable an IDE port of a mac-io ASIC
183 * pass the busID parameter
184 */
185#define PMAC_FTR_IDE_ENABLE PMAC_FTR_DEF(4)
186
187/* PMAC_FTR_IDE_RESET (struct device_node* node, int busID, int value)
188 * assert(1)/release(0) an IDE reset line (mac-io IDE only)
189 */
190#define PMAC_FTR_IDE_RESET PMAC_FTR_DEF(5)
191
192/* PMAC_FTR_BMAC_ENABLE (struct device_node* node, 0, int value)
193 * enable/disable the bmac (ethernet) cell of a mac-io ASIC, also drive
194 * it's reset line
195 */
196#define PMAC_FTR_BMAC_ENABLE PMAC_FTR_DEF(6)
197
198/* PMAC_FTR_GMAC_ENABLE (struct device_node* node, 0, int value)
199 * enable/disable the gmac (ethernet) cell of an uninorth ASIC. This
200 * control the cell's clock.
201 */
202#define PMAC_FTR_GMAC_ENABLE PMAC_FTR_DEF(7)
203
204/* PMAC_FTR_GMAC_PHY_RESET (struct device_node* node, 0, 0)
205 * Perform a HW reset of the PHY connected to a gmac controller.
206 * Pass the gmac device node, not the PHY node.
207 */
208#define PMAC_FTR_GMAC_PHY_RESET PMAC_FTR_DEF(8)
209
210/* PMAC_FTR_SOUND_CHIP_ENABLE (struct device_node* node, 0, int value)
211 * enable/disable the sound chip, whatever it is and provided it can
212 * acually be controlled
213 */
214#define PMAC_FTR_SOUND_CHIP_ENABLE PMAC_FTR_DEF(9)
215
216/* -- add various tweaks related to sound routing -- */
217
218/* PMAC_FTR_AIRPORT_ENABLE (struct device_node* node, 0, int value)
219 * enable/disable the airport card
220 */
221#define PMAC_FTR_AIRPORT_ENABLE PMAC_FTR_DEF(10)
222
223/* PMAC_FTR_RESET_CPU (NULL, int cpu_nr, 0)
224 * toggle the reset line of a CPU on an uninorth-based SMP machine
225 */
226#define PMAC_FTR_RESET_CPU PMAC_FTR_DEF(11)
227
228/* PMAC_FTR_USB_ENABLE (struct device_node* node, 0, int value)
229 * enable/disable an USB cell, along with the power of the USB "pad"
230 * on keylargo based machines
231 */
232#define PMAC_FTR_USB_ENABLE PMAC_FTR_DEF(12)
233
234/* PMAC_FTR_1394_ENABLE (struct device_node* node, 0, int value)
235 * enable/disable the firewire cell of an uninorth ASIC.
236 */
237#define PMAC_FTR_1394_ENABLE PMAC_FTR_DEF(13)
238
239/* PMAC_FTR_1394_CABLE_POWER (struct device_node* node, 0, int value)
240 * enable/disable the firewire cable power supply of the uninorth
241 * firewire cell
242 */
243#define PMAC_FTR_1394_CABLE_POWER PMAC_FTR_DEF(14)
244
245/* PMAC_FTR_SLEEP_STATE (struct device_node* node, 0, int value)
246 * set the sleep state of the motherboard.
247 *
248 * Pass -1 as value to query for sleep capability
249 * Pass 1 to set IOs to sleep
250 * Pass 0 to set IOs to wake
251 */
252#define PMAC_FTR_SLEEP_STATE PMAC_FTR_DEF(15)
253
254/* PMAC_FTR_GET_MB_INFO (NULL, selector, 0)
255 *
256 * returns some motherboard infos.
257 * selector: 0 - model id
258 * 1 - model flags (capabilities)
259 * 2 - model name (cast to const char *)
260 */
261#define PMAC_FTR_GET_MB_INFO PMAC_FTR_DEF(16)
262#define PMAC_MB_INFO_MODEL 0
263#define PMAC_MB_INFO_FLAGS 1
264#define PMAC_MB_INFO_NAME 2
265
266/* PMAC_FTR_READ_GPIO (NULL, int index, 0)
267 *
268 * read a GPIO from a mac-io controller of type KeyLargo or Pangea.
269 * the value returned is a byte (positive), or a negative error code
270 */
271#define PMAC_FTR_READ_GPIO PMAC_FTR_DEF(17)
272
273/* PMAC_FTR_WRITE_GPIO (NULL, int index, int value)
274 *
275 * write a GPIO of a mac-io controller of type KeyLargo or Pangea.
276 */
277#define PMAC_FTR_WRITE_GPIO PMAC_FTR_DEF(18)
278
279/* PMAC_FTR_ENABLE_MPIC
280 *
281 * Enable the MPIC cell
282 */
283#define PMAC_FTR_ENABLE_MPIC PMAC_FTR_DEF(19)
284
285/* PMAC_FTR_AACK_DELAY_ENABLE (NULL, int enable, 0)
286 *
287 * Enable/disable the AACK delay on the northbridge for systems using DFS
288 */
289#define PMAC_FTR_AACK_DELAY_ENABLE PMAC_FTR_DEF(20)
290
291/* PMAC_FTR_DEVICE_CAN_WAKE
292 *
293 * Used by video drivers to inform system that they can actually perform
294 * wakeup from sleep
295 */
296#define PMAC_FTR_DEVICE_CAN_WAKE PMAC_FTR_DEF(22)
297
298
299/* Don't use those directly, they are for the sake of pmac_setup.c */
300extern long pmac_do_feature_call(unsigned int selector, ...);
301extern void pmac_feature_init(void);
302
303/* Video suspend tweak */
304extern void pmac_set_early_video_resume(void (*proc)(void *data), void *data);
305extern void pmac_call_early_video_resume(void);
306
307#define PMAC_FTR_DEF(x) ((_MACH_Pmac << 16) | (x))
308
309/* The AGP driver registers itself here */
310extern void pmac_register_agp_pm(struct pci_dev *bridge,
311 int (*suspend)(struct pci_dev *bridge),
312 int (*resume)(struct pci_dev *bridge));
313
314/* Those are meant to be used by video drivers to deal with AGP
315 * suspend resume properly
316 */
317extern void pmac_suspend_agp_for_card(struct pci_dev *dev);
318extern void pmac_resume_agp_for_card(struct pci_dev *dev);
319
320/* Used by the via-pmu driver for suspend/resume
321 */
322extern void pmac_tweak_clock_spreading(int enable);
323
324/*
325 * The part below is for use by macio_asic.c only, do not rely
326 * on the data structures or constants below in a normal driver
327 *
328 */
329
330#define MAX_MACIO_CHIPS 2
331
332enum {
333 macio_unknown = 0,
334 macio_grand_central,
335 macio_ohare,
336 macio_ohareII,
337 macio_heathrow,
338 macio_gatwick,
339 macio_paddington,
340 macio_keylargo,
341 macio_pangea,
342 macio_intrepid,
343 macio_keylargo2,
344};
345
346struct macio_chip
347{
348 struct device_node *of_node;
349 int type;
350 const char *name;
351 int rev;
352 volatile u32 __iomem *base;
353 unsigned long flags;
354
355 /* For use by macio_asic PCI driver */
356 struct macio_bus lbus;
357};
358
359extern struct macio_chip macio_chips[MAX_MACIO_CHIPS];
360
361#define MACIO_FLAG_SCCA_ON 0x00000001
362#define MACIO_FLAG_SCCB_ON 0x00000002
363#define MACIO_FLAG_SCC_LOCKED 0x00000004
364#define MACIO_FLAG_AIRPORT_ON 0x00000010
365#define MACIO_FLAG_FW_SUPPORTED 0x00000020
366
367extern struct macio_chip* macio_find(struct device_node* child, int type);
368
369#define MACIO_FCR32(macio, r) ((macio)->base + ((r) >> 2))
370#define MACIO_FCR8(macio, r) (((volatile u8 __iomem *)((macio)->base)) + (r))
371
372#define MACIO_IN32(r) (in_le32(MACIO_FCR32(macio,r)))
373#define MACIO_OUT32(r,v) (out_le32(MACIO_FCR32(macio,r), (v)))
374#define MACIO_BIS(r,v) (MACIO_OUT32((r), MACIO_IN32(r) | (v)))
375#define MACIO_BIC(r,v) (MACIO_OUT32((r), MACIO_IN32(r) & ~(v)))
376#define MACIO_IN8(r) (in_8(MACIO_FCR8(macio,r)))
377#define MACIO_OUT8(r,v) (out_8(MACIO_FCR8(macio,r), (v)))
378
379#endif /* __PPC_ASM_PMAC_FEATURE_H */
380#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/pmac_low_i2c.h b/include/asm-powerpc/pmac_low_i2c.h
new file mode 100644
index 000000000000..809a5963d5e7
--- /dev/null
+++ b/include/asm-powerpc/pmac_low_i2c.h
@@ -0,0 +1,43 @@
1/*
2 * include/asm-ppc/pmac_low_i2c.h
3 *
4 * Copyright (C) 2003 Ben. Herrenschmidt (benh@kernel.crashing.org)
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 __PMAC_LOW_I2C_H__
13#define __PMAC_LOW_I2C_H__
14
15/* i2c mode (based on the platform functions format) */
16enum {
17 pmac_low_i2c_mode_dumb = 1,
18 pmac_low_i2c_mode_std = 2,
19 pmac_low_i2c_mode_stdsub = 3,
20 pmac_low_i2c_mode_combined = 4,
21};
22
23/* RW bit in address */
24enum {
25 pmac_low_i2c_read = 0x01,
26 pmac_low_i2c_write = 0x00
27};
28
29/* Init, called early during boot */
30extern void pmac_init_low_i2c(void);
31
32/* Locking functions exposed to i2c-keywest */
33int pmac_low_i2c_lock(struct device_node *np);
34int pmac_low_i2c_unlock(struct device_node *np);
35
36/* Access functions for platform code */
37int pmac_low_i2c_open(struct device_node *np, int channel);
38int pmac_low_i2c_close(struct device_node *np);
39int pmac_low_i2c_setmode(struct device_node *np, int mode);
40int pmac_low_i2c_xfer(struct device_node *np, u8 addrdir, u8 subaddr, u8 *data, int len);
41
42
43#endif /* __PMAC_LOW_I2C_H__ */
diff --git a/include/asm-powerpc/pmc.h b/include/asm-powerpc/pmc.h
new file mode 100644
index 000000000000..5f41f3a2b293
--- /dev/null
+++ b/include/asm-powerpc/pmc.h
@@ -0,0 +1,47 @@
1/*
2 * pmc.h
3 * Copyright (C) 2004 David Gibson, IBM Corporation
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef _POWERPC_PMC_H
20#define _POWERPC_PMC_H
21
22#include <asm/ptrace.h>
23
24typedef void (*perf_irq_t)(struct pt_regs *);
25extern perf_irq_t perf_irq;
26
27int reserve_pmc_hardware(perf_irq_t new_perf_irq);
28void release_pmc_hardware(void);
29
30#ifdef CONFIG_PPC64
31void power4_enable_pmcs(void);
32#endif
33
34#ifdef CONFIG_FSL_BOOKE
35void init_pmc_stop(int ctr);
36void set_pmc_event(int ctr, int event);
37void set_pmc_user_kernel(int ctr, int user, int kernel);
38void set_pmc_marked(int ctr, int mark0, int mark1);
39void pmc_start_ctr(int ctr, int enable);
40void pmc_start_ctrs(int enable);
41void pmc_stop_ctrs(void);
42void dump_pmcs(void);
43
44extern struct op_powerpc_model op_model_fsl_booke;
45#endif
46
47#endif /* _POWERPC_PMC_H */
diff --git a/include/asm-powerpc/posix_types.h b/include/asm-powerpc/posix_types.h
new file mode 100644
index 000000000000..c6391077224f
--- /dev/null
+++ b/include/asm-powerpc/posix_types.h
@@ -0,0 +1,129 @@
1#ifndef _ASM_POWERPC_POSIX_TYPES_H
2#define _ASM_POWERPC_POSIX_TYPES_H
3
4/*
5 * This file is generally used by user-level software, so you need to
6 * be a little careful about namespace pollution etc. Also, we cannot
7 * assume GCC is being used.
8 */
9
10typedef unsigned long __kernel_ino_t;
11typedef unsigned int __kernel_mode_t;
12typedef long __kernel_off_t;
13typedef int __kernel_pid_t;
14typedef unsigned int __kernel_uid_t;
15typedef unsigned int __kernel_gid_t;
16typedef long __kernel_ptrdiff_t;
17typedef long __kernel_time_t;
18typedef long __kernel_clock_t;
19typedef int __kernel_timer_t;
20typedef int __kernel_clockid_t;
21typedef long __kernel_suseconds_t;
22typedef int __kernel_daddr_t;
23typedef char * __kernel_caddr_t;
24typedef unsigned short __kernel_uid16_t;
25typedef unsigned short __kernel_gid16_t;
26typedef unsigned int __kernel_uid32_t;
27typedef unsigned int __kernel_gid32_t;
28typedef unsigned int __kernel_old_uid_t;
29typedef unsigned int __kernel_old_gid_t;
30
31#ifdef __powerpc64__
32typedef unsigned long __kernel_nlink_t;
33typedef int __kernel_ipc_pid_t;
34typedef unsigned long __kernel_size_t;
35typedef long __kernel_ssize_t;
36typedef unsigned long __kernel_old_dev_t;
37#else
38typedef unsigned short __kernel_nlink_t;
39typedef short __kernel_ipc_pid_t;
40typedef unsigned int __kernel_size_t;
41typedef int __kernel_ssize_t;
42typedef unsigned int __kernel_old_dev_t;
43#endif
44
45#ifdef __powerpc64__
46typedef long long __kernel_loff_t;
47#else
48#ifdef __GNUC__
49typedef long long __kernel_loff_t;
50#endif
51#endif
52
53typedef struct {
54 int val[2];
55} __kernel_fsid_t;
56
57#ifndef __GNUC__
58
59#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
60#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
61#define __FD_ISSET(d, set) (((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) != 0)
62#define __FD_ZERO(set) \
63 ((void) memset ((__ptr_t) (set), 0, sizeof (__kernel_fd_set)))
64
65#else /* __GNUC__ */
66
67#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) \
68 || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 0)
69/* With GNU C, use inline functions instead so args are evaluated only once: */
70
71#undef __FD_SET
72static __inline__ void __FD_SET(unsigned long fd, __kernel_fd_set *fdsetp)
73{
74 unsigned long _tmp = fd / __NFDBITS;
75 unsigned long _rem = fd % __NFDBITS;
76 fdsetp->fds_bits[_tmp] |= (1UL<<_rem);
77}
78
79#undef __FD_CLR
80static __inline__ void __FD_CLR(unsigned long fd, __kernel_fd_set *fdsetp)
81{
82 unsigned long _tmp = fd / __NFDBITS;
83 unsigned long _rem = fd % __NFDBITS;
84 fdsetp->fds_bits[_tmp] &= ~(1UL<<_rem);
85}
86
87#undef __FD_ISSET
88static __inline__ int __FD_ISSET(unsigned long fd, __kernel_fd_set *p)
89{
90 unsigned long _tmp = fd / __NFDBITS;
91 unsigned long _rem = fd % __NFDBITS;
92 return (p->fds_bits[_tmp] & (1UL<<_rem)) != 0;
93}
94
95/*
96 * This will unroll the loop for the normal constant case (8 ints,
97 * for a 256-bit fd_set)
98 */
99#undef __FD_ZERO
100static __inline__ void __FD_ZERO(__kernel_fd_set *p)
101{
102 unsigned long *tmp = (unsigned long *)p->fds_bits;
103 int i;
104
105 if (__builtin_constant_p(__FDSET_LONGS)) {
106 switch (__FDSET_LONGS) {
107 case 16:
108 tmp[12] = 0; tmp[13] = 0; tmp[14] = 0; tmp[15] = 0;
109 tmp[ 8] = 0; tmp[ 9] = 0; tmp[10] = 0; tmp[11] = 0;
110
111 case 8:
112 tmp[ 4] = 0; tmp[ 5] = 0; tmp[ 6] = 0; tmp[ 7] = 0;
113
114 case 4:
115 tmp[ 0] = 0; tmp[ 1] = 0; tmp[ 2] = 0; tmp[ 3] = 0;
116 return;
117 }
118 }
119 i = __FDSET_LONGS;
120 while (i) {
121 i--;
122 *tmp = 0;
123 tmp++;
124 }
125}
126
127#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */
128#endif /* __GNUC__ */
129#endif /* _ASM_POWERPC_POSIX_TYPES_H */
diff --git a/include/asm-powerpc/ppc-pci.h b/include/asm-powerpc/ppc-pci.h
new file mode 100644
index 000000000000..36cdc869e580
--- /dev/null
+++ b/include/asm-powerpc/ppc-pci.h
@@ -0,0 +1,96 @@
1/*
2 * c 2001 PPC 64 Team, 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_PPC_PCI_H
10#define _ASM_POWERPC_PPC_PCI_H
11
12#include <linux/pci.h>
13#include <asm/pci-bridge.h>
14
15extern unsigned long isa_io_base;
16
17extern void pci_setup_phb_io(struct pci_controller *hose, int primary);
18extern void pci_setup_phb_io_dynamic(struct pci_controller *hose, int primary);
19
20
21extern struct list_head hose_list;
22extern int global_phb_number;
23
24extern unsigned long find_and_init_phbs(void);
25
26extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */
27
28/** Bus Unit ID macros; get low and hi 32-bits of the 64-bit BUID */
29#define BUID_HI(buid) ((buid) >> 32)
30#define BUID_LO(buid) ((buid) & 0xffffffff)
31
32/* PCI device_node operations */
33struct device_node;
34typedef void *(*traverse_func)(struct device_node *me, void *data);
35void *traverse_pci_devices(struct device_node *start, traverse_func pre,
36 void *data);
37
38void pci_devs_phb_init(void);
39void pci_devs_phb_init_dynamic(struct pci_controller *phb);
40void __devinit scan_phb(struct pci_controller *hose);
41
42/* From rtas_pci.h */
43void init_pci_config_tokens (void);
44unsigned long get_phb_buid (struct device_node *);
45
46/* From pSeries_pci.h */
47extern void pSeries_final_fixup(void);
48extern void pSeries_irq_bus_setup(struct pci_bus *bus);
49
50extern unsigned long pci_probe_only;
51
52/* ---- EEH internal-use-only related routines ---- */
53#ifdef CONFIG_EEH
54/**
55 * rtas_set_slot_reset -- unfreeze a frozen slot
56 *
57 * Clear the EEH-frozen condition on a slot. This routine
58 * does this by asserting the PCI #RST line for 1/8th of
59 * a second; this routine will sleep while the adapter is
60 * being reset.
61 */
62void rtas_set_slot_reset (struct pci_dn *);
63
64/**
65 * eeh_restore_bars - Restore device configuration info.
66 *
67 * A reset of a PCI device will clear out its config space.
68 * This routines will restore the config space for this
69 * device, and is children, to values previously obtained
70 * from the firmware.
71 */
72void eeh_restore_bars(struct pci_dn *);
73
74/**
75 * rtas_configure_bridge -- firmware initialization of pci bridge
76 *
77 * Ask the firmware to configure all PCI bridges devices
78 * located behind the indicated node. Required after a
79 * pci device reset. Does essentially the same hing as
80 * eeh_restore_bars, but for brdges, and lets firmware
81 * do the work.
82 */
83void rtas_configure_bridge(struct pci_dn *);
84
85int rtas_write_config(struct pci_dn *, int where, int size, u32 val);
86
87/**
88 * mark and clear slots: find "partition endpoint" PE and set or
89 * clear the flags for each subnode of the PE.
90 */
91void eeh_mark_slot (struct device_node *dn, int mode_flag);
92void eeh_clear_slot (struct device_node *dn, int mode_flag);
93
94#endif
95
96#endif /* _ASM_POWERPC_PPC_PCI_H */
diff --git a/include/asm-powerpc/ppc_asm.h b/include/asm-powerpc/ppc_asm.h
new file mode 100644
index 000000000000..c27baa0563fe
--- /dev/null
+++ b/include/asm-powerpc/ppc_asm.h
@@ -0,0 +1,491 @@
1/*
2 * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan.
3 */
4#ifndef _ASM_POWERPC_PPC_ASM_H
5#define _ASM_POWERPC_PPC_ASM_H
6
7#include <linux/stringify.h>
8#include <linux/config.h>
9#include <asm/asm-compat.h>
10
11#ifndef __ASSEMBLY__
12#error __FILE__ should only be used in assembler files
13#else
14
15#define SZL (BITS_PER_LONG/8)
16
17/*
18 * Macros for storing registers into and loading registers from
19 * exception frames.
20 */
21#ifdef __powerpc64__
22#define SAVE_GPR(n, base) std n,GPR0+8*(n)(base)
23#define REST_GPR(n, base) ld n,GPR0+8*(n)(base)
24#define SAVE_NVGPRS(base) SAVE_8GPRS(14, base); SAVE_10GPRS(22, base)
25#define REST_NVGPRS(base) REST_8GPRS(14, base); REST_10GPRS(22, base)
26#else
27#define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base)
28#define REST_GPR(n, base) lwz n,GPR0+4*(n)(base)
29#define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); \
30 SAVE_10GPRS(22, base)
31#define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); \
32 REST_10GPRS(22, base)
33#endif
34
35
36#define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base)
37#define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base)
38#define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base)
39#define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base)
40#define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base)
41#define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base)
42#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
43#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base)
44
45#define SAVE_FPR(n, base) stfd n,THREAD_FPR0+8*(n)(base)
46#define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base)
47#define SAVE_4FPRS(n, base) SAVE_2FPRS(n, base); SAVE_2FPRS(n+2, base)
48#define SAVE_8FPRS(n, base) SAVE_4FPRS(n, base); SAVE_4FPRS(n+4, base)
49#define SAVE_16FPRS(n, base) SAVE_8FPRS(n, base); SAVE_8FPRS(n+8, base)
50#define SAVE_32FPRS(n, base) SAVE_16FPRS(n, base); SAVE_16FPRS(n+16, base)
51#define REST_FPR(n, base) lfd n,THREAD_FPR0+8*(n)(base)
52#define REST_2FPRS(n, base) REST_FPR(n, base); REST_FPR(n+1, base)
53#define REST_4FPRS(n, base) REST_2FPRS(n, base); REST_2FPRS(n+2, base)
54#define REST_8FPRS(n, base) REST_4FPRS(n, base); REST_4FPRS(n+4, base)
55#define REST_16FPRS(n, base) REST_8FPRS(n, base); REST_8FPRS(n+8, base)
56#define REST_32FPRS(n, base) REST_16FPRS(n, base); REST_16FPRS(n+16, base)
57
58#define SAVE_VR(n,b,base) li b,THREAD_VR0+(16*(n)); stvx n,b,base
59#define SAVE_2VRS(n,b,base) SAVE_VR(n,b,base); SAVE_VR(n+1,b,base)
60#define SAVE_4VRS(n,b,base) SAVE_2VRS(n,b,base); SAVE_2VRS(n+2,b,base)
61#define SAVE_8VRS(n,b,base) SAVE_4VRS(n,b,base); SAVE_4VRS(n+4,b,base)
62#define SAVE_16VRS(n,b,base) SAVE_8VRS(n,b,base); SAVE_8VRS(n+8,b,base)
63#define SAVE_32VRS(n,b,base) SAVE_16VRS(n,b,base); SAVE_16VRS(n+16,b,base)
64#define REST_VR(n,b,base) li b,THREAD_VR0+(16*(n)); lvx n,b,base
65#define REST_2VRS(n,b,base) REST_VR(n,b,base); REST_VR(n+1,b,base)
66#define REST_4VRS(n,b,base) REST_2VRS(n,b,base); REST_2VRS(n+2,b,base)
67#define REST_8VRS(n,b,base) REST_4VRS(n,b,base); REST_4VRS(n+4,b,base)
68#define REST_16VRS(n,b,base) REST_8VRS(n,b,base); REST_8VRS(n+8,b,base)
69#define REST_32VRS(n,b,base) REST_16VRS(n,b,base); REST_16VRS(n+16,b,base)
70
71#define SAVE_EVR(n,s,base) evmergehi s,s,n; stw s,THREAD_EVR0+4*(n)(base)
72#define SAVE_2EVRS(n,s,base) SAVE_EVR(n,s,base); SAVE_EVR(n+1,s,base)
73#define SAVE_4EVRS(n,s,base) SAVE_2EVRS(n,s,base); SAVE_2EVRS(n+2,s,base)
74#define SAVE_8EVRS(n,s,base) SAVE_4EVRS(n,s,base); SAVE_4EVRS(n+4,s,base)
75#define SAVE_16EVRS(n,s,base) SAVE_8EVRS(n,s,base); SAVE_8EVRS(n+8,s,base)
76#define SAVE_32EVRS(n,s,base) SAVE_16EVRS(n,s,base); SAVE_16EVRS(n+16,s,base)
77#define REST_EVR(n,s,base) lwz s,THREAD_EVR0+4*(n)(base); evmergelo n,s,n
78#define REST_2EVRS(n,s,base) REST_EVR(n,s,base); REST_EVR(n+1,s,base)
79#define REST_4EVRS(n,s,base) REST_2EVRS(n,s,base); REST_2EVRS(n+2,s,base)
80#define REST_8EVRS(n,s,base) REST_4EVRS(n,s,base); REST_4EVRS(n+4,s,base)
81#define REST_16EVRS(n,s,base) REST_8EVRS(n,s,base); REST_8EVRS(n+8,s,base)
82#define REST_32EVRS(n,s,base) REST_16EVRS(n,s,base); REST_16EVRS(n+16,s,base)
83
84/* Macros to adjust thread priority for hardware multithreading */
85#define HMT_VERY_LOW or 31,31,31 # very low priority
86#define HMT_LOW or 1,1,1
87#define HMT_MEDIUM_LOW or 6,6,6 # medium low priority
88#define HMT_MEDIUM or 2,2,2
89#define HMT_MEDIUM_HIGH or 5,5,5 # medium high priority
90#define HMT_HIGH or 3,3,3
91
92/* handle instructions that older assemblers may not know */
93#define RFCI .long 0x4c000066 /* rfci instruction */
94#define RFDI .long 0x4c00004e /* rfdi instruction */
95#define RFMCI .long 0x4c00004c /* rfmci instruction */
96
97#ifdef CONFIG_PPC64
98
99#define XGLUE(a,b) a##b
100#define GLUE(a,b) XGLUE(a,b)
101
102#define _GLOBAL(name) \
103 .section ".text"; \
104 .align 2 ; \
105 .globl name; \
106 .globl GLUE(.,name); \
107 .section ".opd","aw"; \
108name: \
109 .quad GLUE(.,name); \
110 .quad .TOC.@tocbase; \
111 .quad 0; \
112 .previous; \
113 .type GLUE(.,name),@function; \
114GLUE(.,name):
115
116#define _KPROBE(name) \
117 .section ".kprobes.text","a"; \
118 .align 2 ; \
119 .globl name; \
120 .globl GLUE(.,name); \
121 .section ".opd","aw"; \
122name: \
123 .quad GLUE(.,name); \
124 .quad .TOC.@tocbase; \
125 .quad 0; \
126 .previous; \
127 .type GLUE(.,name),@function; \
128GLUE(.,name):
129
130#define _STATIC(name) \
131 .section ".text"; \
132 .align 2 ; \
133 .section ".opd","aw"; \
134name: \
135 .quad GLUE(.,name); \
136 .quad .TOC.@tocbase; \
137 .quad 0; \
138 .previous; \
139 .type GLUE(.,name),@function; \
140GLUE(.,name):
141
142#else /* 32-bit */
143
144#define _GLOBAL(n) \
145 .text; \
146 .stabs __stringify(n:F-1),N_FUN,0,0,n;\
147 .globl n; \
148n:
149
150#define _KPROBE(n) \
151 .section ".kprobes.text","a"; \
152 .globl n; \
153n:
154
155#endif
156
157/*
158 * LOADADDR( rn, name )
159 * loads the address of 'name' into 'rn'
160 *
161 * LOADBASE( rn, name )
162 * loads the address (possibly without the low 16 bits) of 'name' into 'rn'
163 * suitable for base+disp addressing
164 */
165#ifdef __powerpc64__
166#define LOADADDR(rn,name) \
167 lis rn,name##@highest; \
168 ori rn,rn,name##@higher; \
169 rldicr rn,rn,32,31; \
170 oris rn,rn,name##@h; \
171 ori rn,rn,name##@l
172
173#define LOADBASE(rn,name) \
174 ld rn,name@got(r2)
175
176#define OFF(name) 0
177
178#define SET_REG_TO_CONST(reg, value) \
179 lis reg,(((value)>>48)&0xFFFF); \
180 ori reg,reg,(((value)>>32)&0xFFFF); \
181 rldicr reg,reg,32,31; \
182 oris reg,reg,(((value)>>16)&0xFFFF); \
183 ori reg,reg,((value)&0xFFFF);
184
185#define SET_REG_TO_LABEL(reg, label) \
186 lis reg,(label)@highest; \
187 ori reg,reg,(label)@higher; \
188 rldicr reg,reg,32,31; \
189 oris reg,reg,(label)@h; \
190 ori reg,reg,(label)@l;
191
192/* offsets for stack frame layout */
193#define LRSAVE 16
194
195#else /* 32-bit */
196#define LOADADDR(rn,name) \
197 lis rn,name@ha; \
198 addi rn,rn,name@l
199
200#define LOADBASE(rn,name) \
201 lis rn,name@ha
202
203#define OFF(name) name@l
204
205/* offsets for stack frame layout */
206#define LRSAVE 4
207
208#endif
209
210/* various errata or part fixups */
211#ifdef CONFIG_PPC601_SYNC_FIX
212#define SYNC \
213BEGIN_FTR_SECTION \
214 sync; \
215 isync; \
216END_FTR_SECTION_IFSET(CPU_FTR_601)
217#define SYNC_601 \
218BEGIN_FTR_SECTION \
219 sync; \
220END_FTR_SECTION_IFSET(CPU_FTR_601)
221#define ISYNC_601 \
222BEGIN_FTR_SECTION \
223 isync; \
224END_FTR_SECTION_IFSET(CPU_FTR_601)
225#else
226#define SYNC
227#define SYNC_601
228#define ISYNC_601
229#endif
230
231
232#ifndef CONFIG_SMP
233#define TLBSYNC
234#else /* CONFIG_SMP */
235/* tlbsync is not implemented on 601 */
236#define TLBSYNC \
237BEGIN_FTR_SECTION \
238 tlbsync; \
239 sync; \
240END_FTR_SECTION_IFCLR(CPU_FTR_601)
241#endif
242
243
244/*
245 * This instruction is not implemented on the PPC 603 or 601; however, on
246 * the 403GCX and 405GP tlbia IS defined and tlbie is not.
247 * All of these instructions exist in the 8xx, they have magical powers,
248 * and they must be used.
249 */
250
251#if !defined(CONFIG_4xx) && !defined(CONFIG_8xx)
252#define tlbia \
253 li r4,1024; \
254 mtctr r4; \
255 lis r4,KERNELBASE@h; \
2560: tlbie r4; \
257 addi r4,r4,0x1000; \
258 bdnz 0b
259#endif
260
261
262#ifdef CONFIG_IBM440EP_ERR42
263#define PPC440EP_ERR42 isync
264#else
265#define PPC440EP_ERR42
266#endif
267
268
269#if defined(CONFIG_BOOKE)
270#define toreal(rd)
271#define fromreal(rd)
272
273#define tophys(rd,rs) \
274 addis rd,rs,0
275
276#define tovirt(rd,rs) \
277 addis rd,rs,0
278
279#elif defined(CONFIG_PPC64)
280#define toreal(rd) /* we can access c000... in real mode */
281#define fromreal(rd)
282
283#define tophys(rd,rs) \
284 clrldi rd,rs,2
285
286#define tovirt(rd,rs) \
287 rotldi rd,rs,16; \
288 ori rd,rd,((KERNELBASE>>48)&0xFFFF);\
289 rotldi rd,rd,48
290#else
291/*
292 * On APUS (Amiga PowerPC cpu upgrade board), we don't know the
293 * physical base address of RAM at compile time.
294 */
295#define toreal(rd) tophys(rd,rd)
296#define fromreal(rd) tovirt(rd,rd)
297
298#define tophys(rd,rs) \
2990: addis rd,rs,-KERNELBASE@h; \
300 .section ".vtop_fixup","aw"; \
301 .align 1; \
302 .long 0b; \
303 .previous
304
305#define tovirt(rd,rs) \
3060: addis rd,rs,KERNELBASE@h; \
307 .section ".ptov_fixup","aw"; \
308 .align 1; \
309 .long 0b; \
310 .previous
311#endif
312
313#ifdef CONFIG_PPC64
314#define RFI rfid
315#define MTMSRD(r) mtmsrd r
316
317#else
318#define FIX_SRR1(ra, rb)
319#ifndef CONFIG_40x
320#define RFI rfi
321#else
322#define RFI rfi; b . /* Prevent prefetch past rfi */
323#endif
324#define MTMSRD(r) mtmsr r
325#define CLR_TOP32(r)
326#endif
327
328/* The boring bits... */
329
330/* Condition Register Bit Fields */
331
332#define cr0 0
333#define cr1 1
334#define cr2 2
335#define cr3 3
336#define cr4 4
337#define cr5 5
338#define cr6 6
339#define cr7 7
340
341
342/* General Purpose Registers (GPRs) */
343
344#define r0 0
345#define r1 1
346#define r2 2
347#define r3 3
348#define r4 4
349#define r5 5
350#define r6 6
351#define r7 7
352#define r8 8
353#define r9 9
354#define r10 10
355#define r11 11
356#define r12 12
357#define r13 13
358#define r14 14
359#define r15 15
360#define r16 16
361#define r17 17
362#define r18 18
363#define r19 19
364#define r20 20
365#define r21 21
366#define r22 22
367#define r23 23
368#define r24 24
369#define r25 25
370#define r26 26
371#define r27 27
372#define r28 28
373#define r29 29
374#define r30 30
375#define r31 31
376
377
378/* Floating Point Registers (FPRs) */
379
380#define fr0 0
381#define fr1 1
382#define fr2 2
383#define fr3 3
384#define fr4 4
385#define fr5 5
386#define fr6 6
387#define fr7 7
388#define fr8 8
389#define fr9 9
390#define fr10 10
391#define fr11 11
392#define fr12 12
393#define fr13 13
394#define fr14 14
395#define fr15 15
396#define fr16 16
397#define fr17 17
398#define fr18 18
399#define fr19 19
400#define fr20 20
401#define fr21 21
402#define fr22 22
403#define fr23 23
404#define fr24 24
405#define fr25 25
406#define fr26 26
407#define fr27 27
408#define fr28 28
409#define fr29 29
410#define fr30 30
411#define fr31 31
412
413/* AltiVec Registers (VPRs) */
414
415#define vr0 0
416#define vr1 1
417#define vr2 2
418#define vr3 3
419#define vr4 4
420#define vr5 5
421#define vr6 6
422#define vr7 7
423#define vr8 8
424#define vr9 9
425#define vr10 10
426#define vr11 11
427#define vr12 12
428#define vr13 13
429#define vr14 14
430#define vr15 15
431#define vr16 16
432#define vr17 17
433#define vr18 18
434#define vr19 19
435#define vr20 20
436#define vr21 21
437#define vr22 22
438#define vr23 23
439#define vr24 24
440#define vr25 25
441#define vr26 26
442#define vr27 27
443#define vr28 28
444#define vr29 29
445#define vr30 30
446#define vr31 31
447
448/* SPE Registers (EVPRs) */
449
450#define evr0 0
451#define evr1 1
452#define evr2 2
453#define evr3 3
454#define evr4 4
455#define evr5 5
456#define evr6 6
457#define evr7 7
458#define evr8 8
459#define evr9 9
460#define evr10 10
461#define evr11 11
462#define evr12 12
463#define evr13 13
464#define evr14 14
465#define evr15 15
466#define evr16 16
467#define evr17 17
468#define evr18 18
469#define evr19 19
470#define evr20 20
471#define evr21 21
472#define evr22 22
473#define evr23 23
474#define evr24 24
475#define evr25 25
476#define evr26 26
477#define evr27 27
478#define evr28 28
479#define evr29 29
480#define evr30 30
481#define evr31 31
482
483/* some stab codes */
484#define N_FUN 36
485#define N_RSYM 64
486#define N_SLINE 68
487#define N_SO 100
488
489#endif /* __ASSEMBLY__ */
490
491#endif /* _ASM_POWERPC_PPC_ASM_H */
diff --git a/include/asm-powerpc/processor.h b/include/asm-powerpc/processor.h
new file mode 100644
index 000000000000..d12382d292d4
--- /dev/null
+++ b/include/asm-powerpc/processor.h
@@ -0,0 +1,287 @@
1#ifndef _ASM_POWERPC_PROCESSOR_H
2#define _ASM_POWERPC_PROCESSOR_H
3
4/*
5 * Copyright (C) 2001 PPC 64 Team, IBM Corp
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/config.h>
14#include <asm/reg.h>
15
16#ifndef __ASSEMBLY__
17#include <linux/compiler.h>
18#include <asm/ptrace.h>
19#include <asm/types.h>
20
21/* We do _not_ want to define new machine types at all, those must die
22 * in favor of using the device-tree
23 * -- BenH.
24 */
25
26/* Platforms codes (to be obsoleted) */
27#define PLATFORM_PSERIES 0x0100
28#define PLATFORM_PSERIES_LPAR 0x0101
29#define PLATFORM_ISERIES_LPAR 0x0201
30#define PLATFORM_LPAR 0x0001
31#define PLATFORM_POWERMAC 0x0400
32#define PLATFORM_MAPLE 0x0500
33#define PLATFORM_PREP 0x0600
34#define PLATFORM_CHRP 0x0700
35#define PLATFORM_CELL 0x1000
36
37/* Compat platform codes for 32 bits */
38#define _MACH_prep PLATFORM_PREP
39#define _MACH_Pmac PLATFORM_POWERMAC
40#define _MACH_chrp PLATFORM_CHRP
41
42/* PREP sub-platform types see residual.h for these */
43#define _PREP_Motorola 0x01 /* motorola prep */
44#define _PREP_Firm 0x02 /* firmworks prep */
45#define _PREP_IBM 0x00 /* ibm prep */
46#define _PREP_Bull 0x03 /* bull prep */
47
48/* CHRP sub-platform types. These are arbitrary */
49#define _CHRP_Motorola 0x04 /* motorola chrp, the cobra */
50#define _CHRP_IBM 0x05 /* IBM chrp, the longtrail and longtrail 2 */
51#define _CHRP_Pegasos 0x06 /* Genesi/bplan's Pegasos and Pegasos2 */
52
53#define platform_is_pseries() (_machine == PLATFORM_PSERIES || \
54 _machine == PLATFORM_PSERIES_LPAR)
55#define platform_is_lpar() (!!(_machine & PLATFORM_LPAR))
56
57#if defined(CONFIG_PPC_MULTIPLATFORM)
58extern int _machine;
59
60#ifdef CONFIG_PPC32
61
62/* what kind of prep workstation we are */
63extern int _prep_type;
64extern int _chrp_type;
65
66/*
67 * This is used to identify the board type from a given PReP board
68 * vendor. Board revision is also made available. This will be moved
69 * elsewhere soon
70 */
71extern unsigned char ucSystemType;
72extern unsigned char ucBoardRev;
73extern unsigned char ucBoardRevMaj, ucBoardRevMin;
74
75#endif /* CONFIG_PPC32 */
76
77#elif defined(CONFIG_PPC_ISERIES)
78/*
79 * iSeries is soon to become MULTIPLATFORM hopefully ...
80 */
81#define _machine PLATFORM_ISERIES_LPAR
82#else
83#define _machine 0
84#endif /* CONFIG_PPC_MULTIPLATFORM */
85
86/*
87 * Default implementation of macro that returns current
88 * instruction pointer ("program counter").
89 */
90#define current_text_addr() ({ __label__ _l; _l: &&_l;})
91
92/* Macros for adjusting thread priority (hardware multi-threading) */
93#define HMT_very_low() asm volatile("or 31,31,31 # very low priority")
94#define HMT_low() asm volatile("or 1,1,1 # low priority")
95#define HMT_medium_low() asm volatile("or 6,6,6 # medium low priority")
96#define HMT_medium() asm volatile("or 2,2,2 # medium priority")
97#define HMT_medium_high() asm volatile("or 5,5,5 # medium high priority")
98#define HMT_high() asm volatile("or 3,3,3 # high priority")
99
100#ifdef __KERNEL__
101
102extern int have_of;
103
104struct task_struct;
105void start_thread(struct pt_regs *regs, unsigned long fdptr, unsigned long sp);
106void release_thread(struct task_struct *);
107
108/* Prepare to copy thread state - unlazy all lazy status */
109extern void prepare_to_copy(struct task_struct *tsk);
110
111/* Create a new kernel thread. */
112extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
113
114/* Lazy FPU handling on uni-processor */
115extern struct task_struct *last_task_used_math;
116extern struct task_struct *last_task_used_altivec;
117extern struct task_struct *last_task_used_spe;
118
119#ifdef CONFIG_PPC32
120#define TASK_SIZE (CONFIG_TASK_SIZE)
121
122/* This decides where the kernel will search for a free chunk of vm
123 * space during mmap's.
124 */
125#define TASK_UNMAPPED_BASE (TASK_SIZE / 8 * 3)
126#endif
127
128#ifdef CONFIG_PPC64
129/* 64-bit user address space is 44-bits (16TB user VM) */
130#define TASK_SIZE_USER64 (0x0000100000000000UL)
131
132/*
133 * 32-bit user address space is 4GB - 1 page
134 * (this 1 page is needed so referencing of 0xFFFFFFFF generates EFAULT
135 */
136#define TASK_SIZE_USER32 (0x0000000100000000UL - (1*PAGE_SIZE))
137
138#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
139 TASK_SIZE_USER32 : TASK_SIZE_USER64)
140
141/* This decides where the kernel will search for a free chunk of vm
142 * space during mmap's.
143 */
144#define TASK_UNMAPPED_BASE_USER32 (PAGE_ALIGN(TASK_SIZE_USER32 / 4))
145#define TASK_UNMAPPED_BASE_USER64 (PAGE_ALIGN(TASK_SIZE_USER64 / 4))
146
147#define TASK_UNMAPPED_BASE ((test_thread_flag(TIF_32BIT)) ? \
148 TASK_UNMAPPED_BASE_USER32 : TASK_UNMAPPED_BASE_USER64 )
149#endif
150
151typedef struct {
152 unsigned long seg;
153} mm_segment_t;
154
155struct thread_struct {
156 unsigned long ksp; /* Kernel stack pointer */
157#ifdef CONFIG_PPC64
158 unsigned long ksp_vsid;
159#endif
160 struct pt_regs *regs; /* Pointer to saved register state */
161 mm_segment_t fs; /* for get_fs() validation */
162#ifdef CONFIG_PPC32
163 void *pgdir; /* root of page-table tree */
164 signed long last_syscall;
165#endif
166#if defined(CONFIG_4xx) || defined (CONFIG_BOOKE)
167 unsigned long dbcr0; /* debug control register values */
168 unsigned long dbcr1;
169#endif
170 double fpr[32]; /* Complete floating point set */
171 struct { /* fpr ... fpscr must be contiguous */
172
173 unsigned int pad;
174 unsigned int val; /* Floating point status */
175 } fpscr;
176 int fpexc_mode; /* floating-point exception mode */
177#ifdef CONFIG_PPC64
178 unsigned long start_tb; /* Start purr when proc switched in */
179 unsigned long accum_tb; /* Total accumilated purr for process */
180#endif
181 unsigned long vdso_base; /* base of the vDSO library */
182 unsigned long dabr; /* Data address breakpoint register */
183#ifdef CONFIG_ALTIVEC
184 /* Complete AltiVec register set */
185 vector128 vr[32] __attribute((aligned(16)));
186 /* AltiVec status */
187 vector128 vscr __attribute((aligned(16)));
188 unsigned long vrsave;
189 int used_vr; /* set if process has used altivec */
190#endif /* CONFIG_ALTIVEC */
191#ifdef CONFIG_SPE
192 unsigned long evr[32]; /* upper 32-bits of SPE regs */
193 u64 acc; /* Accumulator */
194 unsigned long spefscr; /* SPE & eFP status */
195 int used_spe; /* set if process has used spe */
196#endif /* CONFIG_SPE */
197};
198
199#define ARCH_MIN_TASKALIGN 16
200
201#define INIT_SP (sizeof(init_stack) + (unsigned long) &init_stack)
202
203
204#ifdef CONFIG_PPC32
205#define INIT_THREAD { \
206 .ksp = INIT_SP, \
207 .fs = KERNEL_DS, \
208 .pgdir = swapper_pg_dir, \
209 .fpexc_mode = MSR_FE0 | MSR_FE1, \
210}
211#else
212#define INIT_THREAD { \
213 .ksp = INIT_SP, \
214 .regs = (struct pt_regs *)INIT_SP - 1, /* XXX bogus, I think */ \
215 .fs = KERNEL_DS, \
216 .fpr = {0}, \
217 .fpscr = { .val = 0, }, \
218 .fpexc_mode = MSR_FE0|MSR_FE1, \
219}
220#endif
221
222/*
223 * Return saved PC of a blocked thread. For now, this is the "user" PC
224 */
225#define thread_saved_pc(tsk) \
226 ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
227
228unsigned long get_wchan(struct task_struct *p);
229
230#define KSTK_EIP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->nip: 0)
231#define KSTK_ESP(tsk) ((tsk)->thread.regs? (tsk)->thread.regs->gpr[1]: 0)
232
233/* Get/set floating-point exception mode */
234#define GET_FPEXC_CTL(tsk, adr) get_fpexc_mode((tsk), (adr))
235#define SET_FPEXC_CTL(tsk, val) set_fpexc_mode((tsk), (val))
236
237extern int get_fpexc_mode(struct task_struct *tsk, unsigned long adr);
238extern int set_fpexc_mode(struct task_struct *tsk, unsigned int val);
239
240static inline unsigned int __unpack_fe01(unsigned long msr_bits)
241{
242 return ((msr_bits & MSR_FE0) >> 10) | ((msr_bits & MSR_FE1) >> 8);
243}
244
245static inline unsigned long __pack_fe01(unsigned int fpmode)
246{
247 return ((fpmode << 10) & MSR_FE0) | ((fpmode << 8) & MSR_FE1);
248}
249
250#ifdef CONFIG_PPC64
251#define cpu_relax() do { HMT_low(); HMT_medium(); barrier(); } while (0)
252#else
253#define cpu_relax() barrier()
254#endif
255
256/*
257 * Prefetch macros.
258 */
259#define ARCH_HAS_PREFETCH
260#define ARCH_HAS_PREFETCHW
261#define ARCH_HAS_SPINLOCK_PREFETCH
262
263static inline void prefetch(const void *x)
264{
265 if (unlikely(!x))
266 return;
267
268 __asm__ __volatile__ ("dcbt 0,%0" : : "r" (x));
269}
270
271static inline void prefetchw(const void *x)
272{
273 if (unlikely(!x))
274 return;
275
276 __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (x));
277}
278
279#define spin_lock_prefetch(x) prefetchw(x)
280
281#ifdef CONFIG_PPC64
282#define HAVE_ARCH_PICK_MMAP_LAYOUT
283#endif
284
285#endif /* __KERNEL__ */
286#endif /* __ASSEMBLY__ */
287#endif /* _ASM_POWERPC_PROCESSOR_H */
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
new file mode 100644
index 000000000000..f999df1c5c90
--- /dev/null
+++ b/include/asm-powerpc/prom.h
@@ -0,0 +1,227 @@
1#ifndef _POWERPC_PROM_H
2#define _POWERPC_PROM_H
3#ifdef __KERNEL__
4
5/*
6 * Definitions for talking to the Open Firmware PROM on
7 * Power Macintosh computers.
8 *
9 * Copyright (C) 1996-2005 Paul Mackerras.
10 *
11 * Updates for PPC64 by Peter Bergner & David Engebretsen, IBM Corp.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#include <linux/config.h>
19#include <linux/types.h>
20#include <linux/proc_fs.h>
21#include <asm/atomic.h>
22
23/* Definitions used by the flattened device tree */
24#define OF_DT_HEADER 0xd00dfeed /* marker */
25#define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */
26#define OF_DT_END_NODE 0x2 /* End node */
27#define OF_DT_PROP 0x3 /* Property: name off, size,
28 * content */
29#define OF_DT_NOP 0x4 /* nop */
30#define OF_DT_END 0x9
31
32#define OF_DT_VERSION 0x10
33
34/*
35 * This is what gets passed to the kernel by prom_init or kexec
36 *
37 * The dt struct contains the device tree structure, full pathes and
38 * property contents. The dt strings contain a separate block with just
39 * the strings for the property names, and is fully page aligned and
40 * self contained in a page, so that it can be kept around by the kernel,
41 * each property name appears only once in this page (cheap compression)
42 *
43 * the mem_rsvmap contains a map of reserved ranges of physical memory,
44 * passing it here instead of in the device-tree itself greatly simplifies
45 * the job of everybody. It's just a list of u64 pairs (base/size) that
46 * ends when size is 0
47 */
48struct boot_param_header
49{
50 u32 magic; /* magic word OF_DT_HEADER */
51 u32 totalsize; /* total size of DT block */
52 u32 off_dt_struct; /* offset to structure */
53 u32 off_dt_strings; /* offset to strings */
54 u32 off_mem_rsvmap; /* offset to memory reserve map */
55 u32 version; /* format version */
56 u32 last_comp_version; /* last compatible version */
57 /* version 2 fields below */
58 u32 boot_cpuid_phys; /* Physical CPU id we're booting on */
59 /* version 3 fields below */
60 u32 dt_strings_size; /* size of the DT strings block */
61};
62
63
64
65typedef u32 phandle;
66typedef u32 ihandle;
67
68struct address_range {
69 unsigned long space;
70 unsigned long address;
71 unsigned long size;
72};
73
74struct interrupt_info {
75 int line;
76 int sense; /* +ve/-ve logic, edge or level, etc. */
77};
78
79struct pci_address {
80 u32 a_hi;
81 u32 a_mid;
82 u32 a_lo;
83};
84
85struct isa_address {
86 u32 a_hi;
87 u32 a_lo;
88};
89
90struct isa_range {
91 struct isa_address isa_addr;
92 struct pci_address pci_addr;
93 unsigned int size;
94};
95
96struct reg_property {
97 unsigned long address;
98 unsigned long size;
99};
100
101struct reg_property32 {
102 unsigned int address;
103 unsigned int size;
104};
105
106struct reg_property64 {
107 u64 address;
108 u64 size;
109};
110
111struct property {
112 char *name;
113 int length;
114 unsigned char *value;
115 struct property *next;
116};
117
118struct device_node {
119 char *name;
120 char *type;
121 phandle node;
122 phandle linux_phandle;
123 int n_addrs;
124 struct address_range *addrs;
125 int n_intrs;
126 struct interrupt_info *intrs;
127 char *full_name;
128
129 struct property *properties;
130 struct device_node *parent;
131 struct device_node *child;
132 struct device_node *sibling;
133 struct device_node *next; /* next device of same type */
134 struct device_node *allnext; /* next in list of all nodes */
135 struct proc_dir_entry *pde; /* this node's proc directory */
136 struct kref kref;
137 unsigned long _flags;
138 void *data;
139};
140
141extern struct device_node *of_chosen;
142
143/* flag descriptions */
144#define OF_DYNAMIC 1 /* node and properties were allocated via kmalloc */
145
146#define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
147#define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
148
149#define HAVE_ARCH_DEVTREE_FIXUPS
150
151static inline void set_node_proc_entry(struct device_node *dn, struct proc_dir_entry *de)
152{
153 dn->pde = de;
154}
155
156
157/* OBSOLETE: Old style node lookup */
158extern struct device_node *find_devices(const char *name);
159extern struct device_node *find_type_devices(const char *type);
160extern struct device_node *find_path_device(const char *path);
161extern struct device_node *find_compatible_devices(const char *type,
162 const char *compat);
163extern struct device_node *find_all_nodes(void);
164
165/* New style node lookup */
166extern struct device_node *of_find_node_by_name(struct device_node *from,
167 const char *name);
168extern struct device_node *of_find_node_by_type(struct device_node *from,
169 const char *type);
170extern struct device_node *of_find_compatible_node(struct device_node *from,
171 const char *type, const char *compat);
172extern struct device_node *of_find_node_by_path(const char *path);
173extern struct device_node *of_find_node_by_phandle(phandle handle);
174extern struct device_node *of_find_all_nodes(struct device_node *prev);
175extern struct device_node *of_get_parent(const struct device_node *node);
176extern struct device_node *of_get_next_child(const struct device_node *node,
177 struct device_node *prev);
178extern struct device_node *of_node_get(struct device_node *node);
179extern void of_node_put(struct device_node *node);
180
181/* For scanning the flat device-tree at boot time */
182int __init of_scan_flat_dt(int (*it)(unsigned long node,
183 const char *uname, int depth,
184 void *data),
185 void *data);
186void* __init of_get_flat_dt_prop(unsigned long node, const char *name,
187 unsigned long *size);
188
189/* For updating the device tree at runtime */
190extern void of_attach_node(struct device_node *);
191extern void of_detach_node(const struct device_node *);
192
193/* Other Prototypes */
194extern void finish_device_tree(void);
195extern void unflatten_device_tree(void);
196extern void early_init_devtree(void *);
197extern int device_is_compatible(struct device_node *device, const char *);
198extern int machine_is_compatible(const char *compat);
199extern unsigned char *get_property(struct device_node *node, const char *name,
200 int *lenp);
201extern void print_properties(struct device_node *node);
202extern int prom_n_addr_cells(struct device_node* np);
203extern int prom_n_size_cells(struct device_node* np);
204extern int prom_n_intr_cells(struct device_node* np);
205extern void prom_get_irq_senses(unsigned char *senses, int off, int max);
206extern int prom_add_property(struct device_node* np, struct property* prop);
207
208#ifdef CONFIG_PPC32
209/*
210 * PCI <-> OF matching functions
211 * (XXX should these be here?)
212 */
213struct pci_bus;
214struct pci_dev;
215extern int pci_device_from_OF_node(struct device_node *node,
216 u8* bus, u8* devfn);
217extern struct device_node* pci_busdev_to_OF_node(struct pci_bus *, int);
218extern struct device_node* pci_device_to_OF_node(struct pci_dev *);
219extern void pci_create_OF_bus_map(void);
220#endif
221
222extern struct resource *request_OF_resource(struct device_node* node,
223 int index, const char* name_postfix);
224extern int release_OF_resource(struct device_node* node, int index);
225
226#endif /* __KERNEL__ */
227#endif /* _POWERPC_PROM_H */
diff --git a/include/asm-powerpc/ptrace.h b/include/asm-powerpc/ptrace.h
new file mode 100644
index 000000000000..1f7ecdb0b6ce
--- /dev/null
+++ b/include/asm-powerpc/ptrace.h
@@ -0,0 +1,248 @@
1#ifndef _ASM_POWERPC_PTRACE_H
2#define _ASM_POWERPC_PTRACE_H
3
4/*
5 * Copyright (C) 2001 PPC64 Team, IBM Corp
6 *
7 * This struct defines the way the registers are stored on the
8 * kernel stack during a system call or other kernel entry.
9 *
10 * this should only contain volatile regs
11 * since we can keep non-volatile in the thread_struct
12 * should set this up when only volatiles are saved
13 * by intr code.
14 *
15 * Since this is going on the stack, *CARE MUST BE TAKEN* to insure
16 * that the overall structure is a multiple of 16 bytes in length.
17 *
18 * Note that the offsets of the fields in this struct correspond with
19 * the PT_* values below. This simplifies arch/powerpc/kernel/ptrace.c.
20 *
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version
24 * 2 of the License, or (at your option) any later version.
25 */
26
27#ifndef __ASSEMBLY__
28
29struct pt_regs {
30 unsigned long gpr[32];
31 unsigned long nip;
32 unsigned long msr;
33 unsigned long orig_gpr3; /* Used for restarting system calls */
34 unsigned long ctr;
35 unsigned long link;
36 unsigned long xer;
37 unsigned long ccr;
38#ifdef __powerpc64__
39 unsigned long softe; /* Soft enabled/disabled */
40#else
41 unsigned long mq; /* 601 only (not used at present) */
42 /* Used on APUS to hold IPL value. */
43#endif
44 unsigned long trap; /* Reason for being here */
45 /* N.B. for critical exceptions on 4xx, the dar and dsisr
46 fields are overloaded to hold srr0 and srr1. */
47 unsigned long dar; /* Fault registers */
48 unsigned long dsisr; /* on 4xx/Book-E used for ESR */
49 unsigned long result; /* Result of a system call */
50};
51
52#endif /* __ASSEMBLY__ */
53
54#ifdef __KERNEL__
55
56#ifdef __powerpc64__
57
58#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */
59
60/* Size of dummy stack frame allocated when calling signal handler. */
61#define __SIGNAL_FRAMESIZE 128
62#define __SIGNAL_FRAMESIZE32 64
63
64#else /* __powerpc64__ */
65
66#define STACK_FRAME_OVERHEAD 16 /* size of minimum stack frame */
67
68/* Size of stack frame allocated when calling signal handler. */
69#define __SIGNAL_FRAMESIZE 64
70
71#endif /* __powerpc64__ */
72
73#ifndef __ASSEMBLY__
74
75#define instruction_pointer(regs) ((regs)->nip)
76#ifdef CONFIG_SMP
77extern unsigned long profile_pc(struct pt_regs *regs);
78#else
79#define profile_pc(regs) instruction_pointer(regs)
80#endif
81
82#ifdef __powerpc64__
83#define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)
84#else
85#define user_mode(regs) (((regs)->msr & MSR_PR) != 0)
86#endif
87
88#define force_successful_syscall_return() \
89 do { \
90 current_thread_info()->syscall_noerror = 1; \
91 } while(0)
92
93/*
94 * We use the least-significant bit of the trap field to indicate
95 * whether we have saved the full set of registers, or only a
96 * partial set. A 1 there means the partial set.
97 * On 4xx we use the next bit to indicate whether the exception
98 * is a critical exception (1 means it is).
99 */
100#define FULL_REGS(regs) (((regs)->trap & 1) == 0)
101#ifndef __powerpc64__
102#define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) == 0)
103#endif /* ! __powerpc64__ */
104#define TRAP(regs) ((regs)->trap & ~0xF)
105#ifdef __powerpc64__
106#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
107#else
108#define CHECK_FULL_REGS(regs) \
109do { \
110 if ((regs)->trap & 1) \
111 printk(KERN_CRIT "%s: partial register set\n", __FUNCTION__); \
112} while (0)
113#endif /* __powerpc64__ */
114
115#endif /* __ASSEMBLY__ */
116
117#endif /* __KERNEL__ */
118
119/*
120 * Offsets used by 'ptrace' system call interface.
121 * These can't be changed without breaking binary compatibility
122 * with MkLinux, etc.
123 */
124#define PT_R0 0
125#define PT_R1 1
126#define PT_R2 2
127#define PT_R3 3
128#define PT_R4 4
129#define PT_R5 5
130#define PT_R6 6
131#define PT_R7 7
132#define PT_R8 8
133#define PT_R9 9
134#define PT_R10 10
135#define PT_R11 11
136#define PT_R12 12
137#define PT_R13 13
138#define PT_R14 14
139#define PT_R15 15
140#define PT_R16 16
141#define PT_R17 17
142#define PT_R18 18
143#define PT_R19 19
144#define PT_R20 20
145#define PT_R21 21
146#define PT_R22 22
147#define PT_R23 23
148#define PT_R24 24
149#define PT_R25 25
150#define PT_R26 26
151#define PT_R27 27
152#define PT_R28 28
153#define PT_R29 29
154#define PT_R30 30
155#define PT_R31 31
156
157#define PT_NIP 32
158#define PT_MSR 33
159#ifdef __KERNEL__
160#define PT_ORIG_R3 34
161#endif
162#define PT_CTR 35
163#define PT_LNK 36
164#define PT_XER 37
165#define PT_CCR 38
166#ifndef __powerpc64__
167#define PT_MQ 39
168#else
169#define PT_SOFTE 39
170#define PT_TRAP 40
171#define PT_DAR 41
172#define PT_DSISR 42
173#define PT_RESULT 43
174#endif
175
176#define PT_FPR0 48 /* each FP reg occupies 2 slots in this space */
177
178#ifndef __powerpc64__
179
180#define PT_FPR31 (PT_FPR0 + 2*31)
181#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
182
183#else /* __powerpc64__ */
184
185#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */
186
187#ifdef __KERNEL__
188#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */
189#endif
190
191#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */
192#define PT_VSCR (PT_VR0 + 32*2 + 1)
193#define PT_VRSAVE (PT_VR0 + 33*2)
194
195#ifdef __KERNEL__
196#define PT_VR0_32 164 /* each Vector reg occupies 4 slots in 32-bit */
197#define PT_VSCR_32 (PT_VR0 + 32*4 + 3)
198#define PT_VRSAVE_32 (PT_VR0 + 33*4)
199#endif
200
201#endif /* __powerpc64__ */
202
203/*
204 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
205 * The transfer totals 34 quadword. Quadwords 0-31 contain the
206 * corresponding vector registers. Quadword 32 contains the vscr as the
207 * last word (offset 12) within that quadword. Quadword 33 contains the
208 * vrsave as the first word (offset 0) within the quadword.
209 *
210 * This definition of the VMX state is compatible with the current PPC32
211 * ptrace interface. This allows signal handling and ptrace to use the same
212 * structures. This also simplifies the implementation of a bi-arch
213 * (combined (32- and 64-bit) gdb.
214 */
215#define PTRACE_GETVRREGS 18
216#define PTRACE_SETVRREGS 19
217
218#ifndef __powerpc64__
219/* Get/set all the upper 32-bits of the SPE registers, accumulator, and
220 * spefscr, in one go */
221#define PTRACE_GETEVRREGS 20
222#define PTRACE_SETEVRREGS 21
223#endif /* __powerpc64__ */
224
225/*
226 * Get or set a debug register. The first 16 are DABR registers and the
227 * second 16 are IABR registers.
228 */
229#define PTRACE_GET_DEBUGREG 25
230#define PTRACE_SET_DEBUGREG 26
231
232#ifdef __powerpc64__
233/* Additional PTRACE requests implemented on PowerPC. */
234#define PPC_PTRACE_GETREGS 0x99 /* Get GPRs 0 - 31 */
235#define PPC_PTRACE_SETREGS 0x98 /* Set GPRs 0 - 31 */
236#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */
237#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */
238
239/* Calls to trace a 64bit program from a 32bit program */
240#define PPC_PTRACE_PEEKTEXT_3264 0x95
241#define PPC_PTRACE_PEEKDATA_3264 0x94
242#define PPC_PTRACE_POKETEXT_3264 0x93
243#define PPC_PTRACE_POKEDATA_3264 0x92
244#define PPC_PTRACE_PEEKUSR_3264 0x91
245#define PPC_PTRACE_POKEUSR_3264 0x90
246#endif /* __powerpc64__ */
247
248#endif /* _ASM_POWERPC_PTRACE_H */
diff --git a/include/asm-powerpc/reg.h b/include/asm-powerpc/reg.h
new file mode 100644
index 000000000000..eb392d038ed7
--- /dev/null
+++ b/include/asm-powerpc/reg.h
@@ -0,0 +1,625 @@
1/*
2 * Contains the definition of registers common to all PowerPC variants.
3 * If a register definition has been changed in a different PowerPC
4 * variant, we will case it in #ifndef XXX ... #endif, and have the
5 * number used in the Programming Environments Manual For 32-Bit
6 * Implementations of the PowerPC Architecture (a.k.a. Green Book) here.
7 */
8
9#ifndef _ASM_POWERPC_REG_H
10#define _ASM_POWERPC_REG_H
11#ifdef __KERNEL__
12
13#include <linux/stringify.h>
14#include <asm/cputable.h>
15
16/* Pickup Book E specific registers. */
17#if defined(CONFIG_BOOKE) || defined(CONFIG_40x)
18#include <asm/reg_booke.h>
19#endif /* CONFIG_BOOKE || CONFIG_40x */
20
21#ifdef CONFIG_8xx
22#include <asm/reg_8xx.h>
23#endif /* CONFIG_8xx */
24
25#define MSR_SF_LG 63 /* Enable 64 bit mode */
26#define MSR_ISF_LG 61 /* Interrupt 64b mode valid on 630 */
27#define MSR_HV_LG 60 /* Hypervisor state */
28#define MSR_VEC_LG 25 /* Enable AltiVec */
29#define MSR_POW_LG 18 /* Enable Power Management */
30#define MSR_WE_LG 18 /* Wait State Enable */
31#define MSR_TGPR_LG 17 /* TLB Update registers in use */
32#define MSR_CE_LG 17 /* Critical Interrupt Enable */
33#define MSR_ILE_LG 16 /* Interrupt Little Endian */
34#define MSR_EE_LG 15 /* External Interrupt Enable */
35#define MSR_PR_LG 14 /* Problem State / Privilege Level */
36#define MSR_FP_LG 13 /* Floating Point enable */
37#define MSR_ME_LG 12 /* Machine Check Enable */
38#define MSR_FE0_LG 11 /* Floating Exception mode 0 */
39#define MSR_SE_LG 10 /* Single Step */
40#define MSR_BE_LG 9 /* Branch Trace */
41#define MSR_DE_LG 9 /* Debug Exception Enable */
42#define MSR_FE1_LG 8 /* Floating Exception mode 1 */
43#define MSR_IP_LG 6 /* Exception prefix 0x000/0xFFF */
44#define MSR_IR_LG 5 /* Instruction Relocate */
45#define MSR_DR_LG 4 /* Data Relocate */
46#define MSR_PE_LG 3 /* Protection Enable */
47#define MSR_PX_LG 2 /* Protection Exclusive Mode */
48#define MSR_PMM_LG 2 /* Performance monitor */
49#define MSR_RI_LG 1 /* Recoverable Exception */
50#define MSR_LE_LG 0 /* Little Endian */
51
52#ifdef __ASSEMBLY__
53#define __MASK(X) (1<<(X))
54#else
55#define __MASK(X) (1UL<<(X))
56#endif
57
58#ifdef CONFIG_PPC64
59#define MSR_SF __MASK(MSR_SF_LG) /* Enable 64 bit mode */
60#define MSR_ISF __MASK(MSR_ISF_LG) /* Interrupt 64b mode valid on 630 */
61#define MSR_HV __MASK(MSR_HV_LG) /* Hypervisor state */
62#else
63/* so tests for these bits fail on 32-bit */
64#define MSR_SF 0
65#define MSR_ISF 0
66#define MSR_HV 0
67#endif
68
69#define MSR_VEC __MASK(MSR_VEC_LG) /* Enable AltiVec */
70#define MSR_POW __MASK(MSR_POW_LG) /* Enable Power Management */
71#define MSR_WE __MASK(MSR_WE_LG) /* Wait State Enable */
72#define MSR_TGPR __MASK(MSR_TGPR_LG) /* TLB Update registers in use */
73#define MSR_CE __MASK(MSR_CE_LG) /* Critical Interrupt Enable */
74#define MSR_ILE __MASK(MSR_ILE_LG) /* Interrupt Little Endian */
75#define MSR_EE __MASK(MSR_EE_LG) /* External Interrupt Enable */
76#define MSR_PR __MASK(MSR_PR_LG) /* Problem State / Privilege Level */
77#define MSR_FP __MASK(MSR_FP_LG) /* Floating Point enable */
78#define MSR_ME __MASK(MSR_ME_LG) /* Machine Check Enable */
79#define MSR_FE0 __MASK(MSR_FE0_LG) /* Floating Exception mode 0 */
80#define MSR_SE __MASK(MSR_SE_LG) /* Single Step */
81#define MSR_BE __MASK(MSR_BE_LG) /* Branch Trace */
82#define MSR_DE __MASK(MSR_DE_LG) /* Debug Exception Enable */
83#define MSR_FE1 __MASK(MSR_FE1_LG) /* Floating Exception mode 1 */
84#define MSR_IP __MASK(MSR_IP_LG) /* Exception prefix 0x000/0xFFF */
85#define MSR_IR __MASK(MSR_IR_LG) /* Instruction Relocate */
86#define MSR_DR __MASK(MSR_DR_LG) /* Data Relocate */
87#define MSR_PE __MASK(MSR_PE_LG) /* Protection Enable */
88#define MSR_PX __MASK(MSR_PX_LG) /* Protection Exclusive Mode */
89#ifndef MSR_PMM
90#define MSR_PMM __MASK(MSR_PMM_LG) /* Performance monitor */
91#endif
92#define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */
93#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */
94
95#ifdef CONFIG_PPC64
96#define MSR_ MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_ISF
97#define MSR_KERNEL MSR_ | MSR_SF | MSR_HV
98
99#define MSR_USER32 MSR_ | MSR_PR | MSR_EE
100#define MSR_USER64 MSR_USER32 | MSR_SF
101
102#else /* 32-bit */
103/* Default MSR for kernel mode. */
104#ifndef MSR_KERNEL /* reg_booke.h also defines this */
105#ifdef CONFIG_APUS_FAST_EXCEPT
106#define MSR_KERNEL (MSR_ME|MSR_IP|MSR_RI|MSR_IR|MSR_DR)
107#else
108#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR)
109#endif
110#endif
111
112#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE)
113#endif
114
115/* Floating Point Status and Control Register (FPSCR) Fields */
116#define FPSCR_FX 0x80000000 /* FPU exception summary */
117#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */
118#define FPSCR_VX 0x20000000 /* Invalid operation summary */
119#define FPSCR_OX 0x10000000 /* Overflow exception summary */
120#define FPSCR_UX 0x08000000 /* Underflow exception summary */
121#define FPSCR_ZX 0x04000000 /* Zero-divide exception summary */
122#define FPSCR_XX 0x02000000 /* Inexact exception summary */
123#define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */
124#define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */
125#define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */
126#define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */
127#define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */
128#define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */
129#define FPSCR_FR 0x00040000 /* Fraction rounded */
130#define FPSCR_FI 0x00020000 /* Fraction inexact */
131#define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */
132#define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */
133#define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */
134#define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */
135#define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */
136#define FPSCR_VE 0x00000080 /* Invalid op exception enable */
137#define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */
138#define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */
139#define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */
140#define FPSCR_XE 0x00000008 /* FP inexact exception enable */
141#define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */
142#define FPSCR_RN 0x00000003 /* FPU rounding control */
143
144/* Special Purpose Registers (SPRNs)*/
145#define SPRN_CTR 0x009 /* Count Register */
146#define SPRN_CTRLF 0x088
147#define SPRN_CTRLT 0x098
148#define CTRL_RUNLATCH 0x1
149#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */
150#define DABR_TRANSLATION (1UL << 2)
151#define SPRN_DAR 0x013 /* Data Address Register */
152#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
153#define DSISR_NOHPTE 0x40000000 /* no translation found */
154#define DSISR_PROTFAULT 0x08000000 /* protection fault */
155#define DSISR_ISSTORE 0x02000000 /* access was a store */
156#define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
157#define DSISR_NOSEGMENT 0x00200000 /* STAB/SLB miss */
158#define SPRN_TBRL 0x10C /* Time Base Read Lower Register (user, R/O) */
159#define SPRN_TBRU 0x10D /* Time Base Read Upper Register (user, R/O) */
160#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */
161#define SPRN_TBWU 0x11D /* Time Base Upper Register (super, R/W) */
162#define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */
163#define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */
164#define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */
165#define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */
166#define SPRN_DBAT1U 0x21A /* Data BAT 1 Upper Register */
167#define SPRN_DBAT2L 0x21D /* Data BAT 2 Lower Register */
168#define SPRN_DBAT2U 0x21C /* Data BAT 2 Upper Register */
169#define SPRN_DBAT3L 0x21F /* Data BAT 3 Lower Register */
170#define SPRN_DBAT3U 0x21E /* Data BAT 3 Upper Register */
171#define SPRN_DBAT4L 0x239 /* Data BAT 4 Lower Register */
172#define SPRN_DBAT4U 0x238 /* Data BAT 4 Upper Register */
173#define SPRN_DBAT5L 0x23B /* Data BAT 5 Lower Register */
174#define SPRN_DBAT5U 0x23A /* Data BAT 5 Upper Register */
175#define SPRN_DBAT6L 0x23D /* Data BAT 6 Lower Register */
176#define SPRN_DBAT6U 0x23C /* Data BAT 6 Upper Register */
177#define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */
178#define SPRN_DBAT7U 0x23E /* Data BAT 7 Upper Register */
179
180#define SPRN_DEC 0x016 /* Decrement Register */
181#define SPRN_DER 0x095 /* Debug Enable Regsiter */
182#define DER_RSTE 0x40000000 /* Reset Interrupt */
183#define DER_CHSTPE 0x20000000 /* Check Stop */
184#define DER_MCIE 0x10000000 /* Machine Check Interrupt */
185#define DER_EXTIE 0x02000000 /* External Interrupt */
186#define DER_ALIE 0x01000000 /* Alignment Interrupt */
187#define DER_PRIE 0x00800000 /* Program Interrupt */
188#define DER_FPUVIE 0x00400000 /* FP Unavailable Interrupt */
189#define DER_DECIE 0x00200000 /* Decrementer Interrupt */
190#define DER_SYSIE 0x00040000 /* System Call Interrupt */
191#define DER_TRE 0x00020000 /* Trace Interrupt */
192#define DER_SEIE 0x00004000 /* FP SW Emulation Interrupt */
193#define DER_ITLBMSE 0x00002000 /* Imp. Spec. Instruction TLB Miss */
194#define DER_ITLBERE 0x00001000 /* Imp. Spec. Instruction TLB Error */
195#define DER_DTLBMSE 0x00000800 /* Imp. Spec. Data TLB Miss */
196#define DER_DTLBERE 0x00000400 /* Imp. Spec. Data TLB Error */
197#define DER_LBRKE 0x00000008 /* Load/Store Breakpoint Interrupt */
198#define DER_IBRKE 0x00000004 /* Instruction Breakpoint Interrupt */
199#define DER_EBRKE 0x00000002 /* External Breakpoint Interrupt */
200#define DER_DPIE 0x00000001 /* Dev. Port Nonmaskable Request */
201#define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */
202#define SPRN_EAR 0x11A /* External Address Register */
203#define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */
204#define SPRN_HASH2 0x3D3 /* Secondary Hash Address Resgister */
205#define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */
206#define HID0_EMCP (1<<31) /* Enable Machine Check pin */
207#define HID0_EBA (1<<29) /* Enable Bus Address Parity */
208#define HID0_EBD (1<<28) /* Enable Bus Data Parity */
209#define HID0_SBCLK (1<<27)
210#define HID0_EICE (1<<26)
211#define HID0_TBEN (1<<26) /* Timebase enable - 745x */
212#define HID0_ECLK (1<<25)
213#define HID0_PAR (1<<24)
214#define HID0_STEN (1<<24) /* Software table search enable - 745x */
215#define HID0_HIGH_BAT (1<<23) /* Enable high BATs - 7455 */
216#define HID0_DOZE (1<<23)
217#define HID0_NAP (1<<22)
218#define HID0_SLEEP (1<<21)
219#define HID0_DPM (1<<20)
220#define HID0_BHTCLR (1<<18) /* Clear branch history table - 7450 */
221#define HID0_XAEN (1<<17) /* Extended addressing enable - 7450 */
222#define HID0_NHR (1<<16) /* Not hard reset (software bit-7450)*/
223#define HID0_ICE (1<<15) /* Instruction Cache Enable */
224#define HID0_DCE (1<<14) /* Data Cache Enable */
225#define HID0_ILOCK (1<<13) /* Instruction Cache Lock */
226#define HID0_DLOCK (1<<12) /* Data Cache Lock */
227#define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */
228#define HID0_DCI (1<<10) /* Data Cache Invalidate */
229#define HID0_SPD (1<<9) /* Speculative disable */
230#define HID0_DAPUEN (1<<8) /* Debug APU enable */
231#define HID0_SGE (1<<7) /* Store Gathering Enable */
232#define HID0_SIED (1<<7) /* Serial Instr. Execution [Disable] */
233#define HID0_DFCA (1<<6) /* Data Cache Flush Assist */
234#define HID0_LRSTK (1<<4) /* Link register stack - 745x */
235#define HID0_BTIC (1<<5) /* Branch Target Instr Cache Enable */
236#define HID0_ABE (1<<3) /* Address Broadcast Enable */
237#define HID0_FOLD (1<<3) /* Branch Folding enable - 745x */
238#define HID0_BHTE (1<<2) /* Branch History Table Enable */
239#define HID0_BTCD (1<<1) /* Branch target cache disable */
240#define HID0_NOPDST (1<<1) /* No-op dst, dstt, etc. instr. */
241#define HID0_NOPTI (1<<0) /* No-op dcbt and dcbst instr. */
242
243#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */
244#define HID1_EMCP (1<<31) /* 7450 Machine Check Pin Enable */
245#define HID1_DFS (1<<22) /* 7447A Dynamic Frequency Scaling */
246#define HID1_PC0 (1<<16) /* 7450 PLL_CFG[0] */
247#define HID1_PC1 (1<<15) /* 7450 PLL_CFG[1] */
248#define HID1_PC2 (1<<14) /* 7450 PLL_CFG[2] */
249#define HID1_PC3 (1<<13) /* 7450 PLL_CFG[3] */
250#define HID1_SYNCBE (1<<11) /* 7450 ABE for sync, eieio */
251#define HID1_ABE (1<<10) /* 7450 Address Broadcast Enable */
252#define HID1_PS (1<<16) /* 750FX PLL selection */
253#define SPRN_HID2 0x3F8 /* Hardware Implementation Register 2 */
254#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */
255#define SPRN_HID4 0x3F4 /* 970 HID4 */
256#define SPRN_HID5 0x3F6 /* 970 HID5 */
257#define SPRN_HID6 0x3F9 /* BE HID 6 */
258#define HID6_LB (0x0F<<12) /* Concurrent Large Page Modes */
259#define HID6_DLP (1<<20) /* Disable all large page modes (4K only) */
260#define SPRN_TSCR 0x399 /* Thread switch control on BE */
261#define SPRN_TTR 0x39A /* Thread switch timeout on BE */
262#define TSCR_DEC_ENABLE 0x200000 /* Decrementer Interrupt */
263#define TSCR_EE_ENABLE 0x100000 /* External Interrupt */
264#define TSCR_EE_BOOST 0x080000 /* External Interrupt Boost */
265#define SPRN_TSC 0x3FD /* Thread switch control on others */
266#define SPRN_TST 0x3FC /* Thread switch timeout on others */
267#if !defined(SPRN_IAC1) && !defined(SPRN_IAC2)
268#define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */
269#define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */
270#endif
271#define SPRN_IBAT0L 0x211 /* Instruction BAT 0 Lower Register */
272#define SPRN_IBAT0U 0x210 /* Instruction BAT 0 Upper Register */
273#define SPRN_IBAT1L 0x213 /* Instruction BAT 1 Lower Register */
274#define SPRN_IBAT1U 0x212 /* Instruction BAT 1 Upper Register */
275#define SPRN_IBAT2L 0x215 /* Instruction BAT 2 Lower Register */
276#define SPRN_IBAT2U 0x214 /* Instruction BAT 2 Upper Register */
277#define SPRN_IBAT3L 0x217 /* Instruction BAT 3 Lower Register */
278#define SPRN_IBAT3U 0x216 /* Instruction BAT 3 Upper Register */
279#define SPRN_IBAT4L 0x231 /* Instruction BAT 4 Lower Register */
280#define SPRN_IBAT4U 0x230 /* Instruction BAT 4 Upper Register */
281#define SPRN_IBAT5L 0x233 /* Instruction BAT 5 Lower Register */
282#define SPRN_IBAT5U 0x232 /* Instruction BAT 5 Upper Register */
283#define SPRN_IBAT6L 0x235 /* Instruction BAT 6 Lower Register */
284#define SPRN_IBAT6U 0x234 /* Instruction BAT 6 Upper Register */
285#define SPRN_IBAT7L 0x237 /* Instruction BAT 7 Lower Register */
286#define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */
287#define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */
288#define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */
289#define SPRN_ICTRL 0x3F3 /* 1011 7450 icache and interrupt ctrl */
290#define ICTRL_EICE 0x08000000 /* enable icache parity errs */
291#define ICTRL_EDC 0x04000000 /* enable dcache parity errs */
292#define ICTRL_EICP 0x00000100 /* enable icache par. check */
293#define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */
294#define SPRN_IMMR 0x27E /* Internal Memory Map Register */
295#define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Regsiter */
296#define SPRN_L2CR2 0x3f8
297#define L2CR_L2E 0x80000000 /* L2 enable */
298#define L2CR_L2PE 0x40000000 /* L2 parity enable */
299#define L2CR_L2SIZ_MASK 0x30000000 /* L2 size mask */
300#define L2CR_L2SIZ_256KB 0x10000000 /* L2 size 256KB */
301#define L2CR_L2SIZ_512KB 0x20000000 /* L2 size 512KB */
302#define L2CR_L2SIZ_1MB 0x30000000 /* L2 size 1MB */
303#define L2CR_L2CLK_MASK 0x0e000000 /* L2 clock mask */
304#define L2CR_L2CLK_DISABLED 0x00000000 /* L2 clock disabled */
305#define L2CR_L2CLK_DIV1 0x02000000 /* L2 clock / 1 */
306#define L2CR_L2CLK_DIV1_5 0x04000000 /* L2 clock / 1.5 */
307#define L2CR_L2CLK_DIV2 0x08000000 /* L2 clock / 2 */
308#define L2CR_L2CLK_DIV2_5 0x0a000000 /* L2 clock / 2.5 */
309#define L2CR_L2CLK_DIV3 0x0c000000 /* L2 clock / 3 */
310#define L2CR_L2RAM_MASK 0x01800000 /* L2 RAM type mask */
311#define L2CR_L2RAM_FLOW 0x00000000 /* L2 RAM flow through */
312#define L2CR_L2RAM_PIPE 0x01000000 /* L2 RAM pipelined */
313#define L2CR_L2RAM_PIPE_LW 0x01800000 /* L2 RAM pipelined latewr */
314#define L2CR_L2DO 0x00400000 /* L2 data only */
315#define L2CR_L2I 0x00200000 /* L2 global invalidate */
316#define L2CR_L2CTL 0x00100000 /* L2 RAM control */
317#define L2CR_L2WT 0x00080000 /* L2 write-through */
318#define L2CR_L2TS 0x00040000 /* L2 test support */
319#define L2CR_L2OH_MASK 0x00030000 /* L2 output hold mask */
320#define L2CR_L2OH_0_5 0x00000000 /* L2 output hold 0.5 ns */
321#define L2CR_L2OH_1_0 0x00010000 /* L2 output hold 1.0 ns */
322#define L2CR_L2SL 0x00008000 /* L2 DLL slow */
323#define L2CR_L2DF 0x00004000 /* L2 differential clock */
324#define L2CR_L2BYP 0x00002000 /* L2 DLL bypass */
325#define L2CR_L2IP 0x00000001 /* L2 GI in progress */
326#define L2CR_L2IO_745x 0x00100000 /* L2 instr. only (745x) */
327#define L2CR_L2DO_745x 0x00010000 /* L2 data only (745x) */
328#define L2CR_L2REP_745x 0x00001000 /* L2 repl. algorithm (745x) */
329#define L2CR_L2HWF_745x 0x00000800 /* L2 hardware flush (745x) */
330#define SPRN_L3CR 0x3FA /* Level 3 Cache Control Regsiter */
331#define L3CR_L3E 0x80000000 /* L3 enable */
332#define L3CR_L3PE 0x40000000 /* L3 data parity enable */
333#define L3CR_L3APE 0x20000000 /* L3 addr parity enable */
334#define L3CR_L3SIZ 0x10000000 /* L3 size */
335#define L3CR_L3CLKEN 0x08000000 /* L3 clock enable */
336#define L3CR_L3RES 0x04000000 /* L3 special reserved bit */
337#define L3CR_L3CLKDIV 0x03800000 /* L3 clock divisor */
338#define L3CR_L3IO 0x00400000 /* L3 instruction only */
339#define L3CR_L3SPO 0x00040000 /* L3 sample point override */
340#define L3CR_L3CKSP 0x00030000 /* L3 clock sample point */
341#define L3CR_L3PSP 0x0000e000 /* L3 P-clock sample point */
342#define L3CR_L3REP 0x00001000 /* L3 replacement algorithm */
343#define L3CR_L3HWF 0x00000800 /* L3 hardware flush */
344#define L3CR_L3I 0x00000400 /* L3 global invalidate */
345#define L3CR_L3RT 0x00000300 /* L3 SRAM type */
346#define L3CR_L3NIRCA 0x00000080 /* L3 non-integer ratio clock adj. */
347#define L3CR_L3DO 0x00000040 /* L3 data only mode */
348#define L3CR_PMEN 0x00000004 /* L3 private memory enable */
349#define L3CR_PMSIZ 0x00000001 /* L3 private memory size */
350
351#define SPRN_MSSCR0 0x3f6 /* Memory Subsystem Control Register 0 */
352#define SPRN_MSSSR0 0x3f7 /* Memory Subsystem Status Register 1 */
353#define SPRN_LDSTCR 0x3f8 /* Load/Store control register */
354#define SPRN_LDSTDB 0x3f4 /* */
355#define SPRN_LR 0x008 /* Link Register */
356#ifndef SPRN_PIR
357#define SPRN_PIR 0x3FF /* Processor Identification Register */
358#endif
359#define SPRN_PTEHI 0x3D5 /* 981 7450 PTE HI word (S/W TLB load) */
360#define SPRN_PTELO 0x3D6 /* 982 7450 PTE LO word (S/W TLB load) */
361#define SPRN_PURR 0x135 /* Processor Utilization of Resources Reg */
362#define SPRN_PVR 0x11F /* Processor Version Register */
363#define SPRN_RPA 0x3D6 /* Required Physical Address Register */
364#define SPRN_SDA 0x3BF /* Sampled Data Address Register */
365#define SPRN_SDR1 0x019 /* MMU Hash Base Register */
366#define SPRN_ASR 0x118 /* Address Space Register */
367#define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */
368#define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */
369#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */
370#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */
371#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */
372#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */
373#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */
374#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */
375#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */
376#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */
377#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */
378#ifndef SPRN_SVR
379#define SPRN_SVR 0x11E /* System Version Register */
380#endif
381#define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */
382/* these bits were defined in inverted endian sense originally, ugh, confusing */
383#define THRM1_TIN (1 << 31)
384#define THRM1_TIV (1 << 30)
385#define THRM1_THRES(x) ((x&0x7f)<<23)
386#define THRM3_SITV(x) ((x&0x3fff)<<1)
387#define THRM1_TID (1<<2)
388#define THRM1_TIE (1<<1)
389#define THRM1_V (1<<0)
390#define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */
391#define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */
392#define THRM3_E (1<<0)
393#define SPRN_TLBMISS 0x3D4 /* 980 7450 TLB Miss Register */
394#define SPRN_UMMCR0 0x3A8 /* User Monitor Mode Control Register 0 */
395#define SPRN_UMMCR1 0x3AC /* User Monitor Mode Control Register 0 */
396#define SPRN_UPMC1 0x3A9 /* User Performance Counter Register 1 */
397#define SPRN_UPMC2 0x3AA /* User Performance Counter Register 2 */
398#define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */
399#define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */
400#define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */
401#define SPRN_VRSAVE 0x100 /* Vector Register Save Register */
402#define SPRN_XER 0x001 /* Fixed Point Exception Register */
403
404#define SPRN_SCOMC 0x114 /* SCOM Access Control */
405#define SPRN_SCOMD 0x115 /* SCOM Access DATA */
406
407/* Performance monitor SPRs */
408#ifdef CONFIG_PPC64
409#define SPRN_MMCR0 795
410#define MMCR0_FC 0x80000000UL /* freeze counters */
411#define MMCR0_FCS 0x40000000UL /* freeze in supervisor state */
412#define MMCR0_KERNEL_DISABLE MMCR0_FCS
413#define MMCR0_FCP 0x20000000UL /* freeze in problem state */
414#define MMCR0_PROBLEM_DISABLE MMCR0_FCP
415#define MMCR0_FCM1 0x10000000UL /* freeze counters while MSR mark = 1 */
416#define MMCR0_FCM0 0x08000000UL /* freeze counters while MSR mark = 0 */
417#define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */
418#define MMCR0_FCECE 0x02000000UL /* freeze ctrs on enabled cond or event */
419#define MMCR0_TBEE 0x00400000UL /* time base exception enable */
420#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/
421#define MMCR0_PMCjCE 0x00004000UL /* PMCj count enable*/
422#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */
423#define MMCR0_PMAO 0x00000080UL /* performance monitor alert has occurred, set to 0 after handling exception */
424#define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */
425#define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */
426#define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */
427#define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */
428#define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */
429#define SPRN_MMCR1 798
430#define SPRN_MMCRA 0x312
431#define MMCRA_SIHV 0x10000000UL /* state of MSR HV when SIAR set */
432#define MMCRA_SIPR 0x08000000UL /* state of MSR PR when SIAR set */
433#define MMCRA_SAMPLE_ENABLE 0x00000001UL /* enable sampling */
434#define SPRN_PMC1 787
435#define SPRN_PMC2 788
436#define SPRN_PMC3 789
437#define SPRN_PMC4 790
438#define SPRN_PMC5 791
439#define SPRN_PMC6 792
440#define SPRN_PMC7 793
441#define SPRN_PMC8 794
442#define SPRN_SIAR 780
443#define SPRN_SDAR 781
444
445#else /* 32-bit */
446#define SPRN_MMCR0 0x3B8 /* Monitor Mode Control Register 0 */
447#define SPRN_MMCR1 0x3BC /* Monitor Mode Control Register 1 */
448#define SPRN_PMC1 0x3B9 /* Performance Counter Register 1 */
449#define SPRN_PMC2 0x3BA /* Performance Counter Register 2 */
450#define SPRN_PMC3 0x3BD /* Performance Counter Register 3 */
451#define SPRN_PMC4 0x3BE /* Performance Counter Register 4 */
452
453/* Bit definitions for MMCR0 and PMC1 / PMC2. */
454#define MMCR0_PMC1_CYCLES (1 << 7)
455#define MMCR0_PMC1_ICACHEMISS (5 << 7)
456#define MMCR0_PMC1_DTLB (6 << 7)
457#define MMCR0_PMC2_DCACHEMISS 0x6
458#define MMCR0_PMC2_CYCLES 0x1
459#define MMCR0_PMC2_ITLB 0x7
460#define MMCR0_PMC2_LOADMISSTIME 0x5
461#define MMCR0_PMXE (1 << 26)
462#endif
463
464/* Processor Version Register (PVR) field extraction */
465
466#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
467#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
468
469#define __is_processor(pv) (PVR_VER(mfspr(SPRN_PVR)) == (pv))
470
471/*
472 * IBM has further subdivided the standard PowerPC 16-bit version and
473 * revision subfields of the PVR for the PowerPC 403s into the following:
474 */
475
476#define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */
477#define PVR_MEM(pvr) (((pvr) >> 16) & 0xF) /* Member field */
478#define PVR_CORE(pvr) (((pvr) >> 12) & 0xF) /* Core field */
479#define PVR_CFG(pvr) (((pvr) >> 8) & 0xF) /* Configuration field */
480#define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF) /* Major revision field */
481#define PVR_MIN(pvr) (((pvr) >> 0) & 0xF) /* Minor revision field */
482
483/* Processor Version Numbers */
484
485#define PVR_403GA 0x00200000
486#define PVR_403GB 0x00200100
487#define PVR_403GC 0x00200200
488#define PVR_403GCX 0x00201400
489#define PVR_405GP 0x40110000
490#define PVR_STB03XXX 0x40310000
491#define PVR_NP405H 0x41410000
492#define PVR_NP405L 0x41610000
493#define PVR_601 0x00010000
494#define PVR_602 0x00050000
495#define PVR_603 0x00030000
496#define PVR_603e 0x00060000
497#define PVR_603ev 0x00070000
498#define PVR_603r 0x00071000
499#define PVR_604 0x00040000
500#define PVR_604e 0x00090000
501#define PVR_604r 0x000A0000
502#define PVR_620 0x00140000
503#define PVR_740 0x00080000
504#define PVR_750 PVR_740
505#define PVR_740P 0x10080000
506#define PVR_750P PVR_740P
507#define PVR_7400 0x000C0000
508#define PVR_7410 0x800C0000
509#define PVR_7450 0x80000000
510#define PVR_8540 0x80200000
511#define PVR_8560 0x80200000
512/*
513 * For the 8xx processors, all of them report the same PVR family for
514 * the PowerPC core. The various versions of these processors must be
515 * differentiated by the version number in the Communication Processor
516 * Module (CPM).
517 */
518#define PVR_821 0x00500000
519#define PVR_823 PVR_821
520#define PVR_850 PVR_821
521#define PVR_860 PVR_821
522#define PVR_8240 0x00810100
523#define PVR_8245 0x80811014
524#define PVR_8260 PVR_8240
525
526/* 64-bit processors */
527/* XXX the prefix should be PVR_, we'll do a global sweep to fix it one day */
528#define PV_NORTHSTAR 0x0033
529#define PV_PULSAR 0x0034
530#define PV_POWER4 0x0035
531#define PV_ICESTAR 0x0036
532#define PV_SSTAR 0x0037
533#define PV_POWER4p 0x0038
534#define PV_970 0x0039
535#define PV_POWER5 0x003A
536#define PV_POWER5p 0x003B
537#define PV_970FX 0x003C
538#define PV_630 0x0040
539#define PV_630p 0x0041
540#define PV_970MP 0x0044
541#define PV_BE 0x0070
542
543/*
544 * Number of entries in the SLB. If this ever changes we should handle
545 * it with a use a cpu feature fixup.
546 */
547#define SLB_NUM_ENTRIES 64
548
549/* Macros for setting and retrieving special purpose registers */
550#ifndef __ASSEMBLY__
551#define mfmsr() ({unsigned long rval; \
552 asm volatile("mfmsr %0" : "=r" (rval)); rval;})
553#ifdef CONFIG_PPC64
554#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \
555 : : "r" (v))
556#define mtmsrd(v) __mtmsrd((v), 0)
557#define mtmsr(v) mtmsrd(v)
558#else
559#define mtmsr(v) asm volatile("mtmsr %0" : : "r" (v))
560#endif
561
562#define mfspr(rn) ({unsigned long rval; \
563 asm volatile("mfspr %0," __stringify(rn) \
564 : "=r" (rval)); rval;})
565#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : : "r" (v))
566
567#define mftb() ({unsigned long rval; \
568 asm volatile("mftb %0" : "=r" (rval)); rval;})
569#define mftbl() ({unsigned long rval; \
570 asm volatile("mftbl %0" : "=r" (rval)); rval;})
571
572#define mttbl(v) asm volatile("mttbl %0":: "r"(v))
573#define mttbu(v) asm volatile("mttbu %0":: "r"(v))
574
575#ifdef CONFIG_PPC32
576#define mfsrin(v) ({unsigned int rval; \
577 asm volatile("mfsrin %0,%1" : "=r" (rval) : "r" (v)); \
578 rval;})
579#endif
580
581#define proc_trap() asm volatile("trap")
582
583#ifdef CONFIG_PPC64
584static inline void ppc64_runlatch_on(void)
585{
586 unsigned long ctrl;
587
588 if (cpu_has_feature(CPU_FTR_CTRL)) {
589 ctrl = mfspr(SPRN_CTRLF);
590 ctrl |= CTRL_RUNLATCH;
591 mtspr(SPRN_CTRLT, ctrl);
592 }
593}
594
595static inline void ppc64_runlatch_off(void)
596{
597 unsigned long ctrl;
598
599 if (cpu_has_feature(CPU_FTR_CTRL)) {
600 ctrl = mfspr(SPRN_CTRLF);
601 ctrl &= ~CTRL_RUNLATCH;
602 mtspr(SPRN_CTRLT, ctrl);
603 }
604}
605
606extern unsigned long scom970_read(unsigned int address);
607extern void scom970_write(unsigned int address, unsigned long value);
608
609#endif /* CONFIG_PPC64 */
610
611#define __get_SP() ({unsigned long sp; \
612 asm volatile("mr %0,1": "=r" (sp)); sp;})
613
614#else /* __ASSEMBLY__ */
615
616#define RUNLATCH_ON(REG) \
617BEGIN_FTR_SECTION \
618 mfspr (REG),SPRN_CTRLF; \
619 ori (REG),(REG),CTRL_RUNLATCH; \
620 mtspr SPRN_CTRLT,(REG); \
621END_FTR_SECTION_IFSET(CPU_FTR_CTRL)
622
623#endif /* __ASSEMBLY__ */
624#endif /* __KERNEL__ */
625#endif /* _ASM_POWERPC_REG_H */
diff --git a/include/asm-powerpc/reg_8xx.h b/include/asm-powerpc/reg_8xx.h
new file mode 100644
index 000000000000..e8ea346b21d3
--- /dev/null
+++ b/include/asm-powerpc/reg_8xx.h
@@ -0,0 +1,42 @@
1/*
2 * Contains register definitions common to PowerPC 8xx CPUs. Notice
3 */
4#ifndef _ASM_POWERPC_REG_8xx_H
5#define _ASM_POWERPC_REG_8xx_H
6
7/* Cache control on the MPC8xx is provided through some additional
8 * special purpose registers.
9 */
10#define SPRN_IC_CST 560 /* Instruction cache control/status */
11#define SPRN_IC_ADR 561 /* Address needed for some commands */
12#define SPRN_IC_DAT 562 /* Read-only data register */
13#define SPRN_DC_CST 568 /* Data cache control/status */
14#define SPRN_DC_ADR 569 /* Address needed for some commands */
15#define SPRN_DC_DAT 570 /* Read-only data register */
16
17/* Commands. Only the first few are available to the instruction cache.
18*/
19#define IDC_ENABLE 0x02000000 /* Cache enable */
20#define IDC_DISABLE 0x04000000 /* Cache disable */
21#define IDC_LDLCK 0x06000000 /* Load and lock */
22#define IDC_UNLINE 0x08000000 /* Unlock line */
23#define IDC_UNALL 0x0a000000 /* Unlock all */
24#define IDC_INVALL 0x0c000000 /* Invalidate all */
25
26#define DC_FLINE 0x0e000000 /* Flush data cache line */
27#define DC_SFWT 0x01000000 /* Set forced writethrough mode */
28#define DC_CFWT 0x03000000 /* Clear forced writethrough mode */
29#define DC_SLES 0x05000000 /* Set little endian swap mode */
30#define DC_CLES 0x07000000 /* Clear little endian swap mode */
31
32/* Status.
33*/
34#define IDC_ENABLED 0x80000000 /* Cache is enabled */
35#define IDC_CERR1 0x00200000 /* Cache error 1 */
36#define IDC_CERR2 0x00100000 /* Cache error 2 */
37#define IDC_CERR3 0x00080000 /* Cache error 3 */
38
39#define DC_DFWT 0x40000000 /* Data cache is forced write through */
40#define DC_LES 0x20000000 /* Caches are little endian mode */
41
42#endif /* _ASM_POWERPC_REG_8xx_H */
diff --git a/include/asm-powerpc/rtas.h b/include/asm-powerpc/rtas.h
new file mode 100644
index 000000000000..d1bb611ea626
--- /dev/null
+++ b/include/asm-powerpc/rtas.h
@@ -0,0 +1,232 @@
1#ifndef _POWERPC_RTAS_H
2#define _POWERPC_RTAS_H
3
4#include <linux/spinlock.h>
5#include <asm/page.h>
6
7/*
8 * Definitions for talking to the RTAS on CHRP machines.
9 *
10 * Copyright (C) 2001 Peter Bergner
11 * Copyright (C) 2001 PPC 64 Team, IBM Corp
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18
19#define RTAS_UNKNOWN_SERVICE (-1)
20#define RTAS_INSTANTIATE_MAX (1UL<<30) /* Don't instantiate rtas at/above this value */
21
22/* Buffer size for ppc_rtas system call. */
23#define RTAS_RMOBUF_MAX (64 * 1024)
24
25/* RTAS return status codes */
26#define RTAS_BUSY -2 /* RTAS Busy */
27#define RTAS_EXTENDED_DELAY_MIN 9900
28#define RTAS_EXTENDED_DELAY_MAX 9905
29
30/*
31 * In general to call RTAS use rtas_token("string") to lookup
32 * an RTAS token for the given string (e.g. "event-scan").
33 * To actually perform the call use
34 * ret = rtas_call(token, n_in, n_out, ...)
35 * Where n_in is the number of input parameters and
36 * n_out is the number of output parameters
37 *
38 * If the "string" is invalid on this system, RTAS_UNKNOWN_SERVICE
39 * will be returned as a token. rtas_call() does look for this
40 * token and error out gracefully so rtas_call(rtas_token("str"), ...)
41 * may be safely used for one-shot calls to RTAS.
42 *
43 */
44
45typedef u32 rtas_arg_t;
46
47struct rtas_args {
48 u32 token;
49 u32 nargs;
50 u32 nret;
51 rtas_arg_t args[16];
52 rtas_arg_t *rets; /* Pointer to return values in args[]. */
53};
54
55extern struct rtas_args rtas_stop_self_args;
56
57struct rtas_t {
58 unsigned long entry; /* physical address pointer */
59 unsigned long base; /* physical address pointer */
60 unsigned long size;
61 spinlock_t lock;
62 struct rtas_args args;
63 struct device_node *dev; /* virtual address pointer */
64};
65
66/* RTAS event classes */
67#define RTAS_INTERNAL_ERROR 0x80000000 /* set bit 0 */
68#define RTAS_EPOW_WARNING 0x40000000 /* set bit 1 */
69#define RTAS_POWERMGM_EVENTS 0x20000000 /* set bit 2 */
70#define RTAS_HOTPLUG_EVENTS 0x10000000 /* set bit 3 */
71#define RTAS_EVENT_SCAN_ALL_EVENTS 0xf0000000
72
73/* RTAS event severity */
74#define RTAS_SEVERITY_FATAL 0x5
75#define RTAS_SEVERITY_ERROR 0x4
76#define RTAS_SEVERITY_ERROR_SYNC 0x3
77#define RTAS_SEVERITY_WARNING 0x2
78#define RTAS_SEVERITY_EVENT 0x1
79#define RTAS_SEVERITY_NO_ERROR 0x0
80
81/* RTAS event disposition */
82#define RTAS_DISP_FULLY_RECOVERED 0x0
83#define RTAS_DISP_LIMITED_RECOVERY 0x1
84#define RTAS_DISP_NOT_RECOVERED 0x2
85
86/* RTAS event initiator */
87#define RTAS_INITIATOR_UNKNOWN 0x0
88#define RTAS_INITIATOR_CPU 0x1
89#define RTAS_INITIATOR_PCI 0x2
90#define RTAS_INITIATOR_ISA 0x3
91#define RTAS_INITIATOR_MEMORY 0x4
92#define RTAS_INITIATOR_POWERMGM 0x5
93
94/* RTAS event target */
95#define RTAS_TARGET_UNKNOWN 0x0
96#define RTAS_TARGET_CPU 0x1
97#define RTAS_TARGET_PCI 0x2
98#define RTAS_TARGET_ISA 0x3
99#define RTAS_TARGET_MEMORY 0x4
100#define RTAS_TARGET_POWERMGM 0x5
101
102/* RTAS event type */
103#define RTAS_TYPE_RETRY 0x01
104#define RTAS_TYPE_TCE_ERR 0x02
105#define RTAS_TYPE_INTERN_DEV_FAIL 0x03
106#define RTAS_TYPE_TIMEOUT 0x04
107#define RTAS_TYPE_DATA_PARITY 0x05
108#define RTAS_TYPE_ADDR_PARITY 0x06
109#define RTAS_TYPE_CACHE_PARITY 0x07
110#define RTAS_TYPE_ADDR_INVALID 0x08
111#define RTAS_TYPE_ECC_UNCORR 0x09
112#define RTAS_TYPE_ECC_CORR 0x0a
113#define RTAS_TYPE_EPOW 0x40
114#define RTAS_TYPE_PLATFORM 0xE0
115#define RTAS_TYPE_IO 0xE1
116#define RTAS_TYPE_INFO 0xE2
117#define RTAS_TYPE_DEALLOC 0xE3
118#define RTAS_TYPE_DUMP 0xE4
119/* I don't add PowerMGM events right now, this is a different topic */
120#define RTAS_TYPE_PMGM_POWER_SW_ON 0x60
121#define RTAS_TYPE_PMGM_POWER_SW_OFF 0x61
122#define RTAS_TYPE_PMGM_LID_OPEN 0x62
123#define RTAS_TYPE_PMGM_LID_CLOSE 0x63
124#define RTAS_TYPE_PMGM_SLEEP_BTN 0x64
125#define RTAS_TYPE_PMGM_WAKE_BTN 0x65
126#define RTAS_TYPE_PMGM_BATTERY_WARN 0x66
127#define RTAS_TYPE_PMGM_BATTERY_CRIT 0x67
128#define RTAS_TYPE_PMGM_SWITCH_TO_BAT 0x68
129#define RTAS_TYPE_PMGM_SWITCH_TO_AC 0x69
130#define RTAS_TYPE_PMGM_KBD_OR_MOUSE 0x6a
131#define RTAS_TYPE_PMGM_ENCLOS_OPEN 0x6b
132#define RTAS_TYPE_PMGM_ENCLOS_CLOSED 0x6c
133#define RTAS_TYPE_PMGM_RING_INDICATE 0x6d
134#define RTAS_TYPE_PMGM_LAN_ATTENTION 0x6e
135#define RTAS_TYPE_PMGM_TIME_ALARM 0x6f
136#define RTAS_TYPE_PMGM_CONFIG_CHANGE 0x70
137#define RTAS_TYPE_PMGM_SERVICE_PROC 0x71
138
139struct rtas_error_log {
140 unsigned long version:8; /* Architectural version */
141 unsigned long severity:3; /* Severity level of error */
142 unsigned long disposition:2; /* Degree of recovery */
143 unsigned long extended:1; /* extended log present? */
144 unsigned long /* reserved */ :2; /* Reserved for future use */
145 unsigned long initiator:4; /* Initiator of event */
146 unsigned long target:4; /* Target of failed operation */
147 unsigned long type:8; /* General event or error*/
148 unsigned long extended_log_length:32; /* length in bytes */
149 unsigned char buffer[1];
150};
151
152/*
153 * This can be set by the rtas_flash module so that it can get called
154 * as the absolutely last thing before the kernel terminates.
155 */
156extern void (*rtas_flash_term_hook)(int);
157
158extern struct rtas_t rtas;
159
160extern void enter_rtas(unsigned long);
161extern int rtas_token(const char *service);
162extern int rtas_call(int token, int, int, int *, ...);
163extern void call_rtas_display_status(unsigned char);
164extern void rtas_restart(char *cmd);
165extern void rtas_power_off(void);
166extern void rtas_halt(void);
167extern void rtas_os_term(char *str);
168extern int rtas_get_sensor(int sensor, int index, int *state);
169extern int rtas_get_power_level(int powerdomain, int *level);
170extern int rtas_set_power_level(int powerdomain, int level, int *setlevel);
171extern int rtas_set_indicator(int indicator, int index, int new_value);
172extern void rtas_progress(char *s, unsigned short hex);
173extern void rtas_initialize(void);
174
175struct rtc_time;
176extern unsigned long rtas_get_boot_time(void);
177extern void rtas_get_rtc_time(struct rtc_time *rtc_time);
178extern int rtas_set_rtc_time(struct rtc_time *rtc_time);
179
180/* Given an RTAS status code of 9900..9905 compute the hinted delay */
181unsigned int rtas_extended_busy_delay_time(int status);
182static inline int rtas_is_extended_busy(int status)
183{
184 return status >= 9900 && status <= 9909;
185}
186
187extern void pSeries_log_error(char *buf, unsigned int err_type, int fatal);
188
189/* Error types logged. */
190#define ERR_FLAG_ALREADY_LOGGED 0x0
191#define ERR_FLAG_BOOT 0x1 /* log was pulled from NVRAM on boot */
192#define ERR_TYPE_RTAS_LOG 0x2 /* from rtas event-scan */
193#define ERR_TYPE_KERNEL_PANIC 0x4 /* from panic() */
194
195/* All the types and not flags */
196#define ERR_TYPE_MASK (ERR_TYPE_RTAS_LOG | ERR_TYPE_KERNEL_PANIC)
197
198#define RTAS_DEBUG KERN_DEBUG "RTAS: "
199
200#define RTAS_ERROR_LOG_MAX 2048
201
202/*
203 * Return the firmware-specified size of the error log buffer
204 * for all rtas calls that require an error buffer argument.
205 * This includes 'check-exception' and 'rtas-last-error'.
206 */
207extern int rtas_get_error_log_max(void);
208
209/* Event Scan Parameters */
210#define EVENT_SCAN_ALL_EVENTS 0xf0000000
211#define SURVEILLANCE_TOKEN 9000
212#define LOG_NUMBER 64 /* must be a power of two */
213#define LOG_NUMBER_MASK (LOG_NUMBER-1)
214
215/* Some RTAS ops require a data buffer and that buffer must be < 4G.
216 * Rather than having a memory allocator, just use this buffer
217 * (get the lock first), make the RTAS call. Copy the data instead
218 * of holding the buffer for long.
219 */
220
221#define RTAS_DATA_BUF_SIZE 4096
222extern spinlock_t rtas_data_buf_lock;
223extern char rtas_data_buf[RTAS_DATA_BUF_SIZE];
224
225extern void rtas_stop_self(void);
226
227/* RMO buffer reserved for user-space RTAS use */
228extern unsigned long rtas_rmo_buf;
229
230#define GLOBAL_INTERRUPT_QUEUE 9005
231
232#endif /* _POWERPC_RTAS_H */
diff --git a/include/asm-powerpc/rtc.h b/include/asm-powerpc/rtc.h
new file mode 100644
index 000000000000..f5802926b6c0
--- /dev/null
+++ b/include/asm-powerpc/rtc.h
@@ -0,0 +1,78 @@
1/*
2 * Real-time clock definitions and interfaces
3 *
4 * Author: Tom Rini <trini@mvista.com>
5 *
6 * 2002 (c) MontaVista, Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 *
11 * Based on:
12 * include/asm-m68k/rtc.h
13 *
14 * Copyright Richard Zidlicky
15 * implementation details for genrtc/q40rtc driver
16 *
17 * And the old drivers/macintosh/rtc.c which was heavily based on:
18 * Linux/SPARC Real Time Clock Driver
19 * Copyright (C) 1996 Thomas K. Dyas (tdyas@eden.rutgers.edu)
20 *
21 * With additional work by Paul Mackerras and Franz Sirl.
22 */
23
24#ifndef __ASM_POWERPC_RTC_H__
25#define __ASM_POWERPC_RTC_H__
26
27#ifdef __KERNEL__
28
29#include <linux/rtc.h>
30
31#include <asm/machdep.h>
32#include <asm/time.h>
33
34#define RTC_PIE 0x40 /* periodic interrupt enable */
35#define RTC_AIE 0x20 /* alarm interrupt enable */
36#define RTC_UIE 0x10 /* update-finished interrupt enable */
37
38/* some dummy definitions */
39#define RTC_BATT_BAD 0x100 /* battery bad */
40#define RTC_SQWE 0x08 /* enable square-wave output */
41#define RTC_DM_BINARY 0x04 /* all time/date values are BCD if clear */
42#define RTC_24H 0x02 /* 24 hour mode - else hours bit 7 means pm */
43#define RTC_DST_EN 0x01 /* auto switch DST - works f. USA only */
44
45static inline unsigned int get_rtc_time(struct rtc_time *time)
46{
47 if (ppc_md.get_rtc_time)
48 ppc_md.get_rtc_time(time);
49 return RTC_24H;
50}
51
52/* Set the current date and time in the real time clock. */
53static inline int set_rtc_time(struct rtc_time *time)
54{
55 if (ppc_md.set_rtc_time)
56 return ppc_md.set_rtc_time(time);
57 return -EINVAL;
58}
59
60static inline unsigned int get_rtc_ss(void)
61{
62 struct rtc_time h;
63
64 get_rtc_time(&h);
65 return h.tm_sec;
66}
67
68static inline int get_rtc_pll(struct rtc_pll_info *pll)
69{
70 return -EINVAL;
71}
72static inline int set_rtc_pll(struct rtc_pll_info *pll)
73{
74 return -EINVAL;
75}
76
77#endif /* __KERNEL__ */
78#endif /* __ASM_POWERPC_RTC_H__ */
diff --git a/include/asm-powerpc/rwsem.h b/include/asm-powerpc/rwsem.h
new file mode 100644
index 000000000000..79bae4933b73
--- /dev/null
+++ b/include/asm-powerpc/rwsem.h
@@ -0,0 +1,168 @@
1#ifndef _ASM_POWERPC_RWSEM_H
2#define _ASM_POWERPC_RWSEM_H
3
4#ifdef __KERNEL__
5
6/*
7 * include/asm-ppc64/rwsem.h: R/W semaphores for PPC using the stuff
8 * in lib/rwsem.c. Adapted largely from include/asm-i386/rwsem.h
9 * by Paul Mackerras <paulus@samba.org>.
10 */
11
12#include <linux/list.h>
13#include <linux/spinlock.h>
14#include <asm/atomic.h>
15#include <asm/system.h>
16
17/*
18 * the semaphore definition
19 */
20struct rw_semaphore {
21 /* XXX this should be able to be an atomic_t -- paulus */
22 signed int count;
23#define RWSEM_UNLOCKED_VALUE 0x00000000
24#define RWSEM_ACTIVE_BIAS 0x00000001
25#define RWSEM_ACTIVE_MASK 0x0000ffff
26#define RWSEM_WAITING_BIAS (-0x00010000)
27#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
28#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
29 spinlock_t wait_lock;
30 struct list_head wait_list;
31#if RWSEM_DEBUG
32 int debug;
33#endif
34};
35
36/*
37 * initialisation
38 */
39#if RWSEM_DEBUG
40#define __RWSEM_DEBUG_INIT , 0
41#else
42#define __RWSEM_DEBUG_INIT /* */
43#endif
44
45#define __RWSEM_INITIALIZER(name) \
46 { RWSEM_UNLOCKED_VALUE, SPIN_LOCK_UNLOCKED, \
47 LIST_HEAD_INIT((name).wait_list) \
48 __RWSEM_DEBUG_INIT }
49
50#define DECLARE_RWSEM(name) \
51 struct rw_semaphore name = __RWSEM_INITIALIZER(name)
52
53extern struct rw_semaphore *rwsem_down_read_failed(struct rw_semaphore *sem);
54extern struct rw_semaphore *rwsem_down_write_failed(struct rw_semaphore *sem);
55extern struct rw_semaphore *rwsem_wake(struct rw_semaphore *sem);
56extern struct rw_semaphore *rwsem_downgrade_wake(struct rw_semaphore *sem);
57
58static inline void init_rwsem(struct rw_semaphore *sem)
59{
60 sem->count = RWSEM_UNLOCKED_VALUE;
61 spin_lock_init(&sem->wait_lock);
62 INIT_LIST_HEAD(&sem->wait_list);
63#if RWSEM_DEBUG
64 sem->debug = 0;
65#endif
66}
67
68/*
69 * lock for reading
70 */
71static inline void __down_read(struct rw_semaphore *sem)
72{
73 if (unlikely(atomic_inc_return((atomic_t *)(&sem->count)) <= 0))
74 rwsem_down_read_failed(sem);
75}
76
77static inline int __down_read_trylock(struct rw_semaphore *sem)
78{
79 int tmp;
80
81 while ((tmp = sem->count) >= 0) {
82 if (tmp == cmpxchg(&sem->count, tmp,
83 tmp + RWSEM_ACTIVE_READ_BIAS)) {
84 return 1;
85 }
86 }
87 return 0;
88}
89
90/*
91 * lock for writing
92 */
93static inline void __down_write(struct rw_semaphore *sem)
94{
95 int tmp;
96
97 tmp = atomic_add_return(RWSEM_ACTIVE_WRITE_BIAS,
98 (atomic_t *)(&sem->count));
99 if (unlikely(tmp != RWSEM_ACTIVE_WRITE_BIAS))
100 rwsem_down_write_failed(sem);
101}
102
103static inline int __down_write_trylock(struct rw_semaphore *sem)
104{
105 int tmp;
106
107 tmp = cmpxchg(&sem->count, RWSEM_UNLOCKED_VALUE,
108 RWSEM_ACTIVE_WRITE_BIAS);
109 return tmp == RWSEM_UNLOCKED_VALUE;
110}
111
112/*
113 * unlock after reading
114 */
115static inline void __up_read(struct rw_semaphore *sem)
116{
117 int tmp;
118
119 tmp = atomic_dec_return((atomic_t *)(&sem->count));
120 if (unlikely(tmp < -1 && (tmp & RWSEM_ACTIVE_MASK) == 0))
121 rwsem_wake(sem);
122}
123
124/*
125 * unlock after writing
126 */
127static inline void __up_write(struct rw_semaphore *sem)
128{
129 if (unlikely(atomic_sub_return(RWSEM_ACTIVE_WRITE_BIAS,
130 (atomic_t *)(&sem->count)) < 0))
131 rwsem_wake(sem);
132}
133
134/*
135 * implement atomic add functionality
136 */
137static inline void rwsem_atomic_add(int delta, struct rw_semaphore *sem)
138{
139 atomic_add(delta, (atomic_t *)(&sem->count));
140}
141
142/*
143 * downgrade write lock to read lock
144 */
145static inline void __downgrade_write(struct rw_semaphore *sem)
146{
147 int tmp;
148
149 tmp = atomic_add_return(-RWSEM_WAITING_BIAS, (atomic_t *)(&sem->count));
150 if (tmp < 0)
151 rwsem_downgrade_wake(sem);
152}
153
154/*
155 * implement exchange and add functionality
156 */
157static inline int rwsem_atomic_update(int delta, struct rw_semaphore *sem)
158{
159 return atomic_add_return(delta, (atomic_t *)(&sem->count));
160}
161
162static inline int rwsem_is_locked(struct rw_semaphore *sem)
163{
164 return (sem->count != 0);
165}
166
167#endif /* __KERNEL__ */
168#endif /* _ASM_POWERPC_RWSEM_H */
diff --git a/include/asm-powerpc/scatterlist.h b/include/asm-powerpc/scatterlist.h
new file mode 100644
index 000000000000..8c992d1491d4
--- /dev/null
+++ b/include/asm-powerpc/scatterlist.h
@@ -0,0 +1,45 @@
1#ifndef _ASM_POWERPC_SCATTERLIST_H
2#define _ASM_POWERPC_SCATTERLIST_H
3/*
4 * Copyright (C) 2001 PPC64 Team, 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#ifdef __KERNEL__
13#include <linux/types.h>
14#include <asm/dma.h>
15
16struct scatterlist {
17 struct page *page;
18 unsigned int offset;
19 unsigned int length;
20
21 /* For TCE support */
22 dma_addr_t dma_address;
23 u32 dma_length;
24};
25
26/*
27 * These macros should be used after a dma_map_sg call has been done
28 * to get bus addresses of each of the SG entries and their lengths.
29 * You should only work with the number of sg entries pci_map_sg
30 * returns, or alternatively stop on the first sg_dma_len(sg) which
31 * is 0.
32 */
33#define sg_dma_address(sg) ((sg)->dma_address)
34#ifdef __powerpc64__
35#define sg_dma_len(sg) ((sg)->dma_length)
36#else
37#define sg_dma_len(sg) ((sg)->length)
38#endif
39
40#ifdef __powerpc64__
41#define ISA_DMA_THRESHOLD (~0UL)
42#endif
43
44#endif /* __KERNEL__ */
45#endif /* _ASM_POWERPC_SCATTERLIST_H */
diff --git a/include/asm-powerpc/seccomp.h b/include/asm-powerpc/seccomp.h
new file mode 100644
index 000000000000..1e1cfe12882b
--- /dev/null
+++ b/include/asm-powerpc/seccomp.h
@@ -0,0 +1,16 @@
1#ifndef _ASM_POWERPC_SECCOMP_H
2
3#include <linux/thread_info.h>
4#include <linux/unistd.h>
5
6#define __NR_seccomp_read __NR_read
7#define __NR_seccomp_write __NR_write
8#define __NR_seccomp_exit __NR_exit
9#define __NR_seccomp_sigreturn __NR_rt_sigreturn
10
11#define __NR_seccomp_read_32 __NR_read
12#define __NR_seccomp_write_32 __NR_write
13#define __NR_seccomp_exit_32 __NR_exit
14#define __NR_seccomp_sigreturn_32 __NR_sigreturn
15
16#endif /* _ASM_POWERPC_SECCOMP_H */
diff --git a/include/asm-powerpc/sections.h b/include/asm-powerpc/sections.h
new file mode 100644
index 000000000000..47be2ac2a925
--- /dev/null
+++ b/include/asm-powerpc/sections.h
@@ -0,0 +1,20 @@
1#ifndef _ASM_POWERPC_SECTIONS_H
2#define _ASM_POWERPC_SECTIONS_H
3
4#include <asm-generic/sections.h>
5
6#ifdef __powerpc64__
7
8extern char _end[];
9
10static inline int in_kernel_text(unsigned long addr)
11{
12 if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
13 return 1;
14
15 return 0;
16}
17
18#endif
19
20#endif /* _ASM_POWERPC_SECTIONS_H */
diff --git a/include/asm-powerpc/semaphore.h b/include/asm-powerpc/semaphore.h
new file mode 100644
index 000000000000..57369d2cadef
--- /dev/null
+++ b/include/asm-powerpc/semaphore.h
@@ -0,0 +1,95 @@
1#ifndef _ASM_POWERPC_SEMAPHORE_H
2#define _ASM_POWERPC_SEMAPHORE_H
3
4/*
5 * Remove spinlock-based RW semaphores; RW semaphore definitions are
6 * now in rwsem.h and we use the generic lib/rwsem.c implementation.
7 * Rework semaphores to use atomic_dec_if_positive.
8 * -- Paul Mackerras (paulus@samba.org)
9 */
10
11#ifdef __KERNEL__
12
13#include <asm/atomic.h>
14#include <asm/system.h>
15#include <linux/wait.h>
16#include <linux/rwsem.h>
17
18struct semaphore {
19 /*
20 * Note that any negative value of count is equivalent to 0,
21 * but additionally indicates that some process(es) might be
22 * sleeping on `wait'.
23 */
24 atomic_t count;
25 wait_queue_head_t wait;
26};
27
28#define __SEMAPHORE_INITIALIZER(name, n) \
29{ \
30 .count = ATOMIC_INIT(n), \
31 .wait = __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
32}
33
34#define __DECLARE_SEMAPHORE_GENERIC(name, count) \
35 struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
36
37#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name, 1)
38#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name, 0)
39
40static inline void sema_init (struct semaphore *sem, int val)
41{
42 atomic_set(&sem->count, val);
43 init_waitqueue_head(&sem->wait);
44}
45
46static inline void init_MUTEX (struct semaphore *sem)
47{
48 sema_init(sem, 1);
49}
50
51static inline void init_MUTEX_LOCKED (struct semaphore *sem)
52{
53 sema_init(sem, 0);
54}
55
56extern void __down(struct semaphore * sem);
57extern int __down_interruptible(struct semaphore * sem);
58extern void __up(struct semaphore * sem);
59
60static inline void down(struct semaphore * sem)
61{
62 might_sleep();
63
64 /*
65 * Try to get the semaphore, take the slow path if we fail.
66 */
67 if (unlikely(atomic_dec_return(&sem->count) < 0))
68 __down(sem);
69}
70
71static inline int down_interruptible(struct semaphore * sem)
72{
73 int ret = 0;
74
75 might_sleep();
76
77 if (unlikely(atomic_dec_return(&sem->count) < 0))
78 ret = __down_interruptible(sem);
79 return ret;
80}
81
82static inline int down_trylock(struct semaphore * sem)
83{
84 return atomic_dec_if_positive(&sem->count) < 0;
85}
86
87static inline void up(struct semaphore * sem)
88{
89 if (unlikely(atomic_inc_return(&sem->count) <= 0))
90 __up(sem);
91}
92
93#endif /* __KERNEL__ */
94
95#endif /* _ASM_POWERPC_SEMAPHORE_H */
diff --git a/include/asm-powerpc/serial.h b/include/asm-powerpc/serial.h
new file mode 100644
index 000000000000..b273d630b32f
--- /dev/null
+++ b/include/asm-powerpc/serial.h
@@ -0,0 +1,18 @@
1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version
5 * 2 of the License, or (at your option) any later version.
6 */
7#ifndef _ASM_POWERPC_SERIAL_H
8#define _ASM_POWERPC_SERIAL_H
9
10/*
11 * Serial ports are not listed here, because they are discovered
12 * through the device tree.
13 */
14
15/* Default baud base if not found in device-tree */
16#define BASE_BAUD ( 1843200 / 16 )
17
18#endif /* _PPC64_SERIAL_H */
diff --git a/include/asm-powerpc/sigcontext.h b/include/asm-powerpc/sigcontext.h
new file mode 100644
index 000000000000..165d630e1cf3
--- /dev/null
+++ b/include/asm-powerpc/sigcontext.h
@@ -0,0 +1,52 @@
1#ifndef _ASM_POWERPC_SIGCONTEXT_H
2#define _ASM_POWERPC_SIGCONTEXT_H
3
4/*
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
9 */
10#include <linux/compiler.h>
11#include <asm/ptrace.h>
12#ifdef __powerpc64__
13#include <asm/elf.h>
14#endif
15
16struct sigcontext {
17 unsigned long _unused[4];
18 int signal;
19#ifdef __powerpc64__
20 int _pad0;
21#endif
22 unsigned long handler;
23 unsigned long oldmask;
24 struct pt_regs __user *regs;
25#ifdef __powerpc64__
26 elf_gregset_t gp_regs;
27 elf_fpregset_t fp_regs;
28/*
29 * To maintain compatibility with current implementations the sigcontext is
30 * extended by appending a pointer (v_regs) to a quadword type (elf_vrreg_t)
31 * followed by an unstructured (vmx_reserve) field of 69 doublewords. This
32 * allows the array of vector registers to be quadword aligned independent of
33 * the alignment of the containing sigcontext or ucontext. It is the
34 * responsibility of the code setting the sigcontext to set this pointer to
35 * either NULL (if this processor does not support the VMX feature) or the
36 * address of the first quadword within the allocated (vmx_reserve) area.
37 *
38 * The pointer (v_regs) of vector type (elf_vrreg_t) is type compatible with
39 * an array of 34 quadword entries (elf_vrregset_t). The entries with
40 * indexes 0-31 contain the corresponding vector registers. The entry with
41 * index 32 contains the vscr as the last word (offset 12) within the
42 * quadword. This allows the vscr to be stored as either a quadword (since
43 * it must be copied via a vector register to/from storage) or as a word.
44 * The entry with index 33 contains the vrsave as the first word (offset 0)
45 * within the quadword.
46 */
47 elf_vrreg_t __user *v_regs;
48 long vmx_reserve[ELF_NVRREG+ELF_NVRREG+1];
49#endif
50};
51
52#endif /* _ASM_POWERPC_SIGCONTEXT_H */
diff --git a/include/asm-powerpc/signal.h b/include/asm-powerpc/signal.h
new file mode 100644
index 000000000000..694c8d2dab87
--- /dev/null
+++ b/include/asm-powerpc/signal.h
@@ -0,0 +1,150 @@
1#ifndef _ASM_POWERPC_SIGNAL_H
2#define _ASM_POWERPC_SIGNAL_H
3
4#include <linux/types.h>
5#include <linux/config.h>
6
7#define _NSIG 64
8#define _NSIG_BPW BITS_PER_LONG
9#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
10
11typedef unsigned long old_sigset_t; /* at least 32 bits */
12
13typedef struct {
14 unsigned long sig[_NSIG_WORDS];
15} sigset_t;
16
17#define SIGHUP 1
18#define SIGINT 2
19#define SIGQUIT 3
20#define SIGILL 4
21#define SIGTRAP 5
22#define SIGABRT 6
23#define SIGIOT 6
24#define SIGBUS 7
25#define SIGFPE 8
26#define SIGKILL 9
27#define SIGUSR1 10
28#define SIGSEGV 11
29#define SIGUSR2 12
30#define SIGPIPE 13
31#define SIGALRM 14
32#define SIGTERM 15
33#define SIGSTKFLT 16
34#define SIGCHLD 17
35#define SIGCONT 18
36#define SIGSTOP 19
37#define SIGTSTP 20
38#define SIGTTIN 21
39#define SIGTTOU 22
40#define SIGURG 23
41#define SIGXCPU 24
42#define SIGXFSZ 25
43#define SIGVTALRM 26
44#define SIGPROF 27
45#define SIGWINCH 28
46#define SIGIO 29
47#define SIGPOLL SIGIO
48/*
49#define SIGLOST 29
50*/
51#define SIGPWR 30
52#define SIGSYS 31
53#define SIGUNUSED 31
54
55/* These should not be considered constants from userland. */
56#define SIGRTMIN 32
57#define SIGRTMAX _NSIG
58
59/*
60 * SA_FLAGS values:
61 *
62 * SA_ONSTACK is not currently supported, but will allow sigaltstack(2).
63 * SA_INTERRUPT is a no-op, but left due to historical reasons. Use the
64 * SA_RESTART flag to get restarting signals (which were the default long ago)
65 * SA_NOCLDSTOP flag to turn off SIGCHLD when children stop.
66 * SA_RESETHAND clears the handler when the signal is delivered.
67 * SA_NOCLDWAIT flag on SIGCHLD to inhibit zombies.
68 * SA_NODEFER prevents the current signal from being masked in the handler.
69 *
70 * SA_ONESHOT and SA_NOMASK are the historical Linux names for the Single
71 * Unix names RESETHAND and NODEFER respectively.
72 */
73#define SA_NOCLDSTOP 0x00000001U
74#define SA_NOCLDWAIT 0x00000002U
75#define SA_SIGINFO 0x00000004U
76#define SA_ONSTACK 0x08000000U
77#define SA_RESTART 0x10000000U
78#define SA_NODEFER 0x40000000U
79#define SA_RESETHAND 0x80000000U
80
81#define SA_NOMASK SA_NODEFER
82#define SA_ONESHOT SA_RESETHAND
83#define SA_INTERRUPT 0x20000000u /* dummy -- ignored */
84
85#define SA_RESTORER 0x04000000U
86
87/*
88 * sigaltstack controls
89 */
90#define SS_ONSTACK 1
91#define SS_DISABLE 2
92
93#define MINSIGSTKSZ 2048
94#define SIGSTKSZ 8192
95
96#include <asm-generic/signal.h>
97
98struct old_sigaction {
99 __sighandler_t sa_handler;
100 old_sigset_t sa_mask;
101 unsigned long sa_flags;
102 __sigrestore_t sa_restorer;
103};
104
105struct sigaction {
106 __sighandler_t sa_handler;
107 unsigned long sa_flags;
108 __sigrestore_t sa_restorer;
109 sigset_t sa_mask; /* mask last for extensibility */
110};
111
112struct k_sigaction {
113 struct sigaction sa;
114};
115
116typedef struct sigaltstack {
117 void __user *ss_sp;
118 int ss_flags;
119 size_t ss_size;
120} stack_t;
121
122#ifdef __KERNEL__
123struct pt_regs;
124extern int do_signal(sigset_t *oldset, struct pt_regs *regs);
125extern int do_signal32(sigset_t *oldset, struct pt_regs *regs);
126#define ptrace_signal_deliver(regs, cookie) do { } while (0)
127#endif /* __KERNEL__ */
128
129#ifndef __powerpc64__
130/*
131 * These are parameters to dbg_sigreturn syscall. They enable or
132 * disable certain debugging things that can be done from signal
133 * handlers. The dbg_sigreturn syscall *must* be called from a
134 * SA_SIGINFO signal so the ucontext can be passed to it. It takes an
135 * array of struct sig_dbg_op, which has the debug operations to
136 * perform before returning from the signal.
137 */
138struct sig_dbg_op {
139 int dbg_type;
140 unsigned long dbg_value;
141};
142
143/* Enable or disable single-stepping. The value sets the state. */
144#define SIG_DBG_SINGLE_STEPPING 1
145
146/* Enable or disable branch tracing. The value sets the state. */
147#define SIG_DBG_BRANCH_TRACING 2
148#endif /* ! __powerpc64__ */
149
150#endif /* _ASM_POWERPC_SIGNAL_H */
diff --git a/include/asm-powerpc/smp.h b/include/asm-powerpc/smp.h
new file mode 100644
index 000000000000..98581e5a8279
--- /dev/null
+++ b/include/asm-powerpc/smp.h
@@ -0,0 +1,121 @@
1/*
2 * smp.h: PowerPC-specific SMP code.
3 *
4 * Original was a copy of sparc smp.h. Now heavily modified
5 * for PPC.
6 *
7 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
8 * Copyright (C) 1996-2001 Cort Dougan <cort@fsmlabs.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version
13 * 2 of the License, or (at your option) any later version.
14 */
15
16#ifndef _ASM_POWERPC_SMP_H
17#define _ASM_POWERPC_SMP_H
18#ifdef __KERNEL__
19
20#include <linux/config.h>
21#include <linux/threads.h>
22#include <linux/cpumask.h>
23#include <linux/kernel.h>
24
25#ifndef __ASSEMBLY__
26
27#ifdef CONFIG_PPC64
28#include <asm/paca.h>
29#endif
30
31extern int boot_cpuid;
32extern int boot_cpuid_phys;
33
34extern void cpu_die(void);
35
36#ifdef CONFIG_SMP
37
38extern void smp_send_debugger_break(int cpu);
39struct pt_regs;
40extern void smp_message_recv(int, struct pt_regs *);
41
42#ifdef CONFIG_HOTPLUG_CPU
43extern void fixup_irqs(cpumask_t map);
44int generic_cpu_disable(void);
45int generic_cpu_enable(unsigned int cpu);
46void generic_cpu_die(unsigned int cpu);
47void generic_mach_cpu_die(void);
48#endif
49
50#ifdef CONFIG_PPC64
51#define raw_smp_processor_id() (get_paca()->paca_index)
52#define hard_smp_processor_id() (get_paca()->hw_cpu_id)
53#else
54/* 32-bit */
55extern int smp_hw_index[];
56
57#define raw_smp_processor_id() (current_thread_info()->cpu)
58#define hard_smp_processor_id() (smp_hw_index[smp_processor_id()])
59#define get_hard_smp_processor_id(cpu) (smp_hw_index[(cpu)])
60#define set_hard_smp_processor_id(cpu, phys)\
61 (smp_hw_index[(cpu)] = (phys))
62#endif
63
64extern cpumask_t cpu_sibling_map[NR_CPUS];
65
66/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
67 *
68 * Make sure this matches openpic_request_IPIs in open_pic.c, or what shows up
69 * in /proc/interrupts will be wrong!!! --Troy */
70#define PPC_MSG_CALL_FUNCTION 0
71#define PPC_MSG_RESCHEDULE 1
72/* This is unused now */
73#if 0
74#define PPC_MSG_MIGRATE_TASK 2
75#endif
76#define PPC_MSG_DEBUGGER_BREAK 3
77
78void smp_init_iSeries(void);
79void smp_init_pSeries(void);
80void smp_init_cell(void);
81void smp_setup_cpu_maps(void);
82
83extern int __cpu_disable(void);
84extern void __cpu_die(unsigned int cpu);
85
86#else
87/* for UP */
88#define smp_setup_cpu_maps()
89
90#endif /* CONFIG_SMP */
91
92#ifdef CONFIG_PPC64
93#define get_hard_smp_processor_id(CPU) (paca[(CPU)].hw_cpu_id)
94#define set_hard_smp_processor_id(CPU, VAL) \
95 do { (paca[(CPU)].hw_cpu_id = (VAL)); } while (0)
96
97extern void smp_release_cpus(void);
98
99#else
100/* 32-bit */
101#ifndef CONFIG_SMP
102#define get_hard_smp_processor_id(cpu) boot_cpuid_phys
103#define set_hard_smp_processor_id(cpu, phys)
104#endif
105#endif
106
107extern int smt_enabled_at_boot;
108
109extern int smp_mpic_probe(void);
110extern void smp_mpic_setup_cpu(int cpu);
111extern void smp_generic_kick_cpu(int nr);
112
113extern void smp_generic_give_timebase(void);
114extern void smp_generic_take_timebase(void);
115
116extern struct smp_ops_t *smp_ops;
117
118#endif /* __ASSEMBLY__ */
119
120#endif /* __KERNEL__ */
121#endif /* _ASM_POWERPC_SMP_H) */
diff --git a/include/asm-powerpc/smu.h b/include/asm-powerpc/smu.h
new file mode 100644
index 000000000000..76c29a9784dd
--- /dev/null
+++ b/include/asm-powerpc/smu.h
@@ -0,0 +1,570 @@
1#ifndef _SMU_H
2#define _SMU_H
3
4/*
5 * Definitions for talking to the SMU chip in newer G5 PowerMacs
6 */
7
8#include <linux/config.h>
9#include <linux/list.h>
10
11/*
12 * Known SMU commands
13 *
14 * Most of what is below comes from looking at the Open Firmware driver,
15 * though this is still incomplete and could use better documentation here
16 * or there...
17 */
18
19
20/*
21 * Partition info commands
22 *
23 * These commands are used to retreive the sdb-partition-XX datas from
24 * the SMU. The lenght is always 2. First byte is the subcommand code
25 * and second byte is the partition ID.
26 *
27 * The reply is 6 bytes:
28 *
29 * - 0..1 : partition address
30 * - 2 : a byte containing the partition ID
31 * - 3 : length (maybe other bits are rest of header ?)
32 *
33 * The data must then be obtained with calls to another command:
34 * SMU_CMD_MISC_ee_GET_DATABLOCK_REC (described below).
35 */
36#define SMU_CMD_PARTITION_COMMAND 0x3e
37#define SMU_CMD_PARTITION_LATEST 0x01
38#define SMU_CMD_PARTITION_BASE 0x02
39#define SMU_CMD_PARTITION_UPDATE 0x03
40
41
42/*
43 * Fan control
44 *
45 * This is a "mux" for fan control commands. The command seem to
46 * act differently based on the number of arguments. With 1 byte
47 * of argument, this seem to be queries for fans status, setpoint,
48 * etc..., while with 0xe arguments, we will set the fans speeds.
49 *
50 * Queries (1 byte arg):
51 * ---------------------
52 *
53 * arg=0x01: read RPM fans status
54 * arg=0x02: read RPM fans setpoint
55 * arg=0x11: read PWM fans status
56 * arg=0x12: read PWM fans setpoint
57 *
58 * the "status" queries return the current speed while the "setpoint" ones
59 * return the programmed/target speed. It _seems_ that the result is a bit
60 * mask in the first byte of active/available fans, followed by 6 words (16
61 * bits) containing the requested speed.
62 *
63 * Setpoint (14 bytes arg):
64 * ------------------------
65 *
66 * first arg byte is 0 for RPM fans and 0x10 for PWM. Second arg byte is the
67 * mask of fans affected by the command. Followed by 6 words containing the
68 * setpoint value for selected fans in the mask (or 0 if mask value is 0)
69 */
70#define SMU_CMD_FAN_COMMAND 0x4a
71
72
73/*
74 * Battery access
75 *
76 * Same command number as the PMU, could it be same syntax ?
77 */
78#define SMU_CMD_BATTERY_COMMAND 0x6f
79#define SMU_CMD_GET_BATTERY_INFO 0x00
80
81/*
82 * Real time clock control
83 *
84 * This is a "mux", first data byte contains the "sub" command.
85 * The "RTC" part of the SMU controls the date, time, powerup
86 * timer, but also a PRAM
87 *
88 * Dates are in BCD format on 7 bytes:
89 * [sec] [min] [hour] [weekday] [month day] [month] [year]
90 * with month being 1 based and year minus 100
91 */
92#define SMU_CMD_RTC_COMMAND 0x8e
93#define SMU_CMD_RTC_SET_PWRUP_TIMER 0x00 /* i: 7 bytes date */
94#define SMU_CMD_RTC_GET_PWRUP_TIMER 0x01 /* o: 7 bytes date */
95#define SMU_CMD_RTC_STOP_PWRUP_TIMER 0x02
96#define SMU_CMD_RTC_SET_PRAM_BYTE_ACC 0x20 /* i: 1 byte (address?) */
97#define SMU_CMD_RTC_SET_PRAM_AUTOINC 0x21 /* i: 1 byte (data?) */
98#define SMU_CMD_RTC_SET_PRAM_LO_BYTES 0x22 /* i: 10 bytes */
99#define SMU_CMD_RTC_SET_PRAM_HI_BYTES 0x23 /* i: 10 bytes */
100#define SMU_CMD_RTC_GET_PRAM_BYTE 0x28 /* i: 1 bytes (address?) */
101#define SMU_CMD_RTC_GET_PRAM_LO_BYTES 0x29 /* o: 10 bytes */
102#define SMU_CMD_RTC_GET_PRAM_HI_BYTES 0x2a /* o: 10 bytes */
103#define SMU_CMD_RTC_SET_DATETIME 0x80 /* i: 7 bytes date */
104#define SMU_CMD_RTC_GET_DATETIME 0x81 /* o: 7 bytes date */
105
106 /*
107 * i2c commands
108 *
109 * To issue an i2c command, first is to send a parameter block to the
110 * the SMU. This is a command of type 0x9a with 9 bytes of header
111 * eventually followed by data for a write:
112 *
113 * 0: bus number (from device-tree usually, SMU has lots of busses !)
114 * 1: transfer type/format (see below)
115 * 2: device address. For combined and combined4 type transfers, this
116 * is the "write" version of the address (bit 0x01 cleared)
117 * 3: subaddress length (0..3)
118 * 4: subaddress byte 0 (or only byte for subaddress length 1)
119 * 5: subaddress byte 1
120 * 6: subaddress byte 2
121 * 7: combined address (device address for combined mode data phase)
122 * 8: data length
123 *
124 * The transfer types are the same good old Apple ones it seems,
125 * that is:
126 * - 0x00: Simple transfer
127 * - 0x01: Subaddress transfer (addr write + data tx, no restart)
128 * - 0x02: Combined transfer (addr write + restart + data tx)
129 *
130 * This is then followed by actual data for a write.
131 *
132 * At this point, the OF driver seems to have a limitation on transfer
133 * sizes of 0xd bytes on reads and 0x5 bytes on writes. I do not know
134 * wether this is just an OF limit due to some temporary buffer size
135 * or if this is an SMU imposed limit. This driver has the same limitation
136 * for now as I use a 0x10 bytes temporary buffer as well
137 *
138 * Once that is completed, a response is expected from the SMU. This is
139 * obtained via a command of type 0x9a with a length of 1 byte containing
140 * 0 as the data byte. OF also fills the rest of the data buffer with 0xff's
141 * though I can't tell yet if this is actually necessary. Once this command
142 * is complete, at this point, all I can tell is what OF does. OF tests
143 * byte 0 of the reply:
144 * - on read, 0xfe or 0xfc : bus is busy, wait (see below) or nak ?
145 * - on read, 0x00 or 0x01 : reply is in buffer (after the byte 0)
146 * - on write, < 0 -> failure (immediate exit)
147 * - else, OF just exists (without error, weird)
148 *
149 * So on read, there is this wait-for-busy thing when getting a 0xfc or
150 * 0xfe result. OF does a loop of up to 64 retries, waiting 20ms and
151 * doing the above again until either the retries expire or the result
152 * is no longer 0xfe or 0xfc
153 *
154 * The Darwin I2C driver is less subtle though. On any non-success status
155 * from the response command, it waits 5ms and tries again up to 20 times,
156 * it doesn't differenciate between fatal errors or "busy" status.
157 *
158 * This driver provides an asynchronous paramblock based i2c command
159 * interface to be used either directly by low level code or by a higher
160 * level driver interfacing to the linux i2c layer. The current
161 * implementation of this relies on working timers & timer interrupts
162 * though, so be careful of calling context for now. This may be "fixed"
163 * in the future by adding a polling facility.
164 */
165#define SMU_CMD_I2C_COMMAND 0x9a
166 /* transfer types */
167#define SMU_I2C_TRANSFER_SIMPLE 0x00
168#define SMU_I2C_TRANSFER_STDSUB 0x01
169#define SMU_I2C_TRANSFER_COMBINED 0x02
170
171/*
172 * Power supply control
173 *
174 * The "sub" command is an ASCII string in the data, the
175 * data lenght is that of the string.
176 *
177 * The VSLEW command can be used to get or set the voltage slewing.
178 * - lenght 5 (only "VSLEW") : it returns "DONE" and 3 bytes of
179 * reply at data offset 6, 7 and 8.
180 * - lenght 8 ("VSLEWxyz") has 3 additional bytes appended, and is
181 * used to set the voltage slewing point. The SMU replies with "DONE"
182 * I yet have to figure out their exact meaning of those 3 bytes in
183 * both cases. They seem to be:
184 * x = processor mask
185 * y = op. point index
186 * z = processor freq. step index
187 * I haven't yet decyphered result codes
188 *
189 */
190#define SMU_CMD_POWER_COMMAND 0xaa
191#define SMU_CMD_POWER_RESTART "RESTART"
192#define SMU_CMD_POWER_SHUTDOWN "SHUTDOWN"
193#define SMU_CMD_POWER_VOLTAGE_SLEW "VSLEW"
194
195/*
196 * Read ADC sensors
197 *
198 * This command takes one byte of parameter: the sensor ID (or "reg"
199 * value in the device-tree) and returns a 16 bits value
200 */
201#define SMU_CMD_READ_ADC 0xd8
202
203/* Misc commands
204 *
205 * This command seem to be a grab bag of various things
206 */
207#define SMU_CMD_MISC_df_COMMAND 0xdf
208#define SMU_CMD_MISC_df_SET_DISPLAY_LIT 0x02 /* i: 1 byte */
209#define SMU_CMD_MISC_df_NMI_OPTION 0x04
210
211/*
212 * Version info commands
213 *
214 * I haven't quite tried to figure out how these work
215 */
216#define SMU_CMD_VERSION_COMMAND 0xea
217
218
219/*
220 * Misc commands
221 *
222 * This command seem to be a grab bag of various things
223 *
224 * SMU_CMD_MISC_ee_GET_DATABLOCK_REC is used, among others, to
225 * transfer blocks of data from the SMU. So far, I've decrypted it's
226 * usage to retreive partition data. In order to do that, you have to
227 * break your transfer in "chunks" since that command cannot transfer
228 * more than a chunk at a time. The chunk size used by OF is 0xe bytes,
229 * but it seems that the darwin driver will let you do 0x1e bytes if
230 * your "PMU" version is >= 0x30. You can get the "PMU" version apparently
231 * either in the last 16 bits of property "smu-version-pmu" or as the 16
232 * bytes at offset 1 of "smu-version-info"
233 *
234 * For each chunk, the command takes 7 bytes of arguments:
235 * byte 0: subcommand code (0x02)
236 * byte 1: 0x04 (always, I don't know what it means, maybe the address
237 * space to use or some other nicety. It's hard coded in OF)
238 * byte 2..5: SMU address of the chunk (big endian 32 bits)
239 * byte 6: size to transfer (up to max chunk size)
240 *
241 * The data is returned directly
242 */
243#define SMU_CMD_MISC_ee_COMMAND 0xee
244#define SMU_CMD_MISC_ee_GET_DATABLOCK_REC 0x02
245#define SMU_CMD_MISC_ee_LEDS_CTRL 0x04 /* i: 00 (00,01) [00] */
246#define SMU_CMD_MISC_ee_GET_DATA 0x05 /* i: 00 , o: ?? */
247
248
249
250/*
251 * - Kernel side interface -
252 */
253
254#ifdef __KERNEL__
255
256/*
257 * Asynchronous SMU commands
258 *
259 * Fill up this structure and submit it via smu_queue_command(),
260 * and get notified by the optional done() callback, or because
261 * status becomes != 1
262 */
263
264struct smu_cmd;
265
266struct smu_cmd
267{
268 /* public */
269 u8 cmd; /* command */
270 int data_len; /* data len */
271 int reply_len; /* reply len */
272 void *data_buf; /* data buffer */
273 void *reply_buf; /* reply buffer */
274 int status; /* command status */
275 void (*done)(struct smu_cmd *cmd, void *misc);
276 void *misc;
277
278 /* private */
279 struct list_head link;
280};
281
282/*
283 * Queues an SMU command, all fields have to be initialized
284 */
285extern int smu_queue_cmd(struct smu_cmd *cmd);
286
287/*
288 * Simple command wrapper. This structure embeds a small buffer
289 * to ease sending simple SMU commands from the stack
290 */
291struct smu_simple_cmd
292{
293 struct smu_cmd cmd;
294 u8 buffer[16];
295};
296
297/*
298 * Queues a simple command. All fields will be initialized by that
299 * function
300 */
301extern int smu_queue_simple(struct smu_simple_cmd *scmd, u8 command,
302 unsigned int data_len,
303 void (*done)(struct smu_cmd *cmd, void *misc),
304 void *misc,
305 ...);
306
307/*
308 * Completion helper. Pass it to smu_queue_simple or as 'done'
309 * member to smu_queue_cmd, it will call complete() on the struct
310 * completion passed in the "misc" argument
311 */
312extern void smu_done_complete(struct smu_cmd *cmd, void *misc);
313
314/*
315 * Synchronous helpers. Will spin-wait for completion of a command
316 */
317extern void smu_spinwait_cmd(struct smu_cmd *cmd);
318
319static inline void smu_spinwait_simple(struct smu_simple_cmd *scmd)
320{
321 smu_spinwait_cmd(&scmd->cmd);
322}
323
324/*
325 * Poll routine to call if blocked with irqs off
326 */
327extern void smu_poll(void);
328
329
330/*
331 * Init routine, presence check....
332 */
333extern int smu_init(void);
334extern int smu_present(void);
335struct of_device;
336extern struct of_device *smu_get_ofdev(void);
337
338
339/*
340 * Common command wrappers
341 */
342extern void smu_shutdown(void);
343extern void smu_restart(void);
344struct rtc_time;
345extern int smu_get_rtc_time(struct rtc_time *time, int spinwait);
346extern int smu_set_rtc_time(struct rtc_time *time, int spinwait);
347
348/*
349 * SMU command buffer absolute address, exported by pmac_setup,
350 * this is allocated very early during boot.
351 */
352extern unsigned long smu_cmdbuf_abs;
353
354
355/*
356 * Kenrel asynchronous i2c interface
357 */
358
359/* SMU i2c header, exactly matches i2c header on wire */
360struct smu_i2c_param
361{
362 u8 bus; /* SMU bus ID (from device tree) */
363 u8 type; /* i2c transfer type */
364 u8 devaddr; /* device address (includes direction) */
365 u8 sublen; /* subaddress length */
366 u8 subaddr[3]; /* subaddress */
367 u8 caddr; /* combined address, filled by SMU driver */
368 u8 datalen; /* length of transfer */
369 u8 data[7]; /* data */
370};
371
372#define SMU_I2C_READ_MAX 0x0d
373#define SMU_I2C_WRITE_MAX 0x05
374
375struct smu_i2c_cmd
376{
377 /* public */
378 struct smu_i2c_param info;
379 void (*done)(struct smu_i2c_cmd *cmd, void *misc);
380 void *misc;
381 int status; /* 1 = pending, 0 = ok, <0 = fail */
382
383 /* private */
384 struct smu_cmd scmd;
385 int read;
386 int stage;
387 int retries;
388 u8 pdata[0x10];
389 struct list_head link;
390};
391
392/*
393 * Call this to queue an i2c command to the SMU. You must fill info,
394 * including info.data for a write, done and misc.
395 * For now, no polling interface is provided so you have to use completion
396 * callback.
397 */
398extern int smu_queue_i2c(struct smu_i2c_cmd *cmd);
399
400
401#endif /* __KERNEL__ */
402
403
404/*
405 * - SMU "sdb" partitions informations -
406 */
407
408
409/*
410 * Partition header format
411 */
412struct smu_sdbp_header {
413 __u8 id;
414 __u8 len;
415 __u8 version;
416 __u8 flags;
417};
418
419
420 /*
421 * demangle 16 and 32 bits integer in some SMU partitions
422 * (currently, afaik, this concerns only the FVT partition
423 * (0x12)
424 */
425#define SMU_U16_MIX(x) le16_to_cpu(x);
426#define SMU_U32_MIX(x) ((((x) & 0xff00ff00u) >> 8)|(((x) & 0x00ff00ffu) << 8))
427
428
429/* This is the definition of the SMU sdb-partition-0x12 table (called
430 * CPU F/V/T operating points in Darwin). The definition for all those
431 * SMU tables should be moved to some separate file
432 */
433#define SMU_SDB_FVT_ID 0x12
434
435struct smu_sdbp_fvt {
436 __u32 sysclk; /* Base SysClk frequency in Hz for
437 * this operating point. Value need to
438 * be unmixed with SMU_U32_MIX()
439 */
440 __u8 pad;
441 __u8 maxtemp; /* Max temp. supported by this
442 * operating point
443 */
444
445 __u16 volts[3]; /* CPU core voltage for the 3
446 * PowerTune modes, a mode with
447 * 0V = not supported. Value need
448 * to be unmixed with SMU_U16_MIX()
449 */
450};
451
452/* This partition contains voltage & current sensor calibration
453 * informations
454 */
455#define SMU_SDB_CPUVCP_ID 0x21
456
457struct smu_sdbp_cpuvcp {
458 __u16 volt_scale; /* u4.12 fixed point */
459 __s16 volt_offset; /* s4.12 fixed point */
460 __u16 curr_scale; /* u4.12 fixed point */
461 __s16 curr_offset; /* s4.12 fixed point */
462 __s32 power_quads[3]; /* s4.28 fixed point */
463};
464
465/* This partition contains CPU thermal diode calibration
466 */
467#define SMU_SDB_CPUDIODE_ID 0x18
468
469struct smu_sdbp_cpudiode {
470 __u16 m_value; /* u1.15 fixed point */
471 __s16 b_value; /* s10.6 fixed point */
472
473};
474
475/* This partition contains Slots power calibration
476 */
477#define SMU_SDB_SLOTSPOW_ID 0x78
478
479struct smu_sdbp_slotspow {
480 __u16 pow_scale; /* u4.12 fixed point */
481 __s16 pow_offset; /* s4.12 fixed point */
482};
483
484/* This partition contains machine specific version information about
485 * the sensor/control layout
486 */
487#define SMU_SDB_SENSORTREE_ID 0x25
488
489struct smu_sdbp_sensortree {
490 u8 model_id;
491 u8 unknown[3];
492};
493
494/* This partition contains CPU thermal control PID informations. So far
495 * only single CPU machines have been seen with an SMU, so we assume this
496 * carries only informations for those
497 */
498#define SMU_SDB_CPUPIDDATA_ID 0x17
499
500struct smu_sdbp_cpupiddata {
501 u8 unknown1;
502 u8 target_temp_delta;
503 u8 unknown2;
504 u8 history_len;
505 s16 power_adj;
506 u16 max_power;
507 s32 gp,gr,gd;
508};
509
510
511/* Other partitions without known structures */
512#define SMU_SDB_DEBUG_SWITCHES_ID 0x05
513
514#ifdef __KERNEL__
515/*
516 * This returns the pointer to an SMU "sdb" partition data or NULL
517 * if not found. The data format is described below
518 */
519extern struct smu_sdbp_header *smu_get_sdb_partition(int id,
520 unsigned int *size);
521
522#endif /* __KERNEL__ */
523
524
525/*
526 * - Userland interface -
527 */
528
529/*
530 * A given instance of the device can be configured for 2 different
531 * things at the moment:
532 *
533 * - sending SMU commands (default at open() time)
534 * - receiving SMU events (not yet implemented)
535 *
536 * Commands are written with write() of a command block. They can be
537 * "driver" commands (for example to switch to event reception mode)
538 * or real SMU commands. They are made of a header followed by command
539 * data if any.
540 *
541 * For SMU commands (not for driver commands), you can then read() back
542 * a reply. The reader will be blocked or not depending on how the device
543 * file is opened. poll() isn't implemented yet. The reply will consist
544 * of a header as well, followed by the reply data if any. You should
545 * always provide a buffer large enough for the maximum reply data, I
546 * recommand one page.
547 *
548 * It is illegal to send SMU commands through a file descriptor configured
549 * for events reception
550 *
551 */
552struct smu_user_cmd_hdr
553{
554 __u32 cmdtype;
555#define SMU_CMDTYPE_SMU 0 /* SMU command */
556#define SMU_CMDTYPE_WANTS_EVENTS 1 /* switch fd to events mode */
557#define SMU_CMDTYPE_GET_PARTITION 2 /* retreive an sdb partition */
558
559 __u8 cmd; /* SMU command byte */
560 __u8 pad[3]; /* padding */
561 __u32 data_len; /* Lenght of data following */
562};
563
564struct smu_user_reply_hdr
565{
566 __u32 status; /* Command status */
567 __u32 reply_len; /* Lenght of data follwing */
568};
569
570#endif /* _SMU_H */
diff --git a/include/asm-powerpc/sparsemem.h b/include/asm-powerpc/sparsemem.h
new file mode 100644
index 000000000000..ba1b34fdb967
--- /dev/null
+++ b/include/asm-powerpc/sparsemem.h
@@ -0,0 +1,20 @@
1#ifndef _ASM_POWERPC_SPARSEMEM_H
2#define _ASM_POWERPC_SPARSEMEM_H 1
3
4#ifdef CONFIG_SPARSEMEM
5/*
6 * SECTION_SIZE_BITS 2^N: how big each section will be
7 * MAX_PHYSADDR_BITS 2^N: how much physical address space we have
8 * MAX_PHYSMEM_BITS 2^N: how much memory we can have in that space
9 */
10#define SECTION_SIZE_BITS 24
11#define MAX_PHYSADDR_BITS 44
12#define MAX_PHYSMEM_BITS 44
13
14#ifdef CONFIG_MEMORY_HOTPLUG
15extern void create_section_mapping(unsigned long start, unsigned long end);
16#endif /* CONFIG_MEMORY_HOTPLUG */
17
18#endif /* CONFIG_SPARSEMEM */
19
20#endif /* _ASM_POWERPC_SPARSEMEM_H */
diff --git a/include/asm-powerpc/spinlock.h b/include/asm-powerpc/spinlock.h
new file mode 100644
index 000000000000..caa4b14e0e94
--- /dev/null
+++ b/include/asm-powerpc/spinlock.h
@@ -0,0 +1,269 @@
1#ifndef __ASM_SPINLOCK_H
2#define __ASM_SPINLOCK_H
3
4/*
5 * Simple spin lock operations.
6 *
7 * Copyright (C) 2001-2004 Paul Mackerras <paulus@au.ibm.com>, IBM
8 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
9 * Copyright (C) 2002 Dave Engebretsen <engebret@us.ibm.com>, IBM
10 * Rework to support virtual processors
11 *
12 * Type of int is used as a full 64b word is not necessary.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 *
19 * (the type definitions are in asm/spinlock_types.h)
20 */
21#ifdef CONFIG_PPC64
22#include <asm/paca.h>
23#include <asm/hvcall.h>
24#include <asm/iseries/hv_call.h>
25#endif
26#include <asm/asm-compat.h>
27#include <asm/synch.h>
28
29#define __raw_spin_is_locked(x) ((x)->slock != 0)
30
31#ifdef CONFIG_PPC64
32/* use 0x800000yy when locked, where yy == CPU number */
33#define LOCK_TOKEN (*(u32 *)(&get_paca()->lock_token))
34#else
35#define LOCK_TOKEN 1
36#endif
37
38/*
39 * This returns the old value in the lock, so we succeeded
40 * in getting the lock if the return value is 0.
41 */
42static __inline__ unsigned long __spin_trylock(raw_spinlock_t *lock)
43{
44 unsigned long tmp, token;
45
46 token = LOCK_TOKEN;
47 __asm__ __volatile__(
48"1: lwarx %0,0,%2 # __spin_trylock\n\
49 cmpwi 0,%0,0\n\
50 bne- 2f\n\
51 stwcx. %1,0,%2\n\
52 bne- 1b\n\
53 isync\n\
542:" : "=&r" (tmp)
55 : "r" (token), "r" (&lock->slock)
56 : "cr0", "memory");
57
58 return tmp;
59}
60
61static int __inline__ __raw_spin_trylock(raw_spinlock_t *lock)
62{
63 return __spin_trylock(lock) == 0;
64}
65
66/*
67 * On a system with shared processors (that is, where a physical
68 * processor is multiplexed between several virtual processors),
69 * there is no point spinning on a lock if the holder of the lock
70 * isn't currently scheduled on a physical processor. Instead
71 * we detect this situation and ask the hypervisor to give the
72 * rest of our timeslice to the lock holder.
73 *
74 * So that we can tell which virtual processor is holding a lock,
75 * we put 0x80000000 | smp_processor_id() in the lock when it is
76 * held. Conveniently, we have a word in the paca that holds this
77 * value.
78 */
79
80#if defined(CONFIG_PPC_SPLPAR) || defined(CONFIG_PPC_ISERIES)
81/* We only yield to the hypervisor if we are in shared processor mode */
82#define SHARED_PROCESSOR (get_paca()->lppaca.shared_proc)
83extern void __spin_yield(raw_spinlock_t *lock);
84extern void __rw_yield(raw_rwlock_t *lock);
85#else /* SPLPAR || ISERIES */
86#define __spin_yield(x) barrier()
87#define __rw_yield(x) barrier()
88#define SHARED_PROCESSOR 0
89#endif
90
91static void __inline__ __raw_spin_lock(raw_spinlock_t *lock)
92{
93 while (1) {
94 if (likely(__spin_trylock(lock) == 0))
95 break;
96 do {
97 HMT_low();
98 if (SHARED_PROCESSOR)
99 __spin_yield(lock);
100 } while (unlikely(lock->slock != 0));
101 HMT_medium();
102 }
103}
104
105static void __inline__ __raw_spin_lock_flags(raw_spinlock_t *lock, unsigned long flags)
106{
107 unsigned long flags_dis;
108
109 while (1) {
110 if (likely(__spin_trylock(lock) == 0))
111 break;
112 local_save_flags(flags_dis);
113 local_irq_restore(flags);
114 do {
115 HMT_low();
116 if (SHARED_PROCESSOR)
117 __spin_yield(lock);
118 } while (unlikely(lock->slock != 0));
119 HMT_medium();
120 local_irq_restore(flags_dis);
121 }
122}
123
124static __inline__ void __raw_spin_unlock(raw_spinlock_t *lock)
125{
126 __asm__ __volatile__(SYNC_ON_SMP" # __raw_spin_unlock"
127 : : :"memory");
128 lock->slock = 0;
129}
130
131#ifdef CONFIG_PPC64
132extern void __raw_spin_unlock_wait(raw_spinlock_t *lock);
133#else
134#define __raw_spin_unlock_wait(lock) \
135 do { while (__raw_spin_is_locked(lock)) cpu_relax(); } while (0)
136#endif
137
138/*
139 * Read-write spinlocks, allowing multiple readers
140 * but only one writer.
141 *
142 * NOTE! it is quite common to have readers in interrupts
143 * but no interrupt writers. For those circumstances we
144 * can "mix" irq-safe locks - any writer needs to get a
145 * irq-safe write-lock, but readers can get non-irqsafe
146 * read-locks.
147 */
148
149#define __raw_read_can_lock(rw) ((rw)->lock >= 0)
150#define __raw_write_can_lock(rw) (!(rw)->lock)
151
152#ifdef CONFIG_PPC64
153#define __DO_SIGN_EXTEND "extsw %0,%0\n"
154#define WRLOCK_TOKEN LOCK_TOKEN /* it's negative */
155#else
156#define __DO_SIGN_EXTEND
157#define WRLOCK_TOKEN (-1)
158#endif
159
160/*
161 * This returns the old value in the lock + 1,
162 * so we got a read lock if the return value is > 0.
163 */
164static long __inline__ __read_trylock(raw_rwlock_t *rw)
165{
166 long tmp;
167
168 __asm__ __volatile__(
169"1: lwarx %0,0,%1 # read_trylock\n"
170 __DO_SIGN_EXTEND
171" addic. %0,%0,1\n\
172 ble- 2f\n"
173 PPC405_ERR77(0,%1)
174" stwcx. %0,0,%1\n\
175 bne- 1b\n\
176 isync\n\
1772:" : "=&r" (tmp)
178 : "r" (&rw->lock)
179 : "cr0", "xer", "memory");
180
181 return tmp;
182}
183
184/*
185 * This returns the old value in the lock,
186 * so we got the write lock if the return value is 0.
187 */
188static __inline__ long __write_trylock(raw_rwlock_t *rw)
189{
190 long tmp, token;
191
192 token = WRLOCK_TOKEN;
193 __asm__ __volatile__(
194"1: lwarx %0,0,%2 # write_trylock\n\
195 cmpwi 0,%0,0\n\
196 bne- 2f\n"
197 PPC405_ERR77(0,%1)
198" stwcx. %1,0,%2\n\
199 bne- 1b\n\
200 isync\n\
2012:" : "=&r" (tmp)
202 : "r" (token), "r" (&rw->lock)
203 : "cr0", "memory");
204
205 return tmp;
206}
207
208static void __inline__ __raw_read_lock(raw_rwlock_t *rw)
209{
210 while (1) {
211 if (likely(__read_trylock(rw) > 0))
212 break;
213 do {
214 HMT_low();
215 if (SHARED_PROCESSOR)
216 __rw_yield(rw);
217 } while (unlikely(rw->lock < 0));
218 HMT_medium();
219 }
220}
221
222static void __inline__ __raw_write_lock(raw_rwlock_t *rw)
223{
224 while (1) {
225 if (likely(__write_trylock(rw) == 0))
226 break;
227 do {
228 HMT_low();
229 if (SHARED_PROCESSOR)
230 __rw_yield(rw);
231 } while (unlikely(rw->lock != 0));
232 HMT_medium();
233 }
234}
235
236static int __inline__ __raw_read_trylock(raw_rwlock_t *rw)
237{
238 return __read_trylock(rw) > 0;
239}
240
241static int __inline__ __raw_write_trylock(raw_rwlock_t *rw)
242{
243 return __write_trylock(rw) == 0;
244}
245
246static void __inline__ __raw_read_unlock(raw_rwlock_t *rw)
247{
248 long tmp;
249
250 __asm__ __volatile__(
251 "eieio # read_unlock\n\
2521: lwarx %0,0,%1\n\
253 addic %0,%0,-1\n"
254 PPC405_ERR77(0,%1)
255" stwcx. %0,0,%1\n\
256 bne- 1b"
257 : "=&r"(tmp)
258 : "r"(&rw->lock)
259 : "cr0", "memory");
260}
261
262static __inline__ void __raw_write_unlock(raw_rwlock_t *rw)
263{
264 __asm__ __volatile__(SYNC_ON_SMP" # write_unlock"
265 : : :"memory");
266 rw->lock = 0;
267}
268
269#endif /* __ASM_SPINLOCK_H */
diff --git a/include/asm-powerpc/spinlock_types.h b/include/asm-powerpc/spinlock_types.h
new file mode 100644
index 000000000000..74236c9f05b1
--- /dev/null
+++ b/include/asm-powerpc/spinlock_types.h
@@ -0,0 +1,20 @@
1#ifndef _ASM_POWERPC_SPINLOCK_TYPES_H
2#define _ASM_POWERPC_SPINLOCK_TYPES_H
3
4#ifndef __LINUX_SPINLOCK_TYPES_H
5# error "please don't include this file directly"
6#endif
7
8typedef struct {
9 volatile unsigned int slock;
10} raw_spinlock_t;
11
12#define __RAW_SPIN_LOCK_UNLOCKED { 0 }
13
14typedef struct {
15 volatile signed int lock;
16} raw_rwlock_t;
17
18#define __RAW_RW_LOCK_UNLOCKED { 0 }
19
20#endif
diff --git a/include/asm-powerpc/sstep.h b/include/asm-powerpc/sstep.h
new file mode 100644
index 000000000000..630a9889c07c
--- /dev/null
+++ b/include/asm-powerpc/sstep.h
@@ -0,0 +1,26 @@
1/*
2 * Copyright (C) 2004 Paul Mackerras <paulus@au.ibm.com>, IBM
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
10struct pt_regs;
11
12/*
13 * We don't allow single-stepping an mtmsrd that would clear
14 * MSR_RI, since that would make the exception unrecoverable.
15 * Since we need to single-step to proceed from a breakpoint,
16 * we don't allow putting a breakpoint on an mtmsrd instruction.
17 * Similarly we don't allow breakpoints on rfid instructions.
18 * These macros tell us if an instruction is a mtmsrd or rfid.
19 * Note that IS_MTMSRD returns true for both an mtmsr (32-bit)
20 * and an mtmsrd (64-bit).
21 */
22#define IS_MTMSRD(instr) (((instr) & 0xfc0007be) == 0x7c000124)
23#define IS_RFID(instr) (((instr) & 0xfc0007fe) == 0x4c000024)
24
25/* Emulate instructions that cause a transfer of control. */
26extern int emulate_step(struct pt_regs *regs, unsigned int instr);
diff --git a/include/asm-powerpc/stat.h b/include/asm-powerpc/stat.h
new file mode 100644
index 000000000000..e4edc510b530
--- /dev/null
+++ b/include/asm-powerpc/stat.h
@@ -0,0 +1,81 @@
1#ifndef _ASM_POWERPC_STAT_H
2#define _ASM_POWERPC_STAT_H
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#include <linux/types.h>
10
11#define STAT_HAVE_NSEC 1
12
13#ifndef __powerpc64__
14struct __old_kernel_stat {
15 unsigned short st_dev;
16 unsigned short st_ino;
17 unsigned short st_mode;
18 unsigned short st_nlink;
19 unsigned short st_uid;
20 unsigned short st_gid;
21 unsigned short st_rdev;
22 unsigned long st_size;
23 unsigned long st_atime;
24 unsigned long st_mtime;
25 unsigned long st_ctime;
26};
27#endif /* !__powerpc64__ */
28
29struct stat {
30 unsigned long st_dev;
31 ino_t st_ino;
32#ifdef __powerpc64__
33 nlink_t st_nlink;
34 mode_t st_mode;
35#else
36 mode_t st_mode;
37 nlink_t st_nlink;
38#endif
39 uid_t st_uid;
40 gid_t st_gid;
41 unsigned long st_rdev;
42 off_t st_size;
43 unsigned long st_blksize;
44 unsigned long st_blocks;
45 unsigned long st_atime;
46 unsigned long st_atime_nsec;
47 unsigned long st_mtime;
48 unsigned long st_mtime_nsec;
49 unsigned long st_ctime;
50 unsigned long st_ctime_nsec;
51 unsigned long __unused4;
52 unsigned long __unused5;
53#ifdef __powerpc64__
54 unsigned long __unused6;
55#endif
56};
57
58/* This matches struct stat64 in glibc2.1. Only used for 32 bit. */
59struct stat64 {
60 unsigned long long st_dev; /* Device. */
61 unsigned long long st_ino; /* File serial number. */
62 unsigned int st_mode; /* File mode. */
63 unsigned int st_nlink; /* Link count. */
64 unsigned int st_uid; /* User ID of the file's owner. */
65 unsigned int st_gid; /* Group ID of the file's group. */
66 unsigned long long st_rdev; /* Device number, if device. */
67 unsigned short __pad2;
68 long long st_size; /* Size of file, in bytes. */
69 int st_blksize; /* Optimal block size for I/O. */
70 long long st_blocks; /* Number 512-byte blocks allocated. */
71 int st_atime; /* Time of last access. */
72 unsigned int st_atime_nsec;
73 int st_mtime; /* Time of last modification. */
74 unsigned int st_mtime_nsec;
75 int st_ctime; /* Time of last status change. */
76 unsigned int st_ctime_nsec;
77 unsigned int __unused4;
78 unsigned int __unused5;
79};
80
81#endif /* _ASM_POWERPC_STAT_H */
diff --git a/include/asm-powerpc/statfs.h b/include/asm-powerpc/statfs.h
new file mode 100644
index 000000000000..67024026c10d
--- /dev/null
+++ b/include/asm-powerpc/statfs.h
@@ -0,0 +1,60 @@
1#ifndef _ASM_POWERPC_STATFS_H
2#define _ASM_POWERPC_STATFS_H
3
4/* For ppc32 we just use the generic definitions, not so simple on ppc64 */
5
6#ifndef __powerpc64__
7#include <asm-generic/statfs.h>
8#else
9
10#ifndef __KERNEL_STRICT_NAMES
11#include <linux/types.h>
12typedef __kernel_fsid_t fsid_t;
13#endif
14
15/*
16 * We're already 64-bit, so duplicate the definition
17 */
18struct statfs {
19 long f_type;
20 long f_bsize;
21 long f_blocks;
22 long f_bfree;
23 long f_bavail;
24 long f_files;
25 long f_ffree;
26 __kernel_fsid_t f_fsid;
27 long f_namelen;
28 long f_frsize;
29 long f_spare[5];
30};
31
32struct statfs64 {
33 long f_type;
34 long f_bsize;
35 long f_blocks;
36 long f_bfree;
37 long f_bavail;
38 long f_files;
39 long f_ffree;
40 __kernel_fsid_t f_fsid;
41 long f_namelen;
42 long f_frsize;
43 long f_spare[5];
44};
45
46struct compat_statfs64 {
47 __u32 f_type;
48 __u32 f_bsize;
49 __u64 f_blocks;
50 __u64 f_bfree;
51 __u64 f_bavail;
52 __u64 f_files;
53 __u64 f_ffree;
54 __kernel_fsid_t f_fsid;
55 __u32 f_namelen;
56 __u32 f_frsize;
57 __u32 f_spare[5];
58};
59#endif /* ! __powerpc64__ */
60#endif
diff --git a/include/asm-powerpc/synch.h b/include/asm-powerpc/synch.h
new file mode 100644
index 000000000000..4660c0394a77
--- /dev/null
+++ b/include/asm-powerpc/synch.h
@@ -0,0 +1,51 @@
1#ifndef _ASM_POWERPC_SYNCH_H
2#define _ASM_POWERPC_SYNCH_H
3
4#include <linux/config.h>
5
6#ifdef __powerpc64__
7#define __SUBARCH_HAS_LWSYNC
8#endif
9
10#ifdef __SUBARCH_HAS_LWSYNC
11# define LWSYNC lwsync
12#else
13# define LWSYNC sync
14#endif
15
16
17/*
18 * Arguably the bitops and *xchg operations don't imply any memory barrier
19 * or SMP ordering, but in fact a lot of drivers expect them to imply
20 * both, since they do on x86 cpus.
21 */
22#ifdef CONFIG_SMP
23#define EIEIO_ON_SMP "eieio\n"
24#define ISYNC_ON_SMP "\n\tisync"
25#define SYNC_ON_SMP __stringify(LWSYNC) "\n"
26#else
27#define EIEIO_ON_SMP
28#define ISYNC_ON_SMP
29#define SYNC_ON_SMP
30#endif
31
32static inline void eieio(void)
33{
34 __asm__ __volatile__ ("eieio" : : : "memory");
35}
36
37static inline void isync(void)
38{
39 __asm__ __volatile__ ("isync" : : : "memory");
40}
41
42#ifdef CONFIG_SMP
43#define eieio_on_smp() eieio()
44#define isync_on_smp() isync()
45#else
46#define eieio_on_smp() __asm__ __volatile__("": : :"memory")
47#define isync_on_smp() __asm__ __volatile__("": : :"memory")
48#endif
49
50#endif /* _ASM_POWERPC_SYNCH_H */
51
diff --git a/include/asm-powerpc/system.h b/include/asm-powerpc/system.h
new file mode 100644
index 000000000000..5341b75c75cb
--- /dev/null
+++ b/include/asm-powerpc/system.h
@@ -0,0 +1,411 @@
1/*
2 * Copyright (C) 1999 Cort Dougan <cort@cs.nmt.edu>
3 */
4#ifndef _ASM_POWERPC_SYSTEM_H
5#define _ASM_POWERPC_SYSTEM_H
6
7#include <linux/config.h>
8#include <linux/kernel.h>
9
10#include <asm/hw_irq.h>
11#include <asm/atomic.h>
12
13/*
14 * Memory barrier.
15 * The sync instruction guarantees that all memory accesses initiated
16 * by this processor have been performed (with respect to all other
17 * mechanisms that access memory). The eieio instruction is a barrier
18 * providing an ordering (separately) for (a) cacheable stores and (b)
19 * loads and stores to non-cacheable memory (e.g. I/O devices).
20 *
21 * mb() prevents loads and stores being reordered across this point.
22 * rmb() prevents loads being reordered across this point.
23 * wmb() prevents stores being reordered across this point.
24 * read_barrier_depends() prevents data-dependent loads being reordered
25 * across this point (nop on PPC).
26 *
27 * We have to use the sync instructions for mb(), since lwsync doesn't
28 * order loads with respect to previous stores. Lwsync is fine for
29 * rmb(), though. Note that lwsync is interpreted as sync by
30 * 32-bit and older 64-bit CPUs.
31 *
32 * For wmb(), we use sync since wmb is used in drivers to order
33 * stores to system memory with respect to writes to the device.
34 * However, smp_wmb() can be a lighter-weight eieio barrier on
35 * SMP since it is only used to order updates to system memory.
36 */
37#define mb() __asm__ __volatile__ ("sync" : : : "memory")
38#define rmb() __asm__ __volatile__ ("lwsync" : : : "memory")
39#define wmb() __asm__ __volatile__ ("sync" : : : "memory")
40#define read_barrier_depends() do { } while(0)
41
42#define set_mb(var, value) do { var = value; mb(); } while (0)
43#define set_wmb(var, value) do { var = value; wmb(); } while (0)
44
45#ifdef CONFIG_SMP
46#define smp_mb() mb()
47#define smp_rmb() rmb()
48#define smp_wmb() __asm__ __volatile__ ("eieio" : : : "memory")
49#define smp_read_barrier_depends() read_barrier_depends()
50#else
51#define smp_mb() barrier()
52#define smp_rmb() barrier()
53#define smp_wmb() barrier()
54#define smp_read_barrier_depends() do { } while(0)
55#endif /* CONFIG_SMP */
56
57#ifdef __KERNEL__
58struct task_struct;
59struct pt_regs;
60
61#ifdef CONFIG_DEBUGGER
62
63extern int (*__debugger)(struct pt_regs *regs);
64extern int (*__debugger_ipi)(struct pt_regs *regs);
65extern int (*__debugger_bpt)(struct pt_regs *regs);
66extern int (*__debugger_sstep)(struct pt_regs *regs);
67extern int (*__debugger_iabr_match)(struct pt_regs *regs);
68extern int (*__debugger_dabr_match)(struct pt_regs *regs);
69extern int (*__debugger_fault_handler)(struct pt_regs *regs);
70
71#define DEBUGGER_BOILERPLATE(__NAME) \
72static inline int __NAME(struct pt_regs *regs) \
73{ \
74 if (unlikely(__ ## __NAME)) \
75 return __ ## __NAME(regs); \
76 return 0; \
77}
78
79DEBUGGER_BOILERPLATE(debugger)
80DEBUGGER_BOILERPLATE(debugger_ipi)
81DEBUGGER_BOILERPLATE(debugger_bpt)
82DEBUGGER_BOILERPLATE(debugger_sstep)
83DEBUGGER_BOILERPLATE(debugger_iabr_match)
84DEBUGGER_BOILERPLATE(debugger_dabr_match)
85DEBUGGER_BOILERPLATE(debugger_fault_handler)
86
87#ifdef CONFIG_XMON
88extern void xmon_init(int enable);
89#endif
90
91#else
92static inline int debugger(struct pt_regs *regs) { return 0; }
93static inline int debugger_ipi(struct pt_regs *regs) { return 0; }
94static inline int debugger_bpt(struct pt_regs *regs) { return 0; }
95static inline int debugger_sstep(struct pt_regs *regs) { return 0; }
96static inline int debugger_iabr_match(struct pt_regs *regs) { return 0; }
97static inline int debugger_dabr_match(struct pt_regs *regs) { return 0; }
98static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }
99#endif
100
101extern int set_dabr(unsigned long dabr);
102extern void print_backtrace(unsigned long *);
103extern void show_regs(struct pt_regs * regs);
104extern void flush_instruction_cache(void);
105extern void hard_reset_now(void);
106extern void poweroff_now(void);
107
108#ifdef CONFIG_6xx
109extern long _get_L2CR(void);
110extern long _get_L3CR(void);
111extern void _set_L2CR(unsigned long);
112extern void _set_L3CR(unsigned long);
113#else
114#define _get_L2CR() 0L
115#define _get_L3CR() 0L
116#define _set_L2CR(val) do { } while(0)
117#define _set_L3CR(val) do { } while(0)
118#endif
119
120extern void via_cuda_init(void);
121extern void read_rtc_time(void);
122extern void pmac_find_display(void);
123extern void giveup_fpu(struct task_struct *);
124extern void disable_kernel_fp(void);
125extern void enable_kernel_fp(void);
126extern void flush_fp_to_thread(struct task_struct *);
127extern void enable_kernel_altivec(void);
128extern void giveup_altivec(struct task_struct *);
129extern void load_up_altivec(struct task_struct *);
130extern int emulate_altivec(struct pt_regs *);
131extern void giveup_spe(struct task_struct *);
132extern void load_up_spe(struct task_struct *);
133extern int fix_alignment(struct pt_regs *);
134extern void cvt_fd(float *from, double *to, struct thread_struct *thread);
135extern void cvt_df(double *from, float *to, struct thread_struct *thread);
136
137#ifdef CONFIG_ALTIVEC
138extern void flush_altivec_to_thread(struct task_struct *);
139#else
140static inline void flush_altivec_to_thread(struct task_struct *t)
141{
142}
143#endif
144
145#ifdef CONFIG_SPE
146extern void flush_spe_to_thread(struct task_struct *);
147#else
148static inline void flush_spe_to_thread(struct task_struct *t)
149{
150}
151#endif
152
153extern int call_rtas(const char *, int, int, unsigned long *, ...);
154extern void cacheable_memzero(void *p, unsigned int nb);
155extern void *cacheable_memcpy(void *, const void *, unsigned int);
156extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);
157extern void bad_page_fault(struct pt_regs *, unsigned long, int);
158extern int die(const char *, struct pt_regs *, long);
159extern void _exception(int, struct pt_regs *, int, unsigned long);
160#ifdef CONFIG_BOOKE_WDT
161extern u32 booke_wdt_enabled;
162extern u32 booke_wdt_period;
163#endif /* CONFIG_BOOKE_WDT */
164
165/* EBCDIC -> ASCII conversion for [0-9A-Z] on iSeries */
166extern unsigned char e2a(unsigned char);
167
168struct device_node;
169extern void note_scsi_host(struct device_node *, void *);
170
171extern struct task_struct *__switch_to(struct task_struct *,
172 struct task_struct *);
173#define switch_to(prev, next, last) ((last) = __switch_to((prev), (next)))
174
175struct thread_struct;
176extern struct task_struct *_switch(struct thread_struct *prev,
177 struct thread_struct *next);
178
179extern unsigned int rtas_data;
180extern int mem_init_done; /* set on boot once kmalloc can be called */
181extern unsigned long memory_limit;
182extern unsigned long klimit;
183
184extern int powersave_nap; /* set if nap mode can be used in idle loop */
185
186/*
187 * Atomic exchange
188 *
189 * Changes the memory location '*ptr' to be val and returns
190 * the previous value stored there.
191 */
192static __inline__ unsigned long
193__xchg_u32(volatile void *p, unsigned long val)
194{
195 unsigned long prev;
196
197 __asm__ __volatile__(
198 EIEIO_ON_SMP
199"1: lwarx %0,0,%2 \n"
200 PPC405_ERR77(0,%2)
201" stwcx. %3,0,%2 \n\
202 bne- 1b"
203 ISYNC_ON_SMP
204 : "=&r" (prev), "=m" (*(volatile unsigned int *)p)
205 : "r" (p), "r" (val), "m" (*(volatile unsigned int *)p)
206 : "cc", "memory");
207
208 return prev;
209}
210
211#ifdef CONFIG_PPC64
212static __inline__ unsigned long
213__xchg_u64(volatile void *p, unsigned long val)
214{
215 unsigned long prev;
216
217 __asm__ __volatile__(
218 EIEIO_ON_SMP
219"1: ldarx %0,0,%2 \n"
220 PPC405_ERR77(0,%2)
221" stdcx. %3,0,%2 \n\
222 bne- 1b"
223 ISYNC_ON_SMP
224 : "=&r" (prev), "=m" (*(volatile unsigned long *)p)
225 : "r" (p), "r" (val), "m" (*(volatile unsigned long *)p)
226 : "cc", "memory");
227
228 return prev;
229}
230#endif
231
232/*
233 * This function doesn't exist, so you'll get a linker error
234 * if something tries to do an invalid xchg().
235 */
236extern void __xchg_called_with_bad_pointer(void);
237
238static __inline__ unsigned long
239__xchg(volatile void *ptr, unsigned long x, unsigned int size)
240{
241 switch (size) {
242 case 4:
243 return __xchg_u32(ptr, x);
244#ifdef CONFIG_PPC64
245 case 8:
246 return __xchg_u64(ptr, x);
247#endif
248 }
249 __xchg_called_with_bad_pointer();
250 return x;
251}
252
253#define xchg(ptr,x) \
254 ({ \
255 __typeof__(*(ptr)) _x_ = (x); \
256 (__typeof__(*(ptr))) __xchg((ptr), (unsigned long)_x_, sizeof(*(ptr))); \
257 })
258
259#define tas(ptr) (xchg((ptr),1))
260
261/*
262 * Compare and exchange - if *p == old, set it to new,
263 * and return the old value of *p.
264 */
265#define __HAVE_ARCH_CMPXCHG 1
266
267static __inline__ unsigned long
268__cmpxchg_u32(volatile unsigned int *p, unsigned long old, unsigned long new)
269{
270 unsigned int prev;
271
272 __asm__ __volatile__ (
273 EIEIO_ON_SMP
274"1: lwarx %0,0,%2 # __cmpxchg_u32\n\
275 cmpw 0,%0,%3\n\
276 bne- 2f\n"
277 PPC405_ERR77(0,%2)
278" stwcx. %4,0,%2\n\
279 bne- 1b"
280 ISYNC_ON_SMP
281 "\n\
2822:"
283 : "=&r" (prev), "=m" (*p)
284 : "r" (p), "r" (old), "r" (new), "m" (*p)
285 : "cc", "memory");
286
287 return prev;
288}
289
290#ifdef CONFIG_PPC64
291static __inline__ unsigned long
292__cmpxchg_u64(volatile unsigned long *p, unsigned long old, unsigned long new)
293{
294 unsigned long prev;
295
296 __asm__ __volatile__ (
297 EIEIO_ON_SMP
298"1: ldarx %0,0,%2 # __cmpxchg_u64\n\
299 cmpd 0,%0,%3\n\
300 bne- 2f\n\
301 stdcx. %4,0,%2\n\
302 bne- 1b"
303 ISYNC_ON_SMP
304 "\n\
3052:"
306 : "=&r" (prev), "=m" (*p)
307 : "r" (p), "r" (old), "r" (new), "m" (*p)
308 : "cc", "memory");
309
310 return prev;
311}
312#endif
313
314/* This function doesn't exist, so you'll get a linker error
315 if something tries to do an invalid cmpxchg(). */
316extern void __cmpxchg_called_with_bad_pointer(void);
317
318static __inline__ unsigned long
319__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new,
320 unsigned int size)
321{
322 switch (size) {
323 case 4:
324 return __cmpxchg_u32(ptr, old, new);
325#ifdef CONFIG_PPC64
326 case 8:
327 return __cmpxchg_u64(ptr, old, new);
328#endif
329 }
330 __cmpxchg_called_with_bad_pointer();
331 return old;
332}
333
334#define cmpxchg(ptr,o,n) \
335 ({ \
336 __typeof__(*(ptr)) _o_ = (o); \
337 __typeof__(*(ptr)) _n_ = (n); \
338 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
339 (unsigned long)_n_, sizeof(*(ptr))); \
340 })
341
342#ifdef CONFIG_PPC64
343/*
344 * We handle most unaligned accesses in hardware. On the other hand
345 * unaligned DMA can be very expensive on some ppc64 IO chips (it does
346 * powers of 2 writes until it reaches sufficient alignment).
347 *
348 * Based on this we disable the IP header alignment in network drivers.
349 */
350#define NET_IP_ALIGN 0
351#endif
352
353#define arch_align_stack(x) (x)
354
355/* Used in very early kernel initialization. */
356extern unsigned long reloc_offset(void);
357extern unsigned long add_reloc_offset(unsigned long);
358extern void reloc_got2(unsigned long);
359
360#define PTRRELOC(x) ((typeof(x)) add_reloc_offset((unsigned long)(x)))
361
362static inline void create_instruction(unsigned long addr, unsigned int instr)
363{
364 unsigned int *p;
365 p = (unsigned int *)addr;
366 *p = instr;
367 asm ("dcbst 0, %0; sync; icbi 0,%0; sync; isync" : : "r" (p));
368}
369
370/* Flags for create_branch:
371 * "b" == create_branch(addr, target, 0);
372 * "ba" == create_branch(addr, target, BRANCH_ABSOLUTE);
373 * "bl" == create_branch(addr, target, BRANCH_SET_LINK);
374 * "bla" == create_branch(addr, target, BRANCH_ABSOLUTE | BRANCH_SET_LINK);
375 */
376#define BRANCH_SET_LINK 0x1
377#define BRANCH_ABSOLUTE 0x2
378
379static inline void create_branch(unsigned long addr,
380 unsigned long target, int flags)
381{
382 unsigned int instruction;
383
384 if (! (flags & BRANCH_ABSOLUTE))
385 target = target - addr;
386
387 /* Mask out the flags and target, so they don't step on each other. */
388 instruction = 0x48000000 | (flags & 0x3) | (target & 0x03FFFFFC);
389
390 create_instruction(addr, instruction);
391}
392
393static inline void create_function_call(unsigned long addr, void * func)
394{
395 unsigned long func_addr;
396
397#ifdef CONFIG_PPC64
398 /*
399 * On PPC64 the function pointer actually points to the function's
400 * descriptor. The first entry in the descriptor is the address
401 * of the function text.
402 */
403 func_addr = *(unsigned long *)func;
404#else
405 func_addr = (unsigned long)func;
406#endif
407 create_branch(addr, func_addr, BRANCH_SET_LINK);
408}
409
410#endif /* __KERNEL__ */
411#endif /* _ASM_POWERPC_SYSTEM_H */
diff --git a/include/asm-powerpc/tce.h b/include/asm-powerpc/tce.h
new file mode 100644
index 000000000000..980a094fd5a7
--- /dev/null
+++ b/include/asm-powerpc/tce.h
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 2001 Mike Corrigan & Dave Engebretsen, IBM Corporation
3 * Rewrite, cleanup:
4 * Copyright (C) 2004 Olof Johansson <olof@lixom.net>, 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 the
14 * 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_TCE_H
22#define _ASM_POWERPC_TCE_H
23
24/*
25 * Tces come in two formats, one for the virtual bus and a different
26 * format for PCI
27 */
28#define TCE_VB 0
29#define TCE_PCI 1
30
31/* TCE page size is 4096 bytes (1 << 12) */
32
33#define TCE_SHIFT 12
34#define TCE_PAGE_SIZE (1 << TCE_SHIFT)
35#define TCE_PAGE_FACTOR (PAGE_SHIFT - TCE_SHIFT)
36
37
38/* tce_entry
39 * Used by pSeries (SMP) and iSeries/pSeries LPAR, but there it's
40 * abstracted so layout is irrelevant.
41 */
42union tce_entry {
43 unsigned long te_word;
44 struct {
45 unsigned int tb_cacheBits :6; /* Cache hash bits - not used */
46 unsigned int tb_rsvd :6;
47 unsigned long tb_rpn :40; /* Real page number */
48 unsigned int tb_valid :1; /* Tce is valid (vb only) */
49 unsigned int tb_allio :1; /* Tce is valid for all lps (vb only) */
50 unsigned int tb_lpindex :8; /* LpIndex for user of TCE (vb only) */
51 unsigned int tb_pciwr :1; /* Write allowed (pci only) */
52 unsigned int tb_rdwr :1; /* Read allowed (pci), Write allowed (vb) */
53 } te_bits;
54#define te_cacheBits te_bits.tb_cacheBits
55#define te_rpn te_bits.tb_rpn
56#define te_valid te_bits.tb_valid
57#define te_allio te_bits.tb_allio
58#define te_lpindex te_bits.tb_lpindex
59#define te_pciwr te_bits.tb_pciwr
60#define te_rdwr te_bits.tb_rdwr
61};
62
63
64#endif /* _ASM_POWERPC_TCE_H */
diff --git a/include/asm-powerpc/termios.h b/include/asm-powerpc/termios.h
index c5b8e5358f83..7f80a019b6a0 100644
--- a/include/asm-powerpc/termios.h
+++ b/include/asm-powerpc/termios.h
@@ -94,142 +94,9 @@ struct termio {
94#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025" 94#define INIT_C_CC "\003\034\177\025\004\001\000\000\000\000\027\022\032\021\023\026\025"
95#endif 95#endif
96 96
97#define FIOCLEX _IO('f', 1)
98#define FIONCLEX _IO('f', 2)
99#define FIOASYNC _IOW('f', 125, int)
100#define FIONBIO _IOW('f', 126, int)
101#define FIONREAD _IOR('f', 127, int)
102#define TIOCINQ FIONREAD
103
104#define TIOCGETP _IOR('t', 8, struct sgttyb)
105#define TIOCSETP _IOW('t', 9, struct sgttyb)
106#define TIOCSETN _IOW('t', 10, struct sgttyb) /* TIOCSETP wo flush */
107
108#define TIOCSETC _IOW('t', 17, struct tchars)
109#define TIOCGETC _IOR('t', 18, struct tchars)
110#define TCGETS _IOR('t', 19, struct termios)
111#define TCSETS _IOW('t', 20, struct termios)
112#define TCSETSW _IOW('t', 21, struct termios)
113#define TCSETSF _IOW('t', 22, struct termios)
114
115#define TCGETA _IOR('t', 23, struct termio)
116#define TCSETA _IOW('t', 24, struct termio)
117#define TCSETAW _IOW('t', 25, struct termio)
118#define TCSETAF _IOW('t', 28, struct termio)
119
120#define TCSBRK _IO('t', 29)
121#define TCXONC _IO('t', 30)
122#define TCFLSH _IO('t', 31)
123
124#define TIOCSWINSZ _IOW('t', 103, struct winsize)
125#define TIOCGWINSZ _IOR('t', 104, struct winsize)
126#define TIOCSTART _IO('t', 110) /* start output, like ^Q */
127#define TIOCSTOP _IO('t', 111) /* stop output, like ^S */
128#define TIOCOUTQ _IOR('t', 115, int) /* output queue size */
129
130#define TIOCGLTC _IOR('t', 116, struct ltchars)
131#define TIOCSLTC _IOW('t', 117, struct ltchars)
132#define TIOCSPGRP _IOW('t', 118, int)
133#define TIOCGPGRP _IOR('t', 119, int)
134
135#define TIOCEXCL 0x540C
136#define TIOCNXCL 0x540D
137#define TIOCSCTTY 0x540E
138
139#define TIOCSTI 0x5412
140#define TIOCMGET 0x5415
141#define TIOCMBIS 0x5416
142#define TIOCMBIC 0x5417
143#define TIOCMSET 0x5418
144#define TIOCGSOFTCAR 0x5419
145#define TIOCSSOFTCAR 0x541A
146#define TIOCLINUX 0x541C
147#define TIOCCONS 0x541D
148#define TIOCGSERIAL 0x541E
149#define TIOCSSERIAL 0x541F
150#define TIOCPKT 0x5420
151
152#define TIOCNOTTY 0x5422
153#define TIOCSETD 0x5423
154#define TIOCGETD 0x5424
155#define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
156
157#define TIOCSERCONFIG 0x5453
158#define TIOCSERGWILD 0x5454
159#define TIOCSERSWILD 0x5455
160#define TIOCGLCKTRMIOS 0x5456
161#define TIOCSLCKTRMIOS 0x5457
162#define TIOCSERGSTRUCT 0x5458 /* For debugging only */
163#define TIOCSERGETLSR 0x5459 /* Get line status register */
164#define TIOCSERGETMULTI 0x545A /* Get multiport config */
165#define TIOCSERSETMULTI 0x545B /* Set multiport config */
166
167#define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */
168#define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
169
170/* Used for packet mode */
171#define TIOCPKT_DATA 0
172#define TIOCPKT_FLUSHREAD 1
173#define TIOCPKT_FLUSHWRITE 2
174#define TIOCPKT_STOP 4
175#define TIOCPKT_START 8
176#define TIOCPKT_NOSTOP 16
177#define TIOCPKT_DOSTOP 32
178
179/* modem lines */
180#define TIOCM_LE 0x001
181#define TIOCM_DTR 0x002
182#define TIOCM_RTS 0x004
183#define TIOCM_ST 0x008
184#define TIOCM_SR 0x010
185#define TIOCM_CTS 0x020
186#define TIOCM_CAR 0x040
187#define TIOCM_RNG 0x080
188#define TIOCM_DSR 0x100
189#define TIOCM_CD TIOCM_CAR
190#define TIOCM_RI TIOCM_RNG
191#define TIOCM_OUT1 0x2000
192#define TIOCM_OUT2 0x4000
193#define TIOCM_LOOP 0x8000
194
195/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
196#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
197
198#ifdef __KERNEL__ 97#ifdef __KERNEL__
199 98
200/* 99#include <asm-generic/termios.h>
201 * Translate a "termio" structure into a "termios". Ugh.
202 */
203#define SET_LOW_TERMIOS_BITS(termios, termio, x) { \
204 unsigned short __tmp; \
205 get_user(__tmp,&(termio)->x); \
206 (termios)->x = (0xffff0000 & (termios)->x) | __tmp; \
207}
208
209#define user_termio_to_kernel_termios(termios, termio) \
210({ \
211 SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \
212 SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \
213 SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \
214 SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \
215 copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \
216})
217
218/*
219 * Translate a "termios" structure into a "termio". Ugh.
220 */
221#define kernel_termios_to_user_termio(termio, termios) \
222({ \
223 put_user((termios)->c_iflag, &(termio)->c_iflag); \
224 put_user((termios)->c_oflag, &(termio)->c_oflag); \
225 put_user((termios)->c_cflag, &(termio)->c_cflag); \
226 put_user((termios)->c_lflag, &(termio)->c_lflag); \
227 put_user((termios)->c_line, &(termio)->c_line); \
228 copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \
229})
230
231#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
232#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
233 100
234#endif /* __KERNEL__ */ 101#endif /* __KERNEL__ */
235 102
diff --git a/include/asm-powerpc/thread_info.h b/include/asm-powerpc/thread_info.h
new file mode 100644
index 000000000000..e525f49bd179
--- /dev/null
+++ b/include/asm-powerpc/thread_info.h
@@ -0,0 +1,146 @@
1/* thread_info.h: PowerPC low-level thread information
2 * adapted from the i386 version by Paul Mackerras
3 *
4 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
5 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
6 */
7
8#ifndef _ASM_POWERPC_THREAD_INFO_H
9#define _ASM_POWERPC_THREAD_INFO_H
10
11#ifdef __KERNEL__
12
13/* We have 8k stacks on ppc32 and 16k on ppc64 */
14
15#ifdef CONFIG_PPC64
16#define THREAD_SHIFT 14
17#else
18#define THREAD_SHIFT 13
19#endif
20
21#define THREAD_SIZE (1 << THREAD_SHIFT)
22
23#ifndef __ASSEMBLY__
24#include <linux/config.h>
25#include <linux/cache.h>
26#include <asm/processor.h>
27#include <asm/page.h>
28#include <linux/stringify.h>
29
30/*
31 * low level task data.
32 */
33struct thread_info {
34 struct task_struct *task; /* main task structure */
35 struct exec_domain *exec_domain; /* execution domain */
36 int cpu; /* cpu we're on */
37 int preempt_count; /* 0 => preemptable,
38 <0 => BUG */
39 struct restart_block restart_block;
40 /* set by force_successful_syscall_return */
41 unsigned char syscall_noerror;
42 /* low level flags - has atomic operations done on it */
43 unsigned long flags ____cacheline_aligned_in_smp;
44};
45
46/*
47 * macros/functions for gaining access to the thread information structure
48 *
49 * preempt_count needs to be 1 initially, until the scheduler is functional.
50 */
51#define INIT_THREAD_INFO(tsk) \
52{ \
53 .task = &tsk, \
54 .exec_domain = &default_exec_domain, \
55 .cpu = 0, \
56 .preempt_count = 1, \
57 .restart_block = { \
58 .fn = do_no_restart_syscall, \
59 }, \
60 .flags = 0, \
61}
62
63#define init_thread_info (init_thread_union.thread_info)
64#define init_stack (init_thread_union.stack)
65
66/* thread information allocation */
67
68#if THREAD_SHIFT >= PAGE_SHIFT
69
70#define THREAD_ORDER (THREAD_SHIFT - PAGE_SHIFT)
71
72#ifdef CONFIG_DEBUG_STACK_USAGE
73#define alloc_thread_info(tsk) \
74 ((struct thread_info *)__get_free_pages(GFP_KERNEL | \
75 __GFP_ZERO, THREAD_ORDER))
76#else
77#define alloc_thread_info(tsk) \
78 ((struct thread_info *)__get_free_pages(GFP_KERNEL, THREAD_ORDER))
79#endif
80#define free_thread_info(ti) free_pages((unsigned long)ti, THREAD_ORDER)
81
82#else /* THREAD_SHIFT < PAGE_SHIFT */
83
84#ifdef CONFIG_DEBUG_STACK_USAGE
85#define alloc_thread_info(tsk) kzalloc(THREAD_SIZE, GFP_KERNEL)
86#else
87#define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL)
88#endif
89#define free_thread_info(ti) kfree(ti)
90
91#endif /* THREAD_SHIFT < PAGE_SHIFT */
92
93#define get_thread_info(ti) get_task_struct((ti)->task)
94#define put_thread_info(ti) put_task_struct((ti)->task)
95
96/* how to get the thread information struct from C */
97static inline struct thread_info *current_thread_info(void)
98{
99 register unsigned long sp asm("r1");
100
101 /* gcc4, at least, is smart enough to turn this into a single
102 * rlwinm for ppc32 and clrrdi for ppc64 */
103 return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
104}
105
106#endif /* __ASSEMBLY__ */
107
108#define PREEMPT_ACTIVE 0x10000000
109
110/*
111 * thread information flag bit numbers
112 */
113#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
114#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
115#define TIF_SIGPENDING 2 /* signal pending */
116#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
117#define TIF_POLLING_NRFLAG 4 /* true if poll_idle() is polling
118 TIF_NEED_RESCHED */
119#define TIF_32BIT 5 /* 32 bit binary */
120/* #define SPARE 6 */
121#define TIF_ABI_PENDING 7 /* 32/64 bit switch needed */
122#define TIF_SYSCALL_AUDIT 8 /* syscall auditing active */
123#define TIF_SINGLESTEP 9 /* singlestepping active */
124#define TIF_MEMDIE 10
125#define TIF_SECCOMP 11 /* secure computing */
126
127/* as above, but as bit values */
128#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
129#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
130#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
131#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
132#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
133#define _TIF_32BIT (1<<TIF_32BIT)
134/* #define _SPARE (1<<SPARE) */
135#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
136#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
137#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
138#define _TIF_SECCOMP (1<<TIF_SECCOMP)
139#define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT|_TIF_SECCOMP)
140
141#define _TIF_USER_WORK_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING | \
142 _TIF_NEED_RESCHED)
143
144#endif /* __KERNEL__ */
145
146#endif /* _ASM_POWERPC_THREAD_INFO_H */
diff --git a/include/asm-powerpc/time.h b/include/asm-powerpc/time.h
new file mode 100644
index 000000000000..d9b86a17271b
--- /dev/null
+++ b/include/asm-powerpc/time.h
@@ -0,0 +1,226 @@
1/*
2 * Common time prototypes and such for all ppc machines.
3 *
4 * Written by Cort Dougan (cort@cs.nmt.edu) to merge
5 * Paul Mackerras' version and mine for PReP and Pmac.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#ifndef __POWERPC_TIME_H
14#define __POWERPC_TIME_H
15
16#ifdef __KERNEL__
17#include <linux/config.h>
18#include <linux/types.h>
19#include <linux/percpu.h>
20
21#include <asm/processor.h>
22#ifdef CONFIG_PPC64
23#include <asm/paca.h>
24#include <asm/iseries/hv_call.h>
25#endif
26
27/* time.c */
28extern unsigned long tb_ticks_per_jiffy;
29extern unsigned long tb_ticks_per_usec;
30extern unsigned long tb_ticks_per_sec;
31extern u64 tb_to_xs;
32extern unsigned tb_to_us;
33extern unsigned long tb_last_stamp;
34extern u64 tb_last_jiffy;
35
36DECLARE_PER_CPU(unsigned long, last_jiffy);
37
38struct rtc_time;
39extern void to_tm(int tim, struct rtc_time * tm);
40extern time_t last_rtc_update;
41
42extern void generic_calibrate_decr(void);
43extern void wakeup_decrementer(void);
44
45/* Some sane defaults: 125 MHz timebase, 1GHz processor */
46extern unsigned long ppc_proc_freq;
47#define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8)
48extern unsigned long ppc_tb_freq;
49#define DEFAULT_TB_FREQ 125000000UL
50
51/*
52 * By putting all of this stuff into a single struct we
53 * reduce the number of cache lines touched by do_gettimeofday.
54 * Both by collecting all of the data in one cache line and
55 * by touching only one TOC entry on ppc64.
56 */
57struct gettimeofday_vars {
58 u64 tb_to_xs;
59 u64 stamp_xsec;
60 u64 tb_orig_stamp;
61};
62
63struct gettimeofday_struct {
64 unsigned long tb_ticks_per_sec;
65 struct gettimeofday_vars vars[2];
66 struct gettimeofday_vars * volatile varp;
67 unsigned var_idx;
68 unsigned tb_to_us;
69};
70
71struct div_result {
72 u64 result_high;
73 u64 result_low;
74};
75
76/* Accessor functions for the timebase (RTC on 601) registers. */
77/* If one day CONFIG_POWER is added just define __USE_RTC as 1 */
78#ifdef CONFIG_6xx
79#define __USE_RTC() (!cpu_has_feature(CPU_FTR_USE_TB))
80#else
81#define __USE_RTC() 0
82#endif
83
84/* On ppc64 this gets us the whole timebase; on ppc32 just the lower half */
85static inline unsigned long get_tbl(void)
86{
87 unsigned long tbl;
88
89#if defined(CONFIG_403GCX)
90 asm volatile("mfspr %0, 0x3dd" : "=r" (tbl));
91#else
92 asm volatile("mftb %0" : "=r" (tbl));
93#endif
94 return tbl;
95}
96
97static inline unsigned int get_tbu(void)
98{
99 unsigned int tbu;
100
101#if defined(CONFIG_403GCX)
102 asm volatile("mfspr %0, 0x3dc" : "=r" (tbu));
103#else
104 asm volatile("mftbu %0" : "=r" (tbu));
105#endif
106 return tbu;
107}
108
109static inline unsigned int get_rtcl(void)
110{
111 unsigned int rtcl;
112
113 asm volatile("mfrtcl %0" : "=r" (rtcl));
114 return rtcl;
115}
116
117static inline u64 get_rtc(void)
118{
119 unsigned int hi, lo, hi2;
120
121 do {
122 asm volatile("mfrtcu %0; mfrtcl %1; mfrtcu %2"
123 : "=r" (hi), "=r" (lo), "=r" (hi2));
124 } while (hi2 != hi);
125 return (u64)hi * 1000000000 + lo;
126}
127
128#ifdef CONFIG_PPC64
129static inline u64 get_tb(void)
130{
131 return mftb();
132}
133#else
134static inline u64 get_tb(void)
135{
136 unsigned int tbhi, tblo, tbhi2;
137
138 do {
139 tbhi = get_tbu();
140 tblo = get_tbl();
141 tbhi2 = get_tbu();
142 } while (tbhi != tbhi2);
143
144 return ((u64)tbhi << 32) | tblo;
145}
146#endif
147
148static inline void set_tb(unsigned int upper, unsigned int lower)
149{
150 mtspr(SPRN_TBWL, 0);
151 mtspr(SPRN_TBWU, upper);
152 mtspr(SPRN_TBWL, lower);
153}
154
155/* Accessor functions for the decrementer register.
156 * The 4xx doesn't even have a decrementer. I tried to use the
157 * generic timer interrupt code, which seems OK, with the 4xx PIT
158 * in auto-reload mode. The problem is PIT stops counting when it
159 * hits zero. If it would wrap, we could use it just like a decrementer.
160 */
161static inline unsigned int get_dec(void)
162{
163#if defined(CONFIG_40x)
164 return (mfspr(SPRN_PIT));
165#else
166 return (mfspr(SPRN_DEC));
167#endif
168}
169
170static inline void set_dec(int val)
171{
172#if defined(CONFIG_40x)
173 return; /* Have to let it auto-reload */
174#elif defined(CONFIG_8xx_CPU6)
175 set_dec_cpu6(val);
176#else
177#ifdef CONFIG_PPC_ISERIES
178 struct paca_struct *lpaca = get_paca();
179 int cur_dec;
180
181 if (lpaca->lppaca.shared_proc) {
182 lpaca->lppaca.virtual_decr = val;
183 cur_dec = get_dec();
184 if (cur_dec > val)
185 HvCall_setVirtualDecr();
186 } else
187#endif
188 mtspr(SPRN_DEC, val);
189#endif /* not 40x or 8xx_CPU6 */
190}
191
192static inline unsigned long tb_ticks_since(unsigned long tstamp)
193{
194 if (__USE_RTC()) {
195 int delta = get_rtcl() - (unsigned int) tstamp;
196 return delta < 0 ? delta + 1000000000 : delta;
197 }
198 return get_tbl() - tstamp;
199}
200
201#define mulhwu(x,y) \
202({unsigned z; asm ("mulhwu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
203
204#ifdef CONFIG_PPC64
205#define mulhdu(x,y) \
206({unsigned long z; asm ("mulhdu %0,%1,%2" : "=r" (z) : "r" (x), "r" (y)); z;})
207#else
208extern u64 mulhdu(u64, u64);
209#endif
210
211extern void smp_space_timers(unsigned int);
212
213extern unsigned mulhwu_scale_factor(unsigned, unsigned);
214extern void div128_by_32(u64 dividend_high, u64 dividend_low,
215 unsigned divisor, struct div_result *dr);
216
217/* Used to store Processor Utilization register (purr) values */
218
219struct cpu_usage {
220 u64 current_tb; /* Holds the current purr register values */
221};
222
223DECLARE_PER_CPU(struct cpu_usage, cpu_usage_array);
224
225#endif /* __KERNEL__ */
226#endif /* __PPC64_TIME_H */
diff --git a/include/asm-powerpc/timex.h b/include/asm-powerpc/timex.h
index 51c5b316be55..c02d15aced91 100644
--- a/include/asm-powerpc/timex.h
+++ b/include/asm-powerpc/timex.h
@@ -10,7 +10,7 @@
10#include <linux/config.h> 10#include <linux/config.h>
11#include <asm/cputable.h> 11#include <asm/cputable.h>
12 12
13#define CLOCK_TICK_RATE 1193180 /* Underlying HZ */ 13#define CLOCK_TICK_RATE 1024000 /* Underlying HZ */
14 14
15typedef unsigned long cycles_t; 15typedef unsigned long cycles_t;
16 16
diff --git a/include/asm-powerpc/tlb.h b/include/asm-powerpc/tlb.h
new file mode 100644
index 000000000000..56659f121779
--- /dev/null
+++ b/include/asm-powerpc/tlb.h
@@ -0,0 +1,70 @@
1/*
2 * TLB shootdown specifics for powerpc
3 *
4 * Copyright (C) 2002 Anton Blanchard, IBM Corp.
5 * Copyright (C) 2002 Paul Mackerras, IBM Corp.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12#ifndef _ASM_POWERPC_TLB_H
13#define _ASM_POWERPC_TLB_H
14
15#include <linux/config.h>
16#ifndef __powerpc64__
17#include <asm/pgtable.h>
18#endif
19#include <asm/pgalloc.h>
20#include <asm/tlbflush.h>
21#ifndef __powerpc64__
22#include <asm/page.h>
23#include <asm/mmu.h>
24#endif
25
26struct mmu_gather;
27
28#define tlb_start_vma(tlb, vma) do { } while (0)
29#define tlb_end_vma(tlb, vma) do { } while (0)
30
31#if !defined(CONFIG_PPC_STD_MMU)
32
33#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
34
35#elif defined(__powerpc64__)
36
37extern void pte_free_finish(void);
38
39static inline void tlb_flush(struct mmu_gather *tlb)
40{
41 flush_tlb_pending();
42 pte_free_finish();
43}
44
45#else
46
47extern void tlb_flush(struct mmu_gather *tlb);
48
49#endif
50
51/* Get the generic bits... */
52#include <asm-generic/tlb.h>
53
54#if !defined(CONFIG_PPC_STD_MMU) || defined(__powerpc64__)
55
56#define __tlb_remove_tlb_entry(tlb, pte, address) do { } while (0)
57
58#else
59extern void flush_hash_entry(struct mm_struct *mm, pte_t *ptep,
60 unsigned long address);
61
62static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep,
63 unsigned long address)
64{
65 if (pte_val(*ptep) & _PAGE_HASHPTE)
66 flush_hash_entry(tlb->mm, ptep, address);
67}
68
69#endif
70#endif /* __ASM_POWERPC_TLB_H */
diff --git a/include/asm-powerpc/tlbflush.h b/include/asm-powerpc/tlbflush.h
new file mode 100644
index 000000000000..a2998eee37bb
--- /dev/null
+++ b/include/asm-powerpc/tlbflush.h
@@ -0,0 +1,147 @@
1#ifndef _ASM_POWERPC_TLBFLUSH_H
2#define _ASM_POWERPC_TLBFLUSH_H
3/*
4 * TLB flushing:
5 *
6 * - flush_tlb_mm(mm) flushes the specified mm context TLB's
7 * - flush_tlb_page(vma, vmaddr) flushes one page
8 * - flush_tlb_page_nohash(vma, vmaddr) flushes one page if SW loaded TLB
9 * - flush_tlb_range(vma, start, end) flushes a range of pages
10 * - flush_tlb_kernel_range(start, end) flushes a range of kernel pages
11 * - flush_tlb_pgtables(mm, start, end) flushes a range of page tables
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18#ifdef __KERNEL__
19
20#include <linux/config.h>
21
22struct mm_struct;
23
24#ifdef CONFIG_PPC64
25
26#include <linux/percpu.h>
27#include <asm/page.h>
28
29#define PPC64_TLB_BATCH_NR 192
30
31struct ppc64_tlb_batch {
32 unsigned long index;
33 struct mm_struct *mm;
34 real_pte_t pte[PPC64_TLB_BATCH_NR];
35 unsigned long vaddr[PPC64_TLB_BATCH_NR];
36 unsigned int psize;
37};
38DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch);
39
40extern void __flush_tlb_pending(struct ppc64_tlb_batch *batch);
41
42static inline void flush_tlb_pending(void)
43{
44 struct ppc64_tlb_batch *batch = &get_cpu_var(ppc64_tlb_batch);
45
46 if (batch->index)
47 __flush_tlb_pending(batch);
48 put_cpu_var(ppc64_tlb_batch);
49}
50
51extern void flush_hash_page(unsigned long va, real_pte_t pte, int psize,
52 int local);
53extern void flush_hash_range(unsigned long number, int local);
54
55#else /* CONFIG_PPC64 */
56
57#include <linux/mm.h>
58
59extern void _tlbie(unsigned long address);
60extern void _tlbia(void);
61
62/*
63 * TODO: (CONFIG_FSL_BOOKE) determine if flush_tlb_range &
64 * flush_tlb_kernel_range are best implemented as tlbia vs
65 * specific tlbie's
66 */
67
68#if (defined(CONFIG_4xx) && !defined(CONFIG_44x)) || defined(CONFIG_8xx)
69#define flush_tlb_pending() asm volatile ("tlbia; sync" : : : "memory")
70#elif defined(CONFIG_4xx) || defined(CONFIG_FSL_BOOKE)
71#define flush_tlb_pending() _tlbia()
72#endif
73
74/*
75 * This gets called at the end of handling a page fault, when
76 * the kernel has put a new PTE into the page table for the process.
77 * We use it to ensure coherency between the i-cache and d-cache
78 * for the page which has just been mapped in.
79 * On machines which use an MMU hash table, we use this to put a
80 * corresponding HPTE into the hash table ahead of time, instead of
81 * waiting for the inevitable extra hash-table miss exception.
82 */
83extern void update_mmu_cache(struct vm_area_struct *, unsigned long, pte_t);
84
85#endif /* CONFIG_PPC64 */
86
87#if defined(CONFIG_PPC64) || defined(CONFIG_4xx) || \
88 defined(CONFIG_FSL_BOOKE) || defined(CONFIG_8xx)
89
90static inline void flush_tlb_mm(struct mm_struct *mm)
91{
92 flush_tlb_pending();
93}
94
95static inline void flush_tlb_page(struct vm_area_struct *vma,
96 unsigned long vmaddr)
97{
98#ifdef CONFIG_PPC64
99 flush_tlb_pending();
100#else
101 _tlbie(vmaddr);
102#endif
103}
104
105static inline void flush_tlb_page_nohash(struct vm_area_struct *vma,
106 unsigned long vmaddr)
107{
108#ifndef CONFIG_PPC64
109 _tlbie(vmaddr);
110#endif
111}
112
113static inline void flush_tlb_range(struct vm_area_struct *vma,
114 unsigned long start, unsigned long end)
115{
116 flush_tlb_pending();
117}
118
119static inline void flush_tlb_kernel_range(unsigned long start,
120 unsigned long end)
121{
122 flush_tlb_pending();
123}
124
125#else /* 6xx, 7xx, 7xxx cpus */
126
127extern void flush_tlb_mm(struct mm_struct *mm);
128extern void flush_tlb_page(struct vm_area_struct *vma, unsigned long vmaddr);
129extern void flush_tlb_page_nohash(struct vm_area_struct *vma, unsigned long addr);
130extern void flush_tlb_range(struct vm_area_struct *vma, unsigned long start,
131 unsigned long end);
132extern void flush_tlb_kernel_range(unsigned long start, unsigned long end);
133
134#endif
135
136/*
137 * This is called in munmap when we have freed up some page-table
138 * pages. We don't need to do anything here, there's nothing special
139 * about our page-table pages. -- paulus
140 */
141static inline void flush_tlb_pgtables(struct mm_struct *mm,
142 unsigned long start, unsigned long end)
143{
144}
145
146#endif /*__KERNEL__ */
147#endif /* _ASM_POWERPC_TLBFLUSH_H */
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index 2512e3836bf4..db8095cbe09b 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -9,15 +9,7 @@
9 9
10static inline int cpu_to_node(int cpu) 10static inline int cpu_to_node(int cpu)
11{ 11{
12 int node; 12 return numa_cpu_lookup_table[cpu];
13
14 node = numa_cpu_lookup_table[cpu];
15
16#ifdef DEBUG_NUMA
17 BUG_ON(node == -1);
18#endif
19
20 return node;
21} 13}
22 14
23#define parent_node(node) (node) 15#define parent_node(node) (node)
@@ -37,8 +29,6 @@ static inline int node_to_first_cpu(int node)
37#define pcibus_to_node(node) (-1) 29#define pcibus_to_node(node) (-1)
38#define pcibus_to_cpumask(bus) (cpu_online_map) 30#define pcibus_to_cpumask(bus) (cpu_online_map)
39 31
40#define nr_cpus_node(node) (nr_cpus_in_node[node])
41
42/* sched_domains SD_NODE_INIT for PPC64 machines */ 32/* sched_domains SD_NODE_INIT for PPC64 machines */
43#define SD_NODE_INIT (struct sched_domain) { \ 33#define SD_NODE_INIT (struct sched_domain) { \
44 .span = CPU_MASK_NONE, \ 34 .span = CPU_MASK_NONE, \
@@ -51,6 +41,10 @@ static inline int node_to_first_cpu(int node)
51 .cache_hot_time = (10*1000000), \ 41 .cache_hot_time = (10*1000000), \
52 .cache_nice_tries = 1, \ 42 .cache_nice_tries = 1, \
53 .per_cpu_gain = 100, \ 43 .per_cpu_gain = 100, \
44 .busy_idx = 3, \
45 .idle_idx = 1, \
46 .newidle_idx = 2, \
47 .wake_idx = 1, \
54 .flags = SD_LOAD_BALANCE \ 48 .flags = SD_LOAD_BALANCE \
55 | SD_BALANCE_EXEC \ 49 | SD_BALANCE_EXEC \
56 | SD_BALANCE_NEWIDLE \ 50 | SD_BALANCE_NEWIDLE \
diff --git a/include/asm-powerpc/types.h b/include/asm-powerpc/types.h
new file mode 100644
index 000000000000..ec3c2ee8bf86
--- /dev/null
+++ b/include/asm-powerpc/types.h
@@ -0,0 +1,110 @@
1#ifndef _ASM_POWERPC_TYPES_H
2#define _ASM_POWERPC_TYPES_H
3
4#ifndef __ASSEMBLY__
5
6/*
7 * This file is never included by application software unless
8 * explicitly requested (e.g., via linux/types.h) in which case the
9 * application is Linux specific so (user-) name space pollution is
10 * not a major issue. However, for interoperability, libraries still
11 * need to be careful to avoid a name clashes.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version
16 * 2 of the License, or (at your option) any later version.
17 */
18
19#ifdef __powerpc64__
20typedef unsigned int umode_t;
21#else
22typedef unsigned short umode_t;
23#endif
24
25/*
26 * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
27 * header files exported to user space
28 */
29
30typedef __signed__ char __s8;
31typedef unsigned char __u8;
32
33typedef __signed__ short __s16;
34typedef unsigned short __u16;
35
36typedef __signed__ int __s32;
37typedef unsigned int __u32;
38
39#ifdef __powerpc64__
40typedef __signed__ long __s64;
41typedef unsigned long __u64;
42#else
43#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
44typedef __signed__ long long __s64;
45typedef unsigned long long __u64;
46#endif
47#endif /* __powerpc64__ */
48
49typedef struct {
50 __u32 u[4];
51} __attribute((aligned(16))) __vector128;
52
53#endif /* __ASSEMBLY__ */
54
55#ifdef __KERNEL__
56/*
57 * These aren't exported outside the kernel to avoid name space clashes
58 */
59#ifdef __powerpc64__
60#define BITS_PER_LONG 64
61#else
62#define BITS_PER_LONG 32
63#endif
64
65#ifndef __ASSEMBLY__
66
67#include <linux/config.h>
68
69typedef signed char s8;
70typedef unsigned char u8;
71
72typedef signed short s16;
73typedef unsigned short u16;
74
75typedef signed int s32;
76typedef unsigned int u32;
77
78#ifdef __powerpc64__
79typedef signed long s64;
80typedef unsigned long u64;
81#else
82typedef signed long long s64;
83typedef unsigned long long u64;
84#endif
85
86typedef __vector128 vector128;
87
88#ifdef __powerpc64__
89typedef u64 dma_addr_t;
90#else
91typedef u32 dma_addr_t;
92#endif
93typedef u64 dma64_addr_t;
94
95typedef struct {
96 unsigned long entry;
97 unsigned long toc;
98 unsigned long env;
99} func_descr_t;
100
101#ifdef CONFIG_LBD
102typedef u64 sector_t;
103#define HAVE_SECTOR_T
104#endif
105
106#endif /* __ASSEMBLY__ */
107
108#endif /* __KERNEL__ */
109
110#endif /* _ASM_POWERPC_TYPES_H */
diff --git a/include/asm-powerpc/uaccess.h b/include/asm-powerpc/uaccess.h
new file mode 100644
index 000000000000..3872e924cdd6
--- /dev/null
+++ b/include/asm-powerpc/uaccess.h
@@ -0,0 +1,464 @@
1#ifndef _ARCH_POWERPC_UACCESS_H
2#define _ARCH_POWERPC_UACCESS_H
3
4#ifdef __KERNEL__
5#ifndef __ASSEMBLY__
6
7#include <linux/sched.h>
8#include <linux/errno.h>
9#include <asm/processor.h>
10
11#define VERIFY_READ 0
12#define VERIFY_WRITE 1
13
14/*
15 * The fs value determines whether argument validity checking should be
16 * performed or not. If get_fs() == USER_DS, checking is performed, with
17 * get_fs() == KERNEL_DS, checking is bypassed.
18 *
19 * For historical reasons, these macros are grossly misnamed.
20 *
21 * The fs/ds values are now the highest legal address in the "segment".
22 * This simplifies the checking in the routines below.
23 */
24
25#define MAKE_MM_SEG(s) ((mm_segment_t) { (s) })
26
27#define KERNEL_DS MAKE_MM_SEG(~0UL)
28#ifdef __powerpc64__
29/* We use TASK_SIZE_USER64 as TASK_SIZE is not constant */
30#define USER_DS MAKE_MM_SEG(TASK_SIZE_USER64 - 1)
31#else
32#define USER_DS MAKE_MM_SEG(TASK_SIZE - 1)
33#endif
34
35#define get_ds() (KERNEL_DS)
36#define get_fs() (current->thread.fs)
37#define set_fs(val) (current->thread.fs = (val))
38
39#define segment_eq(a, b) ((a).seg == (b).seg)
40
41#ifdef __powerpc64__
42/*
43 * This check is sufficient because there is a large enough
44 * gap between user addresses and the kernel addresses
45 */
46#define __access_ok(addr, size, segment) \
47 (((addr) <= (segment).seg) && ((size) <= (segment).seg))
48
49#else
50
51#define __access_ok(addr, size, segment) \
52 (((addr) <= (segment).seg) && \
53 (((size) == 0) || (((size) - 1) <= ((segment).seg - (addr)))))
54
55#endif
56
57#define access_ok(type, addr, size) \
58 (__chk_user_ptr(addr), \
59 __access_ok((__force unsigned long)(addr), (size), get_fs()))
60
61/*
62 * The exception table consists of pairs of addresses: the first is the
63 * address of an instruction that is allowed to fault, and the second is
64 * the address at which the program should continue. No registers are
65 * modified, so it is entirely up to the continuation code to figure out
66 * what to do.
67 *
68 * All the routines below use bits of fixup code that are out of line
69 * with the main instruction path. This means when everything is well,
70 * we don't even have to jump over them. Further, they do not intrude
71 * on our cache or tlb entries.
72 */
73
74struct exception_table_entry {
75 unsigned long insn;
76 unsigned long fixup;
77};
78
79/*
80 * These are the main single-value transfer routines. They automatically
81 * use the right size if we just have the right pointer type.
82 *
83 * This gets kind of ugly. We want to return _two_ values in "get_user()"
84 * and yet we don't want to do any pointers, because that is too much
85 * of a performance impact. Thus we have a few rather ugly macros here,
86 * and hide all the ugliness from the user.
87 *
88 * The "__xxx" versions of the user access functions are versions that
89 * do not verify the address space, that must have been done previously
90 * with a separate "access_ok()" call (this is used when we do multiple
91 * accesses to the same area of user memory).
92 *
93 * As we use the same address space for kernel and user data on the
94 * PowerPC, we can just do these as direct assignments. (Of course, the
95 * exception handling means that it's no longer "just"...)
96 *
97 * The "user64" versions of the user access functions are versions that
98 * allow access of 64-bit data. The "get_user" functions do not
99 * properly handle 64-bit data because the value gets down cast to a long.
100 * The "put_user" functions already handle 64-bit data properly but we add
101 * "user64" versions for completeness
102 */
103#define get_user(x, ptr) \
104 __get_user_check((x), (ptr), sizeof(*(ptr)))
105#define put_user(x, ptr) \
106 __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
107
108#define __get_user(x, ptr) \
109 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
110#define __put_user(x, ptr) \
111 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
112#ifndef __powerpc64__
113#define __get_user64(x, ptr) \
114 __get_user64_nocheck((x), (ptr), sizeof(*(ptr)))
115#define __put_user64(x, ptr) __put_user(x, ptr)
116#endif
117
118#define __get_user_unaligned __get_user
119#define __put_user_unaligned __put_user
120
121extern long __put_user_bad(void);
122
123/*
124 * We don't tell gcc that we are accessing memory, but this is OK
125 * because we do not write to any memory gcc knows about, so there
126 * are no aliasing issues.
127 */
128#define __put_user_asm(x, addr, err, op) \
129 __asm__ __volatile__( \
130 "1: " op " %1,0(%2) # put_user\n" \
131 "2:\n" \
132 ".section .fixup,\"ax\"\n" \
133 "3: li %0,%3\n" \
134 " b 2b\n" \
135 ".previous\n" \
136 ".section __ex_table,\"a\"\n" \
137 " .balign %5\n" \
138 PPC_LONG "1b,3b\n" \
139 ".previous" \
140 : "=r" (err) \
141 : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err),\
142 "i"(sizeof(unsigned long)))
143
144#ifdef __powerpc64__
145#define __put_user_asm2(x, ptr, retval) \
146 __put_user_asm(x, ptr, retval, "std")
147#else /* __powerpc64__ */
148#define __put_user_asm2(x, addr, err) \
149 __asm__ __volatile__( \
150 "1: stw %1,0(%2)\n" \
151 "2: stw %1+1,4(%2)\n" \
152 "3:\n" \
153 ".section .fixup,\"ax\"\n" \
154 "4: li %0,%3\n" \
155 " b 3b\n" \
156 ".previous\n" \
157 ".section __ex_table,\"a\"\n" \
158 " .balign %5\n" \
159 PPC_LONG "1b,4b\n" \
160 PPC_LONG "2b,4b\n" \
161 ".previous" \
162 : "=r" (err) \
163 : "r" (x), "b" (addr), "i" (-EFAULT), "0" (err),\
164 "i"(sizeof(unsigned long)))
165#endif /* __powerpc64__ */
166
167#define __put_user_size(x, ptr, size, retval) \
168do { \
169 retval = 0; \
170 switch (size) { \
171 case 1: __put_user_asm(x, ptr, retval, "stb"); break; \
172 case 2: __put_user_asm(x, ptr, retval, "sth"); break; \
173 case 4: __put_user_asm(x, ptr, retval, "stw"); break; \
174 case 8: __put_user_asm2(x, ptr, retval); break; \
175 default: __put_user_bad(); \
176 } \
177} while (0)
178
179#define __put_user_nocheck(x, ptr, size) \
180({ \
181 long __pu_err; \
182 might_sleep(); \
183 __chk_user_ptr(ptr); \
184 __put_user_size((x), (ptr), (size), __pu_err); \
185 __pu_err; \
186})
187
188#define __put_user_check(x, ptr, size) \
189({ \
190 long __pu_err = -EFAULT; \
191 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
192 might_sleep(); \
193 if (access_ok(VERIFY_WRITE, __pu_addr, size)) \
194 __put_user_size((x), __pu_addr, (size), __pu_err); \
195 __pu_err; \
196})
197
198extern long __get_user_bad(void);
199
200#define __get_user_asm(x, addr, err, op) \
201 __asm__ __volatile__( \
202 "1: "op" %1,0(%2) # get_user\n" \
203 "2:\n" \
204 ".section .fixup,\"ax\"\n" \
205 "3: li %0,%3\n" \
206 " li %1,0\n" \
207 " b 2b\n" \
208 ".previous\n" \
209 ".section __ex_table,\"a\"\n" \
210 " .balign %5\n" \
211 PPC_LONG "1b,3b\n" \
212 ".previous" \
213 : "=r" (err), "=r" (x) \
214 : "b" (addr), "i" (-EFAULT), "0" (err), \
215 "i"(sizeof(unsigned long)))
216
217#ifdef __powerpc64__
218#define __get_user_asm2(x, addr, err) \
219 __get_user_asm(x, addr, err, "ld")
220#else /* __powerpc64__ */
221#define __get_user_asm2(x, addr, err) \
222 __asm__ __volatile__( \
223 "1: lwz %1,0(%2)\n" \
224 "2: lwz %1+1,4(%2)\n" \
225 "3:\n" \
226 ".section .fixup,\"ax\"\n" \
227 "4: li %0,%3\n" \
228 " li %1,0\n" \
229 " li %1+1,0\n" \
230 " b 3b\n" \
231 ".previous\n" \
232 ".section __ex_table,\"a\"\n" \
233 " .balign %5\n" \
234 PPC_LONG "1b,4b\n" \
235 PPC_LONG "2b,4b\n" \
236 ".previous" \
237 : "=r" (err), "=&r" (x) \
238 : "b" (addr), "i" (-EFAULT), "0" (err), \
239 "i"(sizeof(unsigned long)))
240#endif /* __powerpc64__ */
241
242#define __get_user_size(x, ptr, size, retval) \
243do { \
244 retval = 0; \
245 __chk_user_ptr(ptr); \
246 if (size > sizeof(x)) \
247 (x) = __get_user_bad(); \
248 switch (size) { \
249 case 1: __get_user_asm(x, ptr, retval, "lbz"); break; \
250 case 2: __get_user_asm(x, ptr, retval, "lhz"); break; \
251 case 4: __get_user_asm(x, ptr, retval, "lwz"); break; \
252 case 8: __get_user_asm2(x, ptr, retval); break; \
253 default: (x) = __get_user_bad(); \
254 } \
255} while (0)
256
257#define __get_user_nocheck(x, ptr, size) \
258({ \
259 long __gu_err; \
260 unsigned long __gu_val; \
261 __chk_user_ptr(ptr); \
262 might_sleep(); \
263 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
264 (x) = (__typeof__(*(ptr)))__gu_val; \
265 __gu_err; \
266})
267
268#ifndef __powerpc64__
269#define __get_user64_nocheck(x, ptr, size) \
270({ \
271 long __gu_err; \
272 long long __gu_val; \
273 __chk_user_ptr(ptr); \
274 might_sleep(); \
275 __get_user_size(__gu_val, (ptr), (size), __gu_err); \
276 (x) = (__typeof__(*(ptr)))__gu_val; \
277 __gu_err; \
278})
279#endif /* __powerpc64__ */
280
281#define __get_user_check(x, ptr, size) \
282({ \
283 long __gu_err = -EFAULT; \
284 unsigned long __gu_val = 0; \
285 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
286 might_sleep(); \
287 if (access_ok(VERIFY_READ, __gu_addr, (size))) \
288 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
289 (x) = (__typeof__(*(ptr)))__gu_val; \
290 __gu_err; \
291})
292
293/* more complex routines */
294
295extern unsigned long __copy_tofrom_user(void __user *to,
296 const void __user *from, unsigned long size);
297
298#ifndef __powerpc64__
299
300extern inline unsigned long copy_from_user(void *to,
301 const void __user *from, unsigned long n)
302{
303 unsigned long over;
304
305 if (access_ok(VERIFY_READ, from, n))
306 return __copy_tofrom_user((__force void __user *)to, from, n);
307 if ((unsigned long)from < TASK_SIZE) {
308 over = (unsigned long)from + n - TASK_SIZE;
309 return __copy_tofrom_user((__force void __user *)to, from,
310 n - over) + over;
311 }
312 return n;
313}
314
315extern inline unsigned long copy_to_user(void __user *to,
316 const void *from, unsigned long n)
317{
318 unsigned long over;
319
320 if (access_ok(VERIFY_WRITE, to, n))
321 return __copy_tofrom_user(to, (__force void __user *)from, n);
322 if ((unsigned long)to < TASK_SIZE) {
323 over = (unsigned long)to + n - TASK_SIZE;
324 return __copy_tofrom_user(to, (__force void __user *)from,
325 n - over) + over;
326 }
327 return n;
328}
329
330#else /* __powerpc64__ */
331
332#define __copy_in_user(to, from, size) \
333 __copy_tofrom_user((to), (from), (size))
334
335extern unsigned long copy_from_user(void *to, const void __user *from,
336 unsigned long n);
337extern unsigned long copy_to_user(void __user *to, const void *from,
338 unsigned long n);
339extern unsigned long copy_in_user(void __user *to, const void __user *from,
340 unsigned long n);
341
342#endif /* __powerpc64__ */
343
344static inline unsigned long __copy_from_user_inatomic(void *to,
345 const void __user *from, unsigned long n)
346{
347 if (__builtin_constant_p(n) && (n <= 8)) {
348 unsigned long ret;
349
350 switch (n) {
351 case 1:
352 __get_user_size(*(u8 *)to, from, 1, ret);
353 break;
354 case 2:
355 __get_user_size(*(u16 *)to, from, 2, ret);
356 break;
357 case 4:
358 __get_user_size(*(u32 *)to, from, 4, ret);
359 break;
360 case 8:
361 __get_user_size(*(u64 *)to, from, 8, ret);
362 break;
363 }
364 if (ret == 0)
365 return 0;
366 }
367 return __copy_tofrom_user((__force void __user *)to, from, n);
368}
369
370static inline unsigned long __copy_to_user_inatomic(void __user *to,
371 const void *from, unsigned long n)
372{
373 if (__builtin_constant_p(n) && (n <= 8)) {
374 unsigned long ret;
375
376 switch (n) {
377 case 1:
378 __put_user_size(*(u8 *)from, (u8 __user *)to, 1, ret);
379 break;
380 case 2:
381 __put_user_size(*(u16 *)from, (u16 __user *)to, 2, ret);
382 break;
383 case 4:
384 __put_user_size(*(u32 *)from, (u32 __user *)to, 4, ret);
385 break;
386 case 8:
387 __put_user_size(*(u64 *)from, (u64 __user *)to, 8, ret);
388 break;
389 }
390 if (ret == 0)
391 return 0;
392 }
393 return __copy_tofrom_user(to, (__force const void __user *)from, n);
394}
395
396static inline unsigned long __copy_from_user(void *to,
397 const void __user *from, unsigned long size)
398{
399 might_sleep();
400 return __copy_from_user_inatomic(to, from, size);
401}
402
403static inline unsigned long __copy_to_user(void __user *to,
404 const void *from, unsigned long size)
405{
406 might_sleep();
407 return __copy_to_user_inatomic(to, from, size);
408}
409
410extern unsigned long __clear_user(void __user *addr, unsigned long size);
411
412static inline unsigned long clear_user(void __user *addr, unsigned long size)
413{
414 might_sleep();
415 if (likely(access_ok(VERIFY_WRITE, addr, size)))
416 return __clear_user(addr, size);
417 if ((unsigned long)addr < TASK_SIZE) {
418 unsigned long over = (unsigned long)addr + size - TASK_SIZE;
419 return __clear_user(addr, size - over) + over;
420 }
421 return size;
422}
423
424extern int __strncpy_from_user(char *dst, const char __user *src, long count);
425
426static inline long strncpy_from_user(char *dst, const char __user *src,
427 long count)
428{
429 might_sleep();
430 if (likely(access_ok(VERIFY_READ, src, 1)))
431 return __strncpy_from_user(dst, src, count);
432 return -EFAULT;
433}
434
435/*
436 * Return the size of a string (including the ending 0)
437 *
438 * Return 0 for error
439 */
440extern int __strnlen_user(const char __user *str, long len, unsigned long top);
441
442/*
443 * Returns the length of the string at str (including the null byte),
444 * or 0 if we hit a page we can't access,
445 * or something > len if we didn't find a null byte.
446 *
447 * The `top' parameter to __strnlen_user is to make sure that
448 * we can never overflow from the user area into kernel space.
449 */
450static inline int strnlen_user(const char __user *str, long len)
451{
452 unsigned long top = current->thread.fs.seg;
453
454 if ((unsigned long)str > top)
455 return 0;
456 return __strnlen_user(str, len, top);
457}
458
459#define strlen_user(str) strnlen_user((str), 0x7ffffffe)
460
461#endif /* __ASSEMBLY__ */
462#endif /* __KERNEL__ */
463
464#endif /* _ARCH_POWERPC_UACCESS_H */
diff --git a/include/asm-powerpc/ucontext.h b/include/asm-powerpc/ucontext.h
new file mode 100644
index 000000000000..d9a4ddf0cc86
--- /dev/null
+++ b/include/asm-powerpc/ucontext.h
@@ -0,0 +1,40 @@
1#ifndef _ASM_POWERPC_UCONTEXT_H
2#define _ASM_POWERPC_UCONTEXT_H
3
4#ifdef __powerpc64__
5#include <asm/sigcontext.h>
6#else
7#include <asm/elf.h>
8#endif
9#include <asm/signal.h>
10
11#ifndef __powerpc64__
12struct mcontext {
13 elf_gregset_t mc_gregs;
14 elf_fpregset_t mc_fregs;
15 unsigned long mc_pad[2];
16 elf_vrregset_t mc_vregs __attribute__((__aligned__(16)));
17};
18#endif
19
20struct ucontext {
21 unsigned long uc_flags;
22 struct ucontext __user *uc_link;
23 stack_t uc_stack;
24#ifndef __powerpc64__
25 int uc_pad[7];
26 struct mcontext __user *uc_regs;/* points to uc_mcontext field */
27#endif
28 sigset_t uc_sigmask;
29 /* glibc has 1024-bit signal masks, ours are 64-bit */
30#ifdef __powerpc64__
31 sigset_t __unused[15]; /* Allow for uc_sigmask growth */
32 struct sigcontext uc_mcontext; /* last for extensibility */
33#else
34 int uc_maskext[30];
35 int uc_pad2[3];
36 struct mcontext uc_mcontext;
37#endif
38};
39
40#endif /* _ASM_POWERPC_UCONTEXT_H */
diff --git a/include/asm-powerpc/udbg.h b/include/asm-powerpc/udbg.h
new file mode 100644
index 000000000000..a383383bc4d4
--- /dev/null
+++ b/include/asm-powerpc/udbg.h
@@ -0,0 +1,31 @@
1/*
2 * c 2001 PPC 64 Team, 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
10#ifndef _ASM_POWERPC_UDBG_H
11#define _ASM_POWERPC_UDBG_H
12
13#include <linux/compiler.h>
14#include <linux/init.h>
15
16extern void (*udbg_putc)(unsigned char c);
17extern unsigned char (*udbg_getc)(void);
18extern int (*udbg_getc_poll)(void);
19
20extern void udbg_puts(const char *s);
21extern int udbg_write(const char *s, int n);
22extern int udbg_read(char *buf, int buflen);
23
24extern void register_early_udbg_console(void);
25extern void udbg_printf(const char *fmt, ...);
26
27extern void udbg_init_uart(void __iomem *comport, unsigned int speed);
28
29struct device_node;
30extern void udbg_init_scc(struct device_node *np);
31#endif /* _ASM_POWERPC_UDBG_H */
diff --git a/include/asm-powerpc/uninorth.h b/include/asm-powerpc/uninorth.h
new file mode 100644
index 000000000000..f737732c3861
--- /dev/null
+++ b/include/asm-powerpc/uninorth.h
@@ -0,0 +1,229 @@
1/*
2 * uninorth.h: definitions for using the "UniNorth" host bridge chip
3 * from Apple. This chip is used on "Core99" machines
4 * This also includes U2 used on more recent MacRISC2/3
5 * machines and U3 (G5)
6 *
7 */
8#ifdef __KERNEL__
9#ifndef __ASM_UNINORTH_H__
10#define __ASM_UNINORTH_H__
11
12/*
13 * Uni-N and U3 config space reg. definitions
14 *
15 * (Little endian)
16 */
17
18/* Address ranges selection. This one should work with Bandit too */
19/* Not U3 */
20#define UNI_N_ADDR_SELECT 0x48
21#define UNI_N_ADDR_COARSE_MASK 0xffff0000 /* 256Mb regions at *0000000 */
22#define UNI_N_ADDR_FINE_MASK 0x0000ffff /* 16Mb regions at f*000000 */
23
24/* AGP registers */
25/* Not U3 */
26#define UNI_N_CFG_GART_BASE 0x8c
27#define UNI_N_CFG_AGP_BASE 0x90
28#define UNI_N_CFG_GART_CTRL 0x94
29#define UNI_N_CFG_INTERNAL_STATUS 0x98
30#define UNI_N_CFG_GART_DUMMY_PAGE 0xa4
31
32/* UNI_N_CFG_GART_CTRL bits definitions */
33#define UNI_N_CFG_GART_INVAL 0x00000001
34#define UNI_N_CFG_GART_ENABLE 0x00000100
35#define UNI_N_CFG_GART_2xRESET 0x00010000
36#define UNI_N_CFG_GART_DISSBADET 0x00020000
37/* The following seems to only be used only on U3 <j.glisse@gmail.com> */
38#define U3_N_CFG_GART_SYNCMODE 0x00040000
39#define U3_N_CFG_GART_PERFRD 0x00080000
40#define U3_N_CFG_GART_B2BGNT 0x00200000
41#define U3_N_CFG_GART_FASTDDR 0x00400000
42
43/* My understanding of UniNorth AGP as of UniNorth rev 1.0x,
44 * revision 1.5 (x4 AGP) may need further changes.
45 *
46 * AGP_BASE register contains the base address of the AGP aperture on
47 * the AGP bus. It doesn't seem to be visible to the CPU as of UniNorth 1.x,
48 * even if decoding of this address range is enabled in the address select
49 * register. Apparently, the only supported bases are 256Mb multiples
50 * (high 4 bits of that register).
51 *
52 * GART_BASE register appear to contain the physical address of the GART
53 * in system memory in the high address bits (page aligned), and the
54 * GART size in the low order bits (number of GART pages)
55 *
56 * The GART format itself is one 32bits word per physical memory page.
57 * This word contains, in little-endian format (!!!), the physical address
58 * of the page in the high bits, and what appears to be an "enable" bit
59 * in the LSB bit (0) that must be set to 1 when the entry is valid.
60 *
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
63 * cachable). AGP memory itself doens't seem to be cache coherent neither.
64 *
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,
67 * in order, to the GART_CTRL register:
68 *
69 * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL
70 * UNI_N_CFG_GART_ENABLE
71 * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_2xRESET
72 * UNI_N_CFG_GART_ENABLE
73 *
74 * As far as AGP "features" are concerned, it looks like fast write may
75 * not be supported but this has to be confirmed.
76 *
77 * Turning on AGP seem to require a double invalidate operation, one before
78 * setting the AGP command register, on after.
79 *
80 * Turning off AGP seems to require the following sequence: first wait
81 * for the AGP to be idle by reading the internal status register, then
82 * write in that order to the GART_CTRL register:
83 *
84 * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL
85 * 0
86 * UNI_N_CFG_GART_2xRESET
87 * 0
88 */
89
90/*
91 * Uni-N memory mapped reg. definitions
92 *
93 * Those registers are Big-Endian !!
94 *
95 * Their meaning come from either Darwin and/or from experiments I made with
96 * the bootrom, I'm not sure about their exact meaning yet
97 *
98 */
99
100/* Version of the UniNorth chip */
101#define UNI_N_VERSION 0x0000 /* Known versions: 3,7 and 8 */
102
103#define UNI_N_VERSION_107 0x0003 /* 1.0.7 */
104#define UNI_N_VERSION_10A 0x0007 /* 1.0.10 */
105#define UNI_N_VERSION_150 0x0011 /* 1.5 */
106#define UNI_N_VERSION_200 0x0024 /* 2.0 */
107#define UNI_N_VERSION_PANGEA 0x00C0 /* Integrated U1 + K */
108#define UNI_N_VERSION_INTREPID 0x00D2 /* Integrated U2 + K */
109#define UNI_N_VERSION_300 0x0030 /* 3.0 (U3 on G5) */
110
111/* This register is used to enable/disable various clocks */
112#define UNI_N_CLOCK_CNTL 0x0020
113#define UNI_N_CLOCK_CNTL_PCI 0x00000001 /* PCI2 clock control */
114#define UNI_N_CLOCK_CNTL_GMAC 0x00000002 /* GMAC clock control */
115#define UNI_N_CLOCK_CNTL_FW 0x00000004 /* FireWire clock control */
116#define UNI_N_CLOCK_CNTL_ATA100 0x00000010 /* ATA-100 clock control (U2) */
117
118/* Power Management control */
119#define UNI_N_POWER_MGT 0x0030
120#define UNI_N_POWER_MGT_NORMAL 0x00
121#define UNI_N_POWER_MGT_IDLE2 0x01
122#define UNI_N_POWER_MGT_SLEEP 0x02
123
124/* This register is configured by Darwin depending on the UniN
125 * revision
126 */
127#define UNI_N_ARB_CTRL 0x0040
128#define UNI_N_ARB_CTRL_QACK_DELAY_SHIFT 15
129#define UNI_N_ARB_CTRL_QACK_DELAY_MASK 0x0e1f8000
130#define UNI_N_ARB_CTRL_QACK_DELAY 0x30
131#define UNI_N_ARB_CTRL_QACK_DELAY105 0x00
132
133/* This one _might_ return the CPU number of the CPU reading it;
134 * the bootROM decides whether to boot or to sleep/spinloop depending
135 * on this register beeing 0 or not
136 */
137#define UNI_N_CPU_NUMBER 0x0050
138
139/* This register appear to be read by the bootROM to decide what
140 * to do on a non-recoverable reset (powerup or wakeup)
141 */
142#define UNI_N_HWINIT_STATE 0x0070
143#define UNI_N_HWINIT_STATE_SLEEPING 0x01
144#define UNI_N_HWINIT_STATE_RUNNING 0x02
145/* This last bit appear to be used by the bootROM to know the second
146 * CPU has started and will enter it's sleep loop with IP=0
147 */
148#define UNI_N_HWINIT_STATE_CPU1_FLAG 0x10000000
149
150/* This register controls AACK delay, which is set when 2004 iBook/PowerBook
151 * is in low speed mode.
152 */
153#define UNI_N_AACK_DELAY 0x0100
154#define UNI_N_AACK_DELAY_ENABLE 0x00000001
155
156/* Clock status for Intrepid */
157#define UNI_N_CLOCK_STOP_STATUS0 0x0150
158#define UNI_N_CLOCK_STOPPED_EXTAGP 0x00200000
159#define UNI_N_CLOCK_STOPPED_AGPDEL 0x00100000
160#define UNI_N_CLOCK_STOPPED_I2S0_45_49 0x00080000
161#define UNI_N_CLOCK_STOPPED_I2S0_18 0x00040000
162#define UNI_N_CLOCK_STOPPED_I2S1_45_49 0x00020000
163#define UNI_N_CLOCK_STOPPED_I2S1_18 0x00010000
164#define UNI_N_CLOCK_STOPPED_TIMER 0x00008000
165#define UNI_N_CLOCK_STOPPED_SCC_RTCLK18 0x00004000
166#define UNI_N_CLOCK_STOPPED_SCC_RTCLK32 0x00002000
167#define UNI_N_CLOCK_STOPPED_SCC_VIA32 0x00001000
168#define UNI_N_CLOCK_STOPPED_SCC_SLOT0 0x00000800
169#define UNI_N_CLOCK_STOPPED_SCC_SLOT1 0x00000400
170#define UNI_N_CLOCK_STOPPED_SCC_SLOT2 0x00000200
171#define UNI_N_CLOCK_STOPPED_PCI_FBCLKO 0x00000100
172#define UNI_N_CLOCK_STOPPED_VEO0 0x00000080
173#define UNI_N_CLOCK_STOPPED_VEO1 0x00000040
174#define UNI_N_CLOCK_STOPPED_USB0 0x00000020
175#define UNI_N_CLOCK_STOPPED_USB1 0x00000010
176#define UNI_N_CLOCK_STOPPED_USB2 0x00000008
177#define UNI_N_CLOCK_STOPPED_32 0x00000004
178#define UNI_N_CLOCK_STOPPED_45 0x00000002
179#define UNI_N_CLOCK_STOPPED_49 0x00000001
180
181#define UNI_N_CLOCK_STOP_STATUS1 0x0160
182#define UNI_N_CLOCK_STOPPED_PLL4REF 0x00080000
183#define UNI_N_CLOCK_STOPPED_CPUDEL 0x00040000
184#define UNI_N_CLOCK_STOPPED_CPU 0x00020000
185#define UNI_N_CLOCK_STOPPED_BUF_REFCKO 0x00010000
186#define UNI_N_CLOCK_STOPPED_PCI2 0x00008000
187#define UNI_N_CLOCK_STOPPED_FW 0x00004000
188#define UNI_N_CLOCK_STOPPED_GB 0x00002000
189#define UNI_N_CLOCK_STOPPED_ATA66 0x00001000
190#define UNI_N_CLOCK_STOPPED_ATA100 0x00000800
191#define UNI_N_CLOCK_STOPPED_MAX 0x00000400
192#define UNI_N_CLOCK_STOPPED_PCI1 0x00000200
193#define UNI_N_CLOCK_STOPPED_KLPCI 0x00000100
194#define UNI_N_CLOCK_STOPPED_USB0PCI 0x00000080
195#define UNI_N_CLOCK_STOPPED_USB1PCI 0x00000040
196#define UNI_N_CLOCK_STOPPED_USB2PCI 0x00000020
197#define UNI_N_CLOCK_STOPPED_7PCI1 0x00000008
198#define UNI_N_CLOCK_STOPPED_AGP 0x00000004
199#define UNI_N_CLOCK_STOPPED_PCI0 0x00000002
200#define UNI_N_CLOCK_STOPPED_18 0x00000001
201
202/* Intrepid registe to OF do-platform-clockspreading */
203#define UNI_N_CLOCK_SPREADING 0x190
204
205/* Uninorth 1.5 rev. has additional perf. monitor registers at 0xf00-0xf50 */
206
207
208/*
209 * U3 specific registers
210 */
211
212
213/* U3 Toggle */
214#define U3_TOGGLE_REG 0x00e0
215#define U3_PMC_START_STOP 0x0001
216#define U3_MPIC_RESET 0x0002
217#define U3_MPIC_OUTPUT_ENABLE 0x0004
218
219/* U3 API PHY Config 1 */
220#define U3_API_PHY_CONFIG_1 0x23030
221
222/* U3 HyperTransport registers */
223#define U3_HT_CONFIG_BASE 0x70000
224#define U3_HT_LINK_COMMAND 0x100
225#define U3_HT_LINK_CONFIG 0x110
226#define U3_HT_LINK_FREQ 0x120
227
228#endif /* __ASM_UNINORTH_H__ */
229#endif /* __KERNEL__ */
diff --git a/include/asm-powerpc/unistd.h b/include/asm-powerpc/unistd.h
new file mode 100644
index 000000000000..0991dfceef1d
--- /dev/null
+++ b/include/asm-powerpc/unistd.h
@@ -0,0 +1,509 @@
1#ifndef _ASM_PPC_UNISTD_H_
2#define _ASM_PPC_UNISTD_H_
3
4/*
5 * This file contains the system call numbers.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#define __NR_restart_syscall 0
14#define __NR_exit 1
15#define __NR_fork 2
16#define __NR_read 3
17#define __NR_write 4
18#define __NR_open 5
19#define __NR_close 6
20#define __NR_waitpid 7
21#define __NR_creat 8
22#define __NR_link 9
23#define __NR_unlink 10
24#define __NR_execve 11
25#define __NR_chdir 12
26#define __NR_time 13
27#define __NR_mknod 14
28#define __NR_chmod 15
29#define __NR_lchown 16
30#define __NR_break 17
31#define __NR_oldstat 18
32#define __NR_lseek 19
33#define __NR_getpid 20
34#define __NR_mount 21
35#define __NR_umount 22
36#define __NR_setuid 23
37#define __NR_getuid 24
38#define __NR_stime 25
39#define __NR_ptrace 26
40#define __NR_alarm 27
41#define __NR_oldfstat 28
42#define __NR_pause 29
43#define __NR_utime 30
44#define __NR_stty 31
45#define __NR_gtty 32
46#define __NR_access 33
47#define __NR_nice 34
48#define __NR_ftime 35
49#define __NR_sync 36
50#define __NR_kill 37
51#define __NR_rename 38
52#define __NR_mkdir 39
53#define __NR_rmdir 40
54#define __NR_dup 41
55#define __NR_pipe 42
56#define __NR_times 43
57#define __NR_prof 44
58#define __NR_brk 45
59#define __NR_setgid 46
60#define __NR_getgid 47
61#define __NR_signal 48
62#define __NR_geteuid 49
63#define __NR_getegid 50
64#define __NR_acct 51
65#define __NR_umount2 52
66#define __NR_lock 53
67#define __NR_ioctl 54
68#define __NR_fcntl 55
69#define __NR_mpx 56
70#define __NR_setpgid 57
71#define __NR_ulimit 58
72#define __NR_oldolduname 59
73#define __NR_umask 60
74#define __NR_chroot 61
75#define __NR_ustat 62
76#define __NR_dup2 63
77#define __NR_getppid 64
78#define __NR_getpgrp 65
79#define __NR_setsid 66
80#define __NR_sigaction 67
81#define __NR_sgetmask 68
82#define __NR_ssetmask 69
83#define __NR_setreuid 70
84#define __NR_setregid 71
85#define __NR_sigsuspend 72
86#define __NR_sigpending 73
87#define __NR_sethostname 74
88#define __NR_setrlimit 75
89#define __NR_getrlimit 76
90#define __NR_getrusage 77
91#define __NR_gettimeofday 78
92#define __NR_settimeofday 79
93#define __NR_getgroups 80
94#define __NR_setgroups 81
95#define __NR_select 82
96#define __NR_symlink 83
97#define __NR_oldlstat 84
98#define __NR_readlink 85
99#define __NR_uselib 86
100#define __NR_swapon 87
101#define __NR_reboot 88
102#define __NR_readdir 89
103#define __NR_mmap 90
104#define __NR_munmap 91
105#define __NR_truncate 92
106#define __NR_ftruncate 93
107#define __NR_fchmod 94
108#define __NR_fchown 95
109#define __NR_getpriority 96
110#define __NR_setpriority 97
111#define __NR_profil 98
112#define __NR_statfs 99
113#define __NR_fstatfs 100
114#define __NR_ioperm 101
115#define __NR_socketcall 102
116#define __NR_syslog 103
117#define __NR_setitimer 104
118#define __NR_getitimer 105
119#define __NR_stat 106
120#define __NR_lstat 107
121#define __NR_fstat 108
122#define __NR_olduname 109
123#define __NR_iopl 110
124#define __NR_vhangup 111
125#define __NR_idle 112
126#define __NR_vm86 113
127#define __NR_wait4 114
128#define __NR_swapoff 115
129#define __NR_sysinfo 116
130#define __NR_ipc 117
131#define __NR_fsync 118
132#define __NR_sigreturn 119
133#define __NR_clone 120
134#define __NR_setdomainname 121
135#define __NR_uname 122
136#define __NR_modify_ldt 123
137#define __NR_adjtimex 124
138#define __NR_mprotect 125
139#define __NR_sigprocmask 126
140#define __NR_create_module 127
141#define __NR_init_module 128
142#define __NR_delete_module 129
143#define __NR_get_kernel_syms 130
144#define __NR_quotactl 131
145#define __NR_getpgid 132
146#define __NR_fchdir 133
147#define __NR_bdflush 134
148#define __NR_sysfs 135
149#define __NR_personality 136
150#define __NR_afs_syscall 137 /* Syscall for Andrew File System */
151#define __NR_setfsuid 138
152#define __NR_setfsgid 139
153#define __NR__llseek 140
154#define __NR_getdents 141
155#define __NR__newselect 142
156#define __NR_flock 143
157#define __NR_msync 144
158#define __NR_readv 145
159#define __NR_writev 146
160#define __NR_getsid 147
161#define __NR_fdatasync 148
162#define __NR__sysctl 149
163#define __NR_mlock 150
164#define __NR_munlock 151
165#define __NR_mlockall 152
166#define __NR_munlockall 153
167#define __NR_sched_setparam 154
168#define __NR_sched_getparam 155
169#define __NR_sched_setscheduler 156
170#define __NR_sched_getscheduler 157
171#define __NR_sched_yield 158
172#define __NR_sched_get_priority_max 159
173#define __NR_sched_get_priority_min 160
174#define __NR_sched_rr_get_interval 161
175#define __NR_nanosleep 162
176#define __NR_mremap 163
177#define __NR_setresuid 164
178#define __NR_getresuid 165
179#define __NR_query_module 166
180#define __NR_poll 167
181#define __NR_nfsservctl 168
182#define __NR_setresgid 169
183#define __NR_getresgid 170
184#define __NR_prctl 171
185#define __NR_rt_sigreturn 172
186#define __NR_rt_sigaction 173
187#define __NR_rt_sigprocmask 174
188#define __NR_rt_sigpending 175
189#define __NR_rt_sigtimedwait 176
190#define __NR_rt_sigqueueinfo 177
191#define __NR_rt_sigsuspend 178
192#define __NR_pread64 179
193#define __NR_pwrite64 180
194#define __NR_chown 181
195#define __NR_getcwd 182
196#define __NR_capget 183
197#define __NR_capset 184
198#define __NR_sigaltstack 185
199#define __NR_sendfile 186
200#define __NR_getpmsg 187 /* some people actually want streams */
201#define __NR_putpmsg 188 /* some people actually want streams */
202#define __NR_vfork 189
203#define __NR_ugetrlimit 190 /* SuS compliant getrlimit */
204#define __NR_readahead 191
205#ifndef __powerpc64__ /* these are 32-bit only */
206#define __NR_mmap2 192
207#define __NR_truncate64 193
208#define __NR_ftruncate64 194
209#define __NR_stat64 195
210#define __NR_lstat64 196
211#define __NR_fstat64 197
212#endif
213#define __NR_pciconfig_read 198
214#define __NR_pciconfig_write 199
215#define __NR_pciconfig_iobase 200
216#define __NR_multiplexer 201
217#define __NR_getdents64 202
218#define __NR_pivot_root 203
219#ifndef __powerpc64__
220#define __NR_fcntl64 204
221#endif
222#define __NR_madvise 205
223#define __NR_mincore 206
224#define __NR_gettid 207
225#define __NR_tkill 208
226#define __NR_setxattr 209
227#define __NR_lsetxattr 210
228#define __NR_fsetxattr 211
229#define __NR_getxattr 212
230#define __NR_lgetxattr 213
231#define __NR_fgetxattr 214
232#define __NR_listxattr 215
233#define __NR_llistxattr 216
234#define __NR_flistxattr 217
235#define __NR_removexattr 218
236#define __NR_lremovexattr 219
237#define __NR_fremovexattr 220
238#define __NR_futex 221
239#define __NR_sched_setaffinity 222
240#define __NR_sched_getaffinity 223
241/* 224 currently unused */
242#define __NR_tuxcall 225
243#ifndef __powerpc64__
244#define __NR_sendfile64 226
245#endif
246#define __NR_io_setup 227
247#define __NR_io_destroy 228
248#define __NR_io_getevents 229
249#define __NR_io_submit 230
250#define __NR_io_cancel 231
251#define __NR_set_tid_address 232
252#define __NR_fadvise64 233
253#define __NR_exit_group 234
254#define __NR_lookup_dcookie 235
255#define __NR_epoll_create 236
256#define __NR_epoll_ctl 237
257#define __NR_epoll_wait 238
258#define __NR_remap_file_pages 239
259#define __NR_timer_create 240
260#define __NR_timer_settime 241
261#define __NR_timer_gettime 242
262#define __NR_timer_getoverrun 243
263#define __NR_timer_delete 244
264#define __NR_clock_settime 245
265#define __NR_clock_gettime 246
266#define __NR_clock_getres 247
267#define __NR_clock_nanosleep 248
268#define __NR_swapcontext 249
269#define __NR_tgkill 250
270#define __NR_utimes 251
271#define __NR_statfs64 252
272#define __NR_fstatfs64 253
273#ifndef __powerpc64__
274#define __NR_fadvise64_64 254
275#endif
276#define __NR_rtas 255
277#define __NR_sys_debug_setcontext 256
278/* Number 257 is reserved for vserver */
279/* 258 currently unused */
280#define __NR_mbind 259
281#define __NR_get_mempolicy 260
282#define __NR_set_mempolicy 261
283#define __NR_mq_open 262
284#define __NR_mq_unlink 263
285#define __NR_mq_timedsend 264
286#define __NR_mq_timedreceive 265
287#define __NR_mq_notify 266
288#define __NR_mq_getsetattr 267
289#define __NR_kexec_load 268
290#define __NR_add_key 269
291#define __NR_request_key 270
292#define __NR_keyctl 271
293#define __NR_waitid 272
294#define __NR_ioprio_set 273
295#define __NR_ioprio_get 274
296#define __NR_inotify_init 275
297#define __NR_inotify_add_watch 276
298#define __NR_inotify_rm_watch 277
299
300#define __NR_syscalls 278
301
302#ifdef __KERNEL__
303#define __NR__exit __NR_exit
304#define NR_syscalls __NR_syscalls
305#endif
306
307#ifndef __ASSEMBLY__
308
309/* On powerpc a system call basically clobbers the same registers like a
310 * function call, with the exception of LR (which is needed for the
311 * "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
312 * an error return status).
313 */
314
315#define __syscall_nr(nr, type, name, args...) \
316 unsigned long __sc_ret, __sc_err; \
317 { \
318 register unsigned long __sc_0 __asm__ ("r0"); \
319 register unsigned long __sc_3 __asm__ ("r3"); \
320 register unsigned long __sc_4 __asm__ ("r4"); \
321 register unsigned long __sc_5 __asm__ ("r5"); \
322 register unsigned long __sc_6 __asm__ ("r6"); \
323 register unsigned long __sc_7 __asm__ ("r7"); \
324 register unsigned long __sc_8 __asm__ ("r8"); \
325 \
326 __sc_loadargs_##nr(name, args); \
327 __asm__ __volatile__ \
328 ("sc \n\t" \
329 "mfcr %0 " \
330 : "=&r" (__sc_0), \
331 "=&r" (__sc_3), "=&r" (__sc_4), \
332 "=&r" (__sc_5), "=&r" (__sc_6), \
333 "=&r" (__sc_7), "=&r" (__sc_8) \
334 : __sc_asm_input_##nr \
335 : "cr0", "ctr", "memory", \
336 "r9", "r10","r11", "r12"); \
337 __sc_ret = __sc_3; \
338 __sc_err = __sc_0; \
339 } \
340 if (__sc_err & 0x10000000) \
341 { \
342 errno = __sc_ret; \
343 __sc_ret = -1; \
344 } \
345 return (type) __sc_ret
346
347#define __sc_loadargs_0(name, dummy...) \
348 __sc_0 = __NR_##name
349#define __sc_loadargs_1(name, arg1) \
350 __sc_loadargs_0(name); \
351 __sc_3 = (unsigned long) (arg1)
352#define __sc_loadargs_2(name, arg1, arg2) \
353 __sc_loadargs_1(name, arg1); \
354 __sc_4 = (unsigned long) (arg2)
355#define __sc_loadargs_3(name, arg1, arg2, arg3) \
356 __sc_loadargs_2(name, arg1, arg2); \
357 __sc_5 = (unsigned long) (arg3)
358#define __sc_loadargs_4(name, arg1, arg2, arg3, arg4) \
359 __sc_loadargs_3(name, arg1, arg2, arg3); \
360 __sc_6 = (unsigned long) (arg4)
361#define __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5) \
362 __sc_loadargs_4(name, arg1, arg2, arg3, arg4); \
363 __sc_7 = (unsigned long) (arg5)
364#define __sc_loadargs_6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
365 __sc_loadargs_5(name, arg1, arg2, arg3, arg4, arg5); \
366 __sc_8 = (unsigned long) (arg6)
367
368#define __sc_asm_input_0 "0" (__sc_0)
369#define __sc_asm_input_1 __sc_asm_input_0, "1" (__sc_3)
370#define __sc_asm_input_2 __sc_asm_input_1, "2" (__sc_4)
371#define __sc_asm_input_3 __sc_asm_input_2, "3" (__sc_5)
372#define __sc_asm_input_4 __sc_asm_input_3, "4" (__sc_6)
373#define __sc_asm_input_5 __sc_asm_input_4, "5" (__sc_7)
374#define __sc_asm_input_6 __sc_asm_input_5, "6" (__sc_8)
375
376#define _syscall0(type,name) \
377type name(void) \
378{ \
379 __syscall_nr(0, type, name); \
380}
381
382#define _syscall1(type,name,type1,arg1) \
383type name(type1 arg1) \
384{ \
385 __syscall_nr(1, type, name, arg1); \
386}
387
388#define _syscall2(type,name,type1,arg1,type2,arg2) \
389type name(type1 arg1, type2 arg2) \
390{ \
391 __syscall_nr(2, type, name, arg1, arg2); \
392}
393
394#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
395type name(type1 arg1, type2 arg2, type3 arg3) \
396{ \
397 __syscall_nr(3, type, name, arg1, arg2, arg3); \
398}
399
400#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
401type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
402{ \
403 __syscall_nr(4, type, name, arg1, arg2, arg3, arg4); \
404}
405
406#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
407type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
408{ \
409 __syscall_nr(5, type, name, arg1, arg2, arg3, arg4, arg5); \
410}
411#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
412type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
413{ \
414 __syscall_nr(6, type, name, arg1, arg2, arg3, arg4, arg5, arg6); \
415}
416
417#ifdef __KERNEL__
418
419#include <linux/config.h>
420#include <linux/types.h>
421#include <linux/compiler.h>
422#include <linux/linkage.h>
423
424#define __ARCH_WANT_IPC_PARSE_VERSION
425#define __ARCH_WANT_OLD_READDIR
426#define __ARCH_WANT_STAT64
427#define __ARCH_WANT_SYS_ALARM
428#define __ARCH_WANT_SYS_GETHOSTNAME
429#define __ARCH_WANT_SYS_PAUSE
430#define __ARCH_WANT_SYS_SGETMASK
431#define __ARCH_WANT_SYS_SIGNAL
432#define __ARCH_WANT_SYS_TIME
433#define __ARCH_WANT_SYS_UTIME
434#define __ARCH_WANT_SYS_WAITPID
435#define __ARCH_WANT_SYS_SOCKETCALL
436#define __ARCH_WANT_SYS_FADVISE64
437#define __ARCH_WANT_SYS_GETPGRP
438#define __ARCH_WANT_SYS_LLSEEK
439#define __ARCH_WANT_SYS_NICE
440#define __ARCH_WANT_SYS_OLD_GETRLIMIT
441#define __ARCH_WANT_SYS_OLDUMOUNT
442#define __ARCH_WANT_SYS_SIGPENDING
443#define __ARCH_WANT_SYS_SIGPROCMASK
444#define __ARCH_WANT_SYS_RT_SIGACTION
445#ifdef CONFIG_PPC32
446#define __ARCH_WANT_OLD_STAT
447#endif
448#ifdef CONFIG_PPC64
449#define __ARCH_WANT_COMPAT_SYS_TIME
450#endif
451
452/*
453 * System call prototypes.
454 */
455#ifdef __KERNEL_SYSCALLS__
456extern pid_t setsid(void);
457extern int write(int fd, const char *buf, off_t count);
458extern int read(int fd, char *buf, off_t count);
459extern off_t lseek(int fd, off_t offset, int count);
460extern int dup(int fd);
461extern int execve(const char *file, char **argv, char **envp);
462extern int open(const char *file, int flag, int mode);
463extern int close(int fd);
464extern pid_t waitpid(pid_t pid, int *wait_stat, int options);
465#endif /* __KERNEL_SYSCALLS__ */
466
467/*
468 * Functions that implement syscalls.
469 */
470unsigned long sys_mmap(unsigned long addr, size_t len, unsigned long prot,
471 unsigned long flags, unsigned long fd, off_t offset);
472unsigned long sys_mmap2(unsigned long addr, size_t len,
473 unsigned long prot, unsigned long flags,
474 unsigned long fd, unsigned long pgoff);
475struct pt_regs;
476int sys_execve(unsigned long a0, unsigned long a1, unsigned long a2,
477 unsigned long a3, unsigned long a4, unsigned long a5,
478 struct pt_regs *regs);
479int sys_clone(unsigned long clone_flags, unsigned long usp,
480 int __user *parent_tidp, void __user *child_threadptr,
481 int __user *child_tidp, int p6, struct pt_regs *regs);
482int sys_fork(unsigned long p1, unsigned long p2, unsigned long p3,
483 unsigned long p4, unsigned long p5, unsigned long p6,
484 struct pt_regs *regs);
485int sys_vfork(unsigned long p1, unsigned long p2, unsigned long p3,
486 unsigned long p4, unsigned long p5, unsigned long p6,
487 struct pt_regs *regs);
488int sys_pipe(int __user *fildes);
489struct sigaction;
490long sys_rt_sigaction(int sig, const struct sigaction __user *act,
491 struct sigaction __user *oact, size_t sigsetsize);
492
493/*
494 * "Conditional" syscalls
495 *
496 * What we want is __attribute__((weak,alias("sys_ni_syscall"))),
497 * but it doesn't work on all toolchains, so we just do it by hand
498 */
499#ifdef CONFIG_PPC32
500#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")
501#else
502#define cond_syscall(x) asm(".weak\t." #x "\n\t.set\t." #x ",.sys_ni_syscall")
503#endif
504
505#endif /* __KERNEL__ */
506
507#endif /* __ASSEMBLY__ */
508
509#endif /* _ASM_PPC_UNISTD_H_ */
diff --git a/include/asm-powerpc/vdso.h b/include/asm-powerpc/vdso.h
new file mode 100644
index 000000000000..b9f9118b1607
--- /dev/null
+++ b/include/asm-powerpc/vdso.h
@@ -0,0 +1,83 @@
1#ifndef __PPC64_VDSO_H__
2#define __PPC64_VDSO_H__
3
4#ifdef __KERNEL__
5
6/* Default link addresses for the vDSOs */
7#define VDSO32_LBASE 0x100000
8#define VDSO64_LBASE 0x100000
9
10/* Default map addresses */
11#define VDSO32_MBASE VDSO32_LBASE
12#define VDSO64_MBASE VDSO64_LBASE
13
14#define VDSO_VERSION_STRING LINUX_2.6.15
15
16/* Define if 64 bits VDSO has procedure descriptors */
17#undef VDS64_HAS_DESCRIPTORS
18
19#ifndef __ASSEMBLY__
20
21extern unsigned int vdso64_pages;
22extern unsigned int vdso32_pages;
23
24/* Offsets relative to thread->vdso_base */
25extern unsigned long vdso64_rt_sigtramp;
26extern unsigned long vdso32_sigtramp;
27extern unsigned long vdso32_rt_sigtramp;
28
29extern void vdso_init(void);
30
31#else /* __ASSEMBLY__ */
32
33#ifdef __VDSO64__
34#ifdef VDS64_HAS_DESCRIPTORS
35#define V_FUNCTION_BEGIN(name) \
36 .globl name; \
37 .section ".opd","a"; \
38 .align 3; \
39 name: \
40 .quad .name,.TOC.@tocbase,0; \
41 .previous; \
42 .globl .name; \
43 .type .name,@function; \
44 .name: \
45
46#define V_FUNCTION_END(name) \
47 .size .name,.-.name;
48
49#define V_LOCAL_FUNC(name) (.name)
50
51#else /* VDS64_HAS_DESCRIPTORS */
52
53#define V_FUNCTION_BEGIN(name) \
54 .globl name; \
55 name: \
56
57#define V_FUNCTION_END(name) \
58 .size name,.-name;
59
60#define V_LOCAL_FUNC(name) (name)
61
62#endif /* VDS64_HAS_DESCRIPTORS */
63#endif /* __VDSO64__ */
64
65#ifdef __VDSO32__
66
67#define V_FUNCTION_BEGIN(name) \
68 .globl name; \
69 .type name,@function; \
70 name: \
71
72#define V_FUNCTION_END(name) \
73 .size name,.-name;
74
75#define V_LOCAL_FUNC(name) (name)
76
77#endif /* __VDSO32__ */
78
79#endif /* __ASSEMBLY__ */
80
81#endif /* __KERNEL__ */
82
83#endif /* __PPC64_VDSO_H__ */
diff --git a/include/asm-powerpc/vdso_datapage.h b/include/asm-powerpc/vdso_datapage.h
new file mode 100644
index 000000000000..411832d5bbdb
--- /dev/null
+++ b/include/asm-powerpc/vdso_datapage.h
@@ -0,0 +1,108 @@
1#ifndef _VDSO_DATAPAGE_H
2#define _VDSO_DATAPAGE_H
3
4/*
5 * Copyright (C) 2002 Peter Bergner <bergner@vnet.ibm.com>, IBM
6 * Copyright (C) 2005 Benjamin Herrenschmidy <benh@kernel.crashing.org>,
7 * IBM Corp.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
14
15
16/*
17 * Note about this structure:
18 *
19 * This structure was historically called systemcfg and exposed to
20 * userland via /proc/ppc64/systemcfg. Unfortunately, this became an
21 * ABI issue as some proprietary software started relying on being able
22 * to mmap() it, thus we have to keep the base layout at least for a
23 * few kernel versions.
24 *
25 * However, since ppc32 doesn't suffer from this backward handicap,
26 * a simpler version of the data structure is used there with only the
27 * fields actually used by the vDSO.
28 *
29 */
30
31/*
32 * If the major version changes we are incompatible.
33 * Minor version changes are a hint.
34 */
35#define SYSTEMCFG_MAJOR 1
36#define SYSTEMCFG_MINOR 1
37
38#ifndef __ASSEMBLY__
39
40#include <linux/unistd.h>
41
42#define SYSCALL_MAP_SIZE ((__NR_syscalls + 31) / 32)
43
44/*
45 * So here is the ppc64 backward compatible version
46 */
47
48#ifdef CONFIG_PPC64
49
50struct vdso_data {
51 __u8 eye_catcher[16]; /* Eyecatcher: SYSTEMCFG:PPC64 0x00 */
52 struct { /* Systemcfg version numbers */
53 __u32 major; /* Major number 0x10 */
54 __u32 minor; /* Minor number 0x14 */
55 } version;
56
57 __u32 platform; /* Platform flags 0x18 */
58 __u32 processor; /* Processor type 0x1C */
59 __u64 processorCount; /* # of physical processors 0x20 */
60 __u64 physicalMemorySize; /* Size of real memory(B) 0x28 */
61 __u64 tb_orig_stamp; /* Timebase at boot 0x30 */
62 __u64 tb_ticks_per_sec; /* Timebase tics / sec 0x38 */
63 __u64 tb_to_xs; /* Inverse of TB to 2^20 0x40 */
64 __u64 stamp_xsec; /* 0x48 */
65 __u64 tb_update_count; /* Timebase atomicity ctr 0x50 */
66 __u32 tz_minuteswest; /* Minutes west of Greenwich 0x58 */
67 __u32 tz_dsttime; /* Type of dst correction 0x5C */
68 __u32 dcache_size; /* L1 d-cache size 0x60 */
69 __u32 dcache_line_size; /* L1 d-cache line size 0x64 */
70 __u32 icache_size; /* L1 i-cache size 0x68 */
71 __u32 icache_line_size; /* L1 i-cache line size 0x6C */
72
73 /* those additional ones don't have to be located anywhere
74 * special as they were not part of the original systemcfg
75 */
76 __s32 wtom_clock_sec; /* Wall to monotonic clock */
77 __s32 wtom_clock_nsec;
78 __u32 syscall_map_64[SYSCALL_MAP_SIZE]; /* map of syscalls */
79 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
80};
81
82#else /* CONFIG_PPC64 */
83
84/*
85 * And here is the simpler 32 bits version
86 */
87struct vdso_data {
88 __u64 tb_orig_stamp; /* Timebase at boot 0x30 */
89 __u64 tb_ticks_per_sec; /* Timebase tics / sec 0x38 */
90 __u64 tb_to_xs; /* Inverse of TB to 2^20 0x40 */
91 __u64 stamp_xsec; /* 0x48 */
92 __u32 tb_update_count; /* Timebase atomicity ctr 0x50 */
93 __u32 tz_minuteswest; /* Minutes west of Greenwich 0x58 */
94 __u32 tz_dsttime; /* Type of dst correction 0x5C */
95 __s32 wtom_clock_sec; /* Wall to monotonic clock */
96 __s32 wtom_clock_nsec;
97 __u32 syscall_map_32[SYSCALL_MAP_SIZE]; /* map of syscalls */
98};
99
100#endif /* CONFIG_PPC64 */
101
102#ifdef __KERNEL__
103extern struct vdso_data *vdso_data;
104#endif
105
106#endif /* __ASSEMBLY__ */
107
108#endif /* _SYSTEMCFG_H */
diff --git a/include/asm-powerpc/vga.h b/include/asm-powerpc/vga.h
new file mode 100644
index 000000000000..f8d350aabf1a
--- /dev/null
+++ b/include/asm-powerpc/vga.h
@@ -0,0 +1,54 @@
1#ifndef _ASM_POWERPC_VGA_H_
2#define _ASM_POWERPC_VGA_H_
3
4#ifdef __KERNEL__
5
6/*
7 * Access to VGA videoram
8 *
9 * (c) 1998 Martin Mares <mj@ucw.cz>
10 */
11
12
13#include <asm/io.h>
14
15#include <linux/config.h>
16
17#if defined(CONFIG_VGA_CONSOLE) || defined(CONFIG_MDA_CONSOLE)
18
19#define VT_BUF_HAVE_RW
20/*
21 * These are only needed for supporting VGA or MDA text mode, which use little
22 * endian byte ordering.
23 * In other cases, we can optimize by using native byte ordering and
24 * <linux/vt_buffer.h> has already done the right job for us.
25 */
26
27static inline void scr_writew(u16 val, volatile u16 *addr)
28{
29 st_le16(addr, val);
30}
31
32static inline u16 scr_readw(volatile const u16 *addr)
33{
34 return ld_le16(addr);
35}
36
37#define VT_BUF_HAVE_MEMCPYW
38#define scr_memcpyw memcpy
39
40#endif /* !CONFIG_VGA_CONSOLE && !CONFIG_MDA_CONSOLE */
41
42extern unsigned long vgacon_remap_base;
43
44#ifdef __powerpc64__
45#define VGA_MAP_MEM(x) ((unsigned long) ioremap((x), 0))
46#else
47#define VGA_MAP_MEM(x) (x + vgacon_remap_base)
48#endif
49
50#define vga_readb(x) (*(x))
51#define vga_writeb(x,y) (*(y) = (x))
52
53#endif /* __KERNEL__ */
54#endif /* _ASM_POWERPC_VGA_H_ */
diff --git a/include/asm-powerpc/vio.h b/include/asm-powerpc/vio.h
new file mode 100644
index 000000000000..e0ccf108277c
--- /dev/null
+++ b/include/asm-powerpc/vio.h
@@ -0,0 +1,106 @@
1/*
2 * IBM PowerPC Virtual I/O Infrastructure Support.
3 *
4 * Copyright (c) 2003 IBM Corp.
5 * Dave Engebretsen engebret@us.ibm.com
6 * Santiago Leon santil@us.ibm.com
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
12 */
13
14#ifndef _ASM_POWERPC_VIO_H
15#define _ASM_POWERPC_VIO_H
16
17#include <linux/config.h>
18#include <linux/init.h>
19#include <linux/errno.h>
20#include <linux/device.h>
21#include <linux/dma-mapping.h>
22#include <linux/mod_devicetable.h>
23
24#include <asm/hvcall.h>
25#include <asm/scatterlist.h>
26
27/*
28 * Architecture-specific constants for drivers to
29 * extract attributes of the device using vio_get_attribute()
30 */
31#define VETH_MAC_ADDR "local-mac-address"
32#define VETH_MCAST_FILTER_SIZE "ibm,mac-address-filters"
33
34/* End architecture-specific constants */
35
36#define h_vio_signal(ua, mode) \
37 plpar_hcall_norets(H_VIO_SIGNAL, ua, mode)
38
39#define VIO_IRQ_DISABLE 0UL
40#define VIO_IRQ_ENABLE 1UL
41
42struct iommu_table;
43
44/*
45 * The vio_dev structure is used to describe virtual I/O devices.
46 */
47struct vio_dev {
48 struct iommu_table *iommu_table; /* vio_map_* uses this */
49 char *name;
50 char *type;
51 uint32_t unit_address;
52 unsigned int irq;
53 struct device dev;
54};
55
56struct vio_driver {
57 struct list_head node;
58 const struct vio_device_id *id_table;
59 int (*probe)(struct vio_dev *dev, const struct vio_device_id *id);
60 int (*remove)(struct vio_dev *dev);
61 void (*shutdown)(struct vio_dev *dev);
62 unsigned long driver_data;
63 struct device_driver driver;
64};
65
66struct vio_bus_ops {
67 int (*match)(const struct vio_device_id *id, const struct vio_dev *dev);
68 void (*unregister_device)(struct vio_dev *);
69 void (*release_device)(struct device *);
70};
71
72extern struct dma_mapping_ops vio_dma_ops;
73extern struct bus_type vio_bus_type;
74extern struct vio_dev vio_bus_device;
75
76extern int vio_register_driver(struct vio_driver *drv);
77extern void vio_unregister_driver(struct vio_driver *drv);
78
79extern struct vio_dev * __devinit vio_register_device(struct vio_dev *viodev);
80extern void __devinit vio_unregister_device(struct vio_dev *dev);
81
82extern int vio_bus_init(struct vio_bus_ops *);
83
84#ifdef CONFIG_PPC_PSERIES
85struct device_node;
86
87extern struct vio_dev * __devinit vio_register_device_node(
88 struct device_node *node_vdev);
89extern struct vio_dev *vio_find_node(struct device_node *vnode);
90extern const void *vio_get_attribute(struct vio_dev *vdev, void *which,
91 int *length);
92extern int vio_enable_interrupts(struct vio_dev *dev);
93extern int vio_disable_interrupts(struct vio_dev *dev);
94#endif
95
96static inline struct vio_driver *to_vio_driver(struct device_driver *drv)
97{
98 return container_of(drv, struct vio_driver, driver);
99}
100
101static inline struct vio_dev *to_vio_dev(struct device *dev)
102{
103 return container_of(dev, struct vio_dev, dev);
104}
105
106#endif /* _ASM_POWERPC_VIO_H */
diff --git a/include/asm-powerpc/xmon.h b/include/asm-powerpc/xmon.h
new file mode 100644
index 000000000000..43f7129984c7
--- /dev/null
+++ b/include/asm-powerpc/xmon.h
@@ -0,0 +1,12 @@
1#ifndef __PPC_XMON_H
2#define __PPC_XMON_H
3#ifdef __KERNEL__
4
5struct pt_regs;
6
7extern int xmon(struct pt_regs *excp);
8extern void xmon_printf(const char *fmt, ...);
9extern void xmon_init(int);
10
11#endif
12#endif